peaks-loop 4.0.0-beta.9 → 4.0.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/CHANGELOG.md +910 -141
- package/README-en.md +26 -7
- package/README.md +75 -6
- package/agents/karpathy-reviewer.md +33 -0
- package/bin/peaks.js +0 -0
- package/dist/cli/cli-helpers.d.ts +31 -6
- package/dist/cli/cli-helpers.js +48 -25
- package/dist/cli/commands/_register.d.ts +3 -0
- package/dist/cli/commands/_register.js +139 -0
- package/dist/cli/commands/_super.d.ts +10 -0
- package/dist/cli/commands/_super.js +97 -0
- package/dist/cli/commands/adapter-commands-s2a.js +1 -1
- package/dist/cli/commands/asset-commands.js +33 -16
- package/dist/cli/commands/audit-commands.js +2 -2
- package/dist/cli/commands/autonomous-swarm-commands.d.ts +12 -0
- package/dist/cli/commands/autonomous-swarm-commands.js +120 -0
- package/dist/cli/commands/bee-commands.js +1 -1
- package/dist/cli/commands/capability-commands.js +1 -1
- package/dist/cli/commands/capability-worker-config-sc-commands.js +0 -2
- package/dist/cli/commands/changeset-commands.d.ts +13 -0
- package/dist/cli/commands/changeset-commands.js +46 -0
- package/dist/cli/commands/code-commands.d.ts +11 -1
- package/dist/cli/commands/code-commands.js +19 -699
- package/dist/cli/commands/code-job-shape-commands.d.ts +9 -0
- package/dist/cli/commands/code-job-shape-commands.js +164 -0
- package/dist/cli/commands/code-mode-gate-commands.d.ts +9 -0
- package/dist/cli/commands/code-mode-gate-commands.js +223 -0
- package/dist/cli/commands/code-review-commands.js +2 -2
- package/dist/cli/commands/code-run-command.d.ts +12 -0
- package/dist/cli/commands/code-run-command.js +68 -0
- package/dist/cli/commands/code-runtime-commands.d.ts +11 -0
- package/dist/cli/commands/code-runtime-commands.js +391 -0
- package/dist/cli/commands/codegraph-commands.js +1 -1
- package/dist/cli/commands/compact-command.js +53 -1
- package/dist/cli/commands/complexity-commands.js +1 -1
- package/dist/cli/commands/config-commands.js +4 -75
- package/dist/cli/commands/container-commands.d.ts +28 -0
- package/dist/cli/commands/container-commands.js +221 -0
- package/dist/cli/commands/context-commands.js +3 -2
- package/dist/cli/commands/core/artifacts-command.js +1 -1
- package/dist/cli/commands/core/binding-commands.js +1 -1
- package/dist/cli/commands/core/doctor-command.js +63 -3
- package/dist/cli/commands/core/memory-command.js +1 -1
- package/dist/cli/commands/core/profile-command.js +1 -1
- package/dist/cli/commands/core/proxy-command.js +1 -1
- package/dist/cli/commands/core/session-command.js +9 -7
- package/dist/cli/commands/core/skill-command.js +7 -4
- package/dist/cli/commands/core/standards-command.js +1 -1
- package/dist/cli/commands/cron-commands.d.ts +57 -0
- package/dist/cli/commands/cron-commands.js +257 -0
- package/dist/cli/commands/cron-scheduler-commands.d.ts +47 -0
- package/dist/cli/commands/cron-scheduler-commands.js +284 -0
- package/dist/cli/commands/dashboard-commands.d.ts +4 -0
- package/dist/cli/commands/dashboard-commands.js +10 -0
- package/dist/cli/commands/dashboard-long-run.d.ts +25 -0
- package/dist/cli/commands/dashboard-long-run.js +122 -0
- package/dist/cli/commands/dashboard-summary.d.ts +12 -0
- package/dist/cli/commands/dashboard-summary.js +58 -0
- package/dist/cli/commands/dispatch-commands.d.ts +0 -7
- package/dist/cli/commands/dispatch-commands.js +372 -8
- package/dist/cli/commands/dispatch-from-dag.js +4 -1
- package/dist/cli/commands/doc-commands.js +1 -1
- package/dist/cli/commands/ecc-commands.d.ts +30 -0
- package/dist/cli/commands/ecc-commands.js +119 -0
- package/dist/cli/commands/evolution-commands.js +1 -1
- package/dist/cli/commands/feedback-commands.js +1 -1
- package/dist/cli/commands/final-review-commands.js +1 -1
- package/dist/cli/commands/fixture-commands.js +1 -1
- package/dist/cli/commands/fork-commands.js +1 -1
- package/dist/cli/commands/gate-commands.js +128 -6
- package/dist/cli/commands/governance-classify-contract-commands.d.ts +21 -0
- package/dist/cli/commands/governance-classify-contract-commands.js +273 -0
- package/dist/cli/commands/heartbeat-commands.js +76 -5
- package/dist/cli/commands/heartbeat-watch-command.d.ts +31 -0
- package/dist/cli/commands/heartbeat-watch-command.js +146 -0
- package/dist/cli/commands/hook-handle.js +1 -1
- package/dist/cli/commands/hooks-commands.js +126 -10
- package/dist/cli/commands/ide-commands.js +1 -1
- package/dist/cli/commands/impact-commands.js +1 -1
- package/dist/cli/commands/job-commands.js +34 -1
- package/dist/cli/commands/lease-metrics-commands.d.ts +67 -0
- package/dist/cli/commands/lease-metrics-commands.js +231 -0
- package/dist/cli/commands/lease-stats-commands.d.ts +65 -0
- package/dist/cli/commands/lease-stats-commands.js +107 -0
- package/dist/cli/commands/legacy-commands.js +1 -1
- package/dist/cli/commands/log-commands.js +1 -1
- package/dist/cli/commands/loop-commands.js +1 -1
- package/dist/cli/commands/loop-eval-commands.js +1 -1
- package/dist/cli/commands/memory-commands.js +1 -1
- package/dist/cli/commands/migrate-1-4-1-command.js +1 -1
- package/dist/cli/commands/migrate-v2-10-to-v2-11-command.js +1 -1
- package/dist/cli/commands/mut-commands.d.ts +1 -1
- package/dist/cli/commands/mut-commands.js +1 -5
- package/dist/cli/commands/observability-commands.js +1 -1
- package/dist/cli/commands/openspec-commands.js +65 -4
- package/dist/cli/commands/perf-audit-commands.js +3 -3
- package/dist/cli/commands/perf-commands.js +1 -1
- package/dist/cli/commands/polyrepo-commands.js +1 -1
- package/dist/cli/commands/prd-blocks-commands.js +1 -1
- package/dist/cli/commands/prd-commands.js +4 -2
- package/dist/cli/commands/preferences-commands.js +23 -3
- package/dist/cli/commands/project-commands.js +1 -1
- package/dist/cli/commands/qa-business-review-commands.js +1 -1
- package/dist/cli/commands/qa-commands.d.ts +1 -1
- package/dist/cli/commands/qa-commands.js +39 -3
- package/dist/cli/commands/release-commands.d.ts +15 -0
- package/dist/cli/commands/release-commands.js +113 -21
- package/dist/cli/commands/request-commands.js +1 -1
- package/dist/cli/commands/retrospective-commands.js +1 -1
- package/dist/cli/commands/reviewer-commands.js +1 -1
- package/dist/cli/commands/role-commands.js +1 -1
- package/dist/cli/commands/runtime-commands-helpers.d.ts +7 -0
- package/dist/cli/commands/runtime-commands-helpers.js +24 -0
- package/dist/cli/commands/runtime-commands.js +1 -2
- package/dist/cli/commands/sc-commands.js +4 -2
- package/dist/cli/commands/scan-commands.js +1 -1
- package/dist/cli/commands/security-audit-commands.js +3 -3
- package/dist/cli/commands/sediment-commands.js +10 -1
- package/dist/cli/commands/session-24h-mode.d.ts +26 -0
- package/dist/cli/commands/session-24h-mode.js +196 -0
- package/dist/cli/commands/share-commands.d.ts +19 -0
- package/dist/cli/commands/share-commands.js +121 -2
- package/dist/cli/commands/skill-conformance-commands.js +1 -1
- package/dist/cli/commands/skill-loop-engineering-readiness-commands.js +1 -1
- package/dist/cli/commands/skill-search-commands.js +4 -1
- package/dist/cli/commands/slice-commands.js +1 -1
- package/dist/cli/commands/slice-integrate-commands.js +1 -1
- package/dist/cli/commands/slice-review-commands.js +1 -1
- package/dist/cli/commands/smoke-commands.js +1 -1
- package/dist/cli/commands/sop-commands.js +1 -1
- package/dist/cli/commands/spill-demo-command.d.ts +7 -0
- package/dist/cli/commands/spill-demo-command.js +29 -0
- package/dist/cli/commands/statusline-commands.d.ts +12 -0
- package/dist/cli/commands/statusline-commands.js +79 -17
- package/dist/cli/commands/sub-agent-commands.js +2 -1
- package/dist/cli/commands/sub-agent-shared.d.ts +10 -0
- package/dist/cli/commands/sub-agent-shared.js +24 -1
- package/dist/cli/commands/swarm-commands.d.ts +13 -0
- package/dist/cli/commands/swarm-commands.js +77 -0
- package/dist/cli/commands/tech-commands.d.ts +64 -0
- package/dist/cli/commands/tech-commands.js +195 -0
- package/dist/cli/commands/understand-commands.js +1 -1
- package/dist/cli/commands/upgrade-commands.d.ts +2 -0
- package/dist/cli/commands/upgrade-commands.js +40 -5
- package/dist/cli/commands/user-touchpoint-commands.js +1 -1
- package/dist/cli/commands/verdict-aggregate-command.js +1 -1
- package/dist/cli/commands/vm-commands.d.ts +31 -0
- package/dist/cli/commands/vm-commands.js +274 -0
- package/dist/cli/commands/workflow-commands.js +24 -1
- package/dist/cli/commands/workflow-plan-commands.js +1 -1
- package/dist/cli/commands/workspace/init-command.js +1 -1
- package/dist/cli/commands/workspace/migrate-command.js +1 -1
- package/dist/cli/commands/workspace/reconcile-command.js +1 -1
- package/dist/cli/commands/worktree-auth-commands.d.ts +29 -0
- package/dist/cli/commands/worktree-auth-commands.js +652 -0
- package/dist/cli/index.js +58 -13
- package/dist/cli/program.d.ts +2 -2
- package/dist/cli/program.js +86 -281
- package/dist/services/24h-mode/decider.d.ts +103 -0
- package/dist/services/24h-mode/decider.js +144 -0
- package/dist/services/24h-mode/index.d.ts +12 -0
- package/dist/services/24h-mode/index.js +12 -0
- package/dist/services/24h-mode/state.d.ts +48 -0
- package/dist/services/24h-mode/state.js +51 -0
- package/dist/services/24h-mode/store.d.ts +27 -0
- package/dist/services/24h-mode/store.js +119 -0
- package/dist/services/artifacts/artifact-prerequisites.js +1 -1
- package/dist/services/artifacts/request-artifact-service.js +1 -1
- package/dist/services/artifacts/workspace-service.js +1 -1
- package/dist/services/audit/enforcers/lint-bee-runtime-contract.d.ts +25 -0
- package/dist/services/audit/enforcers/lint-bee-runtime-contract.js +91 -0
- package/dist/services/audit/enforcers/lint-peaks-code-runtime.d.ts +16 -0
- package/dist/services/audit/enforcers/lint-peaks-code-runtime.js +31 -0
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +23 -0
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +59 -0
- package/dist/services/audit/enforcers/lint-peaks-ui-sc-txt-runtime.d.ts +28 -0
- package/dist/services/audit/enforcers/lint-peaks-ui-sc-txt-runtime.js +86 -0
- package/dist/services/audit/enforcers/lint-prd-artifact-handoff.d.ts +16 -0
- package/dist/services/audit/enforcers/lint-prd-artifact-handoff.js +41 -0
- package/dist/services/audit/enforcers/lint-prd-source-snapshot.d.ts +27 -0
- package/dist/services/audit/enforcers/lint-prd-source-snapshot.js +47 -0
- package/dist/services/audit/enforcers/lint-qa-gateguard-and-runtime.d.ts +19 -0
- package/dist/services/audit/enforcers/lint-qa-gateguard-and-runtime.js +47 -0
- package/dist/services/audit/enforcers/lint-rd-handoff-coverage.d.ts +18 -0
- package/dist/services/audit/enforcers/lint-rd-handoff-coverage.js +70 -0
- package/dist/services/audit/enforcers/lint-skill-presence-mandatory.d.ts +25 -0
- package/dist/services/audit/enforcers/lint-skill-presence-mandatory.js +53 -0
- package/dist/services/audit/red-line-catalog-p2-a.d.ts +0 -6
- package/dist/services/audit/red-line-catalog-p2-a.js +230 -1
- package/dist/services/audit/static-service.d.ts +32 -25
- package/dist/services/audit/static-service.js +30 -109
- package/dist/services/audit-independent/index.d.ts +2 -0
- package/dist/services/audit-independent/index.js +2 -0
- package/dist/services/autonomous-swarm/autonomous-swarm-service.d.ts +127 -0
- package/dist/services/autonomous-swarm/autonomous-swarm-service.js +446 -0
- package/dist/services/changeset/changeset-check-service.d.ts +22 -0
- package/dist/services/changeset/changeset-check-service.js +47 -0
- package/dist/services/code/auto-compact-modes.d.ts +30 -0
- package/dist/services/code/auto-compact-modes.js +38 -0
- package/dist/services/code/auto-compact-orchestrator.d.ts +43 -5
- package/dist/services/code/auto-compact-orchestrator.js +101 -21
- package/dist/services/code/dag-orchestrator.d.ts +30 -1
- package/dist/services/code/dag-orchestrator.js +106 -1
- package/dist/services/code/status-line-renderer.d.ts +2 -0
- package/dist/services/code/status-line-renderer.js +21 -3
- package/dist/services/code-review/ocr-service.d.ts +1 -1
- package/dist/services/code-review/ocr-service.js +6 -3
- package/dist/services/compact-history/compact-history-service.d.ts +41 -0
- package/dist/services/compact-history/compact-history-service.js +62 -0
- package/dist/services/compact-statusline/compact-statusline-service.d.ts +16 -0
- package/dist/services/compact-statusline/compact-statusline-service.js +83 -0
- package/dist/services/config/config-service.d.ts +1 -12
- package/dist/services/config/config-service.js +3 -72
- package/dist/services/config/config-types.d.ts +2 -4
- package/dist/services/config/config-types.js +1 -1
- package/dist/services/container/container-lease.d.ts +67 -0
- package/dist/services/container/container-lease.js +135 -0
- package/dist/services/context/auto-compact-dispatcher.d.ts +40 -5
- package/dist/services/context/auto-compact-dispatcher.js +32 -102
- package/dist/services/context/auto-compact-reader.js +1 -1
- package/dist/services/context/auto-compact-types.d.ts +27 -2
- package/dist/services/context/auto-compact-types.js +8 -1
- package/dist/services/context/build-dispatch-system-prompt.d.ts +75 -0
- package/dist/services/context/build-dispatch-system-prompt.js +117 -0
- package/dist/services/context/collector.d.ts +2 -2
- package/dist/services/context/context-builder.d.ts +4 -4
- package/dist/services/context/context-schema.d.ts +48 -48
- package/dist/services/context/ide-detect.d.ts +4 -0
- package/dist/services/context/ide-detect.js +24 -0
- package/dist/services/context/main-session-monitor.d.ts +1 -4
- package/dist/services/context/main-session-monitor.js +1 -24
- package/dist/services/context/memory-index-reader.d.ts +8 -0
- package/dist/services/context/memory-index-reader.js +57 -0
- package/dist/services/context/memory-lru-cache.d.ts +12 -0
- package/dist/services/context/memory-lru-cache.js +60 -0
- package/dist/services/context/memory-preflight-config.d.ts +19 -0
- package/dist/services/context/memory-preflight-config.js +25 -0
- package/dist/services/context/memory-preflight-service.d.ts +19 -0
- package/dist/services/context/memory-preflight-service.js +120 -0
- package/dist/services/context/spillover-store.d.ts +23 -0
- package/dist/services/context/spillover-store.js +155 -0
- package/dist/services/context/spillover-types.d.ts +18 -0
- package/dist/services/context/spillover-types.js +1 -0
- package/dist/services/crystallization/crystallization-service.d.ts +22 -5
- package/dist/services/crystallization/crystallization-service.js +8 -14
- package/dist/services/crystallization/crystallization-types.d.ts +6 -6
- package/dist/services/crystallization/evidence-brief-builder.d.ts +1 -1
- package/dist/services/crystallization/index.d.ts +13 -0
- package/dist/services/crystallization/index.js +13 -0
- package/dist/services/dashboard/project-dashboard-service.js +2 -2
- package/dist/services/dispatch/await-batch.d.ts +70 -0
- package/dist/services/dispatch/await-batch.js +272 -0
- package/dist/services/dispatch/batch-counter.js +1 -1
- package/dist/services/dispatch/dispatch-record-writer.d.ts +126 -4
- package/dist/services/dispatch/dispatch-record-writer.js +239 -9
- package/dist/services/dispatch/slice-dag.d.ts +46 -0
- package/dist/services/dispatch/slice-dag.js +6 -0
- package/dist/services/dispatch/stage-enum.d.ts +27 -0
- package/dist/services/dispatch/stage-enum.js +48 -0
- package/dist/services/dispatch/startup-timeout.d.ts +86 -0
- package/dist/services/dispatch/startup-timeout.js +97 -0
- package/dist/services/dispatch/sub-agent-dispatcher.js +40 -89
- package/dist/services/dispatch/test-tool-detection.d.ts +25 -1
- package/dist/services/dispatch/test-tool-detection.js +80 -0
- package/dist/services/doctor/doctor-service/checks/check-id-schema.d.ts +18 -0
- package/dist/services/doctor/doctor-service/checks/check-id-schema.js +64 -0
- package/dist/services/doctor/doctor-service/checks/codegraph-capability.d.ts +14 -0
- package/dist/services/doctor/doctor-service/checks/codegraph-capability.js +69 -0
- package/dist/services/doctor/doctor-service/checks/dist-source-version.d.ts +32 -0
- package/dist/services/doctor/doctor-service/checks/dist-source-version.js +110 -0
- package/dist/services/doctor/doctor-service/checks/gateguard-conflict.d.ts +24 -0
- package/dist/services/doctor/doctor-service/checks/gateguard-conflict.js +164 -0
- package/dist/services/doctor/doctor-service/checks/l3-memory-health.d.ts +16 -0
- package/dist/services/doctor/doctor-service/checks/l3-memory-health.js +57 -0
- package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.d.ts +19 -0
- package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.js +66 -0
- package/dist/services/doctor/doctor-service/checks/schema-validity.d.ts +10 -0
- package/dist/services/doctor/doctor-service/checks/schema-validity.js +33 -0
- package/dist/services/doctor/doctor-service/checks/skill-apply-note.d.ts +20 -0
- package/dist/services/doctor/doctor-service/checks/skill-apply-note.js +85 -0
- package/dist/services/doctor/doctor-service/checks/skill-existence.d.ts +13 -0
- package/dist/services/doctor/doctor-service/checks/skill-existence.js +30 -0
- package/dist/services/doctor/doctor-service/checks/skill-name-match.d.ts +10 -0
- package/dist/services/doctor/doctor-service/checks/skill-name-match.js +25 -0
- package/dist/services/doctor/doctor-service/checks/skill-parse.d.ts +10 -0
- package/dist/services/doctor/doctor-service/checks/skill-parse.js +19 -0
- package/dist/services/doctor/doctor-service/checks/skill-presence.d.ts +21 -0
- package/dist/services/doctor/doctor-service/checks/skill-presence.js +75 -0
- package/dist/services/doctor/doctor-service/checks/skill-runbook.d.ts +14 -0
- package/dist/services/doctor/doctor-service/checks/skill-runbook.js +47 -0
- package/dist/services/doctor/doctor-service/checks/statusline-install.d.ts +14 -0
- package/dist/services/doctor/doctor-service/checks/statusline-install.js +32 -0
- package/dist/services/doctor/doctor-service/checks/statusline-runtime.d.ts +13 -0
- package/dist/services/doctor/doctor-service/checks/statusline-runtime.js +30 -0
- package/dist/services/doctor/doctor-service/checks/user-config.d.ts +11 -0
- package/dist/services/doctor/doctor-service/checks/user-config.js +27 -0
- package/dist/services/doctor/doctor-service/checks/workspace-init.d.ts +16 -0
- package/dist/services/doctor/doctor-service/checks/workspace-init.js +34 -0
- package/dist/services/doctor/doctor-service/checks/workspace-layout.d.ts +33 -0
- package/dist/services/doctor/doctor-service/checks/workspace-layout.js +180 -0
- package/dist/services/doctor/doctor-service/index.d.ts +48 -0
- package/dist/services/doctor/doctor-service/index.js +254 -0
- package/dist/services/doctor/doctor-service/plugin-registry.d.ts +41 -0
- package/dist/services/doctor/doctor-service/plugin-registry.js +77 -0
- package/dist/services/doctor/doctor-service/report/final-summary.d.ts +20 -0
- package/dist/services/doctor/doctor-service/report/final-summary.js +29 -0
- package/dist/services/doctor/doctor-service/types.d.ts +245 -0
- package/dist/services/doctor/doctor-service/types.js +15 -0
- package/dist/services/doctor/doctor-service.d.ts +15 -146
- package/dist/services/doctor/doctor-service.js +22 -926
- package/dist/services/doctor/index.d.ts +22 -0
- package/dist/services/doctor/index.js +22 -0
- package/dist/services/env/shell-probe.d.ts +71 -0
- package/dist/services/env/shell-probe.js +161 -0
- package/dist/services/evolution/evolution-types.d.ts +39 -39
- package/dist/services/final-review/final-review-service.d.ts +11 -1
- package/dist/services/final-review/index.d.ts +2 -0
- package/dist/services/final-review/index.js +1 -0
- package/dist/services/hooks/auto-compact-hook-install.d.ts +4 -5
- package/dist/services/hooks/auto-compact-hook-install.js +4 -5
- package/dist/services/hooks/worktree-authorization-gate.d.ts +205 -0
- package/dist/services/hooks/worktree-authorization-gate.js +492 -0
- package/dist/services/ide/adapters/claude-code-adapter.js +2 -2
- package/dist/services/ide/adapters/qoder-adapter.d.ts +25 -0
- package/dist/services/ide/adapters/qoder-adapter.js +57 -0
- package/dist/services/ide/adapters/tongyi-lingma-adapter.d.ts +16 -0
- package/dist/services/ide/adapters/tongyi-lingma-adapter.js +45 -0
- package/dist/services/ide/ide-registry.js +6 -0
- package/dist/services/ide/ide-types.d.ts +1 -1
- package/dist/services/job/job-types.d.ts +56 -56
- package/dist/services/job-snapshot/index.d.ts +8 -0
- package/dist/services/job-snapshot/index.js +7 -0
- package/dist/services/{job/job-resource-snapshot.d.ts → job-snapshot/snapshot.d.ts} +1 -1
- package/dist/services/job-snapshot/types.d.ts +7 -0
- package/dist/services/job-snapshot/types.js +1 -0
- package/dist/services/karpathy-cost/karpathy-cost-check-service.d.ts +67 -0
- package/dist/services/karpathy-cost/karpathy-cost-check-service.js +108 -0
- package/dist/services/log/retention.d.ts +16 -0
- package/dist/services/log/retention.js +17 -0
- package/dist/services/loop/loop-bee-relation-types.d.ts +6 -6
- package/dist/services/loop/loop-release-types.d.ts +24 -24
- package/dist/services/loop/monotonic-runner.d.ts +17 -11
- package/dist/services/loop/monotonic-runner.js +118 -79
- package/dist/services/memory/project-memory-service/index/kind-dispatch.d.ts +8 -0
- package/dist/services/memory/project-memory-service/index/kind-dispatch.js +253 -0
- package/dist/services/memory/project-memory-service/index/ranking.d.ts +6 -0
- package/dist/services/memory/project-memory-service/index/ranking.js +171 -0
- package/dist/services/memory/project-memory-service/index/search.d.ts +34 -0
- package/dist/services/memory/project-memory-service/index/search.js +194 -0
- package/dist/services/memory/project-memory-service/index.d.ts +9 -0
- package/dist/services/memory/project-memory-service/index.js +24 -0
- package/dist/services/memory/project-memory-service/parsers/frontmatter.d.ts +9 -0
- package/dist/services/memory/project-memory-service/parsers/frontmatter.js +106 -0
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +7 -0
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +96 -0
- package/dist/services/memory/project-memory-service/store/atomic-write.d.ts +5 -0
- package/dist/services/memory/project-memory-service/store/atomic-write.js +56 -0
- package/dist/services/memory/project-memory-service/store/paths.d.ts +8 -0
- package/dist/services/memory/project-memory-service/store/paths.js +116 -0
- package/dist/services/memory/project-memory-service/types.d.ts +128 -0
- package/dist/services/memory/project-memory-service/types.js +9 -0
- package/dist/services/memory/project-memory-service.d.ts +1 -167
- package/dist/services/memory/project-memory-service.js +19 -816
- package/dist/services/migrate-skill-name/schema.d.ts +2 -2
- package/dist/services/observability/aggregation.d.ts +27 -0
- package/dist/services/observability/aggregation.js +72 -0
- package/dist/services/observability/observability-service.d.ts +73 -7
- package/dist/services/observability/observability-service.js +87 -1
- package/dist/services/openspec/artifact-boundary.d.ts +138 -0
- package/dist/services/openspec/artifact-boundary.js +150 -0
- package/dist/services/openspec/coverage-evidence-reader.d.ts +191 -0
- package/dist/services/openspec/coverage-evidence-reader.js +386 -0
- package/dist/services/openspec/openspec-archive-service.d.ts +70 -0
- package/dist/services/openspec/openspec-archive-service.js +320 -8
- package/dist/services/openspec/openspec-bridge-service.js +1 -1
- package/dist/services/openspec/openspec-init-service.js +1 -1
- package/dist/services/openspec/openspec-propose-from-doctor-service.js +1 -1
- package/dist/services/openspec/openspec-render-service.js +7 -4
- package/dist/services/openspec/openspec-scan-service.js +1 -1
- package/dist/services/openspec/openspec-validate-service.js +5 -4
- package/dist/services/preferences/preferences-service.js +10 -0
- package/dist/services/preferences/preferences-types.d.ts +13 -0
- package/dist/services/preferences/preferences-types.js +11 -0
- package/dist/services/qa/screenshot-archive-service.d.ts +51 -0
- package/dist/services/qa/screenshot-archive-service.js +134 -0
- package/dist/services/rd/rd-service.js +10 -11
- package/dist/services/rd/types.d.ts +32 -32
- package/dist/services/rd-swarm/rd-swarm-service.d.ts +60 -0
- package/dist/services/rd-swarm/rd-swarm-service.js +93 -0
- package/dist/services/recommendations/capability-seed-items.js +0 -1
- package/dist/services/recommendations/capability-seed-mappings.js +0 -1
- package/dist/services/recommendations/capability-seed-sources.js +0 -1
- package/dist/services/release/version-precheck-service.d.ts +51 -0
- package/dist/services/release/version-precheck-service.js +257 -0
- package/dist/services/scan/acceptance-coverage-service.js +1 -1
- package/dist/services/scan/archetype-service.js +1 -1
- package/dist/services/scan/existing-system-service.js +1 -1
- package/dist/services/scan/libraries-service.js +1 -1
- package/dist/services/sediment/json-schema.d.ts +40 -40
- package/dist/services/share/bundle-types.d.ts +12 -12
- package/dist/services/share/run-state-contract.d.ts +2 -2
- package/dist/services/skill/skill-search-service.d.ts +12 -7
- package/dist/services/skill/skill-search-service.js +8 -4
- package/dist/services/skillhub/migrations/001-initial.sql +71 -0
- package/dist/services/skillhub/migrations/002-loop-release.sql +32 -0
- package/dist/services/skillhub/migrations/003-loop-bee-relation.sql +35 -0
- package/dist/services/skillhub/migrations/004-loop-bee-extension.sql +65 -0
- package/dist/services/skillhub/migrations/005-evolution-evaluation.sql +81 -0
- package/dist/services/skillhub/migrations/006-crystallization-event.sql +92 -0
- package/dist/services/skills/hooks-settings-service.d.ts +75 -0
- package/dist/services/skills/hooks-settings-service.js +230 -2
- package/dist/services/skills/skill-registry.d.ts +1 -0
- package/dist/services/skills/skill-registry.js +6 -4
- package/dist/services/skills/skill-runbook-service.js +1 -1
- package/dist/services/slice/slice-check-service.js +1 -1
- package/dist/services/standards/main-session-monitor-ban-hook.d.ts +14 -0
- package/dist/services/standards/main-session-monitor-ban-hook.js +19 -0
- package/dist/services/standards/missing-standards-detector.d.ts +25 -0
- package/dist/services/standards/missing-standards-detector.js +43 -12
- package/dist/services/tech/tech-change-id-service.d.ts +82 -0
- package/dist/services/tech/tech-change-id-service.js +117 -0
- package/dist/services/understand/understand-hybrid-service.js +1 -1
- package/dist/services/understand/understand-scan-service.js +2 -2
- package/dist/services/upgrade/upgrade-service.js +4 -3
- package/dist/services/verdict/envelopes.d.ts +2 -2
- package/dist/services/verdict/envelopes.js +2 -2
- package/dist/services/verdict/verdict-aggregator.d.ts +3 -3
- package/dist/services/vm/vm-lease.d.ts +40 -0
- package/dist/services/vm/vm-lease.js +137 -0
- package/dist/services/workflow/autonomous-resume-writer.js +1 -1
- package/dist/services/workflow/pipeline-verify-gate-support.d.ts +47 -0
- package/dist/services/workflow/pipeline-verify-gate-support.js +194 -0
- package/dist/services/workflow/pipeline-verify-service.d.ts +17 -81
- package/dist/services/workflow/pipeline-verify-service.js +42 -218
- package/dist/services/workflow/pipeline-verify-types.d.ts +90 -0
- package/dist/services/workflow/pipeline-verify-types.js +10 -0
- package/dist/services/workflow/plan-reader.d.ts +1 -1
- package/dist/services/workflow/plan-reader.js +1 -1
- package/dist/services/workflow/plan-refresher.d.ts +1 -1
- package/dist/services/workflow/plan-refresher.js +1 -1
- package/dist/services/workflow/plan-trigger-detector.d.ts +1 -1
- package/dist/services/workflow/plan-trigger-detector.js +1 -1
- package/dist/services/workflow/workflow-autonomous-resume-helpers.d.ts +1 -1
- package/dist/services/workflow/workflow-autonomous-service.d.ts +2 -98
- package/dist/services/workflow/workflow-autonomous-types.d.ts +114 -0
- package/dist/services/workflow/workflow-autonomous-types.js +21 -0
- package/dist/services/workflow/workflow-router-service.js +18 -16
- package/dist/services/workflow/workflow-spec-lint.d.ts +13 -0
- package/dist/services/workflow/workflow-spec-lint.js +75 -0
- package/dist/services/workflow/workflow-spec-types.d.ts +100 -0
- package/dist/services/workflow/workflow-spec-types.js +13 -0
- package/dist/services/workflow/workflow-spec-yaml.d.ts +17 -0
- package/dist/services/workflow/workflow-spec-yaml.js +88 -0
- package/dist/services/workflow/workflow-spec.d.ts +11 -91
- package/dist/services/workflow/workflow-spec.js +16 -145
- package/dist/services/workspace/migrate-service.js +1 -1
- package/dist/services/workspace/workspace-service.js +1 -1
- package/dist/services/worktree/worktree-lease.d.ts +170 -0
- package/dist/services/worktree/worktree-lease.js +242 -0
- package/package.json +47 -51
- package/scripts/clean-dist.mjs +31 -1
- package/scripts/copy-templates.mjs +16 -0
- package/scripts/sync-version.mjs +53 -2
- package/skills/bee/peaks-perf-audit/SKILL.md +17 -0
- package/skills/bee/peaks-prd/SKILL.md +16 -0
- package/skills/bee/peaks-prd/test-prompts.json +12 -0
- package/skills/bee/peaks-qa/SKILL.md +16 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +22 -0
- package/skills/bee/peaks-qa/test-prompts.json +12 -0
- package/skills/bee/peaks-rd/SKILL.md +29 -20
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +39 -0
- package/skills/bee/peaks-rd/test-prompts.json +12 -0
- package/skills/bee/peaks-reviewer/SKILL.md +17 -0
- package/skills/bee/peaks-sc/SKILL.md +16 -0
- package/skills/bee/peaks-security-audit/SKILL.md +17 -0
- package/skills/bee/peaks-txt/SKILL.md +16 -0
- package/skills/bee/peaks-txt/test-prompts.json +12 -0
- package/skills/bee/peaks-ui/SKILL.md +49 -43
- package/skills/bee/peaks-ui/test-prompts.json +12 -0
- package/skills/peaks-code/SKILL.md +54 -109
- package/skills/peaks-code/references/boundaries.md +15 -1
- package/skills/peaks-code/references/cron-scheduler-deployment.md +313 -0
- package/skills/peaks-code/references/external-skill-invocation.md +27 -0
- package/skills/peaks-code/references/lease-dashboard.html +224 -0
- package/skills/peaks-code/references/lease-stats.sample.json +26 -0
- package/skills/peaks-code/references/peaks-worktree-l2-enforcers.md +208 -0
- package/skills/peaks-code/references/periodic-checkpoint.md +4 -4
- package/skills/peaks-code/references/runbook.md +63 -1
- package/skills/peaks-code/references/startup-sequence.md +110 -0
- package/skills/peaks-code/references/step-0-8-gate.md +1 -1
- package/skills/peaks-code/references/sub-agent-dispatch.md +92 -1
- package/skills/peaks-code/references/worktree-governance.md +123 -0
- package/skills/peaks-code/test-prompts.json +12 -0
- package/skills/peaks-doctor/SKILL.md +1 -1
- package/skills/peaks-ide/SKILL.md +1 -1
- package/skills/peaks-solo/SKILL.md +21 -0
- package/skills/peaks-solo/references/triage-decision-table.md +6 -0
- package/skills/peaks-sop/test-prompts.json +17 -0
- package/dist/cli/commands/agent-commands.d.ts +0 -20
- package/dist/cli/commands/agent-commands.js +0 -48
- package/dist/cli/commands/classify-classify-commands.d.ts +0 -19
- package/dist/cli/commands/classify-classify-commands.js +0 -151
- package/dist/cli/commands/contract-commands.d.ts +0 -26
- package/dist/cli/commands/contract-commands.js +0 -114
- package/dist/cli/commands/session-auto-compact-hook-command.d.ts +0 -37
- package/dist/cli/commands/session-auto-compact-hook-command.js +0 -127
- package/dist/cli/commands/worker-commands.d.ts +0 -3
- package/dist/cli/commands/worker-commands.js +0 -52
- package/dist/services/agent/ecc-agent-service.d.ts +0 -47
- package/dist/services/agent/ecc-agent-service.js +0 -143
- package/dist/services/config/provider-service.d.ts +0 -48
- package/dist/services/config/provider-service.js +0 -143
- package/dist/services/context/dispatch-context-guard.d.ts +0 -27
- package/dist/services/context/dispatch-context-guard.js +0 -192
- package/dist/services/context/shared-channel.d.ts +0 -93
- package/dist/services/context/shared-channel.js +0 -308
- package/dist/services/filesystem/file-lock.d.ts +0 -11
- package/dist/services/filesystem/file-lock.js +0 -152
- package/dist/services/mut/assert-scanner.d.ts +0 -6
- package/dist/services/mut/assert-scanner.js +0 -116
- package/dist/services/mut/index.d.ts +0 -8
- package/dist/services/mut/index.js +0 -7
- package/dist/services/mut/mut-runner.d.ts +0 -39
- package/dist/services/mut/mut-runner.js +0 -29
- package/dist/services/mut/production-stryker.d.ts +0 -2
- package/dist/services/mut/production-stryker.js +0 -75
- package/dist/services/mut/report-builder.d.ts +0 -11
- package/dist/services/mut/report-builder.js +0 -110
- package/dist/services/mut/report-loader.d.ts +0 -31
- package/dist/services/mut/report-loader.js +0 -78
- package/dist/services/mut/thresholds.d.ts +0 -21
- package/dist/services/mut/thresholds.js +0 -22
- package/dist/services/mut/types.d.ts +0 -336
- package/dist/services/mut/types.js +0 -59
- package/dist/services/providers/minimax-provider-service.d.ts +0 -24
- package/dist/services/providers/minimax-provider-service.js +0 -143
- package/dist/services/providers/minimax-worker-service.d.ts +0 -21
- package/dist/services/providers/minimax-worker-service.js +0 -83
- package/dist/shared/fs.d.ts +0 -4
- package/dist/shared/fs.js +0 -26
- package/dist/shared/paths.d.ts +0 -6
- package/dist/shared/paths.js +0 -50
- package/dist/shared/result.d.ts +0 -22
- package/dist/shared/result.js +0 -46
- package/dist/shared/version.d.ts +0 -1
- package/dist/shared/version.js +0 -1
- package/examples/video-demo/README.md +0 -142
- package/examples/video-demo/out/en-closing-960.png +0 -0
- package/examples/video-demo/out/zh-closing-960.png +0 -0
- package/examples/video-demo/preview/peaks-loop-demo-en.mp4 +0 -0
- package/examples/video-demo/preview/peaks-loop-demo.mp4 +0 -0
- /package/dist/services/{job/job-resource-snapshot.js → job-snapshot/snapshot.js} +0 -0
|
@@ -23,16 +23,16 @@ export declare const MigrateResultSchema: z.ZodObject<{
|
|
|
23
23
|
skipped: z.ZodArray<z.ZodString, "many">;
|
|
24
24
|
errors: z.ZodArray<z.ZodString, "many">;
|
|
25
25
|
}, "strip", z.ZodTypeAny, {
|
|
26
|
-
ok: boolean;
|
|
27
26
|
skipped: string[];
|
|
27
|
+
ok: boolean;
|
|
28
28
|
scannedFiles: number;
|
|
29
29
|
modifiedFiles: number;
|
|
30
30
|
keyValueReplacements: number;
|
|
31
31
|
stringReplacements: number;
|
|
32
32
|
errors: string[];
|
|
33
33
|
}, {
|
|
34
|
-
ok: boolean;
|
|
35
34
|
skipped: string[];
|
|
35
|
+
ok: boolean;
|
|
36
36
|
scannedFiles: number;
|
|
37
37
|
modifiedFiles: number;
|
|
38
38
|
keyValueReplacements: number;
|
|
@@ -62,3 +62,30 @@ export declare function periodStartIso(period: Period, now?: () => Date): string
|
|
|
62
62
|
export declare function filterByPeriod(events: readonly ObservabilityEvent[], period: Period, now?: () => Date): ObservabilityEvent[];
|
|
63
63
|
export declare function readAllSessionEvents(projectRoot: string): ObservabilityEvent[];
|
|
64
64
|
export declare function readSessionEvents(projectRoot: string, sessionId: string): ObservabilityEvent[];
|
|
65
|
+
/**
|
|
66
|
+
* Cumulative 5-metric surface for the `peaks dashboard summary` CLI.
|
|
67
|
+
* All values are derived from raw observability events (per-event
|
|
68
|
+
* counting), not from state files — semantics differ from
|
|
69
|
+
* `peaks dashboard long-run`, which derives indicators from
|
|
70
|
+
* `.peaks/_runtime/<sid>/24h-state.json`.
|
|
71
|
+
*/
|
|
72
|
+
export type DashboardMetrics = {
|
|
73
|
+
readonly cycleCount: number;
|
|
74
|
+
readonly tokenCount: number;
|
|
75
|
+
readonly dispatchCount: number;
|
|
76
|
+
readonly compactCount: number;
|
|
77
|
+
readonly monotonicTriggerCount: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Aggregate the 5 dashboard metric classes for a single session, filtered
|
|
81
|
+
* to events with `ts >= since`. Events with unparseable timestamps are
|
|
82
|
+
* counted (best-effort, mirrors `readObservabilityEvents` behavior). The
|
|
83
|
+
* `token-usage` total is summed from `detail.totalTokens` (falling back to
|
|
84
|
+
* `inputTokens + outputTokens` when the aggregate field is missing).
|
|
85
|
+
*/
|
|
86
|
+
export declare function aggregateDashboardMetrics(projectRoot: string, sessionId: string, since: Date): DashboardMetrics;
|
|
87
|
+
/**
|
|
88
|
+
* Pure-function variant used by tests: counts across an already-loaded
|
|
89
|
+
* event list. `since` may be null to count everything.
|
|
90
|
+
*/
|
|
91
|
+
export declare function aggregateDashboardMetricsFromEvents(events: readonly ObservabilityEvent[], since?: Date | null): DashboardMetrics;
|
|
@@ -215,3 +215,75 @@ export function readAllSessionEvents(projectRoot) {
|
|
|
215
215
|
export function readSessionEvents(projectRoot, sessionId) {
|
|
216
216
|
return readObservabilityEvents(projectRoot, sessionId);
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Aggregate the 5 dashboard metric classes for a single session, filtered
|
|
220
|
+
* to events with `ts >= since`. Events with unparseable timestamps are
|
|
221
|
+
* counted (best-effort, mirrors `readObservabilityEvents` behavior). The
|
|
222
|
+
* `token-usage` total is summed from `detail.totalTokens` (falling back to
|
|
223
|
+
* `inputTokens + outputTokens` when the aggregate field is missing).
|
|
224
|
+
*/
|
|
225
|
+
export function aggregateDashboardMetrics(projectRoot, sessionId, since) {
|
|
226
|
+
const events = readObservabilityEvents(projectRoot, sessionId);
|
|
227
|
+
const cutoff = since.getTime();
|
|
228
|
+
let cycleCount = 0;
|
|
229
|
+
let tokenCount = 0;
|
|
230
|
+
let dispatchCount = 0;
|
|
231
|
+
let compactCount = 0;
|
|
232
|
+
let monotonicTriggerCount = 0;
|
|
233
|
+
for (const event of events) {
|
|
234
|
+
const ts = Date.parse(event.ts);
|
|
235
|
+
if (Number.isFinite(cutoff) && Number.isFinite(ts) && ts < cutoff)
|
|
236
|
+
continue;
|
|
237
|
+
if (event.category === 'cycle')
|
|
238
|
+
cycleCount += 1;
|
|
239
|
+
else if (event.category === 'token-usage') {
|
|
240
|
+
const detail = event.detail;
|
|
241
|
+
const t = typeof detail.totalTokens === 'number'
|
|
242
|
+
? detail.totalTokens
|
|
243
|
+
: (typeof detail.inputTokens === 'number' ? detail.inputTokens : 0)
|
|
244
|
+
+ (typeof detail.outputTokens === 'number' ? detail.outputTokens : 0);
|
|
245
|
+
tokenCount += t;
|
|
246
|
+
}
|
|
247
|
+
else if (event.category === 'dispatch')
|
|
248
|
+
dispatchCount += 1;
|
|
249
|
+
else if (event.category === 'post-compact')
|
|
250
|
+
compactCount += 1;
|
|
251
|
+
else if (event.category === 'monotonic-trigger')
|
|
252
|
+
monotonicTriggerCount += 1;
|
|
253
|
+
}
|
|
254
|
+
return { cycleCount, tokenCount, dispatchCount, compactCount, monotonicTriggerCount };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Pure-function variant used by tests: counts across an already-loaded
|
|
258
|
+
* event list. `since` may be null to count everything.
|
|
259
|
+
*/
|
|
260
|
+
export function aggregateDashboardMetricsFromEvents(events, since = null) {
|
|
261
|
+
const cutoff = since?.getTime() ?? null;
|
|
262
|
+
let cycleCount = 0;
|
|
263
|
+
let tokenCount = 0;
|
|
264
|
+
let dispatchCount = 0;
|
|
265
|
+
let compactCount = 0;
|
|
266
|
+
let monotonicTriggerCount = 0;
|
|
267
|
+
for (const event of events) {
|
|
268
|
+
const ts = Date.parse(event.ts);
|
|
269
|
+
if (cutoff !== null && Number.isFinite(ts) && ts < cutoff)
|
|
270
|
+
continue;
|
|
271
|
+
if (event.category === 'cycle')
|
|
272
|
+
cycleCount += 1;
|
|
273
|
+
else if (event.category === 'token-usage') {
|
|
274
|
+
const detail = event.detail;
|
|
275
|
+
const t = typeof detail.totalTokens === 'number'
|
|
276
|
+
? detail.totalTokens
|
|
277
|
+
: (typeof detail.inputTokens === 'number' ? detail.inputTokens : 0)
|
|
278
|
+
+ (typeof detail.outputTokens === 'number' ? detail.outputTokens : 0);
|
|
279
|
+
tokenCount += t;
|
|
280
|
+
}
|
|
281
|
+
else if (event.category === 'dispatch')
|
|
282
|
+
dispatchCount += 1;
|
|
283
|
+
else if (event.category === 'post-compact')
|
|
284
|
+
compactCount += 1;
|
|
285
|
+
else if (event.category === 'monotonic-trigger')
|
|
286
|
+
monotonicTriggerCount += 1;
|
|
287
|
+
}
|
|
288
|
+
return { cycleCount, tokenCount, dispatchCount, compactCount, monotonicTriggerCount };
|
|
289
|
+
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
export declare const OBSERVABILITY_SCHEMA_VERSION: 1;
|
|
23
|
-
export declare const OBSERVABILITY_CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact"];
|
|
23
|
+
export declare const OBSERVABILITY_CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact", "cycle", "token-usage", "monotonic-trigger", "lease"];
|
|
24
24
|
export type ObservabilityCategory = typeof OBSERVABILITY_CATEGORIES[number];
|
|
25
25
|
export declare const OBSERVABILITY_SUBAGENT_ROLES: readonly ["rd", "qa", "code-reviewer", "karpathy-reviewer", "peaks-security-audit", "peaks-perf-audit"];
|
|
26
26
|
export type ObservabilitySubagentRole = typeof OBSERVABILITY_SUBAGENT_ROLES[number];
|
|
@@ -28,24 +28,24 @@ export declare const ObservabilityEventSchema: z.ZodObject<{
|
|
|
28
28
|
schemaVersion: z.ZodLiteral<1>;
|
|
29
29
|
ts: z.ZodString;
|
|
30
30
|
sessionId: z.ZodString;
|
|
31
|
-
category: z.ZodEnum<["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact"]>;
|
|
31
|
+
category: z.ZodEnum<["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact", "cycle", "token-usage", "monotonic-trigger", "lease"]>;
|
|
32
32
|
sliceRid: z.ZodOptional<z.ZodString>;
|
|
33
33
|
role: z.ZodOptional<z.ZodEnum<["rd", "qa", "code-reviewer", "karpathy-reviewer", "peaks-security-audit", "peaks-perf-audit"]>>;
|
|
34
34
|
detail: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
35
35
|
}, "strip", z.ZodTypeAny, {
|
|
36
36
|
sessionId: string;
|
|
37
|
+
detail: Record<string, unknown>;
|
|
37
38
|
schemaVersion: 1;
|
|
38
39
|
ts: string;
|
|
39
|
-
category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact";
|
|
40
|
-
detail: Record<string, unknown>;
|
|
40
|
+
category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact" | "cycle" | "token-usage" | "monotonic-trigger" | "lease";
|
|
41
41
|
role?: "qa" | "rd" | "code-reviewer" | "karpathy-reviewer" | "peaks-security-audit" | "peaks-perf-audit" | undefined;
|
|
42
42
|
sliceRid?: string | undefined;
|
|
43
43
|
}, {
|
|
44
44
|
sessionId: string;
|
|
45
|
+
detail: Record<string, unknown>;
|
|
45
46
|
schemaVersion: 1;
|
|
46
47
|
ts: string;
|
|
47
|
-
category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact";
|
|
48
|
-
detail: Record<string, unknown>;
|
|
48
|
+
category: "slice-transition" | "dispatch" | "checkpoint" | "mode-gate" | "context-trigger" | "post-compact" | "cycle" | "token-usage" | "monotonic-trigger" | "lease";
|
|
49
49
|
role?: "qa" | "rd" | "code-reviewer" | "karpathy-reviewer" | "peaks-security-audit" | "peaks-perf-audit" | undefined;
|
|
50
50
|
sliceRid?: string | undefined;
|
|
51
51
|
}>;
|
|
@@ -90,6 +90,72 @@ export declare function readObservabilityEvents(projectRoot: string, sessionId:
|
|
|
90
90
|
export declare function isCurrentSchemaVersion(record: unknown): record is ObservabilityEvent;
|
|
91
91
|
export declare const OBSERVABILITY_CONSTANTS: {
|
|
92
92
|
readonly SCHEMA_VERSION: 1;
|
|
93
|
-
readonly CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact"];
|
|
93
|
+
readonly CATEGORIES: readonly ["slice-transition", "dispatch", "checkpoint", "mode-gate", "context-trigger", "post-compact", "cycle", "token-usage", "monotonic-trigger", "lease"];
|
|
94
94
|
readonly SUBAGENT_ROLES: readonly ["rd", "qa", "code-reviewer", "karpathy-reviewer", "peaks-security-audit", "peaks-perf-audit"];
|
|
95
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Slice 2026-07-29-worktree-l2-extended Part 4.A: lease lifecycle
|
|
98
|
+
* observability. Each `peaks worktree spawn / renew / release /
|
|
99
|
+
* gc` CLI emits a `lease` event; the auto-release hook in
|
|
100
|
+
* dispatch finalization emits `autoRelease` (success) or
|
|
101
|
+
* `autoRelease-failed` (detached spawn failed). The
|
|
102
|
+
* `peaks lease metrics --json` reader aggregates these for the
|
|
103
|
+
* dashboard.
|
|
104
|
+
*
|
|
105
|
+
* Fire-and-forget by contract (mirrors emitCycleEvent /
|
|
106
|
+
* emitTokenUsageEvent): never throws, written=false on schema
|
|
107
|
+
* mismatch or IO failure. Callers do not inspect the result.
|
|
108
|
+
*/
|
|
109
|
+
export type LeaseEventKind = 'spawn' | 'renew' | 'release' | 'gc' | 'autoRelease' | 'autoRelease-failed' | 'autoRelease-skipped';
|
|
110
|
+
export declare function emitLeaseEvent(opts: {
|
|
111
|
+
sessionId: string;
|
|
112
|
+
projectRoot: string;
|
|
113
|
+
kind: LeaseEventKind;
|
|
114
|
+
leaseId: string;
|
|
115
|
+
rid?: string;
|
|
116
|
+
role?: string;
|
|
117
|
+
/** Reason the autoRelease was skipped (e.g. "no-lease", "non-terminal-status"). */
|
|
118
|
+
reason?: string;
|
|
119
|
+
}): EmitResult;
|
|
120
|
+
/**
|
|
121
|
+
* rid-030 F-direction: per-cycle event (cycle started / completed / failed).
|
|
122
|
+
* Fire-and-forget; never throws. Tagging `kind` for downstream dashboards.
|
|
123
|
+
*/
|
|
124
|
+
export declare function emitCycleEvent(opts: {
|
|
125
|
+
sessionId: string;
|
|
126
|
+
projectRoot: string;
|
|
127
|
+
cycle: number;
|
|
128
|
+
status: 'started' | 'completed' | 'failed';
|
|
129
|
+
}): EmitResult;
|
|
130
|
+
/**
|
|
131
|
+
* rid-030 F-direction: per-token-usage event. `totalTokens` is the
|
|
132
|
+
* sum the dashboard cares about; `inputTokens`/`outputTokens` are kept
|
|
133
|
+
* for downstream drill-down.
|
|
134
|
+
*/
|
|
135
|
+
export declare function emitTokenUsageEvent(opts: {
|
|
136
|
+
sessionId: string;
|
|
137
|
+
projectRoot: string;
|
|
138
|
+
inputTokens: number;
|
|
139
|
+
outputTokens: number;
|
|
140
|
+
}): EmitResult;
|
|
141
|
+
/**
|
|
142
|
+
* rid-030 F-direction: per-monotonic-trigger event.
|
|
143
|
+
*/
|
|
144
|
+
export declare function emitMonotonicTriggerEvent(opts: {
|
|
145
|
+
sessionId: string;
|
|
146
|
+
projectRoot: string;
|
|
147
|
+
report: 'pass' | 'warn' | 'block';
|
|
148
|
+
action: string;
|
|
149
|
+
}): EmitResult;
|
|
150
|
+
/**
|
|
151
|
+
* rid-030 F-direction: per-subagent-dispatch event. Reuses the
|
|
152
|
+
* existing `dispatch` category (rd/qa/reviewer/audit). Provides a
|
|
153
|
+
* canonical emit helper so dashboards don't have to hand-author the
|
|
154
|
+
* `ObservabilityEvent` envelope.
|
|
155
|
+
*/
|
|
156
|
+
export declare function emitDispatchEvent(opts: {
|
|
157
|
+
sessionId: string;
|
|
158
|
+
projectRoot: string;
|
|
159
|
+
role: ObservabilitySubagentRole;
|
|
160
|
+
status?: 'queued' | 'running' | 'done' | 'failed';
|
|
161
|
+
}): EmitResult;
|
|
@@ -27,7 +27,17 @@ export const OBSERVABILITY_CATEGORIES = [
|
|
|
27
27
|
'checkpoint',
|
|
28
28
|
'mode-gate',
|
|
29
29
|
'context-trigger',
|
|
30
|
-
'post-compact'
|
|
30
|
+
'post-compact',
|
|
31
|
+
'cycle',
|
|
32
|
+
'token-usage',
|
|
33
|
+
'monotonic-trigger',
|
|
34
|
+
// Slice 2026-07-29-worktree-l2-extended Part 4.A: lease lifecycle
|
|
35
|
+
// metrics. Emitted by `peaks worktree spawn / renew / release /
|
|
36
|
+
// gc` and by the auto-release hook in dispatch finalization (Part
|
|
37
|
+
// 3.A). Read by `peaks lease metrics`. The `detail.kind` field
|
|
38
|
+
// discriminates spawn / renew / release / gc / autoRelease /
|
|
39
|
+
// autoRelease-failed / autoRelease-skipped.
|
|
40
|
+
'lease'
|
|
31
41
|
];
|
|
32
42
|
// v2.12.0 fan-out collapse: `security-reviewer` (in-process RD slot)
|
|
33
43
|
// moved out to the standalone `peaks-security-audit` skill; the matching
|
|
@@ -117,3 +127,79 @@ export const OBSERVABILITY_CONSTANTS = {
|
|
|
117
127
|
CATEGORIES: OBSERVABILITY_CATEGORIES,
|
|
118
128
|
SUBAGENT_ROLES: OBSERVABILITY_SUBAGENT_ROLES
|
|
119
129
|
};
|
|
130
|
+
export function emitLeaseEvent(opts) {
|
|
131
|
+
const detail = { kind: opts.kind, leaseId: opts.leaseId };
|
|
132
|
+
if (opts.rid !== undefined)
|
|
133
|
+
detail['rid'] = opts.rid;
|
|
134
|
+
if (opts.role !== undefined)
|
|
135
|
+
detail['role'] = opts.role;
|
|
136
|
+
if (opts.reason !== undefined)
|
|
137
|
+
detail['reason'] = opts.reason;
|
|
138
|
+
return emitObservabilityEvent({
|
|
139
|
+
schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
|
|
140
|
+
ts: new Date().toISOString(),
|
|
141
|
+
sessionId: opts.sessionId,
|
|
142
|
+
category: 'lease',
|
|
143
|
+
detail
|
|
144
|
+
}, { projectRoot: opts.projectRoot });
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* rid-030 F-direction: per-cycle event (cycle started / completed / failed).
|
|
148
|
+
* Fire-and-forget; never throws. Tagging `kind` for downstream dashboards.
|
|
149
|
+
*/
|
|
150
|
+
export function emitCycleEvent(opts) {
|
|
151
|
+
return emitObservabilityEvent({
|
|
152
|
+
schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
|
|
153
|
+
ts: new Date().toISOString(),
|
|
154
|
+
sessionId: opts.sessionId,
|
|
155
|
+
category: 'cycle',
|
|
156
|
+
detail: { cycle: opts.cycle, status: opts.status }
|
|
157
|
+
}, { projectRoot: opts.projectRoot });
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* rid-030 F-direction: per-token-usage event. `totalTokens` is the
|
|
161
|
+
* sum the dashboard cares about; `inputTokens`/`outputTokens` are kept
|
|
162
|
+
* for downstream drill-down.
|
|
163
|
+
*/
|
|
164
|
+
export function emitTokenUsageEvent(opts) {
|
|
165
|
+
const totalTokens = Math.max(0, opts.inputTokens) + Math.max(0, opts.outputTokens);
|
|
166
|
+
return emitObservabilityEvent({
|
|
167
|
+
schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
|
|
168
|
+
ts: new Date().toISOString(),
|
|
169
|
+
sessionId: opts.sessionId,
|
|
170
|
+
category: 'token-usage',
|
|
171
|
+
detail: {
|
|
172
|
+
inputTokens: opts.inputTokens,
|
|
173
|
+
outputTokens: opts.outputTokens,
|
|
174
|
+
totalTokens
|
|
175
|
+
}
|
|
176
|
+
}, { projectRoot: opts.projectRoot });
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* rid-030 F-direction: per-monotonic-trigger event.
|
|
180
|
+
*/
|
|
181
|
+
export function emitMonotonicTriggerEvent(opts) {
|
|
182
|
+
return emitObservabilityEvent({
|
|
183
|
+
schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
|
|
184
|
+
ts: new Date().toISOString(),
|
|
185
|
+
sessionId: opts.sessionId,
|
|
186
|
+
category: 'monotonic-trigger',
|
|
187
|
+
detail: { report: opts.report, action: opts.action }
|
|
188
|
+
}, { projectRoot: opts.projectRoot });
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* rid-030 F-direction: per-subagent-dispatch event. Reuses the
|
|
192
|
+
* existing `dispatch` category (rd/qa/reviewer/audit). Provides a
|
|
193
|
+
* canonical emit helper so dashboards don't have to hand-author the
|
|
194
|
+
* `ObservabilityEvent` envelope.
|
|
195
|
+
*/
|
|
196
|
+
export function emitDispatchEvent(opts) {
|
|
197
|
+
return emitObservabilityEvent({
|
|
198
|
+
schemaVersion: OBSERVABILITY_SCHEMA_VERSION,
|
|
199
|
+
ts: new Date().toISOString(),
|
|
200
|
+
sessionId: opts.sessionId,
|
|
201
|
+
category: 'dispatch',
|
|
202
|
+
role: opts.role,
|
|
203
|
+
detail: { status: opts.status ?? 'done' }
|
|
204
|
+
}, { projectRoot: opts.projectRoot });
|
|
205
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact boundary helpers for peaks-loop.
|
|
3
|
+
*
|
|
4
|
+
* Slice rid-009:
|
|
5
|
+
* - sub-slice 1: change-id validation (`validateChangeId`).
|
|
6
|
+
* - sub-slice 2: artifact path planning (`planArtifactPath` + `isPathInsideArtifactRoot` re-export).
|
|
7
|
+
* - sub-slice 3: workspace-unavailable response (`buildWorkspaceUnavailable`).
|
|
8
|
+
*
|
|
9
|
+
* The colocated single-file layout avoids creating two competing path-safety
|
|
10
|
+
* layers — `src/shared/path-safety.ts` already owns the primitive
|
|
11
|
+
* `isPathInsideArtifactRoot` which we re-export unchanged.
|
|
12
|
+
*
|
|
13
|
+
* Conventions:
|
|
14
|
+
* - `Result<T, E>` is hand-rolled in this file (no `neverthrow` dep).
|
|
15
|
+
* - All errors are typed unions — no thrown exceptions for validation.
|
|
16
|
+
* - The change-id format mirrors the pre-existing
|
|
17
|
+
* `[A-Za-z0-9][A-Za-z0-9._-]*` regex used by
|
|
18
|
+
* `openspec-validate-service.ts` so the refactor (task 3) preserves
|
|
19
|
+
* the exact error message byte-for-byte.
|
|
20
|
+
* - Path planning uses `posix.normalize` to keep semantics stable across
|
|
21
|
+
* win32/posix runners; JSON output always uses `/`.
|
|
22
|
+
*/
|
|
23
|
+
import { isPathInsideArtifactRoot as _isPathInsideArtifactRoot } from '../../shared/path-safety.js';
|
|
24
|
+
export type Result<T, E> = {
|
|
25
|
+
ok: true;
|
|
26
|
+
value: T;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
error: E;
|
|
30
|
+
};
|
|
31
|
+
export declare function ok<T>(value: T): Result<T, never>;
|
|
32
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
33
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
34
|
+
ok: true;
|
|
35
|
+
value: T;
|
|
36
|
+
};
|
|
37
|
+
export type ChangeIdError = {
|
|
38
|
+
code: 'change-id-empty';
|
|
39
|
+
message: string;
|
|
40
|
+
} | {
|
|
41
|
+
code: 'change-id-format';
|
|
42
|
+
message: string;
|
|
43
|
+
} | {
|
|
44
|
+
code: 'change-id-reserved';
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
export type BoundaryError = ChangeIdError | {
|
|
48
|
+
code: 'workspace-unconfigured';
|
|
49
|
+
message: string;
|
|
50
|
+
} | {
|
|
51
|
+
code: 'path-outside-artifact-root';
|
|
52
|
+
path: string;
|
|
53
|
+
root: string;
|
|
54
|
+
message: string;
|
|
55
|
+
} | {
|
|
56
|
+
code: 'unsafe-path-input';
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Validate a change-id string. Returns a typed `Result`; the error code
|
|
61
|
+
* distinguishes "empty" / "format" / "reserved" so callers can branch on
|
|
62
|
+
* the cause without re-parsing the message.
|
|
63
|
+
*
|
|
64
|
+
* Acceptance contract (rid-009 §3.3.1, task 1):
|
|
65
|
+
* - accepts `[A-Za-z0-9][A-Za-z0-9._-]*` (existing regex semantics)
|
|
66
|
+
* - rejects empty string with `change-id-empty`
|
|
67
|
+
* - rejects `.` and `..` with `change-id-reserved`
|
|
68
|
+
* - rejects everything else that does not match the regex with
|
|
69
|
+
* `change-id-format`
|
|
70
|
+
*
|
|
71
|
+
* The format-error message is byte-for-byte identical to the pre-refactor
|
|
72
|
+
* string produced at `openspec-validate-service.ts:55` so existing
|
|
73
|
+
* `OpenSpecValidationIssue` consumers do not break.
|
|
74
|
+
*/
|
|
75
|
+
export declare function validateChangeId(id: string): Result<{
|
|
76
|
+
changeId: string;
|
|
77
|
+
}, ChangeIdError>;
|
|
78
|
+
/**
|
|
79
|
+
* Re-export of `src/shared/path-safety.ts#isPathInsideArtifactRoot`.
|
|
80
|
+
*
|
|
81
|
+
* Single source of truth: the primitive is owned by `src/shared/path-safety.ts`;
|
|
82
|
+
* this module owns the *domain* helpers (change-id + path planner) that consume
|
|
83
|
+
* the primitive. Tests in `tests/unit/services/openspec/artifact-boundary.test.ts`
|
|
84
|
+
* exercise the RE-EXPORT wiring; the primitive's own correctness is covered by
|
|
85
|
+
* its native test file.
|
|
86
|
+
*/
|
|
87
|
+
export { _isPathInsideArtifactRoot as isPathInsideArtifactRoot };
|
|
88
|
+
/**
|
|
89
|
+
* Input for `planArtifactPath`. The caller MUST supply `changeId`, `workspaceRoot`,
|
|
90
|
+
* `role`, and `requestId`. Exactly one of `absolutePath` or `relativePath` may be
|
|
91
|
+
* supplied; if neither is supplied, a default template `"<changeId>/<role>/<requestId>"`
|
|
92
|
+
* is used. `template` overrides the default placeholder substitution when both
|
|
93
|
+
* `absolutePath` and `relativePath` are absent.
|
|
94
|
+
*/
|
|
95
|
+
export type PlanArtifactPathInput = {
|
|
96
|
+
changeId: string;
|
|
97
|
+
workspaceRoot: string;
|
|
98
|
+
role: string;
|
|
99
|
+
requestId: string;
|
|
100
|
+
absolutePath?: string;
|
|
101
|
+
relativePath?: string;
|
|
102
|
+
template?: string;
|
|
103
|
+
};
|
|
104
|
+
export type PlanArtifactPathOutput = {
|
|
105
|
+
absolutePath: string;
|
|
106
|
+
relativePath: string;
|
|
107
|
+
jsonSafeRelativePath: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Plan an artifact-relative path under the configured Peaks artifact workspace.
|
|
111
|
+
*
|
|
112
|
+
* Semantics (rid-009 §3.3.2, tasks 5–9):
|
|
113
|
+
* - Backslashes in the candidate path are normalized to forward slashes for
|
|
114
|
+
* JSON safety; empty segments (`foo//bar`) are collapsed by `posix.normalize`.
|
|
115
|
+
* - If the resolved absolute path is NOT contained under `workspaceRoot`
|
|
116
|
+
* (per `isPathInsideArtifactRoot`), returns
|
|
117
|
+
* `BoundaryError.path-outside-artifact-root` — NO silent fallback to cwd.
|
|
118
|
+
* - JSON output (`jsonSafeRelativePath`) ALWAYS uses `/` so it round-trips
|
|
119
|
+
* cleanly through `JSON.stringify` on Windows.
|
|
120
|
+
*
|
|
121
|
+
* Path math only — this helper never touches the filesystem, so it is fully
|
|
122
|
+
* hermetic and safe to call on paths that do not exist yet.
|
|
123
|
+
*/
|
|
124
|
+
export declare function planArtifactPath(input: PlanArtifactPathInput): Result<PlanArtifactPathOutput, BoundaryError>;
|
|
125
|
+
export type WorkspaceUnavailableResponse = {
|
|
126
|
+
ok: false;
|
|
127
|
+
mode: 'preview-only' | 'blocked';
|
|
128
|
+
reason: 'artifact-workspace-unavailable';
|
|
129
|
+
nextActions: string[];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Build the explicit response used when no artifact workspace is configured.
|
|
133
|
+
* The next action is static natural language so callers can surface remediation
|
|
134
|
+
* without requiring the user to type a CLI command or hand-author data.
|
|
135
|
+
*/
|
|
136
|
+
export declare function buildWorkspaceUnavailable(input: {
|
|
137
|
+
mode: WorkspaceUnavailableResponse['mode'];
|
|
138
|
+
}): WorkspaceUnavailableResponse;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact boundary helpers for peaks-loop.
|
|
3
|
+
*
|
|
4
|
+
* Slice rid-009:
|
|
5
|
+
* - sub-slice 1: change-id validation (`validateChangeId`).
|
|
6
|
+
* - sub-slice 2: artifact path planning (`planArtifactPath` + `isPathInsideArtifactRoot` re-export).
|
|
7
|
+
* - sub-slice 3: workspace-unavailable response (`buildWorkspaceUnavailable`).
|
|
8
|
+
*
|
|
9
|
+
* The colocated single-file layout avoids creating two competing path-safety
|
|
10
|
+
* layers — `src/shared/path-safety.ts` already owns the primitive
|
|
11
|
+
* `isPathInsideArtifactRoot` which we re-export unchanged.
|
|
12
|
+
*
|
|
13
|
+
* Conventions:
|
|
14
|
+
* - `Result<T, E>` is hand-rolled in this file (no `neverthrow` dep).
|
|
15
|
+
* - All errors are typed unions — no thrown exceptions for validation.
|
|
16
|
+
* - The change-id format mirrors the pre-existing
|
|
17
|
+
* `[A-Za-z0-9][A-Za-z0-9._-]*` regex used by
|
|
18
|
+
* `openspec-validate-service.ts` so the refactor (task 3) preserves
|
|
19
|
+
* the exact error message byte-for-byte.
|
|
20
|
+
* - Path planning uses `posix.normalize` to keep semantics stable across
|
|
21
|
+
* win32/posix runners; JSON output always uses `/`.
|
|
22
|
+
*/
|
|
23
|
+
import { posix, relative, resolve, isAbsolute as nodeIsAbsolute } from 'node:path';
|
|
24
|
+
import { isPathInsideArtifactRoot as _isPathInsideArtifactRoot } from '../../shared/path-safety.js';
|
|
25
|
+
export function ok(value) {
|
|
26
|
+
return { ok: true, value };
|
|
27
|
+
}
|
|
28
|
+
export function err(error) {
|
|
29
|
+
return { ok: false, error };
|
|
30
|
+
}
|
|
31
|
+
export function isOk(result) {
|
|
32
|
+
return result.ok;
|
|
33
|
+
}
|
|
34
|
+
const CHANGE_ID_FORMAT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
35
|
+
/**
|
|
36
|
+
* Validate a change-id string. Returns a typed `Result`; the error code
|
|
37
|
+
* distinguishes "empty" / "format" / "reserved" so callers can branch on
|
|
38
|
+
* the cause without re-parsing the message.
|
|
39
|
+
*
|
|
40
|
+
* Acceptance contract (rid-009 §3.3.1, task 1):
|
|
41
|
+
* - accepts `[A-Za-z0-9][A-Za-z0-9._-]*` (existing regex semantics)
|
|
42
|
+
* - rejects empty string with `change-id-empty`
|
|
43
|
+
* - rejects `.` and `..` with `change-id-reserved`
|
|
44
|
+
* - rejects everything else that does not match the regex with
|
|
45
|
+
* `change-id-format`
|
|
46
|
+
*
|
|
47
|
+
* The format-error message is byte-for-byte identical to the pre-refactor
|
|
48
|
+
* string produced at `openspec-validate-service.ts:55` so existing
|
|
49
|
+
* `OpenSpecValidationIssue` consumers do not break.
|
|
50
|
+
*/
|
|
51
|
+
export function validateChangeId(id) {
|
|
52
|
+
if (id === '') {
|
|
53
|
+
return err({ code: 'change-id-empty', message: 'changeId is empty' });
|
|
54
|
+
}
|
|
55
|
+
if (id === '.' || id === '..') {
|
|
56
|
+
return err({ code: 'change-id-reserved', message: `changeId ${id} is reserved` });
|
|
57
|
+
}
|
|
58
|
+
if (id.startsWith('.') || id.endsWith('.')) {
|
|
59
|
+
return err({
|
|
60
|
+
code: 'change-id-format',
|
|
61
|
+
message: `changeId ${id} does not match [A-Za-z0-9][A-Za-z0-9._-]*`
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!CHANGE_ID_FORMAT_PATTERN.test(id)) {
|
|
65
|
+
return err({
|
|
66
|
+
code: 'change-id-format',
|
|
67
|
+
message: `changeId ${id} does not match [A-Za-z0-9][A-Za-z0-9._-]*`
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return ok({ changeId: id });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Re-export of `src/shared/path-safety.ts#isPathInsideArtifactRoot`.
|
|
74
|
+
*
|
|
75
|
+
* Single source of truth: the primitive is owned by `src/shared/path-safety.ts`;
|
|
76
|
+
* this module owns the *domain* helpers (change-id + path planner) that consume
|
|
77
|
+
* the primitive. Tests in `tests/unit/services/openspec/artifact-boundary.test.ts`
|
|
78
|
+
* exercise the RE-EXPORT wiring; the primitive's own correctness is covered by
|
|
79
|
+
* its native test file.
|
|
80
|
+
*/
|
|
81
|
+
export { _isPathInsideArtifactRoot as isPathInsideArtifactRoot };
|
|
82
|
+
const DEFAULT_TEMPLATE = '<changeId>/<role>/<requestId>';
|
|
83
|
+
function interpolateTemplate(template, changeId, role, requestId) {
|
|
84
|
+
return template
|
|
85
|
+
.replaceAll('<changeId>', changeId)
|
|
86
|
+
.replaceAll('<role>', role)
|
|
87
|
+
.replaceAll('<requestId>', requestId);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Plan an artifact-relative path under the configured Peaks artifact workspace.
|
|
91
|
+
*
|
|
92
|
+
* Semantics (rid-009 §3.3.2, tasks 5–9):
|
|
93
|
+
* - Backslashes in the candidate path are normalized to forward slashes for
|
|
94
|
+
* JSON safety; empty segments (`foo//bar`) are collapsed by `posix.normalize`.
|
|
95
|
+
* - If the resolved absolute path is NOT contained under `workspaceRoot`
|
|
96
|
+
* (per `isPathInsideArtifactRoot`), returns
|
|
97
|
+
* `BoundaryError.path-outside-artifact-root` — NO silent fallback to cwd.
|
|
98
|
+
* - JSON output (`jsonSafeRelativePath`) ALWAYS uses `/` so it round-trips
|
|
99
|
+
* cleanly through `JSON.stringify` on Windows.
|
|
100
|
+
*
|
|
101
|
+
* Path math only — this helper never touches the filesystem, so it is fully
|
|
102
|
+
* hermetic and safe to call on paths that do not exist yet.
|
|
103
|
+
*/
|
|
104
|
+
export function planArtifactPath(input) {
|
|
105
|
+
const workspaceRoot = input.workspaceRoot;
|
|
106
|
+
const candidateRaw = input.absolutePath !== undefined
|
|
107
|
+
? input.absolutePath
|
|
108
|
+
: input.relativePath !== undefined
|
|
109
|
+
? input.relativePath
|
|
110
|
+
: interpolateTemplate(input.template ?? DEFAULT_TEMPLATE, input.changeId, input.role, input.requestId);
|
|
111
|
+
// Always normalize separators to forward-slashes for the JSON-safe output,
|
|
112
|
+
// then run posix.normalize so empty segments (foo//bar) and `..` segments
|
|
113
|
+
// collapse to canonical form.
|
|
114
|
+
const forwardSlashed = candidateRaw.replace(/\\/g, '/');
|
|
115
|
+
const normalized = posix.normalize(forwardSlashed);
|
|
116
|
+
// Resolve against workspaceRoot. If the candidate is already absolute,
|
|
117
|
+
// posix.normalize preserves the leading `/`; `resolve` keeps it absolute
|
|
118
|
+
// without prepending workspaceRoot (Node's path.resolve treats absolute
|
|
119
|
+
// candidates as already-resolved).
|
|
120
|
+
const absolutePath = nodeIsAbsolute(normalized)
|
|
121
|
+
? resolve(normalized)
|
|
122
|
+
: resolve(workspaceRoot, normalized);
|
|
123
|
+
if (!_isPathInsideArtifactRoot(absolutePath, workspaceRoot)) {
|
|
124
|
+
return err({
|
|
125
|
+
code: 'path-outside-artifact-root',
|
|
126
|
+
path: absolutePath,
|
|
127
|
+
root: workspaceRoot,
|
|
128
|
+
message: `path "${absolutePath}" resolves outside artifact root "${workspaceRoot}"`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const relativePath = relative(workspaceRoot, absolutePath);
|
|
132
|
+
const jsonSafeRelativePath = relativePath.replace(/\\/g, '/');
|
|
133
|
+
return ok({ absolutePath, relativePath, jsonSafeRelativePath });
|
|
134
|
+
}
|
|
135
|
+
const WORKSPACE_UNAVAILABLE_NEXT_ACTIONS = [
|
|
136
|
+
'Configure artifact workspace by describing where Peaks should store artifacts.'
|
|
137
|
+
];
|
|
138
|
+
/**
|
|
139
|
+
* Build the explicit response used when no artifact workspace is configured.
|
|
140
|
+
* The next action is static natural language so callers can surface remediation
|
|
141
|
+
* without requiring the user to type a CLI command or hand-author data.
|
|
142
|
+
*/
|
|
143
|
+
export function buildWorkspaceUnavailable(input) {
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
mode: input.mode,
|
|
147
|
+
reason: 'artifact-workspace-unavailable',
|
|
148
|
+
nextActions: [...WORKSPACE_UNAVAILABLE_NEXT_ACTIONS]
|
|
149
|
+
};
|
|
150
|
+
}
|