@kirill.konshin/lint 0.5.5 → 0.6.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/README.md +38 -3
- package/commands/spec-author.md +39 -0
- package/dist/configs/base.d.ts +4 -3
- package/dist/configs/base.js +61 -74
- package/dist/configs/imports.d.ts +3 -2
- package/dist/configs/imports.js +95 -146
- package/dist/configs/nx.d.ts +4 -3
- package/dist/configs/nx.js +31 -41
- package/dist/configs/prettier.d.ts +3 -2
- package/dist/configs/prettier.js +19 -16
- package/dist/configs/promise.d.ts +3 -2
- package/dist/configs/promise.js +16 -16
- package/dist/configs/react.d.ts +4 -3
- package/dist/configs/react.js +178 -217
- package/dist/configs/storybook.d.ts +4 -3
- package/dist/configs/storybook.js +22 -22
- package/dist/configs/tailwind.d.ts +4 -3
- package/dist/configs/tailwind.js +67 -91
- package/dist/configs/testing.d.ts +7 -6
- package/dist/configs/testing.js +112 -146
- package/dist/configs/turbo.d.ts +4 -3
- package/dist/configs/turbo.js +19 -27
- package/dist/configs/typescriptTypeAware.d.ts +4 -3
- package/dist/configs/typescriptTypeAware.js +99 -95
- package/dist/configs/unicorn.d.ts +3 -2
- package/dist/configs/unicorn.js +34 -41
- package/dist/exts.d.ts +2 -1
- package/dist/exts.js +10 -11
- package/dist/index.d.ts +44 -42
- package/dist/index.js +53 -85
- package/dist/lib.d.ts +21 -21
- package/dist/lib.js +261 -301
- package/dist/lintPrepare.d.ts +20 -17
- package/dist/lintPrepare.js +341 -371
- package/dist/lintStaged.d.ts +4 -3
- package/dist/lintStaged.js +25 -22
- package/dist/prettier.d.ts +4 -3
- package/dist/prettier.js +16 -17
- package/dist/restrictions.d.ts +11 -10
- package/dist/restrictions.js +18 -22
- package/dist/yarn.cjs +79 -98
- package/dist/yarn.d.cts +3 -2
- package/package.json +24 -8
- package/rules/agent.md +2 -0
- package/rules/openspec.md +1 -1
- package/skills/spec-steward/SKILL.md +3 -11
- package/skills/spec-steward/references/audit.md +18 -43
- package/skills/spec-steward/references/contract.md +4 -4
- package/skills/spec-steward/references/criteria.md +4 -4
- package/skills/spec-steward/references/review-format.md +6 -6
- package/skills/spec-steward/references/wiring.md +2 -2
- package/skills/spec-steward/references/worker.md +67 -0
- package/skills/spec-steward/scripts/lib/corpus.mjs +1 -1
- package/skills/spec-steward/scripts/lib/evidence.mjs +2 -147
- package/skills/spec-steward/scripts/lib/wire.mjs +6 -4
- package/skills/spec-steward/scripts/steward.mjs +30 -91
- package/skills/spec-steward/sweeps.json +49 -0
- package/skills/spec-tools/SKILL.md +46 -0
- package/skills/spec-tools/references/contract.md +111 -0
- package/skills/spec-tools/references/gitlab.md +122 -0
- package/skills/spec-verify/SKILL.md +153 -0
- package/spec-tools/dist/audit-DkZZulq6.mjs +130 -0
- package/spec-tools/dist/auditChanged-CNGjlake.mjs +1 -0
- package/spec-tools/dist/auditChanged-CZCvMgyZ.mjs +618 -0
- package/spec-tools/dist/auditReport-xgq4wK2i.mjs +458 -0
- package/spec-tools/dist/auditScope-CBuBtfPG.mjs +104 -0
- package/spec-tools/dist/changeGates-DdeQKfle.mjs +333 -0
- package/spec-tools/dist/changeGates-uy4Ti8rK.mjs +1 -0
- package/spec-tools/dist/ci-BUewHJS3.mjs +143 -0
- package/spec-tools/dist/ci-CFBzn8Of.mjs +1 -0
- package/spec-tools/dist/cli.mjs +93 -0
- package/spec-tools/dist/comment-szasMMg2.mjs +57 -0
- package/spec-tools/dist/files-Bppsb34B.mjs +1 -0
- package/spec-tools/dist/files-QlzY687_.mjs +38 -0
- package/spec-tools/dist/html-BMTkpbUN.mjs +1766 -0
- package/spec-tools/dist/jsonrepair-Dlm5dEen.mjs +742 -0
- package/spec-tools/dist/repo-CjIoUPYl.mjs +16 -0
- package/spec-tools/dist/repo-DUcnJw3c.mjs +1 -0
- package/spec-tools/dist/run-BElA9du3.mjs +67 -0
- package/spec-tools/dist/specDiff-8G56jMYn.mjs +123 -0
- package/spec-tools/dist/steward-DeieyOcj.mjs +34 -0
- package/spec-tools/dist/stewardAudit-BRMM0lrD.mjs +1 -0
- package/spec-tools/dist/stewardAudit-v0vOMfLN.mjs +271 -0
- package/spec-tools/dist/tier-Cn0P7juM.mjs +1 -0
- package/spec-tools/dist/tier-c3s_mA_I.mjs +65 -0
- package/spec-tools/dist/util-wnxhsnWO.mjs +49 -0
- package/spec-tools/dist/verdict-BFfN9PO8.mjs +58 -0
- package/spec-tools/dist/workers-BcIgckeq.mjs +417 -0
- package/spec-tools/dist/workflowEvidence-DyBj8EdG.mjs +1 -0
- package/spec-tools/dist/workflowEvidence-oui6ghPI.mjs +78 -0
- package/dist/configs/base.d.ts.map +0 -1
- package/dist/configs/imports.d.ts.map +0 -1
- package/dist/configs/nx.d.ts.map +0 -1
- package/dist/configs/prettier.d.ts.map +0 -1
- package/dist/configs/promise.d.ts.map +0 -1
- package/dist/configs/react.d.ts.map +0 -1
- package/dist/configs/storybook.d.ts.map +0 -1
- package/dist/configs/tailwind.d.ts.map +0 -1
- package/dist/configs/testing.d.ts.map +0 -1
- package/dist/configs/turbo.d.ts.map +0 -1
- package/dist/configs/typescriptTypeAware.d.ts.map +0 -1
- package/dist/configs/unicorn.d.ts.map +0 -1
- package/dist/exts.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib.d.ts.map +0 -1
- package/dist/lintPrepare.d.ts.map +0 -1
- package/dist/lintStaged.d.ts.map +0 -1
- package/dist/prettier.d.ts.map +0 -1
- package/dist/restrictions.d.ts.map +0 -1
- package/dist/yarn.d.cts.map +0 -1
- package/skills/spec-steward/workflows/audit.js +0 -539
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
export const meta = {
|
|
2
|
-
name: 'spec-steward-audit',
|
|
3
|
-
description:
|
|
4
|
-
'Audit OpenSpec corpora for specification quality, evidence and placement; verified findings for a review file',
|
|
5
|
-
whenToUse:
|
|
6
|
-
'A corpus-wide or affected-set specification audit whose findings become a spec-steward review file (args: roots, units, skillDir, placementGuide, context)',
|
|
7
|
-
phases: [
|
|
8
|
-
{ title: 'Understand', detail: 'architecture, enforcement and decision-history maps' },
|
|
9
|
-
{ title: 'Audit', detail: 'one auditor per part and per sweep' },
|
|
10
|
-
{ title: 'Verify', detail: 'factual lens, then judgment lens, per unit' },
|
|
11
|
-
{ title: 'Critic', detail: 'completeness critic and targeted follow-up units' },
|
|
12
|
-
{ title: 'Consolidate', detail: 'merge duplicates per area, then themes across areas' },
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/* global args, agent, parallel, pipeline, phase, log -- provided by the Workflow runtime */
|
|
17
|
-
|
|
18
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
19
|
-
// Arguments (all paths absolute):
|
|
20
|
-
// roots: [{ name, path, specsDir? }] repositories under audit
|
|
21
|
-
// skillDir: the spec-steward folder (references/*.md are read by every agent)
|
|
22
|
-
// placementGuide: rules/agent.md — where each kind of guidance belongs
|
|
23
|
-
// context: run-specific facts and owner decisions, verbatim into every prompt
|
|
24
|
-
// understand: [{ key, title, prompt }] map-makers (default: none)
|
|
25
|
-
// evidenceDir: where `steward evidence` wrote <NAME>/<capability>.md
|
|
26
|
-
// units: [{ key, title, kind: 'part'|'sweep', focus, capabilities?: ['NAME:cap'], files?: [path], effort? }]
|
|
27
|
-
// a part reads each capability's spec and evidence bundle, then its extra files
|
|
28
|
-
// allCapabilities:['NAME:cap'] for the critic's coverage table
|
|
29
|
-
// maxCriticRounds: default 2
|
|
30
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
const A = args ?? {};
|
|
33
|
-
const roots = A.roots ?? [];
|
|
34
|
-
const LAYERS = [
|
|
35
|
-
'SPEC-REQUIRED',
|
|
36
|
-
'SPEC-ADVISORY',
|
|
37
|
-
'DESIGN',
|
|
38
|
-
'AGENTS',
|
|
39
|
-
'RULE',
|
|
40
|
-
'SKILL',
|
|
41
|
-
'COMMAND',
|
|
42
|
-
'OPSX-CONFIG',
|
|
43
|
-
'README',
|
|
44
|
-
'TOOLING',
|
|
45
|
-
'TEST',
|
|
46
|
-
'CI',
|
|
47
|
-
'MERGE',
|
|
48
|
-
'REWRITE',
|
|
49
|
-
'DELETE',
|
|
50
|
-
];
|
|
51
|
-
const FINDING_PROPS = {
|
|
52
|
-
repo: { type: 'string', description: 'repository NAME as given' },
|
|
53
|
-
file: { type: 'string', description: 'repository-relative path' },
|
|
54
|
-
line: { type: 'integer', description: '1-based line of the heading or exact sentence quoted' },
|
|
55
|
-
quote: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
description: 'verbatim text from that line or the block starting there, ≤ 300 chars, … elides',
|
|
58
|
-
},
|
|
59
|
-
level: { type: 'string', enum: ['requirement', 'scenario', 'sentence', 'capability', 'file', 'section'] },
|
|
60
|
-
ruleName: { type: 'string', description: 'requirement/scenario heading, or a short label for a non-spec rule' },
|
|
61
|
-
criteria: { type: 'array', items: { type: 'integer' }, description: 'numbers from criteria.md (1–24)' },
|
|
62
|
-
layer: { type: 'string', enum: LAYERS, description: 'the owning layer proposed' },
|
|
63
|
-
whatsWrong: { type: 'string' },
|
|
64
|
-
proposed: {
|
|
65
|
-
type: 'string',
|
|
66
|
-
description: 'starts with Keep → / Reclassify → / Move → / Replace → / Merge → / Rewrite → / Delete →',
|
|
67
|
-
},
|
|
68
|
-
evidence: { type: 'array', items: { type: 'string' }, description: 'file:line references actually read' },
|
|
69
|
-
crossRefs: { type: 'array', items: { type: 'string' } },
|
|
70
|
-
themeKey: {
|
|
71
|
-
type: 'string',
|
|
72
|
-
description: 'kebab-case key of the underlying problem, from the vocabulary when one fits',
|
|
73
|
-
},
|
|
74
|
-
needsHumanIntent: { type: 'boolean' },
|
|
75
|
-
reversesPastDecision: { type: 'string', description: 'the past owner decision this would reverse, or empty' },
|
|
76
|
-
confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
|
|
77
|
-
};
|
|
78
|
-
const REQUIRED_FINDING = [
|
|
79
|
-
'repo',
|
|
80
|
-
'file',
|
|
81
|
-
'line',
|
|
82
|
-
'quote',
|
|
83
|
-
'ruleName',
|
|
84
|
-
'criteria',
|
|
85
|
-
'layer',
|
|
86
|
-
'whatsWrong',
|
|
87
|
-
'proposed',
|
|
88
|
-
'themeKey',
|
|
89
|
-
'needsHumanIntent',
|
|
90
|
-
'confidence',
|
|
91
|
-
];
|
|
92
|
-
const FINDINGS = {
|
|
93
|
-
type: 'object',
|
|
94
|
-
properties: {
|
|
95
|
-
findings: { type: 'array', items: { type: 'object', properties: FINDING_PROPS, required: REQUIRED_FINDING } },
|
|
96
|
-
sound: {
|
|
97
|
-
type: 'array',
|
|
98
|
-
items: { type: 'string' },
|
|
99
|
-
description: 'NAME:capability#requirement-slug judged correct, well-placed, adequately evidenced',
|
|
100
|
-
},
|
|
101
|
-
notes: { type: 'array', items: { type: 'string' } },
|
|
102
|
-
},
|
|
103
|
-
required: ['findings', 'sound'],
|
|
104
|
-
};
|
|
105
|
-
const VERDICTS = {
|
|
106
|
-
type: 'object',
|
|
107
|
-
properties: {
|
|
108
|
-
verdicts: {
|
|
109
|
-
type: 'array',
|
|
110
|
-
items: {
|
|
111
|
-
type: 'object',
|
|
112
|
-
properties: {
|
|
113
|
-
index: { type: 'integer' },
|
|
114
|
-
verdict: { type: 'string', enum: ['keep', 'revise', 'drop'] },
|
|
115
|
-
reason: { type: 'string' },
|
|
116
|
-
revised: { type: 'object', properties: FINDING_PROPS },
|
|
117
|
-
},
|
|
118
|
-
required: ['index', 'verdict', 'reason'],
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
required: ['verdicts'],
|
|
123
|
-
};
|
|
124
|
-
const CONSOLIDATED = {
|
|
125
|
-
type: 'object',
|
|
126
|
-
properties: {
|
|
127
|
-
findings: {
|
|
128
|
-
type: 'array',
|
|
129
|
-
items: {
|
|
130
|
-
type: 'object',
|
|
131
|
-
properties: { ...FINDING_PROPS, sourceIds: { type: 'array', items: { type: 'string' } } },
|
|
132
|
-
required: [...REQUIRED_FINDING, 'sourceIds'],
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
required: ['findings'],
|
|
137
|
-
};
|
|
138
|
-
const THEME = {
|
|
139
|
-
type: 'object',
|
|
140
|
-
properties: {
|
|
141
|
-
title: { type: 'string' },
|
|
142
|
-
whatsWrong: { type: 'string' },
|
|
143
|
-
proposed: { type: 'string' },
|
|
144
|
-
layer: { type: 'string', enum: LAYERS },
|
|
145
|
-
criteria: { type: 'array', items: { type: 'integer' } },
|
|
146
|
-
needsHumanIntent: { type: 'boolean' },
|
|
147
|
-
members: {
|
|
148
|
-
type: 'array',
|
|
149
|
-
items: {
|
|
150
|
-
type: 'object',
|
|
151
|
-
properties: { id: { type: 'string' }, note: { type: 'string' } },
|
|
152
|
-
required: ['id'],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
excluded: { type: 'array', items: { type: 'string' } },
|
|
156
|
-
},
|
|
157
|
-
required: ['title', 'whatsWrong', 'proposed', 'layer', 'criteria', 'members'],
|
|
158
|
-
};
|
|
159
|
-
const CRITIC = {
|
|
160
|
-
type: 'object',
|
|
161
|
-
properties: {
|
|
162
|
-
verdict: { type: 'string' },
|
|
163
|
-
gaps: {
|
|
164
|
-
type: 'array',
|
|
165
|
-
items: {
|
|
166
|
-
type: 'object',
|
|
167
|
-
properties: {
|
|
168
|
-
key: { type: 'string' },
|
|
169
|
-
title: { type: 'string' },
|
|
170
|
-
focus: { type: 'string' },
|
|
171
|
-
files: { type: 'array', items: { type: 'string' } },
|
|
172
|
-
},
|
|
173
|
-
required: ['key', 'title', 'focus', 'files'],
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
required: ['verdict', 'gaps'],
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const THEME_KEYS = [
|
|
181
|
-
'restating-scenario',
|
|
182
|
-
'single-scenario-padding',
|
|
183
|
-
'bdd-verbosity',
|
|
184
|
-
'impl-detail-in-spec',
|
|
185
|
-
'coding-convention-in-spec',
|
|
186
|
-
'process-rule-in-spec',
|
|
187
|
-
'agent-steering-as-spec',
|
|
188
|
-
'tooling-should-enforce',
|
|
189
|
-
'textual-test',
|
|
190
|
-
'comment-as-evidence',
|
|
191
|
-
'citation-upkeep',
|
|
192
|
-
'unverifiable-absolute',
|
|
193
|
-
'vague-obligation',
|
|
194
|
-
'advisory-not-required',
|
|
195
|
-
'duplicate-rule',
|
|
196
|
-
'cross-repo-drift',
|
|
197
|
-
'contradiction',
|
|
198
|
-
'stale-rule',
|
|
199
|
-
'scope-unclear',
|
|
200
|
-
'repo-wide-reasoning',
|
|
201
|
-
'placement-duplication',
|
|
202
|
-
'agents-md-bloat',
|
|
203
|
-
'ci-cost',
|
|
204
|
-
'missing-invariant',
|
|
205
|
-
'gap-marker',
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
const rootList = roots.map((r) => `- ${r.name} → ${r.path}`).join('\n');
|
|
209
|
-
const READ_FIRST = [
|
|
210
|
-
`${A.skillDir}/references/model.md`,
|
|
211
|
-
`${A.skillDir}/references/criteria.md`,
|
|
212
|
-
A.placementGuide,
|
|
213
|
-
].filter(Boolean);
|
|
214
|
-
|
|
215
|
-
const COMMON = `You are part of a specification audit. READ-ONLY: never create, edit or delete a file, never run a command that changes anything (no installs, builds, formatters, git writes). Read, Grep, Glob and read-only shell (git show/log/diff, ls, cat, rg) only.
|
|
216
|
-
|
|
217
|
-
Repositories under audit (NAME → absolute path; paths in findings are repository-relative):
|
|
218
|
-
${rootList}
|
|
219
|
-
|
|
220
|
-
Read these first, in full — they are the standard you judge by:
|
|
221
|
-
${READ_FIRST.map((p) => `- ${p}`).join('\n')}
|
|
222
|
-
|
|
223
|
-
Non-negotiables:
|
|
224
|
-
- Specification quality first. Ordinary implementation bugs are out of scope unless they reveal the rule is unrealistic, unclear, outdated, ambiguous, or contradicted by what the tests actually assert.
|
|
225
|
-
- Comments, descriptions, prompt text and citations are never evidence that code complies, and never a violation by themselves. Judge executable behaviour and structure.
|
|
226
|
-
- For every rule you would keep REQUIRED, ask what meaningful failure its verification catches. Never propose a test merely because a rule lacks one; never propose a test of incidental text or structure.
|
|
227
|
-
- Internal component and API contracts are legitimate specification. The line is contract versus implementation/process, not product versus engineering.
|
|
228
|
-
- Do not decide intent silently: when the intended meaning is ambiguous, describe the readings, propose options, set needsHumanIntent.
|
|
229
|
-
- No style preferences: every finding states a concrete problem.
|
|
230
|
-
- A proposal that reverses an earlier owner decision says so (reversesPastDecision).
|
|
231
|
-
- Quote the ORIGINAL text verbatim; the line must be where that text is. Open the file to confirm before writing it.
|
|
232
|
-
|
|
233
|
-
Theme keys (use one when it fits; coin a new kebab-case key only when none does): ${THEME_KEYS.join(', ')}.
|
|
234
|
-
|
|
235
|
-
Run context — facts established and decisions the owner has already made:
|
|
236
|
-
${A.context ?? '(none)'}`;
|
|
237
|
-
|
|
238
|
-
const asJson = (x) => JSON.stringify(x, null, 1);
|
|
239
|
-
const filesOf = (u) => [
|
|
240
|
-
...(u.capabilities ?? []).flatMap((c) => {
|
|
241
|
-
const [name, cap] = c.split(':');
|
|
242
|
-
const root = roots.find((r) => r.name === name);
|
|
243
|
-
const spec = `${root?.path}/${root?.specsDir ?? 'openspec/specs'}/${cap}/spec.md`;
|
|
244
|
-
return A.evidenceDir ? [spec, `${A.evidenceDir}/${name}/${cap}.md`] : [spec];
|
|
245
|
-
}),
|
|
246
|
-
...(u.files ?? []),
|
|
247
|
-
];
|
|
248
|
-
const ids = (n) => `F${n}`;
|
|
249
|
-
let counter = 0;
|
|
250
|
-
const tag = (unit, list) =>
|
|
251
|
-
(list ?? []).map((f) => ({
|
|
252
|
-
...f,
|
|
253
|
-
id: ids(++counter),
|
|
254
|
-
unit: unit.key,
|
|
255
|
-
crossRefs: f.crossRefs ?? [],
|
|
256
|
-
evidence: f.evidence ?? [],
|
|
257
|
-
}));
|
|
258
|
-
|
|
259
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
260
|
-
phase('Understand');
|
|
261
|
-
const maps = await parallel(
|
|
262
|
-
(A.understand ?? []).map(
|
|
263
|
-
(u) => () =>
|
|
264
|
-
agent(
|
|
265
|
-
`${COMMON}\n\n# Your task: ${u.title}\n\n${u.prompt}\n\nReturn the map as concise markdown (≤ 2500 words), with file:line references for every claim.`,
|
|
266
|
-
{
|
|
267
|
-
label: `map:${u.key}`,
|
|
268
|
-
phase: 'Understand',
|
|
269
|
-
effort: 'high',
|
|
270
|
-
},
|
|
271
|
-
),
|
|
272
|
-
),
|
|
273
|
-
);
|
|
274
|
-
const MAPS = (A.understand ?? [])
|
|
275
|
-
.map((u, i) => `## Map — ${u.title}\n\n${maps[i] ?? '(this map is unavailable — read the sources yourself)'}`)
|
|
276
|
-
.join('\n\n');
|
|
277
|
-
log(`maps ready: ${maps.filter(Boolean).length}/${(A.understand ?? []).length}`);
|
|
278
|
-
|
|
279
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
280
|
-
const auditPrompt = (u) => `${COMMON}
|
|
281
|
-
|
|
282
|
-
${MAPS}
|
|
283
|
-
|
|
284
|
-
# Your unit: ${u.title} (${u.kind})
|
|
285
|
-
|
|
286
|
-
${u.focus}
|
|
287
|
-
|
|
288
|
-
Read IN FULL (spec files first; then evidence bundles, which quote each requirement with line numbers, the tests citing it, code citations, where its terms occur, and related requirements in other capabilities and repositories):
|
|
289
|
-
${filesOf(u)
|
|
290
|
-
.map((f) => `- ${f}`)
|
|
291
|
-
.join('\n')}
|
|
292
|
-
|
|
293
|
-
Then trace into code and tests wherever a verdict depends on them — open the source, do not guess.
|
|
294
|
-
|
|
295
|
-
Output:
|
|
296
|
-
- One finding per (rule, problem). A rule may be a requirement, a scenario, a sentence, or — outside the specs — a section or line of AGENTS.md, a skill, a config, a script, a CI job.
|
|
297
|
-
- criteria: numbers from criteria.md. layer: the owning layer you propose. proposed: begins with the target notation and says exactly what to do; a rewrite gives the new text; a move names the target file or glob.
|
|
298
|
-
- sound: ${u.kind === 'part' ? 'EVERY requirement of your capabilities that you judged correct, well-placed and adequately evidenced, as NAME:capability#requirement-slug. Every requirement of your unit must appear either in a finding (on it or one of its scenarios) or in sound.' : 'leave empty unless you judged specific requirements sound.'}
|
|
299
|
-
- Be aggressive about questionable specification design and conservative about deciding intent.`;
|
|
300
|
-
|
|
301
|
-
const factualPrompt = (u, res) => `${COMMON}
|
|
302
|
-
|
|
303
|
-
# Verify FACTS of these findings (unit: ${u.title})
|
|
304
|
-
|
|
305
|
-
For each finding, by index: open the file at the line. Is the quote verbatim there (or within the block that starts there)? Are the evidence references real, and do they say what the finding claims? Is every claim about code, tests, tooling or CI true — open them.
|
|
306
|
-
- keep: all true.
|
|
307
|
-
- revise: correct the line, quote, file or a factual claim — return only the corrected fields in revised.
|
|
308
|
-
- drop: a central claim is false and cannot be repaired.
|
|
309
|
-
Be strict; a finding built on a misreading is revised or dropped.
|
|
310
|
-
|
|
311
|
-
Findings:
|
|
312
|
-
${asJson(res.findings.map((f, index) => ({ index, ...f, id: undefined, unit: undefined })))}`;
|
|
313
|
-
|
|
314
|
-
const judgePrompt = (u, res) => `${COMMON}
|
|
315
|
-
|
|
316
|
-
${MAPS}
|
|
317
|
-
|
|
318
|
-
# Judge these findings as the skeptic (unit: ${u.title})
|
|
319
|
-
|
|
320
|
-
For each finding, by index:
|
|
321
|
-
- It silently decides intent that is genuinely ambiguous → revise: needsHumanIntent true, options in proposed.
|
|
322
|
-
- It is a style preference, an ordinary implementation bug, or speculation → drop.
|
|
323
|
-
- Its proposed verification would not catch a real failure (compliance theatre) → revise or drop.
|
|
324
|
-
- It moves an internal contract out of the spec only because it is not user-facing → revise.
|
|
325
|
-
- The target layer contradicts the placement guide → revise.
|
|
326
|
-
- It reverses a past owner decision without saying so → revise reversesPastDecision.
|
|
327
|
-
- It duplicates another finding in this list → drop the weaker, say which in reason.
|
|
328
|
-
Default to keep when the finding is concrete, grounded and its proposal is sound. Sharpen wording where it helps the owner decide quickly.
|
|
329
|
-
|
|
330
|
-
Findings:
|
|
331
|
-
${asJson(res.findings.map((f, index) => ({ index, ...f, id: undefined, unit: undefined })))}`;
|
|
332
|
-
|
|
333
|
-
const applyVerdicts = (res, v, lens) => {
|
|
334
|
-
if (!v) return res;
|
|
335
|
-
const dropped = [...(res.dropped ?? [])];
|
|
336
|
-
const findings = [];
|
|
337
|
-
res.findings.forEach((f, i) => {
|
|
338
|
-
const verdict = (v.verdicts ?? []).find((x) => x.index === i);
|
|
339
|
-
if (verdict?.verdict === 'drop') dropped.push({ ...f, droppedBy: lens, reason: verdict.reason });
|
|
340
|
-
else if (verdict?.verdict === 'revise')
|
|
341
|
-
findings.push({
|
|
342
|
-
...f,
|
|
343
|
-
...(verdict.revised ?? {}),
|
|
344
|
-
id: f.id,
|
|
345
|
-
unit: f.unit,
|
|
346
|
-
revisedBy: [...(f.revisedBy ?? []), lens],
|
|
347
|
-
});
|
|
348
|
-
else findings.push(f);
|
|
349
|
-
});
|
|
350
|
-
return { ...res, findings, dropped };
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
const runUnits = (units) =>
|
|
354
|
-
pipeline(
|
|
355
|
-
units,
|
|
356
|
-
(u) =>
|
|
357
|
-
agent(auditPrompt(u), {
|
|
358
|
-
label: `audit:${u.key}`,
|
|
359
|
-
phase: 'Audit',
|
|
360
|
-
schema: FINDINGS,
|
|
361
|
-
effort: u.effort ?? 'high',
|
|
362
|
-
}).then((r) =>
|
|
363
|
-
r
|
|
364
|
-
? {
|
|
365
|
-
unit: u.key,
|
|
366
|
-
findings: tag(u, r.findings),
|
|
367
|
-
sound: r.sound ?? [],
|
|
368
|
-
notes: r.notes ?? [],
|
|
369
|
-
dropped: [],
|
|
370
|
-
}
|
|
371
|
-
: null,
|
|
372
|
-
),
|
|
373
|
-
(res, u) =>
|
|
374
|
-
res && res.findings.length
|
|
375
|
-
? agent(factualPrompt(u, res), {
|
|
376
|
-
label: `facts:${u.key}`,
|
|
377
|
-
phase: 'Verify',
|
|
378
|
-
schema: VERDICTS,
|
|
379
|
-
effort: 'medium',
|
|
380
|
-
}).then((v) => applyVerdicts(res, v, 'facts'))
|
|
381
|
-
: res,
|
|
382
|
-
(res, u) =>
|
|
383
|
-
res && res.findings.length
|
|
384
|
-
? agent(judgePrompt(u, res), {
|
|
385
|
-
label: `judge:${u.key}`,
|
|
386
|
-
phase: 'Verify',
|
|
387
|
-
schema: VERDICTS,
|
|
388
|
-
effort: 'high',
|
|
389
|
-
}).then((v) => applyVerdicts(res, v, 'judgment'))
|
|
390
|
-
: res,
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
phase('Audit');
|
|
394
|
-
const results = (await runUnits(A.units ?? [])).filter(Boolean);
|
|
395
|
-
log(
|
|
396
|
-
`audited ${results.length}/${(A.units ?? []).length} units: ${results.reduce((n, r) => n + r.findings.length, 0)} findings kept, ${results.reduce((n, r) => n + r.dropped.length, 0)} dropped`,
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
400
|
-
phase('Critic');
|
|
401
|
-
const criticReports = [];
|
|
402
|
-
const capOf = (f) => {
|
|
403
|
-
const root = roots.find((r) => r.name === f.repo);
|
|
404
|
-
const specs = (root?.specsDir ?? 'openspec/specs') + '/';
|
|
405
|
-
return f.file?.startsWith(specs) && f.file.endsWith('/spec.md')
|
|
406
|
-
? `${f.repo}:${f.file.slice(specs.length, -'/spec.md'.length)}`
|
|
407
|
-
: null;
|
|
408
|
-
};
|
|
409
|
-
for (let round = 1; round <= (A.maxCriticRounds ?? 2); round++) {
|
|
410
|
-
const all = results.flatMap((r) => r.findings);
|
|
411
|
-
const perCap = (A.allCapabilities ?? [...new Set((A.units ?? []).flatMap((u) => u.capabilities ?? []))]).map(
|
|
412
|
-
(c) => {
|
|
413
|
-
const n = all.filter((f) => capOf(f) === c).length;
|
|
414
|
-
const sound = results.flatMap((r) => r.sound).filter((s) => s.startsWith(`${c}#`)).length;
|
|
415
|
-
return `${c}: ${n} findings, ${sound} sound`;
|
|
416
|
-
},
|
|
417
|
-
);
|
|
418
|
-
const perCriterion = Array.from(
|
|
419
|
-
{ length: 24 },
|
|
420
|
-
(_, i) => `${i + 1}: ${all.filter((f) => (f.criteria ?? []).includes(i + 1)).length}`,
|
|
421
|
-
);
|
|
422
|
-
const unitsRun = (A.units ?? []).concat(criticReports.flatMap((c) => c.gaps)).map((u) => `${u.key} — ${u.title}`);
|
|
423
|
-
const critic = await agent(
|
|
424
|
-
`${COMMON}
|
|
425
|
-
|
|
426
|
-
# Completeness critic — round ${round}
|
|
427
|
-
|
|
428
|
-
The audit so far. What is missing: a capability with no findings and no sound list, a criterion that yielded nothing though the corpus plainly has cases, a modality not run, a source unread, a pair of shared capabilities not compared, a sweep that was too shallow? Read the sources yourself to decide; propose at most 6 targeted follow-up units (key, title, focus — exactly what to examine and why —, files to read in full). Return no gaps when coverage is genuinely complete; do not invent work.
|
|
429
|
-
|
|
430
|
-
Units run:
|
|
431
|
-
${unitsRun.join('\n')}
|
|
432
|
-
|
|
433
|
-
Per capability:
|
|
434
|
-
${perCap.join('\n')}
|
|
435
|
-
|
|
436
|
-
Per criterion (findings citing it):
|
|
437
|
-
${perCriterion.join(', ')}
|
|
438
|
-
|
|
439
|
-
Notes from auditors:
|
|
440
|
-
${results
|
|
441
|
-
.flatMap((r) => r.notes.map((n) => `- [${r.unit}] ${n}`))
|
|
442
|
-
.join('\n')
|
|
443
|
-
.slice(0, 12000)}`,
|
|
444
|
-
{ label: `critic:${round}`, phase: 'Critic', schema: CRITIC, effort: 'high' },
|
|
445
|
-
);
|
|
446
|
-
if (!critic) break;
|
|
447
|
-
criticReports.push({ round, verdict: critic.verdict, gaps: critic.gaps });
|
|
448
|
-
log(`critic round ${round}: ${critic.gaps.length} gap(s) — ${critic.verdict.slice(0, 200)}`);
|
|
449
|
-
if (!critic.gaps.length) break;
|
|
450
|
-
const extra = (
|
|
451
|
-
await runUnits(critic.gaps.map((g) => ({ ...g, key: `critic${round}-${g.key}`, kind: 'sweep' })))
|
|
452
|
-
).filter(Boolean);
|
|
453
|
-
results.push(...extra);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
457
|
-
phase('Consolidate');
|
|
458
|
-
const unitByCap = new Map();
|
|
459
|
-
for (const u of A.units ?? []) for (const c of u.capabilities ?? []) unitByCap.set(c, u.key);
|
|
460
|
-
const areaOf = (f) => unitByCap.get(capOf(f)) ?? f.unit;
|
|
461
|
-
const areas = new Map();
|
|
462
|
-
for (const f of results.flatMap((r) => r.findings)) {
|
|
463
|
-
const a = areaOf(f);
|
|
464
|
-
areas.set(a, [...(areas.get(a) ?? []), f]);
|
|
465
|
-
}
|
|
466
|
-
const titleOf = (key) => (A.units ?? []).find((u) => u.key === key)?.title ?? key;
|
|
467
|
-
|
|
468
|
-
const consolidated = (
|
|
469
|
-
await parallel(
|
|
470
|
-
[...areas.entries()].map(
|
|
471
|
-
([area, list]) =>
|
|
472
|
-
() =>
|
|
473
|
-
list.length < 2
|
|
474
|
-
? Promise.resolve(list.map((f) => ({ ...f, area, sourceIds: [f.id] })))
|
|
475
|
-
: agent(
|
|
476
|
-
`${COMMON}
|
|
477
|
-
|
|
478
|
-
# Consolidate the findings of one area: ${titleOf(area)}
|
|
479
|
-
|
|
480
|
-
Several auditors and sweeps produced these findings. Merge duplicates — the same rule with the same problem becomes ONE finding listing every merged id in sourceIds; the same rule with different problems stays separate, each cross-referencing the other. Keep file, line and quote EXACTLY as in one of the sources (copy, never paraphrase). Write the merged whatsWrong and proposed so the owner can decide in one read; keep the strongest evidence; unify themeKeys for the same underlying problem. Drop nothing that is not a duplicate. Every input id must appear in exactly one output's sourceIds.
|
|
481
|
-
|
|
482
|
-
Findings:
|
|
483
|
-
${asJson(list.map((f) => ({ ...f, unit: undefined, revisedBy: undefined })))}`,
|
|
484
|
-
{ label: `merge:${area}`, phase: 'Consolidate', schema: CONSOLIDATED, effort: 'high' },
|
|
485
|
-
).then((r) =>
|
|
486
|
-
r
|
|
487
|
-
? r.findings.map((f) => ({ ...f, area }))
|
|
488
|
-
: list.map((f) => ({ ...f, area, sourceIds: [f.id] })),
|
|
489
|
-
),
|
|
490
|
-
),
|
|
491
|
-
)
|
|
492
|
-
)
|
|
493
|
-
.filter(Boolean)
|
|
494
|
-
.flat()
|
|
495
|
-
.map((f, i) => ({ ...f, cid: `C${i + 1}` }));
|
|
496
|
-
|
|
497
|
-
const byTheme = new Map();
|
|
498
|
-
for (const f of consolidated) byTheme.set(f.themeKey, [...(byTheme.get(f.themeKey) ?? []), f]);
|
|
499
|
-
const themeCandidates = [...byTheme.entries()].filter(([, list]) => list.length >= 3);
|
|
500
|
-
const themes = (
|
|
501
|
-
await parallel(
|
|
502
|
-
themeCandidates.map(
|
|
503
|
-
([key, list]) =>
|
|
504
|
-
() =>
|
|
505
|
-
agent(
|
|
506
|
-
`${COMMON}
|
|
507
|
-
|
|
508
|
-
# Form a theme: ${key}
|
|
509
|
-
|
|
510
|
-
These findings were tagged with the same underlying problem. Decide which truly share ONE problem and ONE consolidated solution, and write that theme so the owner can give a single verdict: a title, what is wrong, the proposed solution (target notation), the layer, the criteria, and the members (by cid) each with a short member-specific note when the member differs from the rest. Exclude (by cid) any finding that does not fit; it stays a single item.
|
|
511
|
-
|
|
512
|
-
Findings:
|
|
513
|
-
${asJson(list.map((f) => ({ cid: f.cid, repo: f.repo, file: f.file, line: f.line, quote: f.quote, ruleName: f.ruleName, whatsWrong: f.whatsWrong, proposed: f.proposed, layer: f.layer, criteria: f.criteria })))}`,
|
|
514
|
-
{ label: `theme:${key}`, phase: 'Consolidate', schema: THEME, effort: 'high' },
|
|
515
|
-
).then((t) => (t ? { key, ...t } : null)),
|
|
516
|
-
),
|
|
517
|
-
)
|
|
518
|
-
).filter(Boolean);
|
|
519
|
-
|
|
520
|
-
const themed = new Set(themes.flatMap((t) => t.members.map((m) => m.id)));
|
|
521
|
-
return {
|
|
522
|
-
maps: Object.fromEntries((A.understand ?? []).map((u, i) => [u.key, maps[i] ?? null])),
|
|
523
|
-
themes: themes.map((t) => ({
|
|
524
|
-
...t,
|
|
525
|
-
members: t.members
|
|
526
|
-
.map((m) => ({ ...consolidated.find((f) => f.cid === m.id), note: m.note ?? '' }))
|
|
527
|
-
.filter((m) => m.cid),
|
|
528
|
-
})),
|
|
529
|
-
findings: consolidated.filter((f) => !themed.has(f.cid)),
|
|
530
|
-
sound: [...new Set(results.flatMap((r) => r.sound))].sort(),
|
|
531
|
-
dropped: results.flatMap((r) => r.dropped),
|
|
532
|
-
critic: criticReports,
|
|
533
|
-
stats: {
|
|
534
|
-
units: results.length,
|
|
535
|
-
kept: consolidated.length,
|
|
536
|
-
themes: themes.length,
|
|
537
|
-
dropped: results.reduce((n, r) => n + r.dropped.length, 0),
|
|
538
|
-
},
|
|
539
|
-
};
|