peaks-loop 4.1.5 → 4.1.7

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 (104) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +67 -0
  3. package/README-en.md +47 -183
  4. package/README.md +24 -188
  5. package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
  6. package/dist/cli/commands/best-practice-scan-command.js +35 -20
  7. package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
  8. package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
  9. package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
  10. package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
  11. package/dist/cli/commands/core/skill-registry-commands.js +9 -4
  12. package/dist/cli/commands/dispatch-command-spec.js +1 -1
  13. package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
  14. package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
  15. package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
  16. package/dist/cli/commands/dispatch-prompt-composition.d.ts +1 -1
  17. package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
  18. package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
  19. package/dist/cli/commands/openspec-command-shared.js +2 -2
  20. package/dist/cli/commands/request-transition-failures.js +31 -4
  21. package/dist/cli/commands/request-transition-preflight.js +1 -1
  22. package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
  23. package/dist/cli/commands/verdict-aggregate-command.js +2 -1
  24. package/dist/cli/commands/workflow-gate-commands.js +4 -4
  25. package/dist/cli/program.js +0 -2
  26. package/dist/services/artifacts/artifact-contract-block.js +21 -2
  27. package/dist/services/artifacts/artifact-prerequisites.d.ts +1 -0
  28. package/dist/services/artifacts/artifact-prerequisites.js +11 -99
  29. package/dist/services/artifacts/backcompat-acceptance.d.ts +66 -0
  30. package/dist/services/artifacts/backcompat-acceptance.js +220 -0
  31. package/dist/services/artifacts/prerequisite-checks.d.ts +8 -0
  32. package/dist/services/artifacts/prerequisite-checks.js +7 -2
  33. package/dist/services/artifacts/prerequisite-path-resolver.d.ts +39 -0
  34. package/dist/services/artifacts/prerequisite-path-resolver.js +110 -0
  35. package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
  36. package/dist/services/artifacts/rd-transition-gates.js +71 -0
  37. package/dist/services/artifacts/request-artifact-service.js +22 -20
  38. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +9 -1
  39. package/dist/services/artifacts/request-artifact-state-helpers.js +6 -4
  40. package/dist/services/audit-independent/judged-declaration-check.d.ts +1 -0
  41. package/dist/services/audit-independent/judged-declaration-check.js +62 -1
  42. package/dist/services/context/build-dispatch-system-prompt.d.ts +5 -9
  43. package/dist/services/context/build-dispatch-system-prompt.js +11 -11
  44. package/dist/services/context/post-compact-reinjection.js +1 -1
  45. package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
  46. package/dist/services/dispatch/test-tool-detection.js +12 -1
  47. package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.d.ts +15 -0
  48. package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.js +53 -0
  49. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +38 -0
  50. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +243 -0
  51. package/dist/services/doctor/doctor-service/plugin-registry.js +4 -0
  52. package/dist/services/doctor/doctor-service/types.d.ts +12 -0
  53. package/dist/services/evidence/evidence-generator.js +8 -4
  54. package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
  55. package/dist/services/openspec/coverage-evidence-reader.js +8 -8
  56. package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
  57. package/dist/services/openspec/openspec-archive-service.js +6 -6
  58. package/dist/services/scan/file-size-baseline.d.ts +13 -6
  59. package/dist/services/scan/file-size-baseline.js +54 -31
  60. package/dist/services/scan/file-size-scan.d.ts +7 -14
  61. package/dist/services/scan/file-size-scan.js +6 -1
  62. package/dist/services/scan/type-corroboration.d.ts +32 -0
  63. package/dist/services/scan/type-corroboration.js +51 -0
  64. package/dist/services/scan/type-sanity-service.d.ts +14 -0
  65. package/dist/services/scan/type-sanity-service.js +10 -19
  66. package/dist/services/security/safe-settings-path.d.ts +5 -0
  67. package/dist/services/security/safe-settings-path.js +64 -8
  68. package/dist/services/skill/resume-detector.js +8 -8
  69. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +28 -9
  70. package/dist/services/workflow/pipeline-verify-gate-support.js +40 -117
  71. package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
  72. package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
  73. package/dist/services/workflow/pipeline-verify-rd-phase.d.ts +67 -0
  74. package/dist/services/workflow/pipeline-verify-rd-phase.js +122 -0
  75. package/dist/services/workflow/pipeline-verify-service.js +42 -44
  76. package/dist/services/workflow/request-type-resolution.d.ts +99 -0
  77. package/dist/services/workflow/request-type-resolution.js +130 -0
  78. package/dist/services/workflow/workflow-skip-service.d.ts +1 -0
  79. package/dist/services/workflow/workflow-skip-service.js +19 -21
  80. package/dist/services/workflow/workflow-state-store.d.ts +9 -0
  81. package/dist/services/workflow/workflow-state-store.js +26 -1
  82. package/dist/services/workspace/workspace-service.js +4 -16
  83. package/dist/shared/incrementing-number.d.ts +23 -2
  84. package/dist/shared/incrementing-number.js +57 -15
  85. package/package.json +5 -7
  86. package/schemas/doctor-report.schema.json +2 -2
  87. package/skills/bee/peaks-prd/SKILL.md +3 -2
  88. package/skills/peaks-code/SKILL.md +32 -15
  89. package/dist/cli/commands/vm-command-shared.d.ts +0 -23
  90. package/dist/cli/commands/vm-command-shared.js +0 -23
  91. package/dist/cli/commands/vm-commands.d.ts +0 -3
  92. package/dist/cli/commands/vm-commands.js +0 -45
  93. package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
  94. package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
  95. package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
  96. package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
  97. package/dist/cli/commands/vm-release-command.d.ts +0 -5
  98. package/dist/cli/commands/vm-release-command.js +0 -101
  99. package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
  100. package/dist/cli/commands/vm-spawn-command.js +0 -177
  101. package/dist/cli/commands/vm-status-command.d.ts +0 -3
  102. package/dist/cli/commands/vm-status-command.js +0 -50
  103. package/dist/services/vm/vm-lease.d.ts +0 -40
  104. package/dist/services/vm/vm-lease.js +0 -160
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Check: the project carries the commit-leg back-compat acceptance list
3
+ * (`config:backcompat-acceptance`).
4
+ *
5
+ * Absence is a FAILURE, not a skip: without the list the commit-leg expiry gate
6
+ * fails closed, so a feature / bugfix / refactor slice cannot complete. The
7
+ * doctor reports the same state (`severity: 'error'`) and names the seed the
8
+ * `peaks workspace init` command writes — the LLM runs it on the user's behalf.
9
+ *
10
+ * An uninitialized project (no `.peaks/`) is not this check's finding: the
11
+ * workspace-init check owns that state, and reporting here too would name the
12
+ * same root twice.
13
+ */
14
+ import { existsSync } from 'node:fs';
15
+ import { join } from 'node:path';
16
+ const CHECK_ID = 'config:backcompat-acceptance';
17
+ const RELATIVE = '.peaks/lint/backcompat-expired-acceptance.json';
18
+ function run({ projectRootResolver }) {
19
+ const projectRoot = projectRootResolver();
20
+ if (projectRoot === null || !existsSync(join(projectRoot, '.peaks'))) {
21
+ return [
22
+ {
23
+ id: CHECK_ID,
24
+ ok: true,
25
+ message: 'No initialized workspace to inspect for a back-compat acceptance list'
26
+ }
27
+ ];
28
+ }
29
+ const absolute = join(projectRoot, '.peaks', 'lint', 'backcompat-expired-acceptance.json');
30
+ if (existsSync(absolute)) {
31
+ return [
32
+ {
33
+ id: CHECK_ID,
34
+ ok: true,
35
+ message: `Back-compat acceptance list present (${RELATIVE})`
36
+ }
37
+ ];
38
+ }
39
+ return [
40
+ {
41
+ id: CHECK_ID,
42
+ ok: false,
43
+ severity: 'error',
44
+ message: `Back-compat acceptance list is absent (${RELATIVE}); the commit-leg expiry gate ` +
45
+ 'fails closed. Ask the LLM to run `peaks workspace init --project <repo>` to seed it; ' +
46
+ "the LLM edits the tracked file on the user's behalf."
47
+ }
48
+ ];
49
+ }
50
+ export const check = {
51
+ name: 'backcompat-acceptance',
52
+ run
53
+ };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Check: canonical-store vs IDE skill-tree parity
3
+ * (`skills:reference-parity:<ide>:<skill>`).
4
+ *
5
+ * The reported host shape: `~/.peaks/skills/peaks-code/references/fast-lane-norm.md`
6
+ * exists while `~/.claude/skills/peaks-code/references/fast-lane-norm.md` does
7
+ * not. `peaks skill sync` closes that gap, but nothing named it first, so the
8
+ * missing reference surfaced only when a skill's prose cited it.
9
+ *
10
+ * Read-only: the check lists both trees and reports the difference. It never
11
+ * repairs, rewrites, or deletes. A mismatch is a warning — a skill missing one
12
+ * reference still runs — and the message names the LLM-run repair.
13
+ *
14
+ * The canonical store is the anchor: only skills present under
15
+ * `<PEAKS_HOME or ~/.peaks>/skills` are compared, so a user-authored skill that
16
+ * exists only in an IDE root is not reported as drift.
17
+ *
18
+ * Symlinks are followed (`statSync`, not `lstatSync`), so the common junction
19
+ * install compares equal; a real copy whose file set drifted is the case this
20
+ * check exists for. Each directory is visited once by resolved path, so a
21
+ * junction cycle cannot invent phantom paths.
22
+ */
23
+ import type { DoctorCheck, DoctorCheckPlugin } from '../types.js';
24
+ /**
25
+ * Pure comparator. `canonicalRoot` is the canonical skills store
26
+ * (`<PEAKS_HOME or ~/.peaks>/skills`); `ideRoots` are the IDE-side skills
27
+ * directories to compare against it. Roots that do not exist are skipped, so
28
+ * the wrapper may pass every adapter that declares `skillInstall`.
29
+ *
30
+ * Identical trees emit no check at all: the absence of a parity finding is the
31
+ * pass, which keeps the doctor report exactly as long as its findings. A store
32
+ * that exists but cannot be read is a warning, never silence.
33
+ */
34
+ export declare function compareSkillReferenceParity(canonicalRoot: string, ideRoots: ReadonlyArray<{
35
+ ide: string;
36
+ skillsDir: string;
37
+ }>): DoctorCheck[];
38
+ export declare const check: DoctorCheckPlugin;
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Check: canonical-store vs IDE skill-tree parity
3
+ * (`skills:reference-parity:<ide>:<skill>`).
4
+ *
5
+ * The reported host shape: `~/.peaks/skills/peaks-code/references/fast-lane-norm.md`
6
+ * exists while `~/.claude/skills/peaks-code/references/fast-lane-norm.md` does
7
+ * not. `peaks skill sync` closes that gap, but nothing named it first, so the
8
+ * missing reference surfaced only when a skill's prose cited it.
9
+ *
10
+ * Read-only: the check lists both trees and reports the difference. It never
11
+ * repairs, rewrites, or deletes. A mismatch is a warning — a skill missing one
12
+ * reference still runs — and the message names the LLM-run repair.
13
+ *
14
+ * The canonical store is the anchor: only skills present under
15
+ * `<PEAKS_HOME or ~/.peaks>/skills` are compared, so a user-authored skill that
16
+ * exists only in an IDE root is not reported as drift.
17
+ *
18
+ * Symlinks are followed (`statSync`, not `lstatSync`), so the common junction
19
+ * install compares equal; a real copy whose file set drifted is the case this
20
+ * check exists for. Each directory is visited once by resolved path, so a
21
+ * junction cycle cannot invent phantom paths.
22
+ */
23
+ import { existsSync, readdirSync, realpathSync, statSync } from 'node:fs';
24
+ import { homedir } from 'node:os';
25
+ import { join } from 'node:path';
26
+ import { getAdapter, listAdapterIds } from '../../../ide/ide-registry.js';
27
+ const MANAGED_MARKER_SUFFIX = '.peaks-managed';
28
+ /** Atomic-write scratch names the canonical store leaves behind; never assets. */
29
+ const TEMP_ENTRY_PREFIX = '.peaks-tmp-';
30
+ /** Secondary bound: a legitimate skill tree is shallow. */
31
+ const MAX_DEPTH = 24;
32
+ /** How many paths the message names per side, so a large drift stays readable. */
33
+ const REPORT_LIMIT = 3;
34
+ const REPAIR_HINT = 'Ask the LLM to run `peaks skill sync`';
35
+ function listRelativeFiles(root) {
36
+ const walk = { root, into: new Set(), visited: new Set() };
37
+ collectFiles(walk, '', 0);
38
+ return walk.into;
39
+ }
40
+ function collectFiles(walk, prefix, depth) {
41
+ if (depth > MAX_DEPTH)
42
+ return;
43
+ const directory = prefix === '' ? walk.root : join(walk.root, prefix);
44
+ let identity;
45
+ try {
46
+ identity = realpathSync(directory);
47
+ }
48
+ catch {
49
+ // An unreadable directory contributes no comparable files.
50
+ return;
51
+ }
52
+ if (walk.visited.has(identity))
53
+ return;
54
+ walk.visited.add(identity);
55
+ for (const name of readEntryNames(directory).sort()) {
56
+ if (isIgnoredEntryName(name))
57
+ continue;
58
+ const relativePath = prefix === '' ? name : `${prefix}/${name}`;
59
+ const kind = entryKind(join(walk.root, relativePath));
60
+ if (kind === 'directory') {
61
+ collectFiles(walk, relativePath, depth + 1);
62
+ }
63
+ else if (kind === 'file') {
64
+ walk.into.add(relativePath);
65
+ }
66
+ }
67
+ }
68
+ /** Names directly under `directory`; an unreadable directory has none. */
69
+ function readEntryNames(directory) {
70
+ try {
71
+ return readdirSync(directory);
72
+ }
73
+ catch {
74
+ return [];
75
+ }
76
+ }
77
+ /** `.`/`..`, managed sidecars and scratch siblings are not skill assets. */
78
+ function isIgnoredEntryName(name) {
79
+ return (name === '.' ||
80
+ name === '..' ||
81
+ name.endsWith(MANAGED_MARKER_SUFFIX) ||
82
+ name.startsWith(TEMP_ENTRY_PREFIX));
83
+ }
84
+ /** What `absolutePath` is, following symlinks; an unreadable entry is `other`. */
85
+ function entryKind(absolutePath) {
86
+ try {
87
+ const stats = statSync(absolutePath);
88
+ if (stats.isDirectory())
89
+ return 'directory';
90
+ return stats.isFile() ? 'file' : 'other';
91
+ }
92
+ catch {
93
+ // A dangling link or an unreadable entry is not a comparable file.
94
+ return 'other';
95
+ }
96
+ }
97
+ /** Skill names under `root` (directories only, symlinks followed). */
98
+ function listSkillNames(root) {
99
+ const skills = [];
100
+ for (const name of readEntryNames(root).sort()) {
101
+ if (isIgnoredEntryName(name))
102
+ continue;
103
+ if (entryKind(join(root, name)) === 'directory')
104
+ skills.push(name);
105
+ }
106
+ return skills;
107
+ }
108
+ /**
109
+ * Why the canonical store cannot be compared, or null when it is a readable
110
+ * directory. An absent path is handled separately (a fresh host is not a
111
+ * finding); an existing but unusable path is, because it would otherwise look
112
+ * exactly like "no drift".
113
+ */
114
+ function storeProblem(canonicalRoot) {
115
+ let kind;
116
+ try {
117
+ const stats = statSync(canonicalRoot);
118
+ kind = stats.isDirectory() ? 'directory' : stats.isFile() ? 'file' : 'other';
119
+ }
120
+ catch {
121
+ return 'cannot be read';
122
+ }
123
+ if (kind !== 'directory')
124
+ return 'is not a directory';
125
+ try {
126
+ readdirSync(canonicalRoot);
127
+ }
128
+ catch {
129
+ return 'is not readable';
130
+ }
131
+ return null;
132
+ }
133
+ function diffSkillTrees(ide, skill, canonicalFiles, ideFiles) {
134
+ const missing = [...canonicalFiles].filter((path) => !ideFiles.has(path)).sort();
135
+ const extra = [...ideFiles].filter((path) => !canonicalFiles.has(path)).sort();
136
+ if (missing.length === 0 && extra.length === 0)
137
+ return null;
138
+ return { ide, skill, missing, extra };
139
+ }
140
+ function summarize(paths) {
141
+ const shown = paths.slice(0, REPORT_LIMIT).join(', ');
142
+ const rest = paths.length - REPORT_LIMIT;
143
+ return rest > 0 ? `${shown} and ${rest} more` : shown;
144
+ }
145
+ /**
146
+ * Keep a filesystem-derived name inside the check-id schema's id alphabet.
147
+ * The message keeps the real name; only the id is normalised, because the
148
+ * doctor's own `doctor-self:check-id-pattern` check fails the report on an id
149
+ * the schema cannot match.
150
+ */
151
+ function toIdSegment(value) {
152
+ const cleaned = value.replace(/[^A-Za-z0-9._-]/g, '-');
153
+ return /^[A-Za-z0-9]/.test(cleaned) ? cleaned : `s-${cleaned}`;
154
+ }
155
+ function toCheck(issue, canonicalRoot) {
156
+ const parts = [
157
+ `Skill ${issue.skill} under IDE ${issue.ide} diverges from the canonical store at ${canonicalRoot}`
158
+ ];
159
+ if (issue.missing.length > 0)
160
+ parts.push(`missing: ${summarize(issue.missing)}`);
161
+ if (issue.extra.length > 0)
162
+ parts.push(`extra: ${summarize(issue.extra)}`);
163
+ return {
164
+ id: `skills:reference-parity:${toIdSegment(issue.ide)}:${toIdSegment(issue.skill)}`,
165
+ ok: false,
166
+ severity: 'warning',
167
+ message: `${parts.join('; ')}. ${REPAIR_HINT}.`
168
+ };
169
+ }
170
+ /**
171
+ * Pure comparator. `canonicalRoot` is the canonical skills store
172
+ * (`<PEAKS_HOME or ~/.peaks>/skills`); `ideRoots` are the IDE-side skills
173
+ * directories to compare against it. Roots that do not exist are skipped, so
174
+ * the wrapper may pass every adapter that declares `skillInstall`.
175
+ *
176
+ * Identical trees emit no check at all: the absence of a parity finding is the
177
+ * pass, which keeps the doctor report exactly as long as its findings. A store
178
+ * that exists but cannot be read is a warning, never silence.
179
+ */
180
+ export function compareSkillReferenceParity(canonicalRoot, ideRoots) {
181
+ if (!existsSync(canonicalRoot)) {
182
+ return [
183
+ {
184
+ id: 'skills:reference-parity:store',
185
+ ok: true,
186
+ message: `Canonical skill store not found at ${canonicalRoot}; nothing to compare`
187
+ }
188
+ ];
189
+ }
190
+ const problem = storeProblem(canonicalRoot);
191
+ if (problem !== null) {
192
+ return [
193
+ {
194
+ id: 'skills:reference-parity:store',
195
+ ok: false,
196
+ severity: 'warning',
197
+ message: `Canonical skill store at ${canonicalRoot} ${problem}; IDE skill roots were not compared`
198
+ }
199
+ ];
200
+ }
201
+ const canonicalSkills = new Map();
202
+ for (const skill of listSkillNames(canonicalRoot)) {
203
+ canonicalSkills.set(skill, listRelativeFiles(join(canonicalRoot, skill)));
204
+ }
205
+ const checks = [];
206
+ for (const { ide, skillsDir } of ideRoots) {
207
+ if (!existsSync(skillsDir))
208
+ continue;
209
+ for (const skill of [...canonicalSkills.keys()].sort()) {
210
+ const issue = diffSkillTrees(ide, skill, canonicalSkills.get(skill) ?? new Set(), listRelativeFiles(join(skillsDir, skill)));
211
+ if (issue !== null)
212
+ checks.push(toCheck(issue, canonicalRoot));
213
+ }
214
+ }
215
+ return checks;
216
+ }
217
+ function canonicalSkillsStore() {
218
+ const home = process.env.PEAKS_HOME?.trim();
219
+ const root = home !== undefined && home.length > 0 ? home : join(homedir(), '.peaks');
220
+ return join(root, 'skills');
221
+ }
222
+ /** IDE skills dirs from the adapter registry, existing roots only. */
223
+ function existingIdeSkillRoots() {
224
+ const roots = [];
225
+ for (const ide of listAdapterIds()) {
226
+ const skillsDir = getAdapter(ide).skillInstall?.skillsDir;
227
+ if (skillsDir === undefined || !existsSync(skillsDir))
228
+ continue;
229
+ roots.push({ ide, skillsDir });
230
+ }
231
+ return roots;
232
+ }
233
+ function run(context) {
234
+ const injected = context.options.skillParity;
235
+ if (injected !== undefined) {
236
+ return compareSkillReferenceParity(injected.canonicalRoot, injected.ideRoots);
237
+ }
238
+ return compareSkillReferenceParity(canonicalSkillsStore(), existingIdeSkillRoots());
239
+ }
240
+ export const check = {
241
+ name: 'skill-reference-parity',
242
+ run
243
+ };
@@ -34,6 +34,7 @@ import { check as skillNameMatch } from './checks/skill-name-match.js';
34
34
  import { check as skillParse } from './checks/skill-parse.js';
