speccle 0.12.0 → 0.15.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 +280 -2
- package/dist/calibration.js +156 -0
- package/dist/changeset.js +141 -0
- package/dist/cli.js +486 -9
- package/dist/config.js +13 -10
- package/dist/doctor.js +19 -5
- package/dist/lenses.js +68 -0
- package/dist/remedy.js +133 -0
- package/dist/render.js +225 -10
- package/dist/reviewinit.js +139 -0
- package/dist/reviewrun.js +516 -0
- package/dist/risk.js +228 -0
- package/dist/update.js +15 -6
- package/dist/verify.js +92 -0
- package/lenses/accessibility.md +39 -0
- package/lenses/architecture.md +38 -0
- package/lenses/correctness.md +36 -0
- package/lenses/house-conventions.md +37 -0
- package/lenses/performance.md +40 -0
- package/lenses/risk.md +45 -0
- package/lenses/security.md +42 -0
- package/lenses/test-quality.md +39 -0
- package/package.json +5 -4
- package/skills/review/SKILL.md +190 -0
package/dist/cli.js
CHANGED
|
@@ -1,31 +1,82 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { calibrationReport, recordCalibration } from "./calibration.js";
|
|
2
3
|
import { check } from "./check.js";
|
|
3
4
|
import { claims } from "./claims.js";
|
|
4
5
|
import { initConfig } from "./config.js";
|
|
5
6
|
import { DEFAULT_DIALECT, DIALECT_NAMES } from "./dialects.js";
|
|
6
7
|
import { doctor } from "./doctor.js";
|
|
7
8
|
import { init, ownVersion } from "./init.js";
|
|
9
|
+
import { materializeLenses } from "./lenses.js";
|
|
8
10
|
import { lint } from "./lint.js";
|
|
9
|
-
import {
|
|
11
|
+
import { recallRemedy, recordRemedy, REMEDY_ROUTES } from "./remedy.js";
|
|
12
|
+
import { renderCalibrateRecord, renderCalibrateReport, renderCheck, renderClaims, renderConfigInit, renderDoctor, renderHuman, renderInit, renderLensesInit, renderRemedyRecall, renderRemedyRecord, renderReviewInit, renderReviewRun, renderRisk, renderSkillsInit, renderStrength, renderUpdate, renderVerify, } from "./render.js";
|
|
13
|
+
import { scaffoldReviewWorkflow } from "./reviewinit.js";
|
|
14
|
+
import { reviewRun } from "./reviewrun.js";
|
|
15
|
+
import { risk } from "./risk.js";
|
|
10
16
|
import { materializeSkills } from "./skills.js";
|
|
11
17
|
import { DEFAULT_COVERAGE_SUMMARY, DEFAULT_MUTATION_REPORT, strength } from "./strength.js";
|
|
12
18
|
import { update } from "./update.js";
|
|
19
|
+
import { verify } from "./verify.js";
|
|
13
20
|
const USAGE = `Usage: speccle <command> [options]
|
|
14
21
|
|
|
15
22
|
Commands:
|
|
16
|
-
init [path] [--json] Record repo facts in .speccle/config.json
|
|
17
|
-
|
|
18
|
-
doctor [path] [--json] Report staleness across the CLI, skills, and strength stack
|
|
19
|
-
update [path] [--json] Refresh the skills as a diff; report
|
|
23
|
+
init [path] [--json] Record repo facts in .speccle/config.json, materialize the
|
|
24
|
+
skills into .claude/skills/ and the lenses into .speccle/lenses/
|
|
25
|
+
doctor [path] [--json] Report staleness across the CLI, skills, lenses, and strength stack
|
|
26
|
+
update [path] [--json] Refresh the skills and lenses as a diff; report stack and binary fixes
|
|
20
27
|
lint [path] [--json] Lint every SPEC.md under path (default: current directory)
|
|
21
28
|
claims [path] [--json] Join criteria to the test names that claim them — no reports needed
|
|
29
|
+
verify [path] [--json] Run .speccle/checks/ against the change set: cross-file invariants
|
|
30
|
+
risk [path] [--json] Score the change set from spec-aware signals; gate on the review threshold
|
|
31
|
+
calibrate record [path] Append a calibration entry: the risk floor + your honest verdict
|
|
32
|
+
calibrate report [path] Read the calibration record: signal reliability + the supported threshold
|
|
33
|
+
remedy record [path] Record a remedy: the finding, the fix, and the prevention artefact
|
|
34
|
+
remedy recall [path] Recall the known remedy for a finding's class — fix consistently
|
|
35
|
+
review init [path] [--json] Scaffold the opt-in CI driver: a GitHub Actions workflow, pinned
|
|
36
|
+
review run [path] Review a pull request with the lens panel and post one review.
|
|
37
|
+
The one command here that calls a model — needs a metered key
|
|
22
38
|
strength [path] [--json] Oracle-strength heatmap: per-criterion killed ÷ covered
|
|
23
39
|
strength init [path] [--json] Provision the strength stack: devDependencies + configs
|
|
24
40
|
--version, -v Print the installed CLI version
|
|
25
41
|
|
|
26
|
-
claims options:
|
|
42
|
+
claims / risk options:
|
|
27
43
|
--dialect <name> Test dialect: ${DIALECT_NAMES.join(", ")} (default: ${DEFAULT_DIALECT})
|
|
28
44
|
|
|
45
|
+
verify / risk options:
|
|
46
|
+
--base <ref> Read the change set from the commits between <ref> and HEAD, instead of the
|
|
47
|
+
working tree's pending change — what a CI driver needs, where the tree is
|
|
48
|
+
clean. Measured from the merge base, so it needs their shared history
|
|
49
|
+
|
|
50
|
+
risk exit codes: 0 below the review threshold (review may fix), 1 at or above it (human required)
|
|
51
|
+
|
|
52
|
+
calibrate record options:
|
|
53
|
+
--needed-human <true|false> Did this change actually need a human? (required — the honest verdict)
|
|
54
|
+
--found-real <true|false> Did the review find something real? (required)
|
|
55
|
+
--escalated A risk lens escalated beyond the deterministic floor
|
|
56
|
+
--note <text> Free-text context for the entry
|
|
57
|
+
--dialect <name> Test dialect: ${DIALECT_NAMES.join(", ")} (default: ${DEFAULT_DIALECT})
|
|
58
|
+
|
|
59
|
+
remedy record options:
|
|
60
|
+
--class <handle> Short, stable handle for the finding's class (required — the recall key)
|
|
61
|
+
--finding <text> What the finding is (required)
|
|
62
|
+
--fix <text> The fix applied to the code (required)
|
|
63
|
+
--route <route> Prevention route: ${REMEDY_ROUTES.join(", ")} (required)
|
|
64
|
+
--artefact <ref> The prevention artefact: a .speccle/checks|lenses path or a SPEC
|
|
65
|
+
criterion id (required for every route but none)
|
|
66
|
+
--note <text> Free-text context for the entry
|
|
67
|
+
|
|
68
|
+
remedy recall options:
|
|
69
|
+
--class <handle> The finding's class to look up (required)
|
|
70
|
+
|
|
71
|
+
review run options:
|
|
72
|
+
--pr <number> The pull request to review (required)
|
|
73
|
+
--repo <owner/name> Defaults to GITHUB_REPOSITORY
|
|
74
|
+
--base <ref> Base ref for the risk verdict (default: origin/<the PR's base>)
|
|
75
|
+
--force Review again even if this driver already reviewed the PR
|
|
76
|
+
--model <id> Overrides SPECCLE_REVIEW_MODEL
|
|
77
|
+
--dry-run Report what would be posted, and post nothing
|
|
78
|
+
Reads ANTHROPIC_API_KEY and GITHUB_TOKEN from the environment
|
|
79
|
+
|
|
29
80
|
strength options:
|
|
30
81
|
--check Report whether the reports are fresh, stale, or missing — never runs them
|
|
31
82
|
--mutation <file> Stryker JSON report (default: ${DEFAULT_MUTATION_REPORT})
|
|
@@ -53,6 +104,34 @@ async function main(argv) {
|
|
|
53
104
|
return runLint(rest);
|
|
54
105
|
if (command === "claims")
|
|
55
106
|
return runClaims(rest);
|
|
107
|
+
if (command === "verify")
|
|
108
|
+
return runVerify(rest);
|
|
109
|
+
if (command === "risk")
|
|
110
|
+
return runRisk(rest);
|
|
111
|
+
if (command === "calibrate" && rest[0] === "record")
|
|
112
|
+
return runCalibrateRecord(rest.slice(1));
|
|
113
|
+
if (command === "calibrate" && rest[0] === "report")
|
|
114
|
+
return runCalibrateReport(rest.slice(1));
|
|
115
|
+
if (command === "calibrate") {
|
|
116
|
+
console.error(`calibrate needs a subcommand: record or report\n\n${USAGE}`);
|
|
117
|
+
return 2;
|
|
118
|
+
}
|
|
119
|
+
if (command === "remedy" && rest[0] === "record")
|
|
120
|
+
return runRemedyRecord(rest.slice(1));
|
|
121
|
+
if (command === "remedy" && rest[0] === "recall")
|
|
122
|
+
return runRemedyRecall(rest.slice(1));
|
|
123
|
+
if (command === "remedy") {
|
|
124
|
+
console.error(`remedy needs a subcommand: record or recall\n\n${USAGE}`);
|
|
125
|
+
return 2;
|
|
126
|
+
}
|
|
127
|
+
if (command === "review" && rest[0] === "init")
|
|
128
|
+
return runReviewInit(rest.slice(1));
|
|
129
|
+
if (command === "review" && rest[0] === "run")
|
|
130
|
+
return runReviewRun(rest.slice(1));
|
|
131
|
+
if (command === "review") {
|
|
132
|
+
console.error(`review needs a subcommand: init or run\n\n${USAGE}`);
|
|
133
|
+
return 2;
|
|
134
|
+
}
|
|
56
135
|
if (command === "strength" && rest[0] === "init")
|
|
57
136
|
return runStrengthInit(rest.slice(1));
|
|
58
137
|
if (command === "strength")
|
|
@@ -98,6 +177,300 @@ async function runClaims(args) {
|
|
|
98
177
|
console.log(json ? JSON.stringify(report, null, 2) : renderClaims(report));
|
|
99
178
|
return report.clean ? 0 : 1;
|
|
100
179
|
}
|
|
180
|
+
async function runVerify(args) {
|
|
181
|
+
let json = false;
|
|
182
|
+
let base;
|
|
183
|
+
const positional = [];
|
|
184
|
+
for (let i = 0; i < args.length; i++) {
|
|
185
|
+
const arg = args[i];
|
|
186
|
+
if (arg === "--json")
|
|
187
|
+
json = true;
|
|
188
|
+
else if (arg === "--base") {
|
|
189
|
+
const value = args[++i];
|
|
190
|
+
if (value === undefined) {
|
|
191
|
+
console.error(`--base needs a git ref\n\n${USAGE}`);
|
|
192
|
+
return 2;
|
|
193
|
+
}
|
|
194
|
+
base = value;
|
|
195
|
+
}
|
|
196
|
+
else if (arg.startsWith("-")) {
|
|
197
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
198
|
+
return 2;
|
|
199
|
+
}
|
|
200
|
+
else
|
|
201
|
+
positional.push(arg);
|
|
202
|
+
}
|
|
203
|
+
if (positional.length > 1) {
|
|
204
|
+
console.error(`verify takes at most one path\n\n${USAGE}`);
|
|
205
|
+
return 2;
|
|
206
|
+
}
|
|
207
|
+
let report;
|
|
208
|
+
try {
|
|
209
|
+
report = await verify(positional[0] ?? ".", { ...(base !== undefined && { base }) });
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
console.error(message(err));
|
|
213
|
+
return 2;
|
|
214
|
+
}
|
|
215
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderVerify(report));
|
|
216
|
+
return report.clean ? 0 : 1;
|
|
217
|
+
}
|
|
218
|
+
async function runRisk(args) {
|
|
219
|
+
let json = false;
|
|
220
|
+
let dialect;
|
|
221
|
+
let base;
|
|
222
|
+
const positional = [];
|
|
223
|
+
for (let i = 0; i < args.length; i++) {
|
|
224
|
+
const arg = args[i];
|
|
225
|
+
if (arg === "--json")
|
|
226
|
+
json = true;
|
|
227
|
+
else if (arg === "--dialect" || arg === "--base") {
|
|
228
|
+
const value = args[++i];
|
|
229
|
+
if (value === undefined) {
|
|
230
|
+
console.error(`${arg} needs ${arg === "--base" ? "a git ref" : "a dialect name"}\n\n${USAGE}`);
|
|
231
|
+
return 2;
|
|
232
|
+
}
|
|
233
|
+
if (arg === "--dialect")
|
|
234
|
+
dialect = value;
|
|
235
|
+
else
|
|
236
|
+
base = value;
|
|
237
|
+
}
|
|
238
|
+
else if (arg.startsWith("-")) {
|
|
239
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
240
|
+
return 2;
|
|
241
|
+
}
|
|
242
|
+
else
|
|
243
|
+
positional.push(arg);
|
|
244
|
+
}
|
|
245
|
+
if (positional.length > 1) {
|
|
246
|
+
console.error(`risk takes at most one path\n\n${USAGE}`);
|
|
247
|
+
return 2;
|
|
248
|
+
}
|
|
249
|
+
let report;
|
|
250
|
+
try {
|
|
251
|
+
report = await risk(positional[0] ?? ".", {
|
|
252
|
+
...(dialect !== undefined && { dialect }),
|
|
253
|
+
...(base !== undefined && { base }),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
console.error(message(err));
|
|
258
|
+
return 2;
|
|
259
|
+
}
|
|
260
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderRisk(report));
|
|
261
|
+
return report.humanRequired ? 1 : 0;
|
|
262
|
+
}
|
|
263
|
+
async function runCalibrateRecord(args) {
|
|
264
|
+
let json = false;
|
|
265
|
+
let dialect;
|
|
266
|
+
let neededHuman;
|
|
267
|
+
let foundReal;
|
|
268
|
+
let escalated = false;
|
|
269
|
+
let note;
|
|
270
|
+
const positional = [];
|
|
271
|
+
for (let i = 0; i < args.length; i++) {
|
|
272
|
+
const arg = args[i];
|
|
273
|
+
if (arg === "--json")
|
|
274
|
+
json = true;
|
|
275
|
+
else if (arg === "--escalated")
|
|
276
|
+
escalated = true;
|
|
277
|
+
else if (arg === "--needed-human" || arg === "--found-real") {
|
|
278
|
+
const value = args[++i];
|
|
279
|
+
if (value !== "true" && value !== "false") {
|
|
280
|
+
console.error(`${arg} needs true or false\n\n${USAGE}`);
|
|
281
|
+
return 2;
|
|
282
|
+
}
|
|
283
|
+
if (arg === "--needed-human")
|
|
284
|
+
neededHuman = value === "true";
|
|
285
|
+
else
|
|
286
|
+
foundReal = value === "true";
|
|
287
|
+
}
|
|
288
|
+
else if (arg === "--note" || arg === "--dialect") {
|
|
289
|
+
const value = args[++i];
|
|
290
|
+
if (value === undefined) {
|
|
291
|
+
console.error(`${arg} needs a value\n\n${USAGE}`);
|
|
292
|
+
return 2;
|
|
293
|
+
}
|
|
294
|
+
if (arg === "--note")
|
|
295
|
+
note = value;
|
|
296
|
+
else
|
|
297
|
+
dialect = value;
|
|
298
|
+
}
|
|
299
|
+
else if (arg.startsWith("-")) {
|
|
300
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
301
|
+
return 2;
|
|
302
|
+
}
|
|
303
|
+
else
|
|
304
|
+
positional.push(arg);
|
|
305
|
+
}
|
|
306
|
+
if (positional.length > 1) {
|
|
307
|
+
console.error(`calibrate record takes at most one path\n\n${USAGE}`);
|
|
308
|
+
return 2;
|
|
309
|
+
}
|
|
310
|
+
// The honest verdict is required, never defaulted — a fabricated verdict is the dishonest
|
|
311
|
+
// calibration data ADR-0042 exists to keep out of the record.
|
|
312
|
+
if (neededHuman === undefined || foundReal === undefined) {
|
|
313
|
+
console.error(`calibrate record needs --needed-human and --found-real\n\n${USAGE}`);
|
|
314
|
+
return 2;
|
|
315
|
+
}
|
|
316
|
+
let report;
|
|
317
|
+
try {
|
|
318
|
+
report = await recordCalibration(positional[0] ?? ".", { neededHuman, foundReal, escalated, ...(note !== undefined && { note }) }, { ...(dialect !== undefined && { dialect }) });
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
console.error(message(err));
|
|
322
|
+
return 2;
|
|
323
|
+
}
|
|
324
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderCalibrateRecord(report));
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
async function runCalibrateReport(args) {
|
|
328
|
+
let json = false;
|
|
329
|
+
const positional = [];
|
|
330
|
+
for (const arg of args) {
|
|
331
|
+
if (arg === "--json")
|
|
332
|
+
json = true;
|
|
333
|
+
else if (arg.startsWith("-")) {
|
|
334
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
335
|
+
return 2;
|
|
336
|
+
}
|
|
337
|
+
else
|
|
338
|
+
positional.push(arg);
|
|
339
|
+
}
|
|
340
|
+
if (positional.length > 1) {
|
|
341
|
+
console.error(`calibrate report takes at most one path\n\n${USAGE}`);
|
|
342
|
+
return 2;
|
|
343
|
+
}
|
|
344
|
+
let report;
|
|
345
|
+
try {
|
|
346
|
+
report = await calibrationReport(positional[0] ?? ".");
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
console.error(message(err));
|
|
350
|
+
return 2;
|
|
351
|
+
}
|
|
352
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderCalibrateReport(report));
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
async function runRemedyRecord(args) {
|
|
356
|
+
let json = false;
|
|
357
|
+
let classHandle;
|
|
358
|
+
let finding;
|
|
359
|
+
let fix;
|
|
360
|
+
let route;
|
|
361
|
+
let artefact;
|
|
362
|
+
let note;
|
|
363
|
+
const positional = [];
|
|
364
|
+
for (let i = 0; i < args.length; i++) {
|
|
365
|
+
const arg = args[i];
|
|
366
|
+
if (arg === "--json")
|
|
367
|
+
json = true;
|
|
368
|
+
else if (arg === "--class" ||
|
|
369
|
+
arg === "--finding" ||
|
|
370
|
+
arg === "--fix" ||
|
|
371
|
+
arg === "--route" ||
|
|
372
|
+
arg === "--artefact" ||
|
|
373
|
+
arg === "--note") {
|
|
374
|
+
const value = args[++i];
|
|
375
|
+
if (value === undefined) {
|
|
376
|
+
console.error(`${arg} needs a value\n\n${USAGE}`);
|
|
377
|
+
return 2;
|
|
378
|
+
}
|
|
379
|
+
if (arg === "--class")
|
|
380
|
+
classHandle = value;
|
|
381
|
+
else if (arg === "--finding")
|
|
382
|
+
finding = value;
|
|
383
|
+
else if (arg === "--fix")
|
|
384
|
+
fix = value;
|
|
385
|
+
else if (arg === "--route")
|
|
386
|
+
route = value;
|
|
387
|
+
else if (arg === "--artefact")
|
|
388
|
+
artefact = value;
|
|
389
|
+
else
|
|
390
|
+
note = value;
|
|
391
|
+
}
|
|
392
|
+
else if (arg.startsWith("-")) {
|
|
393
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
394
|
+
return 2;
|
|
395
|
+
}
|
|
396
|
+
else
|
|
397
|
+
positional.push(arg);
|
|
398
|
+
}
|
|
399
|
+
if (positional.length > 1) {
|
|
400
|
+
console.error(`remedy record takes at most one path\n\n${USAGE}`);
|
|
401
|
+
return 2;
|
|
402
|
+
}
|
|
403
|
+
if (classHandle === undefined ||
|
|
404
|
+
finding === undefined ||
|
|
405
|
+
fix === undefined ||
|
|
406
|
+
route === undefined) {
|
|
407
|
+
console.error(`remedy record needs --class, --finding, --fix, and --route\n\n${USAGE}`);
|
|
408
|
+
return 2;
|
|
409
|
+
}
|
|
410
|
+
if (!REMEDY_ROUTES.includes(route)) {
|
|
411
|
+
console.error(`--route must be one of ${REMEDY_ROUTES.join(", ")}\n\n${USAGE}`);
|
|
412
|
+
return 2;
|
|
413
|
+
}
|
|
414
|
+
let report;
|
|
415
|
+
try {
|
|
416
|
+
report = await recordRemedy(positional[0] ?? ".", {
|
|
417
|
+
class: classHandle,
|
|
418
|
+
finding,
|
|
419
|
+
fix,
|
|
420
|
+
route: route,
|
|
421
|
+
...(artefact !== undefined && { artefact }),
|
|
422
|
+
...(note !== undefined && { note }),
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
catch (err) {
|
|
426
|
+
console.error(message(err));
|
|
427
|
+
return 2;
|
|
428
|
+
}
|
|
429
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderRemedyRecord(report));
|
|
430
|
+
return 0;
|
|
431
|
+
}
|
|
432
|
+
async function runRemedyRecall(args) {
|
|
433
|
+
let json = false;
|
|
434
|
+
let classHandle;
|
|
435
|
+
const positional = [];
|
|
436
|
+
for (let i = 0; i < args.length; i++) {
|
|
437
|
+
const arg = args[i];
|
|
438
|
+
if (arg === "--json")
|
|
439
|
+
json = true;
|
|
440
|
+
else if (arg === "--class") {
|
|
441
|
+
const value = args[++i];
|
|
442
|
+
if (value === undefined) {
|
|
443
|
+
console.error(`--class needs a value\n\n${USAGE}`);
|
|
444
|
+
return 2;
|
|
445
|
+
}
|
|
446
|
+
classHandle = value;
|
|
447
|
+
}
|
|
448
|
+
else if (arg.startsWith("-")) {
|
|
449
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
450
|
+
return 2;
|
|
451
|
+
}
|
|
452
|
+
else
|
|
453
|
+
positional.push(arg);
|
|
454
|
+
}
|
|
455
|
+
if (positional.length > 1) {
|
|
456
|
+
console.error(`remedy recall takes at most one path\n\n${USAGE}`);
|
|
457
|
+
return 2;
|
|
458
|
+
}
|
|
459
|
+
if (classHandle === undefined) {
|
|
460
|
+
console.error(`remedy recall needs --class\n\n${USAGE}`);
|
|
461
|
+
return 2;
|
|
462
|
+
}
|
|
463
|
+
let report;
|
|
464
|
+
try {
|
|
465
|
+
report = await recallRemedy(positional[0] ?? ".", classHandle);
|
|
466
|
+
}
|
|
467
|
+
catch (err) {
|
|
468
|
+
console.error(message(err));
|
|
469
|
+
return 2;
|
|
470
|
+
}
|
|
471
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderRemedyRecall(report));
|
|
472
|
+
return 0;
|
|
473
|
+
}
|
|
101
474
|
async function runDoctor(args) {
|
|
102
475
|
let json = false;
|
|
103
476
|
const positional = [];
|
|
@@ -266,10 +639,12 @@ async function runInit(args) {
|
|
|
266
639
|
const root = positional[0] ?? ".";
|
|
267
640
|
let config;
|
|
268
641
|
let skills;
|
|
642
|
+
let lenses;
|
|
269
643
|
try {
|
|
270
|
-
// Materialize first, then stamp the version onto the config — so the recorded
|
|
271
|
-
// only ever
|
|
644
|
+
// Materialize first, then stamp the version onto the config — so the recorded anchors
|
|
645
|
+
// only ever name the skills and lenses that actually landed on disk.
|
|
272
646
|
skills = await materializeSkills(root);
|
|
647
|
+
lenses = await materializeLenses(root);
|
|
273
648
|
config = await initConfig(root, await ownVersion());
|
|
274
649
|
}
|
|
275
650
|
catch (err) {
|
|
@@ -277,13 +652,115 @@ async function runInit(args) {
|
|
|
277
652
|
return 2;
|
|
278
653
|
}
|
|
279
654
|
if (json) {
|
|
280
|
-
console.log(JSON.stringify({ config, skills }, null, 2));
|
|
655
|
+
console.log(JSON.stringify({ config, skills, lenses }, null, 2));
|
|
281
656
|
}
|
|
282
657
|
else {
|
|
283
658
|
console.log(renderConfigInit(config));
|
|
284
659
|
console.log("");
|
|
285
660
|
console.log(renderSkillsInit(skills));
|
|
661
|
+
console.log("");
|
|
662
|
+
console.log(renderLensesInit(lenses));
|
|
663
|
+
}
|
|
664
|
+
return 0;
|
|
665
|
+
}
|
|
666
|
+
async function runReviewInit(args) {
|
|
667
|
+
let json = false;
|
|
668
|
+
const positional = [];
|
|
669
|
+
for (const arg of args) {
|
|
670
|
+
if (arg === "--json")
|
|
671
|
+
json = true;
|
|
672
|
+
else if (arg.startsWith("-")) {
|
|
673
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
674
|
+
return 2;
|
|
675
|
+
}
|
|
676
|
+
else
|
|
677
|
+
positional.push(arg);
|
|
678
|
+
}
|
|
679
|
+
if (positional.length > 1) {
|
|
680
|
+
console.error(`review init takes at most one path\n\n${USAGE}`);
|
|
681
|
+
return 2;
|
|
682
|
+
}
|
|
683
|
+
let report;
|
|
684
|
+
try {
|
|
685
|
+
report = await scaffoldReviewWorkflow(positional[0] ?? ".");
|
|
686
|
+
}
|
|
687
|
+
catch (err) {
|
|
688
|
+
console.error(message(err));
|
|
689
|
+
return 2;
|
|
690
|
+
}
|
|
691
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderReviewInit(report));
|
|
692
|
+
return 0;
|
|
693
|
+
}
|
|
694
|
+
async function runReviewRun(args) {
|
|
695
|
+
let json = false;
|
|
696
|
+
let force = false;
|
|
697
|
+
let dryRun = false;
|
|
698
|
+
let pr;
|
|
699
|
+
let repo;
|
|
700
|
+
let base;
|
|
701
|
+
let model;
|
|
702
|
+
const positional = [];
|
|
703
|
+
for (let i = 0; i < args.length; i++) {
|
|
704
|
+
const arg = args[i];
|
|
705
|
+
if (arg === "--json")
|
|
706
|
+
json = true;
|
|
707
|
+
else if (arg === "--force")
|
|
708
|
+
force = true;
|
|
709
|
+
else if (arg === "--dry-run")
|
|
710
|
+
dryRun = true;
|
|
711
|
+
else if (arg === "--pr" || arg === "--repo" || arg === "--base" || arg === "--model") {
|
|
712
|
+
const value = args[++i];
|
|
713
|
+
if (value === undefined) {
|
|
714
|
+
console.error(`${arg} needs a value\n\n${USAGE}`);
|
|
715
|
+
return 2;
|
|
716
|
+
}
|
|
717
|
+
if (arg === "--pr") {
|
|
718
|
+
const number = Number(value);
|
|
719
|
+
if (!Number.isInteger(number) || number <= 0) {
|
|
720
|
+
console.error(`--pr needs a pull request number\n\n${USAGE}`);
|
|
721
|
+
return 2;
|
|
722
|
+
}
|
|
723
|
+
pr = number;
|
|
724
|
+
}
|
|
725
|
+
else if (arg === "--repo")
|
|
726
|
+
repo = value;
|
|
727
|
+
else if (arg === "--base")
|
|
728
|
+
base = value;
|
|
729
|
+
else
|
|
730
|
+
model = value;
|
|
731
|
+
}
|
|
732
|
+
else if (arg.startsWith("-")) {
|
|
733
|
+
console.error(`Unknown option: ${arg}\n\n${USAGE}`);
|
|
734
|
+
return 2;
|
|
735
|
+
}
|
|
736
|
+
else
|
|
737
|
+
positional.push(arg);
|
|
738
|
+
}
|
|
739
|
+
if (positional.length > 1) {
|
|
740
|
+
console.error(`review run takes at most one path\n\n${USAGE}`);
|
|
741
|
+
return 2;
|
|
742
|
+
}
|
|
743
|
+
if (pr === undefined) {
|
|
744
|
+
console.error(`review run needs --pr\n\n${USAGE}`);
|
|
745
|
+
return 2;
|
|
746
|
+
}
|
|
747
|
+
let report;
|
|
748
|
+
try {
|
|
749
|
+
report = await reviewRun(positional[0] ?? ".", {
|
|
750
|
+
pr,
|
|
751
|
+
force,
|
|
752
|
+
dryRun,
|
|
753
|
+
...(repo !== undefined && { repo }),
|
|
754
|
+
...(base !== undefined && { base }),
|
|
755
|
+
...(model !== undefined && { model }),
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
catch (err) {
|
|
759
|
+
console.error(message(err));
|
|
760
|
+
return 2;
|
|
286
761
|
}
|
|
762
|
+
console.log(json ? JSON.stringify(report, null, 2) : renderReviewRun(report));
|
|
763
|
+
// Posting findings is not a failure: the risk gate is the check, and it runs as its own step.
|
|
287
764
|
return 0;
|
|
288
765
|
}
|
|
289
766
|
async function runStrengthInit(args) {
|
package/dist/config.js
CHANGED
|
@@ -58,22 +58,25 @@ export async function detectConfig(root) {
|
|
|
58
58
|
* written record is the source of truth, never the detection (ADR-0040), the same posture
|
|
59
59
|
* `strength init` takes with the stack it provisions.
|
|
60
60
|
*
|
|
61
|
-
* When `
|
|
62
|
-
*
|
|
63
|
-
* a re-run would leave
|
|
64
|
-
* themselves stay kept — only the
|
|
61
|
+
* When `payloadVersion` is given, it is (re)stamped onto both the skills and the lenses
|
|
62
|
+
* anchors even on the kept path: `init`/`update` materialize both from the same tarball, so
|
|
63
|
+
* the two anchors must move with them or a re-run would leave a recorded version behind the
|
|
64
|
+
* files it just wrote. The facts themselves stay kept — only the stamps follow the payload.
|
|
65
65
|
*/
|
|
66
|
-
export async function initConfig(root,
|
|
66
|
+
export async function initConfig(root, payloadVersion) {
|
|
67
|
+
const stamped = (config) => payloadVersion === undefined
|
|
68
|
+
? config
|
|
69
|
+
: { ...config, skillsVersion: payloadVersion, lensesVersion: payloadVersion };
|
|
67
70
|
const existing = await readConfig(root);
|
|
68
71
|
if (existing !== undefined) {
|
|
69
|
-
const config =
|
|
70
|
-
|
|
72
|
+
const config = stamped(existing);
|
|
73
|
+
const moved = payloadVersion !== undefined &&
|
|
74
|
+
(existing.skillsVersion !== payloadVersion || existing.lensesVersion !== payloadVersion);
|
|
75
|
+
if (moved)
|
|
71
76
|
await writeConfig(root, config);
|
|
72
|
-
}
|
|
73
77
|
return { root, file: CONFIG_FILE, action: "kept", config };
|
|
74
78
|
}
|
|
75
|
-
const
|
|
76
|
-
const config = skillsVersion !== undefined ? { ...detected, skillsVersion } : detected;
|
|
79
|
+
const config = stamped(await detectConfig(root));
|
|
77
80
|
await writeConfig(root, config);
|
|
78
81
|
return { root, file: CONFIG_FILE, action: "written", config };
|
|
79
82
|
}
|
package/dist/doctor.js
CHANGED
|
@@ -2,6 +2,7 @@ import { access, readdir, readFile, stat } from "node:fs/promises";
|
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { readConfig } from "./config.js";
|
|
4
4
|
import { ownVersion, STRENGTH_DEPS, STRYKER_CONFIG_NAMES } from "./init.js";
|
|
5
|
+
import { LENSES_DIR } from "./lenses.js";
|
|
5
6
|
import { SKILLS_DIR } from "./skills.js";
|
|
6
7
|
/**
|
|
7
8
|
* Reports the truth about the three things that drift in a Speccle consumer — the CLI, the
|
|
@@ -15,8 +16,10 @@ export async function doctor(target) {
|
|
|
15
16
|
throw new Error(`path not found: ${target}`);
|
|
16
17
|
const cli = await ownVersion();
|
|
17
18
|
const config = await readConfig(root);
|
|
18
|
-
const
|
|
19
|
-
const skillsStatus =
|
|
19
|
+
const skillsRecorded = config?.skillsVersion ?? null;
|
|
20
|
+
const skillsStatus = derivePayloadStatus(await hasSkills(root), skillsRecorded, cli);
|
|
21
|
+
const lensesRecorded = config?.lensesVersion ?? null;
|
|
22
|
+
const lensesStatus = derivePayloadStatus(await hasLenses(root), lensesRecorded, cli);
|
|
20
23
|
const provisioned = await anyPresent(root, STRYKER_CONFIG_NAMES);
|
|
21
24
|
const declared = await declaredDeps(root);
|
|
22
25
|
const deps = STRENGTH_DEPS.map((spec) => checkDep(spec, declared));
|
|
@@ -25,16 +28,18 @@ export async function doctor(target) {
|
|
|
25
28
|
: deps.some((dep) => dep.status !== "ok")
|
|
26
29
|
? "drift"
|
|
27
30
|
: "current";
|
|
28
|
-
const
|
|
31
|
+
const current = (status) => status === "current" || status === "absent";
|
|
32
|
+
const ok = current(skillsStatus) && current(lensesStatus) && stackStatus !== "drift";
|
|
29
33
|
return {
|
|
30
34
|
root,
|
|
31
35
|
cli,
|
|
32
|
-
skills: { recorded, bundled: cli, status: skillsStatus },
|
|
36
|
+
skills: { recorded: skillsRecorded, bundled: cli, status: skillsStatus },
|
|
37
|
+
lenses: { recorded: lensesRecorded, bundled: cli, status: lensesStatus },
|
|
33
38
|
stack: { provisioned, deps, status: stackStatus },
|
|
34
39
|
ok,
|
|
35
40
|
};
|
|
36
41
|
}
|
|
37
|
-
function
|
|
42
|
+
function derivePayloadStatus(present, recorded, bundled) {
|
|
38
43
|
if (!present)
|
|
39
44
|
return "absent";
|
|
40
45
|
if (recorded === null)
|
|
@@ -82,6 +87,15 @@ async function hasSkills(root) {
|
|
|
82
87
|
return false;
|
|
83
88
|
}
|
|
84
89
|
}
|
|
90
|
+
async function hasLenses(root) {
|
|
91
|
+
try {
|
|
92
|
+
const entries = await readdir(join(root, LENSES_DIR));
|
|
93
|
+
return entries.some((entry) => entry.endsWith(".md"));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
85
99
|
async function anyPresent(root, names) {
|
|
86
100
|
for (const name of names) {
|
|
87
101
|
if (await exists(join(root, name)))
|