peaks-loop 4.1.6 → 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 (25) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +31 -0
  3. package/dist/cli/commands/core/skill-registry-commands.js +9 -4
  4. package/dist/services/artifacts/artifact-prerequisites.d.ts +1 -0
  5. package/dist/services/artifacts/artifact-prerequisites.js +9 -97
  6. package/dist/services/artifacts/backcompat-acceptance.d.ts +66 -0
  7. package/dist/services/artifacts/backcompat-acceptance.js +220 -0
  8. package/dist/services/artifacts/prerequisite-checks.d.ts +8 -0
  9. package/dist/services/artifacts/prerequisite-checks.js +7 -2
  10. package/dist/services/artifacts/prerequisite-path-resolver.d.ts +39 -0
  11. package/dist/services/artifacts/prerequisite-path-resolver.js +110 -0
  12. package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.d.ts +15 -0
  13. package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.js +53 -0
  14. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +38 -0
  15. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +243 -0
  16. package/dist/services/doctor/doctor-service/plugin-registry.js +4 -0
  17. package/dist/services/doctor/doctor-service/types.d.ts +12 -0
  18. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +4 -1
  19. package/dist/services/workflow/pipeline-verify-gate-support.js +8 -79
  20. package/dist/services/workflow/pipeline-verify-rd-phase.d.ts +67 -0
  21. package/dist/services/workflow/pipeline-verify-rd-phase.js +122 -0
  22. package/dist/services/workflow/pipeline-verify-service.js +16 -17
  23. package/dist/services/workspace/workspace-service.js +4 -16
  24. package/package.json +5 -5
  25. package/schemas/doctor-report.schema.json +2 -2
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Where a prerequisite resolves on disk: its declared path, the numbered
3
+ * filename prefix `request init` writes, and the historical session-root tiers.
4
+ *
5
+ * THE ONE RESOLVER. The transition (`checkPrerequisites`) and the commit gate
6
+ * (`checkExpiredBackCompatCommitGate`) both ask this module, so a numbered
7
+ * prefix or a legacy root that one honours cannot be misread by the other.
8
+ * It lives here, rather than in `artifact-prerequisites.ts`, because that file
9
+ * is over the file-size cap and a change may only shrink it.
10
+ */
11
+ import { join, dirname, basename } from 'node:path';
12
+ import { readdir } from 'node:fs/promises';
13
+ import { pathExists } from 'peaks-loop-shared/fs';
14
+ import { NUMBERED_PREFIX_RE, slugifyDescription } from '../../shared/incrementing-number.js';
15
+ export function resolvePrerequisitePath(prerequisite, requestId) {
16
+ return prerequisite.relativePath.replace('<rid>', requestId);
17
+ }
18
+ export function sessionRootsFor(projectRoot, sessionId) {
19
+ if (sessionId === undefined)
20
+ return { canonical: null, legacy: null };
21
+ return {
22
+ canonical: join(projectRoot, '.peaks', '_runtime', sessionId),
23
+ legacy: join(projectRoot, '.peaks', sessionId)
24
+ };
25
+ }
26
+ /**
27
+ * Resolve a prerequisite to an on-disk path, tolerating the numbered filename
28
+ * prefix that `request init` writes (e.g. `001-<rid>.md`). When the prerequisite
29
+ * path contains `<rid>`, we accept either the legacy bare `<rid>.md` form or any
30
+ * `NNN-<rid>.md` numbered form — mirroring the matcher in request-artifact-service.
31
+ * Returns the matched absolute path, or null when nothing matches.
32
+ */
33
+ async function resolvePrerequisiteAbsolutePath(sessionRoot, prerequisite, requestId) {
34
+ const relative = resolvePrerequisitePath(prerequisite, requestId);
35
+ const exact = join(sessionRoot, relative);
36
+ if (await pathExists(exact)) {
37
+ return exact;
38
+ }
39
+ // Only `<rid>`-templated prerequisites can carry a numbered prefix; fixed paths
40
+ // (e.g. rd/tech-doc.md) are matched exactly above.
41
+ if (!prerequisite.relativePath.includes('<rid>')) {
42
+ return null;
43
+ }
44
+ const dir = dirname(exact);
45
+ // The on-disk suffix is the SLUG of this basename — the writer lowercases the
46
+ // rid — so a mixed-case rid used to be reported absent with the file on disk.
47
+ const suffix = `-${slugifyDescription(basename(exact).replace(/\.md$/, ''))}.md`;
48
+ let entries;
49
+ try {
50
+ entries = await readdir(dir);
51
+ }
52
+ catch {
53
+ // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
54
+ return null;
55
+ }
56
+ const match = entries.find((name) => NUMBERED_PREFIX_RE.test(name) && name.endsWith(suffix));
57
+ return match ? join(dir, match) : null;
58
+ }
59
+ /**
60
+ * Resolve a prerequisite to an on-disk path, with a 2-tier fallback
61
+ * dirs are no longer created):
62
+ * 1. `<canonicalSessionRoot>/<relative>` (post-F3 canonical session
63
+ * home, when `canonicalSessionRoot` is provided).
64
+ * 2. `<legacySessionRoot>/<relative>` (pre-F3 legacy session home,
65
+ * when `legacySessionRoot` is provided).
66
+ * Tolerates the numbered filename prefix that `request init` writes
67
+ * (e.g. `001-<rid>.md`) at every tier. Returns the matched absolute
68
+ * path, or null when nothing matches.
69
+ *
70
+ * Back-compat: once neither primary session-root tier resolved, the
71
+ * resolver walks `prerequisite.legacyRelativePaths` in declared order
72
+ * and tries each at BOTH session roots before declaring the prereq
73
+ * missing. This covers both artifacts that moved location
74
+ * (`rd/security-review.md` → `audit/security.md`) and ones that later
75
+ * gained a rid in the filename (`audit/security.md` →
76
+ */
77
+ export async function resolvePrerequisiteAbsolutePathWithFallback(canonicalSessionRoot, legacySessionRoot, prerequisite, requestId) {
78
+ const roots = [canonicalSessionRoot, legacySessionRoot];
79
+ // First pass: try the primary relativePath at every root.
80
+ for (const root of roots) {
81
+ if (root === null)
82
+ continue;
83
+ const found = await resolvePrerequisiteAbsolutePath(root, prerequisite, requestId);
84
+ if (found !== null)
85
+ return found;
86
+ }
87
+ // Second pass: the single previous location, then any further older
88
+ // ones, at every root — newest first, so a session that somehow holds
89
+ // both a pre-rid and a v2.11.x file resolves to the newer shape.
90
+ // Only the relativePath is swapped — the same numbered-prefix
91
+ // tolerance applies via the shared resolver.
92
+ const legacyTiers = [
93
+ ...(prerequisite.legacyRelativePath !== undefined ? [prerequisite.legacyRelativePath] : []),
94
+ ...(prerequisite.legacyRelativePaths ?? [])
95
+ ];
96
+ for (const legacy of legacyTiers) {
97
+ const legacyPrereq = {
98
+ ...prerequisite,
99
+ relativePath: legacy
100
+ };
101
+ for (const root of roots) {
102
+ if (root === null)
103
+ continue;
104
+ const found = await resolvePrerequisiteAbsolutePath(root, legacyPrereq, requestId);
105
+ if (found !== null)
106
+ return found;
107
+ }
108
+ }
109
+ return null;
110
+ }
@@ -0,0 +1,15 @@
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 type { DoctorCheckPlugin } from '../types.js';
15
+ export declare const check: DoctorCheckPlugin;
@@ -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
@@ -7,6 +7,7 @@
7
7
  *