35
35
  import { check as skillRunbook } from './checks/skill-runbook.js';
36
36
  import { check as skillApplyNote } from './checks/skill-apply-note.js';
37
+ import { check as skillReferenceParity } from './checks/skill-reference-parity.js';
37
38
  import { check as schemaValidity } from './checks/schema-validity.js';
38
39
  import { check as userConfig } from './checks/user-config.js';
39
40
  import { check as skillPresence } from './checks/skill-presence.js';
@@ -49,6 +50,7 @@ import { check as workspaceLayout } from './checks/workspace-layout.js';
49
50
  import { check as gateguardConflict } from './checks/gateguard-conflict.js';
50
51
  import { check as eccHooksSchemaDrift } from './checks/ecc-hooks-schema-drift.js';
51
52
  import { check as checkIdSchema } from './checks/check-id-schema.js';
53
+ import { check as backcompatAcceptance } from './checks/backcompat-acceptance.js';
52
54
  import { check as l3OrphanSessions } from './checks/l3-orphan-sessions.js';
53
55
  import { check as l3MemoryHealth } from './checks/l3-memory-health.js';
54
56
  /**
@@ -63,6 +65,7 @@ export const PLUGINS = [
63
65
  skillParse, // id prefix "skill-parse:"
64
66
  skillRunbook, // id prefix "skill-runbook:"
65
67
  skillApplyNote, // id prefix "skill-apply-note:"
68
+ skillReferenceParity, // ids "skills:reference-parity:<ide>:<skill>" + "skills:reference-parity:store"
66
69
  schemaValidity, // id prefix "schema:"
67
70
  userConfig, // id "config:user"
68
71
  skillPresence, // ids "skill-presence:current" + "skill-presence:freshness"
@@ -77,6 +80,7 @@ export const PLUGINS = [
77
80
  workspaceLayout, // id "build:workspace-layout-canonical"
78
81
  gateguardConflict, // id "integration:gateguard-peaks-conflict"
79
82
  eccHooksSchemaDrift, // id "integration:ecc-hooks-schema-drift"
83
+ backcompatAcceptance, // id "config:backcompat-acceptance"
80
84
  checkIdSchema, // id "doctor-self:check-id-pattern"
81
85
  l3OrphanSessions, // id "L3:l3-orphan-sessions"
82
86
  l3MemoryHealth // id "L3:l3-memory-health"
@@ -108,6 +108,18 @@ export type DoctorOptions = {
108
108
  gateguardProbe?: GateguardProbe;
109
109
  /** Injected for the integration:ecc-hooks-schema-drift check (defaults to defaultEccHooksDriftProbe on disk). */
