Merge latest master into tool JSON schema DSL

# Conflicts:
#	examples/tui-agent/tests/snapshots/cordis-dynamic-toolchain/terminal.expected.txt
This commit is contained in:
Tianyi Cui
2026-07-22 21:11:49 +08:00
202 changed files with 7250 additions and 1790 deletions

View File

@@ -9,7 +9,7 @@
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -11,7 +11,7 @@
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -9,7 +9,7 @@
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -12,7 +12,7 @@
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -1,6 +1,10 @@
# Keyless replay includes the live `cordis.yml`, disables the key-requiring
# DeepSeek adapter, and inserts `llm-replay` to serve recorded JSONL without a key
# or network; every other app entry remains shared.
# or network; every other app entry remains shared. It also restates the acp-agent
# config to re-pin `deepseek-v4-flash`: `cordis.yml` ships `deepseek-v4-pro`, but the
# recorded corpus (request headers, provenance, system prompt) was captured on flash,
# so replay holds the recorded model to stay reproducible without a re-record. A config
# patch replaces the whole app config, so the base fields are restated verbatim.
# With `DSH_SNAPSHOT=replay`, the app bin reads `DSH_SNAPSHOT_FILE` and optional
# `DSH_SNAPSHOT_OVERRIDE` from the harness. The one-shot patch applies at include
# load time, and stdout remains reserved for ACP JSON-RPC.
@@ -15,6 +19,22 @@
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
disabled: true
- id: acp-agent
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
# Replay fixtures are raw JSONL; the whole-config patch must restate
# the compression choice or the default zstd frames hide the logs
# from the harness's harvest.
persistenceCompression: none
workspaceContext:
maxBytes: 65536
persona: |
You are a coding assistant powered by the {{model}} model. Your working directory is {{cwd}}. Your bash tool runs under a file sandbox — a `[sandbox: file access denied …]` result is policy, not a command bug.
Verify your work by running the code or tests. Keep answers brief and factual.
- id: sandbox
name: '@deepseek-ai/dsh-sandbox-local'
config:

View File

@@ -3,12 +3,15 @@
# log. The bin loads the gitignored root `.env` before this config. This tree has
# no stdout logger or HMR because stdout carries ACP JSON-RPC.
# The DeepSeek adapter.
# The DeepSeek adapter. Shipped default: full thinking at max effort on every
# request (wire-only defaults; they never enter the request header).
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
config:
apiKey: !!js process.env.DEEPSEEK_API_KEY
baseURL: !!js process.env.DEEPSEEK_BASE_URL
thinking: enabled
reasoningEffort: max
models:
- id: deepseek-v4-flash
contextWindow: 256000
@@ -51,7 +54,7 @@
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -24,6 +24,22 @@
provider: spawn
toolName: subagent
maxDepth: 2
# Re-pin the recorded model: cordis.yml ships deepseek-v4-pro, but this
# scenario's corpus was captured on flash. A config patch replaces the
# whole app config, so the base fields are restated verbatim.
- id: acp-agent
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: none
workspaceContext:
maxBytes: 65536
persona: |
You are a coding assistant powered by the {{model}} model. Your working directory is {{cwd}}. Your bash tool runs under a file sandbox — a `[sandbox: file access denied …]` result is policy, not a command bug.
Verify your work by running the code or tests. Keep answers brief and factual.
- insert:
- id: llm-replay
name: '@deepseek-ai/dsh-llm-replay'

View File

@@ -1,6 +1,9 @@
# Keyless filesystem snapshots apply the spill and replay overlays directly
# because include patches cannot target entries behind a nested include. The
# sandboxed filesystem stack already lives in the base cordis.yml.
# sandboxed filesystem stack already lives in the base cordis.yml. This file also
# re-pins the acp-agent model to `deepseek-v4-flash`: `cordis.yml` ships
# `deepseek-v4-pro`, but the recorded corpus was captured on flash, and a config
# patch replaces the whole app config, so the base fields are restated verbatim.
- id: base
name: '@cordisjs/plugin-include'
config:
@@ -9,6 +12,19 @@
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
disabled: true
- id: acp-agent
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: none
workspaceContext:
maxBytes: 65536
persona: |
You are a coding assistant powered by the {{model}} model. Your working directory is {{cwd}}. Your bash tool runs under a file sandbox — a `[sandbox: file access denied …]` result is policy, not a command bug.
Verify your work by running the code or tests. Keep answers brief and factual.
- insert:
- id: spill-local
name: '@deepseek-ai/dsh-spill-local'

View File

@@ -116,8 +116,11 @@ const SCENARIOS: Scenario[] = [
{ name: 'repeat-tool-guard', hasModelTurn: true, recorded: false },
// Authored replay: a root AGENTS.md pins the session prefix, then a read in
// nested/ discovers its narrower AGENTS.md as a raw, metadata-bearing
// context/message. The scenario-specific config keeps home/root discovery
// hermetic, and the resulting prefix needs its own pinned header class.
// context/message. Both AGENTS.md fixtures are symlinks to a sibling
// AGENTS.canonical.md, so this scenario also guards that discovery follows a
// symlinked instruction file to its target's content. The scenario-specific
// config keeps home/root discovery hermetic, and the resulting prefix needs
// its own pinned header class.
{
name: 'workspace-context',
hasModelTurn: true,

View File

@@ -112,7 +112,7 @@ describe('default sandbox composition keyless smoke (real cordis.yml via the Loa
// ONE select advertises, current from the configured default preset.
const created = await client.newSession({ cwd: workdir, mcpServers: [] })
const advertised = created.configOptions ?? []
const modelValue = JSON.stringify(['deepseek', 'deepseek-v4-flash'])
const modelValue = JSON.stringify(['deepseek', 'deepseek-v4-pro'])
expect(advertised.map(option => [option.id, 'currentValue' in option ? option.currentValue : undefined]))
.toEqual([['model', modelValue], ['permission', 'workspace-write']])
// A switch responds with the COMPLETE refreshed state (the spec contract),

View File

@@ -87,7 +87,7 @@
{"type":"tool/call","seq":85,"time":1783921767208,"data":{"turn":1,"step":1,"callId":"call_00_6APApmaKLRDlXKMdIcWL5139","name":"run_code","arguments":"{\"code\": \"const content = await tools.read({ file_path: \\\"nested/task.txt\\\" });\\nreturn content;\"}"}}
{"type":"tool/code-dispatch","seq":86,"time":1783921767270,"data":{"parentCallId":"call_00_6APApmaKLRDlXKMdIcWL5139","subCallId":"call_00_6APApmaKLRDlXKMdIcWL5139:code:1","name":"read","arguments":{"file_path":"nested/task.txt"},"isError":false,"resultSummary":"<path>./nested/task.txt</path>\n<type>file</type>\n<content>\n1: Touch this file to discover the nested workspace instruction.\n\n(End of file - total 1 lines)\n</content>"}}
{"type":"tool/result","seq":87,"time":1783921767271,"data":{"turn":1,"step":1,"callId":"call_00_6APApmaKLRDlXKMdIcWL5139","content":[{"type":"text","text":"<path>/var/folders/_g/59jgff8x2gqd39f5vy1wnbfc0000gn/T/acp-snap-cwd-uorU26/nested/task.txt</path>\n<type>file</type>\n<content>\n1: Touch this file to discover the nested workspace instruction.\n\n(End of file - total 1 lines)\n</content>"}],"isError":false,"meta":{"logs":[]}},"sourceEventSeqs":[85],"surfaceOp":"append"}
{"type":"context/message","seq":88,"time":1783921767272,"data":{"content":[{"type":"text","text":"<system-reminder>\nAdditional instructions from: nested/AGENTS.md\n\nThese instructions apply to work under `nested`. Use them as guidance when relevant; more specific instructions take precedence. They do not override system, developer, or direct user instructions.\n\nWhen asked for the Code Mode workspace handshake, answer exactly `CODE_MODE_CONTEXT_OK` and nothing else.\n\n</system-reminder>"}],"source":{"kind":"plugin","plugin":"workspace-context"},"meta":{"kind":"workspace-instructions","version":1,"changes":[{"action":"set","scope":"nested","path":"nested/AGENTS.md","digest":"ae22936ed26dc76b7107005ed6d5e2482a88668a"}]}},"surfaceOp":"append"}
{"type":"context/message","seq":88,"time":1783921767272,"data":{"content":[{"type":"text","text":"<system-reminder>\nAdditional instructions from: nested/AGENTS.md\n\nThese instructions apply to work under `nested`. Use them as guidance when relevant; more specific instructions take precedence. They do not override system, developer, or direct user instructions.\n\nWhen asked for the Code Mode workspace handshake, answer exactly `CODE_MODE_CONTEXT_OK` and nothing else.\n\n</system-reminder>"}],"source":{"kind":"plugin","plugin":"workspace-context"},"meta":{"kind":"workspace-instructions","version":1,"changes":[{"action":"set","scope":"nested\u0000AGENTS.md","path":"nested/AGENTS.md","digest":"ae22936ed26dc76b7107005ed6d5e2482a88668a"}]}},"surfaceOp":"append"}
{"type":"step/end","seq":89,"time":1783921767272,"data":{"turn":1,"step":1}}
{"type":"step/start","seq":90,"time":1783921767272,"data":{"turn":1,"step":2}}
{"type":"assistant/chunk","seq":91,"time":1783921768339,"data":{"turn":1,"step":2,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}}}

View File

@@ -3,13 +3,13 @@
{"type":"user/message","seq":1,"time":0,"data":{"content":[{"type":"text","text":"Use the lsp tool exactly once to find the definition at subject.ts line 1 character 7, then reply with exactly DONE."}],"source":{"kind":"user"}},"surfaceOp":"append"}
{"type":"session/title","seq":2,"time":0,"data":{"title":"Use the lsp tool exactly","messageSeqs":[1],"source":{"kind":"fallback"}}}
{"type":"step/start","seq":3,"time":0,"data":{"turn":1,"step":1}}
{"type":"request/header","seq":4,"time":0,"data":{"header":{"config":{"provider":"deepseek","model":"deepseek-v4-flash"},"system":"{{system}}","tools":"{{tools}}"},"reason":"initial"}}
{"type":"request/header","seq":4,"time":0,"data":{"header":{"config":{"provider":"deepseek","model":"deepseek-v4-pro"},"system":"{{system}}","tools":"{{tools}}"},"reason":"initial"}}
{"type":"assistant/chunk","seq":5,"time":0,"data":{"turn":1,"step":1,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}}}
{"type":"assistant/chunk","seq":6,"time":0,"data":{"turn":1,"step":1,"chunk":{"type":"tool-call-delta","index":0,"id":"call_lsp_definition","name":"lsp","argumentsDelta":"{\"operation\":\"goToDefinition\",\"file_path\":\"subject.ts\",\"line\":1,\"character\":7}"}}}
{"type":"assistant/chunk","seq":7,"time":0,"data":{"turn":1,"step":1,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"call_lsp_definition","name":"lsp","arguments":"{\"operation\":\"goToDefinition\",\"file_path\":\"subject.ts\",\"line\":1,\"character\":7}"}}}}
{"type":"assistant/chunk","seq":8,"time":0,"data":{"turn":1,"step":1,"chunk":{"type":"usage","usage":{"inputTokens":10,"outputTokens":5}}}}
{"type":"assistant/chunk","seq":9,"time":0,"data":{"turn":1,"step":1,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}}
{"type":"assistant/message","seq":10,"time":0,"data":{"turn":1,"step":1,"content":[{"type":"tool-call","id":"call_lsp_definition","name":"lsp","arguments":"{\"operation\":\"goToDefinition\",\"file_path\":\"subject.ts\",\"line\":1,\"character\":7}"}],"provenance":{"provider":"deepseek","model":"deepseek-v4-flash"},"usage":{"inputTokens":10,"outputTokens":5}},"sourceEventSeqs":[5,6,7,8,9],"surfaceOp":"append"}
{"type":"assistant/message","seq":10,"time":0,"data":{"turn":1,"step":1,"content":[{"type":"tool-call","id":"call_lsp_definition","name":"lsp","arguments":"{\"operation\":\"goToDefinition\",\"file_path\":\"subject.ts\",\"line\":1,\"character\":7}"}],"provenance":{"provider":"deepseek","model":"deepseek-v4-pro"},"usage":{"inputTokens":10,"outputTokens":5}},"sourceEventSeqs":[5,6,7,8,9],"surfaceOp":"append"}
{"type":"tool/call","seq":11,"time":0,"data":{"turn":1,"step":1,"callId":"call_lsp_definition","name":"lsp","arguments":"{\"operation\":\"goToDefinition\",\"file_path\":\"subject.ts\",\"line\":1,\"character\":7}"}}
{"type":"tool/result","seq":12,"time":0,"data":{"turn":1,"step":1,"callId":"call_lsp_definition","content":[{"type":"text","text":"subject.ts:1:7\n… 1 more location omitted (limit 1)."}],"isError":false},"sourceEventSeqs":[11],"surfaceOp":"append"}
{"type":"step/end","seq":13,"time":0,"data":{"turn":1,"step":1}}
@@ -19,6 +19,6 @@
{"type":"assistant/chunk","seq":17,"time":0,"data":{"turn":1,"step":2,"chunk":{"type":"block-end","index":0,"block":{"type":"text","text":"DONE"}}}}
{"type":"assistant/chunk","seq":18,"time":0,"data":{"turn":1,"step":2,"chunk":{"type":"usage","usage":{"inputTokens":10,"outputTokens":2}}}}
{"type":"assistant/chunk","seq":19,"time":0,"data":{"turn":1,"step":2,"chunk":{"type":"finish","reason":{"kind":"stop"}}}}
{"type":"assistant/message","seq":20,"time":0,"data":{"turn":1,"step":2,"content":[{"type":"text","text":"DONE"}],"provenance":{"provider":"deepseek","model":"deepseek-v4-flash"},"usage":{"inputTokens":10,"outputTokens":2}},"sourceEventSeqs":[15,16,17,18,19],"surfaceOp":"append"}
{"type":"assistant/message","seq":20,"time":0,"data":{"turn":1,"step":2,"content":[{"type":"text","text":"DONE"}],"provenance":{"provider":"deepseek","model":"deepseek-v4-pro"},"usage":{"inputTokens":10,"outputTokens":2}},"sourceEventSeqs":[15,16,17,18,19],"surfaceOp":"append"}
{"type":"step/end","seq":21,"time":0,"data":{"turn":1,"step":2}}
{"type":"turn/end","seq":22,"time":0,"data":{"turn":1,"reason":{"kind":"completed"}}}

