peaks-loop 4.1.2 → 4.1.3
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/.claude-plugin/marketplace.json +136 -47
- package/CHANGELOG.md +56 -0
- package/README-en.md +1 -1
- package/README.md +1 -1
- package/contracts/readonly-argv-whitelist.json +211 -0
- package/dist/cli/commands/audit-artifact-runners.d.ts +16 -0
- package/dist/cli/commands/audit-artifact-runners.js +170 -0
- package/dist/cli/commands/audit-command-shared.d.ts +97 -0
- package/dist/cli/commands/audit-command-shared.js +60 -0
- package/dist/cli/commands/audit-commands.d.ts +7 -31
- package/dist/cli/commands/audit-commands.js +64 -473
- package/dist/cli/commands/audit-goal-runners.d.ts +17 -0
- package/dist/cli/commands/audit-goal-runners.js +114 -0
- package/dist/cli/commands/audit-red-lines-runners.d.ts +11 -0
- package/dist/cli/commands/audit-red-lines-runners.js +43 -0
- package/dist/cli/commands/audit-refusal-data.d.ts +23 -0
- package/dist/cli/commands/audit-refusal-data.js +69 -0
- package/dist/cli/commands/audit-static-runners.d.ts +13 -0
- package/dist/cli/commands/audit-static-runners.js +139 -0
- package/dist/cli/commands/await-runners.d.ts +11 -0
- package/dist/cli/commands/await-runners.js +148 -0
- package/dist/cli/commands/code-auto-compact-command.d.ts +3 -0
- package/dist/cli/commands/code-auto-compact-command.js +124 -0
- package/dist/cli/commands/code-auto-compact-envelope.d.ts +22 -0
- package/dist/cli/commands/code-auto-compact-envelope.js +39 -0
- package/dist/cli/commands/code-context-audit-command.d.ts +3 -0
- package/dist/cli/commands/code-context-audit-command.js +68 -0
- package/dist/cli/commands/code-context-now-command.d.ts +3 -0
- package/dist/cli/commands/code-context-now-command.js +124 -0
- package/dist/cli/commands/code-context-now-envelope.d.ts +66 -0
- package/dist/cli/commands/code-context-now-envelope.js +136 -0
- package/dist/cli/commands/code-context-now-mapping.d.ts +27 -0
- package/dist/cli/commands/code-context-now-mapping.js +43 -0
- package/dist/cli/commands/code-emit-handoff-command.d.ts +3 -0
- package/dist/cli/commands/code-emit-handoff-command.js +99 -0
- package/dist/cli/commands/code-gate-step-08-command.d.ts +3 -0
- package/dist/cli/commands/code-gate-step-08-command.js +139 -0
- package/dist/cli/commands/code-post-compact-detect-command.d.ts +3 -0
- package/dist/cli/commands/code-post-compact-detect-command.js +50 -0
- package/dist/cli/commands/code-runtime-commands.d.ts +9 -43
- package/dist/cli/commands/code-runtime-commands.js +20 -672
- package/dist/cli/commands/code-runtime-session.d.ts +1 -0
- package/dist/cli/commands/code-runtime-session.js +15 -0
- package/dist/cli/commands/compact-command.d.ts +6 -2
- package/dist/cli/commands/compact-command.js +12 -559
- package/dist/cli/commands/compact-dry-run-command.d.ts +3 -0
- package/dist/cli/commands/compact-dry-run-command.js +87 -0
- package/dist/cli/commands/compact-force-command.d.ts +3 -0
- package/dist/cli/commands/compact-force-command.js +98 -0
- package/dist/cli/commands/compact-harness-window-command.d.ts +3 -0
- package/dist/cli/commands/compact-harness-window-command.js +174 -0
- package/dist/cli/commands/compact-history-command.d.ts +3 -0
- package/dist/cli/commands/compact-history-command.js +89 -0
- package/dist/cli/commands/compact-read-commands.d.ts +3 -0
- package/dist/cli/commands/compact-read-commands.js +123 -0
- package/dist/cli/commands/compact-settle-command.d.ts +3 -0
- package/dist/cli/commands/compact-settle-command.js +130 -0
- package/dist/cli/commands/compact-shared.d.ts +9 -0
- package/dist/cli/commands/compact-shared.js +26 -0
- package/dist/cli/commands/core/skill-command.d.ts +1 -44
- package/dist/cli/commands/core/skill-command.js +13 -541
- package/dist/cli/commands/core/skill-context-verdict.d.ts +38 -0
- package/dist/cli/commands/core/skill-context-verdict.js +63 -0
- package/dist/cli/commands/core/skill-generated-config-notice.d.ts +41 -0
- package/dist/cli/commands/core/skill-generated-config-notice.js +75 -0
- package/dist/cli/commands/core/skill-heartbeat-commands.d.ts +3 -0
- package/dist/cli/commands/core/skill-heartbeat-commands.js +50 -0
- package/dist/cli/commands/core/skill-presence-commands.d.ts +3 -0
- package/dist/cli/commands/core/skill-presence-commands.js +123 -0
- package/dist/cli/commands/core/skill-presence-housekeeping-commands.d.ts +3 -0
- package/dist/cli/commands/core/skill-presence-housekeeping-commands.js +165 -0
- package/dist/cli/commands/core/skill-registry-commands.d.ts +3 -0
- package/dist/cli/commands/core/skill-registry-commands.js +117 -0
- package/dist/cli/commands/core/skill-runbook-command.d.ts +3 -0
- package/dist/cli/commands/core/skill-runbook-command.js +29 -0
- package/dist/cli/commands/dispatch-command-spec.d.ts +2 -0
- package/dist/cli/commands/dispatch-command-spec.js +62 -0
- package/dist/cli/commands/dispatch-commands.js +159 -775
- package/dist/cli/commands/dispatch-detached-branch.d.ts +3 -0
- package/dist/cli/commands/dispatch-detached-branch.js +58 -0
- package/dist/cli/commands/dispatch-envelope.d.ts +36 -0
- package/dist/cli/commands/dispatch-envelope.js +104 -0
- package/dist/cli/commands/dispatch-isolation-lease.d.ts +17 -0
- package/dist/cli/commands/dispatch-isolation-lease.js +149 -0
- package/dist/cli/commands/dispatch-preflight.d.ts +7 -0
- package/dist/cli/commands/dispatch-preflight.js +105 -0
- package/dist/cli/commands/dispatch-prompt-blocks.d.ts +10 -0
- package/dist/cli/commands/dispatch-prompt-blocks.js +56 -0
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +30 -0
- package/dist/cli/commands/dispatch-prompt-composition.js +171 -0
- package/dist/cli/commands/dispatch-record-write.d.ts +24 -0
- package/dist/cli/commands/dispatch-record-write.js +96 -0
- package/dist/cli/commands/dispatch-tool-call.d.ts +15 -0
- package/dist/cli/commands/dispatch-tool-call.js +128 -0
- package/dist/cli/commands/evolution-command-shared.d.ts +78 -0
- package/dist/cli/commands/evolution-command-shared.js +107 -0
- package/dist/cli/commands/evolution-commands.d.ts +11 -1
- package/dist/cli/commands/evolution-commands.js +19 -350
- package/dist/cli/commands/evolution-evaluate-command.d.ts +24 -0
- package/dist/cli/commands/evolution-evaluate-command.js +138 -0
- package/dist/cli/commands/evolution-propose-command.d.ts +23 -0
- package/dist/cli/commands/evolution-propose-command.js +145 -0
- package/dist/cli/commands/evolution-status-command.d.ts +17 -0
- package/dist/cli/commands/evolution-status-command.js +41 -0
- package/dist/cli/commands/evolution-verdict-commands.d.ts +30 -0
- package/dist/cli/commands/evolution-verdict-commands.js +100 -0
- package/dist/cli/commands/finalize-accumulator.d.ts +44 -0
- package/dist/cli/commands/finalize-accumulator.js +55 -0
- package/dist/cli/commands/finalize-branches.d.ts +34 -0
- package/dist/cli/commands/finalize-branches.js +119 -0
- package/dist/cli/commands/finalize-runners.d.ts +3 -0
- package/dist/cli/commands/finalize-runners.js +92 -0
- package/dist/cli/commands/finalize-selection.d.ts +65 -0
- package/dist/cli/commands/finalize-selection.js +35 -0
- package/dist/cli/commands/gate-commands.js +26 -8
- package/dist/cli/commands/job-checkpoint-commands.d.ts +3 -0
- package/dist/cli/commands/job-checkpoint-commands.js +157 -0
- package/dist/cli/commands/job-command-shared.d.ts +109 -0
- package/dist/cli/commands/job-command-shared.js +72 -0
- package/dist/cli/commands/job-commands.d.ts +4 -64
- package/dist/cli/commands/job-commands.js +42 -552
- package/dist/cli/commands/job-cost-check-command.d.ts +3 -0
- package/dist/cli/commands/job-cost-check-command.js +41 -0
- package/dist/cli/commands/job-init-status-commands.d.ts +3 -0
- package/dist/cli/commands/job-init-status-commands.js +149 -0
- package/dist/cli/commands/job-run-commands.d.ts +3 -0
- package/dist/cli/commands/job-run-commands.js +97 -0
- package/dist/cli/commands/job-state-root.d.ts +35 -0
- package/dist/cli/commands/job-state-root.js +76 -0
- package/dist/cli/commands/loop-eval-capture-index.d.ts +4 -0
- package/dist/cli/commands/loop-eval-capture-index.js +44 -0
- package/dist/cli/commands/loop-eval-commands.d.ts +8 -5
- package/dist/cli/commands/loop-eval-commands.js +12 -626
- package/dist/cli/commands/loop-eval-eval-command.d.ts +3 -0
- package/dist/cli/commands/loop-eval-eval-command.js +168 -0
- package/dist/cli/commands/loop-eval-monotonic-command.d.ts +3 -0
- package/dist/cli/commands/loop-eval-monotonic-command.js +90 -0
- package/dist/cli/commands/loop-eval-parents.d.ts +7 -0
- package/dist/cli/commands/loop-eval-parents.js +20 -0
- package/dist/cli/commands/loop-eval-run-code.d.ts +7 -0
- package/dist/cli/commands/loop-eval-run-code.js +40 -0
- package/dist/cli/commands/loop-eval-run-command.d.ts +3 -0
- package/dist/cli/commands/loop-eval-run-command.js +113 -0
- package/dist/cli/commands/loop-eval-spec-commands.d.ts +3 -0
- package/dist/cli/commands/loop-eval-spec-commands.js +165 -0
- package/dist/cli/commands/loop-eval-spec-lint-command.d.ts +3 -0
- package/dist/cli/commands/loop-eval-spec-lint-command.js +42 -0
- package/dist/cli/commands/loop-eval-workflow-commands.d.ts +3 -0
- package/dist/cli/commands/loop-eval-workflow-commands.js +141 -0
- package/dist/cli/commands/mcp-commands.d.ts +10 -0
- package/dist/cli/commands/mcp-commands.js +157 -0
- package/dist/cli/commands/request-command-options.d.ts +49 -0
- package/dist/cli/commands/request-command-options.js +1 -0
- package/dist/cli/commands/request-commands.d.ts +3 -9
- package/dist/cli/commands/request-commands.js +17 -522
- package/dist/cli/commands/request-init-command.d.ts +3 -0
- package/dist/cli/commands/request-init-command.js +100 -0
- package/dist/cli/commands/request-lint-command.d.ts +3 -0
- package/dist/cli/commands/request-lint-command.js +50 -0
- package/dist/cli/commands/request-list-command.d.ts +10 -0
- package/dist/cli/commands/request-list-command.js +53 -0
- package/dist/cli/commands/request-repair-status-command.d.ts +3 -0
- package/dist/cli/commands/request-repair-status-command.js +61 -0
- package/dist/cli/commands/request-show-command.d.ts +3 -0
- package/dist/cli/commands/request-show-command.js +56 -0
- package/dist/cli/commands/request-transition-command.d.ts +3 -0
- package/dist/cli/commands/request-transition-command.js +122 -0
- package/dist/cli/commands/request-transition-failures.d.ts +8 -0
- package/dist/cli/commands/request-transition-failures.js +90 -0
- package/dist/cli/commands/request-transition-hooks.d.ts +50 -0
- package/dist/cli/commands/request-transition-hooks.js +115 -0
- package/dist/cli/commands/request-transition-preflight.d.ts +10 -0
- package/dist/cli/commands/request-transition-preflight.js +107 -0
- package/dist/cli/commands/scan-command-shared.d.ts +96 -0
- package/dist/cli/commands/scan-command-shared.js +83 -0
- package/dist/cli/commands/scan-commands.d.ts +3 -2
- package/dist/cli/commands/scan-commands.js +23 -463
- package/dist/cli/commands/scan-inventory-commands.d.ts +3 -0
- package/dist/cli/commands/scan-inventory-commands.js +96 -0
- package/dist/cli/commands/scan-project-commands.d.ts +3 -0
- package/dist/cli/commands/scan-project-commands.js +65 -0
- package/dist/cli/commands/scan-scope-commands.d.ts +3 -0
- package/dist/cli/commands/scan-scope-commands.js +149 -0
- package/dist/cli/commands/scan-scope-helpers.d.ts +8 -0
- package/dist/cli/commands/scan-scope-helpers.js +54 -0
- package/dist/cli/commands/scan-structural-commands.d.ts +3 -0
- package/dist/cli/commands/scan-structural-commands.js +113 -0
- package/dist/cli/commands/share-commands.d.ts +12 -68
- package/dist/cli/commands/share-commands.js +47 -556
- package/dist/cli/commands/share-error-hints.d.ts +14 -0
- package/dist/cli/commands/share-error-hints.js +38 -0
- package/dist/cli/commands/share-identity.d.ts +13 -0
- package/dist/cli/commands/share-identity.js +22 -0
- package/dist/cli/commands/share-record-paths.d.ts +37 -0
- package/dist/cli/commands/share-record-paths.js +68 -0
- package/dist/cli/commands/share-runners.d.ts +3 -0
- package/dist/cli/commands/share-runners.js +158 -0
- package/dist/cli/commands/shared-read-runners.d.ts +3 -0
- package/dist/cli/commands/shared-read-runners.js +51 -0
- package/dist/cli/commands/slice-check-command.d.ts +3 -0
- package/dist/cli/commands/slice-check-command.js +54 -0
- package/dist/cli/commands/slice-commands.d.ts +2 -22
- package/dist/cli/commands/slice-commands.js +18 -517
- package/dist/cli/commands/slice-decompose-artifacts.d.ts +18 -0
- package/dist/cli/commands/slice-decompose-artifacts.js +79 -0
- package/dist/cli/commands/slice-decompose-command.d.ts +3 -0
- package/dist/cli/commands/slice-decompose-command.js +123 -0
- package/dist/cli/commands/slice-list-commands.d.ts +3 -0
- package/dist/cli/commands/slice-list-commands.js +182 -0
- package/dist/cli/commands/slice-pick-command.d.ts +3 -0
- package/dist/cli/commands/slice-pick-command.js +60 -0
- package/dist/cli/commands/slice-plan-command.d.ts +24 -0
- package/dist/cli/commands/slice-plan-command.js +111 -0
- package/dist/cli/commands/workflow-commands.d.ts +10 -1
- package/dist/cli/commands/workflow-commands.js +6 -594
- package/dist/cli/commands/workflow-gate-commands.d.ts +3 -0
- package/dist/cli/commands/workflow-gate-commands.js +116 -0
- package/dist/cli/commands/workflow-plan-helpers.d.ts +48 -0
- package/dist/cli/commands/workflow-plan-helpers.js +103 -0
- package/dist/cli/commands/workflow-planning-commands.d.ts +3 -0
- package/dist/cli/commands/workflow-planning-commands.js +56 -0
- package/dist/cli/commands/workflow-swarm-actions.d.ts +7 -0
- package/dist/cli/commands/workflow-swarm-actions.js +109 -0
- package/dist/cli/commands/workflow-swarm-commands.d.ts +3 -0
- package/dist/cli/commands/workflow-swarm-commands.js +138 -0
- package/dist/cli/commands/workflow-tech-actions.d.ts +10 -0
- package/dist/cli/commands/workflow-tech-actions.js +150 -0
- package/dist/cli/commands/workspace/init-actions.d.ts +10 -0
- package/dist/cli/commands/workspace/init-actions.js +199 -0
- package/dist/cli/commands/workspace/init-codegraph-stake.d.ts +10 -0
- package/dist/cli/commands/workspace/init-codegraph-stake.js +54 -0
- package/dist/cli/commands/workspace/init-command.d.ts +8 -124
- package/dist/cli/commands/workspace/init-command.js +59 -623
- package/dist/cli/commands/workspace/init-context.d.ts +58 -0
- package/dist/cli/commands/workspace/init-context.js +121 -0
- package/dist/cli/commands/workspace/init-envelope.d.ts +3 -0
- package/dist/cli/commands/workspace/init-envelope.js +34 -0
- package/dist/cli/commands/workspace/init-failures.d.ts +3 -0
- package/dist/cli/commands/workspace/init-failures.js +84 -0
- package/dist/cli/commands/workspace/init-hooks-decision.d.ts +24 -0
- package/dist/cli/commands/workspace/init-hooks-decision.js +189 -0
- package/dist/cli/commands/workspace/init-options.d.ts +102 -0
- package/dist/cli/commands/workspace/init-options.js +1 -0
- package/dist/cli/commands/worktree-lease-commands.d.ts +10 -6
- package/dist/cli/commands/worktree-lease-commands.js +42 -512
- package/dist/cli/commands/worktree-lease-gc-command.d.ts +12 -0
- package/dist/cli/commands/worktree-lease-gc-command.js +117 -0
- package/dist/cli/commands/worktree-lease-git.d.ts +22 -0
- package/dist/cli/commands/worktree-lease-git.js +48 -0
- package/dist/cli/commands/worktree-lease-list-command.d.ts +12 -0
- package/dist/cli/commands/worktree-lease-list-command.js +100 -0
- package/dist/cli/commands/worktree-lease-load.d.ts +37 -0
- package/dist/cli/commands/worktree-lease-load.js +28 -0
- package/dist/cli/commands/worktree-lease-release-command.d.ts +13 -0
- package/dist/cli/commands/worktree-lease-release-command.js +105 -0
- package/dist/cli/commands/worktree-lease-renew-command.d.ts +11 -0
- package/dist/cli/commands/worktree-lease-renew-command.js +99 -0
- package/dist/cli/commands/worktree-lease-session.d.ts +22 -0
- package/dist/cli/commands/worktree-lease-session.js +29 -0
- package/dist/cli/commands/worktree-lease-spawn-command.d.ts +11 -0
- package/dist/cli/commands/worktree-lease-spawn-command.js +119 -0
- package/dist/cli/commands/worktree-lease-status-command.d.ts +11 -0
- package/dist/cli/commands/worktree-lease-status-command.js +86 -0
- package/dist/cli/commands/worktree-lease-store.d.ts +19 -0
- package/dist/cli/commands/worktree-lease-store.js +24 -0
- package/dist/cli/program.js +5 -0
- package/dist/services/distribution/mcp-install-runner.d.ts +21 -0
- package/dist/services/distribution/mcp-install-runner.js +59 -0
- package/dist/services/distribution/mcp-install.d.ts +95 -0
- package/dist/services/distribution/mcp-install.js +179 -0
- package/dist/services/distribution/plugin-manifest.d.ts +97 -0
- package/dist/services/distribution/plugin-manifest.js +126 -0
- package/dist/services/hooks/mcp-surface-gate.d.ts +19 -0
- package/dist/services/hooks/mcp-surface-gate.js +87 -0
- package/dist/services/ide/adapters/claude-code-adapter.d.ts +4 -35
- package/dist/services/ide/adapters/claude-code-adapter.js +48 -171
- package/dist/services/ide/adapters/claude-code-local-state.d.ts +28 -0
- package/dist/services/ide/adapters/claude-code-local-state.js +112 -0
- package/dist/services/ide/adapters/claude-code-model-window.d.ts +37 -0
- package/dist/services/ide/adapters/claude-code-model-window.js +113 -0
- package/dist/services/ide/ide-mcp-install-types.d.ts +78 -0
- package/dist/services/ide/ide-mcp-install-types.js +104 -0
- package/dist/services/ide/ide-types.d.ts +45 -1
- package/dist/services/ide/mcp-tool-matcher.d.ts +34 -0
- package/dist/services/ide/mcp-tool-matcher.js +84 -0
- package/dist/services/lint/npx-resolver.js +7 -0
- package/dist/services/mcp/cli-executor.d.ts +36 -0
- package/dist/services/mcp/cli-executor.js +97 -0
- package/dist/services/mcp/json-rpc.d.ts +81 -0
- package/dist/services/mcp/json-rpc.js +116 -0
- package/dist/services/mcp/memory-tool.d.ts +3 -0
- package/dist/services/mcp/memory-tool.js +62 -0
- package/dist/services/mcp/server-main.d.ts +1 -0
- package/dist/services/mcp/server-main.js +66 -0
- package/dist/services/mcp/server.d.ts +22 -0
- package/dist/services/mcp/server.js +152 -0
- package/dist/services/mcp/surface.d.ts +62 -0
- package/dist/services/mcp/surface.js +198 -0
- package/dist/services/mcp/tool-core.d.ts +42 -0
- package/dist/services/mcp/tool-core.js +137 -0
- package/dist/services/mcp/tools.d.ts +13 -0
- package/dist/services/mcp/tools.js +58 -0
- package/dist/services/readonly-surface/argv-guard.d.ts +32 -0
- package/dist/services/readonly-surface/argv-guard.js +164 -0
- package/dist/services/readonly-surface/readonly-whitelist.d.ts +147 -0
- package/dist/services/readonly-surface/readonly-whitelist.js +107 -0
- package/dist/services/readonly-surface/whitelist-generator.d.ts +64 -0
- package/dist/services/readonly-surface/whitelist-generator.js +212 -0
- package/dist/services/skills/hooks-codegate-superpowers.d.ts +1 -0
- package/dist/services/skills/hooks-codegate-superpowers.js +26 -0
- package/dist/services/skills/hooks-settings-service.js +10 -2
- package/package.json +17 -6
- package/scripts/install-skills-bundles.mjs +233 -0
- package/scripts/install-skills-fs.mjs +148 -0
- package/scripts/install-skills-ide.mjs +279 -0
- package/scripts/install-skills-output-style-default.mjs +196 -0
- package/scripts/install-skills-output-styles.mjs +121 -0
- package/scripts/install-skills-report.mjs +42 -0
- package/scripts/install-skills-user-config.mjs +198 -0
- package/scripts/install-skills.mjs +36 -1066
- package/scripts/watch-tree.mjs +140 -0
- package/scripts/watch.mjs +4 -126
- package/skills/peaks-status/SKILL.md +31 -13
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-code "what to do next" hints for the failure envelopes of
|
|
3
|
+
* `peaks sub-agent share`, `peaks sub-agent shared-read`, and
|
|
4
|
+
* `peaks sub-agent await`. Extracted from `share-commands.ts` so that file
|
|
5
|
+
* stays under the line cap; each helper is pure — it maps an error code to the
|
|
6
|
+
* single actionable hint the runner places in the envelope, and nothing here
|
|
7
|
+
* prints, reads state, or throws.
|
|
8
|
+
*
|
|
9
|
+
* Each branch names the most likely next step, so a caller gets an actionable
|
|
10
|
+
* hint instead of a generic "see error message" fallback.
|
|
11
|
+
*/
|
|
12
|
+
export function shareErrorNextActions(code) {
|
|
13
|
+
if (code === 'LOCK_TIMEOUT') {
|
|
14
|
+
return 'A concurrent `peaks sub-agent share` is holding the channel lock for >5s; retry, or check for a crashed holder (the .lock file is reaped after 30s).';
|
|
15
|
+
}
|
|
16
|
+
if (code === 'RECORD_NOT_FOUND' || code === 'INVALID_RECORD_PATH') {
|
|
17
|
+
return 'The dispatch record path is missing or outside .peaks/_sub_agents/. Re-run `peaks sub-agent dispatch <role>` to get a fresh record path, then use that here.';
|
|
18
|
+
}
|
|
19
|
+
return 'See error message; check that --batch matches the dispatch envelope and the value is a JSON object ≤ 64KB.';
|
|
20
|
+
}
|
|
21
|
+
export function sharedReadErrorNextActions(code) {
|
|
22
|
+
if (code === 'INVALID_BATCH_ID' || code === 'MISSING_BATCH') {
|
|
23
|
+
return 'Pass --batch <batchId> exactly as returned by the `peaks sub-agent dispatch` envelope.';
|
|
24
|
+
}
|
|
25
|
+
return 'See error message; check that --batch matches the dispatch envelope (typo / wrong batch will return an empty channel, not an error).';
|
|
26
|
+
}
|
|
27
|
+
export function awaitErrorNextActions(code) {
|
|
28
|
+
if (code === 'INVALID_TIMEOUT') {
|
|
29
|
+
return 'Pass --timeout as a positive integer ms (e.g. --timeout 60000). 0 and non-numeric values are rejected.';
|
|
30
|
+
}
|
|
31
|
+
if (code === 'IDE_NOT_SUPPORTED') {
|
|
32
|
+
return 'Switch to claude-code, or rely on LLM-side await for non-claude-code IDEs in slice 1.3.';
|
|
33
|
+
}
|
|
34
|
+
if (code === 'NO_DISPATCH_RECORDS') {
|
|
35
|
+
return 'Check --session-id / --project: records live under .peaks/_sub_agents/<sessionId>/. Use the batchId exactly as printed by the dispatch envelope.';
|
|
36
|
+
}
|
|
37
|
+
return 'See error message; check that --batch matches the dispatch envelope and --timeout is a positive integer ms.';
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session id for a `share` / `shared-read` / `await` envelope: an explicit
|
|
3
|
+
* `--session-id` wins, then `PEAKS_SESSION_ID`, then the id resolved from
|
|
4
|
+
* `.peaks/_runtime/session.json` under `projectRoot`, then the literal
|
|
5
|
+
* `"unknown-sid"` fallback.
|
|
6
|
+
*
|
|
7
|
+
* `peaks sub-agent finalize` deliberately uses a DIFFERENT chain (it never
|
|
8
|
+
* consults the env var), so it keeps its own resolution rather than calling
|
|
9
|
+
* this helper.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveSessionId(options: {
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
}, projectRoot: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity resolution for the `peaks sub-agent share` family envelopes.
|
|
3
|
+
* Extracted from `share-commands.ts` so the runners can share one definition of
|
|
4
|
+
* how a session id is chosen, instead of each repeating the same fallback chain.
|
|
5
|
+
*/
|
|
6
|
+
import { getCurrentSessionId } from '../../services/skills/skill-presence-service.js';
|
|
7
|
+
/**
|
|
8
|
+
* The session id for a `share` / `shared-read` / `await` envelope: an explicit
|
|
9
|
+
* `--session-id` wins, then `PEAKS_SESSION_ID`, then the id resolved from
|
|
10
|
+
* `.peaks/_runtime/session.json` under `projectRoot`, then the literal
|
|
11
|
+
* `"unknown-sid"` fallback.
|
|
12
|
+
*
|
|
13
|
+
* `peaks sub-agent finalize` deliberately uses a DIFFERENT chain (it never
|
|
14
|
+
* consults the env var), so it keeps its own resolution rather than calling
|
|
15
|
+
* this helper.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveSessionId(options, projectRoot) {
|
|
18
|
+
return (options.sessionId ??
|
|
19
|
+
process.env.PEAKS_SESSION_ID ??
|
|
20
|
+
getCurrentSessionId(projectRoot) ??
|
|
21
|
+
'unknown-sid');
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DispatchRecord } from '../../services/dispatch/dispatch-record-writer.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a record's on-disk path through `realpathSync` so the value returned
|
|
4
|
+
* here matches the value `writeInitialDispatchRecord` produces — which itself
|
|
5
|
+
* passes through `assertSafeDispatchRecordPath` and ends up canonicalized. On
|
|
6
|
+
* macOS, `mkdtempSync(join(tmpdir(), prefix))` returns `/var/folders/...`
|
|
7
|
+
* while `process.cwd()` after `chdir` returns `/private/var/folders/...`;
|
|
8
|
+
* without this helper the test fixture's `queuedPath` (canonical) and the
|
|
9
|
+
* envelope's `finalized[].recordPath` (raw) never compare equal. Falls back
|
|
10
|
+
* to the lexical path when the file is missing (race between scan and write).
|
|
11
|
+
*/
|
|
12
|
+
export declare function safeRecordPath(p: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the dispatch records belonging to a batch.
|
|
15
|
+
*
|
|
16
|
+
* Reuses the conventions already in the repo instead of inventing a new one:
|
|
17
|
+
* - records live at `.peaks/_sub_agents/<sid>/dispatch-<rid>-<ts>.json`
|
|
18
|
+
* (`dispatchRecordPath`, src/services/security/safe-settings-path.ts);
|
|
19
|
+
* - a record's batch is its own `batchId` field, written by
|
|
20
|
+
* `writeInitialDispatchRecord`. The `--batch` branch of `finalize` and
|
|
21
|
+
* `findBatchRecords` in heartbeat-watch-command.ts resolve a batch the
|
|
22
|
+
* same way: scan the session dir, filter `dispatch-*.json`, compare field.
|
|
23
|
+
*
|
|
24
|
+
* `unreadable` lists the `dispatch-*.json` candidates whose batch could NOT be
|
|
25
|
+
* determined. The caller must not fold them into "no such batch": a record it
|
|
26
|
+
* cannot read is not evidence that the batch is empty.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveBatchRecords(input: {
|
|
29
|
+
projectRoot: string;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
batchId: string;
|
|
32
|
+
readOne: (recordPath: string) => DispatchRecord;
|
|
33
|
+
}): {
|
|
34
|
+
sessionDir: string;
|
|
35
|
+
recordPaths: string[];
|
|
36
|
+
unreadable: string[];
|
|
37
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch-record path helpers shared by `peaks sub-agent await` (which scans a
|
|
3
|
+
* session directory for a batch's records) and `peaks sub-agent finalize`
|
|
4
|
+
* (which canonicalizes a record path before reporting it). Extracted from
|
|
5
|
+
* `share-commands.ts` so that file stays under the line cap; every helper here
|
|
6
|
+
* is pure — it takes its inputs and returns a value.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readdirSync, realpathSync as realpathSyncNative } from 'node:fs';
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a record's on-disk path through `realpathSync` so the value returned
|
|
12
|
+
* here matches the value `writeInitialDispatchRecord` produces — which itself
|
|
13
|
+
* passes through `assertSafeDispatchRecordPath` and ends up canonicalized. On
|
|
14
|
+
* macOS, `mkdtempSync(join(tmpdir(), prefix))` returns `/var/folders/...`
|
|
15
|
+
* while `process.cwd()` after `chdir` returns `/private/var/folders/...`;
|
|
16
|
+
* without this helper the test fixture's `queuedPath` (canonical) and the
|
|
17
|
+
* envelope's `finalized[].recordPath` (raw) never compare equal. Falls back
|
|
18
|
+
* to the lexical path when the file is missing (race between scan and write).
|
|
19
|
+
*/
|
|
20
|
+
export function safeRecordPath(p) {
|
|
21
|
+
try {
|
|
22
|
+
return realpathSyncNative(p);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return p;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the dispatch records belonging to a batch.
|
|
30
|
+
*
|
|
31
|
+
* Reuses the conventions already in the repo instead of inventing a new one:
|
|
32
|
+
* - records live at `.peaks/_sub_agents/<sid>/dispatch-<rid>-<ts>.json`
|
|
33
|
+
* (`dispatchRecordPath`, src/services/security/safe-settings-path.ts);
|
|
34
|
+
* - a record's batch is its own `batchId` field, written by
|
|
35
|
+
* `writeInitialDispatchRecord`. The `--batch` branch of `finalize` and
|
|
36
|
+
* `findBatchRecords` in heartbeat-watch-command.ts resolve a batch the
|
|
37
|
+
* same way: scan the session dir, filter `dispatch-*.json`, compare field.
|
|
38
|
+
*
|
|
39
|
+
* `unreadable` lists the `dispatch-*.json` candidates whose batch could NOT be
|
|
40
|
+
* determined. The caller must not fold them into "no such batch": a record it
|
|
41
|
+
* cannot read is not evidence that the batch is empty.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveBatchRecords(input) {
|
|
44
|
+
const sessionDir = resolve(input.projectRoot, '.peaks', '_sub_agents', input.sessionId);
|
|
45
|
+
const recordPaths = [];
|
|
46
|
+
const unreadable = [];
|
|
47
|
+
if (!existsSync(sessionDir))
|
|
48
|
+
return { sessionDir, recordPaths, unreadable };
|
|
49
|
+
for (const name of readdirSync(sessionDir)) {
|
|
50
|
+
// `active-dispatches.json` (the index) and `batch-<uuid>.counter.json` are
|
|
51
|
+
// not records; neither carries a `version`, so `readRecord` would reject
|
|
52
|
+
// them as "version mismatch". Same filter as the `--batch` branch below.
|
|
53
|
+
if (!name.startsWith('dispatch-') || !name.endsWith('.json'))
|
|
54
|
+
continue;
|
|
55
|
+
const recordPath = safeRecordPath(join(sessionDir, name));
|
|
56
|
+
let batchId;
|
|
57
|
+
try {
|
|
58
|
+
batchId = input.readOne(recordPath).batchId;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
unreadable.push(recordPath);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (batchId === input.batchId)
|
|
65
|
+
recordPaths.push(recordPath);
|
|
66
|
+
}
|
|
67
|
+
return { sessionDir, recordPaths, unreadable };
|
|
68
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `share` action body for `peaks sub-agent`, moved out of
|
|
3
|
+
* `share-commands.ts` so that registrar file stays under the line cap.
|
|
4
|
+
*
|
|
5
|
+
* The registrar keeps the command shape (name, description, options) and
|
|
6
|
+
* delegates to `runShare` here. Every envelope field, error code, hint text and
|
|
7
|
+
* log entry is byte-identical to the pre-split version.
|
|
8
|
+
*/
|
|
9
|
+
import { fail, getErrorMessage, ok } from 'peaks-loop-shared/result';
|
|
10
|
+
import { SHARED_CHANNEL_SOFT_VALUE_WARN, writeSharedEntry } from 'peaks-loop-shared-channel';
|
|
11
|
+
import { printResult } from '../cli-helpers.js';
|
|
12
|
+
import { writeLogEntry } from '../../services/log/logger.js';
|
|
13
|
+
import { shareErrorNextActions } from './share-error-hints.js';
|
|
14
|
+
import { resolveSessionId } from './share-identity.js';
|
|
15
|
+
export function runShare(options, io) {
|
|
16
|
+
const asJson = options.json === true;
|
|
17
|
+
if (!options.batch || !options.key || !options.value) {
|
|
18
|
+
printResult(io, fail('sub-agent.share', 'MISSING_ARG', '--batch, --key, and --value are required', { ok: false }, ['Re-run with --batch <batchId> --key <key> --value <jsonObject>.']), asJson);
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const parsed = parseShareValue(options.value);
|
|
23
|
+
if (!parsed.ok) {
|
|
24
|
+
printResult(io, fail('sub-agent.share', 'INVALID_VALUE', `value must be a JSON object: ${parsed.message}`, { ok: false }, ['Pass --value as a JSON object literal, e.g. --value \'{"reason":"x"}\'.']), asJson);
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
writeShareEntry({
|
|
29
|
+
options,
|
|
30
|
+
io,
|
|
31
|
+
asJson,
|
|
32
|
+
batch: options.batch,
|
|
33
|
+
key: options.key,
|
|
34
|
+
parsedValue: parsed.value
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse `--value`, which must be a JSON object literal. Mirrors the original
|
|
39
|
+
* inline parse: a parse failure and a non-object parse both surface as
|
|
40
|
+
* `INVALID_VALUE` carrying the thrown message.
|
|
41
|
+
*/
|
|
42
|
+
function parseShareValue(raw) {
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(raw);
|
|
45
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
46
|
+
throw new Error('value must be a JSON object');
|
|
47
|
+
}
|
|
48
|
+
return { ok: true, value: parsed };
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return { ok: false, message: getErrorMessage(err) };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function resolveShareIdentity(options, projectRoot) {
|
|
55
|
+
return {
|
|
56
|
+
sid: resolveSessionId(options, projectRoot),
|
|
57
|
+
rid: options.requestId ?? 'unknown-rid',
|
|
58
|
+
from: options.from ?? 'unknown-role'
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function writeShareEntry(input) {
|
|
62
|
+
try {
|
|
63
|
+
const projectRoot = input.options.project ?? process.cwd();
|
|
64
|
+
const { sid, rid, from } = resolveShareIdentity(input.options, projectRoot);
|
|
65
|
+
const result = writeSharedEntry({
|
|
66
|
+
projectRoot,
|
|
67
|
+
sid,
|
|
68
|
+
rid,
|
|
69
|
+
batchId: input.batch,
|
|
70
|
+
key: input.key,
|
|
71
|
+
from,
|
|
72
|
+
value: input.parsedValue
|
|
73
|
+
});
|
|
74
|
+
if (!result.ok) {
|
|
75
|
+
reportShareFailure(result, input.batch, input.io, input.asJson);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
printShareSuccess({
|
|
79
|
+
result,
|
|
80
|
+
batch: input.batch,
|
|
81
|
+
key: input.key,
|
|
82
|
+
io: input.io,
|
|
83
|
+
asJson: input.asJson
|
|
84
|
+
});
|
|
85
|
+
logShareWrite({
|
|
86
|
+
sid,
|
|
87
|
+
batchId: input.batch,
|
|
88
|
+
key: input.key,
|
|
89
|
+
valueSize: result.entry.valueSize,
|
|
90
|
+
lastWriteWins: result.lastWriteWins
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
reportShareError(error, input.batch, input.io, input.asJson);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Report a thrown share failure, mapping a missing error code to `SHARE_ERROR`. */
|
|
98
|
+
function reportShareError(error, batch, io, asJson) {
|
|
99
|
+
const code = error.code ?? 'SHARE_ERROR';
|
|
100
|
+
printResult(io, fail('sub-agent.share', code, getErrorMessage(error), { ok: false, batchId: batch }, [
|
|
101
|
+
shareErrorNextActions(code)
|
|
102
|
+
]), asJson);
|
|
103
|
+
process.exitCode = 1;
|
|
104
|
+
}
|
|
105
|
+
function reportShareFailure(result, batch, io, asJson) {
|
|
106
|
+
const code = result.code;
|
|
107
|
+
printResult(io, fail('sub-agent.share', code, result.message, { ok: false, batchId: batch }, [
|
|
108
|
+
code === 'VALUE_TOO_LARGE'
|
|
109
|
+
? 'Reduce value size; 1KB is a soft warning, 64KB is a hard reject.'
|
|
110
|
+
: 'See error message; check --batch, --key, --value arguments.'
|
|
111
|
+
]), asJson);
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
}
|
|
114
|
+
function printShareSuccess(input) {
|
|
115
|
+
const warnings = [];
|
|
116
|
+
if (input.result.lastWriteWins) {
|
|
117
|
+
warnings.push('LAST_WRITE_WINS');
|
|
118
|
+
}
|
|
119
|
+
if (input.result.softWarning) {
|
|
120
|
+
warnings.push(`VALUE_SIZE_SOFT_WARN: ${input.result.entry.valueSize} > ${SHARED_CHANNEL_SOFT_VALUE_WARN} bytes`);
|
|
121
|
+
}
|
|
122
|
+
printResult(input.io, ok('sub-agent.share', {
|
|
123
|
+
envelopeVersion: '2.1.0',
|
|
124
|
+
ok: true,
|
|
125
|
+
batchId: input.batch,
|
|
126
|
+
entryKey: input.key,
|
|
127
|
+
writtenAt: input.result.entry.at,
|
|
128
|
+
channelSize: input.result.channelSize,
|
|
129
|
+
lastWriteWins: input.result.lastWriteWins,
|
|
130
|
+
valueSize: input.result.entry.valueSize
|
|
131
|
+
}, warnings, [
|
|
132
|
+
'Sub-agents in the same batch can read this entry via `peaks sub-agent shared-read --batch ' +
|
|
133
|
+
input.batch +
|
|
134
|
+
'`.'
|
|
135
|
+
]), input.asJson);
|
|
136
|
+
}
|
|
137
|
+
function logShareWrite(input) {
|
|
138
|
+
try {
|
|
139
|
+
writeLogEntry({
|
|
140
|
+
ts: new Date().toISOString(),
|
|
141
|
+
level: 'info',
|
|
142
|
+
command: 'sub-agent.share',
|
|
143
|
+
msg: 'shared',
|
|
144
|
+
sessionId: input.sid,
|
|
145
|
+
batchId: input.batchId,
|
|
146
|
+
data: {
|
|
147
|
+
batchId: input.batchId,
|
|
148
|
+
key: input.key,
|
|
149
|
+
valueSize: input.valueSize,
|
|
150
|
+
lastWriteWins: input.lastWriteWins
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
|
|
156
|
+
/* best-effort */
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `shared-read` action body for `peaks sub-agent`, split out of
|
|
3
|
+
* `share-runners.ts` to keep each module under the line cap. The registrar in
|
|
4
|
+
* `share-commands.ts` delegates here; the envelope, error code and hint text are
|
|
5
|
+
* byte-identical to the pre-split version.
|
|
6
|
+
*/
|
|
7
|
+
import { fail, getErrorMessage, ok } from 'peaks-loop-shared/result';
|
|
8
|
+
import { readSharedChannel } from 'peaks-loop-shared-channel';
|
|
9
|
+
import { printResult } from '../cli-helpers.js';
|
|
10
|
+
import { sharedReadErrorNextActions } from './share-error-hints.js';
|
|
11
|
+
import { resolveSessionId } from './share-identity.js';
|
|
12
|
+
export function runSharedRead(options, io) {
|
|
13
|
+
const asJson = options.json === true;
|
|
14
|
+
if (!options.batch) {
|
|
15
|
+
printResult(io, fail('sub-agent.shared-read', 'MISSING_BATCH', '--batch is required', { ok: false }, ['Re-run with --batch <batchId>.']), asJson);
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
printSharedReadSuccess(options, options.batch, io, asJson);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const code = error.code ?? 'SHARED_READ_ERROR';
|
|
24
|
+
printResult(io, fail('sub-agent.shared-read', code, getErrorMessage(error), { ok: false, batchId: options.batch }, [sharedReadErrorNextActions(code)]), asJson);
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function printSharedReadSuccess(options, batch, io, asJson) {
|
|
29
|
+
const projectRoot = options.project ?? process.cwd();
|
|
30
|
+
const sid = resolveSessionId(options, projectRoot);
|
|
31
|
+
const rid = options.requestId ?? 'unknown-rid';
|
|
32
|
+
const channel = readSharedChannel({
|
|
33
|
+
projectRoot,
|
|
34
|
+
sid,
|
|
35
|
+
rid,
|
|
36
|
+
batchId: batch,
|
|
37
|
+
...(options.since !== undefined ? { since: options.since } : {}),
|
|
38
|
+
...(options.key !== undefined ? { keyPattern: options.key } : {})
|
|
39
|
+
});
|
|
40
|
+
printResult(io, ok('sub-agent.shared-read', {
|
|
41
|
+
envelopeVersion: '2.1.0',
|
|
42
|
+
ok: true,
|
|
43
|
+
batchId: batch,
|
|
44
|
+
entries: channel.entries,
|
|
45
|
+
totalEntries: Object.keys(channel.entries).length,
|
|
46
|
+
channelSize: JSON.stringify(channel).length,
|
|
47
|
+
updatedAt: channel.updatedAt
|
|
48
|
+
}, [], [
|
|
49
|
+
'Shared channel is dispatcher-mediated; do not attempt to read sibling dispatch records directly.'
|
|
50
|
+
]), asJson);
|
|
51
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { resolveCanonicalProjectRoot } from '../../services/config/config-service.js';
|
|
2
|
+
import { sliceCheck } from '../../services/slice/slice-check-service.js';
|
|
3
|
+
import { fail, ok } from 'peaks-loop-shared/result';
|
|
4
|
+
import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
|
|
5
|
+
const CHECK_DESCRIPTION = 'Boundary check for a slice (post-micro-cycle, pre-peaks-qa). ' +
|
|
6
|
+
'Runs 4 stages in order: typecheck -> unit-tests (changed-only by default; ' +
|
|
7
|
+
'use --run-tests for the full suite, or --skip-tests to opt out) -> ' +
|
|
8
|
+
'review-fanout -> gate-verify-pipeline. ' +
|
|
9
|
+
'Each stage reports pass / fail / skipped. ' +
|
|
10
|
+
'Exit 0 only if every stage passes or is skipped.';
|
|
11
|
+
const CHECK_PROJECT_HELP = 'target project root';
|
|
12
|
+
const CHECK_RID_HELP = 'request id; REQUIRED — there is no binding to fall back to, and slice check fails without it';
|
|
13
|
+
const CHECK_REFRESH_FANOUT_HELP = 're-run the 3-way review fan-out (peaks-rd) even if the review files already exist';
|
|
14
|
+
const CHECK_RUN_TESTS_HELP = 'opt in to the FULL test suite at the boundary (default is the changed-only suite via `vitest run --changed`); use the peaks-test skill to run the full suite standalone';
|
|
15
|
+
const CHECK_SKIP_TESTS_HELP = 'skip the unit-test stage entirely (e.g. docs-only slices); use the peaks-test skill to run the full suite manually if you want a separate check';
|
|
16
|
+
const CHECK_ALLOW_PRE_EXISTING_HELP = 'opt-in: if the unit-test stage fails, report it as `skipped` with a reason naming the failure count (useful when the repo has unrelated pre-existing failures; the long-term fix is to .skip or coverage.exclude those tests). Only meaningful with --run-tests or the default changed-only mode.';
|
|
17
|
+
async function runSliceCheck(options, io) {
|
|
18
|
+
try {
|
|
19
|
+
const projectRoot = resolveCanonicalProjectRoot(options.project);
|
|
20
|
+
const result = await sliceCheck({
|
|
21
|
+
projectRoot,
|
|
22
|
+
...(options.rid ? { rid: options.rid } : {}),
|
|
23
|
+
refreshFanout: options.refreshFanout === true,
|
|
24
|
+
runTests: options.runTests === true,
|
|
25
|
+
skipTests: options.skipTests === true,
|
|
26
|
+
allowPreExistingFailures: options.allowPreExistingFailures === true
|
|
27
|
+
});
|
|
28
|
+
const warnings = [];
|
|
29
|
+
if (result.stages.some((s) => s.status === 'fail')) {
|
|
30
|
+
warnings.push(`${result.stages.filter((s) => s.status === 'fail').length} of ${result.stages.length} stages failed. 边界 NOT ready -- fix the failures and re-run, or proceed at your own risk.`);
|
|
31
|
+
}
|
|
32
|
+
printResult(io, ok('slice.check', result, warnings, result.nextActions), options.json ?? false);
|
|
33
|
+
if (!result.boundaryReady) {
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
printResult(io, fail('slice.check', 'SLICE_CHECK_FAILED', getErrorMessage(error), { projectRoot: options.project }, [
|
|
39
|
+
`Verify the project path is a peaks repo and --rid names a slice (letters, digits, dots, underscores or dashes): ${options.rid ?? '(no --rid given)'}`
|
|
40
|
+
]), options.json ?? false);
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function registerSliceCheckCommand(slice, io) {
|
|
45
|
+
addJsonOption(slice
|
|
46
|
+
.command('check')
|
|
47
|
+
.description(CHECK_DESCRIPTION)
|
|
48
|
+
.option('--project <path>', CHECK_PROJECT_HELP, '.')
|
|
49
|
+
.option('--rid <rid>', CHECK_RID_HELP)
|
|
50
|
+
.option('--refresh-fanout', CHECK_REFRESH_FANOUT_HELP, false)
|
|
51
|
+
.option('--run-tests', CHECK_RUN_TESTS_HELP, false)
|
|
52
|
+
.option('--skip-tests', CHECK_SKIP_TESTS_HELP, false)
|
|
53
|
+
.option('--allow-pre-existing-failures', CHECK_ALLOW_PRE_EXISTING_HELP, false)).action((options) => runSliceCheck(options, io));
|
|
54
|
+
}
|
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import type { ProgramIO } from '../cli-helpers.js';
|
|
3
|
+
export { parsePickedFile } from './slice-plan-command.js';
|
|
3
4
|
export declare function registerSliceCommands(program: Command, io: ProgramIO): void;
|
|
4
|
-
interface PickedEnvelope {
|
|
5
|
-
readonly rid: string;
|
|
6
|
-
readonly picked: readonly {
|
|
7
|
-
readonly rid: string;
|
|
8
|
-
readonly files: readonly string[];
|
|
9
|
-
readonly label: string;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Validate a -picked.json envelope. Throws a CLI-friendly Error on any
|
|
14
|
-
* shape violation; the catch in the slice.plan action converts it to
|
|
15
|
-
* a fail() envelope with `code: 'PICKED_ENVELOPE_INVALID'`.
|
|
16
|
-
*
|
|
17
|
-
* Schema:
|
|
18
|
-
* { rid: string; picked: Array<{ rid, files: string[], label }> }
|
|
19
|
-
*
|
|
20
|
-
* Rejects: missing rid, missing/invalid picked array, picked[i] missing
|
|
21
|
-
* rid / files / label, picked[i].files empty.
|
|
22
|
-
*/
|
|
23
|
-
export declare function parsePickedFile(pickedPath: string): PickedEnvelope;
|
|
24
|
-
export {};
|