110
110
  eccHooksDriftProbe?: EccHooksDriftProbe;
111
+ /**
112
+ * Injected roots for the `skills:reference-parity` check. When omitted the
113
+ * check binds `$PEAKS_HOME`/`~/.peaks` and the adapter registry. Tests pass
114
+ * temp directories here, so no test reads the real home directory.
115
+ */
116
+ skillParity?: {
117
+ canonicalRoot: string;
118
+ ideRoots: ReadonlyArray<{
119
+ ide: string;
120
+ skillsDir: string;
121
+ }>;
122
+ };
111
123
  /**
112
124
  * root for the L3:l3-memory-health check (defaults to
113
125
  * `findProjectRoot(process.cwd())`). Tests use this to point the
@@ -34,6 +34,7 @@ import { handoffRelativePath, sha256OfBody } from '../prd/handoff-service.js';
34
34
  import { getSessionDir } from '../session/getSessionDir.js';
35
35
  import { REQUEST_ID_PATTERN } from '../artifacts/request-artifact-service.js';
36
36
  import { isUnsafePathInput } from '../../shared/path-safety.js';
37
+ import { requestIdFromFileName, slugifyDescription } from '../../shared/incrementing-number.js';
37
38
  import { renderJudgedSection } from '../audit-independent/judged-declaration-build.js';
38
39
  import { buildCodeReview, buildKarpathyReview, buildPerfAudit, buildPerformanceFindings, buildQaRequest, buildSecurityFindings, buildSecurityReview, buildTechDoc, buildTestCases, buildTestReport, filesMd, lineCountsMd } from './evidence-body-builders.js';
39
40
  /** Comma/space tolerant `--files` splitter. */
