@songtonyli/dsh-cli 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +40 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +28 -13
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +9 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +9 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +481 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
|
|
|
26
26
|
ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
|
|
27
27
|
ordinary optional dependencies, so npm resolves the right one for your machine.
|
|
28
28
|
|
|
29
|
-
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.
|
|
29
|
+
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.40; `dsh --version`
|
|
30
30
|
also reports the harness build the package was assembled from.
|
|
31
31
|
|
|
32
32
|
## License
|
package/bin/dsh.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
|
|
|
18
18
|
// version this package publishes. Reporting only one of the two would make an
|
|
19
19
|
// ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
|
|
20
20
|
if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
|
|
21
|
-
console.log('@songtonyli/dsh-cli 0.1.
|
|
21
|
+
console.log('@songtonyli/dsh-cli 0.1.40 (deepseek-harness 0.1.7-alpha.1)')
|
|
22
22
|
process.exit(0)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"micromark-extension-gfm": "^3.0.0",
|
|
48
48
|
"micromark-util-sanitize-uri": "^2.0.1",
|
|
49
49
|
"simple-icons": "16.31.0",
|
|
50
|
-
"@deepseek-ai/cordis": "^4.0.3",
|
|
51
50
|
"@deepseek-ai/dsh-client-store": "^0.1.7-alpha.1",
|
|
52
|
-
"@deepseek-ai/dsh-util-workspace-path": "^0.1.7-alpha.1"
|
|
51
|
+
"@deepseek-ai/dsh-util-workspace-path": "^0.1.7-alpha.1",
|
|
52
|
+
"@deepseek-ai/cordis": "^4.0.3"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"lib/index.js",
|
|
@@ -158,7 +158,7 @@ window.__ModuleLoader__.load({
|
|
|
158
158
|
const SCROLLBAR_LINGER_MS = 2e3;
|
|
159
159
|
/** Format complete-build metadata for the local brand badge. */
|
|
160
160
|
function localBuildVersion() {
|
|
161
|
-
return `0.1.7-alpha.1-
|
|
161
|
+
return `0.1.7-alpha.1-57b4ad4-dirty`;
|
|
162
162
|
}
|
|
163
163
|
/** Each panel row subscribes only to its own selection state. */
|
|
164
164
|
function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/react": "~18.3.1",
|
|
27
|
-
"@deepseek-ai/
|
|
28
|
-
"@deepseek-ai/
|
|
27
|
+
"@deepseek-ai/dsh-client-store": "^0.1.7-alpha.1",
|
|
28
|
+
"@deepseek-ai/cordis": "^4.0.3"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"lib/index.js",
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/llm/llm-cursor/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 5da635cbc6264d175558dba6cdb522e3b97a4cbb
|
|
6
|
+
README.zh.md: c1098dd49a4d7f0834d3e90b38bbdb90dccde30d
|
|
@@ -68,7 +68,7 @@ Request-time token order is: launch-environment `CURSOR_ACCESS_TOKEN`, then the
|
|
|
68
68
|
|
|
69
69
|
A new Run is rebuilt from harness history, system prompt, and MCP tool definitions (`providerIdentifier: dsh`, `clientName: dsh`). Cursor's server builds the model prompt from `root_prompt_messages_json`, never renders `conversation_state.turns` into it, and discards a `{"role":"system"}` entry there in favour of its own prompt. The adapter therefore publishes the system prompt as a `<rules>` user prompt message and replays every prior turn as `user`, `assistant`, and `tool` prompt messages, writing each historic harness tool call as the `CallDynamicTool` call Cursor records for an MCP tool; the turn structures ride along for the server's bookkeeping. A Cursor CLI Run exposes MCP tools to the model only through `GetDynamicTools` and `CallDynamicTool`, so the request-context answer adds one global Cursor rule telling the model that Cursor's built-in tools return a rejection here, that harness tools are called with `CallDynamicTool` in namespace `dsh`, and which tool names exist.
|
|
70
70
|
|
|
71
|
-
Text, thinking, usage, and MCP tool calls become `StreamChunk`. MCP tool calls end the step once Cursor sends the checkpoint that follows the model's last parallel call, or after `toolCallSettleMs` without a frame. When the request names a Session and is not a compaction or title request, the Run then parks: the adapter keeps the stream open with a `clientHeartbeat` every five seconds. The next request from that Session resumes it when its history before the last assistant message is unchanged and that message is followed only by the pending calls' results and harness-injected user-role context; the adapter answers each call with `mcpResult` on the same stream, appends such context to the last result, and keeps reading. Any other request, a Run that died while parked, or one older than `parkedRunTimeoutMs` falls back to a new Run that replays the in-flight turn with its results and sends a fixed continuation notice as the user message a Run requires; a `resumeAction` is not used because the server restarts the turn from its user message instead of continuing it. A Cursor-native or CLI Pi workspace exec (`read`, `shell`, `piRead`, and kin) is answered with its typed rejection naming the harness tool to call through `CallDynamicTool`, so the Run continues and the model reads the refusal as a tool outcome; text after a refused exec starts a new text block. A CLI hook is answered with an empty matching response. An MCP-state exec returns the advertised `dsh` tools. Any other exec this build cannot type is answered with ExecClientThrow so the Run continues. An exec with no payload still fails the step.
|
|
71
|
+
Text, thinking, usage, and MCP tool calls become `StreamChunk`. MCP tool calls end the step once Cursor sends the checkpoint that follows the model's last parallel call, or after `toolCallSettleMs` without a frame. When the request names a Session and is not a compaction or title request, the Run then parks: the adapter keeps the stream open with a `clientHeartbeat` every five seconds. The next request from that Session resumes it when its history before the last assistant message is unchanged and that message is followed only by the pending calls' results and harness-injected user-role context; the adapter answers each call with `mcpResult` on the same stream, appends such context to the last result, and keeps reading. Any other request, a Run that died while parked, or one older than `parkedRunTimeoutMs` falls back to a new Run that replays the in-flight turn with its results and sends a fixed continuation notice as the user message a Run requires; a `resumeAction` is not used because the server restarts the turn from its user message instead of continuing it. A Cursor-native or CLI Pi workspace exec (`read`, `shell`, `piRead`, and kin) is answered with its typed rejection naming the harness tool to call through `CallDynamicTool`, so the Run continues and the model reads the refusal as a tool outcome; text after a refused exec starts a new text block. A native Cursor question receives a typed rejection that directs the model to the harness `ask_user_question` MCP tool when available, or to ask in a reply otherwise; the Run continues. A CLI hook is answered with an empty matching response. An MCP-state exec returns the advertised `dsh` tools. Any other exec this build cannot type is answered with ExecClientThrow so the Run continues. An exec with no payload still fails the step.
|
|
72
72
|
|
|
73
73
|
Attribution headers required by `LlmAdapter` go on every HTTP/2 request, with Cursor client headers `x-ghost-mode`, `x-cursor-client-version`, and `x-cursor-client-type`.
|
|
74
74
|
|
|
@@ -68,7 +68,7 @@ TUI:`/login llm-cursor/cursor`。无头不会打开浏览器;导出 `CURSOR_
|
|
|
68
68
|
|
|
69
69
|
新的 Run 由 harness 历史、系统提示和 MCP 工具定义重建(`providerIdentifier: dsh`,`clientName: dsh`)。Cursor 服务端只从 `root_prompt_messages_json` 构建模型提示,从不把 `conversation_state.turns` 渲染进去,并且会丢弃其中的 `{"role":"system"}` 条目而使用自己的提示。因此适配器把系统提示作为 `<rules>` user 提示消息发布,并把每个先前轮次重放为 `user`、`assistant` 和 `tool` 提示消息,把每个历史 harness 工具调用写成 Cursor 为 MCP 工具记录的 `CallDynamicTool` 调用;轮次结构一同发送,供服务端记账。Cursor CLI 的 Run 只通过 `GetDynamicTools` 和 `CallDynamicTool` 向模型暴露 MCP 工具,因此请求上下文的应答额外带一条全局 Cursor 规则,告知模型 Cursor 内建工具在这里会返回拒绝、harness 工具以命名空间 `dsh` 中的 `CallDynamicTool` 调用,以及有哪些工具名。
|
|
70
70
|
|
|
71
|
-
文本、thinking、用量与 MCP 工具调用变成 `StreamChunk`。当 Cursor 发出模型最后一个并行调用之后的检查点,或 `toolCallSettleMs` 内没有新帧时,MCP 工具调用结束该步。若请求带有 Session 且不是压缩或标题请求,该 Run 随后挂起:适配器每五秒发送一次 `clientHeartbeat` 保持流开启。该 Session 的下一次请求在以下条件成立时恢复它:最后一条 assistant 消息之前的历史不变,且该消息之后只有待处理调用的结果以及 harness 注入的 user 角色上下文;适配器在同一条流上以 `mcpResult` 应答每个调用,把这类上下文追加到最后一个结果之后,并继续读取。任何其他请求、挂起期间死亡的 Run,或超过 `parkedRunTimeoutMs` 的 Run,都回退为新的 Run:它重放该进行中的轮次及其结果,并把一条固定的继续提示作为 Run 必需的用户消息发送;不使用 `resumeAction`,因为服务端会从该轮的用户消息重新开始而不是继续。Cursor 原生或 CLI Pi 工作区 exec(`read`、`shell`、`piRead` 及同类)以其类型化的拒绝应答,并指出应通过 `CallDynamicTool` 调用的 harness 工具,因此 Run 继续进行,模型把该拒绝当作工具结果读取;被拒绝的 exec 之后的文本开启新的文本块。CLI 钩子以空的匹配响应应答。MCP-state exec 返回已通告的 `dsh` 工具。本构建无法类型化的其他 exec 以 ExecClientThrow 应答,以便 Run 继续。没有 payload 的 exec 仍使该步失败。
|
|
71
|
+
文本、thinking、用量与 MCP 工具调用变成 `StreamChunk`。当 Cursor 发出模型最后一个并行调用之后的检查点,或 `toolCallSettleMs` 内没有新帧时,MCP 工具调用结束该步。若请求带有 Session 且不是压缩或标题请求,该 Run 随后挂起:适配器每五秒发送一次 `clientHeartbeat` 保持流开启。该 Session 的下一次请求在以下条件成立时恢复它:最后一条 assistant 消息之前的历史不变,且该消息之后只有待处理调用的结果以及 harness 注入的 user 角色上下文;适配器在同一条流上以 `mcpResult` 应答每个调用,把这类上下文追加到最后一个结果之后,并继续读取。任何其他请求、挂起期间死亡的 Run,或超过 `parkedRunTimeoutMs` 的 Run,都回退为新的 Run:它重放该进行中的轮次及其结果,并把一条固定的继续提示作为 Run 必需的用户消息发送;不使用 `resumeAction`,因为服务端会从该轮的用户消息重新开始而不是继续。Cursor 原生或 CLI Pi 工作区 exec(`read`、`shell`、`piRead` 及同类)以其类型化的拒绝应答,并指出应通过 `CallDynamicTool` 调用的 harness 工具,因此 Run 继续进行,模型把该拒绝当作工具结果读取;被拒绝的 exec 之后的文本开启新的文本块。Cursor 原生提问会收到类型化的拒绝:若 harness 提供 `ask_user_question` MCP 工具,拒绝会引导模型调用该工具;否则会引导模型在回复中提问。Run 随后继续。CLI 钩子以空的匹配响应应答。MCP-state exec 返回已通告的 `dsh` 工具。本构建无法类型化的其他 exec 以 ExecClientThrow 应答,以便 Run 继续。没有 payload 的 exec 仍使该步失败。
|
|
72
72
|
|
|
73
73
|
`LlmAdapter` 要求的归属头出现在每一次 HTTP/2 请求上,并带有 Cursor 客户端头 `x-ghost-mode`、`x-cursor-client-version` 和 `x-cursor-client-type`。
|
|
74
74
|
|
|
@@ -110,6 +110,11 @@ const AgentRunRequestSchema = /*@__PURE__*/ messageDesc(file_agent, 91);
|
|
|
110
110
|
*/
|
|
111
111
|
const InteractionResponseSchema = /*@__PURE__*/ messageDesc(file_agent, 111);
|
|
112
112
|
/**
|
|
113
|
+
* Describes the message agent.v1.AskQuestionInteractionResponse.
|
|
114
|
+
* Use `create(AskQuestionInteractionResponseSchema)` to create a new message.
|
|
115
|
+
*/
|
|
116
|
+
const AskQuestionInteractionResponseSchema = /*@__PURE__*/ messageDesc(file_agent, 117);
|
|
117
|
+
/**
|
|
113
118
|
* Describes the message agent.v1.ClientHeartbeat.
|
|
114
119
|
* Use `create(ClientHeartbeatSchema)` to create a new message.
|
|
115
120
|
*/
|
|
@@ -135,6 +140,16 @@ const GetUsableModelsRequestSchema = /*@__PURE__*/ messageDesc(file_agent, 126);
|
|
|
135
140
|
*/
|
|
136
141
|
const GetUsableModelsResponseSchema = /*@__PURE__*/ messageDesc(file_agent, 127);
|
|
137
142
|
/**
|
|
143
|
+
* Describes the message agent.v1.AskQuestionResult.
|
|
144
|
+
* Use `create(AskQuestionResultSchema)` to create a new message.
|
|
145
|
+
*/
|
|
146
|
+
const AskQuestionResultSchema = /*@__PURE__*/ messageDesc(file_agent, 145);
|
|
147
|
+
/**
|
|
148
|
+
* Describes the message agent.v1.AskQuestionRejected.
|
|
149
|
+
* Use `create(AskQuestionRejectedSchema)` to create a new message.
|
|
150
|
+
*/
|
|
151
|
+
const AskQuestionRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 149);
|
|
152
|
+
/**
|
|
138
153
|
* Describes the message agent.v1.BackgroundShellSpawnResult.
|
|
139
154
|
* Use `create(BackgroundShellSpawnResultSchema)` to create a new message.
|
|
140
155
|
*/
|
|
@@ -2719,6 +2734,25 @@ function approveWebSearch(stream, query) {
|
|
|
2719
2734
|
})
|
|
2720
2735
|
} });
|
|
2721
2736
|
}
|
|
2737
|
+
/** A human answer must return through a logged harness tool result or later user message. */
|
|
2738
|
+
function rejectNativeQuestion(stream, query, mcpTools) {
|
|
2739
|
+
const questionTool = mcpTools.some((tool) => tool.name === "ask_user_question");
|
|
2740
|
+
const refusal = "Cursor's built-in AskQuestion is not available in DeepSeek Harness.";
|
|
2741
|
+
const reason = questionTool ? `${refusal} Call ${DYNAMIC_TOOL_CALL} with namespace "dsh" and toolName "ask_user_question" instead.` : `${refusal} Ask the user in a reply before continuing.`;
|
|
2742
|
+
sendClient(stream, { message: {
|
|
2743
|
+
case: "interactionResponse",
|
|
2744
|
+
value: create(InteractionResponseSchema, {
|
|
2745
|
+
id: query.id,
|
|
2746
|
+
result: {
|
|
2747
|
+
case: "askQuestionInteractionResponse",
|
|
2748
|
+
value: create(AskQuestionInteractionResponseSchema, { result: create(AskQuestionResultSchema, { result: {
|
|
2749
|
+
case: "rejected",
|
|
2750
|
+
value: create(AskQuestionRejectedSchema, { reason })
|
|
2751
|
+
} }) })
|
|
2752
|
+
}
|
|
2753
|
+
})
|
|
2754
|
+
} });
|
|
2755
|
+
}
|
|
2722
2756
|
function* closeOpen(open) {
|
|
2723
2757
|
if (open === void 0) return;
|
|
2724
2758
|
if (open.type === "text") yield {
|
|
@@ -3009,6 +3043,12 @@ function handleServerMessage(message, run, state) {
|
|
|
3009
3043
|
approveWebSearch(stream, query);
|
|
3010
3044
|
return {};
|
|
3011
3045
|
}
|
|
3046
|
+
if (query.query.case === "askQuestionInteractionQuery") {
|
|
3047
|
+
chunks.push(...closeOpen(state.open));
|
|
3048
|
+
state.open = void 0;
|
|
3049
|
+
rejectNativeQuestion(stream, query, payload.mcpTools);
|
|
3050
|
+
return { chunks };
|
|
3051
|
+
}
|
|
3012
3052
|
throw new LlmError(`llm-cursor: unsupported Cursor interaction query ${query.query.case ?? "unknown"}`, "UNSUPPORTED_CONTENT");
|
|
3013
3053
|
}
|
|
3014
3054
|
return {};
|
|
@@ -468,6 +468,7 @@ function applyReadTool(ctx, caps) {
|
|
|
468
468
|
* Compute one {@link FileDiff} per hunk between `before` and `after`, each carrying the
|
|
469
469
|
* applied change plus {@link DIFF_CONTEXT} context lines. Pure insertions use `oldText: null`,
|
|
470
470
|
* patch-only no-newline markers are omitted, and scattered replacements remain separate hunks.
|
|
471
|
+
* Each side that holds lines carries the 1-based file line it starts at.
|
|
471
472
|
*
|
|
472
473
|
* @param path - the path stamped on every produced diff (the model-facing `file_path`; the
|
|
473
474
|
* bridge relativizes it).
|
|
@@ -494,16 +495,38 @@ function computeHunkDiffs(path, before, after) {
|
|
|
494
495
|
diffs.push({
|
|
495
496
|
path,
|
|
496
497
|
oldText: oldLines.length > 0 ? oldLines.join("\n") : null,
|
|
497
|
-
newText: newLines.join("\n")
|
|
498
|
+
newText: newLines.join("\n"),
|
|
499
|
+
...oldLines.length > 0 ? { oldStart: hunk.oldStart } : {},
|
|
500
|
+
...newLines.length > 0 ? { newStart: hunk.newStart } : {}
|
|
498
501
|
});
|
|
499
502
|
}
|
|
500
503
|
return diffs;
|
|
501
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* One {@link FileDiff} as `tool/result` metadata carries it: JSON with no key
|
|
507
|
+
* for a start the hunk has no line for.
|
|
508
|
+
* @param diff - one computed hunk.
|
|
509
|
+
* @returns the same hunk as a JSON object.
|
|
510
|
+
*/
|
|
511
|
+
function diffJson(diff) {
|
|
512
|
+
const { path, oldText, newText, oldStart, newStart } = diff;
|
|
513
|
+
return {
|
|
514
|
+
path,
|
|
515
|
+
oldText,
|
|
516
|
+
newText,
|
|
517
|
+
...oldStart === void 0 ? {} : { oldStart },
|
|
518
|
+
...newStart === void 0 ? {} : { newStart }
|
|
519
|
+
};
|
|
520
|
+
}
|
|
502
521
|
/** Whether `value` is a valid {@link FileDiff} (defensive narrowing from opaque `meta`). */
|
|
503
522
|
function isFileDiff(value) {
|
|
504
523
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
505
|
-
const { path, oldText, newText } = value;
|
|
506
|
-
return typeof path === "string" && (oldText === null || typeof oldText === "string") && typeof newText === "string";
|
|
524
|
+
const { path, oldText, newText, oldStart, newStart } = value;
|
|
525
|
+
return typeof path === "string" && (oldText === null || typeof oldText === "string") && typeof newText === "string" && (oldStart === void 0 || isLineNumber(oldStart)) && (newStart === void 0 || isLineNumber(newStart));
|
|
526
|
+
}
|
|
527
|
+
/** Whether `value` is a 1-based integer file line. */
|
|
528
|
+
function isLineNumber(value) {
|
|
529
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1;
|
|
507
530
|
}
|
|
508
531
|
/**
|
|
509
532
|
* Narrow opaque live or replayed result metadata to non-empty file diffs. Malformed metadata
|
|
@@ -633,11 +656,7 @@ function applyWriteTool(ctx, sandbox) {
|
|
|
633
656
|
}],
|
|
634
657
|
presentationMeta: (args, value) => ({
|
|
635
658
|
operation: value.operation,
|
|
636
|
-
diffs: value.before === null ? [] : computeHunkDiffs(args.file_path, value.before, value.after).map(
|
|
637
|
-
path,
|
|
638
|
-
oldText,
|
|
639
|
-
newText
|
|
640
|
-
}))
|
|
659
|
+
diffs: value.before === null ? [] : computeHunkDiffs(args.file_path, value.before, value.after).map(diffJson)
|
|
641
660
|
})
|
|
642
661
|
},
|
|
643
662
|
async execute(args, exec) {
|
|
@@ -783,11 +802,7 @@ function applyEditTool(ctx, sandbox) {
|
|
|
783
802
|
type: "text",
|
|
784
803
|
text: formatEditOutput(value.path, args.replace_all ?? false)
|
|
785
804
|
}],
|
|
786
|
-
presentationMeta: (args, value) => ({ diffs: computeHunkDiffs(args.file_path, value.before, value.after).map(
|
|
787
|
-
path,
|
|
788
|
-
oldText,
|
|
789
|
-
newText
|
|
790
|
-
})) })
|
|
805
|
+
presentationMeta: (args, value) => ({ diffs: computeHunkDiffs(args.file_path, value.before, value.after).map(diffJson) })
|
|
791
806
|
},
|
|
792
807
|
async execute(args, exec) {
|
|
793
808
|
const input = parseEditArgs(args);
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/bundle/tui-app/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 43fe458849dbafab87e261e836c8f2c517180939
|
|
6
|
+
README.zh.md: be7f1011249aa0d9dfbb853644f8d23ebf79fc8e
|
|
@@ -40,7 +40,7 @@ On quit the app prints `dsh: session <id> saved; resume with: dsh --profile tui
|
|
|
40
40
|
|
|
41
41
|
### The screen
|
|
42
42
|
|
|
43
|
-
The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, and each tool call is a card with a `◆` glyph coloured by status — yellow while it runs, green once done, red on failure — the bold tool name, the presenter headline in violet, a loading row while it runs, and a body folded to `toolPreviewLines` rows. The card appears when the model starts the call; the result rows float out when the tool answers. An `edit` or `write` diff card frames each run of consecutive additions in a green rounded box and each run of removals in a red one, the removed rows above the added ones. A `subagent` or `subagent_*` card draws folded as one row behind the same status-coloured `◆`, dim for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use warm orange, links and inline code use violet, and quotes stay dim. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
|
|
43
|
+
The header names the session by its title once one is generated or set, with the id beside it. The transcript grows in the terminal's own scrollback: your prompts start with `❯` on a tinted full-width band while colour is on (attachments listed under them), assistant reasoning is dim italic under a `✻ Thinking` header above the Markdown reply, and each tool call is a card with a `◆` glyph coloured by status — yellow while it runs, green once done, red on failure — the bold tool name, the presenter headline in violet, a loading row while it runs, and a body folded to `toolPreviewLines` rows. The card appears when the model starts the call, its header first and its rows unrolling beneath it over about `toolRevealFrames` frames; the result rows unroll and float out the same way when the tool answers. An `edit` or `write` diff card frames each run of consecutive additions in a green rounded box and each run of removals in a red one, the removed rows above the added ones; once the tool applied the change, the applied hunks replace the diff the call carried and lead every row with its file line number, the new file's for added and unchanged rows and the old file's for removed rows. A `subagent` or `subagent_*` card draws folded as one row behind the same status-coloured `◆`, dim for a child handed to the background: while it runs, the tool name, the task description, and the requested model and `background` when the call names them; once settled, the description dimmed with `[done]`, `[started]` for a child handed to the background, or `[failed]` at the right edge. `Space` on the marked row, or `Ctrl+O`, unfolds the full card. A nonempty system prompt and each injected context — instructions, catalogs, snapshots, notices, relays, and recalls — draw as a dim `⬡` title over the first `contextPreviewLines` rows of their model-facing text, with each snapshot contribution named above its own rows; an empty system prompt and a compaction replacement are omitted. A tool card and a context block that carry more rows than they draw end on one marker: `… <n> more rows · Space expands` while the conversation's focus holds that block, and `… <n> more rows · Ctrl+O expands` otherwise. Fenced code in a reply, the file rows of a `read` card, the changed rows of an `edit` or `write` diff card — with `+` additions marked green, `-` removals red, and source text behind those signs drawn in the language the file's extension names — and the shell command of a `!` / `!!` draft, a `$ command` user-shell row (its `$` in the accent colour), and a terminal tool card, use syntax colours from a theme the terminal's own background picks, light or dark; the grammar of a language loads on the first block that asks for it, so that block draws plain and is repainted in colour a moment later, and a language with no grammar here, a terminal that reports neither 24-bit nor 256 colours, and `codeHighlight: false` each draw every block plain. Headings and list markers use warm orange, links and inline code use violet, and quotes stay dim. Streamed reasoning, reply text, and tool arguments are queued as they arrive and drawn a share per frame, about 60 frames per second by default, so a network burst spreads over `streamPaceFrames` frames instead of landing at once, and the queue never holds the model call back. Streamed reply text fades in and every word keeps its own clock: a word enters near the terminal's background color and brightens to the color it settles in over `streamFadeSteps` ticks of `streamFadeStepMs` each, so a fast stream leaves a longer trail of brightening words rather than a darker one. Streamed reasoning and a tool card float out over the same duration: they appear at a lifted color and recede to the dim italic or palette colors they settle in; a card redrawn from persisted history carries no fade, and text that has settled is never dimmed again.
|
|
44
44
|
|
|
45
45
|
Below the transcript sit a spinner while the agent works — its label is `thinking` while the model reasons, `writing` while visible text arrives, or `calling <tool>` while a tool is streamed or still running, plus live `↑` send and `↓` receive tokens for the current model call, as compact `k` / `M` / `B` counts, growing as the stream arrives and settling on the provider usage chunk — any open prompt, a boxed follow-ups list while messages wait, an activity board of the open turn's todos and latest descendant line while either has a row — completed todo content scratched out and status glyphs colored green, yellow, or cyan, at most four todo rows then `+<n> more`, not a focus region, gone on `turn/end` and bind — the editor, the subagent panel, and the footer: a status bar that, unfocused, is one line built from both ends inward. The editor's caret is the terminal's own blinking bar: the app asks for that shape at start, gives your default back on quit, and draws no caret at all while the status bar or the panel holds the keyboard. The model and entry keys are colored; live turn, context, and todo facts use yellow, violet, and green. The model is anchored at the left edge and is never dropped — past 20 columns it falls back to the bare model name, and only a label still too wide for that is ellipsized — and the two keys that leave the input are anchored at the right edge as `Shift+↑ read · Shift+↓ status`, or `Shift+↑ select · Shift+↓ status` while follow-ups wait, narrowing to `Shift+↑↓ nav` and dropped below 40 columns. The key facts fill whatever middle is left, in bar order: effort (`effort default` when the selection leaves reasoning to the model), the running turn's elapsed time, the context window percentage, the todo counts, and the workspace path (shortened with `~` and `…/` when long). Every segment that middle cannot hold folds into a trailing `+N`, together with the segments the unfocused line never draws — the permission preset, token usage (session totals plus the in-flight call), the goal and plan-mode markers from the projection seam, and the count of pending attachments. Compaction and model-request retries appear as notices, the same facts the browser's markers carry.
|
|
46
46
|
|
|
@@ -54,7 +54,7 @@ Transient key feedback floats as a dim framed line in the top-right corner of th
|
|
|
54
54
|
|
|
55
55
|
Motion reaches past streamed text, and every effect rides the same fade tick. The keyboard landing on the conversation, the subagent panel, or the status bar lifts that surface's frame, its chip, and the mark it holds for twelve ticks of `streamFadeStepMs`; a step of the conversation walk lifts the newly focused gutter for six; and a step along the bar lifts the selected label for eight. A new or status-changed activity-board todo row, and a replaced descendant line, float out on that tick the same way a tool card does; replay and `reducedMotion` draw the settled board. The reader arrives complete on the screen it owns, and what it newly shows floats out on that tick the way a tool card does: opening it and showing another turn float out the whole turn, and stepping the list to another section of the same turn floats out that section, over `streamFadeSteps` ticks; scrolling, live growth, and a rewrap float nothing out. No lift changes how many lines anything draws, and `reducedMotion` — like `NO_COLOR`, a disabled palette, and `TERM=dumb` — turns every one of them off and arms no repaint for them.
|
|
56
56
|
|
|
57
|
-
The subagent panel is drawn while a subagent session under the bound one is resident, or the listing carries a candidate it could not read. Unfocused it is one summary line with the listed count and the first child's key label; focused, its heading counts what it lists and ends on the keys it answers, `↑↓ children · Enter opens · Tab regions · Esc input`, narrowed to `↑↓ children · Esc input` and then to `Esc input` on a terminal that cannot hold them, and each row gives the child's depth indent, its label or id, its mode (`one-shot` or `continuable`), `resident`, whether its agent is `running` or `idle`, its elapsed time — the open turn's, else the total its settled turns took — and its token usage, as far as this process's own view of that child and the composed projections carry them. Six rows are drawn at most, with `+<n> more · /subagents lists them all` under them; a candidate the listing could not interpret draws as `unreadable: <reason>` and opens nothing, and a failed listing keeps the rows the last good one produced with `listing failed: <reason>` beneath. The panel disappears with its last row. `Enter` or `Right` on a readable row, like `Enter` on a readable `/subagents` row, opens that child as a subagent view: the terminal draws the child session in place of the bound one — its transcript, live stream, conversation walk, inspector, reader, and its own subagent panel — while the session it was entered from stays open. A resident child is read live, and any other is resumed. The entry's detail rows print as notices under `subagent <label> · Ctrl+P or /parent returns to session <id>`, the header ends on `◆ subagent view ›` with one `›` per level entered and `· Ctrl+P returns`, and `Ctrl+P` or `/parent` goes back one level, redrawing the parent from its log as it stands then. `/new`, `/clear`, `/resume`, `/sessions`, and `/fork` refuse while any session in that chain runs a turn, and otherwise release every view with the session they leave; quitting releases every view and saves the root session.
|
|
57
|
+
The subagent panel is drawn while a subagent session under the bound one is resident, or the listing carries a candidate it could not read. Unfocused it is one summary line with the listed count and the first child's key label; focused, its heading counts what it lists and ends on the keys it answers, `↑↓ children · Enter opens · Tab regions · Esc input`, narrowed to `↑↓ children · Esc input` and then to `Esc input` on a terminal that cannot hold them, and each row gives the child's depth indent, its label or id, its mode (`one-shot` or `continuable`), `resident`, whether its agent is `running` or `idle`, its elapsed time — the open turn's, else the total its settled turns took — and its token usage, as far as this process's own view of that child and the composed projections carry them. Six rows are drawn at most, with `+<n> more · /subagents lists them all` under them; a candidate the listing could not interpret draws as `unreadable: <reason>` and opens nothing, and a failed listing keeps the rows the last good one produced with `listing failed: <reason>` beneath. The panel disappears with its last row. `Enter` or `Right` on a readable row, like `Enter` on a readable `/subagents` row, opens that child as a subagent view: the terminal draws the child session in place of the bound one — its transcript, live stream, conversation walk, inspector, reader, and its own subagent panel — while the session it was entered from stays open. A resident child is read live, and any other is resumed. The entry's detail rows print as notices under `subagent <label> · Ctrl+P or /parent returns to session <id>`, the header ends on `◆ subagent view ›` with one `›` per level entered and `· Ctrl+P returns`, a shaded line directly above the input reads `◆ subagent view · main › <label> · Ctrl+P back to <parent>` for as long as the view is open, whatever the transcript has scrolled to, and `Ctrl+P` or `/parent` goes back one level, redrawing the parent from its log as it stands then. `/new`, `/clear`, `/resume`, `/sessions`, and `/fork` refuse while any session in that chain runs a turn, and otherwise release every view with the session they leave; quitting releases every view and saves the root session.
|
|
58
58
|
|
|
59
59
|
### Keys and commands
|
|
60
60
|
|
|
@@ -228,7 +228,8 @@ An approval request draws `Allow <tool>?` with the asker's reason, the logged ca
|
|
|
228
228
|
| `liveRefreshMs` | `1000` | Period of the redraw that advances the `turn` segment and the panel's elapsed values and re-reads a stale subagent listing |
|
|
229
229
|
| `streamFadeSteps` | `24` | How many ticks a fade lasts: reply text fades in, reasoning and tool cards float out, over `streamFadeSteps × streamFadeStepMs` |
|
|
230
230
|
| `streamFadeStepMs` | `16` | One frame: the fade tick, the repaint period while anything is still moving, and the period paced stream text is drawn at; duration is `streamFadeSteps × streamFadeStepMs` |
|
|
231
|
-
| `streamPaceFrames` | `8` | Frames a backlog of streamed
|
|
231
|
+
| `streamPaceFrames` | `8` | Frames a backlog of streamed reply text or tool arguments takes to reach the screen. Thinking still queued when its block ends, or when reply text or a tool call starts, is drawn at once; `0`, like `reducedMotion`, draws each delta as it arrives |
|
|
232
|
+
| `toolRevealFrames` | `6` | Frames the rows of a tool card take to unroll when the card appears or its result lands, a share of the hidden rows per frame. Unfolding a card, and a card whose unrolling rows are above the part of the screen the renderer can repaint, draw every row at once; `0`, like `reducedMotion`, draws every row at once |
|
|
232
233
|
| `reducedMotion` | `false` | Draw streamed text, streamed reasoning, tool cards, and the chrome in their settled colors, with no fade, no lift, and no repeating repaint |
|
|
233
234
|
| `openBrowser` | `true` | Hand marked authorization pages to the local default browser |
|
|
234
235
|
|
|
@@ -279,7 +280,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
|
|
|
279
280
|
| [`src/screen.ts`](src/screen.ts) | The main screen with the settle passes between building a frame and writing it, the repaint window each pass is judged against, the per-block repaint floor, and the suspension that holds the conversation off the terminal |
|
|
280
281
|
| [`src/alt-screen.ts`](src/alt-screen.ts) | The terminal's alternate screen: taking it, drawing absolutely addressed rows on it, and giving the conversation's own screen back |
|
|
281
282
|
| [`src/fade.ts`](src/fade.ts) | The streamed-text fade: the wall-clock tail tracker, the block-fade clock and registry, the fade-in ramp, the float-out mix, and the recolor of rendered lines |
|
|
282
|
-
| [`src/pace.ts`](src/pace.ts) | The stream pacer: the ordered queue between the assistant stream and the transcript, drained a backlog share per frame |
|
|
283
|
+
| [`src/pace.ts`](src/pace.ts) | The stream pacer: the ordered queue between the assistant stream and the transcript, drained a backlog share per frame; and the row reveal that unrolls a tool card the same way |
|
|
283
284
|
| [`src/motion.ts`](src/motion.ts) | The chrome motion clock and the three-level lift its call sites draw with: the landing, the section step, and the bar walk |
|
|
284
285
|
| [`src/prompts.ts`](src/prompts.ts) | Approval, question, picker, and read-only detail prompts plus the modal queue |
|
|
285
286
|
| [`src/toast.ts`](src/toast.ts) | The transient key-feedback line: its overlay, its clock, and the lines it carries |
|
|
@@ -296,6 +297,7 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
|
|
|
296
297
|
| [`src/queue-panel.ts`](src/queue-panel.ts) | The follow-ups list: pending-row glyphs, hanging wrap, and the enter-steer legend |
|
|
297
298
|
| [`src/activity-board.ts`](src/activity-board.ts) | The activity board: todo glyphs, the completed scratch-out, the row cap, and the one-line descendant summary |
|
|
298
299
|
| [`src/catalog.ts`](src/catalog.ts) | Rows for `/settings`, `/plugins`, `/subagents`, `/deliverables`, `/changes`, and `/outline`, and the `/plugins` management verbs |
|
|
300
|
+
| [`src/view-banner.ts`](src/view-banner.ts) | The line above the input that names an open subagent view and the key back |
|
|
299
301
|
| [`src/todos.ts`](src/todos.ts) | The todo list: the status glyphs, the picker rows with completed content scratched out, and one item's detail rows |
|
|
300
302
|
| [`cordis.patch.yml`](cordis.patch.yml) | The terminal patch over `dsh-base` |
|
|
301
303
|
| — | No runtime invariant companion is published; the app registers listeners on one Agent and holds no mutable relation another observer could contradict. |
|
|
@@ -305,8 +307,9 @@ The patch rides over `dsh-base`: it sets the coding persona prefix and cwd suffi
|
|
|
305
307
|
| [`tests/editor.spec.ts`](tests/editor.spec.ts) | The terminal caret, `Shift+Left` / `Shift+Right` word navigation, and `!` / `!!` draft colour against pi-tui's editor behavior |
|
|
306
308
|
| [`tests/frame.spec.ts`](tests/frame.spec.ts) | The rules, the chip, the body rows, and the legend a width holds |
|
|
307
309
|
| [`tests/motion.spec.ts`](tests/motion.spec.ts) | The motion clock's levels, its repaint demand, and the lift each level draws |
|
|
308
|
-
| [`tests/pace.spec.ts`](tests/pace.spec.ts) | The pacer's per-frame share, grapheme cuts, arrival order, flush, and clear |
|
|
309
|
-
| [`tests/stream-pace.spec.ts`](tests/stream-pace.spec.ts) | Paced
|
|
310
|
+
| [`tests/pace.spec.ts`](tests/pace.spec.ts) | The pacer's per-frame share, grapheme cuts, arrival order, flush, per-channel flush, and clear, and the row reveal's per-frame share, settle, and clamp |
|
|
311
|
+
| [`tests/stream-pace.spec.ts`](tests/stream-pace.spec.ts) | Paced reply text and tool arguments in stream order, thinking drawn when its block ends, the flush at stream end and before a logged event, reduced motion, and tool cards unrolling on the frame tick |
|
|
312
|
+
| [`tests/view-banner.spec.ts`](tests/view-banner.spec.ts) | The subagent-view line's trail, back target, width, and absence at the main session |
|
|
310
313
|
| [`tests/toast.spec.ts`](tests/toast.spec.ts) | The transient line's box, its hold, its fade, and its early settlement |
|
|
311
314
|
| [`tests/reader.spec.ts`](tests/reader.spec.ts) | The reader's geometry, its state machine, its filter, and the rows it returns |
|
|
312
315
|
| [`tests/reader-screen.spec.ts`](tests/reader-screen.spec.ts) | The reader pane: its key map, the screen it fills, its re-anchoring, and its exit |
|
|
@@ -40,7 +40,7 @@ dsh tui --no-open # print sign-in URLs without opening a
|
|
|
40
40
|
|
|
41
41
|
### 屏幕布局
|
|
42
42
|
|
|
43
|
-
页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,每次工具调用是一张卡片,含按状态着色的 `◆` 符号(运行中为黄色、完成为绿色、失败为红色)、粗体工具名、以紫色显示的呈现器标题、运行中的一行加载标记,以及折叠到 `toolPreviewLines`
|
|
43
|
+
页眉在标题生成或设置后以标题命名会话,并在旁边显示 id。对话记录在终端自身的回滚区中增长:你的提示以 `❯` 开头,启用颜色时铺在一条通栏的着色背景带上(附件列在其下),assistant 的推理以暗色斜体显示在 `✻ Thinking` 标题之下、Markdown 回复上方,每次工具调用是一张卡片,含按状态着色的 `◆` 符号(运行中为黄色、完成为绿色、失败为红色)、粗体工具名、以紫色显示的呈现器标题、运行中的一行加载标记,以及折叠到 `toolPreviewLines` 行的正文。卡片在模型开始调用时出现,先画标题,其下各行在约 `toolRevealFrames` 帧内逐行展开;工具回答后,结果行也以同样方式展开并浮出。`edit` 或 `write` diff 卡片把每一段连续新增行框进绿色圆角框、每一段连续删除行框进红色圆角框,删除的旧行在上、新增的新行在下;工具应用变更后,已应用的 hunk 取代调用时携带的 diff,并在每行前标出文件行号,新增行与未变行用新文件的行号,删除行用旧文件的行号。`subagent` 与 `subagent_*` 卡片折叠时只画一行,行首是同样按状态着色的 `◆`,交给后台的子 agent 则为暗色:运行中显示工具名、任务描述,以及调用指定的模型与 `background`;结束后描述变暗,右端标出 `[done]`,交给后台的子 agent 标 `[started]`,失败标 `[failed]`。在被标记的行上按 `Space`,或按 `Ctrl+O`,即可展开完整卡片。非空的系统提示词与每一条注入的上下文——instructions、catalogs、snapshots、notices、relays 与 recalls——绘制为暗色 `⬡` 标题,其下是面向模型文本的前 `contextPreviewLines` 行,快照的每一份贡献具名写在其自身各行上方;空的系统提示词与压缩替换则省略。承载的行数多于其绘制行数的工具卡片与上下文块,结尾都是同一条标记:该块被对话记录的焦点持有时为 `… <n> more rows · Space expands`,否则为 `… <n> more rows · Ctrl+O expands`。回复中的围栏代码、`read` 卡片的文件行、`edit` 或 `write` diff 卡片的变更行——其中 `+` 新增项标为绿色、`-` 删除项标为红色,符号后的源文本按文件扩展名对应的语言绘制——以及 `!` / `!!` 草稿、用户 shell 的 `$ command` 行(其 `$` 用强调色)与终端工具卡片中的 shell 命令,都使用语法高亮,配色主题由终端自身的背景在明暗之间选定;某种语言的语法会在第一个用到它的代码块出现时才加载,因此该块先以纯文本绘制、随后被重绘为彩色;这里没有对应语法的语言、既不支持 24 位也不支持 256 色的终端,以及 `codeHighlight: false`,都会把每个代码块画成纯文本。标题与列表标记使用暖橙色,链接与行内代码使用紫色,引用保持暗色。流式推理、回复文字与工具参数到达时先入队,再按帧(默认约每秒 60 帧)分批绘制,因此一次网络突发会分摊到 `streamPaceFrames` 帧里,而不是一次落下,队列也从不拖慢模型调用。流式回复文字会淡入,而且每个词各走各的时钟:一个词以接近终端背景色的亮度出现,并经 `streamFadeSteps` 次、每次 `streamFadeStepMs` 提亮到它最终稳定的颜色,因此流得更快只会留下更长的一串正在提亮的词,而不会更暗。流式推理与工具卡片在同一时长内浮出:它们以抬高的颜色出现,再退回到稳定时的暗色斜体或调色板颜色;从持久化历史重绘的卡片不带淡入,已经稳定下来的文字也不会再被调暗。
|
|
44
44
|
|
|
45
45
|
对话记录下方依次是 agent 工作时的旋转指示——其标签在模型推理时为 `thinking`,可见文本到达时为 `writing`,工具正在流出或仍在执行时为 `calling <tool>`,并带着当前这次模型调用的实时 `↑` 发送与 `↓` 接收 token,以紧凑的 `k` / `M` / `B` 计数,随数据流入增长,并在提供方的 usage 块到达后落定——任何打开的提示、有消息等待时的带框 follow-ups 列表、本轮 todo 与最新后代行的 activity board(有行时才绘制;已完成内容划掉,状态符号以绿色、黄色或青色显示,todo 最多四行其后 `+<n> more`,不是焦点区域,在 `turn/end` 与 bind 时消失)、编辑器、子 agent 面板,以及页脚:未聚焦时是一行由两端向内构建的状态栏。编辑器的光标是终端自身的闪烁竖条:应用在启动时请求这一形状,退出时把你的默认形状还回去,而状态栏或面板持有键盘期间完全不绘制光标。模型与入口按键带有颜色;进行中的轮次、上下文与 todo 信息分别使用黄色、紫色与绿色。模型锚定在左端且永不丢弃——超过 20 列时退回到裸模型名,只有仍然过宽的标签才会被省略号截断——离开编辑器的那两个按键则锚定在右端,写作 `Shift+↑ read · Shift+↓ status`,有 follow-ups 等待时则写作 `Shift+↑ select · Shift+↓ status`,窄到一定程度收缩为 `Shift+↑↓ nav`,不足 40 列时整体丢弃。关键事实填满剩下的中间部分,按状态栏顺序排列:推理强度(选择把推理交给模型时标为 `effort default`)、进行中轮次的已用时间、上下文窗口百分比、todo 计数,以及 workspace 路径(过长时以 `~` 与 `…/` 缩短)。中间部分容纳不下的每个分段都折进末尾的 `+N`,未聚焦行从不绘制的那些分段也一并折入——权限预设、token 用量(会话合计加上进行中的这次调用)、来自投影接缝的目标与计划模式标记,以及待发送附件的数量。压缩与模型请求重试以通知形式出现,与浏览器标记承载的事实相同。
|
|
46
46
|
|
|
@@ -54,7 +54,7 @@ dsh tui --no-open # print sign-in URLs without opening a
|
|
|
54
54
|
|
|
55
55
|
动效不止于流式文本,而且每种效果都乘着同一个淡入时钟。键盘落到对话记录、子 agent 面板或状态栏上时,会把该表层的边框、其徽标与它持有的标记抬亮十二拍(每拍一个 `streamFadeStepMs`);对话记录走查中的一步把新聚焦的标记条抬亮六拍;状态栏上的一步把所选标签抬亮八拍。活动板上新出现或状态已变的 todo 行,以及被替换的后代行,也在同一时钟上像工具卡片一样浮出;重放与 `reducedMotion` 则画出已稳定的活动板。阅读器在自己占据的屏幕上一次性完整出现,而它新显示的内容会像工具卡片一样在同一时钟上浮出:打开它与显示另一个轮次时浮出整个轮次,在列表中步进到同一轮次的另一个小节时浮出该小节,历时 `streamFadeSteps` 拍;滚动、实时增长与重新换行都不浮出任何内容。任何抬亮都不改变任何东西绘制的行数,而 `reducedMotion`——与 `NO_COLOR`、被禁用的调色板和 `TERM=dumb` 一样——会把它们全部关闭,并且不为它们安排任何重绘。
|
|
56
56
|
|
|
57
|
-
子 agent 面板在绑定会话之下有常驻的子 agent 会话、或列表中带有无法读取的候选者时绘制。未聚焦时它是一行摘要,含列出的数量与第一个子会话的关键标签;聚焦时其标题统计所列出的条目,并以它所应答的按键 `↑↓ children · Enter opens · Tab regions · Esc input` 结尾,在容纳不下时收缩为 `↑↓ children · Esc input`,再收缩为 `Esc input`;每一行给出该子会话的层级缩进、其标签或 id、其模式(`one-shot` 或 `continuable`)、`resident`、其 agent 处于 `running` 还是 `idle`、其已用时间——进行中轮次的用时,否则是已结束轮次的合计——以及其 token 用量,以本进程对该子会话的可见程度与已组合的投影所能提供的为限。最多绘制六行,其下是 `+<n> more · /subagents lists them all`;列表无法解读的候选者绘制为 `unreadable: <reason>` 且打不开任何页面,读取失败的列表则保留上一次成功读取产生的各行,并在其下写出 `listing failed: <reason>`。面板随其最后一行一同消失。在可读的行上按 `Enter` 或 `Right`,与在可读的 `/subagents` 行上按 `Enter` 一样,会把该子会话作为子 agent 视图打开:终端在已绑定会话的位置绘制子会话——其对话记录、实时流、对话记录走查、检查器、阅读器以及它自己的子 agent 面板——而进入它之前的会话保持打开。常驻的子会话被实时读取,其他子会话则被恢复。条目的详情行作为通知打印在 `subagent <label> · Ctrl+P or /parent returns to session <id>` 之下,页眉以 `◆ subagent view ›`(每进入一层一个 `›`)与 `· Ctrl+P returns`
|
|
57
|
+
子 agent 面板在绑定会话之下有常驻的子 agent 会话、或列表中带有无法读取的候选者时绘制。未聚焦时它是一行摘要,含列出的数量与第一个子会话的关键标签;聚焦时其标题统计所列出的条目,并以它所应答的按键 `↑↓ children · Enter opens · Tab regions · Esc input` 结尾,在容纳不下时收缩为 `↑↓ children · Esc input`,再收缩为 `Esc input`;每一行给出该子会话的层级缩进、其标签或 id、其模式(`one-shot` 或 `continuable`)、`resident`、其 agent 处于 `running` 还是 `idle`、其已用时间——进行中轮次的用时,否则是已结束轮次的合计——以及其 token 用量,以本进程对该子会话的可见程度与已组合的投影所能提供的为限。最多绘制六行,其下是 `+<n> more · /subagents lists them all`;列表无法解读的候选者绘制为 `unreadable: <reason>` 且打不开任何页面,读取失败的列表则保留上一次成功读取产生的各行,并在其下写出 `listing failed: <reason>`。面板随其最后一行一同消失。在可读的行上按 `Enter` 或 `Right`,与在可读的 `/subagents` 行上按 `Enter` 一样,会把该子会话作为子 agent 视图打开:终端在已绑定会话的位置绘制子会话——其对话记录、实时流、对话记录走查、检查器、阅读器以及它自己的子 agent 面板——而进入它之前的会话保持打开。常驻的子会话被实时读取,其他子会话则被恢复。条目的详情行作为通知打印在 `subagent <label> · Ctrl+P or /parent returns to session <id>` 之下,页眉以 `◆ subagent view ›`(每进入一层一个 `›`)与 `· Ctrl+P returns` 结尾,只要视图打开,输入框正上方就有一条着色行写着 `◆ subagent view · main › <label> · Ctrl+P back to <parent>`,无论对话记录滚动到哪里,`Ctrl+P` 或 `/parent` 返回上一层,并按父会话此刻的日志重绘它。只要这条链中任一会话正在运行轮次,`/new`、`/clear`、`/resume`、`/sessions` 与 `/fork` 都会拒绝,否则它们会随所离开的会话释放每一个视图;退出会释放每一个视图并保存根会话。
|
|
58
58
|
|
|
59
59
|
### 按键与命令
|
|
60
60
|
|
|
@@ -228,7 +228,8 @@ follow-ups 面板持有键盘时:
|
|
|
228
228
|
| `liveRefreshMs` | `1000` | 重绘周期:推进 `turn` 分段与面板中的已用时间,并重新读取已过期的子 agent 列表 |
|
|
229
229
|
| `streamFadeSteps` | `24` | 一次淡入或浮出持续多少拍:回复文字淡入,推理与工具卡片浮出,时长为 `streamFadeSteps × streamFadeStepMs` |
|
|
230
230
|
| `streamFadeStepMs` | `16` | 一帧的时长:淡入或浮出的一拍、仍在变化时的重绘周期,也是逐帧绘制流式文字的周期;总时长为 `streamFadeSteps × streamFadeStepMs` |
|
|
231
|
-
| `streamPaceFrames` | `8` |
|
|
231
|
+
| `streamPaceFrames` | `8` | 积压的流式回复文字或工具参数要经过多少帧才全部上屏。思考块结束时,或回复文字或工具调用开始时,仍在队列中的思考立即画出;`0` 与 `reducedMotion` 一样,收到即绘制 |
|
|
232
|
+
| `toolRevealFrames` | `6` | 工具卡片出现或其结果落下时,其各行展开所用的帧数,每帧展开隐藏行的一份。展开卡片,以及正在展开的行已位于渲染器可重绘范围之上的卡片,都会一次画出所有行;`0` 与 `reducedMotion` 一样,一次画出所有行 |
|
|
232
233
|
| `reducedMotion` | `false` | 以稳定颜色绘制流式文本、流式推理、工具卡片与应用自身的边框装饰,不做淡入、不做抬亮,也不重复重绘 |
|
|
233
234
|
| `openBrowser` | `true` | 把被标记的授权页面交给本地默认浏览器 |
|
|
234
235
|
|
|
@@ -279,7 +280,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
|
|
|
279
280
|
| [`src/screen.ts`](src/screen.ts) | 在构建一帧与写出该帧之间带若干次结算的主屏幕、每次结算所依据的重绘窗口、每个块的重绘下界,以及把对话记录挡在终端之外的挂起 |
|
|
280
281
|
| [`src/alt-screen.ts`](src/alt-screen.ts) | 终端的备用屏幕:接管它、在其上按绝对行址绘制,以及把对话记录自己的屏幕交还 |
|
|
281
282
|
| [`src/fade.ts`](src/fade.ts) | 流式文本淡入与浮出:基于挂钟的尾部追踪器、块时钟与注册表、淡入亮度级别、浮出混合,以及对已渲染行的重新着色 |
|
|
282
|
-
| [`src/pace.ts`](src/pace.ts) |
|
|
283
|
+
| [`src/pace.ts`](src/pace.ts) | 流式节拍器:助手流与对话记录之间的有序队列,每帧释放积压的一份;以及以同样方式展开工具卡片的逐行展开器 |
|
|
283
284
|
| [`src/motion.ts`](src/motion.ts) | 边框装饰的动效时钟与其调用点所绘的三级抬亮:落键、小节步进与状态栏走查 |
|
|
284
285
|
| [`src/prompts.ts`](src/prompts.ts) | 审批、提问、选择器与只读详情提示以及模态队列 |
|
|
285
286
|
| [`src/toast.ts`](src/toast.ts) | 临时按键提示行:其浮层、其时钟,以及它承载的各条文字 |
|
|
@@ -296,6 +297,7 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
|
|
|
296
297
|
| [`src/queue-panel.ts`](src/queue-panel.ts) | follow-ups 列表:待处理行符号、悬挂换行与 enter-steer 图例 |
|
|
297
298
|
| [`src/activity-board.ts`](src/activity-board.ts) | activity board:todo 状态符号、已完成内容划掉、行数上限,以及一行后代摘要 |
|
|
298
299
|
| [`src/catalog.ts`](src/catalog.ts) | `/settings`、`/plugins`、`/subagents`、`/deliverables`、`/changes` 与 `/outline` 的行,以及 `/plugins` 的管理动作 |
|
|
300
|
+
| [`src/view-banner.ts`](src/view-banner.ts) | 输入框上方标明已打开的子 agent 视图及返回按键的一行 |
|
|
299
301
|
| [`src/todos.ts`](src/todos.ts) | todo 列表:状态符号、已完成内容划掉的选择器行与单个条目的详情行 |
|
|
300
302
|
| [`cordis.patch.yml`](cordis.patch.yml) | 基于 `dsh-base` 的终端 patch |
|
|
301
303
|
| — | 不发布运行时不变量伴随模块;应用只在一个 Agent 上注册监听器,不持有其他观察者可能与之矛盾的可变关系。 |
|
|
@@ -305,8 +307,9 @@ runner 等待完整应用就绪(`ctx.get('loader')?.await()`),并在核心
|
|
|
305
307
|
| [`tests/editor.spec.ts`](tests/editor.spec.ts) | 对照 pi-tui 编辑器行为验证终端光标、`Shift+Left` / `Shift+Right` 词导航,以及 `!` / `!!` 草稿着色 |
|
|
306
308
|
| [`tests/frame.spec.ts`](tests/frame.spec.ts) | 边框线、徽标、正文行,以及某个宽度容纳得下的按键提示 |
|
|
307
309
|
| [`tests/motion.spec.ts`](tests/motion.spec.ts) | 动效时钟的各个级别、它对重绘的要求,以及每一级所绘的抬亮 |
|
|
308
|
-
| [`tests/pace.spec.ts`](tests/pace.spec.ts) | 节拍器的每帧份额、按字素切分、到达顺序、flush 与 clear |
|
|
309
|
-
| [`tests/stream-pace.spec.ts`](tests/stream-pace.spec.ts) |
|
|
310
|
+
| [`tests/pace.spec.ts`](tests/pace.spec.ts) | 节拍器的每帧份额、按字素切分、到达顺序、flush、按通道 flush 与 clear,以及逐行展开器的每帧份额、settle 与 clamp |
|
|
311
|
+
| [`tests/stream-pace.spec.ts`](tests/stream-pace.spec.ts) | 按流顺序分批绘制的回复文字与工具参数,思考块结束时画出思考,流结束时与已记录事件前的 flush,reducedMotion,以及在帧节拍上展开的工具卡片 |
|
|
312
|
+
| [`tests/view-banner.spec.ts`](tests/view-banner.spec.ts) | 子 agent 视图行的路径、返回目标、宽度,以及在主会话时不绘制 |
|
|
310
313
|
| [`tests/toast.spec.ts`](tests/toast.spec.ts) | 临时提示行的方框、其保持、其淡出与其提前结算 |
|
|
311
314
|
| [`tests/reader.spec.ts`](tests/reader.spec.ts) | 阅读器的几何布局、其状态机、其过滤,以及它返回的各行 |
|
|
312
315
|
| [`tests/reader-screen.spec.ts`](tests/reader-screen.spec.ts) | 阅读器面板:其按键映射、它铺满的屏幕、其重新锚定与其退出 |
|
|
@@ -590,24 +590,28 @@ function parseArguments(argumentsJson) {
|
|
|
590
590
|
}
|
|
591
591
|
/**
|
|
592
592
|
* Render a diff for a card body, with the code span behind each changed or
|
|
593
|
-
* context row so the card can colour the file's own language.
|
|
593
|
+
* context row so the card can colour the file's own language. A diff that
|
|
594
|
+
* names where its sides start in the file leads each row with its file line:
|
|
595
|
+
* the new side's for an added or context row, the old side's for a removed one.
|
|
594
596
|
* @param diff - one file's old and new text.
|
|
595
597
|
* @returns the rows and their spans; the `…` gap markers carry no span.
|
|
596
598
|
*/
|
|
597
599
|
function diffBody(diff) {
|
|
598
600
|
const lang = extensionOf(diff.path);
|
|
599
|
-
const rows = hunks(diffLines(diff.oldText, diff.newText), DIFF_CONTEXT_LINES);
|
|
601
|
+
const rows = hunks(numberDiffLines(diffLines(diff.oldText, diff.newText), diff.oldStart, diff.newStart), DIFF_CONTEXT_LINES);
|
|
602
|
+
const digits = rows.reduce((widest, row) => Math.max(widest, row?.number === void 0 ? 0 : String(row.number).length), 0);
|
|
600
603
|
const lines = [];
|
|
601
604
|
const code = [];
|
|
602
605
|
const marks = [];
|
|
603
606
|
for (const row of rows) {
|
|
604
607
|
if (row === void 0) {
|
|
605
|
-
lines.push("
|
|
608
|
+
lines.push(`${" ".repeat(digits === 0 ? 0 : digits + 1)} …`);
|
|
606
609
|
code.push(void 0);
|
|
607
610
|
marks.push(void 0);
|
|
608
611
|
continue;
|
|
609
612
|
}
|
|
610
|
-
const
|
|
613
|
+
const sign = row.kind === "added" ? "+ " : row.kind === "removed" ? "- " : " ";
|
|
614
|
+
const prefix = (digits === 0 ? "" : `${(row.number === void 0 ? "" : String(row.number)).padStart(digits)} `) + sign;
|
|
611
615
|
lines.push(prefix + row.text);
|
|
612
616
|
code.push(lang === void 0 ? void 0 : {
|
|
613
617
|
lang,
|
|
@@ -623,6 +627,26 @@ function diffBody(diff) {
|
|
|
623
627
|
};
|
|
624
628
|
}
|
|
625
629
|
/**
|
|
630
|
+
* Number aligned diff rows from where each side starts in the file.
|
|
631
|
+
* @param lines - the aligned rows, in order.
|
|
632
|
+
* @param oldStart - the old side's first file line; absent leaves removed rows unnumbered.
|
|
633
|
+
* @param newStart - the new side's first file line; absent leaves added and context rows unnumbered.
|
|
634
|
+
* @returns the rows, each carrying its file line when its side has a start.
|
|
635
|
+
*/
|
|
636
|
+
function numberDiffLines(lines, oldStart, newStart) {
|
|
637
|
+
let previous = oldStart;
|
|
638
|
+
let next = newStart;
|
|
639
|
+
return lines.map((line) => {
|
|
640
|
+
const number = line.kind === "removed" ? previous : next;
|
|
641
|
+
if (line.kind !== "added" && previous !== void 0) previous += 1;
|
|
642
|
+
if (line.kind !== "removed" && next !== void 0) next += 1;
|
|
643
|
+
return number === void 0 ? line : {
|
|
644
|
+
...line,
|
|
645
|
+
number
|
|
646
|
+
};
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
626
650
|
* Concatenate bodies: a heading row per diff, then that diff's rows.
|
|
627
651
|
* @param diffs - the files in display order.
|
|
628
652
|
* @returns one body for the whole card half.
|
|
@@ -1342,6 +1366,97 @@ function reportChange(result) {
|
|
|
1342
1366
|
if (result.application === "failed") throw new Error(text);
|
|
1343
1367
|
return text;
|
|
1344
1368
|
}
|
|
1369
|
+
//#endregion
|
|
1370
|
+
//#region lib/types/columns.js
|
|
1371
|
+
/**
|
|
1372
|
+
* Cutting a rendered line at several columns in one pass.
|
|
1373
|
+
*
|
|
1374
|
+
* pi-tui's `sliceByColumn` walks a line from its first character on every
|
|
1375
|
+
* call, so a fade that recolors `n` runs of one line with it reads that line
|
|
1376
|
+
* about `2n` times on every frame. {@link sliceColumns} reads it once and
|
|
1377
|
+
* returns every piece, each exactly what `sliceByColumn` returns for the same
|
|
1378
|
+
* range: the escape sequences inside the range, and every sequence before the
|
|
1379
|
+
* range ahead of its first grapheme, so a piece drawn after recolored text
|
|
1380
|
+
* restores the line's own styling.
|
|
1381
|
+
* @module @deepseek-ai/dsh-tui-app/columns
|
|
1382
|
+
*/
|
|
1383
|
+
/** Grapheme segmenter for the text between escape sequences. */
|
|
1384
|
+
const GRAPHEMES$3 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
1385
|
+
/**
|
|
1386
|
+
* The terminal escape sequence starting at `index`, as pi-tui recognizes one:
|
|
1387
|
+
* a CSI sequence ending in `m`, `G`, `K`, `H`, or `J`, or an OSC or APC
|
|
1388
|
+
* sequence ending in BEL or ST. An unterminated sequence is text.
|
|
1389
|
+
* @param line - the rendered line.
|
|
1390
|
+
* @param index - where the sequence would start.
|
|
1391
|
+
* @returns the sequence's length, or 0 when none starts there.
|
|
1392
|
+
*/
|
|
1393
|
+
function escapeLength(line, index) {
|
|
1394
|
+
if (line[index] !== "\x1B") return 0;
|
|
1395
|
+
const kind = line[index + 1];
|
|
1396
|
+
if (kind === "[") {
|
|
1397
|
+
for (let end = index + 2; end < line.length; end += 1) if ("mGKHJ".includes(line[end])) return end + 1 - index;
|
|
1398
|
+
return 0;
|
|
1399
|
+
}
|
|
1400
|
+
if (kind === "]" || kind === "_") for (let end = index + 2; end < line.length; end += 1) {
|
|
1401
|
+
if (line[end] === "\x07") return end + 1 - index;
|
|
1402
|
+
if (line[end] === "\x1B" && line[end + 1] === "\\") return end + 2 - index;
|
|
1403
|
+
}
|
|
1404
|
+
return 0;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Cut `line` into the column ranges between consecutive cuts.
|
|
1408
|
+
* @param line - the rendered line, escape sequences included.
|
|
1409
|
+
* @param cuts - ascending columns; equal neighbours make an empty range.
|
|
1410
|
+
* @returns `cuts.length + 1` pieces: columns `[0, cuts[0])`, then each range
|
|
1411
|
+
* between two cuts, then everything from the last cut on. A grapheme belongs
|
|
1412
|
+
* to the range its first column is in, and a range no grapheme starts in holds
|
|
1413
|
+
* only the escape sequences inside it.
|
|
1414
|
+
*/
|
|
1415
|
+
function sliceColumns(line, cuts) {
|
|
1416
|
+
const starts = [0, ...cuts];
|
|
1417
|
+
const pieces = starts.map(() => "");
|
|
1418
|
+
const drawn = starts.map(() => false);
|
|
1419
|
+
const before = starts.map(() => "");
|
|
1420
|
+
let sequences = "";
|
|
1421
|
+
let column = 0;
|
|
1422
|
+
let range = 0;
|
|
1423
|
+
let reached = 1;
|
|
1424
|
+
const advance = () => {
|
|
1425
|
+
while (range + 1 < starts.length && starts[range + 1] <= column) range += 1;
|
|
1426
|
+
while (reached < starts.length && starts[reached] <= column) {
|
|
1427
|
+
before[reached] = sequences;
|
|
1428
|
+
reached += 1;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
const append = (text) => {
|
|
1432
|
+
pieces[range] = `${pieces[range]}${text}`;
|
|
1433
|
+
};
|
|
1434
|
+
advance();
|
|
1435
|
+
let index = 0;
|
|
1436
|
+
while (index < line.length) {
|
|
1437
|
+
const length = escapeLength(line, index);
|
|
1438
|
+
if (length > 0) {
|
|
1439
|
+
const sequence = line.slice(index, index + length);
|
|
1440
|
+
sequences += sequence;
|
|
1441
|
+
append(sequence);
|
|
1442
|
+
index += length;
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
let end = index + 1;
|
|
1446
|
+
while (end < line.length && escapeLength(line, end) === 0) end += 1;
|
|
1447
|
+
for (const { segment } of GRAPHEMES$3.segment(line.slice(index, end))) {
|
|
1448
|
+
if (!drawn[range]) {
|
|
1449
|
+
drawn[range] = true;
|
|
1450
|
+
append(before[range]);
|
|
1451
|
+
}
|
|
1452
|
+
append(segment);
|
|
1453
|
+
column += visibleWidth(segment);
|
|
1454
|
+
advance();
|
|
1455
|
+
}
|
|
1456
|
+
index = end;
|
|
1457
|
+
}
|
|
1458
|
+
return pieces;
|
|
1459
|
+
}
|
|
1345
1460
|
/** Control Sequence Introducer. */
|
|
1346
1461
|
const CSI$2 = "\x1B[";
|
|
1347
1462
|
/**
|
|
@@ -2282,14 +2397,12 @@ function collectRuns(runs, covered, sgr) {
|
|
|
2282
2397
|
* runs untouched, and the line's own trailing sequences kept ahead of `restore`.
|
|
2283
2398
|
*/
|
|
2284
2399
|
function paintLine(text, runs, restore) {
|
|
2285
|
-
|
|
2286
|
-
let
|
|
2287
|
-
|
|
2288
|
-
out +=
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
}
|
|
2292
|
-
return `${out}${sliceByColumn(text, cursor, text.length + 1)}${restore}`;
|
|
2400
|
+
const pieces = sliceColumns(text, runs.flatMap((run) => [run.start, run.end]));
|
|
2401
|
+
let out = pieces[0];
|
|
2402
|
+
runs.forEach((run, index) => {
|
|
2403
|
+
out += `${run.sgr}${pieces[2 * index + 1]}${pieces[2 * index + 2]}`;
|
|
2404
|
+
});
|
|
2405
|
+
return `${out}${restore}`;
|
|
2293
2406
|
}
|
|
2294
2407
|
//#endregion
|
|
2295
2408
|
//#region lib/types/motion.js
|
|
@@ -2375,6 +2488,78 @@ function pulse(palette, text, level) {
|
|
|
2375
2488
|
}
|
|
2376
2489
|
}
|
|
2377
2490
|
//#endregion
|
|
2491
|
+
//#region lib/types/tail-wrap.js
|
|
2492
|
+
/**
|
|
2493
|
+
* A text component that rewraps only the last paragraph of a growing text.
|
|
2494
|
+
*
|
|
2495
|
+
* pi-tui's `Text` wraps its whole text again whenever the text changes, so a
|
|
2496
|
+
* streaming thinking block that grows a few graphemes per frame costs a full
|
|
2497
|
+
* rewrap of everything it already holds on every frame. `wrapTextWithAnsi`
|
|
2498
|
+
* wraps each `\n`-separated line on its own, carrying over only the styling
|
|
2499
|
+
* that earlier lines left open, so the lines before the last one keep their
|
|
2500
|
+
* wrap while text is appended. {@link TailWrappedText} keeps that wrap per
|
|
2501
|
+
* width and wraps the last line alone, and draws exactly what `Text` with no
|
|
2502
|
+
* padding draws for the same text.
|
|
2503
|
+
* @module @deepseek-ai/dsh-tui-app/tail-wrap
|
|
2504
|
+
*/
|
|
2505
|
+
/** The SGR sequences a styled text opens with. */
|
|
2506
|
+
const LEADING_STYLE = /^(?:\u001b\[[0-9;]*m)*/u;
|
|
2507
|
+
/** Draws a text like pi-tui's `Text` with no padding, rewrapping only its last line. */
|
|
2508
|
+
var TailWrappedText = class {
|
|
2509
|
+
text = "";
|
|
2510
|
+
/** The wrap of every line before the last one, at one width. */
|
|
2511
|
+
head;
|
|
2512
|
+
/** The last drawing. */
|
|
2513
|
+
drawn;
|
|
2514
|
+
/**
|
|
2515
|
+
* Replace the text.
|
|
2516
|
+
* @param text - the text, styled or plain.
|
|
2517
|
+
*/
|
|
2518
|
+
setText(text) {
|
|
2519
|
+
this.text = text;
|
|
2520
|
+
}
|
|
2521
|
+
invalidate() {
|
|
2522
|
+
this.head = void 0;
|
|
2523
|
+
this.drawn = void 0;
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* Draw the text.
|
|
2527
|
+
* @param width - the columns every line is padded to.
|
|
2528
|
+
* @returns the wrapped lines padded to `width`; none for blank text.
|
|
2529
|
+
*/
|
|
2530
|
+
render(width) {
|
|
2531
|
+
if (this.drawn?.width === width && this.drawn.text === this.text) return this.drawn.lines;
|
|
2532
|
+
const lines = this.text.trim() === "" ? [] : this.wrap(this.text.replace(/\t/gu, " "), Math.max(1, width)).map((line) => `${line}${" ".repeat(Math.max(0, width - visibleWidth(line)))}`);
|
|
2533
|
+
this.drawn = {
|
|
2534
|
+
width,
|
|
2535
|
+
text: this.text,
|
|
2536
|
+
lines
|
|
2537
|
+
};
|
|
2538
|
+
return lines;
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Wrap the text, reusing the wrap of every line before the last one while
|
|
2542
|
+
* those lines carry no styling beyond the sequences the text opens with.
|
|
2543
|
+
* @param text - the text with tabs expanded.
|
|
2544
|
+
* @param width - the columns to wrap at.
|
|
2545
|
+
* @returns the wrapped lines, unpadded.
|
|
2546
|
+
*/
|
|
2547
|
+
wrap(text, width) {
|
|
2548
|
+
const cut = text.lastIndexOf("\n");
|
|
2549
|
+
const open = text.slice(0, text.length - text.replace(LEADING_STYLE, "").length);
|
|
2550
|
+
const styled = text.indexOf("\x1B", open.length);
|
|
2551
|
+
if (cut === -1 || styled !== -1 && styled < cut) return wrapTextWithAnsi(text, width);
|
|
2552
|
+
const head = text.slice(0, cut);
|
|
2553
|
+
if (this.head?.width !== width || this.head.text !== head) this.head = {
|
|
2554
|
+
width,
|
|
2555
|
+
text: head,
|
|
2556
|
+
lines: wrapTextWithAnsi(head, width)
|
|
2557
|
+
};
|
|
2558
|
+
const tail = wrapTextWithAnsi(`${open}\n${text.slice(cut + 1)}`, width).slice(1);
|
|
2559
|
+
return [...this.head.lines, ...tail];
|
|
2560
|
+
}
|
|
2561
|
+
};
|
|
2562
|
+
//#endregion
|
|
2378
2563
|
//#region lib/types/style.js
|
|
2379
2564
|
/**
|
|
2380
2565
|
* The terminal palette: one table of SGR open/close pairs behind named roles,
|
|
@@ -3057,6 +3242,7 @@ var AssistantBlock = class {
|
|
|
3057
3242
|
appliedTail;
|
|
3058
3243
|
/** Last text handed to {@link AssistantBlock.prefixMarkdown}. */
|
|
3059
3244
|
appliedPrefix;
|
|
3245
|
+
/** The reasoning rows; a growing block rewraps only its last paragraph. */
|
|
3060
3246
|
reasoningText;
|
|
3061
3247
|
fade;
|
|
3062
3248
|
/** Width of the last render that drew a text tail; absent before the first one. */
|
|
@@ -3084,7 +3270,7 @@ var AssistantBlock = class {
|
|
|
3084
3270
|
const themeForMarkdown = markdownTheme(palette, this.fences);
|
|
3085
3271
|
this.markdown = new Markdown("", 0, 0, themeForMarkdown);
|
|
3086
3272
|
this.prefixMarkdown = new Markdown("", 0, 0, themeForMarkdown);
|
|
3087
|
-
this.reasoningText = new
|
|
3273
|
+
this.reasoningText = new TailWrappedText();
|
|
3088
3274
|
}
|
|
3089
3275
|
/**
|
|
3090
3276
|
* The message as navigable sections, carrying the model's own text: the
|
|
@@ -3351,6 +3537,12 @@ var ToolBlock = class {
|
|
|
3351
3537
|
drawn = new LastDrawn();
|
|
3352
3538
|
/** Counts every call or result the card was given. */
|
|
3353
3539
|
revision = 0;
|
|
3540
|
+
/** How many of the card's rows are drawn while it unrolls; absent draws every row. */
|
|
3541
|
+
reveal;
|
|
3542
|
+
/** The card's full row count, the leading blank line excluded, at its last render. */
|
|
3543
|
+
rows = 0;
|
|
3544
|
+
/** Whether {@link rows} was measured after the last call, result, or fold change. */
|
|
3545
|
+
measured = false;
|
|
3354
3546
|
toolName;
|
|
3355
3547
|
call;
|
|
3356
3548
|
constructor(theme, name, call, turn) {
|
|
@@ -3411,6 +3603,7 @@ var ToolBlock = class {
|
|
|
3411
3603
|
this.toolName = name;
|
|
3412
3604
|
this.call = call;
|
|
3413
3605
|
this.revision += 1;
|
|
3606
|
+
this.measured = false;
|
|
3414
3607
|
}
|
|
3415
3608
|
/**
|
|
3416
3609
|
* Draw this card, while folded, as one subagent row: the task description
|
|
@@ -3421,6 +3614,7 @@ var ToolBlock = class {
|
|
|
3421
3614
|
setSubagent(facts) {
|
|
3422
3615
|
this.subagent = facts;
|
|
3423
3616
|
this.revision += 1;
|
|
3617
|
+
this.measured = false;
|
|
3424
3618
|
}
|
|
3425
3619
|
/**
|
|
3426
3620
|
* Draw the header and the call rows through `fade` until it settles.
|
|
@@ -3445,23 +3639,63 @@ var ToolBlock = class {
|
|
|
3445
3639
|
* right now, and so whether the frame differs from the one just built.
|
|
3446
3640
|
*/
|
|
3447
3641
|
setRepaintFloor(floor) {
|
|
3642
|
+
const reveal = this.reveal;
|
|
3643
|
+
if (reveal !== void 0 && reveal.shown() < this.rows && floor > 1 + reveal.shown()) {
|
|
3644
|
+
reveal.settle();
|
|
3645
|
+
this.repaintFloor = Math.max(this.repaintFloor, floor);
|
|
3646
|
+
return true;
|
|
3647
|
+
}
|
|
3448
3648
|
if (floor <= this.repaintFloor) return false;
|
|
3449
3649
|
this.repaintFloor = floor;
|
|
3450
3650
|
return this.fade?.age() !== void 0 || this.resultFade?.age() !== void 0;
|
|
3451
3651
|
}
|
|
3452
3652
|
/**
|
|
3453
|
-
* Attach the result rows and settle the status.
|
|
3653
|
+
* Attach the result rows and settle the status. A diff result replaces the
|
|
3654
|
+
* rows of a diff call.
|
|
3454
3655
|
* @param lines - the result rows before preview truncation.
|
|
3455
3656
|
* @param isError - whether the tool reported failure.
|
|
3456
3657
|
* @param code - the span behind each row, for a result the card colours as code.
|
|
3457
3658
|
* @param diff - which rows are diff additions or removals, for a result the card boxes as a diff.
|
|
3458
3659
|
*/
|
|
3459
3660
|
setResult(lines, isError, code, diff) {
|
|
3661
|
+
if (diff !== void 0 && this.call.diff !== void 0) this.call = {
|
|
3662
|
+
title: this.call.title,
|
|
3663
|
+
lines: []
|
|
3664
|
+
};
|
|
3460
3665
|
this.resultLines = lines;
|
|
3461
3666
|
this.resultCode = code;
|
|
3462
3667
|
this.resultDiff = diff;
|
|
3463
3668
|
this.status = isError ? "error" : "done";
|
|
3464
3669
|
this.revision += 1;
|
|
3670
|
+
this.measured = false;
|
|
3671
|
+
}
|
|
3672
|
+
/**
|
|
3673
|
+
* Unroll the card's rows on the application's frame tick instead of drawing
|
|
3674
|
+
* them all in one frame: now, and again whenever a call or a result makes
|
|
3675
|
+
* the card grow.
|
|
3676
|
+
* @param reveal - how many rows are drawn; the card draws that many of its
|
|
3677
|
+
* rows after the leading blank line.
|
|
3678
|
+
*/
|
|
3679
|
+
setReveal(reveal) {
|
|
3680
|
+
this.reveal = reveal;
|
|
3681
|
+
this.measured = false;
|
|
3682
|
+
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Whether rows of this card are still hidden, or the card changed since its
|
|
3685
|
+
* last render and may have gained rows.
|
|
3686
|
+
* @returns true while the reveal still has a frame to draw.
|
|
3687
|
+
*/
|
|
3688
|
+
revealing() {
|
|
3689
|
+
return this.reveal !== void 0 && (!this.measured || this.reveal.shown() < this.rows);
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* Draw one frame's share of the rows still hidden.
|
|
3693
|
+
* @returns whether the reveal still has a frame to draw after this one.
|
|
3694
|
+
*/
|
|
3695
|
+
revealFrame() {
|
|
3696
|
+
if (this.reveal === void 0) return false;
|
|
3697
|
+
if (!this.measured) return true;
|
|
3698
|
+
return this.reveal.frame(this.rows);
|
|
3465
3699
|
}
|
|
3466
3700
|
/**
|
|
3467
3701
|
* Whether the whole body is drawn right now.
|
|
@@ -3475,6 +3709,7 @@ var ToolBlock = class {
|
|
|
3475
3709
|
* @param expanded - whether the full body is shown.
|
|
3476
3710
|
*/
|
|
3477
3711
|
setExpanded(expanded) {
|
|
3712
|
+
if (expanded !== this.expanded) this.reveal?.settle();
|
|
3478
3713
|
this.expanded = expanded;
|
|
3479
3714
|
}
|
|
3480
3715
|
invalidate() {
|
|
@@ -3486,16 +3721,21 @@ var ToolBlock = class {
|
|
|
3486
3721
|
const layout = this.drawn.get(`${String(width)}:${String(marked)}:${String(this.expanded)}:${this.status}:${String(this.revision)}`, () => this.layout(outer, marked));
|
|
3487
3722
|
const call = faded(layout.call, this.fade, this.repaintFloor - 1);
|
|
3488
3723
|
const result = faded(layout.result, this.resultFade, this.repaintFloor - 1 - layout.call.length);
|
|
3489
|
-
const
|
|
3724
|
+
const full = call === layout.call && result === layout.result ? layout.lines : [
|
|
3490
3725
|
"",
|
|
3491
3726
|
...call,
|
|
3492
3727
|
...result
|
|
3493
3728
|
];
|
|
3494
|
-
|
|
3495
|
-
|
|
3729
|
+
this.rows = full.length - 1;
|
|
3730
|
+
this.measured = true;
|
|
3731
|
+
this.reveal?.clamp(this.rows);
|
|
3732
|
+
const shown = this.reveal === void 0 ? this.rows : this.reveal.shown();
|
|
3733
|
+
const visible = (lines) => shown < this.rows ? lines.slice(0, 1 + shown) : lines;
|
|
3734
|
+
if (this.highlight === void 0) return visible(full);
|
|
3735
|
+
const sections = full.length - layout.marker;
|
|
3496
3736
|
const section = this.parts()[this.highlight]?.kind === "result" ? {
|
|
3497
3737
|
from: 1 + layout.call.length,
|
|
3498
|
-
to:
|
|
3738
|
+
to: full.length
|
|
3499
3739
|
} : {
|
|
3500
3740
|
from: 1,
|
|
3501
3741
|
to: 1 + layout.call.length
|
|
@@ -3505,9 +3745,9 @@ var ToolBlock = class {
|
|
|
3505
3745
|
to: Math.min(section.to, sections)
|
|
3506
3746
|
}, {
|
|
3507
3747
|
from: sections,
|
|
3508
|
-
to:
|
|
3748
|
+
to: full.length
|
|
3509
3749
|
});
|
|
3510
|
-
return withGutter(palette,
|
|
3750
|
+
return visible(withGutter(palette, full, (index) => index >= held.from && index < held.to, this.highlightLevel));
|
|
3511
3751
|
}
|
|
3512
3752
|
/**
|
|
3513
3753
|
* Colour, fold, and wrap the card body.
|
|
@@ -4589,6 +4829,29 @@ var StreamPacer = class {
|
|
|
4589
4829
|
this.credit = 0;
|
|
4590
4830
|
for (const entry of entries) entry.release(entry.text);
|
|
4591
4831
|
}
|
|
4832
|
+
/**
|
|
4833
|
+
* Release every queued entry of one channel now, and keep every other
|
|
4834
|
+
* entry in arrival order. A finished thinking block uses this so its
|
|
4835
|
+
* remainder is drawn before later reply text is paced.
|
|
4836
|
+
* @param channel - the channel to release.
|
|
4837
|
+
* @returns whether any entry of that channel was queued.
|
|
4838
|
+
*/
|
|
4839
|
+
flushChannel(channel) {
|
|
4840
|
+
const pending = this.entries.splice(0);
|
|
4841
|
+
const kept = [];
|
|
4842
|
+
const release = [];
|
|
4843
|
+
let backlog = 0;
|
|
4844
|
+
for (const entry of pending) if (entry.channel === channel) release.push(entry);
|
|
4845
|
+
else {
|
|
4846
|
+
kept.push(entry);
|
|
4847
|
+
backlog += entry.text.length;
|
|
4848
|
+
}
|
|
4849
|
+
this.entries.push(...kept);
|
|
4850
|
+
this.backlog = backlog;
|
|
4851
|
+
if (this.entries.length === 0) this.credit = 0;
|
|
4852
|
+
for (const entry of release) entry.release(entry.text);
|
|
4853
|
+
return release.length > 0;
|
|
4854
|
+
}
|
|
4592
4855
|
/** Drop everything queued without releasing it. */
|
|
4593
4856
|
clear() {
|
|
4594
4857
|
this.entries.length = 0;
|
|
@@ -4597,6 +4860,64 @@ var StreamPacer = class {
|
|
|
4597
4860
|
}
|
|
4598
4861
|
};
|
|
4599
4862
|
/**
|
|
4863
|
+
* How many rows of a growing block are drawn, advanced on the application's
|
|
4864
|
+
* frame tick the same way {@link StreamPacer} releases text: each frame draws
|
|
4865
|
+
* `hidden / drainFrames` more rows, at least one, with the fractional part
|
|
4866
|
+
* carried to the next frame. The
|
|
4867
|
+
* block reports its full row count after every render and draws only the
|
|
4868
|
+
* first {@link RowReveal.shown} rows until the reveal catches up.
|
|
4869
|
+
*/
|
|
4870
|
+
var RowReveal = class {
|
|
4871
|
+
drainFrames;
|
|
4872
|
+
count;
|
|
4873
|
+
/** Rows the next frame may draw beyond its own share. */
|
|
4874
|
+
credit = 0;
|
|
4875
|
+
/**
|
|
4876
|
+
* @param drainFrames - frames a hidden run takes to unroll; at least 1.
|
|
4877
|
+
* @param shown - rows drawn before the first frame.
|
|
4878
|
+
*/
|
|
4879
|
+
constructor(drainFrames, shown) {
|
|
4880
|
+
this.drainFrames = Math.max(1, drainFrames);
|
|
4881
|
+
this.count = shown;
|
|
4882
|
+
}
|
|
4883
|
+
/**
|
|
4884
|
+
* Rows drawn right now.
|
|
4885
|
+
* @returns the count, which may exceed the block's rows after {@link RowReveal.settle}.
|
|
4886
|
+
*/
|
|
4887
|
+
shown() {
|
|
4888
|
+
return this.count;
|
|
4889
|
+
}
|
|
4890
|
+
/**
|
|
4891
|
+
* Draw one frame's share of the rows still hidden.
|
|
4892
|
+
* @param total - the block's full row count at its last render.
|
|
4893
|
+
* @returns whether rows are still hidden after this frame.
|
|
4894
|
+
*/
|
|
4895
|
+
frame(total) {
|
|
4896
|
+
if (this.count >= total) {
|
|
4897
|
+
this.credit = 0;
|
|
4898
|
+
return false;
|
|
4899
|
+
}
|
|
4900
|
+
this.credit += (total - this.count) / this.drainFrames;
|
|
4901
|
+
const rows = Math.max(1, Math.floor(this.credit));
|
|
4902
|
+
this.credit = Math.max(0, this.credit - rows);
|
|
4903
|
+
this.count = Math.min(total, this.count + rows);
|
|
4904
|
+
return this.count < total;
|
|
4905
|
+
}
|
|
4906
|
+
/**
|
|
4907
|
+
* Hold the count at the block's full row count, so rows the block loses
|
|
4908
|
+
* later are not owed again when it grows back.
|
|
4909
|
+
* @param total - the block's full row count at this render.
|
|
4910
|
+
*/
|
|
4911
|
+
clamp(total) {
|
|
4912
|
+
if (this.count > total) this.count = total;
|
|
4913
|
+
}
|
|
4914
|
+
/** Draw every row the block has at its next render. */
|
|
4915
|
+
settle() {
|
|
4916
|
+
this.count = Number.POSITIVE_INFINITY;
|
|
4917
|
+
this.credit = 0;
|
|
4918
|
+
}
|
|
4919
|
+
};
|
|
4920
|
+
/**
|
|
4600
4921
|
* Measure the longest prefix of `text` that holds at most `limit` graphemes.
|
|
4601
4922
|
* @param text - the queued text.
|
|
4602
4923
|
* @param limit - graphemes the frame may still release.
|
|
@@ -4619,6 +4940,57 @@ function cutGraphemes(text, limit) {
|
|
|
4619
4940
|
length
|
|
4620
4941
|
};
|
|
4621
4942
|
}
|
|
4943
|
+
//#endregion
|
|
4944
|
+
//#region lib/types/view-banner.js
|
|
4945
|
+
/**
|
|
4946
|
+
* The line above the editor that says the terminal is showing a subagent
|
|
4947
|
+
* session rather than the main one: the path of views from the main session
|
|
4948
|
+
* down to the one on screen, and the key that goes back one level. The
|
|
4949
|
+
* header names the view too, but it scrolls away with the transcript; this
|
|
4950
|
+
* line stays next to the editor for as long as the view is open, and draws
|
|
4951
|
+
* nothing while the main session is on screen.
|
|
4952
|
+
* @module @deepseek-ai/dsh-tui-app/view-banner
|
|
4953
|
+
*/
|
|
4954
|
+
/** What the trail calls the session the first subagent view was opened from. */
|
|
4955
|
+
const MAIN_SESSION_LABEL = "main";
|
|
4956
|
+
/** Glyph the banner opens with; the header marks a subagent view with the same one. */
|
|
4957
|
+
const VIEW_GLYPH = "◆";
|
|
4958
|
+
/** Draws the subagent-view line while a subagent session is on screen. */
|
|
4959
|
+
var ViewBanner = class {
|
|
4960
|
+
palette;
|
|
4961
|
+
/** Labels of the open views, outermost first; empty while the main session is on screen. */
|
|
4962
|
+
views = [];
|
|
4963
|
+
/** @param palette - the palette the line is styled with. */
|
|
4964
|
+
constructor(palette) {
|
|
4965
|
+
this.palette = palette;
|
|
4966
|
+
}
|
|
4967
|
+
/**
|
|
4968
|
+
* Replace the views the line names.
|
|
4969
|
+
* @param views - the label of every open subagent view, outermost first;
|
|
4970
|
+
* empty draws nothing.
|
|
4971
|
+
*/
|
|
4972
|
+
setViews(views) {
|
|
4973
|
+
this.views = [...views];
|
|
4974
|
+
}
|
|
4975
|
+
invalidate() {}
|
|
4976
|
+
/**
|
|
4977
|
+
* Draw the line.
|
|
4978
|
+
* @param width - the columns the line fits.
|
|
4979
|
+
* @returns one banded row while a view is open, and no rows otherwise.
|
|
4980
|
+
*/
|
|
4981
|
+
render(width) {
|
|
4982
|
+
const current = this.views.at(-1);
|
|
4983
|
+
if (current === void 0) return [];
|
|
4984
|
+
const palette = this.palette;
|
|
4985
|
+
const back = this.views.at(-2) ?? "main";
|
|
4986
|
+
const trail = [MAIN_SESSION_LABEL, ...this.views.slice(0, -1)].map((label) => palette.dim(label));
|
|
4987
|
+
return [bandRow(palette, truncateToWidth(` ${[
|
|
4988
|
+
`${palette.warning(VIEW_GLYPH)} ${palette.bold(palette.warning("subagent view"))}`,
|
|
4989
|
+
[...trail, palette.bold(current)].join(palette.dim(" › ")),
|
|
4990
|
+
`${palette.accent("Ctrl+P")} ${palette.dim(`back to ${back}`)}`
|
|
4991
|
+
].join(palette.dim(" · "))}`, width, "…"), width)];
|
|
4992
|
+
}
|
|
4993
|
+
};
|
|
4622
4994
|
/** Columns the ` ─ ` between the chip and the title takes. */
|
|
4623
4995
|
const CHIP_MARGIN = 3;
|
|
4624
4996
|
/** What opens a top rule. */
|
|
@@ -9991,6 +10363,8 @@ var TuiApp = class {
|
|
|
9991
10363
|
blockFades = new FadeRegistry();
|
|
9992
10364
|
/** Streamed deltas waiting for a frame; absent when deltas are drawn as they arrive. */
|
|
9993
10365
|
pacer;
|
|
10366
|
+
/** Tool cards whose rows are still unrolling; each drops out once its reveal caught up. */
|
|
10367
|
+
reveals = /* @__PURE__ */ new Set();
|
|
9994
10368
|
/**
|
|
9995
10369
|
* The chrome motions running right now. It is consulted whatever the
|
|
9996
10370
|
* terminal draws, because a transient line has to come down again even on a
|
|
@@ -10034,6 +10408,10 @@ var TuiApp = class {
|
|
|
10034
10408
|
* the root session is bound. `/parent` returns to the last one.
|
|
10035
10409
|
*/
|
|
10036
10410
|
parents = [];
|
|
10411
|
+
/** The listing label of every open subagent view, outermost first, one per {@link parents} entry. */
|
|
10412
|
+
viewLabels = [];
|
|
10413
|
+
/** Names the open subagent view above the editor; see {@link ViewBanner}. */
|
|
10414
|
+
banner;
|
|
10037
10415
|
streaming;
|
|
10038
10416
|
/** Whether the fold keys left every foldable block open; one appended later follows it. */
|
|
10039
10417
|
toolsExpanded = false;
|
|
@@ -10110,6 +10488,7 @@ var TuiApp = class {
|
|
|
10110
10488
|
this.queue = new Text("", 0, 0);
|
|
10111
10489
|
this.activity = new Text("", 0, 0);
|
|
10112
10490
|
this.panel = new Text("", 0, 0);
|
|
10491
|
+
this.banner = new ViewBanner(palette);
|
|
10113
10492
|
this.footer = new FooterBar(() => ({
|
|
10114
10493
|
segments: this.segments,
|
|
10115
10494
|
render: {
|
|
@@ -10134,6 +10513,7 @@ var TuiApp = class {
|
|
|
10134
10513
|
this.inspector,
|
|
10135
10514
|
this.queueSlot,
|
|
10136
10515
|
this.activitySlot,
|
|
10516
|
+
this.banner,
|
|
10137
10517
|
this.editor,
|
|
10138
10518
|
this.panelSlot,
|
|
10139
10519
|
this.footer
|
|
@@ -10258,6 +10638,7 @@ var TuiApp = class {
|
|
|
10258
10638
|
this.deps.terminal.write(`releasing a subagent view failed: ${describeFailure(error)}\n`);
|
|
10259
10639
|
});
|
|
10260
10640
|
this.parents.length = 0;
|
|
10641
|
+
this.viewLabels.length = 0;
|
|
10261
10642
|
/* v8 ignore next -- the destructured list always holds the bound session */
|
|
10262
10643
|
this.deps.onQuit(root ?? this.bound);
|
|
10263
10644
|
}
|
|
@@ -10285,6 +10666,7 @@ var TuiApp = class {
|
|
|
10285
10666
|
this.sawSystemPrompt = false;
|
|
10286
10667
|
this.turnStartedAt = void 0;
|
|
10287
10668
|
this.pacer?.clear();
|
|
10669
|
+
this.reveals.clear();
|
|
10288
10670
|
this.streaming = void 0;
|
|
10289
10671
|
this.endFade();
|
|
10290
10672
|
this.blockFades.clear();
|
|
@@ -10304,6 +10686,7 @@ var TuiApp = class {
|
|
|
10304
10686
|
this.replaying = false;
|
|
10305
10687
|
if (reading) this.notice(READER_GONE);
|
|
10306
10688
|
this.refreshHeader();
|
|
10689
|
+
this.banner.setViews(this.viewLabels);
|
|
10307
10690
|
this.refreshQueue();
|
|
10308
10691
|
this.refreshFooter();
|
|
10309
10692
|
this.refreshSubagentPanel();
|
|
@@ -10335,6 +10718,7 @@ var TuiApp = class {
|
|
|
10335
10718
|
return;
|
|
10336
10719
|
}
|
|
10337
10720
|
const released = [this.bound, ...this.parents.splice(0).reverse()];
|
|
10721
|
+
this.viewLabels.length = 0;
|
|
10338
10722
|
const dropped = this.pending.length;
|
|
10339
10723
|
this.bind(next);
|
|
10340
10724
|
this.notice(`${verb}: session ${next.agent.session.id}`, "success");
|
|
@@ -10376,6 +10760,7 @@ var TuiApp = class {
|
|
|
10376
10760
|
const parent = this.bound;
|
|
10377
10761
|
const dropped = this.pending.length;
|
|
10378
10762
|
this.parents.push(parent);
|
|
10763
|
+
this.viewLabels.push(row.item.label);
|
|
10379
10764
|
this.bind(next);
|
|
10380
10765
|
this.notice(`subagent ${row.item.label} · Ctrl+P or /parent returns to session ${parent.agent.session.id}`, "success");
|
|
10381
10766
|
if (dropped > 0) this.notice(`${String(dropped)} pending attachment(s) stayed with the parent session`);
|
|
@@ -10411,6 +10796,7 @@ var TuiApp = class {
|
|
|
10411
10796
|
if (this.stopped) return;
|
|
10412
10797
|
const view = this.bound;
|
|
10413
10798
|
this.parents.pop();
|
|
10799
|
+
this.viewLabels.pop();
|
|
10414
10800
|
this.bind({
|
|
10415
10801
|
...parent,
|
|
10416
10802
|
history
|
|
@@ -12788,6 +13174,13 @@ var TuiApp = class {
|
|
|
12788
13174
|
this.updateFadeTicker();
|
|
12789
13175
|
}
|
|
12790
13176
|
/**
|
|
13177
|
+
* Draw thinking that is still queued. The pacer would otherwise keep
|
|
13178
|
+
* releasing it after the model has moved on to reply text or a tool call.
|
|
13179
|
+
*/
|
|
13180
|
+
finishReasoningPace() {
|
|
13181
|
+
if (this.pacer?.flushChannel("reasoning") === true) this.tui.requestRender();
|
|
13182
|
+
}
|
|
13183
|
+
/**
|
|
12791
13184
|
* Take one visible text delta: the block draws it and the tail of that same
|
|
12792
13185
|
* block ages it. The tail is created with the first delta of a message, so
|
|
12793
13186
|
* a block rebuilt from history or committed from the log never carries one.
|
|
@@ -12870,6 +13263,27 @@ var TuiApp = class {
|
|
|
12870
13263
|
this.updateFadeTicker();
|
|
12871
13264
|
}
|
|
12872
13265
|
/**
|
|
13266
|
+
* Unroll a new card's rows on the frame tick from its header down. A card
|
|
13267
|
+
* drawn from a replayed log, and every card on a terminal that paces
|
|
13268
|
+
* nothing, draws whole.
|
|
13269
|
+
* @param block - the card that was just mounted.
|
|
13270
|
+
*/
|
|
13271
|
+
revealBlock(block) {
|
|
13272
|
+
if (this.replaying || this.deps.reducedMotion || this.deps.toolRevealFrames === 0) return;
|
|
13273
|
+
block.setReveal(new RowReveal(this.deps.toolRevealFrames, 1));
|
|
13274
|
+
this.trackReveal(block);
|
|
13275
|
+
}
|
|
13276
|
+
/**
|
|
13277
|
+
* Keep a card on the frame tick while it has rows to unroll, which a call
|
|
13278
|
+
* or a result that makes it grow gives it again.
|
|
13279
|
+
* @param block - the card that just changed.
|
|
13280
|
+
*/
|
|
13281
|
+
trackReveal(block) {
|
|
13282
|
+
if (!block.revealing()) return;
|
|
13283
|
+
this.reveals.add(block);
|
|
13284
|
+
this.updateFadeTicker();
|
|
13285
|
+
}
|
|
13286
|
+
/**
|
|
12873
13287
|
* Settle what the current message has drawn and stop tracking it: both
|
|
12874
13288
|
* tails go, so their text renders at the terminal's foreground from the next
|
|
12875
13289
|
* render on. Card fades are left to expire on their own clock, because a
|
|
@@ -12978,7 +13392,7 @@ var TuiApp = class {
|
|
|
12978
13392
|
* @returns true while a tail or a card fade keeps changing what is drawn.
|
|
12979
13393
|
*/
|
|
12980
13394
|
fadesMoving() {
|
|
12981
|
-
return this.pacer?.pending() === true || this.textTail?.needsRepaint() === true || this.reasoningTail?.needsRepaint() === true || this.blockFades.needsRepaint() || this.motions.needsRepaint();
|
|
13395
|
+
return this.pacer?.pending() === true || this.reveals.size > 0 || this.textTail?.needsRepaint() === true || this.reasoningTail?.needsRepaint() === true || this.blockFades.needsRepaint() || this.motions.needsRepaint();
|
|
12982
13396
|
}
|
|
12983
13397
|
/**
|
|
12984
13398
|
* Apply everything the frame's geometry decides, on the frame that was just
|
|
@@ -13035,6 +13449,7 @@ var TuiApp = class {
|
|
|
13035
13449
|
*/
|
|
13036
13450
|
onFadeTick() {
|
|
13037
13451
|
this.pacer?.frame();
|
|
13452
|
+
for (const block of this.reveals) if (!block.revealFrame()) this.reveals.delete(block);
|
|
13038
13453
|
this.textTail?.tick();
|
|
13039
13454
|
this.reasoningTail?.tick();
|
|
13040
13455
|
this.blockFades.tick();
|
|
@@ -13059,23 +13474,26 @@ var TuiApp = class {
|
|
|
13059
13474
|
switch (chunk.type) {
|
|
13060
13475
|
case "text-delta":
|
|
13061
13476
|
if (chunk.text !== "") {
|
|
13477
|
+
this.finishReasoningPace();
|
|
13478
|
+
this.setStreamActivity("writing");
|
|
13062
13479
|
this.pace("text", chunk.text, (text) => {
|
|
13063
13480
|
this.appendStreamedText(text);
|
|
13064
|
-
this.setStreamActivity("writing");
|
|
13065
13481
|
});
|
|
13066
13482
|
this.noteStreamedChars(chunk.text.length);
|
|
13067
13483
|
}
|
|
13068
13484
|
break;
|
|
13069
13485
|
case "reasoning-delta":
|
|
13070
13486
|
if (chunk.text !== "") {
|
|
13487
|
+
this.setStreamActivity("thinking");
|
|
13071
13488
|
this.pace("reasoning", chunk.text, (text) => {
|
|
13072
13489
|
this.appendStreamedReasoning(text);
|
|
13073
|
-
this.setStreamActivity("thinking");
|
|
13074
13490
|
});
|
|
13075
13491
|
this.noteStreamedChars(chunk.text.length);
|
|
13076
13492
|
}
|
|
13077
13493
|
break;
|
|
13078
13494
|
case "tool-call-delta":
|
|
13495
|
+
this.finishReasoningPace();
|
|
13496
|
+
this.noteStreamedToolCall(chunk);
|
|
13079
13497
|
this.pace(`tool:${chunk.id}:${chunk.name ?? ""}`, chunk.argumentsDelta, (text) => {
|
|
13080
13498
|
this.onToolCallDelta({
|
|
13081
13499
|
...chunk,
|
|
@@ -13088,7 +13506,17 @@ var TuiApp = class {
|
|
|
13088
13506
|
this.applyLiveUsage(chunk.usage);
|
|
13089
13507
|
break;
|
|
13090
13508
|
case "block-start":
|
|
13509
|
+
if (chunk.blockType === "text") {
|
|
13510
|
+
this.finishReasoningPace();
|
|
13511
|
+
this.setStreamActivity("writing");
|
|
13512
|
+
} else if (chunk.blockType === "tool-call") {
|
|
13513
|
+
this.finishReasoningPace();
|
|
13514
|
+
if (!isCallingActivity(this.loaderActivity)) this.setLoaderActivity(callingActivity(void 0));
|
|
13515
|
+
} else if (chunk.blockType !== "reasoning") this.finishReasoningPace();
|
|
13516
|
+
break;
|
|
13091
13517
|
case "block-end":
|
|
13518
|
+
if (chunk.block.type === "reasoning") this.finishReasoningPace();
|
|
13519
|
+
break;
|
|
13092
13520
|
case "finish": break;
|
|
13093
13521
|
/* v8 ignore next -- closed-union exhaustiveness guard */
|
|
13094
13522
|
default: assertNever(chunk, "tui stream chunk");
|
|
@@ -13162,6 +13590,7 @@ var TuiApp = class {
|
|
|
13162
13590
|
this.fadeBlock((fade) => {
|
|
13163
13591
|
block.setResultFade(fade);
|
|
13164
13592
|
});
|
|
13593
|
+
this.trackReveal(block);
|
|
13165
13594
|
this.pendingToolNames.delete(result.toolCallId);
|
|
13166
13595
|
this.syncLoaderFromPendingTools();
|
|
13167
13596
|
break;
|
|
@@ -13353,17 +13782,35 @@ var TuiApp = class {
|
|
|
13353
13782
|
this.loader.setMessage(suffix === "" ? this.loaderActivity : `${this.loaderActivity} ${suffix}`);
|
|
13354
13783
|
}
|
|
13355
13784
|
/**
|
|
13356
|
-
*
|
|
13357
|
-
*
|
|
13358
|
-
*
|
|
13785
|
+
* Label the spinner for a tool-call delta before its card is paced.
|
|
13786
|
+
* A known name becomes `calling <name>` and is remembered until the call
|
|
13787
|
+
* settles; a delta that has not named a tool yet says `calling`, and does
|
|
13788
|
+
* not replace a label that already names one.
|
|
13359
13789
|
* @param chunk - one `tool-call-delta` of the live assistant stream.
|
|
13360
13790
|
*/
|
|
13361
|
-
|
|
13362
|
-
const name =
|
|
13791
|
+
noteStreamedToolCall(chunk) {
|
|
13792
|
+
const name = this.streamedToolName(chunk);
|
|
13363
13793
|
if (name !== void 0) {
|
|
13364
13794
|
if (chunk.id !== "") this.pendingToolNames.set(chunk.id, name);
|
|
13365
13795
|
this.setLoaderActivity(callingActivity(name));
|
|
13366
13796
|
} else if (!isCallingActivity(this.loaderActivity)) this.setLoaderActivity(callingActivity(void 0));
|
|
13797
|
+
}
|
|
13798
|
+
/**
|
|
13799
|
+
* The tool name a live delta carries, or the name already drawn for that call.
|
|
13800
|
+
* @param chunk - one `tool-call-delta` of the live assistant stream.
|
|
13801
|
+
* @returns the name, or undefined while the model has not sent one.
|
|
13802
|
+
*/
|
|
13803
|
+
streamedToolName(chunk) {
|
|
13804
|
+
return chunk.name === "" ? void 0 : chunk.name ?? this.toolBlocks.get(chunk.id)?.name;
|
|
13805
|
+
}
|
|
13806
|
+
/**
|
|
13807
|
+
* Mount or refresh a tool card from a stream delta: the name as soon as
|
|
13808
|
+
* the model sends one, then the presenter headline once the arguments
|
|
13809
|
+
* parse as JSON.
|
|
13810
|
+
* @param chunk - one `tool-call-delta` of the live assistant stream.
|
|
13811
|
+
*/
|
|
13812
|
+
onToolCallDelta(chunk) {
|
|
13813
|
+
const name = this.streamedToolName(chunk);
|
|
13367
13814
|
if (chunk.id === "") return;
|
|
13368
13815
|
const argumentsJson = (this.toolStreamArgs.get(chunk.id) ?? "") + chunk.argumentsDelta;
|
|
13369
13816
|
this.toolStreamArgs.set(chunk.id, argumentsJson);
|
|
@@ -13391,6 +13838,7 @@ var TuiApp = class {
|
|
|
13391
13838
|
existing.setCall(name, call);
|
|
13392
13839
|
if (isSubagentTool(name)) existing.setSubagent(subagentRowFacts(args));
|
|
13393
13840
|
if (source === "log") this.unconfirmedTools.delete(callId);
|
|
13841
|
+
this.trackReveal(existing);
|
|
13394
13842
|
return;
|
|
13395
13843
|
}
|
|
13396
13844
|
const block = new ToolBlock(this.theme, name, call, this.turn);
|
|
@@ -13401,6 +13849,7 @@ var TuiApp = class {
|
|
|
13401
13849
|
this.fadeBlock((fade) => {
|
|
13402
13850
|
block.setFade(fade);
|
|
13403
13851
|
});
|
|
13852
|
+
this.revealBlock(block);
|
|
13404
13853
|
if (source === "stream") this.unconfirmedTools.set(callId, block);
|
|
13405
13854
|
}
|
|
13406
13855
|
/**
|
|
@@ -13411,12 +13860,14 @@ var TuiApp = class {
|
|
|
13411
13860
|
if (this.unconfirmedTools.size === 0) return false;
|
|
13412
13861
|
for (const [callId, block] of this.unconfirmedTools) {
|
|
13413
13862
|
this.chat.removeChild(block);
|
|
13863
|
+
this.reveals.delete(block);
|
|
13414
13864
|
this.toolBlocks.delete(callId);
|
|
13415
13865
|
this.toolArguments.delete(callId);
|
|
13416
13866
|
this.toolStreamArgs.delete(callId);
|
|
13417
13867
|
this.pendingToolNames.delete(callId);
|
|
13418
13868
|
}
|
|
13419
13869
|
this.unconfirmedTools.clear();
|
|
13870
|
+
this.updateFadeTicker();
|
|
13420
13871
|
this.syncLoaderFromPendingTools();
|
|
13421
13872
|
return true;
|
|
13422
13873
|
}
|
|
@@ -13533,6 +13984,7 @@ const Config = z.object({
|
|
|
13533
13984
|
streamFadeSteps: z.natural().min(2).default(24),
|
|
13534
13985
|
streamFadeStepMs: z.natural().min(16).default(16),
|
|
13535
13986
|
streamPaceFrames: z.natural().default(8),
|
|
13987
|
+
toolRevealFrames: z.natural().default(6),
|
|
13536
13988
|
reducedMotion: z.boolean().default(false),
|
|
13537
13989
|
openBrowser: z.boolean().default(true)
|
|
13538
13990
|
});
|
|
@@ -13744,6 +14196,7 @@ async function run(ctx, config, host) {
|
|
|
13744
14196
|
fadeSteps: config.streamFadeSteps,
|
|
13745
14197
|
fadeStepMs: config.streamFadeStepMs,
|
|
13746
14198
|
streamPaceFrames: config.streamPaceFrames,
|
|
14199
|
+
toolRevealFrames: config.toolRevealFrames,
|
|
13747
14200
|
reducedMotion: config.reducedMotion,
|
|
13748
14201
|
env: process.env,
|
|
13749
14202
|
now: () => Date.now(),
|
package/package.json
CHANGED