refactor(cli): exclude tmux context and source guard
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
# Test-only composition: the model attempts one `write` into a staging-shaped
|
||||
# git fixture, so the guard's denial is observed through the real Loader and app.
|
||||
- id: source-guard-mock-llm
|
||||
name: './mock-llm.ts'
|
||||
|
||||
# Managed child-process groups for the bash executor (spawn/kill/output plumbing).
|
||||
- id: subprocess
|
||||
name: '@deepseek-ai/dsh-subprocess-local'
|
||||
|
||||
- id: bash
|
||||
name: '@deepseek-ai/dsh-bash-local'
|
||||
|
||||
- id: fs
|
||||
name: '@deepseek-ai/dsh-fs-local'
|
||||
|
||||
# Read-before-edit policy: without it the write would resolve `createIfAbsent`
|
||||
# and the transcript would not show the guard as the sole reason for refusal.
|
||||
- id: fs-policy
|
||||
name: '@deepseek-ai/dsh-fs-policy'
|
||||
|
||||
- id: tool-fs
|
||||
name: '@deepseek-ai/dsh-tool-fs'
|
||||
|
||||
# Mounts the guard with `protectedCheckout` resolved against the process cwd, so
|
||||
# it arms for the staging fixture the smoke builds there rather than for the
|
||||
# checkout running the test (the config default is this module's own location).
|
||||
- id: source-guard-fixture
|
||||
name: './mount-guard.ts'
|
||||
|
||||
- id: cli-agent
|
||||
name: '@deepseek-ai/dsh-cli-demo'
|
||||
config:
|
||||
provider: source-guard-mock
|
||||
model: source-guard-mock
|
||||
persona: 'Test the source guard.'
|
||||
persistenceRoot: './.sessions'
|
||||
persistenceCompression: none
|
||||
workspaceContext: false
|
||||
@@ -1,43 +0,0 @@
|
||||
import { resolve } from 'node:path'
|
||||
import type { Context } from 'cordis'
|
||||
import { CallId, LlmAdapter, type GenerateOptions, type StreamChunk } from '@deepseek-ai/dsh-llm'
|
||||
|
||||
/** The staged file the smoke builds in the process cwd; the guard must refuse to write it. */
|
||||
const TARGET = resolve('staging/guarded.ts')
|
||||
|
||||
/**
|
||||
* Two-step adapter for the source-guard Loader fixture: the first step calls
|
||||
* `write` on the staged file, the second closes the turn once a tool result has
|
||||
* come back, so the transcript records what the model received.
|
||||
*/
|
||||
class SourceGuardMockAdapter extends LlmAdapter {
|
||||
async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
|
||||
const alreadyCalled = options.messages.some(message => message.content.some(
|
||||
block => block.type === 'tool-result',
|
||||
))
|
||||
if (alreadyCalled) {
|
||||
const text = 'denied as expected'
|
||||
yield { type: 'block-start', index: 0, blockType: 'text' }
|
||||
yield { type: 'text-delta', index: 0, text }
|
||||
yield { type: 'block-end', index: 0, block: { type: 'text', text } }
|
||||
yield { type: 'usage', usage: { inputTokens: 1, outputTokens: 1 } }
|
||||
yield { type: 'finish', reason: { kind: 'stop' } }
|
||||
return
|
||||
}
|
||||
const callId = CallId('source-guard-write')
|
||||
const args = JSON.stringify({ file_path: TARGET, content: 'edited\n' })
|
||||
yield { type: 'block-start', index: 0, blockType: 'tool-call' }
|
||||
yield { type: 'tool-call-delta', index: 0, id: callId, name: 'write', argumentsDelta: args }
|
||||
yield { type: 'block-end', index: 0, block: { type: 'tool-call', id: callId, name: 'write', arguments: args } }
|
||||
yield { type: 'usage', usage: { inputTokens: 1, outputTokens: 1 } }
|
||||
yield { type: 'finish', reason: { kind: 'tool-calls' } }
|
||||
}
|
||||
}
|
||||
|
||||
export const name = 'source-guard-mock-llm'
|
||||
export const inject = ['llm']
|
||||
|
||||
/** Register the test-only `source-guard-mock` adapter. */
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.llm.registerAdapter(['source-guard-mock'], new SourceGuardMockAdapter())
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { resolve } from 'node:path'
|
||||
import type { Context } from 'cordis'
|
||||
import * as SourceGuard from '@deepseek-ai/dsh-source-guard'
|
||||
|
||||
export const name = 'source-guard-fixture'
|
||||
|
||||
/**
|
||||
* Mount the real guard against the staging fixture in the process cwd. The
|
||||
* checkout under protection is a runtime fact of the isolated smoke directory,
|
||||
* which no static config value can name.
|
||||
*/
|
||||
export async function apply(ctx: Context): Promise<void> {
|
||||
await ctx.plugin(SourceGuard, { protectedCheckout: resolve('staging/guard-anchor.ts') })
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/** Test driver that sends two turns through one Headless Loader composition. */
|
||||
|
||||
import { boot, resolveConfigPath } from '@deepseek-ai/dsh-app-boot'
|
||||
import { runOneShot } from '@deepseek-ai/dsh-cli-demo/src/cli.ts'
|
||||
|
||||
const configPath = process.argv[2]
|
||||
if (configPath === undefined) throw new Error('tmux-context driver requires a config path')
|
||||
|
||||
const ctx = await boot('tmux-context-e2e', resolveConfigPath(configPath, undefined))
|
||||
try {
|
||||
await runOneShot(ctx, { task: 'first' })
|
||||
await runOneShot(ctx, { task: 'second' })
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import type { Context } from 'cordis'
|
||||
import { BashExecutor } from '@deepseek-ai/dsh-bash'
|
||||
import type { BashExecRequest, BashExecSpec, BashProcess, BashRunResult } from '@deepseek-ai/dsh-bash'
|
||||
|
||||
/**
|
||||
* Deterministic `ctx.bash` for the tmux-context Loader fixture: any command
|
||||
* (the plugin's `tmux display-message`) returns a fixed tab-delimited reading,
|
||||
* so the injected tmux location is stable without a real tmux server. `start()`
|
||||
* throws — tmux-context must never spawn a background process.
|
||||
*/
|
||||
class TmuxMockBash extends BashExecutor {
|
||||
override resolve(request: BashExecRequest): BashExecSpec {
|
||||
return {
|
||||
command: request.command,
|
||||
workdir: request.workdir ?? process.cwd(),
|
||||
timeoutMs: request.timeoutMs ?? 60_000,
|
||||
stdoutMaxBytes: request.stdoutMaxBytes ?? 64_000,
|
||||
signal: request.signal,
|
||||
sandboxPolicy: request.sandboxPolicy,
|
||||
}
|
||||
}
|
||||
|
||||
override run(_spec: BashExecSpec): Promise<BashRunResult> {
|
||||
const line = ['work', '0', 'editor', '1', '%3', '1', '1', 'a1b2,80x24,0,0,4'].join('\\t')
|
||||
return Promise.resolve({
|
||||
exitCode: 0,
|
||||
signal: null,
|
||||
timedOut: false,
|
||||
aborted: false,
|
||||
timeoutMs: 60_000,
|
||||
stdout: { text: `${line}\n`, truncated: false },
|
||||
stderr: { text: '', truncated: false },
|
||||
})
|
||||
}
|
||||
|
||||
override start(): BashProcess {
|
||||
throw new Error('tmux-context must never start a background task')
|
||||
}
|
||||
}
|
||||
|
||||
export const name = 'tmux-context-mock-bash'
|
||||
|
||||
/** Register the deterministic `ctx.bash` executor for the fixture. */
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.plugin(TmuxMockBash)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import type { Context } from 'cordis'
|
||||
import { LlmAdapter, type StreamChunk } from '@deepseek-ai/dsh-llm'
|
||||
|
||||
/** Deterministic one-step adapter for the tmux-context Loader fixture. */
|
||||
class TmuxContextMockAdapter extends LlmAdapter {
|
||||
async * stream(): AsyncIterable<StreamChunk> {
|
||||
const text = 'tmux context sampled'
|
||||
yield { type: 'block-start', index: 0, blockType: 'text' }
|
||||
yield { type: 'text-delta', index: 0, text }
|
||||
yield { type: 'block-end', index: 0, block: { type: 'text', text } }
|
||||
yield { type: 'usage', usage: { inputTokens: 1, outputTokens: 1 } }
|
||||
yield { type: 'finish', reason: { kind: 'stop' } }
|
||||
}
|
||||
}
|
||||
|
||||
export const name = 'tmux-context-mock-llm'
|
||||
export const inject = ['llm']
|
||||
|
||||
/** Register the test-only `tmux-context-mock` adapter. */
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.llm.registerAdapter(['tmux-context-mock'], new TmuxContextMockAdapter())
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
# Test-only composition: keep tmux-context opt-in while exercising its real Loader/app path.
|
||||
# A deterministic mock ctx.bash returns a fixed tmux reading, so the injected location
|
||||
# is stable without a real tmux server on the test host.
|
||||
- id: tmux-context-mock-llm
|
||||
name: './tmux-context-mock-llm.ts'
|
||||
|
||||
- id: bash
|
||||
name: './tmux-context-mock-bash.ts'
|
||||
|
||||
- id: tmux-context
|
||||
name: '@deepseek-ai/dsh-tmux-context'
|
||||
|
||||
- id: cli-agent
|
||||
name: '@deepseek-ai/dsh-cli-demo'
|
||||
config:
|
||||
provider: tmux-context-mock
|
||||
model: tmux-context-mock
|
||||
persona: 'Test the tmux-context plugin.'
|
||||
persistenceRoot: './.sessions'
|
||||
persistenceCompression: 'none'
|
||||
workspaceContext: false
|
||||
Reference in New Issue
Block a user