@@ -105,19 +106,22 @@ ${lineCountsMd(lineCounts)}
105
106
  };
106
107
  return { content: `${serializeHandoffFrontmatter(frontmatter)}${body}`, hash: handoffHash };
107
108
  }
108
- /** Find the existing numbered QA request file for `rid`, else the default. */
109
+ /** Find the QA request file whose carried id is `rid`, else the default. */
109
110
  async function resolveQaRequestPath(qaDir, rid) {
110
- const suffix = `-${rid}.md`;
111
111
  try {
112
112
  const entries = await readdir(join(qaDir, 'requests'));
113
- const match = entries.find((name) => /^\d+-/.test(name) && name.endsWith(suffix));
113
+ // The operand is the SLUG, as it is at the two `request-artifact-service.ts`
114
+ // sites: the writer lowercases the rid into the filename, so comparing a
115
+ // carried id against the raw rid answers a different question about the same
116
+ // file and misses it whenever the rid carries a capital.
117
+ const match = entries.find((name) => requestIdFromFileName(name) === slugifyDescription(rid));
114
118
  if (match !== undefined)
115
119
  return join(qaDir, 'requests', match);
116
120
  }
117
121
  catch {
118
122
  // directory missing — fall through to the default numbered name
119
123
  }
120
- return join(qaDir, 'requests', `001-${rid}.md`);
124
+ return join(qaDir, 'requests', `001-${slugifyDescription(rid)}.md`);
121
125
  }
