peaks-cli 1.4.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +51 -0
- package/CHANGELOG.md +238 -0
- package/README-en.md +226 -0
- package/README.md +152 -122
- package/dist/src/cli/commands/agent-commands.d.ts +20 -0
- package/dist/src/cli/commands/agent-commands.js +48 -0
- package/dist/src/cli/commands/audit-commands.d.ts +18 -0
- package/dist/src/cli/commands/audit-commands.js +138 -0
- package/dist/src/cli/commands/classify-classify-commands.d.ts +19 -0
- package/dist/src/cli/commands/classify-classify-commands.js +151 -0
- package/dist/src/cli/commands/code-review-commands.d.ts +34 -0
- package/dist/src/cli/commands/code-review-commands.js +83 -0
- package/dist/src/cli/commands/config-commands.js +90 -0
- package/dist/src/cli/commands/context-commands.d.ts +21 -0
- package/dist/src/cli/commands/context-commands.js +167 -0
- package/dist/src/cli/commands/core-artifact-commands.js +60 -2
- package/dist/src/cli/commands/hook-handle.js +50 -0
- package/dist/src/cli/commands/loop-commands.d.ts +21 -0
- package/dist/src/cli/commands/loop-commands.js +128 -0
- package/dist/src/cli/commands/openspec-commands.js +37 -0
- package/dist/src/cli/commands/preferences-commands.d.ts +2 -0
- package/dist/src/cli/commands/preferences-commands.js +147 -0
- package/dist/src/cli/commands/skill-conformance-commands.d.ts +9 -0
- package/dist/src/cli/commands/skill-conformance-commands.js +39 -0
- package/dist/src/cli/commands/understand-commands.js +34 -0
- package/dist/src/cli/commands/upgrade-commands.d.ts +23 -0
- package/dist/src/cli/commands/upgrade-commands.js +57 -0
- package/dist/src/cli/commands/workflow-commands.js +70 -0
- package/dist/src/cli/commands/workspace-commands.js +86 -0
- package/dist/src/cli/program.js +30 -0
- package/dist/src/services/agent/ecc-agent-service.d.ts +47 -0
- package/dist/src/services/agent/ecc-agent-service.js +143 -0
- package/dist/src/services/artifacts/request-artifact-service.js +14 -0
- package/dist/src/services/audit/backing-detector.d.ts +24 -0
- package/dist/src/services/audit/backing-detector.js +59 -0
- package/dist/src/services/audit/classifier.d.ts +38 -0
- package/dist/src/services/audit/classifier.js +127 -0
- package/dist/src/services/audit/enforcers/active-skill-resolver.d.ts +29 -0
- package/dist/src/services/audit/enforcers/active-skill-resolver.js +71 -0
- package/dist/src/services/audit/enforcers/design-draft-confirm.d.ts +25 -0
- package/dist/src/services/audit/enforcers/design-draft-confirm.js +54 -0
- package/dist/src/services/audit/enforcers/lint-audit-regression.d.ts +21 -0
- package/dist/src/services/audit/enforcers/lint-audit-regression.js +86 -0
- package/dist/src/services/audit/enforcers/lint-catalog-governance.d.ts +27 -0
- package/dist/src/services/audit/enforcers/lint-catalog-governance.js +38 -0
- package/dist/src/services/audit/enforcers/lint-cli-back.d.ts +16 -0
- package/dist/src/services/audit/enforcers/lint-cli-back.js +35 -0
- package/dist/src/services/audit/enforcers/lint-output-style.d.ts +11 -0
- package/dist/src/services/audit/enforcers/lint-output-style.js +94 -0
- package/dist/src/services/audit/enforcers/lint-reference-integrity.d.ts +6 -0
- package/dist/src/services/audit/enforcers/lint-reference-integrity.js +83 -0
- package/dist/src/services/audit/enforcers/lint-reference-shape.d.ts +30 -0
- package/dist/src/services/audit/enforcers/lint-reference-shape.js +272 -0
- package/dist/src/services/audit/enforcers/lint-style.d.ts +49 -0
- package/dist/src/services/audit/enforcers/lint-style.js +173 -0
- package/dist/src/services/audit/enforcers/lint-workflow-shape.d.ts +5 -0
- package/dist/src/services/audit/enforcers/lint-workflow-shape.js +141 -0
- package/dist/src/services/audit/enforcers/login-gate.d.ts +23 -0
- package/dist/src/services/audit/enforcers/login-gate.js +40 -0
- package/dist/src/services/audit/enforcers/mock-placement.d.ts +25 -0
- package/dist/src/services/audit/enforcers/mock-placement.js +48 -0
- package/dist/src/services/audit/enforcers/no-root-pollution.d.ts +21 -0
- package/dist/src/services/audit/enforcers/no-root-pollution.js +56 -0
- package/dist/src/services/audit/enforcers/pre-rd-scan.d.ts +22 -0
- package/dist/src/services/audit/enforcers/pre-rd-scan.js +23 -0
- package/dist/src/services/audit/enforcers/prototype-fidelity.d.ts +25 -0
- package/dist/src/services/audit/enforcers/prototype-fidelity.js +75 -0
- package/dist/src/services/audit/enforcers/resume-detection.d.ts +21 -0
- package/dist/src/services/audit/enforcers/resume-detection.js +52 -0
- package/dist/src/services/audit/enforcers/solo-code-ban.d.ts +23 -0
- package/dist/src/services/audit/enforcers/solo-code-ban.js +27 -0
- package/dist/src/services/audit/enforcers/sub-agent-sid.d.ts +25 -0
- package/dist/src/services/audit/enforcers/sub-agent-sid.js +63 -0
- package/dist/src/services/audit/enforcers/tech-doc-presence.d.ts +28 -0
- package/dist/src/services/audit/enforcers/tech-doc-presence.js +35 -0
- package/dist/src/services/audit/red-line-catalog-p2-a.d.ts +21 -0
- package/dist/src/services/audit/red-line-catalog-p2-a.js +233 -0
- package/dist/src/services/audit/red-line-catalog-p2-b.d.ts +19 -0
- package/dist/src/services/audit/red-line-catalog-p2-b.js +225 -0
- package/dist/src/services/audit/red-line-catalog.d.ts +51 -0
- package/dist/src/services/audit/red-line-catalog.js +210 -0
- package/dist/src/services/audit/red-lines-service.d.ts +23 -0
- package/dist/src/services/audit/red-lines-service.js +486 -0
- package/dist/src/services/audit/scanners/openspec-scanner.d.ts +15 -0
- package/dist/src/services/audit/scanners/openspec-scanner.js +55 -0
- package/dist/src/services/audit/scanners/rules-tree-scanner.d.ts +16 -0
- package/dist/src/services/audit/scanners/rules-tree-scanner.js +56 -0
- package/dist/src/services/audit/scanners/skills-tree-scanner.d.ts +17 -0
- package/dist/src/services/audit/scanners/skills-tree-scanner.js +46 -0
- package/dist/src/services/audit/static-service.d.ts +57 -0
- package/dist/src/services/audit/static-service.js +125 -0
- package/dist/src/services/audit/types.d.ts +69 -0
- package/dist/src/services/audit/types.js +13 -0
- package/dist/src/services/classify/classify-service.d.ts +42 -0
- package/dist/src/services/classify/classify-service.js +122 -0
- package/dist/src/services/classify/classify-types.d.ts +79 -0
- package/dist/src/services/classify/classify-types.js +90 -0
- package/dist/src/services/code-review/ocr-service.d.ts +129 -0
- package/dist/src/services/code-review/ocr-service.js +362 -0
- package/dist/src/services/config/config-migration.d.ts +32 -0
- package/dist/src/services/config/config-migration.js +92 -0
- package/dist/src/services/config/config-restore.d.ts +10 -0
- package/dist/src/services/config/config-restore.js +47 -0
- package/dist/src/services/config/config-rollback.d.ts +13 -0
- package/dist/src/services/config/config-rollback.js +26 -0
- package/dist/src/services/config/config-service.d.ts +35 -2
- package/dist/src/services/config/config-service.js +81 -0
- package/dist/src/services/config/config-types.d.ts +58 -0
- package/dist/src/services/config/config-types.js +6 -0
- package/dist/src/services/doctor/doctor-service.js +96 -0
- package/dist/src/services/ide/adapters/hermes-adapter.d.ts +21 -0
- package/dist/src/services/ide/adapters/hermes-adapter.js +51 -0
- package/dist/src/services/ide/adapters/openclaw-adapter.d.ts +14 -0
- package/dist/src/services/ide/adapters/openclaw-adapter.js +42 -0
- package/dist/src/services/ide/ide-registry.js +7 -0
- package/dist/src/services/ide/ide-types.d.ts +1 -1
- package/dist/src/services/openspec/openspec-propose-from-doctor-service.d.ts +31 -0
- package/dist/src/services/openspec/openspec-propose-from-doctor-service.js +95 -0
- package/dist/src/services/preferences/preferences-service.d.ts +6 -0
- package/dist/src/services/preferences/preferences-service.js +43 -0
- package/dist/src/services/preferences/preferences-types.d.ts +90 -0
- package/dist/src/services/preferences/preferences-types.js +38 -0
- package/dist/src/services/skills/skill-conformance-service.d.ts +40 -0
- package/dist/src/services/skills/skill-conformance-service.js +136 -0
- package/dist/src/services/skills/skill-runbook-service.js +44 -10
- package/dist/src/services/skills/sync-service.d.ts +43 -0
- package/dist/src/services/skills/sync-service.js +99 -0
- package/dist/src/services/slice/slice-check-service.js +166 -13
- package/dist/src/services/slice/slice-check-types.d.ts +1 -1
- package/dist/src/services/standards/migrate-claude-rules-service.d.ts +19 -0
- package/dist/src/services/standards/migrate-claude-rules-service.js +193 -0
- package/dist/src/services/understand/understand-scan-service.js +15 -2
- package/dist/src/services/understand/understand-types.d.ts +26 -0
- package/dist/src/services/upgrade/1x-detector-service.d.ts +7 -0
- package/dist/src/services/upgrade/1x-detector-service.js +94 -0
- package/dist/src/services/upgrade/gitignore-migrate-service.d.ts +56 -0
- package/dist/src/services/upgrade/gitignore-migrate-service.js +170 -0
- package/dist/src/services/upgrade/upgrade-service.d.ts +47 -0
- package/dist/src/services/upgrade/upgrade-service.js +381 -0
- package/dist/src/services/workspace/sid-naming-guard.d.ts +14 -0
- package/dist/src/services/workspace/sid-naming-guard.js +31 -0
- package/dist/src/services/workspace/workspace-archive-service.d.ts +19 -0
- package/dist/src/services/workspace/workspace-archive-service.js +32 -0
- package/dist/src/services/workspace/workspace-clean-service.d.ts +41 -0
- package/dist/src/services/workspace/workspace-clean-service.js +86 -0
- package/dist/src/services/workspace/workspace-state-service.d.ts +7 -0
- package/dist/src/services/workspace/workspace-state-service.js +43 -0
- package/dist/src/shared/change-id.js +4 -1
- package/dist/src/shared/version.d.ts +1 -1
- package/dist/src/shared/version.js +1 -1
- package/package.json +8 -2
- package/schemas/doctor-report.schema.json +1 -1
- package/scripts/install-skills.mjs +296 -12
- package/skills/peaks-doctor/SKILL.md +59 -0
- package/skills/peaks-doctor/references/doctor-check-catalog.md +31 -0
- package/skills/peaks-doctor/references/from-doctor-flow.md +64 -0
- package/skills/peaks-doctor/test_prompts.json +17 -0
- package/skills/peaks-ide/SKILL.md +2 -0
- package/skills/peaks-qa/SKILL.md +9 -7
- package/skills/peaks-qa/references/artifact-per-request.md +19 -5
- package/skills/peaks-qa/references/qa-perf-test-plan.md +6 -6
- package/skills/peaks-qa/references/qa-runbook.md +1 -1
- package/skills/peaks-rd/SKILL.md +25 -10
- package/skills/peaks-rd/references/ocr-integration.md +214 -0
- package/skills/peaks-rd/references/rd-fanout-contracts.md +70 -0
- package/skills/peaks-rd/references/rd-runbook.md +1 -1
- package/skills/peaks-solo/SKILL.md +10 -4
- package/skills/peaks-solo/references/step-0-55-1x-detection.md +82 -0
- package/skills/peaks-solo/references/workflow-gates-and-types.md +9 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: peaks-doctor
|
|
3
|
+
description: Orchestrate peaks-cli's L3 doctor (peaks audit + peaks doctor + peaks openspec from-doctor) for project health. Use when the user asks for a project health check, doctor report, audit, or wants to convert doctor findings into OpenSpec change records. Coordinates the L2 audit framework + the L3.2 doctor + the L3.3 from-doctor proposal generator. Triggers on `/peaks-doctor`, "peaks doctor", "项目健康", "doctor report", "health check", "check the project", "audit my repo".
|
|
4
|
+
internal: true
|
|
5
|
+
---
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Peaks-Cli Doctor
|
|
9
|
+
|
|
10
|
+
Peaks-Cli Doctor is the orchestration facade for the L3 doctor workflow. It runs the L2 audit framework (`peaks audit red-lines`) + the L3.2 doctor checks (`peaks doctor`) + the L3.3 from-doctor proposal generator (`peaks openspec from-doctor`). Use it when the user wants a project health check, a red-line audit, or to convert doctor findings into OpenSpec change records.
|
|
11
|
+
|
|
12
|
+
## Skill-first architecture note (read once, internalise)
|
|
13
|
+
|
|
14
|
+
This skill is the **primary surface**. The `peaks <cmd>` CLI is **auxiliary** — invoked by the skill prompt only when a primitive is the right tool. Behaviour only an LLM in a skill prompt would use lives **here in the SKILL.md**, not as a new CLI command. See `.claude/rules/common/dev-preference.md` for the decision template.
|
|
15
|
+
|
|
16
|
+
## Code-Change Red Line (BLOCKING — read before ANY tool call)
|
|
17
|
+
|
|
18
|
+
**Peaks-Cli Doctor is a doctor orchestrator, NOT an implementer. You MUST NOT write, edit, or modify any application source code directly.**
|
|
19
|
+
|
|
20
|
+
The doctor workflow is read-only by design. It produces:
|
|
21
|
+
- `peaks audit red-lines` report (121 red lines in the current repo, 6 cli-backed)
|
|
22
|
+
- `peaks doctor` report (69 checks: 68 pass, 1 fail — L3:l3-memory-health)
|
|
23
|
+
- Optional OpenSpec change records via `peaks openspec from-doctor`
|
|
24
|
+
|
|
25
|
+
If a doctor finding requires a code change, the workflow hands off to `peaks-rd` (or `peaks-solo` for the full pipeline). The doctor itself does NOT modify code.
|
|
26
|
+
|
|
27
|
+
## Workflow (5 steps)
|
|
28
|
+
|
|
29
|
+
1. **Anchor**: `peaks workspace init --project <repo> --json` (idempotent; same as every peaks-* skill).
|
|
30
|
+
2. **Run audit**: `peaks audit red-lines --project <repo> --json` — returns the red-line audit (catalog-matched markers + live enforcer findings). Inspect the `enforcerFindings` array for runtime-detected issues.
|
|
31
|
+
3. **Run doctor**: `peaks doctor --json` — returns 69 checks. Pay special attention to:
|
|
32
|
+
- `L3:l3-orphan-sessions` — invalid sids in .peaks/_runtime/
|
|
33
|
+
- `L3:l3-memory-health` — .peaks/memory/index.json shape
|
|
34
|
+
- `integration:gateguard-peaks-conflict` — third-party Edit/Write hook interference
|
|
35
|
+
- `build:workspace-layout-canonical` — workspace layout
|
|
36
|
+
4. **Triage findings**: For each FAIL check, decide:
|
|
37
|
+
- **Real bug requiring fix** → hand off to peaks-rd (run `peaks openspec from-doctor` first to generate a draft proposal; then peaks-rd to implement)
|
|
38
|
+
- **Acceptable false positive** → document in the handoff; do not act
|
|
39
|
+
- **Configuration drift** → run the suggested recovery command (e.g. `peaks workspace clean`)
|
|
40
|
+
5. **Generate proposals** (per FAIL finding): `peaks openspec from-doctor --project <repo> --check-id <id>` writes `openspec/changes/<date>-fix-<slug>/proposal.md`. Hand off to peaks-rd for implementation.
|
|
41
|
+
|
|
42
|
+
## CLI primitives the skill composes
|
|
43
|
+
|
|
44
|
+
- `peaks workspace init` — anchor the workspace (Step 0)
|
|
45
|
+
- `peaks audit red-lines` — L2 audit
|
|
46
|
+
- `peaks doctor` — L3.2 doctor
|
|
47
|
+
- `peaks openspec from-doctor` — L3.3 proposal generator
|
|
48
|
+
- `peaks openspec validate` — gate a draft proposal
|
|
49
|
+
|
|
50
|
+
## Boundaries
|
|
51
|
+
|
|
52
|
+
- The doctor is read-only. It does NOT modify code, fix bugs, or clean up sessions.
|
|
53
|
+
- The doctor does NOT install UA or any third-party tool. The opt-in UX is surfaced via `peaks understand opt-in`; the doctor just reports state.
|
|
54
|
+
- The doctor does NOT generate change records automatically; it surfaces findings + the LLM calls `peaks openspec from-doctor` to generate them.
|
|
55
|
+
|
|
56
|
+
## References
|
|
57
|
+
|
|
58
|
+
- `references/doctor-check-catalog.md` — every doctor check id + what it means
|
|
59
|
+
- `references/from-doctor-flow.md` — the end-to-end "finding → proposal" path
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Doctor check catalog (peaks-doctor skill reference)
|
|
2
|
+
|
|
3
|
+
Slice L3.2 ships 69 doctor checks. The most user-relevant ones:
|
|
4
|
+
|
|
5
|
+
## L2 audit (slice #2)
|
|
6
|
+
|
|
7
|
+
- **`L2:audit:cli-backed`** — count of red lines whose catalog match has a real enforcer
|
|
8
|
+
- **`L2:audit:prose-only`** — count of red lines that need a future enforcer
|
|
9
|
+
|
|
10
|
+
## L3.2 (slice #9)
|
|
11
|
+
|
|
12
|
+
- **`L3:l3-orphan-sessions`** — directories in `.peaks/_runtime/` that fail `isValidSessionId`. Recover with `peaks workspace clean`.
|
|
13
|
+
- **`L3:l3-memory-health`** — `.peaks/memory/index.json` must be well-formed JSON with a `schema_version` field and an array `entries`. Recovers by re-running `peaks memory extract`.
|
|
14
|
+
|
|
15
|
+
## Build / workspace
|
|
16
|
+
|
|
17
|
+
- **`build:dist-version-matches-source`** — `dist/src/shared/version.js` matches the source `package.json` version
|
|
18
|
+
- **`build:workspace-layout-canonical`** — `.peaks/` follows the canonical `._archive` / `_runtime` / `_sub_agents` layout
|
|
19
|
+
- **`build:workspace-migrate-not-needed`** — when the layout is already canonical
|
|
20
|
+
|
|
21
|
+
## Integration (third-party hooks)
|
|
22
|
+
|
|
23
|
+
- **`integration:gateguard-peaks-conflict`** — warns when `gateguard-fact-force` is installed without a `.peaks/**` skip pattern (the 3rd-party hook would block all peaks-qa .peaks/ artifact writes)
|
|
24
|
+
|
|
25
|
+
## Skills
|
|
26
|
+
|
|
27
|
+
- **`skill:<required-skill>`** — each required skill (peaks-ide, peaks-prd, peaks-rd, peaks-qa, peaks-sc, peaks-solo, peaks-sop, peaks-txt, peaks-ui, peaks-doctor) must be installed in the bundled skills dir
|
|
28
|
+
|
|
29
|
+
## Doctor self
|
|
30
|
+
|
|
31
|
+
- **`doctor-self:check-id-pattern`** — all check IDs match the `doctor-report.schema.json` regex pattern (prevents typos like `L3:l3-orphan-sesions`)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# from-doctor flow (peaks-doctor skill reference)
|
|
2
|
+
|
|
3
|
+
End-to-end path from a doctor finding to an OpenSpec change record.
|
|
4
|
+
|
|
5
|
+
## Flow
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
peaks doctor --json # 1. discover findings
|
|
9
|
+
↓
|
|
10
|
+
match: any check where ok=false
|
|
11
|
+
↓
|
|
12
|
+
peaks openspec from-doctor \
|
|
13
|
+
--project <repo> \
|
|
14
|
+
--check-id <id> # 2. generate draft proposal
|
|
15
|
+
↓
|
|
16
|
+
openspec/changes/<date>-fix-<slug>/proposal.md # 3. LLM reviews + edits
|
|
17
|
+
↓
|
|
18
|
+
peaks openspec validate <change-id> # 4. gate
|
|
19
|
+
↓
|
|
20
|
+
[next slice: peaks-rd implements the change per the proposal]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Example
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Discover
|
|
27
|
+
$ peaks doctor --json | jq '.data.checks[] | select(.ok==false) | .id'
|
|
28
|
+
"L3:l3-memory-health"
|
|
29
|
+
|
|
30
|
+
# Generate draft
|
|
31
|
+
$ peaks openspec from-doctor \
|
|
32
|
+
--project . \
|
|
33
|
+
--check-id L3:l3-memory-health \
|
|
34
|
+
--json
|
|
35
|
+
{
|
|
36
|
+
"ok": true,
|
|
37
|
+
"command": "openspec.from-doctor",
|
|
38
|
+
"data": {
|
|
39
|
+
"changeId": "2026-06-11-fix-l3-l3-memory-health",
|
|
40
|
+
"proposalPath": ".../openspec/changes/2026-06-11-fix-l3-l3-memory-health/proposal.md",
|
|
41
|
+
"created": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# LLM reviews + edits the draft (in this case: add a Why section
|
|
46
|
+
# explaining the missing schema_version field; add an Acceptance
|
|
47
|
+
# Criterion that requires peaks doctor to return ok=true for the check)
|
|
48
|
+
|
|
49
|
+
# Validate
|
|
50
|
+
$ peaks openspec validate 2026-06-11-fix-l3-l3-memory-health --json
|
|
51
|
+
{
|
|
52
|
+
"ok": true,
|
|
53
|
+
"data": { "valid": true, "issues": [] }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Implement (peaks-rd)
|
|
57
|
+
$ /peaks-rd 2026-06-11-fix-l3-l3-memory-health
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Edge cases
|
|
61
|
+
|
|
62
|
+
- **CHECK_ALREADY_PASSING**: `--check-id` matches a passing check. The CLI returns code CHECK_ALREADY_PASSING. Pick a failing check.
|
|
63
|
+
- **CHECK_NOT_FOUND**: `--check-id` doesn't match any check id. Run `peaks doctor --json | jq '.data.checks[].id'` to list.
|
|
64
|
+
- **OPENSPEC_FROM_DOCTOR_FAILED**: filesystem write error (e.g. openspec/ not initialized). Run `peaks openspec init --apply` first.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "doctor-baseline",
|
|
4
|
+
"prompt": "/peaks-doctor",
|
|
5
|
+
"expectedOutcome": "Runs peaks workspace init + peaks audit + peaks doctor; returns a triage of FAIL checks with hand-off suggestions."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"id": "doctor-from-finding",
|
|
9
|
+
"prompt": "peaks doctor flagged L3:l3-memory-health. Generate an OpenSpec change record from it.",
|
|
10
|
+
"expectedOutcome": "Calls peaks openspec from-doctor --check-id L3:l3-memory-health; verifies the proposal.md was written; suggests next step (peaks-rd)."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "doctor-only-audit",
|
|
14
|
+
"prompt": "Run only the audit (not the full doctor).",
|
|
15
|
+
"expectedOutcome": "Calls peaks audit red-lines --project . --json; summarizes the enforcerFindings and the prose-only ratio."
|
|
16
|
+
}
|
|
17
|
+
]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: peaks-ide
|
|
3
3
|
description: Orchestrate peaks-cli's IDE-aware behavior (hooks + statusline + handle) for a user's specific IDE. Detects the current state (which IDE the user is on, what peaks has already installed), plans the install / switch / status / uninstall actions, and invokes the existing peaks CLI primitives. Triggers on `/peaks-ide`, "set up peaks for my IDE", "switch peaks to Trae", "what did peaks install", "uninstall peaks hooks". Sits between the user and `peaks hooks install` / `peaks statusline install` / `peaks hook handle` — those are the CLI primitives; this skill is the user-facing surface.
|
|
4
|
+
internal: true
|
|
5
|
+
---
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Peaks-Cli IDE Setup (peaks-ide)
|
package/skills/peaks-qa/SKILL.md
CHANGED
|
@@ -79,15 +79,15 @@ When this skill is running in the main Claude session (not as a sub-agent), befo
|
|
|
79
79
|
|
|
80
80
|
## Mandatory per-request artifact
|
|
81
81
|
|
|
82
|
-
Every QA invocation — feature, bug, refactor, clarification — must write **three separate files** (test cases + test report + request artifact). Do not merge them into one. Each serves a different reader.
|
|
82
|
+
Every QA invocation — feature, bug, refactor, clarification — must write **three separate files** (test cases + test report + request artifact) under `.peaks/<session-id>/qa/` (canonical placeholder: `.peaks/<session-id>/qa/requests/<request-id>.md`; runtime path is `.peaks/_runtime/<session-id>/qa/...`). Do not merge them into one. Each serves a different reader.
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
External-skill guard: when QA references external material (mattpocock/skills, gstack, superpowers, etc.) it is reference only — do not execute upstream installer, do not persist sensitive upstream examples. Peaks-Cli artifacts and Peaks-Cli acceptance criteria remain authoritative.
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
→ see `references/artifact-per-request.md` for the 3-file contract and the do-not-execute upstream guard.
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
## Default runbook
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
See `references/qa-runbook.md` for the full 10-step runbook (steps #0–#9) with every CLI invocation, the rd-side pre-drafted test-cases optimization, the dev-server lifecycle requirement, the security/performance check discipline, and the 8 quality-gate CLI checks.
|
|
91
91
|
|
|
92
92
|
## Transition verification gates (MANDATORY — run the command, see the output)
|
|
93
93
|
|
|
@@ -125,6 +125,8 @@ Before QA passes or returns work to RD, it must independently recheck the implem
|
|
|
125
125
|
|
|
126
126
|
QA must generate test cases, not merely inspect existing ones. Every QA invocation that validates code changes must produce a test-case artifact at `.peaks/_runtime/<sessionId>/qa/test-cases/<request-id>.md`. Minimum categories: Unit / Integration / UI regression. Each test case MUST have an `**Acceptance:**` field linking to PRD acceptance IDs (A1, A2, ...). The `peaks scan acceptance-coverage` command enforces coverage.
|
|
127
127
|
|
|
128
|
+
**Pre-drafted test cases (slice 004 optimization):** when peaks-rd's 4-way parallel fan-out ran a `qa-test-cases-writer` sub-agent, the test plan is pre-drafted at `.peaks/<id>/qa/test-cases/<rid>.md` and shipped through the rd:qa-handoff gate. QA main loop is aware of this and treats the pre-drafted file as the canonical starting point. **Missing** the pre-drafted file (sub-agent failed, or the slice was a config/docs/chore that did not fan out) → QA drafts it inline as before, falling back to the standard generation flow.
|
|
129
|
+
|
|
128
130
|
→ see `references/test-case-generation.md` for the full format + acceptance-linkage contract.
|
|
129
131
|
|
|
130
132
|
## Mandatory test-report output
|
|
@@ -137,7 +139,7 @@ Every QA invocation must produce a test-report artifact at `.peaks/_runtime/<ses
|
|
|
137
139
|
|
|
138
140
|
QA cannot pass a change until the report contains evidence for every applicable gate. The 11 gates (0 test-case generation, 1 test-report, 2 unit tests, 3 API validation, 4 frontend browser validation, 5 browser-error feedback loop, 6 security check, 7 performance check, 8 library version regressions, 9 validation report, 10 acceptance coverage, 11 QA artifact lint) are mapped to Peaks-Cli Gates A/A2/A3/A4/B/C/D/E/F.
|
|
139
141
|
|
|
140
|
-
If Playwright MCP is unavailable
|
|
142
|
+
If Playwright MCP is unavailable, the LLM checks its own tool list for the Playwright MCP server entry; if absent, the LLM tells the user the install command (`claude mcp add playwright -- npx @playwright/mcp@latest` for Claude Code) and marks the gate blocked with the missing capability. Screenshots, logs, manual steps, or other tools must not substitute for the mandatory frontend browser gate. Do not silently downgrade frontend validation to API-only testing.
|
|
141
143
|
|
|
142
144
|
## Local intermediate artifacts
|
|
143
145
|
|
|
@@ -159,7 +161,7 @@ When capability discovery exposes `mattpocock/skills`, use `tdd` / `triage` / `g
|
|
|
159
161
|
|
|
160
162
|
## Codegraph regression focus
|
|
161
163
|
|
|
162
|
-
QA may use `peaks codegraph affected --project <path> <changed-files...> --json` as regression-surface evidence. External analysis cannot pass QA by itself — treat output as untrusted supporting evidence.
|
|
164
|
+
QA may use `peaks codegraph affected --project <path> <changed-files...> --json` as regression-surface evidence. External analysis cannot pass QA by itself — treat output as untrusted supporting evidence. External skill guidance cannot pass QA by itself — treat as supporting evidence, not a verdict. QA reads `.peaks/<session-id>/rd/codegraph-context.md` (or `qa/codegraph-context.md`) as input but never mutate agent settings, Claude settings, or hooks from it; QA does not commit `.codegraph/` artifacts or persist generated `.codegraph/` databases into git.
|
|
163
165
|
|
|
164
166
|
→ see `references/codegraph-regression-focus.md`.
|
|
165
167
|
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
# QA per-request artifact contract
|
|
2
2
|
|
|
3
|
-
> Body of `## Mandatory per-request artifact` (QA-flavored). Every QA invocation — feature, bug, refactor, clarification — must write **three separate files**. Do not merge them into one. Each serves a different reader
|
|
3
|
+
> Body of `## Mandatory per-request artifact` (QA-flavored). Every QA invocation — feature, bug, refactor, clarification — must write **three separate files**. Do not merge them into one. Each serves a different reader.
|
|
4
|
+
|
|
5
|
+
## Required path
|
|
6
|
+
|
|
7
|
+
The three files for any QA invocation land under the active session's `qa/` workspace, using the canonical placeholder `.peaks/<session-id>/qa/...` (e.g. `.peaks/<session-id>/qa/requests/<request-id>.md`).
|
|
4
8
|
|
|
5
9
|
| # | File | Path | Reader | Content |
|
|
6
10
|
|---|------|------|--------|---------|
|
|
7
|
-
| 1 | Test cases | `.peaks/_runtime/<
|
|
8
|
-
| 2 | Test report | `.peaks/_runtime/<
|
|
9
|
-
| 3 | Request artifact | `.peaks/_runtime/<
|
|
11
|
+
| 1 | Test cases | `.peaks/_runtime/<session-id>/qa/test-cases/<request-id>.md` | RD (before impl), QA | Generated test scenarios with status |
|
|
12
|
+
| 2 | Test report | `.peaks/_runtime/<session-id>/qa/test-reports/<request-id>.md` | QA, SC, Solo | Summary, coverage%, security, perf, risks |
|
|
13
|
+
| 3 | Request artifact | `.peaks/_runtime/<session-id>/qa/requests/<request-id>.md` | Solo, RD↔QA loop | Verdict, boundary check, links to #1 and #2 |
|
|
14
|
+
|
|
15
|
+
## Required content
|
|
16
|
+
|
|
17
|
+
The request artifact is the **verdict carrier** — it must include: QA verdict (`pass` / `return-to-rd` / `blocked`), the red-line audit outcome, links to the test-cases and test-report, the boundary check (acceptance items covered, gaps), and any cross-skill handoff notes for Solo. The test cases file enumerates every scenario with status; the test report summarises execution and links the security / performance / regression companion files.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
The 3-file split is load-bearing. Do not merge. Use the `<request-id>` PRD assigned (`YYYY-MM-DD-<kebab-slug>`). QA may also produce companion artifacts (regression matrix, sanitized browser evidence, security findings, performance findings) under the same `qa/` workspace and link them from these files. Sanitize MCP / network / browser evidence before writing. Do not commit unless the user or active profile authorizes durable retention. Verdict `pass` is blocked while any of the three files is missing or the request artifact is in `draft` / `running` state.
|
|
22
|
+
|
|
23
|
+
## External-skill invocation guard
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
When QA references external material (mattpocock/skills, gstack, superpowers, etc.) treat it as reference only: do not execute upstream installer, do not run upstream installer commands, do not persist sensitive upstream examples to the working tree. Peaks-Cli artifacts, Peaks-Cli gates, and Peaks-Cli acceptance criteria remain authoritative.
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
> `qa/performance-findings-<rid>.md` references this baseline by path +
|
|
8
8
|
> hash.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## File location
|
|
11
11
|
|
|
12
12
|
`.peaks/_runtime/<sessionId>/qa/perf-baseline.md`. The CLI is
|
|
13
13
|
`peaks workflow plan read perf --project <repo> --json` /
|
|
14
14
|
`peaks workflow plan refresh perf --project <repo> --apply` /
|
|
15
15
|
`peaks workflow plan detect-trigger --project <repo> --rid <rid> --json`.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Perf generation workflow
|
|
18
18
|
|
|
19
19
|
1. `peaks workflow plan read perf --project <repo> --json` — return the
|
|
20
20
|
existing baseline envelope. When missing, proceed to step 2.
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
(lighthouse / k6 / autocannon output) — see peaks-rd's
|
|
31
31
|
`mandatory-perf-baseline.md` for the RD-side measurement workflow.
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Perf content schema (deterministic)
|
|
34
34
|
|
|
35
35
|
- `## CLI Command Inventory` — auto-enumerated from
|
|
36
36
|
`src/cli/commands/*-commands.ts`. Sorted alphabetically.
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
actual numbers (CLI does not call measurement tools).
|
|
40
40
|
- `## Thresholds` — placeholder; RD fills per-route thresholds.
|
|
41
41
|
|
|
42
|
-
##
|
|
42
|
+
## Perf refresh trigger table (shared with security plan)
|
|
43
43
|
|
|
44
44
|
| Signal | Reason string | Re-generates the baseline? |
|
|
45
45
|
|---|---|---|
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
| devDependencies change only | (none) | no — locked Q1 default |
|
|
52
52
|
| Pure text edits to `rd/*` or `qa/test-cases/*` | (none) | no |
|
|
53
53
|
|
|
54
|
-
##
|
|
54
|
+
## Perf back-compat (1 minor release)
|
|
55
55
|
|
|
56
56
|
The pre-slice-025 non-suffixed `qa/performance-findings.md` is still
|
|
57
57
|
accepted by `peaks workflow verify-pipeline` Gate C during the
|
|
@@ -59,7 +59,7 @@ accepted by `peaks workflow verify-pipeline` Gate C during the
|
|
|
59
59
|
(`src/services/workflow/artifact-paths.ts`) handles the fallback and
|
|
60
60
|
emits a `legacy-redirect` warning.
|
|
61
61
|
|
|
62
|
-
## CLI surface recap
|
|
62
|
+
## Perf CLI surface recap
|
|
63
63
|
|
|
64
64
|
| Command | Returns | JSON shape |
|
|
65
65
|
|---|---|---|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
## Default runbook (QA)
|
|
2
2
|
|
|
3
3
|
> Body of `## Default runbook` + numbered runbook steps #0–#9. The default sequence the QA skill should execute. Do not skip the boundary check, the unit test gate, the validation report, or — when frontend is in scope — the Playwright MCP browser gate.
|
|
4
4
|
|
package/skills/peaks-rd/SKILL.md
CHANGED
|
@@ -15,9 +15,9 @@ Peaks-Cli RD owns engineering analysis, implementation planning, and refactor ex
|
|
|
15
15
|
|
|
16
16
|
## Hard contracts for browser self-test (BLOCKING — read before any browser_take_screenshot / login flow)
|
|
17
17
|
|
|
18
|
-
For frontend
|
|
18
|
+
For frontend / UI-affecting slices, RD's self-test uses the Playwright MCP headed browser. LLM checks its own tool list for the Playwright MCP entry; if absent, surface the install command (`claude mcp add playwright -- npx @playwright/mcp@latest`) and report the gate blocked. Do not silently downgrade to screenshots-only, manual steps, or chrome-devtools-mcp. Two contracts: (1) self-test screenshots land under `.peaks/_runtime/<sessionId>/qa/screenshots/`, (2) login / CAPTCHA / SSO / MFA is a hard block — surface with `AskUserQuestion`. Same in spirit as `peaks-qa`'s; RD and QA share the headed-browser path.
|
|
19
19
|
|
|
20
|
-
→ see `references/browser-self-test-contracts.md
|
|
20
|
+
→ see `references/browser-self-test-contracts.md`.
|
|
21
21
|
|
|
22
22
|
## Sub-agent dispatch (when launched by peaks-solo swarm)
|
|
23
23
|
|
|
@@ -44,15 +44,13 @@ When this skill is running in the main Claude session (not as a sub-agent — i.
|
|
|
44
44
|
|
|
45
45
|
## Mandatory per-request artifact
|
|
46
46
|
|
|
47
|
-
Every RD invocation — feature, bug, refactor, clarification — must write a durable artifact at `.peaks/_runtime/<
|
|
47
|
+
Every RD invocation — feature, bug, refactor, clarification — must write a durable artifact at `.peaks/<session-id>/rd/requests/<request-id>.md` (the canonical placeholder form: `<session-id>` is the active session id at runtime, `<request-id>` follows the `YYYY-MM-DD-<kebab-slug>` format; the runtime path is `.peaks/_runtime/<session-id>/rd/requests/<request-id>.md`). This is the canonical engineering record for that request; handoff to QA/SC is blocked while the artifact is missing or its state is `draft` or `spec-locked` without implementation evidence. Codegraph context lives at `.peaks/<session-id>/rd/codegraph-context.md`.
|
|
48
48
|
|
|
49
49
|
→ see `references/artifact-per-request.md` for the template + the "two RD artifact files" rule (per-slice vs per-session scope).
|
|
50
50
|
|
|
51
51
|
## Default runbook
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
→ see `references/rd-runbook.md` for the full runbook.
|
|
53
|
+
See `references/rd-runbook.md` for the full 9-step runbook (steps #0–#8) with every CLI invocation, project-scan BLOCKING rule, component-library detection, CSS framework conflict check, and 6 transition gates.
|
|
56
54
|
|
|
57
55
|
## RD gate index
|
|
58
56
|
|
|
@@ -108,11 +106,22 @@ RD cannot mark a development slice complete until all of these are true. Each ga
|
|
|
108
106
|
|
|
109
107
|
If any gate fails, return to development for fixes or hand off as blocked. Do not describe the work as done, shippable, or ready for QA.
|
|
110
108
|
|
|
111
|
-
## Parallel review fan-out (code-
|
|
109
|
+
## Parallel review fan-out (code-reviewer + security-reviewer + perf-baseline-reviewer + qa-test-cases-writer)
|
|
110
|
+
|
|
111
|
+
**When RD reaches the end of implementation, the four review activities run in parallel via `peaks sub-agent dispatch <role>`, not sequentially.** This is the same fan-out pattern peaks-solo uses for the post-PRD swarm. The four sub-agents are `code-reviewer` (code-review evidence), `security-reviewer` (security-review evidence), `perf-baseline-reviewer` (perf-baseline measurement), and `qa-test-cases-writer` (qa/test-cases/<rid>.md). Feature / refactor: all four. Bugfix: code-reviewer + security-reviewer + qa-test-cases-writer always; perf-baseline-reviewer only when perf-shaped. Config / docs / chore: no fan-out. B3 augmentation: ocr (user-owned LLM config at `peaksConfig.ocr.llm`, injected as env vars) → `peaks code-review run-ocr --json` → merge into `code-review.md`; → `references/ocr-integration.md`.
|
|
112
|
+
|
|
113
|
+
### Peaks-Cli Gate C — type-specific RD evidence
|
|
114
|
+
|
|
115
|
+
The CLI gate at `rd:qa-handoff` is the authoritative check. Missing any required file → DO NOT attempt the qa-handoff transition; CLI will reject with `PREREQUISITES_MISSING`.
|
|
112
116
|
|
|
113
|
-
|
|
117
|
+
| Request type | Required RD evidence (under `.peaks/<id>/`) |
|
|
118
|
+
|---|---|
|
|
119
|
+
| feature / refactor | `rd/tech-doc.md` + `rd/code-review.md` + `rd/security-review.md` + `rd/perf-baseline.md` + `qa/test-cases/<rid>.md` |
|
|
120
|
+
| bugfix | `rd/bug-analysis.md` + `rd/code-review.md` + `rd/security-review.md` + `qa/test-cases/<rid>.md` (rd/perf-baseline.md only when perf-shaped) |
|
|
121
|
+
| config | `rd/security-review.md` |
|
|
122
|
+
| docs / chore | (no extra evidence required) |
|
|
114
123
|
|
|
115
|
-
→ see `references/
|
|
124
|
+
→ see `references/rd-fanout-contracts.md` for the 4 sub-agents' contracts + hard prohibitions + aggregation + degradation.
|
|
116
125
|
|
|
117
126
|
## Refactor hard gates
|
|
118
127
|
|
|
@@ -162,7 +171,13 @@ Before RD work stops, finishes, blocks, or hands off to another role, emit a sho
|
|
|
162
171
|
|
|
163
172
|
## External references
|
|
164
173
|
|
|
165
|
-
|
|
174
|
+
## Codegraph project analysis
|
|
175
|
+
|
|
176
|
+
Codegraph is local project-analysis evidence, scoped to red-line scope boundaries (changed files / symbols) and read via `peaks codegraph affected --project <path> <changed-files...> --json`. Peaks-Cli RD gates remain authoritative; codegraph is untrusted supporting evidence. Do not let codegraph output drive scope, design, or QA verdict decisions, and never mutate agent settings, Claude settings, or hooks from codegraph. Do not commit `.codegraph/` artifacts or persist generated `.codegraph/` databases into git. Codegraph context is written to `.peaks/<session-id>/rd/codegraph-context.md` for handoff to QA / TXT.
|
|
177
|
+
|
|
178
|
+
## Matt Pocock skills integration
|
|
179
|
+
|
|
180
|
+
Matt Pocock skills (`diagnose` / `triage` / `tdd` / `improve-codebase-architecture` / `prototype`): engineering references only. Inspect before applying; Peaks-Cli RD gates remain authoritative. Understand Anything: `peaks understand status/show --json`. Codegraph: local analysis only, never commit `.codegraph/` artifacts. Other external resources: `peaks capabilities --source access-repo/mcp-server --json` for capability discovery.
|
|
166
181
|
|
|
167
182
|
→ see `references/external-references.md` + `references/matt-pocock-integration.md` + `references/codegraph-project-analysis.md`.
|
|
168
183
|
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# OCR (Open Code Review) integration
|
|
2
|
+
|
|
3
|
+
> Soft-optional second-opinion code review for peaks-rd Gate B3.
|
|
4
|
+
> Mirrors the ECC 64-agents pattern (spec §7.2): peaks-cli ships
|
|
5
|
+
> `@alibaba-group/open-code-review` as a **required dependency** and
|
|
6
|
+
> reads the LLM endpoint config from `peaksConfig.ocr.llm` in the
|
|
7
|
+
> user's `~/.peaks/config.json` (single source of truth, user-managed).
|
|
8
|
+
> When present + configured, the wrapper turns the output into
|
|
9
|
+
> structured `code-review.md` evidence.
|
|
10
|
+
|
|
11
|
+
## What ocr is
|
|
12
|
+
|
|
13
|
+
[Open Code Review](https://github.com/alibaba/open-code-review) is
|
|
14
|
+
an AI-powered code review CLI from Alibaba. It reads git diffs,
|
|
15
|
+
sends the changed files to a **user-configured LLM endpoint**
|
|
16
|
+
(OpenAI- or Anthropic-compatible), and emits structured
|
|
17
|
+
line-precise review comments. It is NOT a hosted service —
|
|
18
|
+
all LLM traffic goes to the user's own configured endpoint.
|
|
19
|
+
|
|
20
|
+
Distribution: npm `@alibaba-group/open-code-review` (Go binary
|
|
21
|
+
inside; the npm postinstall downloads the platform-specific
|
|
22
|
+
binary from GitHub Releases).
|
|
23
|
+
|
|
24
|
+
## Why peaks-rd uses it (soft-optional)
|
|
25
|
+
|
|
26
|
+
The default peaks-rd code-review evidence is produced by the
|
|
27
|
+
main RD LLM (or the `code-reviewer` sub-agent in the parallel
|
|
28
|
+
fan-out). That's one pair of eyes. When ocr is available, the
|
|
29
|
+
wrapper adds a **second pair** — an independent LLM tuned for
|
|
30
|
+
code review — and the two reviews are merged into the same
|
|
31
|
+
`code-review.md` file. Soft-optional: if ocr isn't installed or
|
|
32
|
+
configured, RD proceeds with the LLM-only review and the slice
|
|
33
|
+
ships without the second opinion.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
`@alibaba-group/open-code-review` is a **required `dependency`** of
|
|
38
|
+
peaks-cli 2.0.1+. `npm i -g peaks-cli` pulls it automatically and
|
|
39
|
+
downloads the platform binary in the postinstall step. Verify with:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
peaks code-review detect-ocr --json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Five possible states:
|
|
46
|
+
|
|
47
|
+
| state | Meaning | Recovery |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `ready` | Installed + binary downloaded + peaks-cli's `peaksConfig.ocr.llm` valid | Nothing — `run-ocr` will work. |
|
|
50
|
+
| `package-missing` | npm dep not installed (corrupt node_modules, or user removed it) | `npm i -g @alibaba-group/open-code-review` (peaks-cli 2.0.1+ does this automatically; this state is rare) |
|
|
51
|
+
| `binary-missing` | npm dep present but Go binary did not download | `pnpm approve-builds @alibaba-group/open-code-review`, OR run `node node_modules/@alibaba-group/open-code-review/scripts/install.js`, OR manually fetch from https://github.com/alibaba/open-code-review/releases and place the binary at the path shown in `nextActions[2]`. |
|
|
52
|
+
| `config-missing` | binary present but `peaksConfig.ocr.llm` is empty or partial | See "Configure" below. |
|
|
53
|
+
| `detection-failed` | Unexpected error during detection | Inspect stderr; re-run probe. |
|
|
54
|
+
|
|
55
|
+
## Configure (one-time, per user) — peaks-cli does NOT auto-configure
|
|
56
|
+
|
|
57
|
+
The LLM endpoint config is **user-maintained inside peaks-cli's own
|
|
58
|
+
config** at `~/.peaks/config.json` under the `ocr.llm` key. The user
|
|
59
|
+
is the only party that touches their LLM token / URL / model. peaks-cli
|
|
60
|
+
never auto-writes the config and never writes `~/.opencodereview/config.json`.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# 1) Print the JSON snippet to paste (read-only, no side effects):
|
|
64
|
+
peaks code-review config-template --json
|
|
65
|
+
|
|
66
|
+
# 2) Paste the snippet into ~/.peaks/config.json under "ocr.llm",
|
|
67
|
+
# replace <your-api-key> with your real key. Alternatively,
|
|
68
|
+
# set keys one at a time:
|
|
69
|
+
peaks config set --key ocr.llm.url --value 'https://api.example.com/v1/messages'
|
|
70
|
+
peaks config set --key ocr.llm.authToken --value '<your-key>'
|
|
71
|
+
peaks config set --key ocr.llm.model --value 'claude-3-5-sonnet-latest'
|
|
72
|
+
peaks config set --key ocr.llm.useAnthropic --value 'true'
|
|
73
|
+
peaks config set --key ocr.llm.authHeader --value 'x-api-key'
|
|
74
|
+
|
|
75
|
+
# 3) Verify readiness (peaks-rd also runs this automatically):
|
|
76
|
+
peaks code-review detect-ocr --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Field map: `peaksConfig.ocr.llm` ↔ ocr subprocess env vars
|
|
80
|
+
|
|
81
|
+
peaks-rd calls ocr with the `peaksConfig.ocr.llm` values **injected as
|
|
82
|
+
env vars** (ocr's highest-priority config path). The mapping is:
|
|
83
|
+
|
|
84
|
+
| `peaksConfig.ocr.llm.*` | Spawn env var | Notes |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `url` | `OCR_LLM_URL` | HTTPS endpoint, no embedded credentials |
|
|
87
|
+
| `authToken` | `OCR_LLM_TOKEN` | Sensitive — stored only in the user-layer `~/.peaks/config.json`; `peaks config get` redacts this field |
|
|
88
|
+
| `model` | `OCR_LLM_MODEL` | e.g. `claude-3-5-sonnet-latest` |
|
|
89
|
+
| `useAnthropic` | `OCR_USE_ANTHROPIC` | Boolean; serialised as `"true"` / `"false"` |
|
|
90
|
+
| `authHeader` | `OCR_LLM_AUTH_HEADER` | One of `authorization` (default Bearer), `x-api-key` (for `sk-ant-*` keys), or `bearer` |
|
|
91
|
+
|
|
92
|
+
The `~/.opencodereview/config.json` file the user might have set up
|
|
93
|
+
for 2.0.0 is no longer consulted by peaks-cli. The user may delete it
|
|
94
|
+
at their discretion — the ocr subprocess ignores the file when peaks-
|
|
95
|
+
cli's env vars are present (and the env-var surface is highest priority).
|
|
96
|
+
|
|
97
|
+
### Required vs optional fields
|
|
98
|
+
|
|
99
|
+
The minimum for `state == "ready"` is the **url + authToken + model**
|
|
100
|
+
triple. `useAnthropic` and `authHeader` are optional; `authHeader`
|
|
101
|
+
defaults to `authorization` (Bearer) inside the ocr subprocess, but
|
|
102
|
+
`sk-ant-*` keys require `authHeader: "x-api-key"`.
|
|
103
|
+
|
|
104
|
+
When the user has not yet populated the config, `detect-ocr` returns
|
|
105
|
+
`state: "config-missing"` with `missingKeys: ["ocr.llm.url",
|
|
106
|
+
"ocr.llm.authToken", "ocr.llm.model"]` and a templated
|
|
107
|
+
`nextActions[1]` payload that includes the JSON snippet to paste.
|
|
108
|
+
|
|
109
|
+
## Use from peaks-rd (LLM workflow)
|
|
110
|
+
|
|
111
|
+
In Gate B3 (code review evidence), before writing
|
|
112
|
+
`.peaks/_runtime/<sid>/rd/code-review.md`, the code-reviewer
|
|
113
|
+
sub-agent runs:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# 1. Detect
|
|
117
|
+
peaks code-review detect-ocr --json
|
|
118
|
+
# 2. If state == "ready", run the review
|
|
119
|
+
peaks code-review run-ocr --json --project . --from origin/main --to HEAD
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The `run-ocr` envelope is:
|
|
123
|
+
|
|
124
|
+
```jsonc
|
|
125
|
+
{
|
|
126
|
+
"ok": true,
|
|
127
|
+
"command": "code-review.run-ocr",
|
|
128
|
+
"data": {
|
|
129
|
+
"spawned": true,
|
|
130
|
+
"state": "ready",
|
|
131
|
+
"exitCode": 0,
|
|
132
|
+
"stdout": "...",
|
|
133
|
+
"stderr": "",
|
|
134
|
+
"durationMs": 12345,
|
|
135
|
+
"parsed": {
|
|
136
|
+
"findings": [
|
|
137
|
+
{ "file": "src/foo.ts", "line": 42, "severity": "minor", "message": "..." }
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
"warnings": [],
|
|
141
|
+
"nextActions": []
|
|
142
|
+
},
|
|
143
|
+
...
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Merge `data.parsed.findings` into `code-review.md` under
|
|
148
|
+
`## Second opinion (ocr)`. Cite each finding by file + line.
|
|
149
|
+
Reconcile disagreements with the LLM-only review explicitly
|
|
150
|
+
(don't silently drop one source).
|
|
151
|
+
|
|
152
|
+
## Soft-fail policy
|
|
153
|
+
|
|
154
|
+
`peaks code-review run-ocr` **never** sets a non-zero exit code,
|
|
155
|
+
even when ocr is not ready or the subprocess fails. The envelope
|
|
156
|
+
`ok` field carries the success signal; the caller (peaks-rd) is
|
|
157
|
+
expected to pattern-match on `data.state` and proceed without the
|
|
158
|
+
second opinion if needed. This matches the ECC 64-agents
|
|
159
|
+
soft-fail policy and the peaks-cli "minimal user operation"
|
|
160
|
+
tenet — missing ocr should never block a slice.
|
|
161
|
+
|
|
162
|
+
## Security
|
|
163
|
+
|
|
164
|
+
- ocr sends your changed files to whatever LLM endpoint you
|
|
165
|
+
configure. Treat this the same as any external code-review
|
|
166
|
+
tool you opt into: don't point it at a free public endpoint
|
|
167
|
+
for proprietary code; use a vendor / self-hosted endpoint with
|
|
168
|
+
appropriate data controls.
|
|
169
|
+
- peaks-cli does NOT auto-configure ocr. Your `ocr.llm.authToken`
|
|
170
|
+
is yours. Rotate as needed. The token is stored only in the
|
|
171
|
+
user-layer `~/.peaks/config.json` (project layer rejects writes
|
|
172
|
+
to any key matching `isSensitiveConfigPath`), and
|
|
173
|
+
`peaks config get` redacts it as `***`.
|
|
174
|
+
- peaks-cli's wrapper records ocr's `stdout` verbatim in the
|
|
175
|
+
envelope (and in `code-review.md` when peaks-rd merges
|
|
176
|
+
findings). Don't put secrets in your code being reviewed.
|
|
177
|
+
- The `peaks code-review config-template` snippet embeds the
|
|
178
|
+
placeholder string `<your-api-key>`; the user is expected to
|
|
179
|
+
replace it before pasting.
|
|
180
|
+
|
|
181
|
+
## Failure modes (real)
|
|
182
|
+
|
|
183
|
+
These are the actual failure modes the wrapper has been
|
|
184
|
+
dogfooded against:
|
|
185
|
+
|
|
186
|
+
1. **Network blocked from GitHub Releases** during postinstall →
|
|
187
|
+
`binary-missing`. peaks-cli still runs cleanly because ocr
|
|
188
|
+
is detected as not-ready; user manually fetches the binary
|
|
189
|
+
and places it at `nextActions[2]`'s path.
|
|
190
|
+
2. **pnpm-installed peaks-cli** → ocr postinstall blocked by
|
|
191
|
+
pnpm's safe-by-default policy → `binary-missing`. Recover
|
|
192
|
+
with `pnpm approve-builds @alibaba-group/open-code-review`.
|
|
193
|
+
3. **No / partial LLM config** → `config-missing` with
|
|
194
|
+
`missingKeys` listing the unpopulated fields. Recover by
|
|
195
|
+
pasting the `peaks code-review config-template` output into
|
|
196
|
+
`~/.peaks/config.json` (or by `peaks config set` per-key).
|
|
197
|
+
4. **Wrong key / wrong endpoint** → ocr subprocess exits non-zero;
|
|
198
|
+
wrapper soft-fails (`ok: false`, `warnings[0]` includes the
|
|
199
|
+
exit code, `stderr` carries ocr's own error message).
|
|
200
|
+
5. **User 2.0.0 → 2.0.1 migration** — they configured
|
|
201
|
+
`~/.opencodereview/config.json` for 2.0.0; peaks-cli 2.0.1
|
|
202
|
+
no longer reads that file. They paste the same values into
|
|
203
|
+
`~/.peaks/config.json` under `ocr.llm` (peaks-cli handles the
|
|
204
|
+
camelCase conversion in the template).
|
|
205
|
+
|
|
206
|
+
## See also
|
|
207
|
+
|
|
208
|
+
- ocr upstream: https://github.com/alibaba/open-code-review
|
|
209
|
+
- peaks-cli source: `src/services/code-review/ocr-service.ts`,
|
|
210
|
+
`src/cli/commands/code-review-commands.ts`
|
|
211
|
+
- peaks-cli config schema: `src/services/config/config-types.ts`
|
|
212
|
+
(`OcrLlmConfig`, `OcrConfig`, `PeaksConfig.ocr?`)
|
|
213
|
+
- ECC 64-agents soft-optional pattern (mirrored):
|
|
214
|
+
`src/services/agent/ecc-agent-service.ts`
|