peaks-loop 3.1.1 → 3.1.2
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 +24 -0
- package/dist/src/cli/commands/job-commands.js +54 -1
- package/dist/src/cli/commands/solo-commands.js +238 -12
- package/dist/src/services/job/job-progress-store.d.ts +60 -0
- package/dist/src/services/job/job-progress-store.js +70 -0
- package/dist/src/services/job/job-types.d.ts +4 -4
- package/dist/src/services/solo/emit-handoff.d.ts +49 -0
- package/dist/src/services/solo/emit-handoff.js +79 -0
- package/dist/src/services/solo/step-08-gate.d.ts +90 -0
- package/dist/src/services/solo/step-08-gate.js +136 -0
- package/dist/src/services/workspace/claude-settings-template.d.ts +6 -1
- package/dist/src/services/workspace/claude-settings-template.js +40 -1
- package/dist/src/shared/version.d.ts +1 -1
- package/dist/src/shared/version.js +1 -1
- package/package.json +1 -1
- package/skills/peaks-solo/SKILL.md +47 -98
- package/skills/peaks-solo/references/runbook.md +20 -0
- package/skills/peaks-solo/references/step-0-8-gate.md +60 -0
|
@@ -5,17 +5,15 @@ description: Full-auto orchestration facade for the Peaks-Loop skill family. Use
|
|
|
5
5
|
|
|
6
6
|
## Single-scope-axis naming convention (2.7.1)
|
|
7
7
|
|
|
8
|
-
The `.peaks/` workspace has a **single scope axis** (session-id) plus a nested **sub-agent axis** under `.peaks/_sub_agents/<sessionId>/...`. Use `<sessionId>` (NEVER bare `<sid>`).
|
|
9
|
-
|
|
10
|
-
**2.7.1:** `recordBypass` / `isBypassLimitReached` had a legacy write path that bypassed `.peaks/_runtime/` (slice 2.7.1 fix in `request-commands.ts:410`). Now writes canonical `.peaks/_runtime/<sid>/`. `getChangeArtifactRoot` removed. Test `skills-skill-md-naming.test.ts` enforces (a) zero bare `<sid>`, (b) axis labels, (c) this callout.
|
|
8
|
+
The `.peaks/` workspace has a **single scope axis** (session-id) plus a nested **sub-agent axis** under `.peaks/_sub_agents/<sessionId>/...`. Use `<sessionId>` (NEVER bare `<sid>`). Reviewable artifacts live at `.peaks/_runtime/<sessionId>/<role>/...` (gitignored); the change-id is an optional filename slug and does NOT route filesystem writes. CLI: session-id → `peaks session *`; sub-agent → `peaks sub-agent *`. OpenSpec's `openspec/changes/<change-id>/` vocabulary (L4) is preserved. Test `skills-skill-md-naming.test.ts` enforces (a) zero bare `<sid>`, (b) axis labels, (c) this callout.
|
|
11
9
|
|
|
12
10
|
## Karpathy guidance (Slice 1/6 — karpathy prompt-injection-lift)
|
|
13
11
|
|
|
14
|
-
Every sub-agent dispatch (`peaks-prd`, `peaks-rd`, `peaks-qa`, `peaks-ui`, `peaks-sc`, `peaks-txt`) MUST receive the 4 Karpathy guidelines. Append the verbatim block from `peaks-rd/references/rd-sub-agent-dispatch.md` §"Karpathy-guidelines context" to the dispatch prompt. Canonical skill id: `andrej-karpathy-skills:karpathy-guidelines`. Summary: **#1 Think Before Coding**, **#2 Simplicity First
|
|
12
|
+
Every sub-agent dispatch (`peaks-prd`, `peaks-rd`, `peaks-qa`, `peaks-ui`, `peaks-sc`, `peaks-txt`) MUST receive the 4 Karpathy guidelines. Append the verbatim block from `peaks-rd/references/rd-sub-agent-dispatch.md` §"Karpathy-guidelines context" to the dispatch prompt. Canonical skill id: `andrej-karpathy-skills:karpathy-guidelines`. Summary: **#1 Think Before Coding**, **#2 Simplicity First**, **#3 Surgical Changes**, **#4 Goal-Driven Execution**.
|
|
15
13
|
|
|
16
14
|
## Hard ban (effective 2.8.3 — read every session, no exceptions)
|
|
17
15
|
|
|
18
|
-
Never create `.peaks/_runtime/<YYYY-MM-DD-*>/` at the top level of `.peaks/`.
|
|
16
|
+
Never create `.peaks/_runtime/<YYYY-MM-DD-*>/` at the top level of `.peaks/`. ALL reviewable artifact dirs live under `.peaks/_runtime/<sessionId>/<role>/...` (gitignored) — never as siblings of `.peaks/_runtime/`. `peaks workspace init` creates only `.peaks/_runtime/<sessionId>/session.json`. If you find yourself about to write a date-prefixed directory directly under `.peaks/`, STOP and reroute under `.peaks/_runtime/<sessionId>/`. The `.gitignore` rule + vitest guard at `tests/unit/workspace/top-level-change-id-guard.test.ts` enforce this.
|
|
19
17
|
|
|
20
18
|
# Peaks-Loop Solo
|
|
21
19
|
|
|
@@ -31,7 +29,7 @@ This skill is the **primary surface**. The `peaks <cmd>` CLI is **auxiliary**
|
|
|
31
29
|
|
|
32
30
|
## Code-Change Red Line (BLOCKING — read before ANY tool call)
|
|
33
31
|
|
|
34
|
-
**Peaks-Loop Solo is an orchestrator, NOT an implementer. You MUST NOT write, edit, or modify any application source code directly.** Every code change goes through `peaks-solo → RD → QA → verdict`.
|
|
32
|
+
**Peaks-Loop Solo is an orchestrator, NOT an implementer. You MUST NOT write, edit, or modify any application source code directly.** Every code change goes through `peaks-solo → RD → QA → verdict`. **If you catch yourself about to write code, STOP.** Hand off to RD. Before declaring workflow complete, run `peaks workflow verify-pipeline --rid <rid> --project <repo> --json`.
|
|
35
33
|
|
|
36
34
|
## Peaks-Loop Startup sequence (MANDATORY — execute in order)
|
|
37
35
|
|
|
@@ -45,7 +43,7 @@ When a NEW conversation opens on a session whose `lastActivity` is from today AN
|
|
|
45
43
|
|
|
46
44
|
### Peaks-Loop Step N: Periodic checkpoint (auto-fire, no user action)
|
|
47
45
|
|
|
48
|
-
Proactive context-overflow defense. CLI: `peaks session checkpoint [--reason <r>] [...flags]`. Fire `--reason periodic` every 20 tool calls (G1 hard-coded), `--reason artifact-written` per PRD/RD/QA/TXT write
|
|
46
|
+
Proactive context-overflow defense. CLI: `peaks session checkpoint [--reason <r>] [...flags]`. Fire `--reason periodic` every 20 tool calls (G1 hard-coded), `--reason artifact-written` per PRD/RD/QA/TXT write. See `references/periodic-checkpoint.md` (otherwise `tests/unit/solo/checkpoint-periodic-frequency.test.ts` fails).
|
|
49
47
|
|
|
50
48
|
### Peaks-Loop Step 0.5: OpenSpec first-run opt-in (conditional)
|
|
51
49
|
|
|
@@ -55,9 +53,7 @@ Run when `openspec/` is absent and `.peaks/.peaks-openspec-opt-in.json` is missi
|
|
|
55
53
|
|
|
56
54
|
### Peaks-Loop Step 0.6: Audit + Goal (NEW)
|
|
57
55
|
|
|
58
|
-
Invoke peaks-audit after need expressed; store approved goal at `.peaks/_runtime/<sessionId>/audit-goal/<rid>.json`. **All autonomous work requires approved goal.**
|
|
59
|
-
|
|
60
|
-
→ see `references/audit-goal-gate.md`.
|
|
56
|
+
Invoke peaks-audit after need expressed; store approved goal at `.peaks/_runtime/<sessionId>/audit-goal/<rid>.json`. **All autonomous work requires approved goal.** → `references/audit-goal-gate.md`.
|
|
61
57
|
|
|
62
58
|
### Peaks-Loop Step N+1: Final Review (NEW)
|
|
63
59
|
|
|
@@ -65,11 +61,7 @@ After autonomous work (RD, QA, security, perf), invoke peaks-final-review for 4-
|
|
|
65
61
|
|
|
66
62
|
### Peaks-Loop Step N+2: Main-session context monitor (D6 + slice 2026-07-02)
|
|
67
63
|
|
|
68
|
-
After every 4th tool call, probe via `peaks solo context-now --project <repo> --json`. Thresholds: 50% / **0.85 pre-compact / 0.95 red-line** (v2.13.0).
|
|
69
|
-
|
|
70
|
-
**≥ 0.85**, LLM MUST fire `peaks solo auto-compact --execute --project <repo>` autonomously. **≥ 0.95** red line: next Bash/Task tool call fires `peaks session auto-compact-hook` (PreToolUse), which in-band spawns `claude --compact` against the current runner.
|
|
71
|
-
|
|
72
|
-
**Karpathy §4 exception**: compact red line keeps runner alive → zero-intervention wins. LLM does NOT ask user to run `/compact`. Honor `--in-flight-batch` (D6.e).
|
|
64
|
+
After every 4th tool call, probe via `peaks solo context-now --project <repo> --json`. Thresholds: 50% / **0.85 pre-compact / 0.95 red-line** (v2.13.0). **In Job mode ≥ 0.85 is MANDATORY auto-compact** (not advisory): Solo MUST call `peaks session auto-compact --execute --project <repo>` autonomously. Pass `--enforce-job-mode` to force the MANDATORY semantics in single-rid mode too (`job-shape.json` auto-enables it). **≥ 0.95** red line: next Bash/Task call fires `peaks session auto-compact-hook` (PreToolUse), in-band spawning `claude --compact`. **Karpathy §4 exception**: compact red line keeps runner alive → zero-intervention wins; LLM MUST NOT ask user to run `/compact`. Honor `--in-flight-batch` (D6.e).
|
|
73
65
|
|
|
74
66
|
### Peaks-Loop Step 0: Anchor the workflow (MANDATORY FIRST ACTIONS — no bail-out)
|
|
75
67
|
|
|
@@ -87,34 +79,30 @@ Run `peaks workspace init` + `peaks skill presence:set peaks-solo` BEFORE any an
|
|
|
87
79
|
|
|
88
80
|
After Step 0, run the resume-detection probe; surface via `AskUserQuestion` if a slice is in flight.
|
|
89
81
|
|
|
90
|
-
**
|
|
82
|
+
**v3.1.2 resume rule:** if `.peaks/_runtime/<sessionId>/job/<jid>/progress.json` exists, read it FIRST and surface `Next: slice #N of M (<currentSlice>)`. `peaks job progress --job-id <jid> [--allow-missing]` is the canonical reader; the same JSON is surfaced by `peaks solo gate-step-08` on every Bash call.
|
|
83
|
+
|
|
84
|
+
**v2.11.0 D7 override:** if user just `/compact`ed, run `peaks solo post-compact-detect --project <repo> --json` FIRST; `shouldAutoResume: true` skips AskUserQuestion (D7.b). Log to `.peaks/_runtime/<sessionId>/txt/auto-decisions.md`.
|
|
91
85
|
|
|
92
|
-
→ see `references/resume-detection.md
|
|
86
|
+
→ see `references/resume-detection.md`.
|
|
93
87
|
|
|
94
88
|
### Peaks-Loop Step 0.55: 1.x → 2.0 detection (BLOCKING on first invocation per session, when the project is not on a 2.0 layout)
|
|
95
89
|
|
|
96
|
-
|
|
90
|
+
After Step 0.7 returns "fresh", run `peaks upgrade --detect-1x --project <root> --json`. If `isOneX: true`, surface `AskUserQuestion`. Persist to `.peaks/preferences.json`. → `references/step-0-55-1x-detection.md`.
|
|
97
91
|
|
|
98
|
-
|
|
92
|
+
### Peaks-Loop Step 0.8 — Job 启动 (BLOCKING on LLM judgement — v3.1.1 patch + v3.1.2 mechanical gates)
|
|
99
93
|
|
|
100
|
-
|
|
94
|
+
The CLI is a **recorder + gate** for job-shape (the LLM judges). LLM calls `peaks solo detect-job --is-job <bool> --rationale <text> --suggested-job-id <jid> --suggested-strategy <single|rotating> --confidence <high|medium|low>`, which writes `.peaks/_runtime/<sessionId>/job-shape.json`. Downstream steps call `read-job-shape` and refuse if missing.
|
|
101
95
|
|
|
102
|
-
|
|
96
|
+
**Hard rule (v3.1.1 red-line #10):** LLM MUST NOT skip `peaks solo detect-job`. If `read-job-shape` throws `JOB_SHAPE_NOT_DECIDED`, record a decision before proceeding.
|
|
103
97
|
|
|
104
|
-
|
|
105
|
-
- N parallel targets (`app/components/*`, `app/modules/*`, `for each subdir`, "以目录为维度", "把剩下的也跑了").
|
|
106
|
-
- Completion phrase implying batch continuation (`until all done`, "继续执行下个 slice", "全部添加完", "all of them").
|
|
107
|
-
- Cost / length disavowal (`不用考虑费用`, "don't worry about cost", "一直跑").
|
|
108
|
-
- Explicit slice count (`25 slices`, "切分成 N 段", "拆成 N 块").
|
|
98
|
+
**v3.1.2 mechanical gates** (recorder-only was bypassed twice):
|
|
109
99
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
4. If `isJob: true` → `peaks job init --job-id <jid> --slice-list <...> --main-loop-strategy <strategy> --rotate-every 3` (BEFORE Step 1).
|
|
115
|
-
5. Downstream steps (Step 1, Step 0.81, etc.) call `read-job-shape` to refuse if missing.
|
|
100
|
+
- **PreToolUse hook** — `peaks workspace init` installs the `Bash` matcher `peaks solo gate-step-08 --project .`. Exits 0 when `job-shape.json` exists (also emits `Next: slice #N+1 of M` from `progress.json`); exits 2 BLOCKED when missing AND prompt matches a fail-closed backup regex; otherwise 0 (allow).
|
|
101
|
+
- **Size-fear ban** — `peaks solo emit-handoff` refuses a final handoff while `remaining > 0` under Job mode.
|
|
102
|
+
- **Forced auto-compact** — `peaks solo context-now --enforce-job-mode` (auto-enabled on `isJob=true`) returns `auto-compact-now` at ≥ 0.85; **In Job mode ≥ 0.85 is MANDATORY auto-compact** (not advisory).
|
|
103
|
+
- **On-disk slice progress** — `peaks job checkpoint --state done` writes `progress.json`; `peaks job progress --job-id <jid> [--allow-missing]` is the canonical reader.
|
|
116
104
|
|
|
117
|
-
|
|
105
|
+
Full mechanics (judgement criteria, hook table, backup-regex rationale, hook wiring) at `references/step-0-8-gate.md`.
|
|
118
106
|
|
|
119
107
|
### Peaks-Loop Step 0.81 — per-slice 收尾
|
|
120
108
|
|
|
@@ -126,37 +114,29 @@ Trigger: `repair-status` atCap=true, context-now red-line ≥5min, or `subagent-
|
|
|
126
114
|
|
|
127
115
|
### Peaks-Loop Step 0.86 — main session rotation
|
|
128
116
|
|
|
129
|
-
Active in rotating mode; fires every `rotateEvery` slices or on-demand
|
|
117
|
+
Active in rotating mode; fires every `rotateEvery` slices or on-demand via `peaks job rotate-now`. Sequence: cycle-summary → checkpoint rotate-marker → `peaks session rotate` → next turn resumes via `peaks session resume --job-id <jid>`.
|
|
130
118
|
|
|
131
119
|
### Peaks-Loop Step 0.87 — sub-agent cleanup gate
|
|
132
120
|
|
|
133
121
|
After every `peaks sub-agent dispatch --batch-id <id>` inside a Job, BEFORE next slice checkpoint: `peaks job subagent-cleanup --job-id <jid> --batch-id <id> --force`. Non-zero → block.
|
|
134
122
|
|
|
135
|
-
→ see `references/job-loop.md` for state machine, visibility
|
|
123
|
+
→ see `references/job-loop.md` for state machine, visibility, rotation cadence, cross-day recovery, 9 red lines.
|
|
136
124
|
|
|
137
125
|
### Peaks-Loop Step 1: Mode selection
|
|
138
126
|
|
|
139
|
-
Use `AskUserQuestion` with `Full auto (Recommended)` first when user did not name a profile OR skill presence is stale (run `peaks skill presence:check-stale --project <path> --json` first; `stale: true` ⇒ re-ask).
|
|
140
|
-
|
|
141
|
-
→ see `references/mode-selection.md`, `references/fast-mode.md`, `references/mode-selection-with-stale-presence.md`.
|
|
127
|
+
Use `AskUserQuestion` with `Full auto (Recommended)` first when user did not name a profile OR skill presence is stale (run `peaks skill presence:check-stale --project <path> --json` first; `stale: true` ⇒ re-ask). → `references/mode-selection.md`, `references/fast-mode.md`, `references/mode-selection-with-stale-presence.md`.
|
|
142
128
|
|
|
143
129
|
### Peaks-Loop Step 2: Re-set skill presence with the chosen mode
|
|
144
130
|
|
|
145
|
-
Re-run `peaks skill presence:set peaks-solo --mode <mode-value> --gate startup`. Install statusline on first run (`peaks statusline install`).
|
|
146
|
-
|
|
147
|
-
→ see `references/skill-presence-and-title.md`.
|
|
131
|
+
Re-run `peaks skill presence:set peaks-solo --mode <mode-value> --gate startup`. Install statusline on first run (`peaks statusline install`). → `references/skill-presence-and-title.md`.
|
|
148
132
|
|
|
149
133
|
### Peaks-Loop Step 2.3: Load project memory (durable, LLM-authored memories)
|
|
150
134
|
|
|
151
|
-
Run `peaks project memories --project <repo> --json` to read decisions / conventions / modules / rules / lessons from `.peaks/memory`.
|
|
152
|
-
|
|
153
|
-
→ see `references/project-memory-loading.md` for the kind table.
|
|
135
|
+
Run `peaks project memories --project <repo> --json` to read decisions / conventions / modules / rules / lessons from `.peaks/memory`. → `references/project-memory-loading.md`.
|
|
154
136
|
|
|
155
137
|
### Peaks-Loop Step 2.5: Set session title
|
|
156
138
|
|
|
157
|
-
Extract a short title from the user's first request (8-20 Chinese chars or 4-10 English words). Run `peaks session title` with the active sid. Skip if a title is already set.
|
|
158
|
-
|
|
159
|
-
→ see `references/skill-presence-and-title.md` (same file as Step 2).
|
|
139
|
+
Extract a short title from the user's first request (8-20 Chinese chars or 4-10 English words). Run `peaks session title` with the active sid. Skip if a title is already set. → `references/skill-presence-and-title.md` (same file as Step 2).
|
|
160
140
|
|
|
161
141
|
## Sub-agent session sharing (MANDATORY — one conversation = one sid)
|
|
162
142
|
|
|
@@ -164,11 +144,7 @@ When peaks-solo dispatches a sub-agent (peaks-rd, peaks-qa, peaks-ui, peaks-txt,
|
|
|
164
144
|
|
|
165
145
|
## Boundaries
|
|
166
146
|
|
|
167
|
-
Peaks-Loop Solo may: identify scenarios
|
|
168
|
-
|
|
169
|
-
Peaks-Loop Solo must NOT silently install hooks, create agents, enable MCP servers, modify Claude settings, create GitHub repos, or bypass role-skill artifacts.
|
|
170
|
-
|
|
171
|
-
→ see `references/boundaries.md` for the do / don't list.
|
|
147
|
+
Peaks-Loop Solo may: identify scenarios, recommend profiles, coordinate role skills through artifacts, coordinate project memory extraction, request user confirmation at risk/commit boundaries. Peaks-Loop Solo must NOT silently install hooks / create agents / enable MCP / modify Claude settings / create GitHub repos / bypass role-skill artifacts. → `references/boundaries.md`.
|
|
172
148
|
|
|
173
149
|
## Peaks-Loop GStack integration
|
|
174
150
|
|
|
@@ -176,7 +152,7 @@ Map gstack stages to Peaks-Loop role artifacts; preserve confirmation gates. →
|
|
|
176
152
|
|
|
177
153
|
## Peaks-Loop Local intermediate artifact workspace (MANDATORY)
|
|
178
154
|
|
|
179
|
-
Step 0 creates the workspace; all intermediate artifacts land under `.peaks/_runtime/<sessionId>/`. NEVER write Peaks-Loop intermediate artifacts to the project root
|
|
155
|
+
Step 0 creates the workspace; all intermediate artifacts land under `.peaks/_runtime/<sessionId>/`. NEVER write Peaks-Loop intermediate artifacts to the project root.
|
|
180
156
|
|
|
181
157
|
## Peaks-Loop Pre-RD project scan checklist (MANDATORY)
|
|
182
158
|
|
|
@@ -184,9 +160,7 @@ Before handing off to `peaks-rd`, scan the project and record findings to `.peak
|
|
|
184
160
|
|
|
185
161
|
## Peaks-Loop Frontend-only development mode
|
|
186
162
|
|
|
187
|
-
When the project has no live backend (no swagger.json, no API server), Solo must activate frontend-only mode. The CLI is authoritative — read `frontendOnly` and `frontendOnlyReason` from `peaks scan archetype --json`.
|
|
188
|
-
|
|
189
|
-
→ see `references/frontend-only-mode.md` for the mode contract, mock-data strategy, and the pre-flight keyword scan.
|
|
163
|
+
When the project has no live backend (no swagger.json, no API server), Solo must activate frontend-only mode. The CLI is authoritative — read `frontendOnly` and `frontendOnlyReason` from `peaks scan archetype --json`. → `references/frontend-only-mode.md`.
|
|
190
164
|
|
|
191
165
|
## Peaks-Loop Request type classification + Workflow order + Transition verification gates
|
|
192
166
|
|
|
@@ -196,27 +170,23 @@ The contract for the 6-type classification table, the 11-step workflow order, an
|
|
|
196
170
|
|
|
197
171
|
> **Slice 5:** when the slice DAG has ≥ 2 leaves at one topological level, dispatch via `peaks sub-agent dispatch --from-dag <dag-file>` (wall-time ≈ max, not sum).
|
|
198
172
|
|
|
199
|
-
Write DAG → `.peaks/_runtime/<sessionId>/sc/slice-dag.json`, run `peaks sub-agent dispatch --from-dag <dag-file> --batch-id <id>` once; orchestrator emits N parallel `buildToolCall` (`dispatchCount === N`).
|
|
173
|
+
Write DAG → `.peaks/_runtime/<sessionId>/sc/slice-dag.json`, run `peaks sub-agent dispatch --from-dag <dag-file> --batch-id <id>` once; orchestrator emits N parallel `buildToolCall` (`dispatchCount === N`).
|
|
200
174
|
|
|
201
|
-
> **2026-06-28 校准:** 主路径 = 唯一蜂群;config/docs/chore
|
|
175
|
+
> **2026-06-28 校准:** 主路径 = 唯一蜂群;config/docs/chore 跳过不打断。详见 `.peaks/memory/peaks-loop-24h-ai-programmer-positioning.md`。
|
|
202
176
|
|
|
203
177
|
### Hard constraint: fan-out is mandatory (slice 2026-06-24-audit-5th-p2)
|
|
204
178
|
|
|
205
|
-
> **No serial opt-out.** `preferences.fanout.defaultMode = 'serial'`
|
|
206
|
-
> was removed in 2.8.4; legacy values auto-migrate to `fan-out`. See
|
|
207
|
-
> `references/fanout-mandatory.md` for the rationale + migration contract.
|
|
179
|
+
> **No serial opt-out.** `preferences.fanout.defaultMode = 'serial'` was removed in 2.8.4; legacy values auto-migrate to `fan-out`.
|
|
208
180
|
|
|
209
|
-
→ see `references/swarm-dispatch-contract.md
|
|
181
|
+
→ see `references/swarm-dispatch-contract.md`, `references/sub-agent-dispatch.md` (NOT `Skill` tool), `references/fanout-mandatory.md`.
|
|
210
182
|
|
|
211
183
|
## Slice 调度:分层并行 + 上游同步(2026-06-28 校准)
|
|
212
184
|
|
|
213
|
-
> 分层并行(G12
|
|
185
|
+
> 分层并行(G12)+ 上游同步(G11)见 `.peaks/memory/peaks-loop-fork-sync-and-layered-parallel.md`。
|
|
214
186
|
|
|
215
187
|
## Peaks-Loop Mandatory RD QA repair loop (AUTO-PROCEED)
|
|
216
188
|
|
|
217
|
-
After `peaks-rd` finishes
|
|
218
|
-
|
|
219
|
-
→ see `references/micro-cycle.md` for the full 5-step procedure (transition, re-launch, fix, re-run, restore presence) + 3-cycle cap.
|
|
189
|
+
After `peaks-rd` finishes, Solo MUST auto-route to `peaks-qa` without waiting for confirmation. Cap: 3 cycles; on 3rd failure emit blocked TXT handoff. Full 5-step procedure at `references/micro-cycle.md`.
|
|
220
190
|
|
|
221
191
|
## Default runbook
|
|
222
192
|
|
|
@@ -226,14 +196,11 @@ When adding new CLI commands, mirror into `references/runbook.md` and `tests/uni
|
|
|
226
196
|
|
|
227
197
|
## RD micro-cycle (TDD small-step rapid-test loop)
|
|
228
198
|
|
|
229
|
-
> **Slice 内部**的修复 / refactor / lint 修复走 micro-cycle(5-10s/cycle
|
|
230
|
-
> Slice 边界走 `peaks slice check`(一次性 4 项自检)。
|
|
231
|
-
> 不要把 micro-cycle 跟边界 check 混用——前者 100ms 反馈循环,后者 30s+ 全套。
|
|
232
|
-
> 完整手册:`references/micro-cycle.md`。
|
|
199
|
+
> **Slice 内部**的修复 / refactor / lint 修复走 micro-cycle(5-10s/cycle);Slice 边界走 `peaks slice check`。完整手册:`references/micro-cycle.md`。
|
|
233
200
|
|
|
234
201
|
## Peaks-Loop Project standards preflight
|
|
235
202
|
|
|
236
|
-
Gather
|
|
203
|
+
Gather via `peaks standards init/update --project <path> --dry-run`. Standards must reflect the project scan (component library, CSS, build tool, state, routing) — never emit a generic template.
|
|
237
204
|
|
|
238
205
|
## Peaks-Loop Refactor mode
|
|
239
206
|
|
|
@@ -245,7 +212,7 @@ Five CLI commands harden the workflow against silent skips: `peaks request lint`
|
|
|
245
212
|
|
|
246
213
|
## Peaks-Loop Completion handoff
|
|
247
214
|
|
|
248
|
-
After final validation, refresh project-local standards via `peaks standards init/update` (never hand-write). Use Peaks-Loop TXT for the compact handoff capsule
|
|
215
|
+
After final validation, refresh project-local standards via `peaks standards init/update` (never hand-write). Use Peaks-Loop TXT for the compact handoff capsule. **Presence management is delegated to the last downstream skill** — peaks-solo does not call `peaks skill presence:clear` itself.
|
|
249
216
|
|
|
250
217
|
## Peaks-Loop Step 11: Memory sediment (BLOCKING on workflow complete)
|
|
251
218
|
|
|
@@ -253,45 +220,27 @@ After final validation, refresh project-local standards via `peaks standards ini
|
|
|
253
220
|
|
|
254
221
|
### Substeps (BLOCKING)
|
|
255
222
|
|
|
256
|
-
**11a — Gate A (txt/ inventory):**
|
|
257
|
-
|
|
258
|
-
```bash
|
|
259
|
-
find .peaks/_runtime/<sessionId>/txt/ -type f -name '*.md' | head
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
If **0 files** → STOP. Dispatch `peaks-txt` first to write `handoff.md`, then return to 11c.
|
|
263
|
-
|
|
264
|
-
**11b — Gate B (memory block embed scan, skill-side only):**
|
|
265
|
-
|
|
266
|
-
```bash
|
|
267
|
-
grep -c 'peaks-memory:start' .peaks/_runtime/<sessionId>/txt/handoff.md || true
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
If **0 AND this session surfaced a stable project fact** (decision / convention / approved refactor / hard rule), STOP and tell peaks-txt to embed at least one `<!-- peaks-memory:start -->` block first.
|
|
271
|
-
|
|
272
|
-
**11c — Canonical extract (the only CLI that writes `.peaks/memory/`):**
|
|
223
|
+
**11a — Gate A (txt/ inventory):** `find .peaks/_runtime/<sessionId>/txt/ -type f -name '*.md' | head`. If **0 files** → STOP. Dispatch `peaks-txt` first to write `handoff.md`, then return to 11c.
|
|
273
224
|
|
|
274
|
-
|
|
275
|
-
peaks memory extract --project <repo> --artifact .peaks/_runtime/<sessionId>/txt/handoff.md --apply --json
|
|
276
|
-
```
|
|
225
|
+
**11b — Gate B (memory block embed scan):** `grep -c 'peaks-memory:start' .peaks/_runtime/<sessionId>/txt/handoff.md || true`. If **0 AND this session surfaced a stable project fact** (decision / convention / approved refactor / hard rule), STOP and tell peaks-txt to embed at least one `<!-- peaks-memory:start -->` block first.
|
|
277
226
|
|
|
278
|
-
`--apply` is REQUIRED
|
|
227
|
+
**11c — Canonical extract** (the only CLI that writes `.peaks/memory/`): `peaks memory extract --project <repo> --artifact .peaks/_runtime/<sessionId>/txt/handoff.md --apply --json`. `--apply` is REQUIRED (without it the command only previews — no files land).
|
|
279
228
|
|
|
280
229
|
**11d — Gate C (zero-write outcome):** If `extractedCount === 0` after 11c, fire AskUserQuestion:
|
|
281
230
|
|
|
282
231
|
> "本次 solo 未沉淀任何 `.peaks/memory` 文件。可选: (a) 回去在 handoff.md 嵌入至少 1 个 `peaks-memory:start` block 后重试; (b) 显式接受 no-sediment 并记录为 lesson; (c) 取消完成。"
|
|
283
232
|
|
|
284
|
-
Default option = (a). Solo MUST NOT silently accept (b) without user pick.
|
|
233
|
+
Default option = (a). Solo MUST NOT silently accept (b) without user pick. Full bash + flow at `references/runbook.md` §Step 11.
|
|
285
234
|
|
|
286
|
-
**Why this step exists:** audit 2026-07-03 confirmed 2 consecutive sessions produced zero `.peaks/memory/` files despite completing RD + QA + handoff artifacts
|
|
235
|
+
**Why this step exists:** audit 2026-07-03 confirmed 2 consecutive sessions produced zero `.peaks/memory/` files despite completing RD + QA + handoff artifacts; `assisted` mode silently skipped runbook Step 10 (no STOP condition). **Why `peaks memory extract` (not `peaks project memories:extract`):** the artifact-scoped extract is canonical; the batch-scoped sibling is for non-handoff flows. Always use `peaks memory extract --apply`.
|
|
287
236
|
|
|
288
237
|
## Peaks-Loop External references and lifecycle
|
|
289
238
|
|
|
290
|
-
3rd-party integrations (codegraph, mattpocock/skills, shadcn/ui, MCPs, Context7) follow Discovery → Reference → Side effect through Peaks CLI only. Run `peaks capabilities` for capability discovery; treat external skills as reference material only. MCP servers (Playwright / Chrome DevTools / Figma) are user-installed — check the tool list for `mcp__<server>__*` entries. Do not execute upstream installer / run upstream commands / persist sensitive examples / install upstream resources directly — funnel side effects through the Peaks CLI surface. Peaks-Loop Solo gates
|
|
239
|
+
3rd-party integrations (codegraph, mattpocock/skills, shadcn/ui, MCPs, Context7) follow Discovery → Reference → Side effect through Peaks CLI only. Run `peaks capabilities` for capability discovery; treat external skills as reference material only. MCP servers (Playwright / Chrome DevTools / Figma) are user-installed — check the tool list for `mcp__<server>__*` entries. Do not execute upstream installer / run upstream commands / persist sensitive examples / install upstream resources directly — funnel side effects through the Peaks CLI surface. Peaks-Loop Solo gates remain authoritative. → `references/external-references.md` + `references/external-skill-invocation.md`.
|
|
291
240
|
|
|
292
241
|
## Codegraph orchestration context
|
|
293
242
|
|
|
294
|
-
`peaks codegraph affected` is an optional project-analysis enhancement (untrusted supporting evidence)
|
|
243
|
+
`peaks codegraph affected` is an optional project-analysis enhancement (untrusted supporting evidence) for role handoff. Solo must not treat codegraph output as approval for scope, design, or QA verdict. Never mutate agent settings / hooks from codegraph; do not commit `.codegraph/` artifacts. RD writes `.peaks/_runtime/<sessionId>/rd/codegraph-context.md`; QA / TXT consume the same envelope. → `references/codegraph-orchestration.md`.
|
|
295
244
|
|
|
296
245
|
## Sub-agent context governance (G7 + G7.7 + G8 + G9 — slice #010)
|
|
297
246
|
|
|
@@ -299,7 +248,7 @@ Main LLM reducer sees metadata-only view (~200 chars/sub-agent); on-demand `Read
|
|
|
299
248
|
|
|
300
249
|
## Sub-agent cross-batch signal — G8.4 share / shared-read / await (slice 2026-06-23-audit-3rd)
|
|
301
250
|
|
|
302
|
-
Three CLI primitives let sibling sub-agents coordinate
|
|
251
|
+
Three CLI primitives let sibling sub-agents coordinate: `peaks sub-agent share / shared-read / await` (last-write-wins, ≤ 1KB warn / ≥ 64KB reject). Channel file gitignored under `.peaks/_sub_agents/<sessionId>/shared/`.
|
|
303
252
|
|
|
304
253
|
## References
|
|
305
254
|
|
|
@@ -219,6 +219,9 @@ fi
|
|
|
219
219
|
|
|
220
220
|
# After Step 7 (RD+QA commit) lands AND Step 0.8 fired (state.json exists):
|
|
221
221
|
peaks job checkpoint --slice-id <rid> --state done --commit-sha $(git rev-parse HEAD)
|
|
222
|
+
# v3.1.2: `peaks job checkpoint --state done` ALSO writes
|
|
223
|
+
# .peaks/_runtime/<sid>/job/<jid>/progress.json. Read it on resume:
|
|
224
|
+
peaks job progress --job-id <jid> --json
|
|
222
225
|
peaks job status --job-id <jid> --json
|
|
223
226
|
peaks job subagent-cleanup --job-id <jid> --batch-id <bid> --force # Step 0.87 gate
|
|
224
227
|
# Loop control:
|
|
@@ -226,4 +229,21 @@ peaks job subagent-cleanup --job-id <jid> --batch-id <bid> --force # Step 0.87
|
|
|
226
229
|
# remaining == 0 → Step 8/9/10/11 (original tail)
|
|
227
230
|
# blocked (strict) → peaks job block + STOP
|
|
228
231
|
# Rotating-mode: every rotateEvery slices → Step 0.86 (peaks session rotate + resume)
|
|
232
|
+
|
|
233
|
+
# v3.1.2 size-fear ban: refuse to emit a final handoff while remaining > 0.
|
|
234
|
+
# The LLM cannot bypass this; --force-under-job requires explicit user approval.
|
|
235
|
+
peaks solo emit-handoff --project <repo> --job-id <jid> --json
|
|
236
|
+
|
|
237
|
+
# v3.1.2 forced auto-compact: when --enforce-job-mode is set OR
|
|
238
|
+
# job-shape.json says isJob=true, ≥0.85 is MANDATORY auto-compact.
|
|
239
|
+
# Solo MUST call this without confirmation under Job mode.
|
|
240
|
+
peaks solo context-now --project <repo> --enforce-job-mode --json
|
|
241
|
+
peaks session auto-compact --execute --project <repo> --json
|
|
242
|
+
|
|
243
|
+
# v3.1.2 PreToolUse gate (installed by `peaks workspace init`):
|
|
244
|
+
# every Bash tool call runs `peaks solo gate-step-08` automatically.
|
|
245
|
+
# Exit 0 = allow (with optional Next: slice #N+1 of M line when
|
|
246
|
+
# progress.json exists). Exit 2 = BLOCKED; LLM must call
|
|
247
|
+
# `peaks solo detect-job` first.
|
|
248
|
+
peaks solo gate-step-08 --project <repo> --json
|
|
229
249
|
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Peaks-Loop Solo — Step 0.8 (v3.1.1 + v3.1.2) Gate Deep-Dive
|
|
2
|
+
|
|
3
|
+
> Read alongside `SKILL.md` Step 0.8. The SKILL.md header is the LOCKED CONTRACT; this file is the mechanics.
|
|
4
|
+
|
|
5
|
+
## Recorder contract (`peaks solo detect-job`)
|
|
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 solo detect-job`, and downstream steps refuse to proceed until the decision file exists.
|
|
8
|
+
|
|
9
|
+
### LLM judgement criteria (read once, then call the recorder)
|
|
10
|
+
|
|
11
|
+
- N parallel targets (`app/components/*`, `app/modules/*`, `for each subdir`, "以目录为维度", "把剩下的也跑了").
|
|
12
|
+
- Completion phrase implying batch continuation (`until all done`, "继续执行下个 slice", "全部添加完", "all of them").
|
|
13
|
+
- Cost / length disavowal (`不用考虑费用`, "don't worry about cost", "一直跑").
|
|
14
|
+
- Explicit slice count (`25 slices`, "切分成 N 段", "拆成 N 块").
|
|
15
|
+
|
|
16
|
+
### Action sequence
|
|
17
|
+
|
|
18
|
+
1. LLM reads the user prompt and applies judgement → `isJob: boolean + rationale + suggestedJobId + suggestedStrategy + confidence`.
|
|
19
|
+
2. LLM calls `peaks solo detect-job --is-job <bool> --rationale <text> --suggested-job-id <jid> --suggested-strategy <single|rotating> --confidence <high|medium|low> [--force]`.
|
|
20
|
+
3. CLI records to `.peaks/_runtime/<sessionId>/job-shape.json`.
|
|
21
|
+
4. If `isJob: true` → `peaks job init --job-id <jid> --slice-list <...> --main-loop-strategy <strategy> --rotate-every 3` (BEFORE Step 1).
|
|
22
|
+
5. Downstream steps (Step 1, Step 0.81, etc.) call `read-job-shape` to refuse if missing.
|
|
23
|
+
|
|
24
|
+
### Hard rule (v3.1.1 red-line #10)
|
|
25
|
+
|
|
26
|
+
LLM MUST NOT skip `peaks solo detect-job` even when the trigger is obvious from context. If the next step's `read-job-shape` throws `JOB_SHAPE_NOT_DECIDED`, Solo MUST record a decision before proceeding. Keyword-based "I already know it's a Job" is not a substitute.
|
|
27
|
+
|
|
28
|
+
## v3.1.2 mechanical gates
|
|
29
|
+
|
|
30
|
+
The recorder-only design was bypassed twice under load; the gate must be un-bypassable.
|
|
31
|
+
|
|
32
|
+
### 1. PreToolUse hook — `peaks solo gate-step-08`
|
|
33
|
+
|
|
34
|
+
`peaks workspace init` installs the `Bash` matcher `peaks solo gate-step-08 --project .` in `.claude/settings.local.json` (alongside the existing Write|Edit|MultiEdit matcher). The hook runs before every Bash call:
|
|
35
|
+
|
|
36
|
+
| Condition | Exit | Behaviour |
|
|
37
|
+
|---|---|---|
|
|
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 solo detect-job` before retrying |
|
|
40
|
+
| `job-shape.json` missing AND no regex match | 0 (allow) | allow, no Job trigger |
|
|
41
|
+
|
|
42
|
+
### 2. Size-fear ban — `peaks solo emit-handoff`
|
|
43
|
+
|
|
44
|
+
Refuses to emit a final handoff while `remaining > 0` under Job mode. Pass `--force-under-job` only with explicit user approval.
|
|
45
|
+
|
|
46
|
+
### 3. Forced auto-compact — `--enforce-job-mode`
|
|
47
|
+
|
|
48
|
+
`peaks solo context-now --enforce-job-mode` (auto-enabled when `job-shape.json` says `isJob=true`) returns `action: 'auto-compact-now'` at ≥ 0.85; Solo MUST call `peaks session auto-compact --execute` without confirmation.
|
|
49
|
+
|
|
50
|
+
### 4. On-disk slice progress — `progress.json`
|
|
51
|
+
|
|
52
|
+
`peaks job checkpoint --state done` writes `progress.json`. `peaks job progress --job-id <jid> [--allow-missing]` is the canonical reader; `peaks solo gate-step-08` also surfaces it on every Bash call so the LLM cannot "wake up cold".
|
|
53
|
+
|
|
54
|
+
## Backup regex rationale
|
|
55
|
+
|
|
56
|
+
The fail-closed backup regex (mentioned above) exists so the gate has defense in depth: even if the recorder's downstream enforcement is bypassed, the hook catches obvious Job-shaped prompts. The regex is intentionally narrow — it MUST miss benign prompts and MUST hit obvious batches — so the LLM-side judgement remains primary.
|
|
57
|
+
|
|
58
|
+
## Hook wiring
|
|
59
|
+
|
|
60
|
+
`peaks workspace init` writes both matchers (Bash + Write|Edit|MultiEdit) atomically; if either fails the whole init fails. `peaks workspace init --remove-hooks` reverses both. The Bash matcher is required for Step 0.8; the Write|Edit|MultiEdit matcher pre-existed (Step 0 [Fact-Forcing Gate]).
|