122
126
  export async function generateEvidence(options) {
123
127
  const { projectRoot, rid, title, files, lineCounts, sessionId } = options;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Coverage Evidence reader for c8 `coverage-summary.json` (Fix-6B).
2
+ * Coverage Evidence reader for the istanbul `coverage-summary.json` shape (Fix-6B).
3
3
  *
4
4
  * - pure helper module, no side effects beyond FS reads
5
- * - reads the istanbul-reporter JSON shape emitted by `c8 --reporter=json-summary`
6
- * (the project's coverage tool — see scripts/coverage-c8.mjs)
5
+ * - reads the istanbul-reporter JSON shape a `--reporter=json-summary` run emits
6
+ * (the project's instrument is `.husky/coverage-ratchet.mjs`, which emits it)
7
7
  * - resolves a `coverage-summary.json` from a fixed discovery order
8
8
  * - validates per-capability coverage against a `## Capability Mapping` block
9
9
  *
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * Conventions:
16
16
  * - All paths are POSIX-normalized for JSON safety.
17
- * - The c8 summary's per-file keys are project-root-relative POSIX paths
17
+ * - The summary's per-file keys are project-root-relative POSIX paths
18
18
  * (e.g. `src/services/openspec/openspec-archive-service.ts`).
19
19
  * - Capability mapping `source` field is also project-root-relative, may be
20
20
  * a file (`foo.ts`) or a directory (`src/services/openspec/`).
@@ -37,7 +37,7 @@ export type CoverageSummary = {
37
37
  files: ReadonlyMap<string, CoverageFileEntry>;
38
38
  };
39
39
  export type CoverageFileEntry = {
40
- /** Absolute path the c8 entry covers (POSIX). */
40
+ /** Absolute path the summary entry covers (POSIX). */
41
41
  path: string;
42
42
  /** Project-root-relative POSIX path (the key the summary uses). */
43
43
  relativePath: string;
@@ -101,7 +101,7 @@ export type CoverageValidation = {
101
101
  *
102
102
  * Discovery order (per Fix-6B AC1):
103
103
  * 1. `explicitPath` (passed via `--coverage-summary`)
104
- * 2. `<projectRoot>/coverage/coverage-summary.json` (c8 wrapper default)
104
+ * 2. `<projectRoot>/coverage/coverage-summary.json` (the coverage run's default)
105
105
  * 3. `<projectRoot>/openspec/coverage-summary.json` (per-project override)
106
106
  *
107
107
  * Returns:
@@ -153,7 +153,7 @@ export declare function parseCapabilityMapping(proposalPath: string): Promise<{
153
153
  * - File path: returns `[file]`.
154
154
  * - Directory path: returns every `*.ts` file recursively under it (relative
155
155
  * to `projectRoot`, POSIX separators). Non-TS files are excluded because
156
- * c8 only collects coverage on TS source modules.
156
+ * the summary only carries TS source modules.
157
157
  */
158
158
  export declare function resolveCapabilityFiles(input: {
159
159
  projectRoot: string;
@@ -161,7 +161,7 @@ export declare function resolveCapabilityFiles(input: {
161
161
  }): Promise<ReadonlyArray<string>>;
162
162
  /**
163
163
  * Validate per-capability coverage. Each capability row's `source` is resolved
164
- * to one or more files; each file must appear in the c8 summary with all four
164
+ * to one or more files; each file must appear in the summary with all four
165
165
  * metrics at exactly 100%.
166
166
  *
167
167
  * Returns `{ ok: true }` when every capability passes; `{ ok: false, mismatches }`
@@ -175,7 +175,7 @@ export declare function validateCapabilityCoverage(input: {
175
175
  }): Promise<CoverageValidation>;
176
176
  /**
177
177
  * Compare the mtime of every spec/proposal/tasks file under the change against
178
- * the mtime of the c8 summary. If any change file is newer than the summary,
178
+ * the mtime of the summary. If any change file is newer than the summary,
179
179
  * the captured V8 counters no longer match the source on disk and the summary
180
180
  * is stale.
181
181
  *
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Coverage Evidence reader for c8 `coverage-summary.json` (Fix-6B).
2
+ * Coverage Evidence reader for the istanbul `coverage-summary.json` shape (Fix-6B).
3
3
  *
4
4
  * - pure helper module, no side effects beyond FS reads
5
- * - reads the istanbul-reporter JSON shape emitted by `c8 --reporter=json-summary`
6
- * (the project's coverage tool — see scripts/coverage-c8.mjs)
5
+ * - reads the istanbul-reporter JSON shape a `--reporter=json-summary` run emits
6
+ * (the project's instrument is `.husky/coverage-ratchet.mjs`, which emits it)
7
7
  * - resolves a `coverage-summary.json` from a fixed discovery order
8
8
  * - validates per-capability coverage against a `## Capability Mapping` block
9
9
  *
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * Conventions:
16
16
  * - All paths are POSIX-normalized for JSON safety.
17
- * - The c8 summary's per-file keys are project-root-relative POSIX paths
17
+ * - The summary's per-file keys are project-root-relative POSIX paths
18
18
  * (e.g. `src/services/openspec/openspec-archive-service.ts`).
19
19
  * - Capability mapping `source` field is also project-root-relative, may be
20
20
  * a file (`foo.ts`) or a directory (`src/services/openspec/`).
@@ -36,7 +36,7 @@ const DEFAULT_DISCOVERY = [
36
36
  *
37
37
  * Discovery order (per Fix-6B AC1):
38
38
  * 1. `explicitPath` (passed via `--coverage-summary`)
39
- * 2. `<projectRoot>/coverage/coverage-summary.json` (c8 wrapper default)
39
+ * 2. `<projectRoot>/coverage/coverage-summary.json` (the coverage run's default)
40
40
  * 3. `<projectRoot>/openspec/coverage-summary.json` (per-project override)
41
41
  *
42
42
  * Returns:
@@ -238,7 +238,7 @@ function parseCapabilityRow(line) {
238
238
  * - File path: returns `[file]`.
239
239
  * - Directory path: returns every `*.ts` file recursively under it (relative
240
240
  * to `projectRoot`, POSIX separators). Non-TS files are excluded because
241
- * c8 only collects coverage on TS source modules.
241
+ * the summary only carries TS source modules.
242
242
  */
243
243
  export async function resolveCapabilityFiles(input) {
244
244
  const abs = resolve(input.projectRoot, input.row.source);
@@ -280,7 +280,7 @@ async function walkTsFiles(absRoot, projectRoot) {
280
280
  // ---------------------------------------------------------------------------
281
281
  /**
282
282
  * Validate per-capability coverage. Each capability row's `source` is resolved
283
- * to one or more files; each file must appear in the c8 summary with all four
283
+ * to one or more files; each file must appear in the summary with all four
284
284
  * metrics at exactly 100%.
285
285
  *
286
286
  * Returns `{ ok: true }` when every capability passes; `{ ok: false, mismatches }`
@@ -336,7 +336,7 @@ export async function validateCapabilityCoverage(input) {
336
336
  // ---------------------------------------------------------------------------
337
337
  /**
338
338
  * Compare the mtime of every spec/proposal/tasks file under the change against
339
- * the mtime of the c8 summary. If any change file is newer than the summary,
339
+ * the mtime of the summary. If any change file is newer than the summary,
340
340
  * the captured V8 counters no longer match the source on disk and the summary
341
341
  * is stale.
342
342
  *
@@ -38,7 +38,7 @@ export type CoverageEvidence = {
38
38
  capabilityRows: ReadonlyArray<CapabilityMappingRow>;
39
39
  /** Resolved coverage-summary.json absolute path (Fix-6B). */
40
40
  summaryPath?: string;
41
- /** Freshness status of the c8 summary relative to change files. */
41
+ /** Freshness status of the summary relative to change files. */
42
42
  summaryStatus: 'missing' | 'stale' | 'fresh' | 'unavailable';
43
43
  /** Per-capability validation outcome. */
44
44
  capabilityValidation: 'ok' | 'mismatch' | 'no-mapping' | 'not-enforced';
@@ -218,7 +218,7 @@ export async function archiveOpenSpecChange(changeId, options = {}) {
218
218
  });
219
219
  }
220
220
  }
221
- // --- Fix-6B: parse Capability Mapping block + validate against c8 summary ---
221
+ // --- Fix-6B: parse Capability Mapping block + validate against the summary ---
222
222
  const mapping = await parseCapabilityMapping(proposalPath);
223
223
  coverage = {
224
224
  ...coverage,
@@ -245,7 +245,7 @@ export async function archiveOpenSpecChange(changeId, options = {}) {
245
245
  ? summaryPathResult.error.triedPaths
246
246
  : [summaryPathResult.error.path];
247
247
  throw new OpenSpecArchiveError('OPENSPEC_COVERAGE_EVIDENCE_MISSING', `Refusing to archive "${changeId}": no coverage-summary.json found at any of: ${triedPaths.join(', ')}. ` +
248
- 'Run `pnpm test:coverage` (which invokes scripts/coverage-c8.mjs) to generate one, ' +
248
+ 'Generate coverage/coverage-summary.json with the project coverage run (`.husky/coverage-ratchet.mjs` here), ' +
249
249
  'or pass --coverage-summary <path> to point at an existing summary, ' +
250
250
  'or re-run with --force to bypass.', {
251
251
  changeId,
@@ -260,7 +260,7 @@ export async function archiveOpenSpecChange(changeId, options = {}) {
260
260
  }
261
261
  catch (error) {
262
262
  throw new OpenSpecArchiveError('OPENSPEC_COVERAGE_EVIDENCE_MISSING', `Refusing to archive "${changeId}": coverage-summary.json at ${summaryPathResult.value} is malformed (${error.message}). ` +
263
- 'Re-run `pnpm test:coverage` to regenerate, or pass --coverage-summary <path> to point at a valid summary.', { changeId, path: summaryPathResult.value, coverage });
263
+ 'Re-generate coverage/coverage-summary.json, or pass --coverage-summary <path> to point at a valid summary.', { changeId, path: summaryPathResult.value, coverage });
264
264
  }
265
265
  coverage = {
266
266
  ...coverage,
@@ -279,7 +279,7 @@ export async function archiveOpenSpecChange(changeId, options = {}) {
279
279
  staleFiles
280
280
  };
281
281
  throw new OpenSpecArchiveError('OPENSPEC_COVERAGE_EVIDENCE_STALE', `Refusing to archive "${changeId}": coverage-summary.json is older than ${staleFiles.length} change file(s). ` +
282
- 'Re-run `pnpm test:coverage` to refresh, or re-run with --force to bypass.', { changeId, staleFiles, summaryPath: summary.path, coverage });
282
+ 'Re-generate coverage/coverage-summary.json to refresh, or re-run with --force to bypass.', { changeId, staleFiles, summaryPath: summary.path, coverage });
283
283
  }
284
284
  coverage = {
285
285
  ...coverage,
@@ -301,8 +301,8 @@ export async function archiveOpenSpecChange(changeId, options = {}) {
301
301
  coverageMismatchBypassed = true;
302
302
  }
303
303
  else {
304
- throw new OpenSpecArchiveError('OPENSPEC_COVERAGE_EVIDENCE_MISMATCH', `Refusing to archive "${changeId}": ${validation.mismatches.length} capability row(s) claim "covered" in proposal.md but c8 reports < 100% coverage. ` +
305
- 'Re-run `pnpm test:coverage` after closing the gap, or re-run with --force to bypass.', {
304
+ throw new OpenSpecArchiveError('OPENSPEC_COVERAGE_EVIDENCE_MISMATCH', `Refusing to archive "${changeId}": ${validation.mismatches.length} capability row(s) claim "covered" in proposal.md but the coverage summary reports < 100% coverage. ` +
305
+ 'Re-generate coverage/coverage-summary.json after closing the gap, or re-run with --force to bypass.', {
306
306
  changeId,
307
307
  mismatches: validation.mismatches,
308
308
  coverage
@@ -13,12 +13,19 @@ export type ChangedFiles = {
13
13
  baselinePathFor(file: string): string;
14
14
  };
15
15
  /**
16
- * The changed-file population the scan measures, as `git diff --name-status`
17
- * reports it. `A`/`M` keep their path; `R`/`C` keep the TARGET path and record
18
- * the source, so the rename is judged against the size the file had before it
19
- * moved; `D` is dropped. A git failure here THROWS rather than returning `[]`.
20
- *
21
- * `only` is the caller's own list, when it has one — see `restrictedTo`.
16
+ * One git enumeration for both readers that need the change set: the declared-
17
+ * type rule judges `changedPaths` (deletions included), and the size scan
18
+ * measures `changedFiles` (the A/M/R/untracked subset). Two spawns total,
19
+ * `git diff` + `git ls-files`, never one pair per reader.
20
+ */
21
+ export type GitChangeSet = {
22
+ changedPaths: string[];
23
+ changedFiles: ChangedFiles;
24
+ };
25
+ export declare function readGitChangeSet(projectRoot: string, baseRef: string, only?: readonly string[]): GitChangeSet;
26
+ /**
27
+ * The measurable subset alone. Kept as the size scan's entry point; the
28
+ * transition gate calls `readGitChangeSet` so the type rule shares the read.
22
29
  */
23
30
  export declare function readChangedFiles(projectRoot: string, baseRef: string, only?: readonly string[]): ChangedFiles;
24
31
  /** The file's raw-line count AT `baseRef`, or `null` when the ref has no such