@zhushanwen/pi-subagent-workflow 7.4.0 → 8.0.0
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 +15 -0
- package/package.json +1 -1
- package/skills/workflow-script-format/SKILL.md +1 -1
- package/src/execution/__tests__/__fixtures__/truncline.snapshot.json +1 -0
- package/src/execution/__tests__/ask-user-transit-e2e.test.ts +10 -4
- package/src/execution/__tests__/before-agent-start-injection.test.ts +132 -0
- package/src/execution/__tests__/bg-notify-render.test.ts +15 -15
- package/src/execution/__tests__/chatmode-first-round-closure-service.test.ts +365 -0
- package/src/execution/__tests__/chatmode-first-round-closure-spawn.test.ts +190 -0
- package/src/execution/__tests__/chatmode-round-notify-real-chain.test.ts +215 -0
- package/src/execution/__tests__/conversation-wiring.test.ts +198 -0
- package/src/execution/__tests__/crash-recovery.test.ts +8 -2
- package/src/execution/__tests__/delivery-methods.test.ts +385 -0
- package/src/execution/__tests__/epipe-fallback.test.ts +241 -0
- package/src/execution/__tests__/execute-and-await-worktree.test.ts +49 -2
- package/src/execution/__tests__/execute-nesting.test.ts +20 -72
- package/src/execution/__tests__/execution-record.test.ts +199 -0
- package/src/execution/__tests__/finalize-record.test.ts +170 -14
- package/src/execution/__tests__/format.test.ts +131 -7
- package/src/execution/__tests__/gc-timer.test.ts +184 -0
- package/src/execution/__tests__/get-record-for-action-restart.test.ts +254 -0
- package/src/execution/__tests__/helpers/spawn-mock.ts +25 -7
- package/src/execution/__tests__/index-session-start-identity.test.ts +371 -0
- package/src/execution/__tests__/index-session-start.test.ts +257 -5
- package/src/execution/__tests__/lifecycle-manager-lock.test.ts +211 -0
- package/src/execution/__tests__/lifecycle-manager.test.ts +337 -0
- package/src/execution/__tests__/lifecycle-predicates.test.ts +116 -0
- package/src/execution/__tests__/list-component.test.ts +59 -5
- package/src/execution/__tests__/list-fields.test.ts +109 -0
- package/src/execution/__tests__/model-resolver.test.ts +38 -1
- package/src/execution/__tests__/nested-visibility-env-propagation.test.ts +287 -0
- package/src/execution/__tests__/nested-visibility.test.ts +325 -0
- package/src/execution/__tests__/notifier-flush.test.ts +209 -7
- package/src/execution/__tests__/one-shot-upgrade.test.ts +205 -0
- package/src/execution/__tests__/parent-child-matrix.test.ts +336 -0
- package/src/execution/__tests__/record-store.test.ts +158 -52
- package/src/execution/__tests__/recursive-visibility-baseline.test.ts +11 -12
- package/src/execution/__tests__/recursive-visibility-env.test.ts +18 -20
- package/src/execution/__tests__/resource-policy.test.ts +109 -0
- package/src/execution/__tests__/run-and-finalize-chatmode.test.ts +267 -0
- package/src/execution/__tests__/run-spawn-chatmode-settled.test.ts +253 -0
- package/src/execution/__tests__/run-spawn-edges.test.ts +18 -25
- package/src/execution/__tests__/run-spawn-integration.test.ts +29 -25
- package/src/execution/__tests__/run-spawn-resume.test.ts +322 -0
- package/src/execution/__tests__/run-spawn-rpc-mode.test.ts +14 -11
- package/src/execution/__tests__/session-pending.test.ts +61 -2
- package/src/execution/__tests__/session-reconstructor.test.ts +4 -4
- package/src/execution/__tests__/session-runner-epipe.test.ts +178 -0
- package/src/execution/__tests__/session-runner-schema-env.test.ts +15 -21
- package/src/execution/__tests__/session-start-reaper.test.ts +10 -8
- package/src/execution/__tests__/spawn-args.test.ts +127 -49
- package/src/execution/__tests__/spawn-worktree-guidance.test.ts +1 -0
- package/src/execution/__tests__/spawned-children.test.ts +92 -0
- package/src/execution/__tests__/status-refactor.test.ts +345 -0
- package/src/execution/__tests__/stdin-writer.test.ts +97 -0
- package/src/execution/__tests__/subagent-service-message-close.test.ts +598 -0
- package/src/execution/__tests__/subagent-service-parent-guard.test.ts +180 -0
- package/src/execution/__tests__/subagent-service.test.ts +49 -11
- package/src/execution/__tests__/timeout-integration.test.ts +27 -13
- package/src/execution/__tests__/tool-action.test.ts +12 -10
- package/src/execution/__tests__/truncline-snapshot.test.ts +81 -0
- package/src/execution/__tests__/turn-limiter-semantics.test.ts +194 -0
- package/src/execution/__tests__/worktree-manager.test.ts +292 -89
- package/src/execution/__tests__/worktree-pid-registration.integration.test.ts +13 -12
- package/src/execution/argv-mirror.ts +21 -2
- package/src/execution/execution-record.ts +126 -9
- package/src/execution/finalize-record.ts +90 -13
- package/src/execution/lifecycle-manager.ts +484 -0
- package/src/execution/lifecycle-predicates.ts +65 -0
- package/src/execution/manifest-store.ts +61 -16
- package/src/execution/model-resolver.ts +26 -5
- package/src/execution/notifier.ts +69 -12
- package/src/execution/pi-invocation.ts +21 -1
- package/src/execution/record-store.ts +554 -107
- package/src/execution/session-pending.ts +116 -45
- package/src/execution/session-reconstructor.ts +224 -7
- package/src/execution/session-runner.ts +270 -68
- package/src/execution/sessions-index.ts +304 -0
- package/src/execution/stdin-writer.ts +93 -7
- package/src/execution/stream-sink.ts +20 -3
- package/src/execution/subagent-service.ts +867 -138
- package/src/execution/turn-limiter.ts +14 -0
- package/src/execution/types.ts +200 -19
- package/src/execution/worktree-manager.ts +128 -49
- package/src/execution/worktree-registry.ts +13 -2
- package/src/index.ts +277 -19
- package/src/injectors/subagent-list-injector.ts +26 -8
- package/src/injectors/workflow-list-injector.ts +25 -8
- package/src/interface/__tests__/subagent-tool-prompt.test.ts +17 -4
- package/src/interface/__tests__/tool-render.test.ts +10 -8
- package/src/interface/bg-notify-render.ts +32 -8
- package/src/interface/command-actions.ts +26 -7
- package/src/interface/commands.ts +21 -22
- package/src/interface/format.ts +43 -16
- package/src/interface/gui-mappers.ts +6 -8
- package/src/interface/helpers.ts +170 -10
- package/src/interface/list-component.ts +53 -14
- package/src/interface/subagent-actions.ts +235 -17
- package/src/interface/subagent-tool.ts +81 -16
- package/src/interface/subagents.ts +2 -1
- package/src/interface/tool-render.ts +11 -24
- package/src/interface/tool-workflow.ts +20 -35
- package/src/interface/views/WorkflowsView.ts +89 -32
- package/src/interface/views/__tests__/WorkflowsView-signature.test.ts +264 -0
- package/src/interface/views/format.ts +3 -3
- package/src/orchestration/__tests__/__fixtures__/worker-template.snapshot.txt +325 -0
- package/src/orchestration/__tests__/args-validator.test.ts +1 -1
- package/src/orchestration/__tests__/config-loader.test.ts +38 -0
- package/src/orchestration/__tests__/error-recovery-handlers.test.ts +394 -4
- package/src/orchestration/__tests__/error-recovery-workflow-call.test.ts +4 -4
- package/src/orchestration/__tests__/execute-agent-call.test.ts +95 -0
- package/src/orchestration/__tests__/jsonl-run-store-session-file.test.ts +657 -18
- package/src/orchestration/__tests__/launcher-nested-workflow.test.ts +0 -2
- package/src/orchestration/__tests__/lifecycle.test.ts +332 -149
- package/src/orchestration/__tests__/skill-discovery.test.ts +130 -61
- package/src/orchestration/__tests__/test-mocks.ts +191 -0
- package/src/orchestration/__tests__/worker-script-template-snapshot.test.ts +98 -0
- package/src/orchestration/__tests__/workflow-nesting-e2e.test.ts +0 -2
- package/src/orchestration/__tests__/workflow-script-lint-memo.test.ts +110 -0
- package/src/orchestration/__tests__/workflows-e2e.test.ts +1 -1
- package/src/orchestration/agent-opts-resolver.ts +4 -1
- package/src/orchestration/args-validator.ts +2 -2
- package/src/orchestration/config-loader.ts +30 -1
- package/src/orchestration/error-recovery.ts +133 -29
- package/src/orchestration/execute-agent-call.ts +31 -7
- package/src/orchestration/jsonl-run-store.ts +287 -40
- package/src/orchestration/launcher.ts +7 -1
- package/src/orchestration/lifecycle.ts +135 -132
- package/src/orchestration/models/__tests__/trace.test.ts +408 -0
- package/src/orchestration/models/budget.ts +1 -1
- package/src/orchestration/models/run-runtime.ts +15 -17
- package/src/orchestration/models/run-spec.ts +2 -2
- package/src/orchestration/models/run-state.ts +3 -3
- package/src/orchestration/models/trace.ts +95 -15
- package/src/orchestration/models/types.ts +8 -9
- package/src/orchestration/models/workflow-run.ts +50 -71
- package/src/orchestration/models/workflow-script.ts +32 -1
- package/src/orchestration/skill-discovery.ts +30 -0
- package/src/orchestration/worker-handle.ts +1 -1
- package/src/orchestration/worker-host.ts +1 -1
- package/src/orchestration/worker-script-builder.ts +29 -10
- package/src/shared/__tests__/agent-ref.test.ts +34 -0
- package/src/shared/__tests__/resource-discovery-manifest-cache.test.ts +280 -0
- package/src/shared/__tests__/resource-discovery.test.ts +55 -0
- package/src/shared/__tests__/schema-jsonify.test.ts +81 -0
- package/src/shared/agent-ref.ts +16 -0
- package/src/shared/resource-discovery.ts +147 -58
- package/src/shared/schema-jsonify.ts +53 -0
package/README.md
CHANGED
|
@@ -57,6 +57,21 @@ pi --tools todo,goal_control,workflow,subagent,ask_user \
|
|
|
57
57
|
|
|
58
58
|
系统内置 `n = 10` 深度护栏(fork 链 + 嵌套取 max),超过抛 `ForkDepthExceededError`。实测建议控制在 **3-4 层**以内——更深层会因上下文逐层压缩导致信息失真。
|
|
59
59
|
|
|
60
|
+
## Workflow 生命周期(one-shot)
|
|
61
|
+
|
|
62
|
+
Workflow run 是一次性执行,状态机两态:`running → done`(`done` 唯一终态,reason 区分 completed / aborted / failed / budget_limited / time_limited)。`workflow` tool 仅 3 个 action:`run` / `status` / `abort`。
|
|
63
|
+
|
|
64
|
+
Runs are one-shot: there is no pause/resume — to stop a run early use abort; for a fresh result start a new run.
|
|
65
|
+
|
|
66
|
+
- **abort 是唯一的提前停止方式**:`{"action":"abort","runId":"<id>"}`(可选 `"error":"<reason>"`)。pause/resume action 已移除,调用会被 pi schema 校验拒绝(`Validation failed for tool "workflow"`);`/workflows pause|resume <id>` 返回 removed 提示
|
|
67
|
+
- **session 切换/关闭时**,所有 running run 当即作废转 `done,failed`(state.error 为 `Session switched: run terminated` / `Session shutdown: run terminated`),已投入的 token 作废;需要结果就重新 run
|
|
68
|
+
- **快照格式 `wf-run-v2`**(status 两态、无 `pausedAt`);旧 `wf-run-v1` 文件加载时静默跳过
|
|
69
|
+
- **worker 崩溃自动重建重试**(默认 3 次):重建时在飞 agent 调用被清除重跑,已完成的调用保留 replay 缓存,不重复消耗 token
|
|
70
|
+
|
|
71
|
+
## 性能:sessions-index.json 持久化索引
|
|
72
|
+
|
|
73
|
+
冷启动首扫的 identity 探测结论持久化为 `<enc>/sessions-index.json`(stat 戳自校验、tmp(pid)+rename 原子写、60s 节流、损坏/版本不符静默回退全量探测),真实目录(1744 jsonl / 671MB)实测冷扫描中位数 972.8ms → 80.6ms(12.1x,预算 ≤300ms)。可复现验收脚本:`bench/cold-scan.bench.ts`(冷扫描计时 + 输出等价断言)、`bench/concurrent-scan.bench.ts`(3 实例并发 + 随机变异四判定),设计文档见 `.xyz-harness/2026-08-15-subagent-workflow-perf/sessions-index-design.md`。
|
|
74
|
+
|
|
60
75
|
## 安装
|
|
61
76
|
|
|
62
77
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/pi-subagent-workflow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"description": "Unified subagent execution and multi-agent workflow orchestration for Pi — spawned-process agent runtime with sync/background modes, stateful workflow management with persistence, state machine, and execution tracing.",
|
|
@@ -241,7 +241,7 @@ agent({ prompt: '...', description: 'review-business-logic' });
|
|
|
241
241
|
|
|
242
242
|
## Constraints
|
|
243
243
|
|
|
244
|
-
- `agent()` calls **must be deterministic in order** for
|
|
244
|
+
- `agent()` calls **must be deterministic in order** for crash-retry replay to work correctly. 根因:调用结果按单调递增的 callId(从 0 起、按调用顺序)缓存。Runs are one-shot(无 pause/resume——提前停止用 abort,要新结果重新 run);worker 基础设施错误自动重试 ≤3 次,重试时已完成调用按 callId 重放缓存结果不重跑。`parallel()` 内的调用顺序不能随机,否则重放会错位命中旧结果。注意:无 script hash 校验,重试重放的是缓存结果,开发期改脚本应重新 run。
|
|
245
245
|
- `parallel()` 并发默认上限 6(ConcurrencyPool,超出自动排队;来源 ADR-030 决策 3)。
|
|
246
246
|
- Throwing an error aborts the workflow (after retries).
|
|
247
247
|
- Use `require()` for Node.js built-ins: `const fs = require('node:fs');`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"label":"plain-ascii-long","maxWidth":40,"text":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","expected":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa…"},{"label":"cjk-long","maxWidth":33,"text":"你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界你好世界","expected":"你好世界你好世界你好世界你好世界…"},{"label":"sgr-mixed-10k","maxWidth":60,"text":"汉字测试 data \u001b[0m\u001b[38;5;9m汉字测试 \u001b[mbeta \u001b[0mγλυφ \u001b[0malpha alpha \u001b[31m\u001b[38;5;9malpha \u001b[mdata \u001b[Kalpha \u001b[0mbeta beta \u001b[K→arrow beta \u001b[1;32m\u001b[38;5;9mdata alpha 汉字测试 alpha \u001b[31m\u001b]0;title\u0007γλυφ alpha →arrow \u001b[38;5;9m\u001b[0malpha γλυφ 汉字测试 汉字测试 beta beta →arrow →arrow 汉字测试 beta \u001b[38;5;9m\u001b[K→arrow \u001b[0malpha beta data \u001b[0m\u001b[38;5;9m\u001b[K\u001b[38;5;9mbeta 汉字测试 \u001b[m\u001b]0;title\u0007\u001b[38;5;9m→arrow beta 汉字测试 \u001b[31mdata \u001b[1;32m\u001b[K\u001b[1;32mγλυφ alpha \u001b[0m\u001b[1;32m汉字测试 汉字测试 \u001b[Kbeta γλυφ γλυφ \u001b[1;32m\u001b[1;32mbeta \u001b[38;5;9m\u001b[K\u001b[1;32m\u001b[0m\u001b[0m\u001b]0;title\u0007→arrow 汉字测试 \u001b[m→arrow 汉字测试 \u001b[38;5;9mbeta \u001b]0;title\u0007→arrow →arrow data \u001b[31m\u001b[0mdata data →arrow γλυφ \u001b[K→arrow 汉字测试 γλυφ \u001b[Kalpha \u001b]0;title\u0007\u001b[31mdata →arrow data \u001b[1;32m\u001b[31m\u001b[0mdata data \u001b[38;5;9m汉字测试 汉字测试 \u001bZ\u001b[K\u001b[K\u001b[0m\u001b[0mγλυφ alpha \u001b[31malpha 汉字测试 alpha alpha \u001b]0;title\u0007\u001b[38;5;9malpha data data data beta \u001b[31m\u001b[1;32mdata →arrow \u001b[1;32m\u001b[K\u001b[mbeta →arrow \u001b[0m→arrow γλυφ beta data data γλυφ →arrow beta data 汉字测试 beta 汉字测试 \u001b[K→arrow →arrow alpha \u001b[mbeta data data \u001b[mγλυφ alpha →arrow 汉字测试 γλυφ γλυφ \u001b[31m\u001b[31m\u001b]0;title\u0007→arrow alpha \u001b[1;32mbeta γλυφ →arrow \u001b[K\u001b[38;5;9m\u001b[0m\u001b[1;32mγλυφ γλυφ \u001b[38;5;9m→arrow \u001b[31m\u001b[1;32m\u001b[1;32mγλυφ 汉字测试 alpha data \u001b]0;title\u0007\u001b[38;5;9malpha \u001b[38;5;9m→arrow 汉字测试 beta \u001b[0mbeta beta \u001b[38;5;9mγλυφ \u001b[mdata \u001b[mbeta \u001b[1;32mdata \u001b[mbeta γλυφ \u001b[m\u001b[31mbeta γλυφ 汉字测试 alpha data \u001b[K\u001b[0m汉字测试 beta alpha 汉字测试 \u001bZ\u001b[0m\u001b[38;5;9m\u001b[mγλυφ alpha γλυφ γλυφ 汉字测试 alpha alpha beta \u001b]0;title\u0007→arrow \u001b[38;5;9m汉字测试 \u001b[0m汉字测试 data \u001b[38;5;9m→arrow 汉字测试 \u001b[m\u001b[0mdata γλυφ γλυφ →arrow data data \u001b[31malpha →arrow data \u001b[K汉字测试 γλυφ \u001b[31m\u001b]0;title\u0007alpha \u001b[1;32m汉字测试 →arrow \u001bZdata \u001b[38;5;9mbeta →arrow 汉字测试 γλυφ \u001b[Kγλυφ beta alpha data γλυφ 汉字测试 beta beta data γλυφ →arrow alpha \u001b[31malpha \u001b[0m\u001b[38;5;9malpha \u001bZ汉字测试 \u001b[38;5;9malpha γλυφ γλυφ \u001bZ汉字测试 beta \u001b[38;5;9mbeta →arrow γλυφ \u001b[K→arrow data \u001b[Kγλυφ beta \u001b[1;32mγλυφ alpha γλυφ beta beta beta 汉字测试 \u001b[1;32mγλυφ \u001b[K汉字测试 beta →arrow γλυφ γλυφ 汉字测试 汉字测试 γλυφ 汉字测试 \u001b[31m汉字测试 \u001b[K\u001b[31mbeta \u001b[0malpha beta \u001b[38;5;9m\u001b[K\u001b[K汉字测试 alpha \u001b[1;32m→arrow 汉字测试 \u001b[38;5;9mdata 汉字测试 \u001b]0;title\u0007\u001b[mbeta \u001b[m\u001b[0mγλυφ γλυφ γλυφ →arrow \u001b[1;32m汉字测试 γλυφ beta \u001b]0;title\u0007\u001b[K→arrow beta 汉字测试 data 汉字测试 beta \u001bZ\u001b[31m\u001b[31m\u001b[Kγλυφ 汉字测试 data 汉字测试 beta beta \u001b[m\u001b]0;title\u0007\u001b[m\u001b[38;5;9malpha →arrow \u001b[m\u001b[m汉字测试 \u001b[1;32m\u001b[1;32m汉字测试 \u001b[mbeta \u001b[31mdata →arrow beta γλυφ beta \u001b[m→arrow \u001b[31m\u001b[mγλυφ \u001b[38;5;9mdata \u001b[m\u001b[0m\u001b]0;title\u0007\u001b[1;32m→arrow beta \u001b[m\u001b[m\u001b[K→arrow alpha \u001b]0;title\u0007\u001b[31mγλυφ γλυφ alpha data 汉字测试 beta \u001bZ\u001b[m\u001b[1;32mγλυφ 汉字测试 \u001bZ\u001b[K\u001bZalpha γλυφ →arrow 汉字测试 alpha γλυφ \u001bZ\u001b[m汉字测试 →arrow \u001b[0mbeta data \u001b[K汉字测试 alpha data beta \u001b[1;32m\u001b[1;32m\u001b[38;5;9m\u001b[1;32m\u001b[38;5;9m\u001b[38;5;9m汉字测试 \u001b[Kγλυφ \u001b[K→arrow γλυφ 汉字测试 →arrow \u001b[0m\u001bZ\u001b[38;5;9m\u001b[K\u001b[38;5;9mγλυφ →arrow γλυφ 汉字测试 beta \u001b[38;5;9m\u001b[31mbeta \u001b[31m\u001b]0;title\u0007汉字测试 →arrow beta 汉字测试 \u001b[31mdata 汉字测试 \u001b[38;5;9mbeta data γλυφ →arrow \u001bZdata \u001b[m→arrow \u001b[31m汉字测试 →arrow \u001bZ\u001b]0;title\u0007alpha \u001b[mγλυφ beta \u001b[m\u001b[1;32mγλυφ \u001b[1;32m\u001b[1;32m→arrow 汉字测试 beta 汉字测试 汉字测试 汉字测试 γλυφ \u001b[38;5;9mγλυφ \u001b[1;32m\u001b[m\u001b[0mbeta \u001b[0m\u001b[38;5;9mbeta γλυφ →arrow beta \u001b[mγλυφ \u001b[1;32m\u001b[malpha \u001b[38;5;9mdata 汉字测试 →arrow →arrow \u001b]0;title\u0007\u001b[31mγλυφ \u001b[mdata beta alpha \u001b[Kγλυφ data data data γλυφ 汉字测试 alpha \u001b]0;title\u0007\u001b[38;5;9m\u001b[38;5;9m\u001b[38;5;9m\u001b[31m\u001b[31m→arrow \u001b[K\u001b[Kdata \u001b[1;32m\u001b[0mdata →arrow data \u001b[1;32m\u001bZ\u001b[m\u001b[0m汉字测试 →arrow beta \u001b[0m汉字测试 alpha \u001b[38;5;9m\u001b]0;title\u0007\u001b[38;5;9mbeta \u001b[31m\u001b[1;32m→arrow \u001b]0;title\u0007beta beta \u001b[38;5;9m汉字测试 γλυφ \u001b[mγλυφ \u001b[31m→arrow \u001b[K\u001b[1;32m汉字测试 \u001b[K汉字测试 \u001b[0malpha \u001b[1;32m\u001b[0m→arrow 汉字测试 beta beta data γλυφ \u001b[Kγλυφ \u001b[0m\u001b[1;32malpha 汉字测试 \u001b[1;32m\u001b[K\u001b[38;5;9m\u001b[0mγλυφ alpha alpha \u001b[m\u001b[0m\u001bZγλυφ data 汉字测试 \u001b[38;5;9m→arrow data beta \u001b[31mdata γλυφ \u001b[38;5;9mbeta \u001bZ→arrow alpha →arrow \u001b[31m\u001b[0m\u001b[mγλυφ \u001b[m\u001b[Kbeta data →arrow \u001b[K\u001b[31mbeta γλυφ →arrow data \u001b[31m\u001b[31malpha \u001b[31m\u001b[0malpha →arrow 汉字测试 \u001b]0;title\u0007\u001b[malpha \u001b[31m\u001b[31mdata \u001b]0;title\u0007\u001b[0malpha \u001b[0m汉字测试 \u001b[31mγλυφ 汉字测试 \u001bZ\u001bZ\u001b[38;5;9mbeta →arrow 汉字测试 \u001b[38;5;9m\u001b[31m→arrow \u001b]0;title\u0007beta 汉字测试 \u001b]0;title\u0007\u001b]0;title\u0007\u001b]0;title\u0007→arrow 汉字测试 \u001b[31m\u001b[malpha data 汉字测试 data beta 汉字测试 →arrow γλυφ \u001b[0m\u001b[mγλυφ beta \u001b[38;5;9malpha \u001b[0m\u001b[mγλυφ \u001b[K汉字测试 \u001b[1;32m\u001b[31malpha alpha \u001b[m\u001bZγλυφ 汉字测试 γλυφ alpha \u001b[31mdata γλυφ \u001b[1;32mdata \u001b[malpha \u001b[Kγλυφ \u001b[31m→arrow beta \u001b[K\u001b[K\u001b[1;32malpha \u001b]0;title\u0007\u001b[31m\u001b[1;32mbeta \u001b[Kbeta γλυφ alpha γλυφ \u001b[38;5;9malpha \u001b[31mdata \u001b]0;title\u0007beta \u001b[K\u001b[m\u001b[K\u001b[K汉字测试 \u001b[K\u001b[38;5;9mdata alpha \u001b[Kdata \u001b[mdata γλυφ beta \u001b[38;5;9m\u001b[mγλυφ \u001b[mbeta \u001b[m\u001bZ\u001b[38;5;9m\u001b]0;title\u0007\u001b[K\u001b[malpha 汉字测试 \u001b[38;5;9mγλυφ beta →arrow beta →arrow γλυφ \u001b[31m→arrow \u001b[38;5;9mγλυφ alpha 汉字测试 beta \u001b[31malpha \u001b[Kalpha alpha \u001b[m\u001b[38;5;9m\u001b[1;32m\u001b[0m→arrow data \u001b]0;title\u0007汉字测试 \u001b[38;5;9mbeta \u001b[mbeta \u001b[0m汉字测试 alpha 汉字测试 \u001b[mdata γλυφ \u001bZ\u001b[1;32mbeta data alpha γλυφ data \u001b[malpha \u001b[38;5;9mbeta beta alpha \u001b[0m\u001b[31m\u001b[m\u001b[31m汉字测试 \u001b[K\u001b[38;5;9mdata \u001b[38;5;9malpha alpha \u001bZ\u001b]0;title\u0007beta \u001b[0m\u001bZ汉字测试 γλυφ γλυφ γλυφ \u001b[malpha \u001b]0;title\u0007汉字测试 汉字测试 \u001b[0m\u001b[Kbeta \u001b[mbeta beta γλυφ 汉字测试 \u001b[1;32m\u001b[Kdata →arrow \u001b[31m→arrow γλυφ γλυφ 汉字测试 \u001b]0;title\u0007\u001b[m\u001b[1;32malpha data \u001bZalpha \u001b]0;title\u0007\u001b[K→arrow \u001b[m\u001b[mγλυφ \u001b[m\u001b[31m\u001b[1;32m→arrow \u001b[31m\u001b[m→arrow 汉字测试 →arrow beta alpha γλυφ \u001b[Kbeta \u001bZ\u001b[38;5;9mdata γλυφ γλυφ alpha \u001b[31m\u001b[K\u001b[1;32m\u001b[m\u001b]0;title\u0007data →arrow alpha →arrow beta beta data beta 汉字测试 alpha \u001b[31malpha beta \u001b[0m\u001b[38;5;9m\u001b[31m\u001b[38;5;9m→arrow \u001b[K\u001b[Kalpha beta \u001b[31m\u001b[1;32mdata \u001b[1;32m\u001b[K\u001b[m\u001b]0;title\u0007\u001b[31m\u001b[38;5;9m\u001b[Kbeta →arrow γλυφ \u001bZalpha γλυφ →arrow →arrow \u001b[m\u001b[K\u001b[1;32m\u001b[malpha 汉字测试 \u001b[mbeta →arrow γλυφ alpha \u001b[0m\u001b[0malpha beta \u001b[m\u001b[1;32m\u001b[1;32malpha →arrow γλυφ \u001b[38;5;9m\u001b[0m\u001b[1;32m\u001bZ→arrow \u001b[38;5;9m\u001b[31malpha alpha 汉字测试 →arrow data beta data \u001b]0;title\u0007γλυφ \u001b[K\u001b[0m→arrow γλυφ alpha \u001b[31m\u001b[m→arrow \u001b]0;title\u0007\u001b[38;5;9m\u001b[0m\u001b[malpha 汉字测试 \u001b[31mγλυφ →arrow \u001b[Kalpha alpha beta \u001b[38;5;9mbeta →arrow data γλυφ beta beta \u001b[38;5;9malpha \u001b[38;5;9m\u001b[m汉字测试 \u001b[m\u001b]0;title\u0007alpha \u001b[K\u001b[38;5;9m\u001b[mγλυφ \u001b[Kγλυφ data 汉字测试 \u001b]0;title\u0007\u001b[0mγλυφ →arrow →arrow →arrow \u001b[1;32mγλυφ 汉字测试 汉字测试 \u001b[0m\u001b[m\u001b[38;5;9mdata 汉字测试 \u001b[1;32m\u001b[0m\u001b[31mγλυφ \u001b]0;title\u0007alpha \u001b[38;5;9m\u001b[31m\u001b[31m\u001b[31malpha 汉字测试 alpha \u001b[0m\u001bZbeta →arrow \u001b[31malpha alpha \u001b[0mdata beta alpha alpha data →arrow beta γλυφ \u001b[31m\u001b[K\u001b[1;32mγλυφ \u001b[1;32m\u001b[1;32m汉字测试 data 汉字测试 beta beta \u001b[m\u001b[Kγλυφ data \u001b[mγλυφ 汉字测试 γλυφ \u001b[m\u001b]0;title\u0007→arrow →arrow \u001b[0m\u001b[mbeta beta 汉字测试 →arrow γλυφ γλυφ \u001b[38;5;9m→arrow \u001b[1;32mγλυφ \u001b]0;title\u0007data \u001b[1;32mbeta \u001b[31m→arrow 汉字测试 alpha data →arrow data \u001b[0m汉字测试 \u001b[m\u001b]0;title\u0007beta alpha \u001b[38;5;9m汉字测试 \u001b[mγλυφ beta \u001b[1;32m\u001b[malpha 汉字测试 \u001b[1;32m\u001b[0m\u001b[31m\u001bZalpha →arrow alpha \u001b[1;32mdata beta data →arrow \u001b]0;title\u0007beta data γλυφ alpha \u001b[38;5;9malpha alpha data \u001bZ\u001b[38;5;9m汉字测试 alpha \u001bZ\u001b[38;5;9mdata alpha →arrow →arrow \u001b[31m\u001b[Kbeta alpha γλυφ beta \u001b[mbeta \u001b[31mγλυφ \u001bZ\u001bZ\u001b[K\u001bZbeta alpha \u001b[1;32m\u001b[31m\u001b]0;title\u0007beta \u001b]0;title\u0007\u001b[1;32malpha beta beta \u001b[0m\u001bZγλυφ alpha \u001b[mdata \u001b[38;5;9m汉字测试 beta \u001b[38;5;9malpha \u001b[Kdata \u001b[0m汉字测试 γλυφ →arrow data \u001b[31mdata γλυφ \u001b[1;32m汉字测试 alpha \u001b]0;title\u0007alpha \u001b[38;5;9m\u001bZalpha 汉字测试 alpha beta γλυφ \u001b[38;5;9m\u001b[Kdata \u001b[1;32malpha data \u001b]0;title\u0007\u001b[m\u001b[1;32m\u001b[K\u001b[38;5;9m\u001b[38;5;9mγλυφ \u001b[m→arrow →arrow \u001b[1;32mγλυφ \u001b[31mdata →arrow \u001b[malpha \u001b]0;title\u0007\u001b[K\u001b[0mbeta 汉字测试 \u001b[31m→arrow \u001b[K\u001b]0;title\u0007alpha beta \u001b]0;title\u0007\u001b[0m汉字测试 beta →arrow beta γλυφ →arrow beta \u001b[m\u001b[K\u001b]0;title\u0007\u001b[m\u001b[0m\u001b[1;32m\u001b[38;5;9mbeta γλυφ data alpha γλυφ \u001b[mγλυφ \u001b[1;32m汉字测试 →arrow 汉字测试 汉字测试 \u001b]0;title\u0007beta alpha \u001b[0mbeta data \u001b[0malpha \u001b[31m\u001b[38;5;9m→arrow data \u001b[31m\u001b]0;title\u0007\u001b[malpha γλυφ \u001b[31m\u001b[38;5;9m\u001bZ\u001b]0;title\u0007alpha \u001b[38;5;9m\u001b[mdata \u001b[31m→arrow alpha \u001b[Kbeta \u001bZ\u001b[0m\u001b[38;5;9m\u001b[m\u001b[1;32mγλυφ alpha data \u001b[31mbeta data \u001b[1;32mbeta →arrow \u001b[mbeta \u001b[31m\u001b[31m\u001b[m\u001b[1;32mdata γλυφ \u001b[38;5;9m→arrow 汉字测试 alpha alpha \u001b[K汉字测试 \u001b[m\u001b[m\u001b[38;5;9m\u001b[31m\u001b[m\u001b[K\u001b[mγλυφ data \u001b[31m\u001b[38;5;9m→arrow 汉字测试 \u001b[38;5;9mdata data alpha \u001b[38;5;9m汉字测试 \u001b[38;5;9m\u001b[31m\u001b[31mbeta \u001b[Kdata data data 汉字测试 γλυφ \u001b]0;title\u0007γλυφ \u001b[m\u001b[38;5;9m汉字测试 data 汉字测试 \u001b[Kγλυφ \u001b]0;title\u0007data \u001b[mdata γλυφ \u001b[1;32m\u001b[31mbeta 汉字测试 \u001b[38;5;9m→arrow \u001b[1;32m汉字测试 beta →arrow γλυφ beta γλυφ alpha \u001b[38;5;9m\u001bZbeta \u001b[38;5;9m\u001b[1;32m\u001b[K→arrow \u001b[38;5;9m\u001b[K\u001b[0mγλυφ alpha beta \u001b[1;32mbeta beta →arrow →arrow 汉字测试 γλυφ alpha \u001b[31mdata \u001b]0;title\u0007→arrow \u001b[38;5;9m\u001b[1;32m\u001b]0;title\u0007\u001b[0m→arrow beta \u001b[Kdata data data beta data data γλυφ γλυφ 汉字测试 \u001b[mγλυφ \u001bZ汉字测试 \u001b]0;title\u0007\u001b]0;title\u0007\u001b[0m\u001bZ\u001b[31mγλυφ data \u001b[38;5;9m\u001b[Kdata γλυφ γλυφ \u001b[0m\u001b[K\u001b[0m→arrow alpha \u001b[K\u001b]0;title\u0007data \u001b[38;5;9mdata →arrow \u001b[m\u001b[38;5;9m汉字测试 \u001bZbeta beta \u001b[Kalpha \u001b[38;5;9m\u001b[0m\u001bZ\u001b[31m\u001b[38;5;9m→arrow \u001b[0m→arrow →arrow →arrow →arrow \u001b[0m汉字测试 data \u001b[1;32m→arrow alpha →arrow \u001b[38;5;9m汉字测试 \u001b[38;5;9m\u001b[38;5;9mdata \u001b]0;title\u0007\u001b]0;title\u0007\u001b]0;title\u0007\u001b[38;5;9mγλυφ \u001b]0;title\u0007\u001b[1;32mγλυφ 汉字测试 \u001b[malpha \u001b[0m汉字测试 beta \u001bZ\u001b[K\u001b[K→arrow \u001b[38;5;9mγλυφ γλυφ \u001b[1;32mγλυφ →arrow \u001bZdata γλυφ \u001bZ\u001b[K\u001bZ\u001bZγλυφ \u001b]0;title\u0007\u001bZ\u001b[38;5;9m\u001b[1;32m\u001b[1;32m\u001b[m\u001b[mdata beta \u001b[K\u001bZ\u001b[38;5;9m\u001bZalpha \u001b[0m\u001b[K→arrow 汉字测试 beta beta alpha \u001b[m汉字测试 beta →arrow \u001b[38;5;9malpha data →arrow 汉字测试 γλυφ \u001b[38;5;9m\u001b[m\u001b]0;title\u0007\u001b]0;title\u0007\u001b[Kbeta beta \u001bZγλυφ \u001b[1;32m\u001b[31m\u001b[31m\u001b[38;5;9mγλυφ \u001bZdata \u001b[0m\u001b[31mγλυφ data \u001b[0m\u001b[31m→arrow \u001b[38;5;9malpha beta \u001bZdata \u001b[Kdata \u001b[1;32mdata 汉字测试 γλυφ \u001b[K\u001b]0;title\u0007→arrow 汉字测试 \u001b[38;5;9m\u001b[K\u001b[38;5;9mbeta \u001b[38;5;9m\u001b[31m→arrow →arrow \u001b[31m\u001b[31m\u001b]0;title\u0007→arrow 汉字测试 \u001b[malpha beta \u001b[38;5;9mγλυφ data γλυφ \u001b]0;title\u0007\u001b[m\u001bZalpha beta \u001b[0m\u001b[0m汉字测试 \u001b[mdata 汉字测试 \u001b[0m→arrow \u001b[0mγλυφ data data \u001b[0m\u001bZ\u001b[m\u001b[0mbeta γλυφ alpha \u001b[K汉字测试 \u001b[0m\u001bZ\u001b[38;5;9mγλυφ beta \u001b[Kalpha γλυφ 汉字测试 \u001b[31mγλυφ γλυφ beta beta \u001b[1;32m→arrow 汉字测试 \u001b[38;5;9m\u001b]0;title\u0007data \u001b[K\u001b[31mdata γλυφ \u001b]0;title\u0007alpha γλυφ \u001b[1;32m\u001b[Kalpha data data \u001b[1;32m\u001b[m→arrow 汉字测试 →arrow beta γλυφ \u001b[38;5;9m\u001bZalpha \u001b[Kalpha \u001bZ\u001b[m\u001b[0m\u001b[38;5;9m→arrow \u001b[m→arrow beta \u001b[Kbeta \u001b[38;5;9m\u001b[Kdata beta 汉字测试 \u001b[Kγλυφ \u001b[38;5;9m\u001b]0;title\u0007γλυφ \u001b[0m汉字测试 汉字测试 \u001b[31mdata \u001b[1;32m\u001b[m\u001b[Kdata \u001b[K\u001b]0;title\u0007\u001b[1;32mbeta \u001b[0mdata \u001b[31m汉字测试 γλυφ →arrow data γλυφ alpha →arrow \u001b[0m\u001b[38;5;9mbeta beta \u001b[malpha 汉字测试 data →arrow γλυφ \u001b[1;32mdata alpha beta \u001b[31m\u001b[Kbeta →arrow data \u001b[31m\u001b[38;5;9mdata \u001b[38;5;9malpha \u001b[Kγλυφ \u001b]0;title\u0007→arrow data \u001b[1;32m\u001b[31m\u001b[0m\u001b[1;32m\u001b[38;5;9m→arrow 汉字测试 beta γλυφ 汉字测试 →arrow \u001b[mdata alpha \u001b[mγλυφ →arrow \u001b[31mγλυφ beta \u001b[1;32mdata \u001b[0m→arrow beta \u001b[31m\u001b[31m\u001b[1;32m汉字测试 data data γλυφ ","expected":"汉字测试 data \u001b[0m\u001b[38;5;9m汉字测试 \u001b[mbeta \u001b[0mγλυφ \u001b[0malpha alpha \u001b[31m\u001b[38;5;9malpha \u001b[mdata \u001b[K…"},{"label":"sgr-mixed-10k-narrow","maxWidth":12,"text":"\u001b[31mdata 汉字测试 beta data \u001b[31mγλυφ \u001b[1;32m\u001b[0m\u001b[m\u001b[m\u001b[31m\u001b[1;32mdata \u001b[mγλυφ →arrow →arrow alpha \u001b[1;32m\u001bZ\u001b[31m汉字测试 \u001bZ→arrow data \u001b[K\u001b[K\u001b[31mbeta \u001b[38;5;9m\u001b[K\u001b[38;5;9mγλυφ γλυφ alpha γλυφ →arrow γλυφ →arrow data \u001b[0m\u001b[Kγλυφ →arrow data \u001bZdata beta \u001b[31m\u001b[mγλυφ \u001b[38;5;9mdata beta γλυφ γλυφ alpha γλυφ alpha \u001b]0;title\u0007\u001b[mdata →arrow data 汉字测试 \u001b[0m→arrow \u001b[0mγλυφ \u001b[1;32m汉字测试 \u001b[31m\u001b[31m\u001b[malpha \u001b[0mdata \u001b]0;title\u0007\u001b]0;title\u0007data γλυφ 汉字测试 beta data \u001b[1;32mdata 汉字测试 \u001b[Kbeta \u001b]0;title\u0007data \u001bZγλυφ 汉字测试 beta γλυφ →arrow 汉字测试 →arrow γλυφ \u001b[38;5;9m\u001b]0;title\u0007→arrow \u001b]0;title\u0007\u001b[31mdata beta \u001b[31m→arrow data beta beta 汉字测试 data data γλυφ \u001b[malpha 汉字测试 γλυφ →arrow \u001b[31m\u001b[0m\u001b]0;title\u0007→arrow →arrow \u001b[0mdata 汉字测试 →arrow alpha \u001b[38;5;9m\u001b[31mbeta beta data \u001b[0malpha \u001b[1;32mdata \u001b[0m\u001b[0mγλυφ \u001b[38;5;9m\u001b[Kdata \u001b[31m→arrow \u001b[mbeta \u001b[31mdata \u001b[0m\u001b[0m\u001bZalpha beta \u001b[1;32malpha \u001b[m汉字测试 data \u001b[0m\u001b[0m→arrow \u001b[0m\u001b]0;title\u0007\u001b[m\u001b[31m\u001b[1;32mdata data →arrow data beta \u001bZbeta \u001b[0mdata \u001bZbeta γλυφ 汉字测试 alpha γλυφ γλυφ \u001b[0mdata data \u001b[Kalpha 汉字测试 \u001b[0m\u001b[mγλυφ alpha beta \u001b[38;5;9mbeta \u001b[0mbeta →arrow \u001b[0mbeta \u001b[38;5;9m\u001b[0mdata data data data γλυφ data data →arrow γλυφ \u001b[1;32mbeta alpha γλυφ beta \u001b[1;32mγλυφ \u001b[K\u001b[1;32malpha \u001b[1;32malpha alpha γλυφ γλυφ \u001b]0;title\u0007beta \u001b]0;title\u0007data data \u001b]0;title\u0007beta \u001b[1;32m\u001b[38;5;9m\u001b[1;32m\u001b[1;32m→arrow data alpha \u001b[1;32m\u001bZalpha 汉字测试 \u001b[31m汉字测试 \u001b[K\u001b[0m→arrow data →arrow \u001b[Kdata →arrow data \u001b[K\u001b[K汉字测试 alpha γλυφ \u001b[0m→arrow \u001b[31m汉字测试 \u001b[31m\u001bZ\u001b[38;5;9mdata data →arrow γλυφ →arrow \u001b[Kdata 汉字测试 \u001b[0mdata \u001b[Kdata data data \u001b[38;5;9mbeta \u001bZdata 汉字测试 →arrow \u001b[38;5;9m\u001b[0mγλυφ \u001bZγλυφ alpha \u001b[m\u001b[m\u001b[K汉字测试 beta \u001b[0malpha alpha γλυφ \u001b[mdata \u001b[31mbeta \u001b[Kbeta \u001b[0m→arrow γλυφ 汉字测试 \u001b[1;32mγλυφ alpha \u001b[31mdata alpha →arrow →arrow 汉字测试 \u001b[1;32malpha \u001b]0;title\u0007data \u001bZdata γλυφ \u001b[31mdata \u001b]0;title\u0007γλυφ alpha \u001b[1;32mdata data beta \u001b]0;title\u0007\u001b[0m\u001b[31m\u001b[Kbeta →arrow alpha →arrow →arrow data data \u001b[K\u001b[0m\u001b[31malpha \u001b[0m\u001b[m汉字测试 beta \u001b[0m→arrow alpha →arrow alpha beta alpha \u001b[m\u001b[31m→arrow →arrow 汉字测试 \u001b[31m→arrow 汉字测试 data 汉字测试 \u001b[38;5;9m\u001b[31mγλυφ \u001b[1;32mγλυφ →arrow 汉字测试 汉字测试 汉字测试 \u001b[m\u001b[31m\u001b[1;32malpha 汉字测试 alpha \u001b[31mbeta \u001b[38;5;9mbeta 汉字测试 \u001b[m\u001b[K汉字测试 →arrow beta γλυφ →arrow γλυφ \u001b]0;title\u0007\u001b[mdata \u001b[0mbeta \u001b[K\u001bZ→arrow data \u001b]0;title\u0007alpha \u001b[38;5;9m\u001b[Kdata \u001b[38;5;9m\u001b[m汉字测试 data \u001b]0;title\u0007汉字测试 \u001b[1;32malpha \u001b[0m汉字测试 \u001b[38;5;9malpha alpha beta 汉字测试 汉字测试 beta γλυφ →arrow \u001b[31m\u001b[K\u001b[31m\u001b]0;title\u0007\u001b[0mγλυφ alpha beta data \u001b[31mdata data \u001bZγλυφ γλυφ γλυφ \u001b[m→arrow \u001b[38;5;9m汉字测试 汉字测试 γλυφ \u001b[K→arrow \u001b[0m\u001b[1;32mγλυφ data data data 汉字测试 \u001b[1;32mγλυφ →arrow beta γλυφ \u001b[0mbeta \u001b[0m\u001b[0malpha \u001b[38;5;9mbeta \u001bZalpha \u001b]0;title\u0007\u001b[38;5;9mγλυφ beta data \u001b[Kγλυφ \u001b[0m→arrow data \u001b[1;32mdata \u001b[31mbeta \u001b[0m\u001b[m\u001b[Kdata data \u001b[0m→arrow \u001b[K\u001b[Kalpha →arrow \u001b[Kbeta beta \u001b[31m\u001b[Kγλυφ beta data beta \u001b[Kdata \u001b[0mγλυφ →arrow →arrow alpha \u001b[mbeta alpha →arrow alpha \u001b[0mγλυφ 汉字测试 γλυφ data γλυφ \u001bZ\u001b[Kγλυφ \u001b[mbeta \u001b]0;title\u0007\u001b[0mbeta 汉字测试 汉字测试 →arrow \u001b[0m\u001b[K\u001b[m\u001b[38;5;9m\u001b[38;5;9m\u001b[m\u001bZ\u001b[1;32mbeta \u001b[31m\u001b[38;5;9m汉字测试 →arrow beta alpha \u001b[0m\u001b[1;32m\u001b[38;5;9m\u001b[38;5;9m\u001b[38;5;9m\u001b[Kγλυφ beta 汉字测试 \u001b[mdata alpha data \u001b[Kdata \u001b[K\u001b[31m→arrow beta γλυφ 汉字测试 \u001b[Kγλυφ data γλυφ \u001b[38;5;9m→arrow data alpha γλυφ data \u001b[31m\u001b[K\u001b[38;5;9mdata 汉字测试 alpha \u001b[31m\u001b[31mbeta \u001b[0mγλυφ \u001b[1;32m\u001b[38;5;9m\u001b[K\u001b[K\u001b[0m\u001bZ→arrow γλυφ 汉字测试 beta \u001bZalpha γλυφ beta \u001b[1;32malpha γλυφ \u001b[31m\u001b[31m\u001b[38;5;9m→arrow \u001b[31malpha 汉字测试 data \u001b[1;32mbeta 汉字测试 γλυφ alpha \u001b[38;5;9m汉字测试 data \u001b[0mbeta alpha →arrow beta beta γλυφ γλυφ \u001b[0m\u001b[K\u001b[0m\u001b[31m→arrow \u001b[38;5;9malpha \u001b[0m\u001b[K→arrow \u001b[0m\u001b]0;title\u0007\u001b[38;5;9m\u001b[0malpha \u001b[0m\u001b]0;title\u0007\u001b[38;5;9mbeta beta \u001b[K\u001b[1;32mbeta →arrow 汉字测试 \u001b[38;5;9m\u001b[K→arrow \u001b[0malpha beta \u001b[0m汉字测试 →arrow alpha 汉字测试 →arrow \u001b[mdata beta \u001b[38;5;9m汉字测试 beta \u001b[31m\u001b[38;5;9m\u001b[Kalpha data \u001b[31m汉字测试 beta →arrow \u001b[38;5;9malpha data alpha \u001b[1;32m\u001b[0m\u001bZγλυφ \u001b[Kγλυφ beta →arrow \u001b[38;5;9m\u001b[m\u001b]0;title\u0007\u001b[1;32mγλυφ alpha \u001b[1;32m→arrow \u001bZγλυφ \u001b[1;32m\u001bZγλυφ 汉字测试 →arrow beta \u001b[malpha →arrow \u001b[1;32malpha alpha \u001b[31malpha alpha \u001b[31m\u001b[Kγλυφ beta \u001b[m\u001b[31mγλυφ \u001b[0m→arrow γλυφ beta alpha \u001b[0mγλυφ alpha alpha \u001b[38;5;9mbeta data γλυφ beta \u001b]0;title\u0007\u001bZγλυφ \u001bZ\u001b[0m\u001b[1;32mγλυφ beta 汉字测试 \u001b[0malpha \u001b[31m\u001b[38;5;9m\u001b[m\u001b[mbeta \u001b[Kalpha →arrow \u001b[38;5;9m\u001bZdata γλυφ \u001b]0;title\u0007γλυφ \u001b[K→arrow \u001bZ\u001b[38;5;9mbeta γλυφ 汉字测试 alpha data γλυφ \u001b[38;5;9m\u001bZγλυφ \u001b]0;title\u0007alpha →arrow 汉字测试 \u001b[31m汉字测试 \u001b[1;32m\u001b[K\u001b[K\u001b[0mbeta 汉字测试 \u001b]0;title\u0007beta data \u001bZ\u001b[m\u001b[m\u001b[0m\u001bZ\u001b[1;32m汉字测试 γλυφ \u001b[38;5;9m\u001b[K→arrow data →arrow \u001b[1;32m\u001b[K\u001b[1;32m汉字测试 汉字测试 beta →arrow data alpha \u001b[m→arrow \u001b[31m\u001bZγλυφ \u001b[1;32mγλυφ \u001b[m\u001bZ\u001b[31m\u001b[0malpha 汉字测试 \u001b[38;5;9m汉字测试 \u001b[38;5;9mγλυφ alpha γλυφ \u001b[1;32m\u001b[38;5;9m\u001b[mdata \u001b[38;5;9mdata \u001b]0;title\u0007\u001b[38;5;9m\u001b[1;32mγλυφ \u001b[38;5;9m\u001b[31m\u001b[1;32mbeta \u001b[31mγλυφ \u001b[38;5;9m→arrow \u001b[31malpha \u001b[38;5;9m汉字测试 \u001b[mbeta beta \u001b[Kγλυφ \u001b[38;5;9m\u001b]0;title\u0007\u001b[0m\u001b[1;32m\u001b[1;32m\u001b[31mbeta \u001b]0;title\u0007data data beta 汉字测试 \u001b]0;title\u0007\u001b[38;5;9m\u001bZdata \u001b[31mγλυφ \u001b[m→arrow \u001b]0;title\u0007beta →arrow 汉字测试 \u001b[mdata \u001b[31malpha γλυφ \u001b[38;5;9m→arrow beta 汉字测试 →arrow γλυφ →arrow \u001b]0;title\u0007\u001b]0;title\u0007汉字测试 alpha \u001b[31m汉字测试 \u001b[1;32m\u001b[38;5;9m\u001b[m\u001b[0m汉字测试 \u001b[m\u001b[38;5;9m→arrow γλυφ \u001b[38;5;9mbeta →arrow \u001b[Kdata alpha 汉字测试 \u001b[1;32m汉字测试 \u001bZ\u001bZalpha \u001b[31m\u001b[mbeta \u001b[m\u001b[K\u001bZ\u001b[1;32mγλυφ \u001b[K→arrow \u001b[m\u001b[1;32mbeta alpha \u001b[0m\u001b[38;5;9m\u001b[1;32mbeta →arrow beta beta 汉字测试 \u001b[0m汉字测试 alpha \u001bZalpha data \u001b[1;32mdata \u001b[malpha alpha \u001b]0;title\u0007\u001b[0m\u001b[0malpha 汉字测试 alpha \u001b[1;32mγλυφ \u001b[0malpha beta \u001b]0;title\u0007\u001bZ\u001b[38;5;9mγλυφ beta γλυφ \u001b[Kalpha \u001b[31m\u001b[0malpha alpha beta \u001b[1;32mγλυφ beta \u001b[0m\u001b[K汉字测试 汉字测试 \u001b[31mbeta \u001b[1;32m汉字测试 alpha \u001b[0m→arrow \u001b[mdata γλυφ alpha alpha beta data \u001b[mγλυφ γλυφ \u001b[0mγλυφ \u001b[0malpha beta \u001b[31mbeta alpha \u001b[malpha data \u001bZ\u001b[1;32m\u001b]0;title\u0007\u001b[38;5;9mγλυφ 汉字测试 γλυφ beta \u001b[38;5;9m\u001b[0m→arrow 汉字测试 →arrow beta beta beta beta →arrow →arrow \u001b[1;32mdata \u001b[0m\u001b[1;32malpha \u001b[m\u001b[38;5;9m汉字测试 \u001b[K\u001bZ汉字测试 \u001b[1;32m→arrow beta alpha \u001b[0mγλυφ →arrow \u001b[mdata →arrow \u001b]0;title\u0007data beta \u001b[Kbeta →arrow alpha 汉字测试 \u001bZ\u001b[K\u001b[0mdata \u001b[31m\u001b[Kγλυφ →arrow γλυφ beta \u001b[38;5;9m→arrow \u001b[38;5;9mdata →arrow 汉字测试 \u001b[38;5;9m\u001b[1;32m汉字测试 \u001b[1;32m\u001b[38;5;9m\u001b[0mγλυφ \u001b[K\u001b[1;32malpha alpha \u001b[K→arrow \u001b[1;32m\u001b[Kalpha \u001b[K汉字测试 \u001b[1;32m\u001b[Kγλυφ \u001b[0m→arrow data →arrow 汉字测试 γλυφ alpha 汉字测试 beta beta data data \u001bZ\u001b[1;32m\u001b]0;title\u0007\u001bZ\u001b]0;title\u0007\u001b[0m\u001b[31mdata data γλυφ \u001b[31m→arrow \u001b[m\u001b[31mdata →arrow data alpha \u001b[38;5;9mdata data \u001b[Kγλυφ \u001b[1;32malpha \u001b[m→arrow data →arrow alpha \u001b[0m\u001b]0;title\u0007alpha alpha \u001b[38;5;9m\u001b[m\u001b[38;5;9mbeta \u001b[m\u001b[31malpha alpha \u001b[m\u001b[K\u001b[m→arrow \u001b[K\u001b[1;32mγλυφ →arrow →arrow alpha \u001b[m\u001b[38;5;9m\u001b[31m\u001b[m汉字测试 γλυφ beta \u001b[0mbeta data \u001b[K\u001b[K\u001b[m→arrow \u001b[1;32m\u001b[31mbeta \u001b[31malpha \u001b[Kalpha γλυφ 汉字测试 \u001b[K\u001b[1;32mbeta →arrow alpha data 汉字测试 \u001b]0;title\u0007beta γλυφ \u001b[K\u001b[0m\u001b[31malpha \u001b[Kbeta \u001b[1;32mbeta \u001b[malpha →arrow 汉字测试 \u001b[1;32m→arrow \u001bZ\u001b[K\u001b[1;32mbeta 汉字测试 \u001b[K汉字测试 γλυφ γλυφ γλυφ \u001b[31m\u001b[Kγλυφ alpha γλυφ \u001b[31mγλυφ \u001bZ\u001b]0;title\u0007\u001b[0malpha →arrow \u001b[1;32m\u001b[m汉字测试 \u001b[38;5;9mbeta \u001b[m\u001b[0m\u001b]0;title\u0007汉字测试 \u001b[38;5;9m→arrow \u001b]0;title\u0007alpha \u001b[m→arrow \u001b[38;5;9m\u001b[0m\u001b[0mbeta \u001b[0m\u001b]0;title\u0007data →arrow γλυφ beta \u001b[38;5;9malpha beta \u001b[mdata γλυφ alpha \u001b[38;5;9m\u001b[38;5;9malpha \u001b[1;32m汉字测试 γλυφ \u001b[1;32mdata →arrow alpha \u001b[K\u001b[malpha \u001b[0mγλυφ \u001bZ\u001bZ汉字测试 γλυφ →arrow \u001b[31m\u001b[1;32mdata \u001b[0mγλυφ beta \u001b]0;title\u0007汉字测试 data \u001b[38;5;9malpha →arrow beta \u001b[38;5;9mγλυφ alpha \u001b[1;32mγλυφ 汉字测试 汉字测试 \u001b[38;5;9m\u001b[1;32m汉字测试 \u001b[0m\u001b[0mγλυφ \u001b[0mbeta data alpha alpha 汉字测试 γλυφ \u001bZ\u001b[38;5;9mbeta γλυφ alpha γλυφ alpha \u001b[m汉字测试 →arrow \u001b[0m汉字测试 γλυφ \u001b]0;title\u0007beta data \u001b[0m\u001b[1;32m\u001b]0;title\u0007\u001b[38;5;9m\u001b]0;title\u0007\u001b[1;32mbeta \u001b[31m汉字测试 γλυφ \u001b[1;32m→arrow 汉字测试 γλυφ 汉字测试 \u001b[m→arrow 汉字测试 beta 汉字测试 →arrow 汉字测试 \u001b[38;5;9m\u001b]0;title\u0007\u001b[38;5;9mdata 汉字测试 \u001b[m\u001b[38;5;9mdata \u001b[Kdata 汉字测试 \u001b[38;5;9mbeta \u001b[0m\u001bZbeta \u001b[1;32malpha 汉字测试 \u001b[1;32mbeta data beta \u001b[1;32m\u001b[38;5;9m→arrow beta \u001b[31mdata beta \u001b[m\u001b[38;5;9mdata \u001b[38;5;9m\u001b[0mdata beta data beta →arrow \u001b[malpha \u001b[31m\u001b[m→arrow \u001b[K→arrow \u001b[31m\u001b[m\u001b]0;title\u0007汉字测试 data beta \u001b[0m汉字测试 data γλυφ alpha \u001b[K\u001b[K→arrow \u001bZ\u001b[0m→arrow →arrow \u001b[m\u001bZγλυφ data \u001b]0;title\u0007beta γλυφ γλυφ \u001b[malpha \u001b[K\u001b[38;5;9m汉字测试 data \u001b[mγλυφ \u001bZ\u001b[0m\u001b[31m\u001b]0;title\u0007data 汉字测试 alpha \u001bZ\u001b]0;title\u0007→arrow beta \u001b[38;5;9mγλυφ \u001b[K\u001b[1;32m\u001b[K\u001b]0;title\u0007beta \u001b[0m汉字测试 data 汉字测试 \u001b]0;title\u0007beta data data →arrow \u001b[mbeta \u001b[K汉字测试 data 汉字测试 汉字测试 beta \u001b[31m\u001bZ→arrow \u001b[1;32m\u001b[mdata \u001bZalpha \u001b[0m\u001bZ\u001b[K\u001b[1;32m→arrow \u001b[1;32m→arrow 汉字测试 \u001b]0;title\u0007\u001b[31mdata \u001b[K\u001bZ→arrow 汉字测试 →arrow 汉字测试 beta \u001b[38;5;9m→arrow \u001b[31mγλυφ →arrow \u001b[31m\u001b[1;32malpha \u001b[38;5;9m\u001b[K\u001b[Kdata \u001b[Kγλυφ γλυφ \u001b[31mγλυφ →arrow \u001b[31mγλυφ γλυφ γλυφ \u001b[1;32m汉字测试 \u001b]0;title\u0007beta \u001b[K\u001b[K\u001b[31m→arrow \u001b]0;title\u0007\u001b[K\u001b[1;32malpha \u001b[31m汉字测试 γλυφ γλυφ →arrow \u001b]0;title\u0007data alpha γλυφ \u001b[0m\u001b[0m\u001b[38;5;9m\u001b[0m\u001bZ\u001b[31m\u001b[31m\u001b[31mdata \u001b[0mdata \u001b[1;32mγλυφ \u001b]0;title\u0007γλυφ →arrow beta data \u001b[1;32malpha beta γλυφ 汉字测试 beta data \u001b[mγλυφ \u001bZbeta \u001b[m\u001b[31mdata \u001b[38;5;9malpha \u001bZ\u001b[31malpha \u001b[0m→arrow \u001b[38;5;9m汉字测试 汉字测试 \u001b[mγλυφ \u001b[31malpha beta data \u001b[Kdata →arrow γλυφ data γλυφ \u001b[m汉字测试 \u001b[31m→arrow data →arrow \u001b[31m\u001b[38;5;9m汉字测试 alpha \u001b[0m\u001b[31mγλυφ \u001b[K→arrow γλυφ 汉字测试 汉字测试 \u001b[m汉字测试 alpha \u001b[0m\u001b[1;32m\u001b[K汉字测试 \u001b[0m\u001b[Kalpha 汉字测试 \u001b[1;32mbeta beta \u001b[0malpha data \u001b[31mγλυφ γλυφ 汉字测试 \u001b]0;title\u0007\u001b[K→arrow 汉字测试 \u001b[31malpha \u001b[31mγλυφ \u001b[K\u001b[malpha \u001b[1;32mbeta 汉字测试 beta →arrow \u001b[m\u001b[m\u001b[mdata alpha 汉字测试 beta \u001b[1;32mdata \u001b[malpha \u001b[0mbeta \u001b[mγλυφ γλυφ →arrow →arrow γλυφ beta data \u001b[31m\u001b[38;5;9m汉字测试 \u001b]0;title\u0007alpha \u001b]0;title\u0007alpha \u001b[0m\u001b[mγλυφ 汉字测试 beta γλυφ γλυφ data beta \u001b[31m\u001b[1;32m\u001b[1;32m汉字测试 γλυφ \u001b[38;5;9m\u001b[m\u001b]0;title\u0007data \u001b[31mγλυφ →arrow alpha \u001b[38;5;9mbeta 汉字测试 \u001b]0;title\u0007\u001b[38;5;9m→arrow \u001b]0;title\u0007\u001b[31m汉字测试 beta \u001b[38;5;9m\u001b[K\u001b[0m\u001b[38;5;9m\u001b[0mbeta beta data γλυφ →arrow \u001b[1;32m\u001b[Kbeta \u001b]0;title\u0007beta 汉字测试 beta alpha →arrow γλυφ \u001b[m\u001bZ\u001b[31malpha \u001b[31mbeta \u001b[m\u001b[0mγλυφ \u001b[0m\u001b[Kdata data \u001b[Kbeta \u001b[K\u001b[0m汉字测试 汉字测试 \u001b]0;title\u0007\u001b[38;5;9m\u001b[1;32m→arrow alpha alpha \u001b[1;32m\u001b[0m→arrow \u001b[K\u001b[1;32malpha alpha \u001b[m\u001b[38;5;9mbeta beta 汉字测试 汉字测试 \u001b[31malpha \u001b[1;32m\u001bZ\u001b[K→arrow \u001b[1;32m汉字测试 →arrow →arrow \u001b[38;5;9m\u001b[Kγλυφ data data alpha γλυφ →arrow data 汉字测试 汉字测试 \u001b[31mγλυφ \u001b[38;5;9malpha →arrow \u001b[mγλυφ \u001b[38;5;9mbeta \u001b[38;5;9m→arrow \u001b[mdata alpha γλυφ \u001b[m汉字测试 \u001b[38;5;9m\u001b[31m汉字测试 \u001b[0m\u001b[38;5;9mγλυφ \u001b[K汉字测试 \u001b[38;5;9mbeta γλυφ γλυφ alpha \u001bZ汉字测试 γλυφ beta 汉字测试 data \u001b[1;32m","expected":"\u001b[31mdata 汉字测\u001b[31m…\u001b[0m"},{"label":"osc-title","maxWidth":30,"text":"\u001b]0;window title\u0007plain text after osc that is long enough to truncate here","expected":"\u001b]0;window title\u0007plain text a…"},{"label":"bare-esc","maxWidth":25,"text":"before \u001bZ after bare esc char continues to exceed the width limit easily","expected":"before \u001bZ after bare esc…"},{"label":"csi-k-mixed-sgr","maxWidth":20,"text":"\u001b[31mred\u001b[K\u001b[32mgreen tail that keeps going past the boundary here ok","expected":"\u001b[31mred\u001b[K\u001b[32mgreen tail th\u001b[31m\u001b[32m…\u001b[0m"},{"label":"osc-inside-truncation","maxWidth":24,"text":"AAAAAAAAAAAAAAAAAAAA\u001b]0;t\u0007BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB","expected":"AAAAAAAAAAAAAAAAAAAA\u001b]0…"},{"label":"esc-at-end","maxWidth":22,"text":"text almost at width limit\u001b","expected":"text almost at width …"},{"label":"sgr-exact-fit","maxWidth":31,"text":"\u001b[31mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\u001b[0m","expected":"\u001b[31mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\u001b[0m"},{"label":"emoji-mix","maxWidth":17,"text":"😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅😀🚀✅\u001b[1mbold\u001b[0myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy","expected":"😀🚀✅😀🚀✅😀🚀✅😀🚀✅…"}]
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// mock 策略:与 run-spawn-integration.test.ts 一致(共享 helpers/spawn-mock.ts),
|
|
26
26
|
// 额外注入 ctx.uiRequestHandler + ctx.dialogQueue + channel registry。
|
|
27
27
|
|
|
28
|
-
import {
|
|
28
|
+
import { spawn } from "node:child_process";
|
|
29
29
|
import * as fs from "node:fs";
|
|
30
30
|
|
|
31
31
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
@@ -36,7 +36,15 @@ vi.mock("node:child_process", async () => {
|
|
|
36
36
|
const { FakeChild } = await import("./helpers/spawn-mock.ts");
|
|
37
37
|
return {
|
|
38
38
|
spawn: vi.fn(() => new FakeChild()),
|
|
39
|
-
|
|
39
|
+
// buildEnvBlock 的 git branch 调用(execFile 异步):默认 err-first 兜底 → catch → branch=""
|
|
40
|
+
execFile: vi.fn(
|
|
41
|
+
(
|
|
42
|
+
_cmd: string,
|
|
43
|
+
_args: readonly string[],
|
|
44
|
+
_opts: unknown,
|
|
45
|
+
cb: (err: Error | null, stdout?: string, stderr?: string) => void,
|
|
46
|
+
) => cb(new Error("execFile not configured in this test")),
|
|
47
|
+
),
|
|
40
48
|
};
|
|
41
49
|
});
|
|
42
50
|
|
|
@@ -88,7 +96,6 @@ import {
|
|
|
88
96
|
} from "./helpers/spawn-mock.ts";
|
|
89
97
|
|
|
90
98
|
const mockSpawn = vi.mocked(spawn);
|
|
91
|
-
const mockExec = vi.mocked(execFileSync);
|
|
92
99
|
const mockExistsSync = vi.mocked(fs.existsSync);
|
|
93
100
|
|
|
94
101
|
const lastSpawnedChild = (): FakeChild => lastSpawnedChildOf(mockSpawn);
|
|
@@ -172,7 +179,6 @@ function makeAskUserCtx(
|
|
|
172
179
|
|
|
173
180
|
beforeEach(() => {
|
|
174
181
|
vi.clearAllMocks();
|
|
175
|
-
mockExec.mockReturnValue("");
|
|
176
182
|
mockExistsSync.mockReturnValue(false);
|
|
177
183
|
// 静默 stdin-writer / factory 的 warn(序列化失败降级等场景)
|
|
178
184
|
vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// src/execution/__tests__/before-agent-start-injection.test.ts
|
|
2
|
+
//
|
|
3
|
+
// SP-3: before_agent_start subagent 状态注入测试。
|
|
4
|
+
//
|
|
5
|
+
// 验证:
|
|
6
|
+
// TC-1: 有活跃 subagent 时 hook 返回 message(customType=subagent-status)
|
|
7
|
+
// TC-2: 无活跃 subagent 时 hook 返回 undefined
|
|
8
|
+
// TC-3: 超过 10 条截断显示 '+N more'
|
|
9
|
+
// TC-4: 快照内容格式正确(含 id、slug、status、rounds)
|
|
10
|
+
|
|
11
|
+
import { describe, expect, it, vi } from "vitest";
|
|
12
|
+
|
|
13
|
+
import { formatSubagentStatusSnapshot } from "../../index.ts";
|
|
14
|
+
import type { SubagentRecord } from "../types.ts";
|
|
15
|
+
|
|
16
|
+
// ── SubagentRecord stub 工厂 ──
|
|
17
|
+
|
|
18
|
+
function makeRecord(over: Partial<SubagentRecord> = {}): SubagentRecord {
|
|
19
|
+
return {
|
|
20
|
+
id: "sa-abc123",
|
|
21
|
+
agent: "general-purpose",
|
|
22
|
+
task: "test task",
|
|
23
|
+
slug: "test-slug",
|
|
24
|
+
status: "running",
|
|
25
|
+
mode: "background",
|
|
26
|
+
startedAt: Date.now(),
|
|
27
|
+
rootSessionId: "session-main",
|
|
28
|
+
parentRecordId: undefined,
|
|
29
|
+
depth: 0,
|
|
30
|
+
endedAt: undefined,
|
|
31
|
+
turns: 0,
|
|
32
|
+
totalTokens: 0,
|
|
33
|
+
model: "test/model",
|
|
34
|
+
thinkingLevel: undefined,
|
|
35
|
+
eventLog: [],
|
|
36
|
+
displayItems: [],
|
|
37
|
+
result: undefined,
|
|
38
|
+
error: undefined,
|
|
39
|
+
sessionFile: undefined,
|
|
40
|
+
round: 0,
|
|
41
|
+
...over,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ============================================================
|
|
46
|
+
// formatSubagentStatusSnapshot(纯函数测试)
|
|
47
|
+
// ============================================================
|
|
48
|
+
|
|
49
|
+
describe("formatSubagentStatusSnapshot", () => {
|
|
50
|
+
// TC-1: 有活跃 subagent 时返回非空快照
|
|
51
|
+
it("TC-1: 有活跃 subagent 时返回含 customType 消息内容", () => {
|
|
52
|
+
const records = [makeRecord({ id: "sa-001", slug: "fix-login", status: "running" })];
|
|
53
|
+
const result = formatSubagentStatusSnapshot(records);
|
|
54
|
+
expect(result).toContain("[subagent-status] 1 active subagent:");
|
|
55
|
+
expect(result).toContain("sa-001");
|
|
56
|
+
expect(result).toContain("fix-login");
|
|
57
|
+
expect(result).toContain("running");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// TC-2: 无活跃 subagent 时返回空列表 → 调用方不调用本函数(返回 undefined)
|
|
61
|
+
// 本测试验证空数组格式化结果的正确性(虽然 hook 层不会传入空数组)
|
|
62
|
+
it("TC-2: 空数组格式化为 0 active subagents", () => {
|
|
63
|
+
const result = formatSubagentStatusSnapshot([]);
|
|
64
|
+
expect(result).toBe("[subagent-status] 0 active subagents:");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// TC-3: 超过 10 条截断显示 '+N more'
|
|
68
|
+
it("TC-3: 超过 10 条截断显示 +N more", () => {
|
|
69
|
+
const records = Array.from({ length: 13 }, (_, i) =>
|
|
70
|
+
makeRecord({ id: `sa-${String(i).padStart(3, "0")}`, slug: `task-${i}`, status: "running" }),
|
|
71
|
+
);
|
|
72
|
+
const result = formatSubagentStatusSnapshot(records);
|
|
73
|
+
// 应显示前 10 条
|
|
74
|
+
expect(result).toContain("sa-000");
|
|
75
|
+
expect(result).toContain("sa-009");
|
|
76
|
+
// 不应显示第 11 条
|
|
77
|
+
expect(result).not.toContain("sa-010");
|
|
78
|
+
// 截断提示
|
|
79
|
+
expect(result).toContain("+3 more, use action:'list'");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// TC-4: 快照内容格式正确(含 id、slug、status、rounds)
|
|
83
|
+
it("TC-4: 快照格式正确——id/slug/status/rounds", () => {
|
|
84
|
+
const records = [
|
|
85
|
+
makeRecord({ id: "sa-aaa", slug: "deploy-app", status: "running", round: 0 }),
|
|
86
|
+
makeRecord({ id: "sa-bbb", slug: "run-tests", status: "idle", round: 3 }),
|
|
87
|
+
];
|
|
88
|
+
const result = formatSubagentStatusSnapshot(records);
|
|
89
|
+
const lines = result.split("\n");
|
|
90
|
+
|
|
91
|
+
// 第一行:标题
|
|
92
|
+
expect(lines[0]).toBe("[subagent-status] 2 active subagents:");
|
|
93
|
+
|
|
94
|
+
// running record:round 0 不显示 rounds
|
|
95
|
+
expect(lines[1]).toBe("- sa-aaa (deploy-app): running");
|
|
96
|
+
|
|
97
|
+
// idle record:round 3 显示 rounds
|
|
98
|
+
expect(lines[2]).toBe("- sa-bbb (run-tests): idle, rounds 3");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// 补充:slug 为空时 fallback 到 agent 名
|
|
102
|
+
it("slug 为空时 fallback 到 agent 名", () => {
|
|
103
|
+
const records = [makeRecord({ id: "sa-x", slug: "", agent: "coder" })];
|
|
104
|
+
const result = formatSubagentStatusSnapshot(records);
|
|
105
|
+
expect(result).toContain("(coder)");
|
|
106
|
+
expect(result).not.toContain("()");
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// ============================================================
|
|
111
|
+
// hook 逻辑集成测试(mock getSubagentService)
|
|
112
|
+
// ============================================================
|
|
113
|
+
|
|
114
|
+
describe("before_agent_start hook logic", () => {
|
|
115
|
+
// 动态导入以拿到真实 hook 注册后的状态。
|
|
116
|
+
// 由于 hook 注册在 index.ts 默认导出函数内,直接测 hook 回调逻辑
|
|
117
|
+
// 需要 mock getSubagentService。这里测 formatSubagentStatusSnapshot 的
|
|
118
|
+
// 集成行为(records → message 结构)来覆盖 hook 逻辑。
|
|
119
|
+
|
|
120
|
+
it("hook 消息结构符合 BeforeAgentStartEventResult.message 签名", () => {
|
|
121
|
+
const records = [makeRecord({ status: "running" })];
|
|
122
|
+
const content = formatSubagentStatusSnapshot(records);
|
|
123
|
+
|
|
124
|
+
// 模拟 hook 返回值结构
|
|
125
|
+
const result = { message: { customType: "subagent-status", content, display: true } };
|
|
126
|
+
|
|
127
|
+
expect(result.message.customType).toBe("subagent-status");
|
|
128
|
+
expect(result.message.display).toBe(true);
|
|
129
|
+
expect(result.message.content).toContain("[subagent-status]");
|
|
130
|
+
expect(result.message.content).toContain("sa-abc123");
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -40,7 +40,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
40
40
|
it("单条 done → 施加 customMessageBg 背景 + 边框 + 内容可见", () => {
|
|
41
41
|
const { theme, bgColors } = makeTheme();
|
|
42
42
|
const comp = renderBgNotifyMessage(
|
|
43
|
-
{ details: { status: "
|
|
43
|
+
{ details: { status: "closed", agent: "worker", id: "bg-1", result: "All green" } },
|
|
44
44
|
{ expanded: false },
|
|
45
45
|
theme,
|
|
46
46
|
);
|
|
@@ -66,7 +66,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
66
66
|
it("id 用 shortId 截断(bg-tag-seq-ts → bg-tag-seq)", () => {
|
|
67
67
|
const { theme } = makeTheme();
|
|
68
68
|
const comp = renderBgNotifyMessage(
|
|
69
|
-
{ details: { status: "
|
|
69
|
+
{ details: { status: "closed", agent: "w", id: "bg-f6f731-10-1719500000000", result: "ok" } },
|
|
70
70
|
{ expanded: false },
|
|
71
71
|
theme,
|
|
72
72
|
);
|
|
@@ -80,7 +80,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
80
80
|
it("单条 failed → 内容含 Error + agent", () => {
|
|
81
81
|
const { theme } = makeTheme();
|
|
82
82
|
const comp = renderBgNotifyMessage(
|
|
83
|
-
{ details: { status: "
|
|
83
|
+
{ details: { status: "closed", agent: "scout", id: "bg-2", error: "boom" } },
|
|
84
84
|
{ expanded: false },
|
|
85
85
|
theme,
|
|
86
86
|
);
|
|
@@ -98,8 +98,8 @@ describe("renderBgNotifyMessage", () => {
|
|
|
98
98
|
details: {
|
|
99
99
|
batch: true,
|
|
100
100
|
items: [
|
|
101
|
-
{ status: "
|
|
102
|
-
{ status: "
|
|
101
|
+
{ status: "closed", agent: "alpha", id: "1", result: "r1" },
|
|
102
|
+
{ status: "closed", agent: "beta", id: "2", error: "e2" },
|
|
103
103
|
],
|
|
104
104
|
},
|
|
105
105
|
},
|
|
@@ -117,10 +117,10 @@ describe("renderBgNotifyMessage", () => {
|
|
|
117
117
|
expect(lines[lines.length - 1]).toContain("╰");
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
it("cancelled → 内容含 cancelled", () => {
|
|
120
|
+
it("closed + closedReason=cancelled → 内容含 cancelled(v4 B-1 cancelled 折入 closed)", () => {
|
|
121
121
|
const { theme } = makeTheme();
|
|
122
122
|
const comp = renderBgNotifyMessage(
|
|
123
|
-
{ details: { status: "cancelled", agent: "w", id: "bg-3" } },
|
|
123
|
+
{ details: { status: "closed", closedReason: "cancelled", agent: "w", id: "bg-3" } },
|
|
124
124
|
{ expanded: false },
|
|
125
125
|
theme,
|
|
126
126
|
);
|
|
@@ -137,7 +137,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
137
137
|
renderBgNotifyMessage({ details: { id: "x", agent: "w" } }, { expanded: false }, theme),
|
|
138
138
|
).toBeUndefined();
|
|
139
139
|
expect(
|
|
140
|
-
renderBgNotifyMessage({ details: { status: "
|
|
140
|
+
renderBgNotifyMessage({ details: { status: "closed", id: "x" } }, { expanded: false }, theme),
|
|
141
141
|
).toBeUndefined();
|
|
142
142
|
});
|
|
143
143
|
|
|
@@ -152,7 +152,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
152
152
|
it("record 带 model → 内容含 model 字符串(agent 后、状态描述前)", () => {
|
|
153
153
|
const { theme } = makeTheme();
|
|
154
154
|
const comp = renderBgNotifyMessage(
|
|
155
|
-
{ details: { status: "
|
|
155
|
+
{ details: { status: "closed", agent: "general-purpose", model: "anthropic/sonnet-4-5", id: "bg-1", result: "ok" } },
|
|
156
156
|
{ expanded: false },
|
|
157
157
|
theme,
|
|
158
158
|
);
|
|
@@ -166,7 +166,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
166
166
|
it("record 无 model → 向后兼容,不渲染 model 段不崩", () => {
|
|
167
167
|
const { theme } = makeTheme();
|
|
168
168
|
const comp = renderBgNotifyMessage(
|
|
169
|
-
{ details: { status: "
|
|
169
|
+
{ details: { status: "closed", agent: "worker", id: "bg-2", result: "r" } },
|
|
170
170
|
{ expanded: false },
|
|
171
171
|
theme,
|
|
172
172
|
);
|
|
@@ -188,7 +188,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
188
188
|
// head 行含 ANSI(fg 包裹),截断时 activeStyles 非空 → 会产生 \x1b[0m
|
|
189
189
|
const longAgent = "a".repeat(60);
|
|
190
190
|
const comp = renderBgNotifyMessage(
|
|
191
|
-
{ details: { status: "
|
|
191
|
+
{ details: { status: "closed", agent: longAgent, id: "bg-1", result: "ok" } },
|
|
192
192
|
{ expanded: false },
|
|
193
193
|
theme,
|
|
194
194
|
);
|
|
@@ -210,7 +210,7 @@ describe("renderBgNotifyMessage", () => {
|
|
|
210
210
|
it("极窄宽度(width < 5)退化:无边框,不崩溃,有背景", () => {
|
|
211
211
|
const { theme, bgColors } = makeTheme();
|
|
212
212
|
const comp = renderBgNotifyMessage(
|
|
213
|
-
{ details: { status: "
|
|
213
|
+
{ details: { status: "closed", agent: "w", id: "bg-1", result: "ok" } },
|
|
214
214
|
{ expanded: false },
|
|
215
215
|
theme,
|
|
216
216
|
);
|
|
@@ -233,9 +233,9 @@ describe("renderBgNotifyMessage", () => {
|
|
|
233
233
|
details: {
|
|
234
234
|
batch: true,
|
|
235
235
|
items: [
|
|
236
|
-
{ status: "
|
|
237
|
-
{ status: "
|
|
238
|
-
{ status: "cancelled", agent: "gamma", id: "3" },
|
|
236
|
+
{ status: "closed", agent: "alpha", id: "1", result: "r1" },
|
|
237
|
+
{ status: "closed", agent: "beta", id: "2", error: "e2" },
|
|
238
|
+
{ status: "closed", closedReason: "cancelled", agent: "gamma", id: "3" },
|
|
239
239
|
],
|
|
240
240
|
},
|
|
241
241
|
},
|