peaks-loop 4.0.23 → 4.0.25

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/cli/commands/_register.js +2 -1
  3. package/dist/cli/commands/best-practice-scan-command.d.ts +36 -0
  4. package/dist/cli/commands/best-practice-scan-command.js +118 -0
  5. package/dist/cli/commands/codegraph-commands.d.ts +10 -0
  6. package/dist/cli/commands/codegraph-commands.js +18 -4
  7. package/dist/cli/commands/request-commands.js +21 -9
  8. package/dist/services/best-practice/language-detector.d.ts +7 -0
  9. package/dist/services/best-practice/language-detector.js +96 -0
  10. package/dist/services/best-practice/output-formatter.d.ts +41 -0
  11. package/dist/services/best-practice/output-formatter.js +116 -0
  12. package/dist/services/best-practice/scan-orchestrator.d.ts +39 -0
  13. package/dist/services/best-practice/scan-orchestrator.js +85 -0
  14. package/dist/services/context/collector.d.ts +5 -12
  15. package/dist/services/context/context-builder.d.ts +12 -20
  16. package/dist/services/context/context-builder.js +1 -1
  17. package/dist/services/context/context-schema.d.ts +51 -364
  18. package/dist/services/context/context-schema.js +3 -3
  19. package/dist/services/crystallization/crystallization-service.d.ts +2 -12
  20. package/dist/services/crystallization/crystallization-service.js +3 -9
  21. package/dist/services/crystallization/crystallization-types.d.ts +45 -153
  22. package/dist/services/crystallization/crystallization-types.js +17 -11
  23. package/dist/services/crystallization/evidence-brief-builder.d.ts +12 -112
  24. package/dist/services/evolution/evolution-types.d.ts +83 -497
  25. package/dist/services/evolution/evolution-types.js +6 -10
  26. package/dist/services/fixture/fixture-sanitize-service.d.ts +10 -36
  27. package/dist/services/fixture/fixture-sanitize-service.js +1 -1
  28. package/dist/services/job/job-progress-store.d.ts +1 -17
  29. package/dist/services/job/job-progress-store.js +2 -2
  30. package/dist/services/job/job-types.d.ts +63 -370
  31. package/dist/services/job/job-types.js +46 -11
  32. package/dist/services/loop/loop-bee-relation-types.d.ts +20 -32
  33. package/dist/services/loop/loop-bee-relation-types.js +2 -2
  34. package/dist/services/loop/loop-release-types.d.ts +31 -110
  35. package/dist/services/migrate-skill-name/schema.d.ts +3 -19
  36. package/dist/services/migrate-skill-name/schema.js +4 -4
  37. package/dist/services/observability/observability-service.d.ts +21 -19
  38. package/dist/services/observability/observability-service.js +1 -1
  39. package/dist/services/prd/best-practice-auto-trigger.d.ts +61 -0
  40. package/dist/services/prd/best-practice-auto-trigger.js +126 -0
  41. package/dist/services/rd/types.d.ts +25 -194
  42. package/dist/services/sediment/json-schema.d.ts +39 -224
  43. package/dist/services/sediment/json-schema.js +2 -2
  44. package/dist/services/session/binding-store.d.ts +5 -47
  45. package/dist/services/session/binding-store.js +1 -1
  46. package/dist/services/share/bundle-types.d.ts +12 -180
  47. package/dist/services/share/bundle-types.js +15 -9
  48. package/dist/services/share/run-state-contract.d.ts +8 -25
  49. package/dist/services/skill/skill-search-service.d.ts +26 -46
  50. package/dist/services/skill/skill-search-service.js +2 -2
  51. package/dist/services/skills/hooks-settings-service.d.ts +9 -0
  52. package/dist/services/skills/hooks-settings-service.js +31 -1
  53. package/dist/services/skills/skill-presence-service.d.ts +24 -0
  54. package/dist/services/skills/skill-presence-service.js +33 -0
  55. package/package.json +8 -8
  56. package/schemas/context.schema.json +17 -8
  57. package/skills/bee/peaks-prd/SKILL.md +17 -0
  58. package/skills/bee/peaks-rd/SKILL.md +7 -0
  59. package/skills/bee/peaks-rd/references/frontend-acl-mapper.md +29 -0
  60. package/skills/peaks-code/SKILL.md +28 -1
  61. package/skills/peaks-code/references/codegraph-orchestration.md +7 -1
  62. package/skills/peaks-code/references/skill-presence-and-title.md +3 -3
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2
3
  "type": "object",
