@zhushanwen/subagent-core 0.4.0 → 0.5.1
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/dist/{chunk-4KN4TTG7.js → chunk-43ONBFZX.js} +1 -1
- package/dist/{chunk-X7SZ5HLQ.js → chunk-V3VHZ2VX.js} +20 -27
- package/dist/execution/engine/engines/zcode/constants.cjs +29 -41
- package/dist/execution/engine/engines/zcode/constants.d.cts +65 -53
- package/dist/execution/engine/engines/zcode/constants.d.ts +65 -53
- package/dist/execution/engine/engines/zcode/constants.js +17 -27
- package/dist/execution/engine/engines/zcode/reader.d.cts +2 -1
- package/dist/execution/engine/engines/zcode/reader.d.ts +2 -1
- package/dist/execution/engine/engines/zcode/reader.js +2 -2
- package/dist/index.cjs +16418 -14070
- package/dist/index.d.cts +5136 -4016
- package/dist/index.d.ts +5136 -4016
- package/dist/index.js +16343 -14048
- package/dist/{types-DpUO16pj.d.cts → types-Dv4QhSJ_.d.cts} +215 -112
- package/dist/{types-DpUO16pj.d.ts → types-Dv4QhSJ_.d.ts} +215 -112
- package/package.json +3 -3
- package/src/__tests__/agent-opts-resolver-schema-prompt.test.ts +0 -1
- package/src/__tests__/append-system-prompt-assembly.test.ts +8 -7
- package/src/__tests__/fr4-get-state-handshake.test.ts +2 -2
- package/src/__tests__/m2-append-content-probe.test.ts +0 -1
- package/src/__tests__/manifest-store.test.ts +10 -9
- package/src/__tests__/record-store-cache.test.ts +0 -2
- package/src/__tests__/record-store-index.test.ts +1 -2
- package/src/__tests__/review-fix-loop-script.test.ts +4 -2
- package/src/__tests__/review-fix-loop-utils.test.ts +10 -10
- package/src/__tests__/robustness-low-batch1.test.ts +6 -5
- package/src/__tests__/robustness-medium-batch1.test.ts +2 -2
- package/src/__tests__/robustness-medium-batch2.test.ts +17 -6
- package/src/__tests__/robustness-medium-batch4.test.ts +2 -2
- package/src/__tests__/session-runner.test.ts +1 -1
- package/src/core/__tests__/host-services.test.ts +2 -2
- package/src/core/__tests__/logger.test.ts +1 -1
- package/src/core/error-message.ts +9 -0
- package/src/core/host-services.ts +21 -5
- package/src/core/notify-ports.ts +18 -5
- package/src/execution/__tests__/agent-profile.test.ts +4 -4
- package/src/execution/__tests__/agent-registry.test.ts +370 -0
- package/src/execution/__tests__/agent-result-mapper.test.ts +18 -2
- package/src/execution/__tests__/agents-assembly.test.ts +2 -2
- package/src/execution/__tests__/ask-user-transit-e2e.test.ts +6 -6
- package/src/execution/__tests__/chat-engine-routing.test.ts +68 -33
- package/src/execution/__tests__/chatmode-first-round-closure-spawn.test.ts +4 -4
- package/src/execution/__tests__/cold-resurrect.test.ts +283 -0
- package/src/execution/__tests__/delivery-methods.test.ts +75 -62
- package/src/execution/__tests__/descendant-sweep-guards.test.ts +220 -0
- package/src/execution/__tests__/descendant-sweep.test.ts +6 -6
- package/src/execution/__tests__/dialog-queue.test.ts +2 -2
- package/src/execution/__tests__/engine-model-validation.test.ts +741 -0
- package/src/execution/__tests__/epipe-fallback.test.ts +29 -24
- package/src/execution/__tests__/execute-and-await-worktree.test.ts +21 -91
- package/src/execution/__tests__/execute-nesting.test.ts +34 -188
- package/src/execution/__tests__/execution-record.test.ts +217 -60
- package/src/execution/__tests__/execution-runtime-face.test.ts +5 -5
- package/src/execution/__tests__/explicit-agent-ref-guard.test.ts +3 -3
- package/src/execution/__tests__/finalize-record.test.ts +173 -17
- package/src/execution/__tests__/gc-timer.test.ts +55 -2
- package/src/execution/__tests__/get-record-for-action-restart.test.ts +12 -12
- package/src/execution/__tests__/get-state-handshake.test.ts +1 -1
- package/src/execution/__tests__/helpers/mock-extension-api.ts +1 -1
- package/src/execution/__tests__/helpers/session-runner-mocks.ts +113 -0
- package/src/execution/__tests__/helpers/spawn-mock.ts +150 -3
- package/src/execution/__tests__/helpers/subagent-service-mocks.ts +137 -0
- package/src/execution/__tests__/keep-alive-no-progress.test.ts +50 -148
- package/src/execution/__tests__/kill-all-escalation.test.ts +2 -2
- package/src/execution/__tests__/lifecycle-predicates.test.ts +1 -2
- package/src/execution/__tests__/manifest-parentid.test.ts +4 -4
- package/src/execution/__tests__/max-turns-to-watchdog-ms.test.ts +1 -1
- package/src/execution/__tests__/model-resolver.test.ts +2 -2
- package/src/execution/__tests__/nested-visibility-env-propagation.test.ts +23 -121
- package/src/execution/__tests__/nested-visibility.test.ts +2 -0
- package/src/execution/__tests__/notify-ledger.test.ts +973 -18
- package/src/execution/__tests__/output-collector.test.ts +117 -6
- package/src/execution/__tests__/pi-invocation.test.ts +1 -1
- package/src/execution/__tests__/record-store.test.ts +10 -9
- package/src/execution/__tests__/records-cwd-isolation.test.ts +2 -2
- package/src/execution/__tests__/recursive-visibility-baseline.test.ts +29 -132
- package/src/execution/__tests__/recursive-visibility-env.test.ts +55 -179
- package/src/execution/__tests__/rpc-mode.test.ts +2 -2
- package/src/execution/__tests__/run-and-finalize-anchoring.test.ts +387 -0
- package/src/execution/__tests__/run-and-finalize-chatmode.test.ts +15 -9
- package/src/execution/__tests__/run-spawn-chatmode-settled.test.ts +4 -4
- package/src/execution/__tests__/run-spawn-edges.test.ts +17 -15
- package/src/execution/__tests__/run-spawn-integration.test.ts +2 -2
- package/src/execution/__tests__/run-spawn-resume.test.ts +2 -2
- package/src/execution/__tests__/run-spawn-rpc-mode.test.ts +2 -2
- package/src/execution/__tests__/run-spawn-stdout-callback-throw.test.ts +4 -4
- package/src/execution/__tests__/service-kill-escalation.test.ts +7 -5
- package/src/execution/__tests__/session-context-resolver.test.ts +0 -2
- package/src/execution/__tests__/session-file-gc.test.ts +35 -0
- package/src/execution/__tests__/session-pending.test.ts +257 -14
- package/src/execution/__tests__/session-reconstructor.test.ts +366 -15
- package/src/execution/__tests__/session-runner-branch-cache-lru.test.ts +1 -1
- package/src/execution/__tests__/session-runner-close-prune.test.ts +2 -2
- package/src/execution/__tests__/session-runner-dispatch.test.ts +489 -0
- package/src/execution/__tests__/session-runner-epipe.test.ts +3 -3
- package/src/execution/__tests__/session-runner-heartbeat-idle-fallback.test.ts +5 -4
- package/src/execution/__tests__/session-runner-lifecycle-helpers.test.ts +290 -0
- package/src/execution/__tests__/session-runner-schema-env.test.ts +7 -5
- package/src/execution/__tests__/settled-watchdog.test.ts +282 -47
- package/src/execution/__tests__/spawn-args.test.ts +11 -10
- package/src/execution/__tests__/spawn-event-adapter-rpc.test.ts +26 -23
- package/src/execution/__tests__/spawn-event-adapter.test.ts +1 -1
- package/src/execution/__tests__/spawn-worktree-guidance.test.ts +5 -4
- package/src/execution/__tests__/spawned-children.test.ts +2 -1
- package/src/execution/__tests__/start-sync-model-guard.test.ts +4 -4
- package/src/execution/__tests__/stdin-writer.test.ts +6 -4
- package/src/execution/__tests__/stream-sink-retirement.test.ts +6 -6
- package/src/execution/__tests__/subagent-actions-core.test.ts +42 -22
- package/src/execution/__tests__/subagent-service-message-close.test.ts +29 -26
- package/src/execution/__tests__/subagent-service-multiproc-guard.test.ts +8 -8
- package/src/execution/__tests__/subagent-service-notify-gate.test.ts +27 -22
- package/src/execution/__tests__/subagent-service-parent-guard.test.ts +30 -29
- package/src/execution/__tests__/subagent-service-recovery-bounds.test.ts +45 -20
- package/src/execution/__tests__/subagent-service.test.ts +37 -30
- package/src/execution/__tests__/subprocess-agent-runner-routing.test.ts +88 -12
- package/src/execution/__tests__/subprocess-agent-runner-timeout.test.ts +75 -0
- package/src/execution/__tests__/subprocess-agent-runner.test.ts +22 -20
- package/src/execution/__tests__/temp-prompt.test.ts +1 -1
- package/src/execution/__tests__/timeout-integration.test.ts +6 -5
- package/src/execution/__tests__/turn-limiter-semantics.test.ts +1 -1
- package/src/execution/__tests__/turn-limiter.test.ts +1 -1
- package/src/execution/__tests__/ui-request-handler-factory.test.ts +12 -6
- package/src/execution/__tests__/ui-request-handler.test.ts +4 -3
- package/src/execution/__tests__/ui-request-queue.test.ts +142 -2
- package/src/execution/__tests__/worktree-manager.test.ts +14 -5
- package/src/execution/__tests__/worktree-pid-registration.integration.test.ts +4 -3
- package/src/execution/agent-registry.ts +74 -30
- package/src/execution/agent-result-mapper.ts +3 -0
- package/src/execution/cold-resurrect.ts +199 -0
- package/src/execution/engine/__tests__/common/capability-gate.test.ts +91 -0
- package/src/execution/engine/__tests__/common/data-dir.test.ts +1 -1
- package/src/execution/engine/__tests__/common/journal-wiring.test.ts +84 -0
- package/src/execution/engine/__tests__/common/kill-chain.test.ts +34 -7
- package/src/execution/engine/__tests__/common/persona-router.test.ts +4 -5
- package/src/execution/engine/__tests__/common/pool-manager.test.ts +211 -51
- package/src/execution/engine/__tests__/common/session-view-service-zcode-dbpath.test.ts +149 -0
- package/src/execution/engine/__tests__/common/session-view-service.test.ts +499 -0
- package/src/execution/engine/__tests__/conformance/contract.abort.test.ts +22 -112
- package/src/execution/engine/__tests__/conformance/contract.agent-events.test.ts +15 -28
- package/src/execution/engine/__tests__/conformance/engine-conformance.live.test.ts +12 -12
- package/src/execution/engine/__tests__/conformance/golden-replay.pi.test.ts +1 -1
- package/src/execution/engine/__tests__/conformance/golden-replay.zcode.test.ts +21 -82
- package/src/execution/engine/__tests__/conformance/zcode-appserver-harness.ts +4 -7
- package/src/execution/engine/__tests__/engine-discovery.test.ts +15 -3
- package/src/execution/engine/__tests__/model-prompt.test.ts +15 -3
- package/src/execution/engine/__tests__/registry.test.ts +4 -2
- package/src/execution/engine/__tests__/routing.test.ts +115 -6
- package/src/execution/engine/common/capability-gate.ts +92 -0
- package/src/execution/engine/common/journal-wiring.ts +97 -0
- package/src/execution/engine/common/kill-chain.ts +42 -10
- package/src/execution/engine/common/nesting-guard.ts +66 -0
- package/src/execution/engine/common/persona-router.ts +18 -8
- package/src/execution/engine/common/pool-manager.ts +332 -78
- package/src/execution/engine/common/session-view-service.ts +506 -0
- package/src/execution/engine/common/session-view-types.ts +125 -0
- package/src/execution/engine/engines/pi/__tests__/pi-engine.test.ts +174 -28
- package/src/execution/engine/engines/pi/__tests__/spawn-opts-direct.test.ts +257 -0
- package/src/execution/{argv-mirror.ts → engine/engines/pi/argv-mirror.ts} +43 -21
- package/src/execution/{get-state-handshake.ts → engine/engines/pi/get-state-handshake.ts} +1 -1
- package/src/execution/{output-collector.ts → engine/engines/pi/output-collector.ts} +108 -19
- package/src/execution/engine/engines/pi/pi-engine.ts +434 -38
- package/src/execution/{pi-invocation.ts → engine/engines/pi/pi-invocation.ts} +2 -2
- package/src/execution/engine/engines/pi/reader.ts +11 -0
- package/src/execution/engine/engines/pi/registration.ts +4 -2
- package/src/execution/{session-runner.ts → engine/engines/pi/session-runner.ts} +617 -412
- package/src/execution/{spawn-event-adapter.ts → engine/engines/pi/spawn-event-adapter.ts} +75 -34
- package/src/execution/{stdin-writer.ts → engine/engines/pi/stdin-writer.ts} +10 -9
- package/src/execution/{temp-prompt.ts → engine/engines/pi/temp-prompt.ts} +2 -2
- package/src/execution/{turn-limiter.ts → engine/engines/pi/turn-limiter.ts} +1 -1
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/fake-appserver.mjs +54 -27
- package/src/execution/engine/engines/zcode/__tests__/appserver-launcher.test.ts +321 -0
- package/src/execution/engine/engines/zcode/__tests__/connection.test.ts +13 -12
- package/src/execution/engine/engines/zcode/__tests__/parser.test.ts +7 -210
- package/src/execution/engine/engines/zcode/__tests__/preparer.test.ts +6 -110
- package/src/execution/engine/engines/zcode/__tests__/session-channel-dispose-harvest.test.ts +247 -0
- package/src/execution/engine/engines/zcode/__tests__/session-channel-turn-timers.test.ts +451 -0
- package/src/execution/engine/engines/zcode/__tests__/session-channel.test.ts +20 -8
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-appserver.test.ts +77 -110
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-degrade.test.ts +25 -319
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-dispose.test.ts +210 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-retry.test.ts +353 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-status.test.ts +282 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-timeout.test.ts +372 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine.live.test.ts +48 -148
- package/src/execution/engine/engines/zcode/appserver-launcher.ts +167 -0
- package/src/execution/engine/engines/zcode/connection.ts +24 -11
- package/src/execution/engine/engines/zcode/constants.ts +75 -71
- package/src/execution/engine/engines/zcode/golden-sample.ts +8 -46
- package/src/execution/engine/engines/zcode/parser.ts +12 -346
- package/src/execution/engine/engines/zcode/preparer.ts +12 -143
- package/src/execution/engine/engines/zcode/session-channel.ts +351 -39
- package/src/execution/engine/engines/zcode/zcode-engine.ts +665 -760
- package/src/execution/engine/host-task-spec.ts +32 -36
- package/src/execution/engine/model-validation.ts +177 -0
- package/src/execution/engine/port.ts +24 -6
- package/src/execution/engine/routing.ts +75 -1
- package/src/execution/engine/types.ts +30 -103
- package/src/execution/execution-record.ts +222 -144
- package/src/execution/finalize-record.ts +131 -93
- package/src/execution/idle-gc.ts +28 -0
- package/src/execution/lifecycle-predicates.ts +1 -1
- package/src/execution/notify-host.ts +212 -0
- package/src/execution/record-store.ts +119 -73
- package/src/execution/round-settlement.ts +93 -0
- package/src/execution/session-file-gc.ts +96 -62
- package/src/execution/session-reconstructor.ts +256 -143
- package/src/execution/sessions-index.ts +117 -47
- package/src/execution/settled-watchdog.ts +264 -52
- package/src/execution/subagent-actions-core.ts +22 -22
- package/src/execution/subagent-service.ts +815 -963
- package/src/execution/subprocess-agent-runner.ts +144 -97
- package/src/execution/types.ts +9 -0
- package/src/execution/ui-request-handler-factory.ts +102 -74
- package/src/execution/ui-request-queue.ts +50 -19
- package/src/index.ts +442 -316
- package/src/orchestration/__tests__/agent-call-catch-fallback.test.ts +1 -1
- package/src/orchestration/__tests__/agent-call-stream.test.ts +2 -2
- package/src/orchestration/__tests__/args-validator.test.ts +14 -0
- package/src/orchestration/__tests__/error-recovery-rebuild-failure.test.ts +1 -1
- package/src/orchestration/__tests__/error-recovery-terminal-hardening.test.ts +11 -9
- package/src/orchestration/__tests__/execute-agent-call.test.ts +151 -11
- package/src/orchestration/__tests__/file-run-store.test.ts +7 -6
- package/src/orchestration/__tests__/launcher-nested-workflow.test.ts +2 -2
- package/src/orchestration/__tests__/lifecycle-abort-broadcast-signal.test.ts +1 -1
- package/src/orchestration/__tests__/lifecycle-runid-injection.test.ts +3 -3
- package/src/orchestration/__tests__/lifecycle.test.ts +7 -5
- package/src/orchestration/__tests__/non-cloneable-return-e2e.test.ts +1 -1
- package/src/orchestration/__tests__/run-snapshot.test.ts +8 -5
- package/src/orchestration/__tests__/script-lint.test.ts +17 -0
- package/src/orchestration/__tests__/test-mocks.ts +2 -0
- package/src/orchestration/__tests__/worker-exit-without-result.test.ts +7 -6
- package/src/orchestration/__tests__/worker-message-pump-finalize-run.test.ts +229 -0
- package/src/orchestration/__tests__/{error-recovery-handlers.test.ts → worker-message-pump-handlers.test.ts} +27 -19
- package/src/orchestration/__tests__/{error-recovery-postmessage-defense.test.ts → worker-message-pump-postmessage-defense.test.ts} +8 -8
- package/src/orchestration/__tests__/{error-recovery-serialize-failed-result.test.ts → worker-message-pump-serialize-failed-result.test.ts} +2 -2
- package/src/orchestration/__tests__/{error-recovery-workflow-call.test.ts → worker-message-pump-workflow-call.test.ts} +1 -1
- package/src/orchestration/__tests__/worker-pending-timeout-abort.test.ts +1 -1
- package/src/orchestration/__tests__/worker-script-builder.test.ts +1 -1
- package/src/orchestration/__tests__/workflow-nesting-e2e.test.ts +1 -1
- package/src/orchestration/agent-opts-resolver.ts +1 -1
- package/src/orchestration/args-validator.ts +53 -31
- package/src/orchestration/execute-agent-call.ts +19 -73
- package/src/orchestration/launcher.ts +128 -81
- package/src/orchestration/lifecycle.ts +43 -45
- package/src/orchestration/models/ports.ts +4 -4
- package/src/orchestration/models/run-runtime.ts +2 -2
- package/src/orchestration/models/trace.ts +1 -1
- package/src/orchestration/models/types.ts +111 -22
- package/src/orchestration/models/workflow-run.ts +1 -1
- package/src/orchestration/script-lint.ts +91 -58
- package/src/orchestration/{error-recovery.ts → worker-message-pump.ts} +157 -150
- package/src/shared/__tests__/meta-parser.test.ts +151 -0
- package/src/shared/__tests__/resource-discovery.test.ts +258 -215
- package/src/shared/atomic-write.ts +12 -9
- package/src/shared/meta-parser.ts +158 -84
- package/src/shared/model-ref.ts +15 -2
- package/src/shared/resource-discovery.ts +9 -183
- package/src/shared/schema-jsonify.ts +1 -1
- package/workflows/review-fix-loop-utils.cjs +151 -89
- package/workflows/review-fix-loop-utils.d.cts +287 -0
- package/src/execution/__tests__/execute-options-mapper.test.ts +0 -200
- package/src/execution/engine/engines/pi/__tests__/task-spec-mapper.test.ts +0 -164
- package/src/execution/engine/engines/pi/task-spec-mapper.ts +0 -100
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/zcode-golden-spawn.json +0 -39
- package/src/execution/engine/engines/zcode/__tests__/launcher.test.ts +0 -150
- package/src/execution/engine/engines/zcode/__tests__/preparer-appserver.test.ts +0 -387
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine.test.ts +0 -710
- package/src/execution/engine/engines/zcode/appserver-home.ts +0 -442
- package/src/execution/engine/engines/zcode/appserver-probe.ts +0 -141
- package/src/execution/engine/engines/zcode/launcher.ts +0 -161
- package/src/execution/execute-options-mapper.ts +0 -115
- package/src/shared/__tests__/resource-discovery-manifest-cache.test.ts +0 -288
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* 职责:封装一次 running-segment 的所有技术资源(worker 线程 +
|
|
8
8
|
* abort controller),统一 release 入口(AC-2:单 release 替代多 boolean flag)。
|
|
9
9
|
* (旧并发门闩 gate 抽象已删——no-op,实际并发由 SubagentService ConcurrencyPool 管理;
|
|
10
|
-
* 原 withSlot 的 pre-abort 检查内联到
|
|
10
|
+
* 原 withSlot 的 pre-abort 检查内联到 worker-message-pump dispatchAgentCall。)
|
|
11
11
|
*
|
|
12
12
|
* 一次性生命周期(G3-001):runtime 释放后不再复用——AbortController 一次性
|
|
13
13
|
* 语义决定 controller 无法跨释放复用,所以整个 RunRuntime 重建。唯一注入路径:
|
|
14
|
-
* assignRuntime(runWorkflow 创建)与 replaceRuntime(
|
|
14
|
+
* assignRuntime(runWorkflow 创建)与 replaceRuntime(worker-message-pump 崩溃重试)。
|
|
15
15
|
*
|
|
16
16
|
* 参考:domain-models.md §10、clarification.md G3-001。
|
|
17
17
|
*/
|
|
@@ -153,7 +153,7 @@ export class Trace {
|
|
|
153
153
|
/**
|
|
154
154
|
* 按 stepIndex 移除节点(崩溃重建清理在飞 call 用)。
|
|
155
155
|
*
|
|
156
|
-
* 正常运行不调用(append-only 不变式)。仅
|
|
156
|
+
* 正常运行不调用(append-only 不变式)。仅 worker-message-pump 的 discardInFlightCalls
|
|
157
157
|
* (rebuildRuntime 内,F2)清理被旧 runtime abort 的在飞 call 时用——移除其 trace
|
|
158
158
|
* 节点,让重跑重发 agent-call 时 append 全新节点走全新执行路径(避免 stale
|
|
159
159
|
* "running" 节点残留 + trace.update 命中旧节点导致新节点 orphan)。
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 层归属:Engine(数据结构 + 不变式守卫)。
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import type { ExecutionRecord } from "../../execution/types.ts";
|
|
16
|
+
import type { ExecutionRecord, WorktreeHandle } from "../../execution/types.ts";
|
|
17
17
|
|
|
18
18
|
// ── 状态机 ────────────────────────────────────────────────────
|
|
19
19
|
|
|
@@ -65,7 +65,37 @@ export function canRunTransition(from: RunStatus, to: RunStatus): boolean {
|
|
|
65
65
|
// ── Agent 调用 ────────────────────────────────────────────────
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* slug 最大长度(D6 合流迁入本文件,原权威定义在已删除的 execution/execute-options-mapper.ts)。
|
|
69
|
+
* 历史值 20 偏紧——描述性 slug 如 "audit-structured-output"(23)/ "fix-subagent-wf-tools"(21)
|
|
70
|
+
* 会撞上限,放宽到 35 兼顾「短到能塞进 TUI 标题行」与「容纳合理描述性 kebab-case 名」。
|
|
71
|
+
* 放本文件的原因:约束对象是 AgentCallOpts.description(slug 的源字段,见下方 slug 派生说明),
|
|
72
|
+
* 与字段同文件;worker-message-pump(live record slug 截断)与壳侧 tool schema maxLength 共享引用。
|
|
73
|
+
*/
|
|
74
|
+
export const SLUG_MAX_LENGTH = 35;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 单次 agent 调用的任务声明(D6 任务形状合流后的单一形状)。
|
|
78
|
+
*
|
|
79
|
+
* [D6 合流裁决] 本类型 = 原 AgentCallOpts(workflow 调用方声明,18 字段)与原
|
|
80
|
+
* AgentTaskSpec(engine 中立任务声明,已删除)的合流形态,从模型脚本 agent() API
|
|
81
|
+
* 到 EnginePort.run 直达 pi 边界一次映射——SAR 链路上的 ExecuteOptions/AgentTaskSpec
|
|
82
|
+
* 中间态消除(设计 docs/design/subagent-dual-track-convergence.md §3.3 D6 / 终态四)。
|
|
83
|
+
*
|
|
84
|
+
* 终态命名按变化轴裁定为 AgentCallOpts,理由:
|
|
85
|
+
* - 字段演进的首要驱动轴是「调用方要表达的任务语义」(agent() API 是唯一生产写入方,
|
|
86
|
+
* 合流字段中 prompt/description/skill/skillPath/schemaEnv/thinkingLevel 等多数派
|
|
87
|
+
* 已是调用方命名);
|
|
88
|
+
* - 原 AgentTaskSpec 的中立重命名层(task/slug/effort/persona)与调用方命名是
|
|
89
|
+
* 形式同构、语义同构的假差异(prompt≡task、slug=description 截断、effort≡thinkingLevel、
|
|
90
|
+
* persona≡skillPath+appendSystemPrompt 平铺),按「消假差异」原则并入调用方命名;
|
|
91
|
+
* - 持久化兼容反向锁定 prompt 形态:jsonl run 快照的 AgentCall.opts 与 worker 消息
|
|
92
|
+
* opts 均以 prompt 字段落盘,改名会破坏旧快照重水合。
|
|
93
|
+
*
|
|
94
|
+
* 引擎中立字段的并入方式(可选字段,原 AgentTaskSpec 独有字段去向):
|
|
95
|
+
* - graceTurns / conversation / idleTimeoutMs / denyTools / permissionMode:可选并入;
|
|
96
|
+
* - persona.agentRef:裁撤(无生产写入方、无消费者——pi 走 agent 字段解析身份);
|
|
97
|
+
* - requires:裁撤(P4 形状预留、无生产写入方;且并入需 import EngineCapabilities
|
|
98
|
+
* 形成 orchestration↔engine 类型环)。将来能力依赖声明下钻时在本形状上加回。
|
|
69
99
|
*
|
|
70
100
|
* D-12 仅重组执行编排,AgentCallOpts 形状保持兼容。
|
|
71
101
|
*/
|
|
@@ -101,14 +131,20 @@ export interface AgentCallOpts {
|
|
|
101
131
|
*/
|
|
102
132
|
timeoutMs?: number;
|
|
103
133
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
* Turn 上限(turn limiter 用)。
|
|
135
|
+
*
|
|
136
|
+
* [预算语义对齐] 未传或 <=0 = 不限 turn;此时也不按 turns 估算 spawn watchdog——
|
|
137
|
+
* 仅当 env XYZ_SUBAGENT_SPAWN_WATCHDOG_MS 设置时才按绝对时限挂 watchdog(见
|
|
138
|
+
* session-runner.resolveSpawnWatchdogMs)。pi 边界直出为 ExecuteOptions.maxTurns
|
|
139
|
+
* → runSpawn(D6 合流后无中间映射层)。
|
|
140
|
+
*/
|
|
111
141
|
maxTurns?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Turn limiter 的宽限轮数(原 AgentTaskSpec.graceTurns 并入):超 maxTurns 后
|
|
144
|
+
* 允许继续的轮数(等待在途工具收尾)。pi 引擎消费;workflow agent() 无写入方,
|
|
145
|
+
* chat 域(ExecuteOptions.graceTurns 同名透传)经 host-task-spec 填充。
|
|
146
|
+
*/
|
|
147
|
+
graceTurns?: number;
|
|
112
148
|
/**
|
|
113
149
|
* Skill name to load (e.g. "code-review"). Resolved to SKILL.md path
|
|
114
150
|
* and injected via --skill flag in the subprocess.
|
|
@@ -129,18 +165,18 @@ export interface AgentCallOpts {
|
|
|
129
165
|
*/
|
|
130
166
|
agent?: string;
|
|
131
167
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*/
|
|
168
|
+
* System prompt injection CONTENT (not file paths).
|
|
169
|
+
* Set by agent-opts-resolver: schema structured-output instruction string.
|
|
170
|
+
* Agent systemPrompt is NOT included here (handled by resolveIdentity/agentConfig).
|
|
171
|
+
* pi 边界直出为 ExecuteOptions.appendSystemPrompt(同名同义透传,D6 合流后无中间映射层)。
|
|
172
|
+
*/
|
|
138
173
|
appendSystemPrompt?: string[];
|
|
139
174
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
175
|
+
* Schema JSON for PI_WORKFLOW_SCHEMA env var.
|
|
176
|
+
* Set by agent-opts-resolver when opts.schema is present (值 = stringifySchemaCached
|
|
177
|
+
* compact,与 schema 派生等值); passed as env var to activate the structured-output
|
|
178
|
+
* tool + hook. pi 边界直出时 schema 派生优先、本字段兜底(解耦形态通道,生产不可达)。
|
|
179
|
+
*/
|
|
144
180
|
schemaEnv?: string;
|
|
145
181
|
/**
|
|
146
182
|
* Per-call 工作目录(ADR-029 决策 1)。传给 child_process.spawn 的 cwd option。
|
|
@@ -159,11 +195,36 @@ export interface AgentCallOpts {
|
|
|
159
195
|
* agent() → execute-agent-call → SAR 路由层。
|
|
160
196
|
*/
|
|
161
197
|
engine?: string;
|
|
162
|
-
/** Filesystem isolation: when true, creates a new git worktree for the agent. Independent of fork.
|
|
163
|
-
|
|
198
|
+
/** Filesystem isolation: when true, creates a new git worktree for the agent. Independent of fork.
|
|
199
|
+
* [D6 合流] 类型扩展为 boolean | WorktreeHandle(原 AgentTaskSpec.worktree 的超集)——
|
|
200
|
+
* WorktreeHandle 形态仅在 chat 域(复用外部已创建的 worktree)出现,workflow agent()
|
|
201
|
+
* 恒传 boolean。 */
|
|
202
|
+
worktree?: boolean | WorktreeHandle;
|
|
164
203
|
/** When true, agent() resolves {value, sessionFile, worktreePath, error} instead of a bare value.
|
|
165
|
-
* Worker-layer flag only — not
|
|
204
|
+
* Worker-layer flag only — not consumed by any engine (dropped at the pi boundary). */
|
|
166
205
|
returnMeta?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* 可持续对话模式(原 AgentTaskSpec.conversation 并入):true = record 标记 chatMode,
|
|
208
|
+
* 轮次完成进 idle 态等待 message 续聊。chat 域(ExecuteOptions.conversation 同名)经
|
|
209
|
+
* host-task-spec 填充;workflow agent() 无写入方。
|
|
210
|
+
*/
|
|
211
|
+
conversation?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* 空闲超时毫秒数(原 AgentTaskSpec.idleTimeoutMs 并入,仅 conversation 模式有意义)。
|
|
214
|
+
* 优先级:参数 > env XYZ_SUBAGENT_IDLE_TIMEOUT_MS > 默认 300000ms;显式 0/负 = 禁用
|
|
215
|
+
* idle GC。chat 域经 host-task-spec 填充。
|
|
216
|
+
*/
|
|
217
|
+
idleTimeoutMs?: number;
|
|
218
|
+
/**
|
|
219
|
+
* 工具 denylist(原 AgentTaskSpec.denyTools 并入,中立新增面):各引擎做语法映射
|
|
220
|
+
* (zcode buildZcodeArgv 消费;pi 链路暂无对应面)。无 workflow 写入方,预留形状。
|
|
221
|
+
*/
|
|
222
|
+
denyTools?: string[];
|
|
223
|
+
/**
|
|
224
|
+
* 中立权限模式(原 AgentTaskSpec.permissionMode 并入,预留形状):映射按各引擎
|
|
225
|
+
* capabilities.permissionMode。无生产写入方/消费者。
|
|
226
|
+
*/
|
|
227
|
+
permissionMode?: string;
|
|
167
228
|
}
|
|
168
229
|
|
|
169
230
|
/**
|
|
@@ -189,6 +250,24 @@ export interface ToolCallEntry {
|
|
|
189
250
|
input: string;
|
|
190
251
|
}
|
|
191
252
|
|
|
253
|
+
/**
|
|
254
|
+
* 失败分诊结构化标签(D5-③,r1 MF4 钉正语义)。
|
|
255
|
+
*
|
|
256
|
+
* - stale_context:pi session context 被 compact/cancel/替换——重试无意义(同 call
|
|
257
|
+
* 再次失败),不重试。
|
|
258
|
+
* - schema_deterministic:确定性 schema 失败(SO tool 从未调用 / gate 终止 /
|
|
259
|
+
* 不可满足 schema)——同 schema 重试必同结果,不重试。
|
|
260
|
+
* - unknown:其余一切失败(瞬态 provider 错误、spawn 失败等)——**默认可重试**。
|
|
261
|
+
*
|
|
262
|
+
* **语义守恒(最高优先约束)**:unknown(含字段缺省)= 可重试——保持收敛前的
|
|
263
|
+
* 默认重试语义;仅 stale_context 与 schema_deterministic 两态维持不重试特判。
|
|
264
|
+
* 词表归属(产出侧单点识别):stale_context / schema_deterministic 的识别词表
|
|
265
|
+
* (stale 词表与确定性 schema 失败标记前缀)保留在产出侧
|
|
266
|
+
* execution/engine/engines/pi/output-collector.ts 包内——词表漂移的失效模式是
|
|
267
|
+
* failureKind=unknown → 保守重试(安全默认),不再是静默漏诊。
|
|
268
|
+
*/
|
|
269
|
+
export type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
|
|
270
|
+
|
|
192
271
|
/**
|
|
193
272
|
* 单次 agent 调用的结果(统一形态)。
|
|
194
273
|
*
|
|
@@ -199,6 +278,16 @@ export interface AgentResult {
|
|
|
199
278
|
/** Raw text output from the agent. */
|
|
200
279
|
content: string;
|
|
201
280
|
/**
|
|
281
|
+
* [D5-③] 失败分诊结构化标签(AgentFailureKind)。产出侧唯一识别点 =
|
|
282
|
+
* execution/engine/engines/pi/output-collector.ts(collectResult 对最终 error
|
|
283
|
+
* 分类后写入,经 agent-result-mapper / AgentOutcome 透传到本形态);消费侧
|
|
284
|
+
* execute-agent-call 读本字段分诊,不再扫 error 文案子串。
|
|
285
|
+
*
|
|
286
|
+
* 仅在 error !== undefined 时有意义(成功时缺省);缺省视为 unknown = 可重试
|
|
287
|
+
* (语义守恒,见 AgentFailureKind)。
|
|
288
|
+
*/
|
|
289
|
+
failureKind?: AgentFailureKind;
|
|
290
|
+
/**
|
|
202
291
|
* Parsed structured output.
|
|
203
292
|
* Present when `schema` was provided and the output was valid JSON.
|
|
204
293
|
* Source: tool_execution_end.result.details(validated data object)。
|
|
@@ -39,7 +39,7 @@ import { canRunTransition } from "./types.ts";
|
|
|
39
39
|
/**
|
|
40
40
|
* 聚合根级 meta(非 RunState 的一部分,不随 trace 持久化到 worker JSONL)。
|
|
41
41
|
*
|
|
42
|
-
* workerErrorCount/scriptErrorCount 跨 runtime 存活(C.5:
|
|
42
|
+
* workerErrorCount/scriptErrorCount 跨 runtime 存活(C.5:worker-message-pump 重试计数载体),
|
|
43
43
|
* 因为 retry 会 replaceRuntime,但计数是 run 级而非 runtime 级。
|
|
44
44
|
*/
|
|
45
45
|
export interface WorkflowRunMeta {
|
|
@@ -136,6 +136,36 @@ function stripStringsAndComments(line: string): string {
|
|
|
136
136
|
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/** 注释行判定:行注释开头或块注释续行开头(* 与斜杠星号前缀)。 */
|
|
140
|
+
function isCommentLine(trimmed: string): boolean {
|
|
141
|
+
return trimmed.startsWith("//") || trimmed.startsWith("*") || trimmed.startsWith("/*");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** 括号平衡增量:圆/花/方括号开符计 +1,闭符计 -1,其余 0。 */
|
|
145
|
+
function bracketDepthDelta(text: string): number {
|
|
146
|
+
let delta = 0;
|
|
147
|
+
for (const ch of text) {
|
|
148
|
+
if (ch === "(" || ch === "{" || ch === "[") delta++;
|
|
149
|
+
if (ch === ")" || ch === "}" || ch === "]") delta--;
|
|
150
|
+
}
|
|
151
|
+
return delta;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 检测行内「agent(」字面量对象调用起点;命中返回替换后的调用头圆括号及其后原文
|
|
155
|
+
//(计括号用),未命中 / 非字面量实参返回 undefined。
|
|
156
|
+
//
|
|
157
|
+
// 非字面量实参(agent(callVar) / agent(expr))返回 undefined:description 等选项在调用点
|
|
158
|
+
// 静态不可见,checkAgentDescription 无法验证运行时构造的调用——继续报 warning 即误报
|
|
159
|
+
// (review-fix-loop 的 agent(call) 三连误报根因)。
|
|
160
|
+
// 形如 agent( 换行 { 的多行字面量调用(argTail 为空)保留原追踪行为。
|
|
161
|
+
function matchAgentCallHead(codeLine: string): string | undefined {
|
|
162
|
+
if (!/\bagent\s*\(/.test(codeLine)) return undefined;
|
|
163
|
+
const afterAgent = codeLine.replace(/^.*?\bagent\s*\(/, "(");
|
|
164
|
+
const argTail = afterAgent.trimStart().slice(1).trimStart();
|
|
165
|
+
if (argTail.length > 0 && !argTail.startsWith("{")) return undefined;
|
|
166
|
+
return afterAgent;
|
|
167
|
+
}
|
|
168
|
+
|
|
139
169
|
/**
|
|
140
170
|
* 遍历 source 中所有 agent 调用的行范围,对每个调用执行 callback。
|
|
141
171
|
*
|
|
@@ -150,9 +180,6 @@ function stripStringsAndComments(line: string): string {
|
|
|
150
180
|
* 内嵌的 agent() 调用——它们同样被 `\bagent\s*\(` 匹配)。
|
|
151
181
|
*
|
|
152
182
|
* 匹配前逐行剔除字符串/注释内容(MF-4):字符串字面量里的 "agent(s)" 不再误触发。
|
|
153
|
-
* 非字面量实参(agent(callVar) / agent(expr))跳过不回调:description 等选项在调用点
|
|
154
|
-
* 静态不可见,checkAgentDescription 无法验证运行时构造的调用——继续报 warning 即误报
|
|
155
|
-
* (review-fix-loop 的 agent(call) 三连误报根因)。
|
|
156
183
|
*
|
|
157
184
|
* @param callback (startLine, endLine) 0-based 行号
|
|
158
185
|
*/
|
|
@@ -170,31 +197,22 @@ function forEachAgentCallRange(
|
|
|
170
197
|
const trimmed = line.trim();
|
|
171
198
|
|
|
172
199
|
// 跳过注释
|
|
173
|
-
if (
|
|
200
|
+
if (isCommentLine(trimmed)) {
|
|
174
201
|
continue;
|
|
175
202
|
}
|
|
176
203
|
|
|
177
204
|
// 匹配/计括号都用剔除字符串与注释后的行,避免字面量内容干扰
|
|
178
205
|
const codeLine = stripStringsAndComments(line);
|
|
179
206
|
|
|
180
|
-
|
|
181
|
-
|
|
207
|
+
if (!inAgentCall) {
|
|
208
|
+
// 检测 agent 调用开始(非字面量实参 → undefined,跳过本行)
|
|
209
|
+
const afterAgent = matchAgentCallHead(codeLine);
|
|
210
|
+
if (afterAgent === undefined) continue;
|
|
182
211
|
inAgentCall = true;
|
|
183
212
|
depth = 0;
|
|
184
213
|
agentStartLine = i;
|
|
185
214
|
// 从 agent( 开始计括号
|
|
186
|
-
|
|
187
|
-
// 非字面量实参(agent(callVar) / agent(expr))→ 跳过(见函数头注释)。
|
|
188
|
-
// 形如 `agent(` 换行 `{` 的多行字面量调用(argTail 为空)保留原追踪行为。
|
|
189
|
-
const argTail = afterAgent.trimStart().slice(1).trimStart();
|
|
190
|
-
if (argTail.length > 0 && !argTail.startsWith("{")) {
|
|
191
|
-
inAgentCall = false;
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
for (const ch of afterAgent) {
|
|
195
|
-
if (ch === "(" || ch === "{" || ch === "[") depth++;
|
|
196
|
-
if (ch === ")" || ch === "}" || ch === "]") depth--;
|
|
197
|
-
}
|
|
215
|
+
depth += bracketDepthDelta(afterAgent);
|
|
198
216
|
if (depth <= 0) {
|
|
199
217
|
// 单行 agent 调用
|
|
200
218
|
callback(agentStartLine, i);
|
|
@@ -203,15 +221,10 @@ function forEachAgentCallRange(
|
|
|
203
221
|
continue;
|
|
204
222
|
}
|
|
205
223
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
if (depth <= 0) {
|
|
212
|
-
callback(agentStartLine, i);
|
|
213
|
-
inAgentCall = false;
|
|
214
|
-
}
|
|
224
|
+
depth += bracketDepthDelta(codeLine);
|
|
225
|
+
if (depth <= 0) {
|
|
226
|
+
callback(agentStartLine, i);
|
|
227
|
+
inAgentCall = false;
|
|
215
228
|
}
|
|
216
229
|
}
|
|
217
230
|
}
|
|
@@ -613,6 +626,54 @@ function checkMetaFieldQuality(field: string, value: string): LintFinding[] {
|
|
|
613
626
|
return findings;
|
|
614
627
|
}
|
|
615
628
|
|
|
629
|
+
/** 对象的 keys 全部收集进集合(非对象安全退化:不加任何 key)。 */
|
|
630
|
+
function collectObjectKeys(src: unknown, out: Set<string>): void {
|
|
631
|
+
if (src === null || typeof src !== "object") return;
|
|
632
|
+
for (const k of Object.keys(src as Record<string, unknown>)) out.add(k);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** patternProperties 的 `^word\\d+$` 形态提取 word 前缀作参数名(其余形态不加)。 */
|
|
636
|
+
function collectPatternPropertyNames(pp: unknown, out: Set<string>): void {
|
|
637
|
+
if (pp === null || typeof pp !== "object") return;
|
|
638
|
+
for (const p of Object.keys(pp as Record<string, unknown>)) {
|
|
639
|
+
const m = p.match(/^\^([a-zA-Z]+)\\d\+\$$/);
|
|
640
|
+
if (m) out.add(m[1] as string);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** W1 参数名集合 = parameters.properties keys + patternProperties 的 word 前缀。 */
|
|
645
|
+
function collectDeclaredParamNames(parameters: unknown): Set<string> {
|
|
646
|
+
const paramNames = new Set<string>();
|
|
647
|
+
if (parameters === null || typeof parameters !== "object") return paramNames;
|
|
648
|
+
const params = parameters as Record<string, unknown>;
|
|
649
|
+
collectObjectKeys(params.properties, paramNames);
|
|
650
|
+
collectPatternPropertyNames(params.patternProperties, paramNames);
|
|
651
|
+
return paramNames;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** W1:单字段内已声明参数名的 ':'/'=' 形态检查(文案见 finding)。 */
|
|
655
|
+
function findParamNameFindings(
|
|
656
|
+
field: string,
|
|
657
|
+
value: string,
|
|
658
|
+
paramNames: ReadonlySet<string>,
|
|
659
|
+
): LintFinding[] {
|
|
660
|
+
const findings: LintFinding[] = [];
|
|
661
|
+
// W1:已声明参数名的 ':'/'=' 形态(参数名转义防 RegExp 注入崩溃——exec-review F2;
|
|
662
|
+
// ':' 形态加 \\b 前缀防子串误报(subtask: 不命中 task——exec-review F6))
|
|
663
|
+
for (const name of paramNames) {
|
|
664
|
+
const nameEsc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
665
|
+
if (new RegExp(`\\b${nameEsc}:\\s`).test(value) || new RegExp(`\\b${nameEsc}=\\S`).test(value)) {
|
|
666
|
+
findings.push({
|
|
667
|
+
severity: "error",
|
|
668
|
+
line: 1,
|
|
669
|
+
message: `meta.${field} 包含已声明参数名 '${name}'('${name}:' / '${name}=' 形态)——参数契约请 read 脚本文件的 @pi-meta parameters 查询,description/when/notFor 只放路由信息`,
|
|
670
|
+
suggestion: `从 meta.${field} 移除 '${name}: ...' / '${name}=...',改在 parameters/usage 中声明`,
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return findings;
|
|
675
|
+
}
|
|
676
|
+
|
|
616
677
|
/**
|
|
617
678
|
* W1-W3:SSOT lint(m4)——保 §5.1 注入段 description 短单句、不含已声明参数名。
|
|
618
679
|
* 仅对 parseResourceMeta 解析成功的 meta 执行(旧 const meta 格式不检查)。
|
|
@@ -624,44 +685,16 @@ function checkMetaFieldQuality(field: string, value: string): LintFinding[] {
|
|
|
624
685
|
*/
|
|
625
686
|
function checkMetaQuality(meta: { description?: string; when?: string; notFor?: string; parameters?: Record<string, unknown> }): LintFinding[] {
|
|
626
687
|
const findings: LintFinding[] = [];
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
// W1 参数名集合
|
|
630
|
-
const paramNames = new Set<string>();
|
|
631
|
-
if (meta.parameters && typeof meta.parameters === "object") {
|
|
632
|
-
const props = (meta.parameters as Record<string, unknown>).properties;
|
|
633
|
-
if (props !== null && typeof props === "object") {
|
|
634
|
-
for (const k of Object.keys(props as Record<string, unknown>)) paramNames.add(k);
|
|
635
|
-
}
|
|
636
|
-
const pp = (meta.parameters as Record<string, unknown>).patternProperties;
|
|
637
|
-
if (pp !== null && typeof pp === "object") {
|
|
638
|
-
for (const p of Object.keys(pp as Record<string, unknown>)) {
|
|
639
|
-
const m = p.match(/^\^([a-zA-Z]+)\\d\+\$$/);
|
|
640
|
-
if (m) paramNames.add(m[1] as string);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
688
|
+
const paramNames = collectDeclaredParamNames(meta.parameters);
|
|
644
689
|
|
|
645
690
|
const fields: Array<[string, string]> = [
|
|
646
|
-
["description", description],
|
|
691
|
+
["description", meta.description ?? ""],
|
|
647
692
|
["when", meta.when ?? ""],
|
|
648
693
|
["notFor", meta.notFor ?? ""],
|
|
649
694
|
];
|
|
650
695
|
for (const [field, value] of fields) {
|
|
651
696
|
if (value.length === 0) continue;
|
|
652
|
-
|
|
653
|
-
// ':' 形态加 \\b 前缀防子串误报(subtask: 不命中 task——exec-review F6))
|
|
654
|
-
for (const name of paramNames) {
|
|
655
|
-
const nameEsc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
656
|
-
if (new RegExp(`\\b${nameEsc}:\\s`).test(value) || new RegExp(`\\b${nameEsc}=\\S`).test(value)) {
|
|
657
|
-
findings.push({
|
|
658
|
-
severity: "error",
|
|
659
|
-
line: 1,
|
|
660
|
-
message: `meta.${field} 包含已声明参数名 '${name}'('${name}:' / '${name}=' 形态)——参数契约请 read 脚本文件的 @pi-meta parameters 查询,description/when/notFor 只放路由信息`,
|
|
661
|
-
suggestion: `从 meta.${field} 移除 '${name}: ...' / '${name}=...',改在 parameters/usage 中声明`,
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
}
|
|
697
|
+
findings.push(...findParamNameFindings(field, value, paramNames));
|
|
665
698
|
findings.push(...checkMetaFieldQuality(field, value));
|
|
666
699
|
}
|
|
667
700
|
return findings;
|