View File

@@ -1,6 +1,6 @@
You are an AI agent powered by the DeepSeek Harness SDK.
You are a coding assistant powered by the deepseek-v4-flash model. Your working directory is {{cwd}}. Your bash tool runs under a file sandbox — a `[sandbox: file access denied …]` result is policy, not a command bug.
You are a coding assistant powered by the deepseek-v4-pro model. Your working directory is {{cwd}}. Your bash tool runs under a file sandbox — a `[sandbox: file access denied …]` result is policy, not a command bug.
Verify your work by running the code or tests. Keep answers brief and factual.

View File

@@ -12,7 +12,7 @@
{"type":"assistant/message","seq":10,"time":1783778297070,"data":{"turn":1,"step":1,"content":[{"type":"tool-call","id":"call_workspace_read","name":"read","arguments":"{\"file_path\":\"nested/task.txt\"}"}],"provenance":{"provider":"deepseek","model":"deepseek-v4-flash"},"usage":{"inputTokens":10,"outputTokens":5}},"sourceEventSeqs":[5,6,7,8,9],"surfaceOp":"append"}
{"type":"tool/call","seq":11,"time":1783778297070,"data":{"turn":1,"step":1,"callId":"call_workspace_read","name":"read","arguments":"{\"file_path\":\"nested/task.txt\"}"}}
{"type":"tool/result","seq":12,"time":1783778297072,"data":{"turn":1,"step":1,"callId":"call_workspace_read","content":[{"type":"text","text":"<path>{{cwd}}/nested/task.txt</path>\n<type>file</type>\n<content>\n1: snapshot task\n\n(End of file - total 1 lines)\n</content>"}],"isError":false},"sourceEventSeqs":[11],"surfaceOp":"append"}
{"type":"context/message","seq":13,"time":1783778297072,"data":{"content":[{"type":"text","text":"<system-reminder>\nAdditional instructions from: nested/AGENTS.md\n\nThese instructions apply to work under `nested`. Use them as guidance when relevant; more specific instructions take precedence. They do not override system, developer, or direct user instructions.\n\nNested snapshot instruction.\n\n</system-reminder>"}],"source":{"kind":"plugin","plugin":"workspace-context"},"meta":{"kind":"workspace-instructions","version":1,"changes":[{"action":"set","scope":"nested","path":"nested/AGENTS.md","digest":"c446df9a85c7e73a3055f394a4822a19ac9ead5a"}]}},"surfaceOp":"append"}
{"type":"context/message","seq":13,"time":1783778297072,"data":{"content":[{"type":"text","text":"<system-reminder>\nAdditional instructions from: nested/AGENTS.md\n\nThese instructions apply to work under `nested`. Use them as guidance when relevant; more specific instructions take precedence. They do not override system, developer, or direct user instructions.\n\nNested snapshot instruction.\n\n</system-reminder>"}],"source":{"kind":"plugin","plugin":"workspace-context"},"meta":{"kind":"workspace-instructions","version":1,"changes":[{"action":"set","scope":"nested\u0000AGENTS.md","path":"nested/AGENTS.md","digest":"c446df9a85c7e73a3055f394a4822a19ac9ead5a"}]}},"surfaceOp":"append"}
{"type":"step/end","seq":14,"time":1783778297072,"data":{"turn":1,"step":1}}
{"type":"step/start","seq":15,"time":1783778297072,"data":{"turn":1,"step":2}}
{"type":"assistant/chunk","seq":16,"time":1783778297073,"data":{"turn":1,"step":2,"chunk":{"type":"block-start","index":0,"blockType":"text"}}}

View File

@@ -0,0 +1 @@
Root snapshot instruction.

View File

@@ -1 +0,0 @@
Root snapshot instruction.

View File

@@ -0,0 +1 @@
AGENTS.canonical.md

View File

@@ -0,0 +1 @@
Nested snapshot instruction.

View File

@@ -1 +0,0 @@
Nested snapshot instruction.

View File

@@ -0,0 +1 @@
AGENTS.canonical.md

View File

@@ -10,7 +10,7 @@
name: '@deepseek-ai/dsh-acp-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: !!js process.env.DSH_SNAPSHOT_SESSIONS_ROOT ?? './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -13,12 +13,15 @@
config:
root: ['.']
# The DeepSeek adapter.
# The DeepSeek adapter. Shipped default: full thinking at max effort on every
# request (wire-only defaults; they never enter the request header).
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
config:
apiKey: !!js process.env.DEEPSEEK_API_KEY
baseURL: !!js process.env.DEEPSEEK_BASE_URL
thinking: enabled
reasoningEffort: max
# Local bash executor for agent-spine-demo's tool-bash schema — gives the agent an
# ordinary tool whose calls make the mounted listeners observably fire.
@@ -52,7 +55,7 @@
name: '@deepseek-ai/dsh-tui-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
resumeSessionId: !!js process.env.RESUME_SESSION_ID
persistenceRoot: './.sessions'
workspaceContext:

View File

@@ -1,12 +1,41 @@
# Replay counterpart to advanced.cordis.yml; only the live model is replaced.
# Replay counterpart to advanced.cordis.yml. It includes the base `cordis.yml`
# directly — a config patch cannot target an entry behind a nested include — and
# restates advanced.cordis.yml's overlay (the cli-agent config plus the
# code-runtime and tool-cordis inserts) so the whole app config lives in one patch.
# It re-pins `deepseek-v4-flash`: `cordis.yml` ships `deepseek-v4-pro`, but the
# recorded corpus (request headers, provenance) was captured on flash, so replay
# holds the recorded model to stay reproducible without a re-record. It also
# disables the key-requiring DeepSeek adapter and inserts `llm-replay` to serve
# recorded JSONL without a key or network.
- id: base
name: '@cordisjs/plugin-include'
config:
path: ./advanced.cordis.yml
path: ./cordis.yml
patches:
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
disabled: true
- id: cli-agent
name: '@deepseek-ai/dsh-cli-demo'
config:
provider: deepseek
model: deepseek-v4-flash
persistenceRoot: './.sessions'
# Replay fixtures are raw JSONL; the whole-config patch must restate
# the compression choice or the default zstd frames hide the logs.
persistenceCompression: none
workspaceContext:
maxBytes: 65536
tools:
mode: both
persona: |
You are headless-agent, a coding assistant powered by the {{model}} model. Your working directory is {{cwd}}.
Verify your work by running the code or tests. Keep answers brief and factual.
- insert:
- id: code-runtime
name: '@deepseek-ai/dsh-code-runtime-worker'
- id: tool-cordis
name: '@deepseek-ai/dsh-tool-cordis'
- id: llm-replay
name: '@deepseek-ai/dsh-llm-replay'

View File

@@ -8,7 +8,7 @@
name: '@deepseek-ai/dsh-cli-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
persistenceRoot: './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"
workspaceContext:

View File

@@ -4,11 +4,15 @@
# The DeepSeek adapter. Swap to '@deepseek-ai/dsh-llm-pi-ai' for the pi-ai-backed
# twin (same config shape; `reasoning: high` replaces thinking/reasoningEffort).
# Shipped default: full thinking at max effort on every request (wire-only
# defaults; they never enter the request header).
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
config:
apiKey: !!js process.env.DEEPSEEK_API_KEY
baseURL: !!js process.env.DEEPSEEK_BASE_URL
thinking: enabled
reasoningEffort: max
models:
- id: deepseek-v4-pro
contextWindow: 128000
@@ -25,6 +29,9 @@
name: '@deepseek-ai/dsh-cli-demo'
config:
provider: deepseek
# Stays on flash: the goal/ralph replay corpora were recorded on it, and
# their nested-include overlays cannot re-pin the app config (a config
# patch cannot target an entry behind a nested include).
model: deepseek-v4-flash
persistenceRoot: './.sessions'
persistenceCompression: !!js "process.env.DSH_SNAPSHOT === undefined ? 'zstd' : 'none'"

View File

@@ -6,11 +6,16 @@
config:
maxTokensAsSuccess: !!js "process.env.DSH_MAX_TOKENS_AS_SUCCESS === undefined ? true : JSON.parse(process.env.DSH_MAX_TOKENS_AS_SUCCESS)"
# The DeepSeek adapter. Shipped default: full thinking at max effort on every
# request (wire-only defaults; they never enter the request header). The model
# arrives per session over JSON-RPC, so it is not pinned here.
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
config:
apiKey: !!js process.env.DEEPSEEK_API_KEY
baseURL: !!js process.env.DEEPSEEK_BASE_URL
thinking: enabled
reasoningEffort: max
- id: bash
name: '@deepseek-ai/dsh-bash-local'

