@sabaiway/agent-workflow-kit 21.0.0 → 22.0.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/CHANGELOG.md +46 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/migrations/3.0.0-hardened-core-loop.md +7 -6
- package/package.json +1 -1
- package/references/advisor-writers.md +1 -1
- package/references/contracts.md +2 -1
- package/references/modes/gates.md +2 -2
- package/references/modes/recommendations.md +1 -1
- package/references/modes/upgrade.md +5 -5
- package/references/scripts/family.json +2 -0
- package/references/scripts/family.mjs +2 -2
- package/references/scripts/gates/migrate-gates.mjs +240 -176
- package/references/scripts/run.mjs +26 -10
- package/references/scripts/test-reporter/reporter.mjs +130 -0
- package/tools/coverage-producer.mjs +76 -41
- package/tools/distribution-files/scripts.mjs +5 -4
- package/tools/ensure-configs.mjs +2 -2
- package/tools/ensure-specs.mjs +11 -8
- package/tools/gates-declaration.mjs +22 -14
- package/tools/gates-init.mjs +33 -17
- package/tools/recommendations.mjs +15 -6
- package/tools/upgrade-runlist.mjs +3 -3
package/tools/gates-init.mjs
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
// executes project-controlled tooling (a node_modules/.bin PATH shim intercepts under every
|
|
32
32
|
// form) — the documented residual, disclosed in the preview, bounded by the two consents;
|
|
33
33
|
// • a `node --test` suite body — the ONE allowlist member that produces lcov unaided — is
|
|
34
|
-
// emitted
|
|
34
|
+
// emitted as the stable kit command's unit-tests name (spec coverage-producer), which adds the
|
|
35
|
+
// lcov reporter, so the offered checker has a producer — only while the project's kit folder
|
|
36
|
+
// holds THIS kit's run.mjs and a reporter, else it is withheld naming the upgrade; every
|
|
35
37
|
// other body is emitted verbatim. The coverage-check candidate is WITHHELD (loud note) when
|
|
36
38
|
// neither the offer nor the existing declaration carries a producer, and --apply refuses to
|
|
37
39
|
// WRITE a declaration whose checker has no producer, is not last, or has a canonical twin:
|
|
@@ -62,8 +64,8 @@ import { fileURLToPath } from 'node:url';
|
|
|
62
64
|
import { isDirectRun } from './direct-run.mjs';
|
|
63
65
|
import { discoverGateCandidates, EXPECTED_WORKFLOW_VERSION } from './velocity-profile.mjs';
|
|
64
66
|
import { GATES_REL, validateDeclaration } from './run-gates.mjs';
|
|
65
|
-
import { canonicalCheckerGates, coverageDeclarationDefects, isKitOwnedCheckerGate } from './gates-declaration.mjs';
|
|
66
|
-
import { COVERAGE_PRODUCER_BODY,
|
|
67
|
+
import { canonicalCheckerGates, coverageDeclarationDefects, coverageProducerPrecedes, isKitOwnedCheckerGate, NO_PRODUCER_REMEDY } from './gates-declaration.mjs';
|
|
68
|
+
import { COVERAGE_PRODUCER_BODY, guardRemedy, matchesCoverageProducer, unitTestsGuardFailure } from './coverage-producer.mjs';
|
|
67
69
|
import { loadConfig } from './orchestration-config.mjs';
|
|
68
70
|
import { assertDocsAiDeployment, writeDocsAiFileAtomic, lstatNoFollow } from './atomic-write.mjs';
|
|
69
71
|
// The source-size practice, through its PURE READ core only (D-18): this module asks whether the
|
|
@@ -117,8 +119,9 @@ never watch/serve, never a write-mode variant) whose BODY is a member of the lit
|
|
|
117
119
|
allowlist is offered, as the hook-free \`COREPACK_ENABLE_NETWORK=0 <pm> exec -- <body>\` form for
|
|
118
120
|
the detected package manager. A gate-class script whose body is NOT in the allowlist is screened
|
|
119
121
|
out with a note naming it (a command you trust can still be declared by hand); non-gate-class
|
|
120
|
-
names are excluded silently, as always. A \`node --test\` body
|
|
121
|
-
|
|
122
|
+
names are excluded silently, as always. A \`node --test\` body runs as ${COVERAGE_PRODUCER_BODY}
|
|
123
|
+
while the kit folder holds this kit's command and reporter (else it is withheld, naming
|
|
124
|
+
/agent-workflow-kit upgrade); the coverage-check candidate is withheld when nothing would produce the lcov it reads,
|
|
122
125
|
and --apply refuses to write a checker with no producer, a checker that is not last, or a second
|
|
123
126
|
canonical checker.
|
|
124
127
|
${TRUST_CHAIN_DISCLOSURE}`;
|
|
@@ -222,11 +225,15 @@ export const execCmdFor = (pm, body) => {
|
|
|
222
225
|
|
|
223
226
|
// The coverage PRODUCER wiring (Decision 1 — closed-world here too). `node --test` is the only
|
|
224
227
|
// allowlist body that produces lcov with no extra dependency, so it is the only body the offer
|
|
225
|
-
//
|
|
226
|
-
// optional-dependency coverage flag set would be speculation about the
|
|
228
|
+
// rewrites — into the stable kit command's unit-tests name; every other body is emitted verbatim
|
|
229
|
+
// and produces none (an optional-dependency coverage flag set would be speculation about the
|
|
230
|
+
// project's own tooling).
|
|
227
231
|
const COVERAGE_PRODUCING_BODY = 'node --test';
|
|
228
232
|
const emittedBodyOf = (body) => (body === COVERAGE_PRODUCING_BODY ? COVERAGE_PRODUCER_BODY : body);
|
|
229
233
|
|
|
234
|
+
// The unit-tests guard reads the project's kit folder against THIS kit's bundled run.mjs.
|
|
235
|
+
const KIT_RUN = join(HERE, '..', 'references', 'scripts', 'run.mjs');
|
|
236
|
+
|
|
230
237
|
export const kebabIdOf = (name) =>
|
|
231
238
|
String(name)
|
|
232
239
|
.toLowerCase()
|
|
@@ -276,6 +283,8 @@ const deriveScripts = (cwd, deps = {}) => {
|
|
|
276
283
|
const entries = [];
|
|
277
284
|
const screenedIds = [];
|
|
278
285
|
const withheld = [];
|
|
286
|
+
const guardWithheld = [];
|
|
287
|
+
let guard;
|
|
279
288
|
for (const c of named) {
|
|
280
289
|
const id = kebabIdOf(c.scriptName);
|
|
281
290
|
if (!id || seen.has(id)) continue; // an empty or duplicate derived id never enters the offer
|
|
@@ -286,12 +295,16 @@ const deriveScripts = (cwd, deps = {}) => {
|
|
|
286
295
|
continue;
|
|
287
296
|
}
|
|
288
297
|
const emitted = emittedBodyOf(body);
|
|
298
|
+
if (emitted !== body && (guard === undefined ? (guard = unitTestsGuardFailure(cwd, KIT_RUN, { lstatSync, readFileSync })) : guard) !== null) {
|
|
299
|
+
guardWithheld.push({ id, ...guard });
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
289
302
|
const { cmd, note } = execCmdFor(pm, emitted);
|
|
290
303
|
if (cmd === null) {
|
|
291
304
|
withheld.push({ id, note });
|
|
292
305
|
continue;
|
|
293
306
|
}
|
|
294
|
-
const coverage = emitted === body ? '' : ' (+ the lcov
|
|
307
|
+
const coverage = emitted === body ? '' : ' (through the stable kit command, + the lcov reporter the coverage checker reads)';
|
|
295
308
|
entries.push({ id, title: `Project script ${c.scriptName}: ${body}${coverage}`, cmd });
|
|
296
309
|
}
|
|
297
310
|
const notes = [];
|
|
@@ -304,7 +317,10 @@ const deriveScripts = (cwd, deps = {}) => {
|
|
|
304
317
|
if (withheld.length) {
|
|
305
318
|
notes.push(`${withheld.length} script gate(s) withheld: ${withheld.map((w) => w.id).join(', ')} — ${withheld[0].note}`);
|
|
306
319
|
}
|
|
307
|
-
|
|
320
|
+
for (const { id, path, kind } of guardWithheld) {
|
|
321
|
+
notes.push(`script gate ${id} withheld: its node --test body runs as ${COVERAGE_PRODUCER_BODY}, and ${path} ${guardRemedy(kind, '/agent-workflow-kit upgrade')}`);
|
|
322
|
+
}
|
|
323
|
+
return { entries, notes, guardWithheld: guardWithheld.map(({ id, path }) => ({ id, path })) };
|
|
308
324
|
};
|
|
309
325
|
|
|
310
326
|
export const deriveScriptEntries = (cwd, deps = {}) => deriveScripts(cwd, deps).entries;
|
|
@@ -533,17 +549,15 @@ export const buildOffer = (cwd, deps = {}) => {
|
|
|
533
549
|
// a declaration the user already wrote by hand, so the rule reads the merged picture; a
|
|
534
550
|
// declaration this preview cannot read degrades to a stated note, never to a silent withhold.
|
|
535
551
|
const existing = declaredGatesBestEffort(cwd, deps);
|
|
536
|
-
//
|
|
537
|
-
//
|
|
538
|
-
//
|
|
552
|
+
// The offered entries carry no marker and no claim, so the closed cmd world screens them; every
|
|
553
|
+
// declared row is asked the ONE row question (readsAsCoverageProducer, through
|
|
554
|
+
// coverageProducerPrecedes over the whole list), so a row claiming the checker never produces.
|
|
539
555
|
const producerPresent =
|
|
540
|
-
scripts.entries.some((entry) =>
|
|
541
|
-
existing.gates.
|
|
556
|
+
scripts.entries.some((entry) => matchesCoverageProducer(entry.cmd)) ||
|
|
557
|
+
coverageProducerPrecedes(existing.gates, existing.gates.length, cwd);
|
|
542
558
|
const withholdCoverage = cc.candidate !== null && !producerPresent;
|
|
543
559
|
const coverageNote = withholdCoverage
|
|
544
|
-
? `the coverage-check candidate was withheld:
|
|
545
|
-
`declared gate carries the canonical coverage reporters, and a checker with no producer passes while ` +
|
|
546
|
-
`verifying nothing (declare a suite gate per references/modes/gates.md, then re-run)`
|
|
560
|
+
? `the coverage-check candidate was withheld: no declared gate is a producer this kit reads, and none is offered — ${NO_PRODUCER_REMEDY}`
|
|
547
561
|
: cc.note;
|
|
548
562
|
// ALWAYS stated, not only when it changed the withhold: the preview would otherwise promise an
|
|
549
563
|
// applicable offer over a declaration --apply is certain to refuse.
|
|
@@ -573,6 +587,8 @@ export const buildOffer = (cwd, deps = {}) => {
|
|
|
573
587
|
return {
|
|
574
588
|
entries: [...scripts.entries, ...candidates],
|
|
575
589
|
notes: [...scripts.notes, noVerificationNote, unreadableNote, rs.note, fc.note, ss.note, coverageNote].filter(Boolean),
|
|
590
|
+
// The script gates the unit-tests guard withheld, { id, path }: the signal the advisor reads, never the note's text.
|
|
591
|
+
guardWithheld: scripts.guardWithheld,
|
|
576
592
|
};
|
|
577
593
|
};
|
|
578
594
|
|
|
@@ -56,14 +56,14 @@ import { surveyFamily, surveyGateHook } from './family-registry.mjs';
|
|
|
56
56
|
import { probeSandboxMasks, needsMasksApply, patternToRel } from './sandbox-masks.mjs';
|
|
57
57
|
import { shellQuoteArg } from './review-state.mjs';
|
|
58
58
|
import { isFinalCapableDeclaration } from './run-gates.mjs';
|
|
59
|
-
import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate } from './gates-declaration.mjs';
|
|
59
|
+
import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate, movableEarlierForm } from './gates-declaration.mjs';
|
|
60
60
|
// The typed channel's READ-ONLY leaf only — never tools/mcp.mjs, which reaches the write core.
|
|
61
61
|
import {
|
|
62
62
|
SERVER_NAME as MCP_SERVER_NAME,
|
|
63
63
|
STATE as MCP_STATE,
|
|
64
64
|
readRegistration,
|
|
65
65
|
} from './mcp-registration.mjs';
|
|
66
|
-
import { matchesCoverageProducer
|
|
66
|
+
import { matchesCoverageProducer } from './coverage-producer.mjs';
|
|
67
67
|
// How much of the TRACKED tree the changed-line coverage domain can assess at all — the fact that
|
|
68
68
|
// turns "the checker certifies" into "the checker certifies the assessable minority".
|
|
69
69
|
import { takeCensus, censusFact, CENSUS_VERDICT } from './tracked-tree-census.mjs';
|
|
@@ -266,7 +266,7 @@ export const composeVerdict = ({ attention, optional, skipped, kit = 0 }) => {
|
|
|
266
266
|
// banned tokens), never a fixture-coverage gamble. A pure-placeholder template marks a WHAT whose
|
|
267
267
|
// content is fully dynamic (capped at composition by truncation-with-count) — except `profile-gap`, whose
|
|
268
268
|
// WHAT is never truncated: the leaf's suite pins every composed WHAT under the cap.
|
|
269
|
-
const GATES_INERT_WHAT = 'the declared coverage checker ({id})
|
|
269
|
+
const GATES_INERT_WHAT = 'the declared coverage checker ({id}): no gate before it is a producer this kit reads';
|
|
270
270
|
export const WHATS = Object.freeze({
|
|
271
271
|
'velocity-core': 'routine read-only commands still prompt — {n} audited read-only allowlist entr(ies) not seeded',
|
|
272
272
|
'velocity-core.rule': 'auto mode refuses a harness apply, so work cannot stay in auto mode — the apply ask rule is not seeded',
|
|
@@ -693,7 +693,7 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
|
|
|
693
693
|
// ORDER decides, through the declaration's own shared predicate: a producer declared AFTER the
|
|
694
694
|
// checker leaves it just as inert as no producer at all (it reads nothing, or stale bytes), and
|
|
695
695
|
// only --final refuses that shape — a plain run reports every gate PASS.
|
|
696
|
-
if (coverageProducerPrecedes(gates, gates.indexOf(checkers[0]))) {
|
|
696
|
+
if (coverageProducerPrecedes(gates, gates.indexOf(checkers[0]), root)) {
|
|
697
697
|
// The pair is LIVE, and that is exactly where the DOMAIN question becomes the honest one: the
|
|
698
698
|
// checker's changed-line domain is `.mjs/.cjs/.js` by design, so on a tree dominated by what
|
|
699
699
|
// that domain excludes, "certified" means "certified over the assessable minority". An
|
|
@@ -728,7 +728,16 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
|
|
|
728
728
|
// arm's sentence would be false over it. An offer computation that throws reaches the probe's
|
|
729
729
|
// stated-skip lane, which is the honest answer to "can the fill help here" when nobody knows.
|
|
730
730
|
const declaredIds = new Set(gates.map((gate) => gate.id));
|
|
731
|
-
const
|
|
731
|
+
const offer = buildOffer(root, deps);
|
|
732
|
+
// A gate an earlier kit wrote that the upgrade moves, anywhere in the declaration, or a `node --test`
|
|
733
|
+
// script the offer withheld on its unit-tests guard: the upgrade is the remedy, in place of the fill
|
|
734
|
+
// preview and of both user arms below — it moves the gate with no question, or a line of its report
|
|
735
|
+
// names what stops it; the advisor predicts nothing about the run (spec coverage-producer, the remedy route).
|
|
736
|
+
if (movableEarlierForm(gates) || offer.guardWithheld.length > 0) {
|
|
737
|
+
add('gates-inert', fillTemplate(WHATS['gates-inert'], { id: truncatedTo(oneLineOf(checkers[0].id), templateBudget(WHATS['gates-inert'])) }), '/agent-workflow-kit upgrade');
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
const offered = offer.entries.filter((entry) => matchesCoverageProducer(entry.cmd));
|
|
732
741
|
const producer = offered.find((entry) => !declaredIds.has(entry.id));
|
|
733
742
|
// The dead pair on a tree the recognized producer set cannot speak for. It is deliberately NOT
|
|
734
743
|
// the ordering arm: a producer that EXISTS but sits after the checker is one MOVE away from
|
|
@@ -754,7 +763,7 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
|
|
|
754
763
|
// a recognizable producer the offer never carries. The arm therefore says only what it knows —
|
|
755
764
|
// nothing declares one and nothing offers one — and its apply names that gap, because the
|
|
756
765
|
// remedy there is a hand-declared gate rather than the marker.
|
|
757
|
-
if (offered.length === 0 && !gates
|
|
766
|
+
if (offered.length === 0 && !coverageProducerPrecedes(gates, gates.length, root)) {
|
|
758
767
|
// An UNAVAILABLE census is NOT a skip here. The dead pair is a defect on any tree, and the
|
|
759
768
|
// arm below states it truthfully — falling through keeps a non-git deployment byte-identical
|
|
760
769
|
// to what it saw before this outcome existed, and still renders an item, so the flow-optimal
|
|
@@ -52,9 +52,9 @@ export const UPGRADE_RUNLIST = Object.freeze([
|
|
|
52
52
|
),
|
|
53
53
|
entry(
|
|
54
54
|
'gates-migration',
|
|
55
|
-
'node ${CLAUDE_SKILL_DIR}/references/scripts/gates/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project>',
|
|
56
|
-
'
|
|
57
|
-
['
|
|
55
|
+
'node ${CLAUDE_SKILL_DIR}/references/scripts/gates/migrate-gates.mjs --kit-tools ${CLAUDE_SKILL_DIR}/tools --cwd <project> --apply',
|
|
56
|
+
'the coverage-check add alone: on the user\'s explicit yes, run its printed OFFER line, the same command with --apply --add-checker',
|
|
57
|
+
['SWITCH', 'EXTEND', 'REMOVE', 'KEPT', 'CUSTOMIZED', 'OFFER'],
|
|
58
58
|
),
|
|
59
59
|
entry(
|
|
60
60
|
'bridges',
|