3
4
  "properties": {
4
5
  "version": {
@@ -11,7 +12,8 @@
11
12
  },
12
13
  "generatedAt": {
13
14
  "type": "string",
14
- "format": "date-time"
15
+ "format": "date-time",
16
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
15
17
  },
16
18
  "sha256": {
17
19
  "type": "string",
@@ -39,7 +41,8 @@
39
41
  },
40
42
  "lines": {
41
43
  "type": "integer",
42
- "minimum": 0
44
+ "minimum": 0,
45
+ "maximum": 9007199254740991
43
46
  },
44
47
  "hash": {
45
48
  "type": "string"
@@ -105,6 +108,9 @@
105
108
  },
106
109
  "deps": {
107
110
  "type": "object",
111
+ "propertyNames": {
112
+ "type": "string"
113
+ },
108
114
  "additionalProperties": {
109
115
  "type": "object",
110
116
  "properties": {
@@ -166,7 +172,8 @@
166
172
  },
167
173
  "fetchedAt": {
168
174
  "type": "string",
169
- "format": "date-time"
175
+ "format": "date-time",
176
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
170
177
  },
171
178
  "contentHash": {
172
179
  "type": "string"
@@ -181,7 +188,8 @@
181
188
  },
182
189
  "tokenEstimate": {
183
190
  "type": "integer",
184
- "minimum": 0
191
+ "minimum": 0,
192
+ "maximum": 9007199254740991
185
193
  },
186
194
  "excerpt": {
187
195
  "type": "string"
@@ -319,11 +327,13 @@
319
327
  },
320
328
  "renderedAt": {
321
329
  "type": "string",
322
- "format": "date-time"
330
+ "format": "date-time",
331
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
323
332
  },
324
333
  "sizeBytes": {
325
334
  "type": "integer",
326
- "minimum": 0
335
+ "minimum": 0,
336
+ "maximum": 9007199254740991
327
337
  },
328
338
  "truncated": {
329
339
  "type": "boolean"
@@ -355,6 +365,5 @@
355
365
  "tokenizer",
356
366
  "renderer"
357
367
  ],
358
- "additionalProperties": false,
359
- "$schema": "http://json-schema.org/draft-07/schema#"
368
+ "additionalProperties": false
360
369
  }
@@ -339,3 +339,20 @@ Verify the surface (no need to re-derive):
339
339
  1. `peaks audit red-lines --project .` reports `proseOnly: 0` for any shipped L2 surface.
340
340
  2. `peaks lease-metrics --rate` after a clean run reports `estimatedLeaked: 0`.
341
341
  3. `peaks worktree list` returns 0 active leases after a clean run.
342
+
343
+ ## Peaks-Loop Step 2.5 sub-step: best-practice scan handoff
344
+
345
+ When peaks-prd's `businessGoal` artifact transitions to `complete` + the sub-step has not
346
+ yet fired for this intent, peaks-prd MUST emit a sub-step handoff to Step 2.5 best-practice
347
+ scan BEFORE transitioning to Step 3 RD.
348
+
349
+ **Handoff contract:**
350
+ - Input: `businessGoal` (natural language) + `.peaks/project-scan/project-scan.md` (auto-generated by `peaks workspace init`)
351
+ - Output: best-practice scan artifact at `.peaks/_runtime/<sessionId>/best-practice/<requestId>.md`
352
+ - Trigger CLI: `peaks best-practice-scan --project <repo> --intent "<businessGoal>" --json`
353
+ - Status: `awaiting-user-ack` (3 valid user responses per spec §7: 接受 / 接受方案 N / 拒绝 + 原因)
354
+
355
+ **State machine:** peak-prd's state machine refuses `--allow-incomplete` style bypass for
356
+ this sub-step. Silent auto-accept is NOT allowed — user explicit ack is mandatory.
357
+
358
+ **Reference:** See `skills/peaks-code/SKILL.md` §Step 2.5 for the full sub-step contract.
@@ -189,6 +189,12 @@ When RD work creates a frontend application and the user has not specified a tec
189
189
 
190
190
  → see `references/frontend-project-generation.md` for the scaffold protocol.
191
191
 
192
+ ## Frontend anti-corruption layer (ACL)
193
+
194
+ When RD work touches the frontend (pure frontend or full-stack), enforce the ACL discipline: the frontend's internal model is never polluted by external / API shapes. DTO ↔ ViewModel mapping converts external fields to internal fields at the boundary, and all conversion logic lives in one mapper file per domain (e.g. `mappers/user.mapper.ts`) — never scattered across pages. Hard constraint, verified by QA / code-review.
195
+
196
+ → see `references/frontend-acl-mapper.md` for the three rules + reference shape + verification.
197
+
192
198
  ## Artifact and standards output
193
199
 
194
200
  When project identification or scanning produces reports, matrices, maps, plans, or validation files, write them under the configured Peaks-Loop artifact workspace (default: `.peaks/_runtime/<sessionId>/rd/`). Do not default to a git-backed artifact repository or external artifact sync. Route standards mutations through `peaks standards init/update`; do not hand-write. Do not update user-global `~/.claude/rules/**` from this workflow.
@@ -267,6 +273,7 @@ Index of every `references/` file in this skill. Read on demand.
267
273
  | `references/compact-handoff.md` | RD compact handoff capsule. |
268
274
  | `references/external-references.md` | External 3rd-party inventory. |
269
275
  | `references/frontend-project-generation.md` | React + Vite + shadcn/ui default. |
276
+ | `references/frontend-acl-mapper.md` | 前端防腐层 ACL + DTO↔VM 映射 + Mapper 聚合硬约束. |
270
277
  | `references/library-version-awareness.md` | Breaking-change gate + freshness check. |
271
278
  | `references/mandatory-perf-baseline.md` | RD-side perf baseline + `peaks perf baseline` workflow. |
272
279
  | `references/matt-pocock-integration.md` | Matt Pocock skills as references. |
@@ -0,0 +1,29 @@
1
+ # Frontend anti-corruption layer (ACL) + Mapper aggregation (RD)
2
+
3
+ > Body of `## Frontend anti-corruption layer (ACL)`. When RD work touches the frontend (pure frontend OR full-stack), the frontend's internal model MUST NOT be polluted by external / API data shapes. Enforce the anti-corruption layer (ACL) discipline on every frontend slice.
4
+
5
+ ## Three hard rules (BLOCKING)
6
+
7
+ 1. **ACL — protect the frontend internals.** The frontend never consumes backend / API DTOs directly in components, pages, hooks, or stores. An anti-corruption layer translates every external shape into an internal one at the boundary.
8
+
9
+ 2. **DTO ↔ ViewModel mapping — external fields → internal fields.** API / DTO field names and nesting are external concerns. Map them to internal ViewModel fields at the boundary. Backend field/schema drift must not leak past the mapper.
10
+
11
+ 3. **Mapper aggregation — one file per domain.** All conversion logic for a domain lives in exactly one mapper file (e.g. `mappers/user.mapper.ts`), never scattered across pages / components. A page or component imports the mapper; it does not inline a mapping.
12
+
13
+ ## Reference shape
14
+
15
+ ```ts
16
+ // mappers/user.mapper.ts — the ONLY place user DTO ↔ ViewModel mapping lives
17
+ import type { UserDTO } from '@/api/types'; // external
18
+ import type { UserViewModel } from '@/models/user'; // internal
19
+
20
+ export function toUserViewModel(dto: UserDTO): UserViewModel {
21
+ return { id: dto.user_id, name: dto.display_name, avatar: dto.avatar_url };
22
+ }
23
+ ```
24
+
25
+ Components / hooks import `toUserViewModel`; they never destructure `dto.user_id` directly.
26
+
27
+ ## Verification
28
+
29
+ QA / code-review must flag: (a) any component / hook / store consuming a `*DTO` or a raw API response field directly, (b) any `*.mapper.ts` duplication across pages. The mapper is the single translation seam between external DTOs and the internal ViewModel.
@@ -189,7 +189,7 @@ See also: references/session-overload-signal-index.md for the 7-signal lookup ta
189
189
  | Drift ID | Step | Symptom | Fix | Inline location |
190
190
  |---|---|---|---|---|
191
191
  | **D-001** | 0.8 | `peaks code detect-job --is-job ...` rejected with `error: unknown option '--is-job'` | Use `peaks job init --job-id <jid> --slice-list <list> --main-loop-strategy <single\|rotating>` | §Step 0.8 first paragraph |
192
- | **D-002** | 2.5 | `peaks session title --session-id <sid> ...` rejected with `error: unknown option '--session-id'` (this is the bare `<sid>` anti-pattern) | sid is positional: `peaks session title <sessionId> "<title>" --json` | §Step 2.5 |
192
+ | **D-002** | 2.5 | `peaks session title --session-id <sid> ...` rejected with `error: unknown option '--session-id'` (this is the bare `<sid>` anti-pattern) | sid is positional: `peaks session title <sessionId> "<title>" --json` | §Step 2.5a |
193
193
  | **D-003** | 0.8 | `JOB_SHAPE_NOT_DECIDED` exception expected but never thrown | Current behavior is `peaks job status` reports `done: 0` passively — treat as recoverable miss, not hard error | §Step 0.8 third paragraph |
194
194
  | **D-010** | 11c | `peaks memory extract` returns `extractedCount: 0` despite `<!-- peaks-memory:start -->` existing | Block requires YAML frontmatter (`title:` + `kind:` + `---`) + closing `<!-- peaks-memory:end -->`. Bare `peaks-memory:start` is parsed silently but produces no writes | §Step 11c + 11d |
195
195
 
@@ -213,6 +213,33 @@ Before handing off to `peaks-rd`, scan the project and record findings to `.peak
213
213
 
214
214
  When the project has no live backend (no swagger.json, no API server), Code must activate frontend-only mode. The CLI is authoritative — read `frontendOnly` and `frontendOnlyReason` from `peaks scan archetype --json`. → `references/frontend-only-mode.md`.
215
215
 
216
+ ## Peaks-Loop Step 2.5: Best-practice scan (BPS) (NEW 2026-08-12)
217
+
218
+ Inserted between current Step 2 (PRD) and Step 3 (RD). Sub-step does a **business-aware,
219
+ language-aware, LLM-recommended best-practice scan** before RD kicks off.
220
+
221
+ **Trigger:** Fires at peak-prd exit when business-goal is non-empty + sub-step not yet
222
+ triggered for this intent.
223
+
224
+ **Action sequence:**
225
+ 1. Detect project language (TS / JS / Python / Go / Java) via `language-detector` (5-lang
226
+ priority chain).
227
+ 2. Query Context7 (`@upstash/context7-mcp@^4.0.2`, installed as peaks-loop production dep)
228
+ priority-1 with 30s timeout.
229
+ 3. WebSearch fallback when Context7 returns empty / errors.
230
+ 4. Synthesize 8-row markdown comparison table per `output-formatter`.
231
+ 5. LLM picks one recommendation (★ marker) with reasoning block.
232
+ 6. **Mandatory ⚠️ catch gate** — user explicitly acks / picks alt / rejects + reason.
233
+
234
+ **Out of scope for this sub-step:**
235
+ - ❌ No changes to RD dispatch Karpathy prose (Step 3 unchanged)
236
+ - ❌ No changes to QA / SC / TXT skills
237
+ - ❌ No new `peaks-best-practice` standalone skill (sub-step inside peaks-prd only)
238
+ - ❌ No framework-knowledge persistent index (future slice)
239
+
240
+ **Reference:** Spec at `.peaks/_runtime/<sessionId>/sc/spec-step-2-5-best-practice-scan.md`
241
+ §4-7. Implementation: `src/cli/commands/best-practice-scan-command.ts` + `src/services/best-practice/`.
242
+
216
243
  ## Peaks-Loop Request type classification + Workflow order + Transition verification gates
217
244
 
218
245
  The 6-type table + 11-step order + 7 transition gates (A-G) live in `references/workflow-gates-and-types.md`. peaks-code narrative references Gate A-G — keep both files in lockstep.
@@ -2,4 +2,10 @@
2
2
 
3
3
  > Body of `## Codegraph orchestration context`. Code treats `peaks codegraph affected --project <path> <changed-files...> --json` as an optional project-analysis enhancement that informs the role handoff between PRD, RD, and QA. The output is untrusted supporting evidence — Code must not treat codegraph output as approval for scope, design, or QA verdict.
4
4
 
5
- Do not run upstream installer flows, mutate agent settings, or commit `.codegraph/` artifacts into git. Peaks-Loop gates remain authoritative; codegraph context is a hint, never a substitute for role-skill output.
5
+ Do not run upstream installer flows, mutate agent settings, or commit `.codegraph/` artifacts into git. Peaks-Loop gates remain authoritative; codegraph context is a hint, never a substitute for role-skill output.
6
+
7
+ ## Post-slice incremental re-index (slice 2026-09-01-feedback)
8
+
9
+ After each slice / task completes (RD done → QA done), the orchestrator MUST proactively run `peaks codegraph index --project <path>` to refresh the codegraph so the next slice's `affected` / `query` / `context` reflect the latest code — never a stale pre-slice graph. `index` is an incremental refresh; `peaks codegraph init` runs once per project, `index` runs after every slice.
10
+
11
+ The upstream bare `codegraph <subcommand>` binary is NOT on PATH — always route through `peaks codegraph <subcommand>`. (Upstream's own `status` output prints `Run "codegraph init" to initialize`; that bare-command hint is misleading in the peaks-loop context. A separate fix slice rewrites it to `peaks codegraph init`.)
@@ -1,6 +1,6 @@
1
- # Step 2 + 2.5 — Skill presence and session title
1
+ # Step 2 + 2.5a — Skill presence and session title
2
2
 
3
- > Combined body for `### Peaks-Loop Step 2: Re-set skill presence with the chosen mode` and `### Peaks-Loop Step 2.5: Set session title`.
3
+ > Combined body for `### Peaks-Loop Step 2: Re-set skill presence with the chosen mode` and `### Peaks-Loop Step 2.5a: Set session title`.
4
4
 
5
5
  ## Step 2 — Re-set skill presence
6
6
 
@@ -20,7 +20,7 @@ Then display the compact status header: `Peaks-Loop Skill: peaks-code | Peaks-Lo
20
20
 
21
21
  Update with `peaks skill presence:set peaks-code --project <repo> --mode <mode> --gate <gate>` when gates change. The presence file persists across the full workflow lifecycle — clear is owned by workflow terminalize; follow-up workflows re-claim via new workflow init.
22
22
 
23
- ## Step 2.5 — Set session title
23
+ ## Step 2.5a — Set session title
24
24
 
25
25
  Extract a short (8-20 Chinese characters, or 4-10 English words) descriptive title from the user's first request. The title should capture the core task — e.g. "修复登录页OAuth回调异常", "添加暗色模式开关", "搭建项目基础架构". Then run:
26
26