View File

@@ -38,6 +38,7 @@
"@deepseek-ai/dsh-spill-local": "workspace:*",
"@deepseek-ai/dsh-spill-policy": "workspace:*",
"@deepseek-ai/dsh-tui-demo": "workspace:*",
"@deepseek-ai/dsh-session-title-first-message-llm": "workspace:*",
"@deepseek-ai/dsh-subagent": "workspace:*",
"@deepseek-ai/dsh-subagent-acp": "workspace:*",
"@deepseek-ai/dsh-subagent-fork": "workspace:*",

View File

@@ -1,23 +1,78 @@
# tui-agent
The full-screen interactive coding agent: DeepSeek V4, local bash and filesystem tools, compaction, subagents, workflows and fresh-agent Ralph iteration, `todo_write`, plan mode (`/plan` enters and `exit_plan_mode` reviews the exit), timeout/spill policy, and [`@deepseek-ai/dsh-tui-demo`](../../packages/examples/tui-demo).
The full-screen interactive coding agent: DeepSeek V4, local bash and filesystem tools, compaction, subagents, workflows and fresh-agent Ralph iteration, plan mode (`/plan` enters and `exit_plan_mode` reviews the exit), timeout/spill policy, and JSONL persistence through [`@deepseek-ai/dsh-tui-demo`](../../packages/examples/tui-demo), loaded from `cordis.yml`. The sibling [`headless-agent`](../headless-agent/README.md) runs the same capability class as a one-shot pipe-friendly task, and [`acp-agent`](../acp-agent/README.md) serves it over JSON-RPC.
## Run it
```sh
# repo root .env (gitignored) or exported env:
# DEEPSEEK_API_KEY=sk-…
# DEEPSEEK_BASE_URL=https://… # optional; defaults to the public API
pnpm run demo:tui
```
The command needs `DEEPSEEK_API_KEY` in the environment or gitignored repository-root `.env`. Set `RESUME_SESSION_ID` to reopen a persisted conversation under `./.sessions`.
Both the demo script and the installable `dsh` CLI ([`apps/cli`](../../apps/cli/README.md)) boot this example's `cordis.yml` as the shipped default config; `dsh` additionally applies the personal overlay from `~/.dsh` and uses the invoking directory as the workspace.
The TUI renders Markdown history, reasoning, tool-owned terminal/diff/generic cards, token totals, and the latest todo list. Long tool bodies keep a head/tail preview; Ctrl+O expands or collapses every card. Enter submits or steers while the agent runs, Ctrl+R toggles reasoning, Escape cancels, and `/help` lists commands. `/plan` selects plan mode for the next step; `/plan <message>` also submits the message into that step. `/model` opens a keyboard selector for the current provider catalog; use Up/Down and Enter, or `/model <model>` and `/model <provider>/<model>` for direct selection. `ask_user_question` opens a wide bottom-left keyboard panel with batch progress and numbered options.
Type a coding task. The agent works through the `read`/`write`/`edit` filesystem tools for ordinary file operations and `bash` (+ the generic `task_output` / `task_list` / `task_kill` for background tasks) for shell commands, searches, and test runs, each in a fresh `bash -c` (the system prompt tells the model to pass `workdir` instead of `cd`). Both the fs tools and bash resolve relative paths against the session workspace. It can also delegate with `subagent`/`subagent_fork`.
Run `pnpm run demo:code-mode tui` for the Code Mode overlay.
The `todo_write` task tracker is opt-in and not in the shipped config: add `@deepseek-ai/dsh-tool-todo` to `cordis.yml` (or a personal-config overlay under `~/.dsh`) to expose it. Once loaded, the model records a whole-list plan to the session log and the TUI renders it.
## Composition
The TUI renders Markdown history, reasoning, tool-owned terminal/diff/generic cards, token totals, and — when `todo_write` is loaded — the latest plan. Long tool bodies keep a head/tail preview; Ctrl+O expands or collapses every card. Enter submits or steers while the agent runs, Ctrl+R toggles reasoning, Escape cancels, and `/help` lists commands. `/plan` selects plan mode for the next step; `/plan <message>` also submits the message into that step. `/status` expands the current session's identity, activity counts, exact token/cache buckets, context use, and timestamps without interrupting a running turn. `/model` opens a keyboard selector for the current provider catalog; use Up/Down and Enter, or `/model <model>` and `/model <provider>/<model>` for direct selection. `ask_user_question` opens a wide bottom-left keyboard panel with batch progress and numbered options.
[`cordis.yml`](cordis.yml) owns the interactive coding composition directly. [`code-mode.cordis.yml`](code-mode.cordis.yml) includes that leaf and replaces the tool presentation mode while adding the code runtime. Non-interactive automation uses the sibling [headless-agent](../headless-agent/README.md) composition.
### Resuming a prior session
Each run starts a fresh session by default (its event log lands under `./.sessions/`). To **continue** a previous conversation, pass its id to the installed `dsh` CLI — the `main` agent then rehydrates the persisted log instead of starting fresh, so the model sees the earlier turns as history:
```sh
dsh --resume <prior-session-id>
```
The TUI prints this exact command on exit and lists it under `/resume`, so resuming is copy-paste. The flag sets `RESUME_SESSION_ID`, wired through `cordis.yml` (`resumeSessionId: !!js process.env.RESUME_SESSION_ID`); the env var still works directly for the uninstalled demo (`RESUME_SESSION_ID=<prior-session-id> pnpm run demo:tui`), and with neither set the agent starts a new session. A missing or unreadable id starts no agent and emits `agent-loop/config-start-failed`: the TUI prints the failure and exits nonzero.
## Code Mode
[`code-mode.cordis.yml`](code-mode.cordis.yml) overlays the same tree with the worker-thread runtime and `tools: { mode: code }`. The model receives one `run_code` transport plus a generated TypeScript SDK for the visible tools; only program output returns to model context. Use `mode: both` to expose native calls alongside `run_code`. See the [Code Mode Agent Note](../../.agents/notes/implemented/feature/2026-06-15-code-mode.md) for the execution contract.
```sh
pnpm run demo:code-mode # this overlay under the TUI (default UI)
pnpm run demo:code-mode acp # the acp-agent example's same-shaped overlay
```
Try a task that spans several tool calls, e.g.:
> Count the lines of every `*.md` file under docs/ and write the three largest to summary.txt.
and watch the transcript: one `run_code` call, a program looping over tools, and a result the model curated instead of five round-trips of raw tool output.
## What each leaf entry demonstrates
This example is a thin leaf `cordis.yml`: it picks the swappable backends, loads one app package, and adds product tools that are intentionally outside the shared spine. The spine (sessions, system-prompt, tools, agents, invariants, `agent-loop`) and the front-door cluster (JSONL persistence, the pi-tui channel, the pre-created `main` agent) live inside the [`@deepseek-ai/dsh-tui-demo`](../../packages/examples/tui-demo) app and the [`@deepseek-ai/dsh-agent-spine-demo`](../../packages/examples/agent-spine-demo) bundle it loads; the leaf wires the backends and model-facing optional tools:
| Entry | Demonstrates |
|---|---|
| `hmr` (`@cordisjs/plugin-hmr`) | the dev/demo edit-reload loop — a **leaf** entry (not baked into the app) because it is Loader-only and needs `node --expose-internals`, which `demo:tui` passes |
| `llm-deepseek` | real `LlmAdapter` via config (`!!js process.env.…` secrets); swap one line to `@deepseek-ai/dsh-llm-pi-ai` for the library-backed twin |
| `bash` (`dsh-bash-local`) | the executor implementation — the swappable half of the bash seam. The model-facing `bash` schema (`tool-bash`) and generic `task_*` controls (`tool-tasks`) come from `dsh-agent-spine-demo`, so only the executor is a leaf choice |
| `tui-agent` (`@deepseek-ai/dsh-tui-demo`) | the app bundle: the agent-spine demo + JSONL persistence + the pi-tui channel + a pre-created `main` agent |
| `subagent`, `subagent-spawn`, `subagent-fork` | the subagent provider registry plus the two in-process backends: a fresh child and a child seeded with the parent's completed-turn prefix |
| `tool-subagent`, `tool-subagent-fork` | two model-facing `dsh-tool-subagent` loads, each bound to a different provider and exposed under a distinct tool name (`subagent`, `subagent_fork`) |
| `workflow-workerthread`, `tool-workflow` | the worker-thread workflow engine and its model-facing `workflow` tool, with child calls routed through the spawn backend |
| `plan-mode` | the plugin-owned `/plan [message]` command, plan-mode prompt policy, tool restrictions, and reviewed `exit_plan_mode` transition |
| `fs-local`, `fs-policy`, `tool-fs` | the filesystem stack: the local `ctx.fs` provider, the read-before-write/edit policy gate (on the `fs/*` event gate), and the model-facing `read`/`write`/`edit` tools. Relative paths resolve against the session workspace |
## End-to-end tests (`pnpm run test:e2e`)
The UI-independent with-key suites assemble the full stack programmatically through `tests/harness.ts` (no PTY, no Loader):
- `tests/full-loop.e2e.ts` — the canary: real model runs `echo e2e-ok` through the real bash tool; asserts `tool/call`/`tool/result` session events and the final answer.
- `tests/coding-task.e2e.ts` — the swebench-style smoke: a temp dir holds `add.js` (with `a - b` where `a + b` belongs) and a failing `add.test.js`; the agent must fix the bug and verify. The test re-runs `node add.test.js` ITSELF and inspects the files — agent claims are not trusted.
- `tests/resume.e2e.ts` — durable continuity across processes: run 1 tells the real model a secret code and persists the turn to a temp JSONL root, then the whole context is disposed; run 2 is a fresh context over the same root that RESUMES the session id and asks the model to recall the code. The recall can only come from the rehydrated log.
- `tests/compaction.e2e.ts` — the compaction smoke: a real multi-step bash task runs with a deliberately tiny context window so the auto-compaction listener fires MID-SESSION. Verifies the WORLD — a `compact/start…end` pair landed in the real log, the surface shrank (a replace node shadowed older nodes), and the agent still produced a correct final answer after compaction.
- `tests/todo-write.e2e.ts` — loads the opt-in `todo_write` tool, then a real model drives it and the test verifies the resulting `todo/write` session event.
- `tests/code-mode.e2e.ts` — the with-key Code Mode proof: a real model, a two-tool task, asserting the wire tool list was exactly `[run_code]`, the `tool/code-dispatch` events landed under the parent call, and the curated answer came back.
These self-skip without `DEEPSEEK_API_KEY`. The keyless `tests/tui-keyless-smoke.e2e.ts` boots the real Loader tree in a PTY (the one sanctioned PTY surface): the base boot + `/plan` + `/exit`, a scripted-LLM conversation with a question dialog and tool round-trip, the Code Mode overlay welcome line, and the resume-failure exit path.
## Snapshot tests
`tests/snapshots/<scenario>/session.jsonl` supplies recorded user prompts and model chunks; sibling child logs drive subagents and workflows. The keyless suite executes those scripts through the real loop and tools, then compares readable terminal cell/style output. Use `pnpm run test:snapshot:refresh` for presentation-only changes and `pnpm run test:snapshot:record` with a DeepSeek key when a recorded model journey changes. The implemented [TUI snapshot Agent Note](../../.agents/notes/implemented/testing/2026-07-18-tui-terminal-state-snapshots.md) owns the scenario matrix.
`tests/snapshots/<scenario>/session.jsonl` supplies recorded user prompts and model chunks; sibling child logs drive subagents and workflows. The keyless suite executes those scripts through the real loop and tool implementations, then compares readable expected terminal cell/style output. Use `pnpm run test:snapshot:refresh` for presentation-only changes and `pnpm run test:snapshot:record` with a DeepSeek key when a recorded model journey changes. The implemented [TUI snapshot Agent Note](../../.agents/notes/implemented/testing/2026-07-18-tui-terminal-state-snapshots.md) owns the scenario matrix and the split between recorded journeys, transient package snapshots, and PTY coverage.