8
8
  */
9
9
  import { type ArtifactPrerequisite, type RequestType } from '../artifacts/artifact-prerequisites.js';
10
+ import { rdGatesForType } from './pipeline-verify-rd-phase.js';
10
11
  import type { RequestArtifactRole, RequestArtifactState } from '../artifacts/request-artifact-service.js';
11
12
  import type { PipelineGate } from './pipeline-verify-types.js';
12
13
  export declare function extractState(markdown: string): string;
@@ -50,7 +51,9 @@ export declare function findRequestFile(projectRoot: string, role: string, rid:
50
51
  */
51
52
  export declare function contractPrerequisite(role: RequestArtifactRole, state: RequestArtifactState, requestType: RequestType, probeName: string): ArtifactPrerequisite | null;
52
53
  export declare function contractEvidencePaths(role: RequestArtifactRole, state: RequestArtifactState, requestType: RequestType, probeName: string): string[] | null;
53
- export declare function rdGatesForType(requestType: RequestType): PipelineGate[];
54
+ /** Re-exported so existing importers keep one import path; the builder and the
55
+ * table it filters live in `pipeline-verify-rd-phase.ts`. */
56
+ export { rdGatesForType };
54
57
  /**
55
58
  * The QA phase's gate list for one type.
56
59
  *
@@ -10,6 +10,7 @@ import { existsSync, readFileSync } from 'node:fs';
10
10
  import { join } from 'node:path';
11
11
  import { getPrerequisitesFor } from '../artifacts/artifact-prerequisites.js';
12
12
  import * as qaPhase from './pipeline-verify-qa-phase.js';
13
+ import { rdEvidenceProbe, rdGatesForType } from './pipeline-verify-rd-phase.js';
13
14
  import { prerequisiteBodyViolations } from '../artifacts/prerequisite-checks.js';
14
15
  import { showRequestArtifact } from '../artifacts/request-artifact-service.js';
15
16
  import { readArtifactState } from '../artifacts/request-artifact-state-helpers.js';
@@ -111,73 +112,9 @@ function contractBodyViolations(role, state, requestType, probeName, absolutePat
111
112
  return [];
112
113
  return prerequisiteBodyViolations(prerequisite, readFileSync(absolutePath, 'utf8'));
113
114
  }
114
- export function rdGatesForType(requestType) {
115
- const gates = [
116
- {
117
- name: 'rd-request-exists',
118
- description: 'RD request artifact created',
119
- passed: false,
120
- detail: ''
121
- }
122
- ];
123
- // This slot used to pin a `tech-doc` gate to `rd/tech-doc.md`, an artifact
124
- // failed trees `peaks request transition` accepts (QA repair cycle 1). The
125
- // design / scope record the contract DOES name at `rd:qa-handoff` is
126
- // `prd/handoff.md`, so that is the gate: table-derived, like the others.
127
- // (`rd/tech-doc.md` still has two non-gate readers — final-review's evidence
128
- // budget and the resume detector. Neither is served by failing a compliant
129
- // slice.)
130
- if (contractEvidencePaths('rd', 'qa-handoff', requestType, 'prd/handoff.md') !== null) {
131
- gates.push({
132
- name: 'prd-handoff',
133
- description: 'PRD handoff capsule (approved scope + non-goals)',
134
- passed: false,
135
- detail: ''
136
- });
137
- }
138
- if (requestType === 'bugfix') {
139
- gates.push({
140
- name: 'bug-analysis',
141
- description: 'Bug root-cause analysis',
142
- passed: false,
143
- detail: ''
144
- });
145
- }
146
- if (requestType !== 'docs' && requestType !== 'chore' && requestType !== 'config') {
147
- gates.push({
148
- name: 'code-review',
149
- description: 'Code review evidence',
150
- passed: false,
151
- detail: ''
152
- });
153
- }
154
- if (requestType === 'feature' ||
155
- requestType === 'refactor' ||
156
- requestType === 'bugfix' ||
157
- requestType === 'config') {
158
- gates.push({
159
- name: 'security-review',
160
- description: 'Security review evidence',
161
- passed: false,
162
- detail: ''
163
- });
164
- }
165
- // The perf evidence the contract requires at `rd:qa-handoff` is `AUDIT_PERF`
166
- // — `audit/perf-<rid>.md`, with `audit/perf.md` and `rd/perf-baseline.md` as
167
- // side as `performance-findings`, checking `qa/performance-findings-<rid>.md`
168
- // — a path the v2.11.0 D1/D4 trim dropped. Relocating the gate (rather than
169
- // deleting it) is what keeps AC3's control meaningful: perf evidence that is
170
- // genuinely absent must still fail.
171
- if (contractEvidencePaths('rd', 'qa-handoff', requestType, 'rd/perf-baseline.md') !== null) {
172
- gates.push({
173
- name: 'perf-baseline',
174
- description: 'Performance audit evidence',
175
- passed: false,
176
- detail: ''
177
- });
178
- }
179
- return gates;
180
- }
115
+ /** Re-exported so existing importers keep one import path; the builder and the
116
+ * table it filters live in `pipeline-verify-rd-phase.ts`. */
117
+ export { rdGatesForType };
181
118
  /**
182
119
  * The QA phase's gate list for one type.
183
120
  *
@@ -207,21 +144,13 @@ export const QA_COMPLETE_STATES = new Set(['verdict-issued']);
207
144
  * gate.detail fields in place and pushes violations / nextActions. Returns the
208
145
  * updated tracker. Verbatim-move from `pipeline-verify-service.ts`. */
209
146
  export function resolveRdEvidencePaths(gates, rdEvidenceDir, projectRoot, rid, requestType, violations, nextActions, tracker) {
210
- // The path each gate is about. The contract is consulted first — see
211
- // `contractEvidencePaths`; `rdGatesForType` only builds a gate when the
212
- // contract carries its prerequisite, so this is the name the gate stands
213
- // for, not a second path table.
214
- const RD_EVIDENCE_PROBE = {
215
- 'prd-handoff': 'prd/handoff.md',
216
- 'bug-analysis': 'rd/bug-analysis.md',
217
- 'code-review': 'rd/code-review.md',
218
- 'security-review': 'rd/security-review.md',
219
- 'perf-baseline': 'rd/perf-baseline.md'
220
- };
147
+ // The path each gate is about, read off the table that declared the gate —
148
+ // not a second path table. The contract is consulted first — see
149
+ // `contractEvidencePaths`.
221
150
  let anyEvidenceResolved = tracker.anyEvidenceResolved;
222
151
  let allResolvedPathsCanonical = tracker.allResolvedPathsCanonical;
223
152
  for (const gate of gates.slice(1)) {
224
- const probeName = RD_EVIDENCE_PROBE[gate.name];
153
+ const probeName = rdEvidenceProbe(gate.name);
225
154
  const relativePaths = (contractEvidencePaths('rd', 'qa-handoff', requestType, probeName) ?? [probeName]).map((relative) => relative.replace('<rid>', rid));
226
155
  const primaryRelativePath = relativePaths[0];
227
156
  const canonicalPath = join(projectRoot, '.peaks', '_runtime', rdEvidenceDir, primaryRelativePath);