peaks-loop 4.0.0-beta → 4.0.0-beta.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/CHANGELOG.md +105 -87
- package/README-en.md +17 -4
- package/README.md +17 -4
- package/dist/src/cli/commands/asset-commands.d.ts +45 -0
- package/dist/src/cli/commands/asset-commands.js +404 -0
- package/dist/src/cli/commands/bee-commands.d.ts +26 -0
- package/dist/src/cli/commands/bee-commands.js +169 -0
- package/dist/src/cli/commands/{solo-commands.d.ts → code-commands.d.ts} +24 -24
- package/dist/src/cli/commands/{solo-commands.js → code-commands.js} +78 -78
- package/dist/src/cli/commands/core/skill-command.js +1 -1
- package/dist/src/cli/commands/dispatch-from-dag.js +1 -1
- package/dist/src/cli/commands/evolution-commands.d.ts +27 -0
- package/dist/src/cli/commands/evolution-commands.js +393 -0
- package/dist/src/cli/commands/hook-handle.js +7 -7
- package/dist/src/cli/commands/job-commands.js +2 -2
- package/dist/src/cli/commands/loop-commands.d.ts +19 -13
- package/dist/src/cli/commands/loop-commands.js +147 -13
- package/dist/src/cli/commands/sediment-commands.js +9 -0
- package/dist/src/cli/commands/session-auto-compact-hook-command.js +2 -2
- package/dist/src/cli/commands/skill-loop-engineering-readiness-commands.d.ts +67 -0
- package/dist/src/cli/commands/skill-loop-engineering-readiness-commands.js +173 -0
- package/dist/src/cli/commands/sub-agent-shared.d.ts +1 -1
- package/dist/src/cli/commands/user-touchpoint-commands.d.ts +4 -4
- package/dist/src/cli/commands/user-touchpoint-commands.js +14 -14
- package/dist/src/cli/commands/workflow-commands.js +22 -22
- package/dist/src/cli/program.js +23 -6
- package/dist/src/services/artifacts/repair-cycle-service.js +1 -1
- package/dist/src/services/audit/enforcers/active-skill-resolver.d.ts +1 -1
- package/dist/src/services/audit/enforcers/active-skill-resolver.js +1 -1
- package/dist/src/services/audit/enforcers/{solo-code-ban.d.ts → code-ban.d.ts} +6 -6
- package/dist/src/services/audit/enforcers/{solo-code-ban.js → code-ban.js} +6 -6
- package/dist/src/services/audit/red-line-catalog.d.ts +2 -2
- package/dist/src/services/audit/red-line-catalog.js +5 -5
- package/dist/src/services/audit/types.d.ts +2 -2
- package/dist/src/services/{solo → code}/auto-compact-orchestrator.d.ts +1 -1
- package/dist/src/services/{solo → code}/auto-compact-orchestrator.js +3 -3
- package/dist/src/services/{solo → code}/dag-orchestrator.d.ts +1 -1
- package/dist/src/services/{solo → code}/dag-orchestrator.js +1 -1
- package/dist/src/services/{solo → code}/emit-handoff.d.ts +1 -1
- package/dist/src/services/{solo → code}/emit-handoff.js +1 -1
- package/dist/src/services/{solo → code}/job-shape-decision.d.ts +1 -1
- package/dist/src/services/{solo → code}/job-shape-decision.js +5 -5
- package/dist/src/services/{solo → code}/mode-gate.d.ts +9 -9
- package/dist/src/services/{solo → code}/mode-gate.js +5 -5
- package/dist/src/services/{solo → code}/post-compact-detector.d.ts +3 -3
- package/dist/src/services/{solo → code}/post-compact-detector.js +4 -4
- package/dist/src/services/{solo → code}/step-08-gate.d.ts +4 -4
- package/dist/src/services/{solo → code}/step-08-gate.js +4 -4
- package/dist/src/services/{solo → code}/user-touchpoint-classifier.d.ts +1 -1
- package/dist/src/services/{solo → code}/user-touchpoint-classifier.js +1 -1
- package/dist/src/services/context/auto-compact-dispatcher.d.ts +2 -2
- package/dist/src/services/context/auto-compact-dispatcher.js +2 -2
- package/dist/src/services/context/auto-compact-types.d.ts +1 -1
- package/dist/src/services/crystallization/crystallization-service.d.ts +239 -0
- package/dist/src/services/crystallization/crystallization-service.js +397 -0
- package/dist/src/services/crystallization/crystallization-store.d.ts +75 -0
- package/dist/src/services/crystallization/crystallization-store.js +193 -0
- package/dist/src/services/crystallization/crystallization-types.d.ts +313 -0
- package/dist/src/services/crystallization/crystallization-types.js +299 -0
- package/dist/src/services/crystallization/evidence-brief-builder.d.ts +237 -0
- package/dist/src/services/crystallization/evidence-brief-builder.js +240 -0
- package/dist/src/services/dispatch/slice-dag.d.ts +2 -2
- package/dist/src/services/dispatch/test-tool-detection.d.ts +1 -1
- package/dist/src/services/dispatch/test-tool-detection.js +1 -1
- package/dist/src/services/evolution/evolution-service.d.ts +137 -0
- package/dist/src/services/evolution/evolution-service.js +281 -0
- package/dist/src/services/evolution/evolution-store.d.ts +57 -0
- package/dist/src/services/evolution/evolution-store.js +232 -0
- package/dist/src/services/evolution/evolution-types.d.ts +706 -0
- package/dist/src/services/evolution/evolution-types.js +286 -0
- package/dist/src/services/evolution/independent-evaluator-runner.d.ts +90 -0
- package/dist/src/services/evolution/independent-evaluator-runner.js +106 -0
- package/dist/src/services/evolution/regression-skeptic-runner.d.ts +64 -0
- package/dist/src/services/evolution/regression-skeptic-runner.js +113 -0
- package/dist/src/services/feedback/feedback-promotion-service.js +2 -2
- package/dist/src/services/job/job-progress-store.d.ts +1 -1
- package/dist/src/services/job/job-progress-store.js +1 -1
- package/dist/src/services/loop/loop-bee-relation-service.d.ts +107 -0
- package/dist/src/services/loop/loop-bee-relation-service.js +211 -0
- package/dist/src/services/loop/loop-bee-relation-store.d.ts +53 -0
- package/dist/src/services/loop/loop-bee-relation-store.js +130 -0
- package/dist/src/services/loop/loop-bee-relation-types.d.ts +118 -0
- package/dist/src/services/loop/loop-bee-relation-types.js +114 -0
- package/dist/src/services/loop/loop-release-service.d.ts +46 -0
- package/dist/src/services/loop/loop-release-service.js +66 -0
- package/dist/src/services/loop/loop-release-store.d.ts +55 -0
- package/dist/src/services/loop/loop-release-store.js +134 -0
- package/dist/src/services/loop/loop-release-types.d.ts +250 -0
- package/dist/src/services/loop/loop-release-types.js +162 -0
- package/dist/src/services/preferences/preferences-service.d.ts +1 -1
- package/dist/src/services/preferences/preferences-types.d.ts +1 -1
- package/dist/src/services/rd/standards-diagnostic.d.ts +1 -1
- package/dist/src/services/rd/standards-diagnostic.js +2 -2
- package/dist/src/services/recommendations/capability-seed-items.js +1 -1
- package/dist/src/services/recommendations/capability-seed-mappings.js +1 -1
- package/dist/src/services/recommendations/recommendation-service.js +1 -1
- package/dist/src/services/refactor/refactor-service.d.ts +1 -1
- package/dist/src/services/share/bundle-reader.d.ts +100 -0
- package/dist/src/services/share/bundle-reader.js +434 -0
- package/dist/src/services/share/bundle-types.d.ts +392 -0
- package/dist/src/services/share/bundle-types.js +318 -0
- package/dist/src/services/share/bundle-writer.d.ts +97 -0
- package/dist/src/services/share/bundle-writer.js +429 -0
- package/dist/src/services/share/run-state-contract.d.ts +133 -0
- package/dist/src/services/share/run-state-contract.js +138 -0
- package/dist/src/services/signal/cancel-handler.js +3 -3
- package/dist/src/services/skill/resume-detector.js +1 -1
- package/dist/src/services/skillhub/release-import.js +7 -2
- package/dist/src/services/skillhub/release-retain.js +6 -1
- package/dist/src/services/skillhub/sqlite-store.js +17 -1
- package/dist/src/services/skillhub/types.d.ts +10 -0
- package/dist/src/services/skills/skill-presence-service.d.ts +1 -1
- package/dist/src/services/standards/loop-engineering-lint.d.ts +38 -0
- package/dist/src/services/standards/loop-engineering-lint.js +101 -0
- package/dist/src/services/standards/loop-engineering-readiness-lint.d.ts +111 -0
- package/dist/src/services/standards/loop-engineering-readiness-lint.js +248 -0
- package/dist/src/services/upgrade/1x-detector-service.js +1 -1
- package/dist/src/services/workflow/pipeline-verify-service.d.ts +1 -1
- package/dist/src/services/workflow/pipeline-verify-service.js +3 -3
- package/dist/src/services/workflow/workflow-autonomous-service.d.ts +3 -3
- package/dist/src/services/workflow/workflow-autonomous-service.js +2 -2
- package/dist/src/services/workflow/workflow-router-service.d.ts +6 -6
- package/dist/src/services/workflow/workflow-router-service.js +33 -33
- package/dist/src/services/workspace/claude-settings-template.d.ts +1 -1
- package/dist/src/services/workspace/claude-settings-template.js +5 -5
- package/dist/src/shared/version.d.ts +1 -1
- package/dist/src/shared/version.js +1 -1
- package/examples/video-demo/README.md +57 -0
- 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/output-styles/peaks-skill-swarm.md +3 -3
- package/package.json +6 -2
- package/skills/bee/peaks-qa/SKILL.md +1 -1
- package/skills/bee/peaks-qa/references/artifact-per-request.md +3 -3
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +6 -6
- package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
- package/skills/bee/peaks-rd/references/rd-runbook.md +1 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +11 -11
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +1 -1
- package/skills/bee/peaks-sc/SKILL.md +1 -1
- package/skills/bee/peaks-txt/SKILL.md +3 -3
- package/skills/bee/peaks-ui/SKILL.md +8 -8
- package/skills/peaks-code/SKILL.md +34 -21
- package/skills/peaks-code/references/anchoring-and-session-info.md +2 -2
- package/skills/peaks-code/references/artifact-contracts.md +1 -1
- package/skills/peaks-code/references/boundaries.md +3 -3
- package/skills/peaks-code/references/codegraph-orchestration.md +1 -1
- package/skills/peaks-code/references/dag-orchestrator.md +7 -7
- package/skills/peaks-code/references/external-references.md +2 -2
- package/skills/peaks-code/references/fanout-mandatory.md +3 -3
- package/skills/peaks-code/references/fast-mode.md +2 -2
- package/skills/peaks-code/references/frontend-only-mode.md +9 -9
- package/skills/peaks-code/references/job-loop.md +1 -1
- package/skills/peaks-code/references/local-artifact-workspace.md +2 -2
- package/skills/peaks-code/references/micro-cycle.md +14 -14
- package/skills/peaks-code/references/mode-selection-with-stale-presence.md +5 -5
- package/skills/peaks-code/references/mode-selection.md +3 -3
- package/skills/peaks-code/references/openspec-workflow.md +16 -16
- package/skills/peaks-code/references/periodic-checkpoint.md +4 -4
- package/skills/peaks-code/references/quality-gate-cheatsheet.md +1 -1
- package/skills/peaks-code/references/refactor-mode.md +1 -1
- package/skills/peaks-code/references/runbook.md +15 -15
- package/skills/peaks-code/references/step-0-55-1x-detection.md +1 -1
- package/skills/peaks-code/references/step-0-8-gate.md +11 -11
- package/skills/peaks-code/references/sub-agent-dispatch.md +8 -8
- package/skills/peaks-code/references/swarm-dispatch-contract.md +17 -17
- package/skills/peaks-code/references/workflow-gates-and-types.md +2 -2
- package/skills/peaks-code/references/workflow.md +5 -5
- package/skills/peaks-content/SKILL.md +272 -0
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +307 -0
- package/skills/peaks-resume/SKILL.md +2 -2
- package/skills/peaks-status/SKILL.md +2 -2
- package/skills/peaks-test/SKILL.md +2 -2
- /package/dist/src/services/{solo → code}/batch-heartbeat-poller.d.ts +0 -0
- /package/dist/src/services/{solo → code}/batch-heartbeat-poller.js +0 -0
- /package/dist/src/services/{solo → code}/status-line-renderer.d.ts +0 -0
- /package/dist/src/services/{solo → code}/status-line-renderer.js +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Extracted from `skills/peaks-code/SKILL.md` on 2026-06-09 (slice 019 — slim skill files to references) to keep SKILL.md under the 800-line cap from `common/coding-style.md`. The content below is the verbatim Frontend-only development mode section that was previously inline; nothing was paraphrased, just relocated.
|
|
4
4
|
|
|
5
|
-
When the project has no live backend (no swagger.json, no API server),
|
|
5
|
+
When the project has no live backend (no swagger.json, no API server), Code must activate frontend-only mode.
|
|
6
6
|
|
|
7
7
|
### Mode determination (deterministic — CLI is the source of truth)
|
|
8
8
|
|
|
@@ -11,13 +11,13 @@ The CLI decision is authoritative. Read `frontendOnly` and `frontendOnlyReason`
|
|
|
11
11
|
User-stated intent is **only** consulted when it conflicts with the CLI result. The two conflict cases:
|
|
12
12
|
|
|
13
13
|
- **CLI says `frontendOnly=false` but the user says "前端项目 / 没有后端 / 先 mock 数据"**: STOP and `AskUserQuestion` to confirm whether to override the scan (the repo probably contains a backend folder the user wants to ignore). Record the override decision and reason in `project-scan.md`.
|
|
14
|
-
- **CLI says `frontendOnly=true` but the user says "需要做后端 / 加 API"**: STOP and `AskUserQuestion` to confirm whether the request actually targets the missing backend (the user may be confused about repo scope, or there is a separate backend repo
|
|
14
|
+
- **CLI says `frontendOnly=true` but the user says "需要做后端 / 加 API"**: STOP and `AskUserQuestion` to confirm whether the request actually targets the missing backend (the user may be confused about repo scope, or there is a separate backend repo Code should switch to).
|
|
15
15
|
|
|
16
16
|
When there is no conflict, do not ask — the CLI value wins and the workflow proceeds.
|
|
17
17
|
|
|
18
18
|
### Mock data strategy selection
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Code records the chosen mock strategy in `.peaks/_runtime/<sessionId>/rd/tech-doc.md` under a `## Mock Data Strategy` section. The choice depends on the project scan results:
|
|
21
21
|
|
|
22
22
|
| Project data-fetching pattern | Recommended mock approach | Rationale |
|
|
23
23
|
|---|---|---|
|
|
@@ -59,15 +59,15 @@ When swagger.json becomes available later, the migration follows this sequence:
|
|
|
59
59
|
3. Remove corresponding mock files.
|
|
60
60
|
4. Run QA regression to verify the real API responses match the mock interface contracts.
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Code records the migration readiness in the TXT handoff capsule under a `## API Migration` section listing: mock file paths, the corresponding swagger endpoints (when known), and the migration status for each.
|
|
63
63
|
|
|
64
64
|
### Feishu document access fallback
|
|
65
65
|
|
|
66
66
|
When the PRD source is a Feishu/Lark document that requires authentication:
|
|
67
67
|
|
|
68
|
-
1. **Primary path**: Playwright MCP headed browser → user completes login →
|
|
69
|
-
2. **Fallback A (user cannot login)**: Ask user to copy-paste the document content or export as Markdown/PDF.
|
|
70
|
-
3. **Fallback B (user provides export)**: User drops a `.md` or `.pdf` export into `.peaks/_runtime/<sessionId>/prd/source/`.
|
|
68
|
+
1. **Primary path**: Playwright MCP headed browser → user completes login → Code reads document content via `browser_snapshot`.
|
|
69
|
+
2. **Fallback A (user cannot login)**: Ask user to copy-paste the document content or export as Markdown/PDF. Code creates the PRD artifact from the pasted content.
|
|
70
|
+
3. **Fallback B (user provides export)**: User drops a `.md` or `.pdf` export into `.peaks/_runtime/<sessionId>/prd/source/`. Code reads and processes it.
|
|
71
71
|
4. **Fallback C (none of the above)**: Mark PRD as `blocked` with reason `doc-inaccessible`, list the exact next steps for the user, and pause the workflow.
|
|
72
72
|
|
|
73
73
|
Never silently fall back to unauthenticated `fetch` or `WebFetch` for authenticated documents.
|
|
@@ -76,7 +76,7 @@ Never silently fall back to unauthenticated `fetch` or `WebFetch` for authentica
|
|
|
76
76
|
|
|
77
77
|
### Frontend-only trigger pre-flight
|
|
78
78
|
|
|
79
|
-
> Body of `### Frontend-only trigger pre-flight`. Before computing the swarm plan,
|
|
79
|
+
> Body of `### Frontend-only trigger pre-flight`. Before computing the swarm plan, Code runs the keyword scan deterministically:
|
|
80
80
|
|
|
81
81
|
1. Read `.peaks/_runtime/<sessionId>/prd/requests/<rid>.md` body.
|
|
82
82
|
2. Lowercase + strip markdown; check regex `\b(页面|组件|表单|弹窗|表格|样式|布局|交互|UI|UX|page|component|form|modal|table|styling|layout|interaction|frontend|前端)\b`.
|
|
@@ -84,4 +84,4 @@ Never silently fall back to unauthenticated `fetch` or `WebFetch` for authentica
|
|
|
84
84
|
4. If `frontendOnly` (from project-scan) is `true` and no keyword hit → UI joins anyway (frontend-only project, even non-visual changes may need visual sanity for regressions).
|
|
85
85
|
5. If `frontendOnly` is `false` and no keyword hit → UI skipped.
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
Code records the pre-flight result in `sc/swarm-plan.json` so the audit trail shows why UI was or was not included.
|
|
@@ -50,13 +50,13 @@ system/ # Existing-system extraction output (visual tokens, conventions
|
|
|
50
50
|
|
|
51
51
|
Files written into these directories during the workflow (not pre-created — they appear as their step runs):
|
|
52
52
|
|
|
53
|
-
- `rd/project-scan.md` (
|
|
53
|
+
- `rd/project-scan.md` (Code step 0.6)
|
|
54
54
|
- `rd/tech-doc.md` (feature/refactor planning; required by `rd → implemented` gate)
|
|
55
55
|
- `rd/bug-analysis.md` (bugfix planning; required by `rd → implemented` gate for `--type bugfix`)
|
|
56
56
|
- `rd/code-review.md`, `rd/security-review.md` (required by `rd → qa-handoff` gate for feature/bugfix/refactor; security-review only for config)
|
|
57
57
|
- `rd/mock-plan.md` (frontend-only mode)
|
|
58
58
|
- `ui/design-draft.md` (UI step)
|
|
59
|
-
- `system/existing-system.md` (
|
|
59
|
+
- `system/existing-system.md` (Code step 0.7; legacy projects only)
|
|
60
60
|
- `qa/test-cases/<rid>.md`, `qa/test-reports/<rid>.md`, `qa/security-findings.md`, `qa/performance-findings.md` (gated per `--type`)
|
|
61
61
|
|
|
62
62
|
## Root pollution prohibition (CRITICAL)
|
|
@@ -171,20 +171,20 @@ verdict=return-to-rd → RD 修 (new slice 内部走 micro-cycle)
|
|
|
171
171
|
>
|
|
172
172
|
> When PRD lands, classify the request type before running `peaks request init` for every role — pass `--type <type>` so the artifact records it and downstream transitions enforce the right gates. Misclassifying a feature as `docs` to skip gates is a workflow violation. If a transition fails with `code: PREREQUISITES_MISSING`, the response lists every missing path — produce them, then re-transition. For one-off exceptions, the escape hatch `--allow-incomplete --reason "<text>"` records the bypass in the artifact transition note.
|
|
173
173
|
|
|
174
|
-
After `peaks-rd` finishes any implementation, repair, or code-output slice, Peaks-Loop
|
|
174
|
+
After `peaks-rd` finishes any implementation, repair, or code-output slice, Peaks-Loop Code MUST automatically route the result to `peaks-qa` without waiting for user confirmation. This is not optional in full-auto mode. Code must not declare the workflow complete, emit a TXT handoff, or stop at RD completion.
|
|
175
175
|
|
|
176
|
-
**How
|
|
176
|
+
**How Code invokes another role (mechanism, not metaphor):**
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
Code is itself a skill running in the current session. There are **two distinct mechanisms** in this skill, and they MUST NOT be confused:
|
|
179
179
|
|
|
180
180
|
1. **Swarm fan-out (planning side, after PRD confirmed)** — uses `peaks sub-agent dispatch <role>` to launch real concurrent sub-agents. The CLI returns a per-IDE tool-call descriptor that the LLM executes in its environment. See "Peaks-Loop Swarm parallel phase" above for the full contract. Sub-agents do NOT call Skill(...) back into the role; they execute the role's instructions inline from the prompt.
|
|
181
|
-
2. **Sequential handoff (execution side, RD↔QA repair loop)** —
|
|
181
|
+
2. **Sequential handoff (execution side, RD↔QA repair loop)** — Code is the only loop, and after RD or QA finishes (whether as a sub-agent or directly), Code drives the next step from the orchestrator seat. Do NOT use the `Skill` tool to "reactivate" peaks-rd or peaks-qa in the main loop; doing so is the v1.x anti-pattern that masqueraded as "calling the role" but actually just re-prompted the same session. From v1.3 onward, the main loop drives roles via the CLI gate (`peaks request transition`) and reads back artefacts (`peaks request show ... --json`); the actual RD/QA work is either done inline by Code (when Code has just been re-invoked by the user) or by a Task sub-agent (in swarm mode).
|
|
182
182
|
|
|
183
|
-
After RD completes (whether inline or sub-agent),
|
|
183
|
+
After RD completes (whether inline or sub-agent), Code does not stop — it must advance to QA. There is no "RD done, ask the user" state in full-auto mode. The only valid stops are: (a) QA verdict=pass, (b) repair cap hit, (c) explicit user cancel.
|
|
184
184
|
|
|
185
|
-
**RD's internal reviews are already parallelized.** When RD finishes implementation, it issues a 3-way sub-agent fan-out (code-review + security-review + perf-baseline, see `skills/peaks-rd/SKILL.md` "Parallel review fan-out") and waits for all to return before transitioning to `qa-handoff`.
|
|
185
|
+
**RD's internal reviews are already parallelized.** When RD finishes implementation, it issues a 3-way sub-agent fan-out (code-review + security-review + perf-baseline, see `skills/peaks-rd/SKILL.md` "Parallel review fan-out") and waits for all to return before transitioning to `qa-handoff`. Code does NOT need to track three separate RD-side sub-runs; the RD role owns the fan-out lifecycle end-to-end. Code's presence restoration after the swarm converges is the only coordination point.
|
|
186
186
|
|
|
187
|
-
**Presence restoration after RD/QA work returns (MANDATORY):** In v1.x, role skills called `peaks skill presence:set <role>` internally and stomped on `.peaks/.active-skill.json`. From v1.3 onward, sub-agents in the Swarm path are forbidden from calling `peaks skill presence:set` (see "Sub-agent dispatch" in each role's SKILL.md), so the main loop's presence file is preserved across the fan-out window by construction. The one place
|
|
187
|
+
**Presence restoration after RD/QA work returns (MANDATORY):** In v1.x, role skills called `peaks skill presence:set <role>` internally and stomped on `.peaks/.active-skill.json`. From v1.3 onward, sub-agents in the Swarm path are forbidden from calling `peaks skill presence:set` (see "Sub-agent dispatch" in each role's SKILL.md), so the main loop's presence file is preserved across the fan-out window by construction. The one place Code still has to actively restore presence is **once after the fan-out returns** (gate=swarm-converged) and again **after each RD↔QA repair iteration** (gate=repair-cycle-<N>). Use the same command from Step 2 with the current mode and the gate that has just advanced:
|
|
188
188
|
|
|
189
189
|
```bash
|
|
190
190
|
peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate <current-gate>
|
|
@@ -192,13 +192,13 @@ peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate <curre
|
|
|
192
192
|
|
|
193
193
|
This keeps the CLAUDE.md status header accurate (`Peaks-Loop Skill: peaks-code`) instead of showing a stale role name. Use the current mode and gate values; the gate may have advanced since startup. Skipping this step causes the header to display the last-known gate permanently.
|
|
194
194
|
|
|
195
|
-
**Full-auto auto-proceed rule**: In the `full-auto` profile, when RD transitions to `qa-handoff`,
|
|
195
|
+
**Full-auto auto-proceed rule**: In the `full-auto` profile, when RD transitions to `qa-handoff`, Code immediately drives QA — by launching a `peaks sub-agent dispatch qa` sub-agent carrying the `peaks-qa` body (swarm path), then executing the returned toolCall, or by running QA inline in the main loop (assisted/strict path). Do not pause, do not ask the user, do not summarize RD results as if they were final. The only valid reason to skip QA is when `--type` is `docs` or `chore` (no acceptance surface).
|
|
196
196
|
|
|
197
197
|
A QA report with any failing, blocked, missing, or unverified acceptance item is not a pass.
|
|
198
198
|
|
|
199
|
-
**How
|
|
199
|
+
**How Code routes QA findings back to RD (mechanism, not metaphor):**
|
|
200
200
|
|
|
201
|
-
When `peaks-qa` returns `verdict=return-to-rd`,
|
|
201
|
+
When `peaks-qa` returns `verdict=return-to-rd`, Code does NOT manually rewrite RD artifacts. Instead it follows this exact sequence:
|
|
202
202
|
|
|
203
203
|
1. Read the QA verdict and findings via `peaks request show <rid> --role qa --project <repo> --json`. The findings live in the QA artifact body (failing acceptance items, evidence paths, severity).
|
|
204
204
|
2. Transition the RD artifact back from `qa-handoff` to a working state and record the QA verdict in the transition note:
|
|
@@ -209,13 +209,13 @@ When `peaks-qa` returns `verdict=return-to-rd`, Solo does NOT manually rewrite R
|
|
|
209
209
|
```
|
|
210
210
|
`spec-locked` is the canonical "needs more RD work" state. The reason is mandatory in repair cycles so the artifact history shows the loop.
|
|
211
211
|
3. Re-launch `peaks-rd` work. Two paths, mode-driven:
|
|
212
|
-
- **Swarm / full-auto**: launch a fresh `peaks sub-agent dispatch rd` sub-agent (then execute the returned toolCall) with the same `peaks-rd` body used in the Swarm phase, plus the QA findings path so it can read the failure list.
|
|
213
|
-
- **Assisted / strict / inline-fallback**:
|
|
212
|
+
- **Swarm / full-auto**: launch a fresh `peaks sub-agent dispatch rd` sub-agent (then execute the returned toolCall) with the same `peaks-rd` body used in the Swarm phase, plus the QA findings path so it can read the failure list. Code restores presence after the sub-agent returns.
|
|
213
|
+
- **Assisted / strict / inline-fallback**: Code executes the RD repair steps directly in the main loop, since there is no concurrent fan-out to coordinate.
|
|
214
214
|
In both paths, pass the QA findings path so the repair sees what failed.
|
|
215
215
|
4. peaks-rd fixes the reported issues only (red-line scope: do not modify unrelated surfaces), regenerates code-review and security-review evidence if changes touched reviewed surfaces, then transitions `rd → implemented → qa-handoff` again.
|
|
216
|
-
5.
|
|
216
|
+
5. Code re-runs QA (sub-agent Task in swarm/full-auto, inline in assisted/strict) with the same `<request-id>`. QA re-runs gates against the new diff.
|
|
217
217
|
6. Repeat steps 1-5 until QA returns `verdict=pass`, or the cap below fires.
|
|
218
|
-
**After each repair iteration** (after peaks-rd and peaks-qa both return),
|
|
218
|
+
**After each repair iteration** (after peaks-rd and peaks-qa both return), Code MUST restore presence:
|
|
219
219
|
```bash
|
|
220
220
|
peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate repair-cycle-<N>
|
|
221
221
|
```
|
|
@@ -62,14 +62,14 @@ peaks skill presence --check-stale --project <path> --json
|
|
|
62
62
|
|
|
63
63
|
Returns the same `stale` / `reason` / `currentOuterSessionId` / `recordedOuterSessionId` fields attached to the standard presence envelope. Default `false` (back-compat).
|
|
64
64
|
|
|
65
|
-
## Pause integration via `peaks
|
|
65
|
+
## Pause integration via `peaks code should-pause`
|
|
66
66
|
|
|
67
|
-
`peaks
|
|
67
|
+
`peaks code should-pause --step step-1-mode-select --mode <mode>` now consults `presence:check-stale` automatically. When stale:
|
|
68
68
|
|
|
69
69
|
```json
|
|
70
70
|
{
|
|
71
71
|
"ok": true,
|
|
72
|
-
"command": "
|
|
72
|
+
"command": "code.should-pause",
|
|
73
73
|
"data": {
|
|
74
74
|
"shouldPause": true,
|
|
75
75
|
"reason": "stale-presence — re-ask Step 1 (recorded outer session id does not match current)",
|
|
@@ -79,7 +79,7 @@ Returns the same `stale` / `reason` / `currentOuterSessionId` / `recordedOuterSe
|
|
|
79
79
|
}
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
The hard-pause on `step-1-mode-select` is preserved for ALL modes (defect #1 fix from slice 2026-06-28-
|
|
82
|
+
The hard-pause on `step-1-mode-select` is preserved for ALL modes (defect #1 fix from slice 2026-06-28-code-mode-bypass-fix). Stale-presence is an additional reason — even when the user names a profile explicitly, peaks-code can still surface the staleness for visibility.
|
|
83
83
|
|
|
84
84
|
## Auto-clear on session rotation
|
|
85
85
|
|
|
@@ -108,7 +108,7 @@ peaks workspace init --project . --json
|
|
|
108
108
|
peaks skill presence:check-stale --project . --json
|
|
109
109
|
# → { stale: true, reason: "no-presence", presence: null }
|
|
110
110
|
|
|
111
|
-
peaks
|
|
111
|
+
peaks code should-pause --step step-1-mode-select --mode full-auto --json
|
|
112
112
|
# → { shouldPause: true, reason: "step=step-1-mode-select is a mode/context-selection step → always pause" }
|
|
113
113
|
|
|
114
114
|
# 3. User picks a profile (or repeats "full-auto"). Then:
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Step 1 — Mode selection
|
|
2
2
|
|
|
3
|
-
> Body of `### Peaks-Loop Step 1`. After Step 0 has anchored the workspace and presence, when the user invokes Peaks-Loop
|
|
3
|
+
> Body of `### Peaks-Loop Step 1`. After Step 0 has anchored the workspace and presence, when the user invokes Peaks-Loop Code without explicitly naming an execution profile, use `AskUserQuestion` to pick the profile. Present the recommended full-auto path as the first/default option with a practical description for each:
|
|
4
4
|
|
|
5
5
|
1. **Full auto (Recommended)** — Peaks-Loop handles planning, role coordination, validation, and compact handoff end-to-end while preserving required confirmation gates for risky or shared-state actions.
|
|
6
6
|
2. **Assisted** — Peaks-Loop proposes plans, artifacts, and checks, then pauses for user decisions at major workflow boundaries.
|
|
7
7
|
3. **Swarm** — Peaks-Loop maximizes safe parallel role/worker execution for larger RD or QA workloads while keeping reducer validation and artifact boundaries explicit.
|
|
8
8
|
4. **Strict** — Peaks-Loop uses the most conservative gates: explicit confirmations, strict slice specs, coverage evidence, QA acceptance, and commit boundaries before continuing.
|
|
9
9
|
|
|
10
|
-
Map the user's selection to the `--mode` flag value (used by `peaks skill presence:set`; `presence:set --mode` accepts any string, so the name matches the user-facing label rather than overloading "
|
|
10
|
+
Map the user's selection to the `--mode` flag value (used by `peaks skill presence:set`; `presence:set --mode` accepts any string, so the name matches the user-facing label rather than overloading "code" which is also the skill name):
|
|
11
11
|
|
|
12
12
|
| User selects | `--mode` value |
|
|
13
13
|
|---|---|
|
|
@@ -16,6 +16,6 @@ Map the user's selection to the `--mode` flag value (used by `peaks skill presen
|
|
|
16
16
|
| Swarm | `swarm` |
|
|
17
17
|
| Strict | `strict` |
|
|
18
18
|
|
|
19
|
-
> Note: `peaks workflow route --mode
|
|
19
|
+
> Note: `peaks workflow route --mode code|team` is a **different** CLI dimension (code developer vs team flow) and is unrelated to the profile choice here. Do not conflate them.
|
|
20
20
|
|
|
21
21
|
If the user already names a profile in their invocation (e.g. `/peaks-code --full-auto`, "用全自动模式"), skip this question and use the named profile directly.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# OpenSpec Lifecycle for Peaks
|
|
1
|
+
# OpenSpec Lifecycle for Peaks Code
|
|
2
2
|
|
|
3
|
-
Peaks
|
|
3
|
+
Peaks Code orchestrates RD, QA, and SC. When the target repository uses OpenSpec, Code must drive the full lifecycle through the Peaks CLI so each role works against the same stable surface.
|
|
4
4
|
|
|
5
5
|
> **Slice #016 (2026-06-09)**: this document used to live at `openspec-mcp-workflow.md` and contained a section on the `peaks mcp *` lifecycle. The MCP subsystem was retired in slice #016; that section is gone. The OpenSpec lifecycle described below is unchanged.
|
|
6
6
|
|
|
@@ -8,19 +8,19 @@ Peaks Solo orchestrates RD, QA, and SC. When the target repository uses OpenSpec
|
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
10
|
peaks openspec render → RD authors a change pack (dry-run, then --apply)
|
|
11
|
-
peaks openspec validate →
|
|
11
|
+
peaks openspec validate → Code gates RD output before slicing starts
|
|
12
12
|
peaks openspec show → any role reads parsed proposal/tasks state
|
|
13
13
|
peaks openspec to-rd → RD projects the pack into refactor slice input
|
|
14
14
|
SC projects it into commit boundary candidates
|
|
15
15
|
peaks openspec validate → QA gates the final state before sign-off
|
|
16
|
-
peaks openspec archive →
|
|
16
|
+
peaks openspec archive → Code moves the change under changes/archive/<id>/
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Rules
|
|
19
|
+
Rules Code applies:
|
|
20
20
|
|
|
21
21
|
- `render --apply` is the only Peaks-managed way to write a change pack. Other roles must not hand-edit `openspec/changes/**`.
|
|
22
22
|
- `validate` is run twice per change in a refactor flow: once before slicing (RD entry gate) and once before archive (QA exit gate). Both must end with `data.valid === true`.
|
|
23
|
-
- `archive --apply` is the lifecycle terminator;
|
|
23
|
+
- `archive --apply` is the lifecycle terminator; Code only invokes it after QA acceptance and SC commit.
|
|
24
24
|
|
|
25
25
|
## Refactor workflow wiring
|
|
26
26
|
|
|
@@ -35,27 +35,27 @@ If the consuming LLM needs an MCP server for docs lookup or research (e.g. Conte
|
|
|
35
35
|
|
|
36
36
|
## Boundary
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Code must not write `openspec/changes/**` or `~/.claude/settings.json` directly. Every mutation goes through the CLI commands above. The CLI returns stable envelopes; Code captures them as artifact links rather than re-explaining their content in the handoff.
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
42
|
# Step 0.5 — OpenSpec first-run opt-in (conditional)
|
|
43
43
|
|
|
44
|
-
> Body of `### Peaks-Loop Step 0.5`. After the workspace is anchored, before project scan,
|
|
44
|
+
> Body of `### Peaks-Loop Step 0.5`. After the workspace is anchored, before project scan, Code checks whether
|
|
45
45
|
the project already has an `openspec/` directory. The lifecycle
|
|
46
46
|
(`render → validate → show → to-rd → validate → archive`) only applies
|
|
47
47
|
when `openspec/` exists; without it, RD/QA/SC silently skip the
|
|
48
48
|
openspec-aware paths and you lose change-proposal tracking, commit
|
|
49
49
|
boundaries from `tasks.md`, and the historical archive.
|
|
50
50
|
|
|
51
|
-
To make that opt-in visible instead of silent,
|
|
51
|
+
To make that opt-in visible instead of silent, Code runs:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
54
|
# 1. Detect whether the project already has openspec/.
|
|
55
55
|
ls <repo>/openspec/changes 2>&1
|
|
56
|
-
# 2. If absent, ask the user once — only on the first
|
|
56
|
+
# 2. If absent, ask the user once — only on the first Code run in this
|
|
57
57
|
# project. The decision is sticky: write it to .peaks/.peaks-openspec-opt-in.json
|
|
58
|
-
# so subsequent
|
|
58
|
+
# so subsequent Code invocations do not re-ask.
|
|
59
59
|
test -f <repo>/.peaks/.peaks-openspec-opt-in.json || \
|
|
60
60
|
echo "{\"enabled\": <bool>}" > <repo>/.peaks/.peaks-openspec-opt-in.json
|
|
61
61
|
```
|
|
@@ -65,11 +65,11 @@ file is missing):
|
|
|
65
65
|
|
|
66
66
|
| Option | What it does |
|
|
67
67
|
|---|---|
|
|
68
|
-
| Enable OpenSpec for this project (Recommended) | Run `peaks openspec init --project <repo> --apply`. After that, every
|
|
69
|
-
| Skip for now | Do nothing.
|
|
70
|
-
| Never ask again for this project | Write `{enabled: false, sticky: true}`.
|
|
68
|
+
| Enable OpenSpec for this project (Recommended) | Run `peaks openspec init --project <repo> --apply`. After that, every Code run uses the change-proposal lifecycle for the same project. |
|
|
69
|
+
| Skip for now | Do nothing. Code proceeds without openspec; the question is re-asked on the next first-run detection. |
|
|
70
|
+
| Never ask again for this project | Write `{enabled: false, sticky: true}`. Code stops asking. The user can re-enable later by removing `.peaks/.peaks-openspec-opt-in.json` and re-running. |
|
|
71
71
|
|
|
72
|
-
The first option is the recommended default because it gives
|
|
72
|
+
The first option is the recommended default because it gives Code the
|
|
73
73
|
full change-proposal lifecycle (proposal / tasks / design / specs
|
|
74
74
|
deltas, archive on ship, commit boundaries from `tasks.md`). It costs
|
|
75
75
|
only a single scaffolded directory and pays back the first time the
|
|
@@ -77,5 +77,5 @@ project needs a real review trail.
|
|
|
77
77
|
|
|
78
78
|
If the user picks "Enable", the only required follow-up is to make
|
|
79
79
|
sure `openspec/changes/` is added to git (it is part of the project
|
|
80
|
-
repo, not a tool-managed artefact).
|
|
80
|
+
repo, not a tool-managed artefact). Code does not run `git add` for
|
|
81
81
|
the user; that is the user's commit boundary.
|
|
@@ -27,7 +27,7 @@ checkpoint as often as it wants.
|
|
|
27
27
|
> does **not** expose a `--periodic-every <n>` override flag — the
|
|
28
28
|
> cadence is owned by the skill, not the CLI. Any patch that relaxes
|
|
29
29
|
> this must update both files in lockstep or fail the
|
|
30
|
-
> `tests/unit/
|
|
30
|
+
> `tests/unit/code/checkpoint-periodic-frequency.test.ts` guard.
|
|
31
31
|
|
|
32
32
|
## Checkpoint CLI contract
|
|
33
33
|
|
|
@@ -72,10 +72,10 @@ This step is strictly IDE-agnostic. The LLM calls the peaks CLI; no IDE-specific
|
|
|
72
72
|
|
|
73
73
|
## Companion surface — auto-compact (zero-pause)
|
|
74
74
|
|
|
75
|
-
When the runner crosses the v2.13.0 auto-compact thresholds (0.85 pre-compact / 0.95 red-line), `peaks session checkpoint` is NOT enough on its own — the LLM must also fire `peaks
|
|
75
|
+
When the runner crosses the v2.13.0 auto-compact thresholds (0.85 pre-compact / 0.95 red-line), `peaks session checkpoint` is NOT enough on its own — the LLM must also fire `peaks code auto-compact --execute` (or wait for the in-band PreToolUse hook at ratio ≥ 0.95 to compact the runner itself). See:
|
|
76
76
|
|
|
77
|
-
- `peaks
|
|
77
|
+
- `peaks code auto-compact --execute` — orchestrator that writes the convergence plan + dispatches the compact pathway
|
|
78
78
|
- `peaks session auto-compact-hook` — the PreToolUse hook entrypoint fired by `.claude/settings.local.json` (slice 2026-07-02-auto-compact-zero-pause)
|
|
79
79
|
- `.peaks/memory/2026-06-27-auto-compact-design.md` — zero-human-intervention design rationale
|
|
80
80
|
|
|
81
|
-
The two surfaces compose: `peaks session checkpoint` persists the context state, `peaks
|
|
81
|
+
The two surfaces compose: `peaks session checkpoint` persists the context state, `peaks code auto-compact` collapses the runner's window. The LLM fires both in the 0.85–0.95 zone; the hook fires alone at ≥ 0.95.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
| `peaks request lint <rid> --role <role> --project <path>` | Scan artifact body for unfilled `<placeholder>`, bare `- ...` bullets, TBD/TODO markers | Before every transition out of `draft` / before role handoff | Any `error`-severity finding (unfilled placeholder, bare-dot bullet) |
|
|
8
8
|
| `peaks request repair-status <rid> --project <path>` | Count RD↔QA repair cycles from `--reason` transition notes ("QA cycle N: ...") | Before every RD repair iteration in step 7 | Cycle count reached the 3-cycle cap |
|
|
9
9
|
| `peaks scan request-type-sanity --project <path> --type <type>` | Cross-verify declared `--type` against the actual `git diff` file mix (catches "feature mis-declared as docs" workflow violations) | After PRD type lock-in AND after each RD repair iteration | Declared type disagrees with the file mix |
|
|
10
|
-
| `peaks scan libraries --project <path>` | Enumerate every dependency + devDependency + peerDependency + optionalDependency with parsed major version; output goes to `## Library versions` in `rd/project-scan.md`. Read-only. | At
|
|
10
|
+
| `peaks scan libraries --project <path>` | Enumerate every dependency + devDependency + peerDependency + optionalDependency with parsed major version; output goes to `## Library versions` in `rd/project-scan.md`. Read-only. | At Code step 0.6 (alongside `peaks scan archetype`) | Always exits 0 (warnings in JSON envelope; never blocks) |
|
|
11
11
|
| `peaks slice check [--rid <rid>] [--project <path>]` | 4-stage slice 边界 check (typecheck + unit-tests + review-fanout + gate-verify-pipeline). Aggregate pass/fail; non-zero exit if any stage fails. See "Slice 边界 check" below for usage rules (boundary only, never inside a micro-cycle). | At slice 边界(post-micro-cycle, pre-peaks-qa)| Any stage fails |
|
|
12
12
|
|
|
13
13
|
Together with `peaks request transition` (which already CLI-enforces per-type artifact prerequisites), these five commands form the runtime quality net. SKILL.md prose is descriptive; the CLI is what physically blocks bad workflows.
|
|
@@ -60,7 +60,7 @@ peaks request transition <rid> --role prd --state confirmed-by-user --project <r
|
|
|
60
60
|
peaks request transition <rid> --role prd --state handed-off --project <repo> --json
|
|
61
61
|
|
|
62
62
|
# 3. Peaks-Loop Default sub-agent fan-out (slice 5 contract)
|
|
63
|
-
#
|
|
63
|
+
# Code computes the swarm plan from --type + frontendOnly + frontend-keyword scan,
|
|
64
64
|
# writes it to .peaks/_runtime/<sid>/sc/swarm-plan.json, then writes the slice
|
|
65
65
|
# DAG to .peaks/_runtime/<sid>/sc/slice-dag.json and launches ONE
|
|
66
66
|
# `peaks sub-agent dispatch --from-dag <dag-file>` call. The CLI's
|
|
@@ -75,10 +75,10 @@ peaks request transition <rid> --role prd --state handed-off --project <repo> --
|
|
|
75
75
|
# `peaks sub-agent dispatch <role>` calls in N separate messages when a fan-out
|
|
76
76
|
# shape exists — `--from-dag` is the only path that exercises the orchestrator.
|
|
77
77
|
#
|
|
78
|
-
# 3a. Pre-fan-out:
|
|
78
|
+
# 3a. Pre-fan-out: Code initialises every role's request artefact slot in the main
|
|
79
79
|
# loop so sub-agents find a stable rid <-> artefact binding. Each role's
|
|
80
80
|
# sub-agent may also call peaks request init itself (idempotent on the same rid);
|
|
81
|
-
#
|
|
81
|
+
# Code's call here is the source of truth. Only init roles that are in the
|
|
82
82
|
# swarm plan — roles not in the plan do not get a slot yet.
|
|
83
83
|
peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-fan-out
|
|
84
84
|
# for each role in swarm-plan.subAgents:
|
|
@@ -88,7 +88,7 @@ peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-
|
|
|
88
88
|
# e.g. if plan = [ui, rd, qa]: run init for ui, rd, qa.
|
|
89
89
|
# If plan = [rd, qa]: run for rd, qa only.
|
|
90
90
|
# If plan = [] (config|docs|chore skip): no inits here, jump to step 4 directly.
|
|
91
|
-
# 3b.
|
|
91
|
+
# 3b. Code writes the slice DAG to a JSON file then issues ONE
|
|
92
92
|
# `peaks sub-agent dispatch --from-dag <dag-file> --batch-id <id>` call.
|
|
93
93
|
# The CLI envelope returns N parallel buildToolCall descriptors
|
|
94
94
|
# (dispatchCount = len(swarm-plan.subAgents) when the DAG has >= 2
|
|
@@ -98,7 +98,7 @@ peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-
|
|
|
98
98
|
# concurrently, so wall-time approximates max(per-leaf time), not sum.
|
|
99
99
|
peaks sc build-dag --change-id <cid> --project <repo> --json > .peaks/_runtime/<sid>/sc/slice-dag.json
|
|
100
100
|
peaks sub-agent dispatch --from-dag .peaks/_runtime/<sid>/sc/slice-dag.json --batch-id <id> --project <repo> --json
|
|
101
|
-
# 3c. After fan-out,
|
|
101
|
+
# 3c. After fan-out, Code restores presence once and runs Gate B (ls checks):
|
|
102
102
|
peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-converged
|
|
103
103
|
ls .peaks/_runtime/<sid>/prd/requests/<rid>.md # PRD artefact must exist (Gate B hard)
|
|
104
104
|
# feature / refactor → ls .peaks/_runtime/<sid>/rd/tech-doc.md
|
|
@@ -174,7 +174,7 @@ peaks workspace reconcile --project <repo> --apply --older-than 7
|
|
|
174
174
|
# (c) Skip for now — blocks stay in the handoff only, no .peaks/memory/ write"
|
|
175
175
|
# If 10a returned 0 AND the session surfaced a stable project fact
|
|
176
176
|
# (decision / convention / approved refactor), STOP — peaks-txt must go
|
|
177
|
-
# back and embed at least one block before
|
|
177
|
+
# back and embed at least one block before Code can advance.
|
|
178
178
|
|
|
179
179
|
# 10c. After the user picks (a) or (b), run:
|
|
180
180
|
peaks memory extract --project <repo> --artifact .peaks/_runtime/<id>/txt/handoff.md --apply --json
|
|
@@ -195,13 +195,13 @@ Repair loop details: see `## Mandatory RD QA repair loop` in SKILL.md for the fu
|
|
|
195
195
|
# Step 0.8 (BLOCKING): LLM judges Job-shape, CLI records it.
|
|
196
196
|
# This is a RECORDER, not a detector. The LLM supplies --is-job + --rationale;
|
|
197
197
|
# the CLI writes .peaks/_runtime/<sid>/job-shape.json. Downstream steps call
|
|
198
|
-
# `peaks
|
|
198
|
+
# `peaks code read-job-shape` to enforce the decision exists.
|
|
199
199
|
|
|
200
200
|
# (The LLM does the semantic judgement, e.g.:)
|
|
201
201
|
# "The user named N=35 parallel app/ subdirs, said 'continue until all done',
|
|
202
202
|
# and disavowed cost. isJob=true, rationale=..., suggestedJobId=app-ut-batch,
|
|
203
203
|
# suggestedStrategy=rotating, confidence=high."
|
|
204
|
-
peaks
|
|
204
|
+
peaks code detect-job \
|
|
205
205
|
--is-job true \
|
|
206
206
|
--rationale "35 parallel app/ subdirs + 'until all done' + '不用考虑费用'" \
|
|
207
207
|
--suggested-job-id app-ut-batch \
|
|
@@ -209,7 +209,7 @@ peaks solo detect-job \
|
|
|
209
209
|
--confidence high
|
|
210
210
|
|
|
211
211
|
# Step 0.81-init: if Job-shaped, init BEFORE Step 1.
|
|
212
|
-
DECISION=$(peaks
|
|
212
|
+
DECISION=$(peaks code read-job-shape --json)
|
|
213
213
|
if [ "$(echo "$DECISION" | jq -r '.data.decision.isJob')" = "true" ]; then
|
|
214
214
|
JID=$(echo "$DECISION" | jq -r '.data.decision.suggestedJobId')
|
|
215
215
|
STRATEGY=$(echo "$DECISION" | jq -r '.data.decision.suggestedStrategy')
|
|
@@ -232,18 +232,18 @@ peaks job subagent-cleanup --job-id <jid> --batch-id <bid> --force # Step 0.87
|
|
|
232
232
|
|
|
233
233
|
# v3.1.2 size-fear ban: refuse to emit a final handoff while remaining > 0.
|
|
234
234
|
# The LLM cannot bypass this; --force-under-job requires explicit user approval.
|
|
235
|
-
peaks
|
|
235
|
+
peaks code emit-handoff --project <repo> --job-id <jid> --json
|
|
236
236
|
|
|
237
237
|
# v3.1.2 forced auto-compact: when --enforce-job-mode is set OR
|
|
238
238
|
# job-shape.json says isJob=true, ≥0.85 is MANDATORY auto-compact.
|
|
239
|
-
#
|
|
240
|
-
peaks
|
|
239
|
+
# Code MUST call this without confirmation under Job mode.
|
|
240
|
+
peaks code context-now --project <repo> --enforce-job-mode --json
|
|
241
241
|
peaks session auto-compact --execute --project <repo> --json
|
|
242
242
|
|
|
243
243
|
# v3.1.2 PreToolUse gate (installed by `peaks workspace init`):
|
|
244
|
-
# every Bash tool call runs `peaks
|
|
244
|
+
# every Bash tool call runs `peaks code gate-step-08` automatically.
|
|
245
245
|
# Exit 0 = allow (with optional Next: slice #N+1 of M line when
|
|
246
246
|
# progress.json exists). Exit 2 = BLOCKED; LLM must call
|
|
247
|
-
# `peaks
|
|
248
|
-
peaks
|
|
247
|
+
# `peaks code detect-job` first.
|
|
248
|
+
peaks code gate-step-08 --project <repo> --json
|
|
249
249
|
```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Peaks-Loop
|
|
1
|
+
# Peaks-Loop Code — Step 0.8 (v3.1.1 + v3.1.2) Gate Deep-Dive
|
|
2
2
|
|
|
3
3
|
> Read alongside `SKILL.md` Step 0.8. The SKILL.md header is the LOCKED CONTRACT; this file is the mechanics.
|
|
4
4
|
|
|
5
|
-
## Recorder contract (`peaks
|
|
5
|
+
## Recorder contract (`peaks code detect-job`)
|
|
6
6
|
|
|
7
|
-
The CLI does NOT judge whether the request is Job-shaped — that is the LLM's job. Keyword regexes are wrong here (too brittle, miss natural-language variants, shift the LLM's semantic understanding into code). The CLI is a **recorder and gate**: the LLM makes the judgement, writes it via `peaks
|
|
7
|
+
The CLI does NOT judge whether the request is Job-shaped — that is the LLM's job. Keyword regexes are wrong here (too brittle, miss natural-language variants, shift the LLM's semantic understanding into code). The CLI is a **recorder and gate**: the LLM makes the judgement, writes it via `peaks code detect-job`, and downstream steps refuse to proceed until the decision file exists.
|
|
8
8
|
|
|
9
9
|
### LLM judgement criteria (read once, then call the recorder)
|
|
10
10
|
|
|
@@ -16,40 +16,40 @@ The CLI does NOT judge whether the request is Job-shaped — that is the LLM's j
|
|
|
16
16
|
### Action sequence
|
|
17
17
|
|
|
18
18
|
1. LLM reads the user prompt and applies judgement → `isJob: boolean + rationale + suggestedJobId + suggestedStrategy + confidence`.
|
|
19
|
-
2. LLM calls `peaks
|
|
19
|
+
2. LLM calls `peaks code detect-job --is-job <bool> --rationale <text> --suggested-job-id <jid> --suggested-strategy <single|rotating> --confidence <high|medium|low> [--force]`.
|
|
20
20
|
3. CLI records to `.peaks/_runtime/<sessionId>/job-shape.json`.
|
|
21
21
|
4. If `isJob: true` → `peaks job init --job-id <jid> --slice-list <...> --main-loop-strategy <strategy> --rotate-every 3` (BEFORE Step 1).
|
|
22
22
|
5. Downstream steps (Step 1, Step 0.81, etc.) call `read-job-shape` to refuse if missing.
|
|
23
23
|
|
|
24
24
|
### Hard rule (v3.1.1 red-line #10)
|
|
25
25
|
|
|
26
|
-
LLM MUST NOT skip `peaks
|
|
26
|
+
LLM MUST NOT skip `peaks code detect-job` even when the trigger is obvious from context. If the next step's `read-job-shape` throws `JOB_SHAPE_NOT_DECIDED`, Code MUST record a decision before proceeding. Keyword-based "I already know it's a Job" is not a substitute.
|
|
27
27
|
|
|
28
28
|
## v3.1.2 mechanical gates
|
|
29
29
|
|
|
30
30
|
The recorder-only design was bypassed twice under load; the gate must be un-bypassable.
|
|
31
31
|
|
|
32
|
-
### 1. PreToolUse hook — `peaks
|
|
32
|
+
### 1. PreToolUse hook — `peaks code gate-step-08`
|
|
33
33
|
|
|
34
|
-
`peaks workspace init` installs the `Bash` matcher `peaks
|
|
34
|
+
`peaks workspace init` installs the `Bash` matcher `peaks code gate-step-08 --project .` in `.claude/settings.local.json` (alongside the existing Write|Edit|MultiEdit matcher). The hook runs before every Bash call:
|
|
35
35
|
|
|
36
36
|
| Condition | Exit | Behaviour |
|
|
37
37
|
|---|---|---|
|
|
38
38
|
| `job-shape.json` exists | 0 (allow) | allow + emit decision; if `progress.json` exists, add `Next: slice #N+1 of M (<currentSlice>)` |
|
|
39
|
-
| `job-shape.json` missing AND prompt matches the fail-closed backup regex | 2 (BLOCKED) | LLM must call `peaks
|
|
39
|
+
| `job-shape.json` missing AND prompt matches the fail-closed backup regex | 2 (BLOCKED) | LLM must call `peaks code detect-job` before retrying |
|
|
40
40
|
| `job-shape.json` missing AND no regex match | 0 (allow) | allow, no Job trigger |
|
|
41
41
|
|
|
42
|
-
### 2. Size-fear ban — `peaks
|
|
42
|
+
### 2. Size-fear ban — `peaks code emit-handoff`
|
|
43
43
|
|
|
44
44
|
Refuses to emit a final handoff while `remaining > 0` under Job mode. Pass `--force-under-job` only with explicit user approval.
|
|
45
45
|
|
|
46
46
|
### 3. Forced auto-compact — `--enforce-job-mode`
|
|
47
47
|
|
|
48
|
-
`peaks
|
|
48
|
+
`peaks code context-now --enforce-job-mode` (auto-enabled when `job-shape.json` says `isJob=true`) returns `action: 'auto-compact-now'` at ≥ 0.85; Code MUST call `peaks session auto-compact --execute` without confirmation.
|
|
49
49
|
|
|
50
50
|
### 4. On-disk slice progress — `progress.json`
|
|
51
51
|
|
|
52
|
-
`peaks job checkpoint --state done` writes `progress.json`. `peaks job progress --job-id <jid> [--allow-missing]` is the canonical reader; `peaks
|
|
52
|
+
`peaks job checkpoint --state done` writes `progress.json`. `peaks job progress --job-id <jid> [--allow-missing]` is the canonical reader; `peaks code gate-step-08` also surfaces it on every Bash call so the LLM cannot "wake up cold".
|
|
53
53
|
|
|
54
54
|
## Backup regex rationale
|
|
55
55
|
|
|
@@ -20,7 +20,7 @@ the skills compose. For sub-agent dispatch the relationship is:
|
|
|
20
20
|
|
|
21
21
|
| Surface | Who owns | What it does | Who calls it |
|
|
22
22
|
|---|---|---|---|
|
|
23
|
-
| SKILL.md (主面) | peaks-code, peaks-rd, peaks-qa | Tells the LLM when and why to dispatch a sub-agent; what prompt to pass; what artifacts to expect back | LLM (during normal
|
|
23
|
+
| SKILL.md (主面) | peaks-code, peaks-rd, peaks-qa | Tells the LLM when and why to dispatch a sub-agent; what prompt to pass; what artifacts to expect back | LLM (during normal Code / RD / QA flow) |
|
|
24
24
|
| CLI (副 / 原子) | `peaks sub-agent dispatch` | Validates the role, looks up the current IDE's `subAgentDispatcher`, returns a per-IDE tool-call descriptor + writes a dispatch record | LLM (read from the SKILL.md) |
|
|
25
25
|
| Dispatcher 抽象 (per-IDE) | `src/services/dispatch/sub-agent-dispatcher.ts` | Encapsulates the IDE-private tool name (claude-code: `Task`, trae: UNVERIFIED placeholder) and arg shape | CLI (called by the CLI) |
|
|
26
26
|
|
|
@@ -278,7 +278,7 @@ When writing a SKILL.md that fans out sub-agents:
|
|
|
278
278
|
|
|
279
279
|
### Sub-agent mechanism (IDE-agnostic dispatch, NOT Skill tool)
|
|
280
280
|
|
|
281
|
-
> Body of `### Sub-agent mechanism`. **
|
|
281
|
+
> Body of `### Sub-agent mechanism`. **Code is itself a skill running in the current session. To invoke a role in the Swarm, Code MUST call the IDE-agnostic dispatch primitive `peaks sub-agent dispatch <role>` — NOT the `Skill` tool, NOT any IDE-private sub-agent literal.** The `Skill` tool is single-stack and blocking; using it for "parallel" work was the v1.x illusion of concurrency. The dispatch CLI is the only mechanism that keeps SKILL.md free of IDE-private tool names and lets the same prompt work on every registered IDE.
|
|
282
282
|
|
|
283
283
|
Each sub-agent dispatch call looks like:
|
|
284
284
|
|
|
@@ -304,21 +304,21 @@ The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `refere
|
|
|
304
304
|
| `rd-planning` | `.peaks/_runtime/<sessionId>/rd/tech-doc.md` (feature/refactor) or `.peaks/_runtime/<sessionId>/rd/bug-analysis.md` (bugfix) | PRD body, project-scan, existing-system, codegraph |
|
|
305
305
|
| `qa-test-cases` | `.peaks/_runtime/<sessionId>/qa/test-cases/<rid>.md` | PRD body, RD planning artefact, project-scan, codegraph |
|
|
306
306
|
|
|
307
|
-
**
|
|
307
|
+
**Code launches all sub-agents in the swarm plan in a single message (multiple `peaks sub-agent dispatch` calls in parallel, each followed by execution of the returned toolCall)** — this is what gives real concurrency. Do not sequentialize them. The CLI returns N toolCall descriptors; the LLM fires all N in the same message; the IDE dispatches them concurrently; Code then waits for all to return, runs `ls` checks against the paths above (Peaks-Loop Gate B), and only then advances to RD implementation.
|
|
308
308
|
|
|
309
309
|
**Hard prohibitions on sub-agents** (also passed in each dispatch prompt):
|
|
310
310
|
|
|
311
311
|
- Do NOT call `Skill(skill="...")` — sub-agents must not recursively activate skills, that defeats the fan-out.
|
|
312
|
-
- Do NOT call `peaks skill presence:set` — only the main
|
|
313
|
-
- Do NOT open interactive user prompts. If a sub-agent needs clarification, it must return a `blocked` verdict in its return string and let
|
|
314
|
-
- Do NOT commit, push, install hooks, or apply settings.json mutations. Only
|
|
312
|
+
- Do NOT call `peaks skill presence:set` — only the main Code loop owns `.peaks/.active-skill.json`. Sub-agents write to a per-agent marker file `.peaks/_runtime/<sessionId>/system/sub-agent-<role>.json` if they need to record state, but never the main presence file.
|
|
313
|
+
- Do NOT open interactive user prompts. If a sub-agent needs clarification, it must return a `blocked` verdict in its return string and let Code handle the user message.
|
|
314
|
+
- Do NOT commit, push, install hooks, or apply settings.json mutations. Only Code holds those permissions.
|
|
315
315
|
- **Reinforced (2026-06-28 incident):** an RD sub-agent silently auto-committed its own diff during a fix-callerid-leak dispatch (commit `bff4dff`). The orchestrator caught the unauthorized commit on the next turn but the user had to manually re-approve. **Every dispatch prompt MUST copy the verbatim block below into its `--prompt` argument** so the sub-agent sees the rule with full weight:
|
|
316
316
|
|
|
317
317
|
```
|
|
318
318
|
## Commit / push policy (verbatim, mandatory)
|
|
319
319
|
- Do NOT run `git commit`, `git push`, `git tag`, `git checkout -b`, or any
|
|
320
320
|
state-mutating git command. Leave the diff on disk and return the
|
|
321
|
-
diff summary in your final message. The orchestrator (
|
|
321
|
+
diff summary in your final message. The orchestrator (Code) owns the
|
|
322
322
|
commit / push decision; it will run `git status` and `git diff` after
|
|
323
323
|
your return and decide whether to commit.
|
|
324
324
|
- If you believe a commit is urgent (e.g. emergency hotfix), return
|
|
@@ -327,7 +327,7 @@ The role's required artefact paths (also see peaks-ui/rd/qa SKILL.md and `refere
|
|
|
327
327
|
```
|
|
328
328
|
- **Do write heartbeats** — call `peaks sub-agent heartbeat --record <dispatchRecordPath> --status running --progress <pct> --note "<text>"` at least every 30s (see `references/sub-agent-dispatch.md` §G6 for the full contract). The parent Dispatcher uses these to render the live status line during the wait.
|
|
329
329
|
|
|
330
|
-
After every sub-agent dispatch returns,
|
|
330
|
+
After every sub-agent dispatch returns, Code **restores presence** once (not per-agent), then continues to Gate B verification:
|
|
331
331
|
|
|
332
332
|
```bash
|
|
333
333
|
peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate swarm-converged
|