View File

@@ -9,9 +9,10 @@
name: '@deepseek-ai/dsh-tui-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
resumeSessionId: !!js process.env.RESUME_SESSION_ID
persistenceRoot: './.sessions'
resumeCommand: 'dsh --resume {session}'
workspaceContext:
maxBytes: 65536
tools:

View File

@@ -23,6 +23,8 @@ flowchart LR
bundle_agent_core --> spine_sessions["ctx.sessions"]
bundle_agent_core --> spine_tools["ctx.tools + tool-bash"]
bundle_agent_core --> spine_loop["ctx.agents + ctx.agentLoop"]
plugin_tui_session_title_llm["session-title-llm<br/>@deepseek-ai/dsh-session-title-first-message-llm"]
cfg --> plugin_tui_session_title_llm
plugin_tui_token_meter["token-meter<br/>@deepseek-ai/dsh-token-meter"]
cfg --> plugin_tui_token_meter
plugin_tui_tool_result_prune["tool-result-prune<br/>@deepseek-ai/dsh-compact-tool-result-prune"]
@@ -45,8 +47,6 @@ flowchart LR
cfg --> plugin_tui_tool_workflow
plugin_tui_tool_ralph["tool-ralph<br/>@deepseek-ai/dsh-tool-ralph"]
cfg --> plugin_tui_tool_ralph
plugin_tui_tool_todo["tool-todo<br/>@deepseek-ai/dsh-tool-todo"]
cfg --> plugin_tui_tool_todo
plugin_tui_plan_mode["plan-mode<br/>@deepseek-ai/dsh-plan-mode"]
cfg --> plugin_tui_plan_mode
plugin_tui_fs_local["fs-local<br/>@deepseek-ai/dsh-fs-local"]
@@ -71,6 +71,7 @@ flowchart LR
| `llm-deepseek` | `@deepseek-ai/dsh-llm-deepseek` |
| `bash` | `@deepseek-ai/dsh-bash-local` |
| `tui-agent` | `@deepseek-ai/dsh-tui-demo` |
| `session-title-llm` | `@deepseek-ai/dsh-session-title-first-message-llm` |
| `token-meter` | `@deepseek-ai/dsh-token-meter` |
| `tool-result-prune` | `@deepseek-ai/dsh-compact-tool-result-prune` |
| `compact-basic` | `@deepseek-ai/dsh-compact-basic` |
@@ -82,7 +83,6 @@ flowchart LR
| `workflow-workerthread` | `@deepseek-ai/dsh-workflow-workerthread` |
| `tool-workflow` | `@deepseek-ai/dsh-tool-workflow` |
| `tool-ralph` | `@deepseek-ai/dsh-tool-ralph` |
| `tool-todo` | `@deepseek-ai/dsh-tool-todo` |
| `plan-mode` | `@deepseek-ai/dsh-plan-mode` |
| `fs-local` | `@deepseek-ai/dsh-fs-local` |
| `fs-policy` | `@deepseek-ai/dsh-fs-policy` |

View File

@@ -1,52 +1,86 @@
# Full-screen coding agent with swappable DeepSeek and local capability backends.
# `dsh-tui-demo` supplies the spine, workspace instructions, generic task controls,
# JSONL persistence, the TUI front door, and `main`. HMR remains a leaf because
# it requires Loader internals; `demo:tui` passes `--expose-internals`.
# Full-screen TUI coding agent with swappable DeepSeek and local-bash backends.
# `dsh-tui-demo` supplies the agent spine, workspace instructions, generic
# task controls, JSONL persistence, the pi-tui front door, and `main`.
# HMR remains a leaf because it requires Loader internals; `demo:tui` passes
# `--expose-internals`. The app bin loads the gitignored root `.env`; this file
# reads `DEEPSEEK_API_KEY` and optional `DEEPSEEK_BASE_URL` through `!!js`.
# Hot-module reload for the dev/demo loop (needs `node --expose-internals`).
- id: hmr
name: '@cordisjs/plugin-hmr'
config:
root: ['.']
# The native DeepSeek adapter. Shipped default: full thinking at max effort on
# every request (wire-only defaults; they never enter the request header).
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek'
config:
apiKey: !!js process.env.DEEPSEEK_API_KEY
baseURL: !!js process.env.DEEPSEEK_BASE_URL
thinking: enabled
reasoningEffort: max
# Local executor for the app bundle's bash tool.
- id: bash
name: '@deepseek-ai/dsh-bash-local'
config:
timeoutMs: 60000
# The app bundle pre-creates the TUI's `main` agent.
- id: tui-agent
name: '@deepseek-ai/dsh-tui-demo'
config:
provider: deepseek
model: deepseek-v4-flash
model: deepseek-v4-pro
# Set RESUME_SESSION_ID to continue a prior persisted session (the ids live
# under ./.sessions); unset starts a fresh session each run.
resumeSessionId: !!js process.env.RESUME_SESSION_ID
persistenceRoot: './.sessions'
# Printed on exit and listed by `/resume`; `{session}` fills the live id.
# `dsh --resume <id>` sets RESUME_SESSION_ID above, so run it from this cwd.
resumeCommand: 'dsh --resume {session}'
workspaceContext:
maxBytes: 65536
welcome: 'TUI agent ready. Give it a coding task.'
ui:
showReasoning: true
maxToolOutputLines: 6
# Keep the persona to identity and behavior; tool plugins own tool guidance.
# The loop resolves {{model}} from this agent's configuration.
persona: |
You are a coding agent powered by the {{model}} model.
Verify your work by running the code or tests. Keep answers brief and
factual.
# Model-made session titles on the first-message cadence: replaces the spine's
# deterministic fallback title with a short model summary. The TUI renders the
# logged `session/title` as the banner subtitle and the terminal window title.
# Omitting provider/model inherits the main request's exact route.
- id: session-title-llm
name: '@deepseek-ai/dsh-session-title-first-message-llm'
config:
targetWords: 5
targetCjkCharacters: 10
maxInputBytes: 4096
maxOutputTokens: 64
timeoutMs: 60000
# Replay-aware request pressure with one service-wide context window.
- id: token-meter
name: '@deepseek-ai/dsh-token-meter'
- id: tool-result-prune
name: '@deepseek-ai/dsh-compact-tool-result-prune'
# Summarize an older range after measured pressure or a canonical provider overflow.
# Service-wide policy provides pressure, retention, and one overflow-retry default.
- id: compact-basic
name: '@deepseek-ai/dsh-compact-basic'
# Expose fresh-child `spawn` and completed-prefix `fork` through independent
# in-process backends. Each tool instance needs a distinct `toolName`; the registry
# rejects duplicates. These leaves follow the app because it provides `ctx.agents` and `ctx.tools`.
- id: subagent
name: '@deepseek-ai/dsh-subagent'
@@ -72,6 +106,9 @@
provider: fork
toolName: subagent_fork
# The worker-thread workflow engine fans a model-written JavaScript script's
# `agent()` calls out through the spawn backend; the adjacent tool exposes it to the model.
- id: workflow-workerthread
name: '@deepseek-ai/dsh-workflow-workerthread'
config:
@@ -85,9 +122,6 @@
- id: tool-ralph
name: '@deepseek-ai/dsh-tool-ralph'
- id: tool-todo
name: '@deepseek-ai/dsh-tool-todo'
# Plan mode gives the TUI a plugin-owned /plan [message] command; the exit
# review rides the TUI's user-interaction provider.
- id: plan-mode
@@ -106,7 +140,8 @@
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
# Policy loads before the model-facing filesystem tools so writes and edits require
# an observed file. This single-session app resolves relative paths from the process cwd.
- id: fs-local
name: '@deepseek-ai/dsh-fs-local'
config:
@@ -118,12 +153,24 @@
- id: tool-fs
name: '@deepseek-ai/dsh-tool-fs'
# Bash-backed discovery tools (glob/grep): fixed ripgrep commands through the
# local bash executor above — not ctx.fs. Capped results save the complete
# formatted list through the spill backend below (ctx.spillStore, optional).
- id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search'
# The tool-call timeout enforcer: arms each declared ToolDefinition.timeoutMs
# (the search tools above declare 30s) as a deadline on exec.signal. Without
# it a declared budget is advisory and only the bash executor's own timeout
# backstop applies.
- id: timeout-policy
name: '@deepseek-ai/dsh-timeout-policy'
# Tool-output spill stack: a local backend that saves oversized tool text under
# a private session-scoped dir, and the tools/post-execute policy that replaces
# an over-budget plain-text result with a preview + the spill locator/retrieval
# hint. A leaf pair after the app (needs ctx.tools). The policy is a no-op until
# a tool returns more than maxInlineBytes of plain text.
- id: spill-local
name: '@deepseek-ai/dsh-spill-local'

View File

@@ -5,6 +5,14 @@ import { CallId, LlmAdapter } from '@deepseek-ai/dsh-llm'
const CONTROL_PROBE = '\u001b]2;MODEL_CONTROLLED\u0007\u001b[999CMODEL_CURSOR\u009b31mMODEL_C1'
const INITIAL_TEXT = `I need one decision before I continue. ${CONTROL_PROBE}`
const FINAL_TEXT = 'Decision received. Scripted TUI run complete.'
// The `skill` scenario types `/skill:scripted-skill`; the manual-invocation front
// door delivers the loaded skill as a user turn wrapped in `<skill name="…">`. The
// body marker below lives in the fixture skill, so echoing it back proves the whole
// block (name attribute plus body) reached the model, not just the command text.
const SKILL_BLOCK_OPEN = '<skill name="scripted-skill">'
const SKILL_BODY_MARKER = 'SCRIPTED SKILL BODY MARKER'
const SKILL_RECEIVED_TEXT = 'Scripted skill body received.'
const TITLE_TEXT = 'scripted session title'
function textChunks(text: string): StreamChunk[] {
return [
@@ -16,7 +24,7 @@ function textChunks(text: string): StreamChunk[] {
]
}
/** Keyless two-step adapter for the real-PTY TUI conversation test. */
/** Keyless adapter for the real-PTY TUI tests: the two-step conversation and the `/skill:` round-trip. */
class ScriptedTuiAdapter extends LlmAdapter {
override listModels(provider: string): Promise<readonly LlmModelInfo[]> {
return Promise.resolve([
@@ -30,10 +38,30 @@ class ScriptedTuiAdapter extends LlmAdapter {
}
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
// The session-title provider's auxiliary request carries no tool schemas,
// unlike every agent turn; answer it with a fixed title so the PTY test can
// assert the logged title reaches the terminal window title.
if ((options.tools?.length ?? 0) === 0) {
for (const chunk of textChunks(TITLE_TEXT)) yield chunk
return
}
if (options.model !== 'tui-scripted-model-pro' || !options.system?.includes('tui-scripted-model-pro')) {
throw new Error('the scripted TUI request did not apply the selected model to routing and prompt variables')
}
const hasToolResult = options.messages.at(-1)?.content.some(block => block.type === 'tool-result') ?? false
const lastMessage = options.messages.at(-1)
const lastText = (lastMessage?.content ?? [])
.filter(block => block.type === 'text')
.map(block => block.text)
.join('\n')
if (lastText.includes(SKILL_BLOCK_OPEN)) {
const ack = lastText.includes(SKILL_BODY_MARKER)
? SKILL_RECEIVED_TEXT
: 'Scripted skill block arrived without its body.'
for (const chunk of textChunks(ack)) yield chunk
return
}
const hasToolResult = lastMessage?.content.some(block => block.type === 'tool-result') ?? false
if (hasToolResult) {
for (const chunk of textChunks(FINAL_TEXT)) yield chunk
return

View File

@@ -26,9 +26,24 @@
provider: tui-scripted
model: tui-scripted-model
persistenceRoot: './.sessions'
# The smoke's log inspection reads plain `.jsonl`; keep the scripted
# fixture uncompressed like the other snapshot-facing configs.
persistenceCompression: none
workspaceContext:
maxBytes: 65536
welcome: 'scripted TUI ready.'
persona: 'Scripted model {{model}}.'
ui:
showReasoning: true
# Model-made session titles, as in the shipped cordis.yml: the scripted adapter
# answers the tool-less title request with a fixed string so the PTY test can
# assert the logged title reaches the terminal window title.
- id: session-title-llm
name: '@deepseek-ai/dsh-session-title-first-message-llm'
config:
targetWords: 5
targetCjkCharacters: 10
maxInputBytes: 4096
maxOutputTokens: 64
timeoutMs: 10000

View File

@@ -10,6 +10,10 @@ node, launch_args_json, launch_env_json, cwd, actions_json, expected_exit, timeo
env = os.environ.copy()
env.update(json.loads(launch_env_json))
env.update({"COLUMNS": "100", "LINES": "30"})
# Deterministic banner: a developer shell's COLORTERM=truecolor would switch the
# banner to the per-letter gradient (one SGR per letter), breaking literal
# DEEPSEEK assertions. The gradient path has its own unit and snapshot coverage.
env.pop("COLORTERM", None)
actions = json.loads(actions_json)
pid, fd = pty.fork()
if pid == 0:
@@ -63,12 +67,19 @@ export interface TuiPtySmokeOptions {
readonly label: string
readonly tempDirPrefix: string
readonly binScript: string
readonly configPath: string
/** Config argument; ignored when {@link configArgs} is set. */
readonly configPath?: string
/** Full argument vector for the bin (e.g. `[]` for a bin with a built-in default config). */
readonly configArgs?: readonly string[]
readonly tsconfigPath: string
readonly actions?: readonly TuiPtyAction[]
readonly env?: Readonly<NodeJS.ProcessEnv>
readonly expectedExitCode?: number
readonly timeoutMs?: number
/** Seed the isolated workspace (`cwd`, with `$DSH_HOME` at `.dsh` and the agents home at `.agents`) before launch. */
readonly prepare?: (cwd: string) => Promise<void>
/** Inspect the workspace after a passing run, before the temp dir is removed. */
readonly inspect?: (cwd: string) => Promise<void>
}
function definedEnv(env: NodeJS.ProcessEnv): Record<string, string> {
@@ -135,6 +146,9 @@ async function runWindowsPtySmoke(
env: definedEnv({
...process.env,
...launch.env,
// Match the POSIX driver: no COLORTERM, so the banner never takes the
// truecolor gradient path under a developer's shell.
COLORTERM: undefined,
COLUMNS: '100',
LINES: '30',
}),
@@ -175,9 +189,13 @@ export async function runTuiPtySmoke(options: TuiPtySmokeOptions): Promise<strin
const cwd = await mkdtemp(join(tmpdir(), options.tempDirPrefix))
const timeoutMs = options.timeoutMs ?? 25_000
try {
await options.prepare?.(cwd)
const launch = resolveExampleLaunch({
srcBin: options.binScript,
configArgs: [options.configPath],
configArgs: options.configArgs !== undefined
? [...options.configArgs]
/* v8 ignore next -- every caller passes configPath or configArgs; the fallback keeps the type total */
: [options.configPath ?? './cordis.yml'],
tsconfigPath: options.tsconfigPath,
exposeInternals: true,
env: {
@@ -186,10 +204,12 @@ export async function runTuiPtySmoke(options: TuiPtySmokeOptions): Promise<strin
...options.env,
},
})
if (process.platform === 'win32') {
return await runWindowsPtySmoke(launch, cwd, options, timeoutMs)
}
return await runPosixPtySmoke(launch, cwd, options, timeoutMs)
const output = process.platform === 'win32'
? await runWindowsPtySmoke(launch, cwd, options, timeoutMs)
: await runPosixPtySmoke(launch, cwd, options, timeoutMs)
// Inspect the workspace before `finally` removes it (e.g. the session log).
await options.inspect?.(cwd)
return output
} finally {
await rm(cwd, { recursive: true, force: true })
}

View File

@@ -1,73 +1,63 @@
terminal 100x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "Use the bash tool to — DSH TUI snapshot"
cursor hidden column=1 viewportRow=27 bufferRow=27
cursor hidden column=1 viewportRow=25 bufferRow=25
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Use the bash tool to"
style 1-20 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| "▌ "
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Use the bash tool to │"
style 0-0 fg=bright-blue
style 2-21 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
5| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Use the bash tool to run exactly: echo TERMINAL_OK. Then reply with the single word DONE and stop."
6| "▌ Use the bash tool to run exactly: echo TERMINAL_OK. Then reply with the single word DONE and stop."
style 0-0 fg=bright-blue
9| "▌ "
7| "▌ "
style 0-0 fg=bright-blue
10| <blank>
11| " Reasoning "
8| <blank>
9| " Reasoning "
style 1-9 fg=bright-black italic
12| " The user wants me to run a simple bash command and then reply with \"DONE\". "
10| " The user wants me to run a simple bash command and then reply with \"DONE\". "
style 1-74 fg=bright-black italic
13| <blank>
14| "▌ "
11| <blank>
12| "▌ "
style 0-0 fg=green
15| "▌ ✓ echo TERMINAL_OK "
13| "▌ ✓ echo TERMINAL_OK "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-19 bold
16| "▌ Echo TERMINAL_OK to verify terminal access "
14| "▌ Echo TERMINAL_OK to verify terminal access "
style 0-0 fg=green
style 2-43 fg=bright-black
17| "▌ TERMINAL_OK "
15| "▌ TERMINAL_OK "
style 0-0 fg=green
18| "▌ [exit 0] "
16| "▌ [exit 0] "
style 0-0 fg=green
style 2-9 dim
19| "▌ "
17| "▌ "
style 0-0 fg=green
20| <blank>
21| " Reasoning "
18| <blank>
19| " Reasoning "
style 1-9 fg=bright-black italic
22| " The command ran successfully and output \"TERMINAL_OK\". I should now reply with just \"DONE\". "
20| " The command ran successfully and output \"TERMINAL_OK\". I should now reply with just \"DONE\". "
style 1-91 fg=bright-black italic
23| <blank>
24| " Assistant "
21| <blank>
22| " Assistant "
style 1-9 fg=bright-magenta bold
25| " DONE "
23| " DONE "
24| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
25| " "
style 1-1 inverse
26| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
27| " "
style 1-1 inverse
28| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
29| "/tmp/dsh-tui-snapshot-bash-te ↑3.0k ↓115 3% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-28 dim
style 42-99 dim
30-35| <blank>
27| "deepseek-v4-flash /workspace/project ↑3.0k ↓115 cache 48% 3% contex"
style 0-88 dim
style 91-99 dim
28-35| <blank>

View File

@@ -1,79 +1,69 @@
terminal 100x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "Using ONE run_code program: call — DSH TUI snapshot"
cursor hidden column=1 viewportRow=29 bufferRow=29
cursor hidden column=1 viewportRow=27 bufferRow=27
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Using ONE run_code program: call"
style 1-32 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| "▌ "
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Using ONE run_code program: call │"
style 0-0 fg=bright-blue
style 2-33 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
5| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Using ONE run_code program: call the bash tool twice — exactly echo CODE_ONE then exactly echo "
6| "▌ Using ONE run_code program: call the bash tool twice — exactly echo CODE_ONE then exactly echo "
style 0-0 fg=bright-blue
style 65-77 fg=cyan
style 92-99 fg=cyan
9| "▌ CODE_TWO — and return the two outputs joined with a plus sign. Then reply with that joined string "
7| "▌ CODE_TWO — and return the two outputs joined with a plus sign. Then reply with that joined string "
style 0-0 fg=bright-blue
style 2-9 fg=cyan
10| "▌ only and stop. "
8| "▌ only and stop. "
style 0-0 fg=bright-blue
11| "▌ "
9| "▌ "
style 0-0 fg=bright-blue
12| <blank>
13| " Reasoning "
10| <blank>
11| " Reasoning "
style 1-9 fg=bright-black italic
14| " The user wants a single run_code program that calls bash twice, then returns the two outputs "
12| " The user wants a single run_code program that calls bash twice, then returns the two outputs "
style 1-99 fg=bright-black italic
15| " joined with a plus sign. Let me write this. "
13| " joined with a plus sign. Let me write this. "
style 1-43 fg=bright-black italic
16| <blank>
17| "▌ "
14| <blank>
15| "▌ "
style 0-0 fg=green
18| "▌ ✓ const out1 = await tools.bash({ command: \"echo CODE_ONE\", description: \"First echo\" }); "
16| "▌ ✓ const out1 = await tools.bash({ command: \"echo CODE_ONE\", description: \"First echo\" }); "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-99 bold
19| "▌ const o "
17| "▌ const o "
style 0-0 fg=green
style 2-8 bold
20| "▌ CODE_ONE+CODE_TWO "
18| "▌ CODE_ONE+CODE_TWO "
style 0-0 fg=green
21| "▌ "
19| "▌ "
style 0-0 fg=green
22| <blank>
23| " Reasoning "
20| <blank>
21| " Reasoning "
style 1-9 fg=bright-black italic
24| " The output is exactly what the user asked for: CODE_ONE+CODE_TWO "
22| " The output is exactly what the user asked for: CODE_ONE+CODE_TWO "
style 1-64 fg=bright-black italic
25| <blank>
26| " Assistant "
23| <blank>
24| " Assistant "
style 1-9 fg=bright-magenta bold
27| " CODE_ONE+CODE_TWO "
25| " CODE_ONE+CODE_TWO "
26| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
27| " "
style 1-1 inverse
28| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
29| " "
style 1-1 inverse
30| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
31| "/tmp/dsh-tui-snapshot-code-mo ↑3.1k ↓158 3% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-28 dim
style 42-99 dim
32-35| <blank>
29| "deepseek-v4-flash /workspace/project ↑3.1k ↓158 cache 50% 3% context tools:"
style 0-79 dim
style 82-99 dim
30-35| <blank>

View File

@@ -1,116 +1,106 @@
terminal 100x36 buffer=normal length=50 base=14 viewport=14
terminal 100x36 buffer=normal length=48 base=12 viewport=12
lifecycle started=1 stopped=0 progress=inactive
title "Run this advanced flow exactly — DSH TUI snapshot"
cursor hidden column=1 viewportRow=33 bufferRow=47
cursor hidden column=1 viewportRow=33 bufferRow=45
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Run this advanced flow exactly"
style 1-30 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| "▌ "
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Run this advanced flow exactly │"
style 0-0 fg=bright-blue
style 2-31 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
5| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Run this advanced flow exactly once: mount a no-op Cordis plugin named snapshot-marker; use "
6| "▌ Run this advanced flow exactly once: mount a no-op Cordis plugin named snapshot-marker; use "
style 0-0 fg=bright-blue
9| "▌ run_code to inspect the live dynamic mounts through tools.cordis_inspect; delegate once to a "
7| "▌ run_code to inspect the live dynamic mounts through tools.cordis_inspect; delegate once to a "
style 0-0 fg=bright-blue
10| "▌ direct spawn child; run one workflow that delegates to another spawn child; unmount dyn-1; then "
8| "▌ direct spawn child; run one workflow that delegates to another spawn child; unmount dyn-1; then "
style 0-0 fg=bright-blue
11| "▌ reply with exactly ADVANCED_ACP_OK. "
9| "▌ reply with exactly ADVANCED_ACP_OK. "
style 0-0 fg=bright-blue
10| "▌ "
style 0-0 fg=bright-blue
11| <blank>
12| "▌ "
style 0-0 fg=bright-blue
13| <blank>
14| "▌ "
style 0-0 fg=green
15| "▌ ✓ Mount plugin into live cordis runtime "
13| "▌ ✓ Mount plugin into live cordis runtime "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-40 bold
16| "▌ mounted dyn-1 (plugin \"snapshot-marker\", state: active) "
14| "▌ mounted dyn-1 (plugin \"snapshot-marker\", state: active) "
style 0-0 fg=green
15| "▌ "
style 0-0 fg=green
16| <blank>
17| "▌ "
style 0-0 fg=green
18| <blank>
19| "▌ "
style 0-0 fg=green
20| "▌ ✓ return await tools.cordis_inspect({ what: 'dynamic' }) "
18| "▌ ✓ return await tools.cordis_inspect({ what: 'dynamic' }) "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-57 bold
21| "▌ ## dynamic "
19| "▌ ## dynamic "
style 0-0 fg=green
22| "▌ - dyn-1: snapshot-marker [active] "
20| "▌ - dyn-1: snapshot-marker [active] "
style 0-0 fg=green
21| "▌ "
style 0-0 fg=green
22| <blank>
23| "▌ "
style 0-0 fg=green
24| <blank>
25| "▌ "
style 0-0 fg=green
26| "▌ ✓ subagent "
24| "▌ ✓ subagent "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-11 bold
27| "▌ DIRECT_CHILD_OK "
25| "▌ DIRECT_CHILD_OK "
style 0-0 fg=green
26| "▌ "
style 0-0 fg=green
27| <blank>
28| "▌ "
style 0-0 fg=green
29| <blank>
30| "▌ "
style 0-0 fg=green
31| "▌ ✓ workflow: advanced-acp-snapshot "
29| "▌ ✓ workflow: advanced-acp-snapshot "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-34 bold
32| "▌ workflow \"advanced-acp-snapshot\" completed (1 agent). "
30| "▌ workflow \"advanced-acp-snapshot\" completed (1 agent). "
style 0-0 fg=green
33| "▌ Return value: "
31| "▌ Return value: "
style 0-0 fg=green
34| "▌ { "
32| "▌ { "
style 0-0 fg=green
35| "▌ \"reply\": \"WORKFLOW_CHILD_OK\" "
33| "▌ \"reply\": \"WORKFLOW_CHILD_OK\" "
style 0-0 fg=green
36| "▌ } "
34| "▌ } "
style 0-0 fg=green
35| "▌ "
style 0-0 fg=green
36| <blank>
37| "▌ "
style 0-0 fg=green
38| <blank>
39| "▌ "
style 0-0 fg=green
40| "▌ ✓ Unmount dyn-1 "
38| "▌ ✓ Unmount dyn-1 "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-16 bold
41| "▌ unmounted dyn-1 (plugin \"snapshot-marker\") "
39| "▌ unmounted dyn-1 (plugin \"snapshot-marker\") "
style 0-0 fg=green
42| "▌ "
40| "▌ "
style 0-0 fg=green
43| <blank>
44| " Assistant "
41| <blank>
42| " Assistant "
style 1-9 fg=bright-magenta bold
45| " ADVANCED_ACP_OK "
43| " ADVANCED_ACP_OK "
44| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
45| " "
style 1-1 inverse
46| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
47| " "
style 1-1 inverse
48| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
49| "/tmp/dsh-tui-snapshot-cordis-dyn ↑18 ↓18 8% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-31 dim
style 42-99 dim
47| "deepseek-v4-flash /workspace/project ↑18 ↓18 cache 0% 7% cont"
style 0-90 dim
style 93-99 dim

View File

@@ -1,106 +1,96 @@
terminal 100x36 buffer=normal length=47 base=11 viewport=11
terminal 100x36 buffer=normal length=45 base=9 viewport=9
lifecycle started=1 stopped=0 progress=inactive
title "Use the workflow tool exactly — DSH TUI snapshot"
cursor hidden column=1 viewportRow=33 bufferRow=44
cursor hidden column=1 viewportRow=33 bufferRow=42
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Use the workflow tool exactly"
style 1-29 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| "▌ "
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Use the workflow tool exactly │"
style 0-0 fg=bright-blue
style 2-30 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
5| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Use the workflow tool exactly once, with args omitted, meta set to { \"name\": \"snapshot-flow\", "
6| "▌ Use the workflow tool exactly once, with args omitted, meta set to { \"name\": \"snapshot-flow\", "
style 0-0 fg=bright-blue
9| "▌ \"description\": \"one child for the snapshot\" }, and this EXACT script body (copy it verbatim): "
7| "▌ \"description\": \"one child for the snapshot\" }, and this EXACT script body (copy it verbatim): "
style 0-0 fg=bright-blue
10| "▌ phase('Run') "
8| "▌ phase('Run') "
style 0-0 fg=bright-blue
11| "▌ const reply = await agent('Reply with exactly the word WF_CHILD_OK and nothing else.') "
9| "▌ const reply = await agent('Reply with exactly the word WF_CHILD_OK and nothing else.') "
style 0-0 fg=bright-blue
12| "▌ return { reply } "
10| "▌ return { reply } "
style 0-0 fg=bright-blue
13| "▌ After the workflow returns, reply with the single word WORKFLOW_DONE and stop. Do not use any "
11| "▌ After the workflow returns, reply with the single word WORKFLOW_DONE and stop. Do not use any "
style 0-0 fg=bright-blue
14| "▌ other tool. "
12| "▌ other tool. "
style 0-0 fg=bright-blue
15| "▌ "
13| "▌ "
style 0-0 fg=bright-blue
16| <blank>
17| " Reasoning "
14| <blank>
15| " Reasoning "
style 1-9 fg=bright-black italic
18| " The user wants me to use the workflow tool exactly once with specific parameters. Let me carefully "
16| " The user wants me to use the workflow tool exactly once with specific parameters. Let me carefully "
style 1-99 fg=bright-black italic
19| " follow the instructions: "
17| " follow the instructions: "
style 1-24 fg=bright-black italic
20| " "
21| " 1. args omitted (so I don't include it) "
18| " "
19| " 1. args omitted (so I don't include it) "
style 1-3 fg=bright-blue
style 4-39 fg=bright-black italic
22| " 2. meta = { \"name\": \"snapshot-flow\", \"description\": \"one child for the snapshot\" } "
20| " 2. meta = { \"name\": \"snapshot-flow\", \"description\": \"one child for the snapshot\" } "
style 1-3 fg=bright-blue
style 4-82 fg=bright-black italic
23| " 3. script = as given verbatim "
21| " 3. script = as given verbatim "
style 1-3 fg=bright-blue
style 4-29 fg=bright-black italic
24| " 4. After it returns, reply with \"WORKFLOW_DONE\" "
22| " 4. After it returns, reply with \"WORKFLOW_DONE\" "
style 1-3 fg=bright-blue
style 4-47 fg=bright-black italic
25| " "
26| " Let me do exactly that. "
23| " "
24| " Let me do exactly that. "
style 1-23 fg=bright-black italic
27| <blank>
28| "▌ "
25| <blank>
26| "▌ "
style 0-0 fg=green
29| "▌ ✓ workflow: snapshot-flow "
27| "▌ ✓ workflow: snapshot-flow "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-26 bold
30| "▌ workflow \"snapshot-flow\" completed (1 agent). "
28| "▌ workflow \"snapshot-flow\" completed (1 agent). "
style 0-0 fg=green
31| "▌ Return value: "
29| "▌ Return value: "
style 0-0 fg=green
32| "▌ { "
30| "▌ { "
style 0-0 fg=green
33| "▌ \"reply\": \"WF_CHILD_OK\" "
31| "▌ \"reply\": \"WF_CHILD_OK\" "
style 0-0 fg=green
34| "▌ } "
32| "▌ } "
style 0-0 fg=green
35| "▌ "
33| "▌ "
style 0-0 fg=green
36| <blank>
37| " Reasoning "
34| <blank>
35| " Reasoning "
style 1-9 fg=bright-black italic
38| " The workflow returned successfully with the reply \"WF_CHILD_OK\". Now I need to reply with exactly "
36| " The workflow returned successfully with the reply \"WF_CHILD_OK\". Now I need to reply with exactly "
style 1-99 fg=bright-black italic
39| " \"WORKFLOW_DONE\" and stop. "
37| " \"WORKFLOW_DONE\" and stop. "
style 1-25 fg=bright-black italic
40| <blank>
41| " Assistant "
38| <blank>
39| " Assistant "
style 1-9 fg=bright-magenta bold
42| " WORKFLOW_DONE "
40| " WORKFLOW_DONE "
41| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
42| " "
style 1-1 inverse
43| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
44| " "
style 1-1 inverse
45| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
46| "/tmp/dsh-tui-snapshot-dynamic ↑3.5k ↓227 3% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-28 dim
style 42-99 dim
44| "deepseek-v4-flash /workspace/project ↑3.5k ↓227 cache 47% 3% context "
style 0-86 dim
style 89-99 dim

View File

@@ -1,73 +1,63 @@
terminal 100x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "Reply with exactly the word: — DSH TUI snapshot"
cursor hidden column=1 viewportRow=30 bufferRow=30
cursor hidden column=1 viewportRow=28 bufferRow=28
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Reply with exactly the word: │"
style 0-0 fg=bright-blue
style 2-29 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| " Entering plan mode (applies from the next step). "
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Reply with exactly the word:"
style 1-28 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| " Entering plan mode (applies from the next step). "
style 1-48 fg=bright-black
7| <blank>
8| "▌ "
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
9| "▌ You "
7| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
10| "▌ Reply with exactly the word: ONE. No tools. "
8| "▌ Reply with exactly the word: ONE. No tools. "
style 0-0 fg=bright-blue
11| "▌ "
9| "▌ "
style 0-0 fg=bright-blue
12| <blank>
13| " Reasoning "
10| <blank>
11| " Reasoning "
style 1-9 fg=bright-black italic
14| " The user wants me to reply with exactly the word \"ONE\" and use no tools. "
12| " The user wants me to reply with exactly the word \"ONE\" and use no tools. "
style 1-72 fg=bright-black italic
15| <blank>
16| " Assistant "
13| <blank>
14| " Assistant "
style 1-9 fg=bright-magenta bold
17| " ONE "
18| <blank>
19| "▌ "
15| " ONE "
16| <blank>
17| "▌ "
style 0-0 fg=bright-blue
20| "▌ You "
18| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
21| "▌ Reply with exactly the word: TWO. No tools. "
19| "▌ Reply with exactly the word: TWO. No tools. "
style 0-0 fg=bright-blue
22| "▌ "
20| "▌ "
style 0-0 fg=bright-blue
23| <blank>
24| " Reasoning "
21| <blank>
22| " Reasoning "
style 1-9 fg=bright-black italic
25| " The user wants me to reply with exactly the word \"TWO\" and no tools. "
23| " The user wants me to reply with exactly the word \"TWO\" and no tools. "
style 1-68 fg=bright-black italic
26| <blank>
27| " Assistant "
24| <blank>
25| " Assistant "
style 1-9 fg=bright-magenta bold
28| " TWO "
26| " TWO "
27| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
28| " "
style 1-1 inverse
29| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
30| " "
style 1-1 inverse
31| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
32| "/tmp/dsh-tui-snapshot-multi-tu ↑2.9k ↓41 3% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-29 dim
style 42-99 dim
33-35| <blank>
30| "deepseek-v4-flash /workspace/project ↑2.9k ↓41 cache 49% 3% co"
style 0-92 dim
style 95-99 dim
31-35| <blank>

View File

@@ -1,91 +1,81 @@
terminal 100x36 buffer=normal length=39 base=3 viewport=3
terminal 100x36 buffer=normal length=37 base=1 viewport=1
lifecycle started=1 stopped=0 progress=inactive
title "Use the read tool twice — DSH TUI snapshot"
cursor hidden column=1 viewportRow=33 bufferRow=36
cursor hidden column=1 viewportRow=33 bufferRow=34
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Use the read tool twice"
style 1-23 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| "▌ "
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Use the read tool twice │"
style 0-0 fg=bright-blue
style 2-24 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
5| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Use the read tool twice in the same assistant message: read a.txt and b.txt. Then reply DONE. "
6| "▌ Use the read tool twice in the same assistant message: read a.txt and b.txt. Then reply DONE. "
style 0-0 fg=bright-blue
7| "▌ "
style 0-0 fg=bright-blue
8| <blank>
9| "▌ "
style 0-0 fg=bright-blue
10| <blank>
11| "▌ "
style 0-0 fg=green
12| "▌ ✓ Read a.txt "
10| "▌ ✓ Read a.txt "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-13 bold
13| "▌ <path>/workspace/project/a.txt</path> "
11| "▌ <path>/workspace/project/a.txt</path> "
style 0-0 fg=green
14| "▌ <type>file</type> "
12| "▌ <type>file</type> "
style 0-0 fg=green
15| "▌ <content> "
13| "▌ <content> "
style 0-0 fg=green
16| "▌ 1: alpha "
14| "▌ 1: alpha "
style 0-0 fg=green
17| "▌ "
15| "▌ "
style 0-0 fg=green
18| "▌ (End of file - total 1 lines) "
16| "▌ (End of file - total 1 lines) "
style 0-0 fg=green
19| "▌ </content> "
17| "▌ </content> "
style 0-0 fg=green
18| "▌ "
style 0-0 fg=green
19| <blank>
20| "▌ "
style 0-0 fg=green
21| <blank>
22| "▌ "
style 0-0 fg=green
23| "▌ ✓ Read b.txt "
21| "▌ ✓ Read b.txt "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-13 bold
24| "▌ <path>/workspace/project/b.txt</path> "
22| "▌ <path>/workspace/project/b.txt</path> "
style 0-0 fg=green
25| "▌ <type>file</type> "
23| "▌ <type>file</type> "
style 0-0 fg=green
26| "▌ <content> "
24| "▌ <content> "
style 0-0 fg=green
27| "▌ 1: beta "
25| "▌ 1: beta "
style 0-0 fg=green
28| "▌ "
26| "▌ "
style 0-0 fg=green
29| "▌ (End of file - total 1 lines) "
27| "▌ (End of file - total 1 lines) "
style 0-0 fg=green
30| "▌ </content> "
28| "▌ </content> "
style 0-0 fg=green
31| "▌ "
29| "▌ "
style 0-0 fg=green
32| <blank>
33| " Assistant "
30| <blank>
31| " Assistant "
style 1-9 fg=bright-magenta bold
34| " DONE "
32| " DONE "
33| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
34| " "
style 1-1 inverse
35| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
36| " "
style 1-1 inverse
37| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
38| "/tmp/dsh-tui-snapshot-parallel-fi ↑20 ↓6 3% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-32 dim
style 42-99 dim
36| "deepseek-v4-flash /workspace/project ↑20 ↓6 cache 0% 3% context t"
style 0-84 dim
style 87-99 dim

View File

@@ -1,81 +1,72 @@
terminal 100x36 buffer=normal length=36 base=0 viewport=0
lifecycle started=1 stopped=0 progress=inactive
title "Use the todo_write tool to — DSH TUI snapshot"
cursor hidden column=1 viewportRow=33 bufferRow=33
cursor hidden column=1 viewportRow=31 bufferRow=31
buffer
0| "╭──────────────────────────────────────────────────────────────────────────────────────────────────╮"
style 0-99 fg=bright-blue
1| "│ DEEPSEEK HARNESS │"
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-blue bold
style 10-16 bold
1| " Use the todo_write tool to"
style 1-26 fg=bright-black
2| " deepseek-v4-flash • main-session"
style 1-34 dim
3| <blank>
4| "▌ "
style 0-0 fg=bright-blue
style 2-9 fg=bright-blue bold
style 11-17 bold
style 99-99 fg=bright-blue
2| "│ Use the todo_write tool to │"
style 0-0 fg=bright-blue
style 2-27 fg=bright-black
style 99-99 fg=bright-blue
3| "│ deepseek-v4-flash • main-session │"
style 0-0 fg=bright-blue
style 2-35 dim
style 99-99 fg=bright-blue
4| "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
style 0-99 fg=bright-blue
5| <blank>
6| "▌ "
style 0-0 fg=bright-blue
7| "▌ You "
5| "▌ You "
style 0-0 fg=bright-blue
style 2-4 fg=bright-blue bold
8| "▌ Use the todo_write tool to record a plan with exactly three todos: \"read the code\" (in_progress), "
6| "▌ Use the todo_write tool to record a plan with exactly three todos: \"read the code\" (in_progress), "
style 0-0 fg=bright-blue
9| "▌ \"write the fix\" (pending), \"run the tests\" (pending). Send all three in one todo_write call. Then "
7| "▌ \"write the fix\" (pending), \"run the tests\" (pending). Send all three in one todo_write call. Then "
style 0-0 fg=bright-blue
10| "▌ reply with the single word DONE and stop. "
8| "▌ reply with the single word DONE and stop. "
style 0-0 fg=bright-blue
11| "▌ "
9| "▌ "
style 0-0 fg=bright-blue
12| <blank>
13| " Reasoning "
10| <blank>
11| " Reasoning "
style 1-9 fg=bright-black italic
14| " The user wants me to use the todo_write tool to record a plan with exactly three todos in the "
12| " The user wants me to use the todo_write tool to record a plan with exactly three todos in the "
style 1-99 fg=bright-black italic
15| " specified statuses, then reply with \"DONE\". "
13| " specified statuses, then reply with \"DONE\". "
style 1-43 fg=bright-black italic
16| <blank>
17| "▌ "
14| <blank>
15| "▌ "
style 0-0 fg=green
18| "▌ ✓ Update todo list "
16| "▌ ✓ Update todo list "
style 0-0 fg=green
style 2-2 fg=green bold
style 3-19 bold
19| "▌ Updated todo list: 2 pending, 1 in progress, 0 completed. "
17| "▌ Updated todo list: 2 pending, 1 in progress, 0 completed. "
style 0-0 fg=green
20| "▌ "
18| "▌ "
style 0-0 fg=green
21| <blank>
22| " Reasoning "
19| <blank>
20| " Reasoning "
style 1-9 fg=bright-black italic
23| " The todos have been written successfully. Now I just need to reply with the single word \"DONE\". "
21| " The todos have been written successfully. Now I just need to reply with the single word \"DONE\". "
style 1-95 fg=bright-black italic
24| <blank>
25| " Assistant "
22| <blank>
23| " Assistant "
style 1-9 fg=bright-magenta bold
26| " DONE "
27| <blank>
28| "Plan"
24| " DONE "
25| <blank>
26| "Plan"
style 0-3 fg=bright-blue bold
29| " ● read the code"
27| " ● read the code"
style 2-2 fg=yellow
30| " ○ write the fix"
28| " ○ write the fix"
style 2-2 dim
31| " ○ run the tests"
29| " ○ run the tests"
style 2-2 dim
30| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
31| " "
style 1-1 inverse
32| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
33| " "
style 1-1 inverse
34| "────────────────────────────────────────────────────────────────────────────────────────────────────"
style 0-99 dim
35| "/tmp/dsh-tui-snapshot-todo-pl ↑3.1k ↓145 3% context tools:compact deepseek-v4-flash(reasoning:on)"
style 0-28 dim
style 42-99 dim
33| "deepseek-v4-flash /workspace/project ↑3.1k ↓145 cache 47% 3% context tools:"
style 0-79 dim
style 82-99 dim
34-35| <blank>

View File

@@ -1,46 +1,114 @@
import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
import { LOADER_SMOKE_TEST_TIMEOUT_MS } from '@deepseek-ai/dsh-loader-smoke'
import { runTuiPtySmoke } from './pty-harness.ts'
import { runTuiPtySmoke, type TuiPtySmokeOptions } from './pty-harness.ts'
const binScript = fileURLToPath(new URL('../../../packages/examples/tui-demo/src/bin.ts', import.meta.url))
const dshBinScript = fileURLToPath(new URL('../../../apps/cli/src/bin.ts', import.meta.url))
const configPath = fileURLToPath(new URL('../cordis.yml', import.meta.url))
const codeModeConfigPath = fileURLToPath(new URL('../code-mode.cordis.yml', import.meta.url))
const scriptedConfigPath = fileURLToPath(new URL('./fixtures/tui-scripted.cordis.yml', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../tsconfig.json', import.meta.url))
/**
* Seed the harness workspace: personal files land in the isolated Harness home
* (`.dsh`), skill bundles under the agents home's `skills/` root — the same
* trees `$DSH_HOME` / `$DSH_AGENTS_HOME` point the child at.
*/
function seedWorkspace(
files: { personal?: Record<string, string>; skills?: Record<string, string> },
): (cwd: string) => Promise<void> {
return async (cwd) => {
for (const [name, content] of Object.entries(files.personal ?? {})) {
const file = join(cwd, '.dsh', name)
await mkdir(dirname(file), { recursive: true })
await writeFile(file, content)
}
for (const [name, content] of Object.entries(files.skills ?? {})) {
const file = join(cwd, '.agents', 'skills', name)
await mkdir(dirname(file), { recursive: true })
await writeFile(file, content)
}
}
}
/** The rendered system prompt from the first `request/header` in the workspace's persisted session log. */
async function readLoggedSystemPrompt(cwd: string): Promise<string> {
const sessionsDir = join(cwd, '.sessions')
const entries = await readdir(sessionsDir, { recursive: true })
// A single keyless run writes one session log; the source section is global, so any log carries it.
const logRelPath = entries.find(name => name.endsWith('.jsonl'))
if (logRelPath === undefined) throw new Error(`no session log written under ${sessionsDir}`)
const lines = (await readFile(join(sessionsDir, logRelPath), 'utf8')).split('\n').filter(Boolean)
for (const line of lines) {
const event = JSON.parse(line) as { type: string; data: { header?: { system?: string } } }
if (event.type === 'request/header') return event.data.header?.system ?? ''
}
throw new Error(`session log ${logRelPath} has no request/header event`)
}
/** Shared defaults: the keyless key, the tui-demo bin, and the live cordis.yml. */
function smoke(overrides: Partial<TuiPtySmokeOptions> & { label: string }): Promise<string> {
return runTuiPtySmoke({
tempDirPrefix: 'tui-agent-smoke-',
binScript,
configPath,
tsconfigPath,
env: { DEEPSEEK_API_KEY: 'keyless-tui-no-call' },
...overrides,
})
}
// The scripted conversation switches to the pro model first: the scripted
// adapter proves routing + prompt variables by rejecting tool-ful calls on any
// other route (see fixtures/tui-scripted-llm.ts).
const SELECT_PRO_MODEL = [
{ waitFor: 'scripted TUI ready.', send: '/model\r' },
{ waitFor: 'Select model', send: '\x1b[B\r' },
] as const
describe('tui-agent keyless smoke (real Loader tree in a PTY)', () => {
it('boots pi-tui, enters plan mode through /plan, accepts /exit, and restores the terminal', async () => {
const output = await runTuiPtySmoke({
it('boots pi-tui, sweeps the borderless banner in, enters plan mode, and restores the terminal', async () => {
// With no configured welcome the borderless banner sweeps in left-to-right;
// the detail line's session id (`main-session-<uuid>`) renders only once
// the sweep reaches it, so it marks a settled banner.
const output = await smoke({
label: 'tui-agent boot',
tempDirPrefix: 'tui-agent-smoke-',
binScript,
configPath,
tsconfigPath,
env: { DEEPSEEK_API_KEY: 'keyless-tui-no-call' },
actions: [
{ waitFor: 'TUI agent ready.', send: '/plan\r' },
{ waitFor: 'main-session-', send: '/plan\r' },
{ waitFor: 'Entering plan mode (applies from the next step).', send: '/exit\r' },
],
})
expect(output).toContain('DEEPSEEK')
expect(output).toContain('TUI agent ready.')
expect(output).toContain('HARNESS')
expect(output).toContain('main-session-')
expect(output).toContain('Entering plan mode (applies from the next step).')
// Borderless: no box-drawing frame around the banner.
expect(output).not.toContain('╭')
expect(output).not.toContain('╮')
expect(output).toContain('\u001B[?2004l')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('switches models, streams a response, answers a user-question dialog, and exits cleanly', async () => {
const output = await runTuiPtySmoke({
const output = await smoke({
label: 'tui-agent conversation',
tempDirPrefix: 'tui-agent-conversation-',
binScript,
configPath: scriptedConfigPath,
tsconfigPath,
actions: [
{ waitFor: 'scripted TUI ready.', send: '/model\r' },
{ waitFor: 'Select model', send: '\x1b[B\r' },
...SELECT_PRO_MODEL,
{ waitFor: 'Model selected: tui-scripted/tui-scripted-model-pro.', send: '/plan exercise the TUI\r' },
{ waitFor: 'How should the scripted run proceed?', send: '\r' },
{ waitFor: 'Decision received. Scripted TUI run complete.', send: '/exit\r' },
{ waitFor: 'Decision received. Scripted TUI run complete.', send: '' },
// Session title: the first user message drives the first-message-llm
// provider's tool-less title call; the scripted adapter answers it, the
// accepted title lands in the log, and the TUI renders the terminal
// window title as `<session title> — <configured title>` via OSC 0.
// Gating /status on it keeps the assertion race-free; the diagnostics
// card is then exercised through the same real Loader/PTY composition.
{ waitFor: 'scripted session title — DeepSeek Harness', send: '/status\r' },
{ waitFor: 'Session status', send: '/exit\r' },
],
})
expect(output).toContain('I need one decision before I continue.')
@@ -52,16 +120,68 @@ describe('tui-agent keyless smoke (real Loader tree in a PTY)', () => {
expect(output).not.toContain('\u001B[999CMODEL_CURSOR')
expect(output).not.toContain('\u009B31mMODEL_C1')
expect(output).toContain('Safe')
expect(output).toContain('\u001B]0;scripted session title — DeepSeek Harness\u0007')
expect(output).toContain('Session status')
expect(output).toContain('Title')
expect(output).toContain('scripted session title')
expect(output).toContain('Model')
expect(output).toContain('tui-scripted/tui-scripted-model-pro')
expect(output).toContain('KV cache')
expect(output).toContain('Context')
expect(output).toContain('128,000')
expect(output).toContain('\u001B[?2004l')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('loads a local skill via /skill: and delivers its body to the model as a user turn', async () => {
// The whole manual-invocation path in one keyless boot: `ctx.get('skills')`
// resolves in the shipped tree, the client-side `/skill:` command parses,
// the local provider loads `scripted-skill` from the agents home, and the
// rendered `<skill name="…">` block reaches the model — proven by the
// scripted adapter echoing the fixture's body marker only when it arrives.
const output = await smoke({
label: 'tui-agent skill',
tempDirPrefix: 'tui-agent-skill-',
configPath: scriptedConfigPath,
prepare: seedWorkspace({
skills: {
'scripted-skill/SKILL.md': [
'---',
'name: scripted-skill',
'description: Keyless PTY proof that the skill command loads a local skill into the conversation.',
'---',
'',
'SCRIPTED SKILL BODY MARKER',
'',
].join('\n'),
},
}),
actions: [
...SELECT_PRO_MODEL,
{ waitFor: 'Model selected: tui-scripted/tui-scripted-model-pro.', send: '/skill:scripted-skill\r' },
{ waitFor: 'Scripted skill body received.', send: '/exit\r' },
],
})
expect(output).toContain('Scripted skill body received.')
expect(output).toContain('\u001B[?2004l')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('boots the Code Mode overlay tree, renders its banner, and exits cleanly', async () => {
// The overlay's only keyless composition proof: the include+patch tree,
// worker code runtime, and one-tool registry all mount before the banner.
const output = await smoke({
label: 'tui-agent code mode',
tempDirPrefix: 'tui-agent-code-mode-',
configPath: codeModeConfigPath,
actions: [{ waitFor: 'TUI Code Mode ready.', send: '/exit\r' }],
})
expect(output).toContain('TUI Code Mode ready.')
expect(output).toContain('\u001B[?2004l')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('prints a config-resume failure and exits instead of leaving a blank terminal', async () => {
const output = await runTuiPtySmoke({
const output = await smoke({
label: 'tui-agent resume failure',
tempDirPrefix: 'tui-agent-resume-',
binScript,
configPath,
tsconfigPath,
env: {
DEEPSEEK_API_KEY: 'keyless-tui-no-call',
RESUME_SESSION_ID: 'missing-session',
@@ -71,3 +191,98 @@ describe('tui-agent keyless smoke (real Loader tree in a PTY)', () => {
expect(output).toContain('ui-tui: session "missing-session" failed to start:')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
})
describe('dsh CLI keyless smoke (apps/cli through the same PTY)', () => {
it('boots the shipped default config with no arguments and no personal overlay', async () => {
const output = await smoke({
label: 'dsh default boot',
tempDirPrefix: 'dsh-default-boot-',
binScript: dshBinScript,
configArgs: [],
actions: [{ waitFor: 'main-session-', send: '/exit\r' }],
})
expect(output).toContain('DEEPSEEK')
expect(output).toContain('main-session-')
expect(output).not.toContain('╭')
expect(output).not.toContain('╮')
expect(output).toContain('\u001B[?2004l')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('applies the personal overlay: config.yaml patches the tree and .env feeds its !!js', async () => {
// The whole personal-config chain in one boot: the personal .env supplies
// the variable, config.yaml patches the tui-agent entry with a `!!js`
// reference to it, and the banner renders the patched welcome verbatim.
const output = await smoke({
label: 'dsh personal overlay',
tempDirPrefix: 'dsh-personal-overlay-',
binScript: dshBinScript,
configArgs: [],
prepare: seedWorkspace({
personal: {
'.env': 'DSH_PERSONAL_WELCOME=PERSONAL OVERLAY READY.\n',
'config.yaml': [
'- id: tui-agent',
" name: '@deepseek-ai/dsh-tui-demo'",
' config:',
' provider: deepseek',
' model: deepseek-v4-flash',
' workspaceContext: false',
' welcome: !!js process.env.DSH_PERSONAL_WELCOME',
'',
].join('\n'),
},
}),
actions: [{ waitFor: 'PERSONAL OVERLAY READY.', send: '/exit\r' }],
})
expect(output).toContain('PERSONAL OVERLAY READY.')
expect(output).toContain('\u001B[?2004l')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('fails loud instead of booting when the personal config.yaml is invalid', async () => {
const output = await smoke({
label: 'dsh invalid personal config',
tempDirPrefix: 'dsh-invalid-personal-',
binScript: dshBinScript,
configArgs: [],
prepare: seedWorkspace({ personal: { 'config.yaml': 'id: not-a-list\n' } }),
expectedExitCode: 1,
})
expect(output).toContain('must be a top-level YAML array of loader patch entries')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('routes the --resume flag into the config resume intake, failing loud on a missing id', async () => {
// The flag path end to end: apps/cli parses `--resume missing-session` and
// sets RESUME_SESSION_ID, the shipped config's `!!js` reads it, and the
// resume fails loud — proving the printed `dsh --resume <id>` hint reaches
// the same intake as the env var.
const output = await smoke({
label: 'dsh resume flag failure',
tempDirPrefix: 'dsh-resume-flag-',
binScript: dshBinScript,
configArgs: ['--resume', 'missing-session'],
expectedExitCode: 1,
})
expect(output).toContain('ui-tui: session "missing-session" failed to start:')
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
it('tells the model where its own source lives, in the system prompt it sends', async () => {
// The launcher resolves the checkout root three hops up from apps/cli/{src,lib};
// this test file sits an equal depth under the same root, so the same hop applies.
const sourceRoot = fileURLToPath(new URL('../../..', import.meta.url))
let loggedSystem = ''
await smoke({
label: 'dsh source-path prompt',
tempDirPrefix: 'dsh-source-path-',
binScript: dshBinScript,
configArgs: [scriptedConfigPath],
actions: [
...SELECT_PRO_MODEL,
{ waitFor: 'Model selected: tui-scripted/tui-scripted-model-pro.', send: 'exercise the TUI\r' },
{ waitFor: 'How should the scripted run proceed?', send: '\r' },
{ waitFor: 'Decision received. Scripted TUI run complete.', send: '/exit\r' },
],
inspect: async (cwd) => { loggedSystem = await readLoggedSystemPrompt(cwd) },
})
expect(loggedSystem).toContain(`Your own source code is the checkout at ${sourceRoot}; you can read it there to learn how dsh works and how to extend it.`)
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
})

View File

@@ -49,6 +49,12 @@ interface Scenario {
enterPlanMode?: boolean
recorded: boolean
seedWorkspace?: boolean
/**
* Load the opt-in `todo_write` tool for this scenario. The shipped tui-agent
* config omits it, so only the todo-plan scenario (the enabled-path proof)
* mounts it; the rest cover the default, todo-free composition.
*/
enableTodo?: boolean
}
const SCENARIOS: Scenario[] = [
@@ -66,6 +72,7 @@ const SCENARIOS: Scenario[] = [
expectedTools: ['todo_write'],
expectedEventCounts: { 'todo/write': 1 },
recorded: true,
enableTodo: true,
},
{
name: 'bash-terminal-card',
@@ -200,7 +207,9 @@ async function mountScenarioContext(
await ctx.plugin(FsPolicy)
await ctx.plugin(ToolFs)
await ctx.plugin(UserInteractionService)
await ctx.plugin(ToolTodo)
// todo_write is opt-in: only the todo-plan scenario mounts it, matching the shipped
// config that omits it. The other scenarios prove the default todo-free composition.
if (scenario.enableTodo === true) await ctx.plugin(ToolTodo)
await ctx.plugin(SubagentService)
await ctx.plugin(SubagentSpawn, { providerName: 'spawn' })
await ctx.plugin(ToolSubagent, { provider: 'spawn', toolName: 'subagent', enableRunInBackground: false })