@sabaiway/agent-workflow-kit 17.0.0 → 19.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 +67 -0
- package/README.md +2 -2
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/advisor-writers.md +3 -4
- package/references/contracts.md +8 -3
- package/references/modes/gates.md +1 -1
- package/references/modes/hook.md +7 -7
- package/references/modes/jev.md +1 -1
- package/references/modes/recommendations.md +4 -4
- package/references/modes/state-block-guard.md +4 -0
- package/tools/apply-danger-check.mjs +35 -26
- package/tools/distribution-files/scripts.mjs +4 -2
- package/tools/gate-hook.mjs +25 -55
- package/tools/jev-facts.mjs +4 -1
- package/tools/jev-skill.mjs +7 -5
- package/tools/recommendations.mjs +82 -162
- package/tools/state-block-hook.mjs +6 -6
- package/tools/write-lanes.mjs +12 -14
|
@@ -47,7 +47,8 @@ import {
|
|
|
47
47
|
import { loadAutonomy, isSparseSeedConfig, AUTONOMY_REL } from './autonomy-config.mjs';
|
|
48
48
|
import { deriveDoctorPlan, TRUSTED_DIRS } from './autonomy-doctor.mjs';
|
|
49
49
|
import { LANE_KIT, laneOf, applySlot, consoleArgv } from './write-lanes.mjs';
|
|
50
|
-
import { STATE_BLOCK_HOOK_COMMAND, STATE_BLOCK_HOOK_RUNTIME, isStopHookWired } from './state-block-hook.mjs';
|
|
50
|
+
import { STATE_BLOCK_HOOK_COMMAND, STATE_BLOCK_HOOK_FILE_REL, STATE_BLOCK_HOOK_RUNTIME, isStopHookWired, writeStateBlockHook } from './state-block-hook.mjs';
|
|
51
|
+
import { HOOK_FILE_REL, HOOKS_DIR, writeGateHook } from './gate-hook.mjs';
|
|
51
52
|
import { detectBackends } from './detect-backends.mjs';
|
|
52
53
|
import { isDirectRun } from './direct-run.mjs';
|
|
53
54
|
import { ACTIVITIES, resolveActivityRecipe, composeReadiness, safeLine } from './recipes.mjs';
|
|
@@ -55,8 +56,7 @@ import { surveyFamily, surveyGateHook } from './family-registry.mjs';
|
|
|
55
56
|
import { probeSandboxMasks, needsMasksApply, patternToRel } from './sandbox-masks.mjs';
|
|
56
57
|
import { shellQuoteArg } from './review-state.mjs';
|
|
57
58
|
import { isFinalCapableDeclaration } from './run-gates.mjs';
|
|
58
|
-
import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate
|
|
59
|
-
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
59
|
+
import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate } 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,
|
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
import { ADOPTION, STORE_DIR_REL as SPEC_STORE_DIR_REL, SPEC_ADOPTION_LANE, declineFingerprint, readDeclineAck, surveySpecAdoption } from './spec-adoption.mjs';
|
|
106
106
|
import { ENSURE_OPS } from './ensure-vocabulary.mjs';
|
|
107
107
|
import { composeProfileGapScreen } from './profile-gap-screen.mjs';
|
|
108
|
-
import { NO_APPLY_LINE, SKILL_PINS, claudeDirOf, keySet, placeOf, printable, skillLine, skillState, skillTargets } from './jev-facts.mjs';
|
|
108
|
+
import { NO_APPLY_LINE, SKILL_PINS, claudeDirOf, keySet, placeOf, printable, skillAccepted, skillLine, skillState, skillTargets } from './jev-facts.mjs';
|
|
109
109
|
|
|
110
110
|
// The upgrade ensure that seeds the spec store — the not-adopted item's apply; pinned to the vocabulary.
|
|
111
111
|
const SPEC_LAYER_ENSURE = ENSURE_OPS.includes('specs') ? 'specs' : null;
|
|
@@ -193,17 +193,14 @@ export const SEVERITIES = Object.freeze({
|
|
|
193
193
|
'source-size.schema-1': SEVERITY_ATTENTION,
|
|
194
194
|
'source-size.layout': SEVERITY_OPTIONAL,
|
|
195
195
|
'gate-hook': SEVERITY_OPTIONAL,
|
|
196
|
-
// A
|
|
197
|
-
|
|
198
|
-
// offer to enable something.
|
|
199
|
-
'gate-hook.marker-stale': SEVERITY_ATTENTION,
|
|
196
|
+
// A wired hook's kit file absent or differing: its lane is kit, as `agents.not-current`'s.
|
|
197
|
+
'gate-hook.not-current': SEVERITY_OPTIONAL,
|
|
200
198
|
'commit-guard': SEVERITY_OPTIONAL,
|
|
201
199
|
'hook-checks': SEVERITY_OPTIONAL,
|
|
202
200
|
enforcement: SEVERITY_OPTIONAL,
|
|
203
201
|
'read-lane': SEVERITY_OPTIONAL,
|
|
204
|
-
'read-lane.stale': SEVERITY_ATTENTION,
|
|
205
|
-
'read-lane.missing': SEVERITY_ATTENTION,
|
|
206
202
|
'state-block': SEVERITY_OPTIONAL,
|
|
203
|
+
'state-block.not-current': SEVERITY_OPTIONAL,
|
|
207
204
|
'mcp-channel': SEVERITY_OPTIONAL,
|
|
208
205
|
'mcp-channel.differing': SEVERITY_ATTENTION,
|
|
209
206
|
agents: SEVERITY_OPTIONAL,
|
|
@@ -229,7 +226,7 @@ export const SEVERITIES = Object.freeze({
|
|
|
229
226
|
'profile-gap': SEVERITY_OPTIONAL,
|
|
230
227
|
'jev-connect': SEVERITY_OPTIONAL,
|
|
231
228
|
'jev-skill': SEVERITY_OPTIONAL,
|
|
232
|
-
'jev-skill.
|
|
229
|
+
'jev-skill.not-current': SEVERITY_OPTIONAL,
|
|
233
230
|
'spec-adoption.adopting': SEVERITY_OPTIONAL,
|
|
234
231
|
});
|
|
235
232
|
// The per-item render tags (frozen presentation data, same language contract as the templates).
|
|
@@ -292,14 +289,13 @@ export const WHATS = Object.freeze({
|
|
|
292
289
|
'source-size.adopted-elsewhere': "the source-size gate runs a DIFFERENT copy of this checker ({n} declared) — adopted here, just not through this kit's own tool",
|
|
293
290
|
'source-size.id-squatter': 'a gate carries the source-size id but is not this checker — the practice reads as declared while nothing measures module size',
|
|
294
291
|
'gate-hook': '{n} declared gate(s) prompt per run — the gate-approval hook is not wired',
|
|
295
|
-
'gate-hook.
|
|
292
|
+
'gate-hook.not-current': `${HOOK_FILE_REL} is absent or differs from the body the kit writes for it — written with that body, with no question`,
|
|
296
293
|
'commit-guard': 'the gate matrix is final-run-capable but no commit-guard arms the pre-commit hook — a commit needs no green receipt yet',
|
|
297
294
|
'hook-checks': 'the pre-commit hook lacks this kit\'s {checks} — the kit arms each line',
|
|
298
295
|
enforcement: ENFORCEMENT_WHAT,
|
|
299
296
|
'read-lane': 'the gate hook is wired but the read-only compound lane is off — pipes/chains of seeded reads still prompt one by one',
|
|
300
|
-
'read-lane.stale': 'the read-lane is ON but the placed gate hook is stale — an old hook never reads lanes.json, so the lane is silently dark; reseed it',
|
|
301
|
-
'read-lane.missing': 'the gate hook is wired but its placed file is missing — every Bash call errors and the read-lane is dark; re-place it',
|
|
302
297
|
'state-block': 'nothing checks the closing state block — a turn that ends on «nothing needed from you», or on a promise it never started, passes unseen',
|
|
298
|
+
'state-block.not-current': `${STATE_BLOCK_HOOK_FILE_REL} is absent or differs from the body the kit writes for it — written with that body, with no question`,
|
|
303
299
|
'mcp-channel': "the kit's read-only MCP server is not registered here — path questions and literal searches stay shell strings",
|
|
304
300
|
'mcp-channel.differing': 'an "{server}" MCP entry is already declared here and DIFFERS from the registration this kit copy would write',
|
|
305
301
|
agents: '{n} bundled subagent vehicle(s) not placed (Claude Code) — {ro} read-only, {ex} the full-tool executor; the apply PREVIEWS first',
|
|
@@ -315,8 +311,8 @@ export const WHATS = Object.freeze({
|
|
|
315
311
|
'spec-adoption': 'feature-spec store absent (docs/ai/specs) — no feature contract can govern a plan here yet; seed the store, or record the decline',
|
|
316
312
|
'profile-gap': '{what}',
|
|
317
313
|
'jev-connect': 'Jev (TypeSafe) is not connected: TYPESAFE_API_KEY is not in the environment the agent\'s commands run in',
|
|
318
|
-
'jev-skill': 'Jev\'s vendor skill is not installed for every agent here: a skill root the kit fills is absent
|
|
319
|
-
'jev-skill.
|
|
314
|
+
'jev-skill': 'Jev\'s vendor skill is not installed for every agent here: a skill root the kit fills is absent',
|
|
315
|
+
'jev-skill.not-current': 'Jev\'s vendor skill is absent or behind the kit\'s pin in {n} agent skill root(s) beside a copy at a kit pin — written with no question',
|
|
320
316
|
'spec-adoption.adopting': 'feature-spec store: {n} draft spec(s), no live contract — nothing governs a plan through it yet; land a live contract, or record the decline',
|
|
321
317
|
});
|
|
322
318
|
|
|
@@ -383,8 +379,12 @@ export const BENEFITS = Object.freeze({
|
|
|
383
379
|
'jev-skill': 'the TypeSafe skill for Claude Code, Codex and Antigravity CLI, one pinned verified copy per agent root, from one command you run',
|
|
384
380
|
});
|
|
385
381
|
// The arms whose gain differs from their base item's (BENEFITS stays keyed by item key).
|
|
382
|
+
const HOOK_CURRENCY_BENEFIT = 'currency — a hook you wired runs the body the kit writes for it today';
|
|
386
383
|
export const VARIANT_BENEFITS = Object.freeze({
|
|
387
384
|
'agents.not-current': 'currency — each kit agent file carries the body the kit writes for it today, model and effort where docs/ai/vehicles.json names them',
|
|
385
|
+
'gate-hook.not-current': HOOK_CURRENCY_BENEFIT,
|
|
386
|
+
'state-block.not-current': HOOK_CURRENCY_BENEFIT,
|
|
387
|
+
'jev-skill.not-current': "currency — every agent skill root the kit fills holds the vendor skill at the kit's pin once a copy is placed",
|
|
388
388
|
'source-size.layout': 'layout — piles past the layout limits become recorded, reasoned debt, so the commit hook can judge new ones once its layout line is armed',
|
|
389
389
|
});
|
|
390
390
|
|
|
@@ -613,46 +613,33 @@ const probeReviewRecipe = ({ root, deps, add, skip }) => {
|
|
|
613
613
|
}
|
|
614
614
|
};
|
|
615
615
|
|
|
616
|
-
|
|
616
|
+
// The kit arm of a WIRED hook (contract: init-project, part hook-writers): the writer's plain dry run,
|
|
617
|
+
// the call the danger check makes. A throw is the probe's stated skip; no planned place or replace
|
|
618
|
+
// renders nothing; a stale stamp beside one is the upgrade-first skip; otherwise the kit item.
|
|
619
|
+
const probeKitHook = ({ key, write, rel, root, deps, add }) => {
|
|
620
|
+
const plan = write({ cwd: root, dryRun: true }, deps);
|
|
621
|
+
if (!plan.placePlanned && !plan.replacePlanned) return;
|
|
622
|
+
if (!plan.stampOk) throw upgradeFirst(plan.stamp);
|
|
623
|
+
const variant = `${key}.not-current`;
|
|
624
|
+
add(key, WHATS[variant], formsApply(variant, root), variant, `writes: ${rel}`);
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
const probeGates = ({ root, deps, add, skip }) => {
|
|
617
628
|
try {
|
|
618
629
|
const sg = surveyGateHook(root, deps);
|
|
619
630
|
if (sg.error) throw new Error(sg.error);
|
|
620
|
-
if (sg.declarationPresent && sg.declaredGates === null) throw new Error(sg.declarationError ?? 'gates.json present but unreadable');
|
|
621
631
|
// An ABSENT file and the seeded-EMPTY list are equally undeclared (Segment B); the
|
|
622
632
|
// apply is the consent-gated gates-init PREVIEW (it proposes entries from the project's own
|
|
623
|
-
// scripts and writes only on an explicit yes) — never the runner.
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
if (
|
|
632
|
-
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
// D8 — the marker REFRESH path. The placed hook validates the declaration through its OWN baked
|
|
636
|
-
// copy and goes dark on any key it does not know (auto-approval off, every gate prompts again),
|
|
637
|
-
// so a declaration carrying the marker key under a hook that predates it silently switches a
|
|
638
|
-
// CONFIGURED capability off with no error anywhere. Deliberately marker-SCOPED: a stale hook is
|
|
639
|
-
// otherwise harmless, and nagging every deployment about hook bytes is not this item's job.
|
|
640
|
-
if (!declarationCarriesMarker(root, deps)) return;
|
|
641
|
-
// Throws on a symlink / directory / unreadable target → the stated skip, never a wrong verdict.
|
|
642
|
-
// ABSENT is not this arm either: a hook that is not placed belongs to the place offers above and
|
|
643
|
-
// in the read-lane item, whose recovery actually places one.
|
|
644
|
-
if (readPlacedHookCurrency(root, deps) !== HOOK_CURRENCY.STALE) return;
|
|
645
|
-
// The writer's OWN stale recovery: `gate-hook --apply --reseed` replaces the placed hook with
|
|
646
|
-
// the bundle in place — the one consented replacement; the slot renders it behind the check.
|
|
647
|
-
// The RESULT is what the read-lane item defers to — not these conditions re-derived there. Both
|
|
648
|
-
// probes read the placed hook independently, so a hook that changes between the two reads would
|
|
649
|
-
// otherwise let each conclude the other owns it and leave a dark lane reported by nobody.
|
|
650
|
-
shared.markerStaleRendered = add(
|
|
651
|
-
'gate-hook',
|
|
652
|
-
fillTemplate(WHATS['gate-hook.marker-stale'], {}),
|
|
653
|
-
`node ${q(toolPath('gate-hook.mjs'))} --apply --reseed --cwd ${q(root)}`,
|
|
654
|
-
'gate-hook.marker-stale',
|
|
655
|
-
);
|
|
633
|
+
// scripts and writes only on an explicit yes) — never the runner. gates-init writes ONLY with
|
|
634
|
+
// --apply — the apply field stays a PURE executable command; the two-step preview semantics
|
|
635
|
+
// live in WHAT, never as prose appended to the command.
|
|
636
|
+
const undeclared = !sg.declarationPresent || sg.declaredGates === 0;
|
|
637
|
+
if (undeclared) add('gates-declaration', fillTemplate(WHATS['gates-declaration'], {}), `node ${q(toolPath('gates-init.mjs'))} --cwd ${q(root)}`);
|
|
638
|
+
// A wired hook is accepted: its kit file is written current whatever the declaration says (an
|
|
639
|
+
// unreadable one is the gates-inert probe's skip). An unwired one keeps the order of its offer.
|
|
640
|
+
if (sg.wired) return probeKitHook({ key: 'gate-hook', write: writeGateHook, rel: HOOK_FILE_REL, root, deps, add });
|
|
641
|
+
if (sg.declaredGates === null) throw new Error(sg.declarationError ?? 'gates.json present but unreadable');
|
|
642
|
+
if (!undeclared) add('gate-hook', fillTemplate(WHATS['gate-hook'], { n: sg.declaredGates }), `node ${q(toolPath('gate-hook.mjs'))} --apply --cwd ${q(root)}`);
|
|
656
643
|
} catch (err) {
|
|
657
644
|
skip('gate-hook', err);
|
|
658
645
|
}
|
|
@@ -1067,55 +1054,18 @@ export const probeEnforcement = ({ root, deps, add, skip }) => {
|
|
|
1067
1054
|
}
|
|
1068
1055
|
};
|
|
1069
1056
|
|
|
1070
|
-
// The read-lane offer (AD-055 Part II, Help-through-Recommendations): once the gate hook is
|
|
1071
|
-
//
|
|
1072
|
-
//
|
|
1073
|
-
//
|
|
1074
|
-
//
|
|
1075
|
-
//
|
|
1076
|
-
|
|
1057
|
+
// The read-lane offer (AD-055 Part II, Help-through-Recommendations): once the gate hook is WIRED,
|
|
1058
|
+
// offer to enable the opt-in read-only compound lane, whatever the placed hook's bytes — a stale or
|
|
1059
|
+
// absent hook under it is a planned file of `gate-hook.not-current`, which the kit route applies
|
|
1060
|
+
// before the offers. Mutually exclusive with the gate-hook offer BY CONSTRUCTION — that offer keys
|
|
1061
|
+
// on `!wired`, this one on `wired`. The apply is the gate-hook --read-lane PREVIEW one-liner (its
|
|
1062
|
+
// own currency check + posture note fire at the writer; it IS a consent flow). Converges once
|
|
1063
|
+
// lanes.json enables the lane.
|
|
1064
|
+
const probeReadLane = ({ root, deps, add, skip }) => {
|
|
1077
1065
|
try {
|
|
1078
1066
|
const sg = surveyGateHook(root, deps);
|
|
1079
1067
|
if (sg.error) throw new Error(sg.error);
|
|
1080
|
-
if (!sg.wired
|
|
1081
|
-
// Wired but the placed hook FILE is missing — the hook errors on every Bash call and the lane
|
|
1082
|
-
// is silently dark; surface it as attention with a place-first recovery (council R2-M2).
|
|
1083
|
-
const placeRecovery = () =>
|
|
1084
|
-
add('read-lane', fillTemplate(WHATS['read-lane.missing'], {}), `node ${q(toolPath('gate-hook.mjs'))} --apply --cwd ${q(root)}`, 'read-lane.missing');
|
|
1085
|
-
if (!sg.filePlaced || readsAbsent(deps, join(root, GATE_HOOK_REL))) {
|
|
1086
|
-
placeRecovery();
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
if (readReadLaneToggle(root, deps)) {
|
|
1090
|
-
// The lane is ON: converged IFF the placed hook is byte-current — a stale (pre-1.48) hook never
|
|
1091
|
-
// reads lanes.json, so the enabled lane is a silent no-op the user must reseed (council B7). The
|
|
1092
|
-
// reseed route pins the ABSOLUTE root (council R2-M3), so running it from any cwd can only
|
|
1093
|
-
// replace this repo's hook.
|
|
1094
|
-
const currency = readPlacedHookCurrency(root, deps);
|
|
1095
|
-
if (currency === HOOK_CURRENCY.CURRENT) return; // converged
|
|
1096
|
-
if (currency === HOOK_CURRENCY.ABSENT) {
|
|
1097
|
-
// The survey saw it placed and it is gone by the time we read it. The missing arm is the
|
|
1098
|
-
// honest report of that; a reseed recovery, which refuses an absent hook, is not.
|
|
1099
|
-
placeRecovery();
|
|
1100
|
-
return;
|
|
1101
|
-
}
|
|
1102
|
-
// ONE render per condition — and the item that renders is the one whose CAUSE is true. A hook
|
|
1103
|
-
// that postdates the read-lane but predates the marker key reads lanes.json perfectly well, so
|
|
1104
|
-
// this arm's "an old hook never reads lanes.json" would be a false diagnosis over it, while the
|
|
1105
|
-
// marker arm's is exact. Both carry the same reseed recovery, so deferring costs
|
|
1106
|
-
// the reader nothing and buys a true sentence. The condition is that the marker arm REALLY
|
|
1107
|
-
// rendered — never the conditions it would have used, re-derived here: each probe reads the
|
|
1108
|
-
// placed hook itself, so a hook changing between the two reads could otherwise have both defer
|
|
1109
|
-
// to the other and leave the dark lane reported by nobody.
|
|
1110
|
-
if (shared.markerStaleRendered === true) return;
|
|
1111
|
-
add(
|
|
1112
|
-
'read-lane',
|
|
1113
|
-
fillTemplate(WHATS['read-lane.stale'], {}),
|
|
1114
|
-
`node ${q(toolPath('gate-hook.mjs'))} --apply --reseed --cwd ${q(root)}`,
|
|
1115
|
-
'read-lane.stale',
|
|
1116
|
-
);
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1068
|
+
if (!sg.wired || readReadLaneToggle(root, deps)) return;
|
|
1119
1069
|
add('read-lane', fillTemplate(WHATS['read-lane'], {}), `node ${q(toolPath('gate-hook.mjs'))} --read-lane --cwd ${q(root)}`);
|
|
1120
1070
|
} catch (err) {
|
|
1121
1071
|
skip('read-lane', err);
|
|
@@ -1125,12 +1075,16 @@ const probeReadLane = ({ root, deps, add, skip, shared }) => {
|
|
|
1125
1075
|
// The state-block-guard offer (AD-075 · OPT-IN-SHIPS-INVISIBLE). This item exists because its absence
|
|
1126
1076
|
// fired: 3.14.0 shipped the detector with a mode doc, a catalog row and a README row — and no advisor
|
|
1127
1077
|
// entry — so `upgrade` reported «nothing is broken» to a user who did not have it. Its writer is
|
|
1128
|
-
// state-block-hook.mjs;
|
|
1078
|
+
// state-block-hook.mjs; acceptance is that leaf's own isStopHookWired over both settings files, and
|
|
1079
|
+
// a wired hook takes the kit arm.
|
|
1129
1080
|
const probeStateBlockHook = ({ root, deps, add, skip }) => {
|
|
1130
1081
|
try {
|
|
1131
1082
|
const project = readSettingsFile(join(root, SETTINGS_FILE), { ...deps, cwd: root });
|
|
1132
1083
|
const local = readSettingsFile(join(root, SETTINGS_LOCAL_FILE), { ...deps, cwd: root });
|
|
1133
|
-
if (isStopHookWired(project.data) || isStopHookWired(local.data))
|
|
1084
|
+
if (isStopHookWired(project.data) || isStopHookWired(local.data)) {
|
|
1085
|
+
probeKitHook({ key: 'state-block', write: writeStateBlockHook, rel: STATE_BLOCK_HOOK_FILE_REL, root, deps, add });
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1134
1088
|
add(
|
|
1135
1089
|
'state-block',
|
|
1136
1090
|
fillTemplate(WHATS['state-block'], {}),
|
|
@@ -1307,59 +1261,14 @@ export const recipeFingerprint = ({ hosts, dirs, home }) => {
|
|
|
1307
1261
|
// so no lane names it. The store's path, keys, lane registry and reader are ack-store.mjs.
|
|
1308
1262
|
|
|
1309
1263
|
// The opt-in read-lane toggle file (AD-055 Part II) — the SAME kit-owned docs/ai/lanes.json the
|
|
1310
|
-
// placed hook reads live. The read-lane item offers to enable it once the hook is
|
|
1264
|
+
// placed hook reads live. The read-lane item offers to enable it once the hook is wired.
|
|
1311
1265
|
export const LANES_FILE = 'docs/ai/lanes.json';
|
|
1312
1266
|
export const READ_LANE_KEY = 'readLane';
|
|
1313
1267
|
|
|
1314
|
-
// The placed gate hook + the bundled runtime the read-lane item byte-compares for currency (AD-055
|
|
1315
|
-
// Part II, council B7): an enabled lane over a STALE hook is a silent no-op — the pre-1.48 hook never
|
|
1316
|
-
// reads lanes.json — so it must surface as an ATTENTION reseed, not a silent convergence.
|
|
1317
|
-
const GATE_HOOK_REL = '.claude/hooks/agent-workflow-gates.mjs';
|
|
1318
|
-
const BUNDLED_HOOK_ABS = join(HERE, '..', 'references', 'hooks', 'gate-approve.mjs');
|
|
1319
|
-
|
|
1320
1268
|
// The state-block-guard wiring the advisor looks for is the writer leaf's own rule (any Stop entry of
|
|
1321
1269
|
// either settings file running the runtime); the two constants are re-exported for their readers.
|
|
1322
1270
|
export { STATE_BLOCK_HOOK_COMMAND, STATE_BLOCK_HOOK_RUNTIME };
|
|
1323
1271
|
|
|
1324
|
-
// The placed gate hook's currency, as the states a caller must tell APART (D8). Read through the
|
|
1325
|
-
// writer-class fail-closed no-follow primitive, never a bare readFile: a byte-compare that FOLLOWS a
|
|
1326
|
-
// symlink can call a placed hook current because something ELSE is — a wrong verdict, which is worse
|
|
1327
|
-
// than a missing one. `current` and `stale` are answers; `absent` is one the caller disposes of
|
|
1328
|
-
// itself (a hook that is not there belongs to the place offers, never to a refresh arm); a symlink,
|
|
1329
|
-
// a directory and an unreadable target all THROW into the probe's stated-skip lane.
|
|
1330
|
-
const HOOK_CURRENCY = Object.freeze({ CURRENT: 'current', STALE: 'stale', ABSENT: 'absent' });
|
|
1331
|
-
const readsAbsent = (deps, path) => {
|
|
1332
|
-
try {
|
|
1333
|
-
(deps.lstat ?? lstatSync)(path);
|
|
1334
|
-
return false;
|
|
1335
|
-
} catch (err) {
|
|
1336
|
-
return err?.code === ABSENT_CODE;
|
|
1337
|
-
}
|
|
1338
|
-
};
|
|
1339
|
-
|
|
1340
|
-
const readPlacedHookCurrency = (root, deps) => {
|
|
1341
|
-
if (readsAbsent(deps, join(root, GATE_HOOK_REL))) return HOOK_CURRENCY.ABSENT;
|
|
1342
|
-
const read = deps.readRegularFileNoFollow ?? readRegularFileNoFollow;
|
|
1343
|
-
const placed = read(join(root, GATE_HOOK_REL));
|
|
1344
|
-
if (placed.outcome === 'absent') return HOOK_CURRENCY.ABSENT;
|
|
1345
|
-
if (placed.outcome === 'foreign') {
|
|
1346
|
-
throw new Error(`${GATE_HOOK_REL} is a ${placed.className}, not a regular file — refusing to judge its currency`);
|
|
1347
|
-
}
|
|
1348
|
-
if (placed.outcome !== 'ok') throw new Error(`${GATE_HOOK_REL} is unreadable (${placed.code})`);
|
|
1349
|
-
const bundle = (deps.readFile ?? readFileSync)(deps.bundledHookPath ?? BUNDLED_HOOK_ABS, 'utf8');
|
|
1350
|
-
return placed.content === bundle ? HOOK_CURRENCY.CURRENT : HOOK_CURRENCY.STALE;
|
|
1351
|
-
};
|
|
1352
|
-
|
|
1353
|
-
// Does the declaration carry the marker KEY at all? The question is PRESENCE, never the value: an
|
|
1354
|
-
// older hook rejects a key it does not know whatever that key says, so `lcovProducer: false` — a
|
|
1355
|
-
// perfectly valid declaration the runner accepts — darkens such a hook exactly as `true` does. Asking
|
|
1356
|
-
// through the producer predicate would be wrong twice over: it answers yes for a cmd-recognized
|
|
1357
|
-
// producer that needs nothing from the hook, and no for the false marker that does.
|
|
1358
|
-
const declarationCarriesMarker = (root, deps) => {
|
|
1359
|
-
const declaration = loadDeclaration(root, deps);
|
|
1360
|
-
return declaration.outcome === 'loaded' && declaration.gates.some((gate) => Object.hasOwn(gate, LCOV_PRODUCER_KEY));
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
1272
|
// Read the opt-in read-lane toggle for the read-lane item. An ABSENT file (or absent docs/ai) →
|
|
1364
1273
|
// false (the lane is off — offer it). `readLane === true` → enabled (converged). A parse/IO error on
|
|
1365
1274
|
// an EXISTING file, a symlinked ancestor/leaf, an escape, or a non-object root THROWS — the probe
|
|
@@ -1564,34 +1473,43 @@ export const probeJevConnect = ({ root, deps, add, skip }) => {
|
|
|
1564
1473
|
}
|
|
1565
1474
|
};
|
|
1566
1475
|
|
|
1567
|
-
// The Jev skill
|
|
1568
|
-
//
|
|
1476
|
+
// The Jev skill (contract: kit/jev-guide, parts jev-offer and jev-copy). The targets are judged whatever the key; a
|
|
1477
|
+
// component a copy at a kit pin accepts renders the kit item, written with no question, and reads no key and no ack;
|
|
1478
|
+
// otherwise the offer, only once the key is set, so the offer and jev-connect never show together. The apply is the lane leaf's checked slot.
|
|
1569
1479
|
export const probeJevSkill = ({ root, deps, add, skip }) => {
|
|
1570
1480
|
try {
|
|
1571
1481
|
const env = deps.getenv ?? {};
|
|
1572
|
-
if (deps.keySet !== true && !keySet(env)) return;
|
|
1573
1482
|
const host = deps.jevHost ?? {};
|
|
1574
1483
|
if (typeof host.home !== 'string' || host.home === '') return;
|
|
1575
1484
|
const pins = deps.jevPins ?? SKILL_PINS;
|
|
1576
1485
|
const { dir, note } = claudeDirOf(env, host.home, host.platform);
|
|
1577
1486
|
const io = { lstat: deps.lstat ?? lstatSync, readdir: deps.readdir ?? readdirSync, readFile: deps.readFile ?? readFileSync, pins };
|
|
1578
1487
|
const judged = skillTargets({ home: host.home, claudeDir: dir }).map((target) => ({ ...target, ...skillState(target, io) }));
|
|
1579
|
-
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1488
|
+
const accepted = skillAccepted(judged);
|
|
1489
|
+
const planned = judged.filter(({ state }) => state === 'absent' || state === 'earlier');
|
|
1490
|
+
if (planned.length === 0) return;
|
|
1491
|
+
let decline = null;
|
|
1492
|
+
if (!accepted) {
|
|
1493
|
+
if (deps.keySet !== true && !keySet(env)) return;
|
|
1494
|
+
decline = factFingerprint(`${JEV_SKILL_DECLINED}${pins[0].tag}`);
|
|
1495
|
+
if (readAckValue(root, deps, ACKS_JEV_SKILL_KEY) === decline) return;
|
|
1496
|
+
}
|
|
1582
1497
|
const line = skillLine(HERE, host.platform, dir);
|
|
1583
1498
|
if (line === '') {
|
|
1584
1499
|
skip('jev-skill', new Error(NO_APPLY_LINE));
|
|
1585
1500
|
return;
|
|
1586
1501
|
}
|
|
1502
|
+
const foreign = judged.filter(({ state }) => state === 'foreign');
|
|
1503
|
+
if (accepted) {
|
|
1504
|
+
const recipe = [`writes: ${planned.map(({ path }) => printable(path)).join(', ')}`,
|
|
1505
|
+
...foreign.map(({ path, reason }) => `left untouched: ${printable(path)} — ${printable(reason)}`), ...(note ? [note] : [])];
|
|
1506
|
+
add('jev-skill', fillTemplate(WHATS['jev-skill.not-current'], { n: planned.length }), line, 'jev-skill.not-current', recipe.join('; '));
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1587
1509
|
const place = placeOf({ env, platform: host.platform, hostname: host.hostname, container: host.container });
|
|
1588
|
-
const
|
|
1589
|
-
const what = behind.length ? fillTemplate(WHATS['jev-skill.earlier'], { old: pins[Math.max(...behind)].tag, new: pins[0].tag })
|
|
1590
|
-
: WHATS['jev-skill'];
|
|
1591
|
-
const untouched = judged.filter(({ state }) => state === 'foreign')
|
|
1592
|
-
.map(({ path, reason }) => `left untouched: ${printable(path)} — ${printable(reason)}; `).join('');
|
|
1510
|
+
const untouched = foreign.map(({ path, reason }) => `left untouched: ${printable(path)} — ${printable(reason)}; `).join('');
|
|
1593
1511
|
const record = `node ${q(toolPath('ack-write.mjs'))} --lane jev-skill --fingerprint ${decline} --cwd ${q(root)}`;
|
|
1594
|
-
add('jev-skill',
|
|
1512
|
+
add('jev-skill', WHATS['jev-skill'], line, 'jev-skill',
|
|
1595
1513
|
`${place ? `run the apply in ${place}; ` : ''}${untouched}${note ? `${note}; ` : ''}${DECLINE_ALTERNATIVE}${record}`);
|
|
1596
1514
|
} catch (err) {
|
|
1597
1515
|
skip('jev-skill', err);
|
|
@@ -1692,7 +1610,7 @@ export const buildRecommendations = ({ cwd, deps = {} } = {}) => {
|
|
|
1692
1610
|
// TOO LONG for the capped WHAT and outside the pure-command apply (such as the bridge-tier
|
|
1693
1611
|
// missing-entries line or the worktrees-dir ack fallback). Single-line like apply; absent otherwise.
|
|
1694
1612
|
// Returns whether the item really RENDERED. One probe's disposition depends on another's having
|
|
1695
|
-
// spoken (
|
|
1613
|
+
// spoken (executor-vehicle yields to agents.not-current), and "the conditions still look right"
|
|
1696
1614
|
// is not the same fact as "an item exists" — the shape backstop can refuse, and a condition read
|
|
1697
1615
|
// twice can answer twice.
|
|
1698
1616
|
const add = (key, what, apply, variant = key, detail = null) => {
|
|
@@ -1717,19 +1635,21 @@ export const buildRecommendations = ({ cwd, deps = {} } = {}) => {
|
|
|
1717
1635
|
return true;
|
|
1718
1636
|
};
|
|
1719
1637
|
// The per-run scratch a probe uses to tell a LATER probe what it actually did. Written by exactly
|
|
1720
|
-
// one pair today (
|
|
1638
|
+
// one pair today (executor-vehicle yields to agents.not-current) and read in the frozen PROBES
|
|
1721
1639
|
// order, so the reader can never run first.
|
|
1722
1640
|
const shared = {};
|
|
1723
|
-
// A device node reads as absent (a sandbox mask), except under .claude/agents
|
|
1724
|
-
//
|
|
1641
|
+
// A device node reads as absent (a sandbox mask), except under .claude/agents/ and at or under
|
|
1642
|
+
// .claude/hooks/: there it is the kit writer's refusal, as the danger check reads it.
|
|
1725
1643
|
const agentsDir = join(root, AGENTS_DIR) + sep;
|
|
1644
|
+
const hooksDir = join(root, HOOKS_DIR) + sep;
|
|
1645
|
+
const kitPath = (path) => String(path).startsWith(agentsDir) || `${path}${sep}`.startsWith(hooksDir);
|
|
1726
1646
|
const contentDeps = Object.create(Object.getPrototypeOf(deps), {
|
|
1727
1647
|
...Object.getOwnPropertyDescriptors(deps),
|
|
1728
1648
|
lstat: {
|
|
1729
1649
|
enumerable: true,
|
|
1730
1650
|
value: (path, ...args) => {
|
|
1731
1651
|
const stat = (deps.lstat ?? deps.lstatSync ?? lstatSync)(path, ...args);
|
|
1732
|
-
if (!
|
|
1652
|
+
if (!kitPath(path) && (stat.isCharacterDevice?.() || stat.isBlockDevice?.())) {
|
|
1733
1653
|
throw Object.assign(new Error(`${ABSENT_CODE}: ${path}`), { code: ABSENT_CODE });
|
|
1734
1654
|
}
|
|
1735
1655
|
return stat;
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
writeHookFile,
|
|
52
52
|
} from './gate-hook.mjs';
|
|
53
53
|
import { isDirectRun } from './direct-run.mjs';
|
|
54
|
+
import { fileLine } from './distribution-files/index.mjs';
|
|
54
55
|
|
|
55
56
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
56
57
|
|
|
@@ -206,11 +207,10 @@ const STATE_BLOCK_CURRENT_LINE = 'nothing to change: the state-block hook is pla
|
|
|
206
207
|
const TRUST_POSTURE_LINE =
|
|
207
208
|
'trust posture: the guard reads the closing assistant message of each turn and writes one warning line; it runs a Node process on every turn end, reads nothing else, makes no network call and approves nothing.';
|
|
208
209
|
|
|
209
|
-
const PLACEMENT_LINES = Object.freeze({
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
210
|
+
const PLACEMENT_LINES = Object.freeze({ [PLACEMENT_CREATE]: ['would place', 'placed'], [PLACEMENT_KEEP]: ['already current', 'already current'] });
|
|
211
|
+
const placementLine = ({ placement, dryRun }) => (placement === PLACEMENT_REPLACE
|
|
212
|
+
? fileLine({ rel: STATE_BLOCK_HOOK_FILE_REL, state: 'hook' }, dryRun ? undefined : 'written', dryRun)
|
|
213
|
+
: `${STATE_BLOCK_HOOK_FILE_REL}: ${PLACEMENT_LINES[placement][dryRun ? 0 : 1]}`);
|
|
214
214
|
|
|
215
215
|
const MERGE_LINES = Object.freeze({
|
|
216
216
|
[MERGE_NO_HOOKS]: 'the hooks key with the Stop entry',
|
|
@@ -230,7 +230,7 @@ export const formatResult = (result) => {
|
|
|
230
230
|
result.dryRun
|
|
231
231
|
? 'agent-workflow state-block hook — DRY RUN (no changes; re-run with --apply)'
|
|
232
232
|
: 'agent-workflow state-block hook — APPLY',
|
|
233
|
-
` - ${
|
|
233
|
+
` - ${placementLine(result)}`,
|
|
234
234
|
formatSettingsLine(result),
|
|
235
235
|
` command: ${STATE_BLOCK_HOOK_COMMAND} (no --require-block; references/modes/state-block-guard.md says when to add it)`,
|
|
236
236
|
TRUST_POSTURE_LINE,
|
package/tools/write-lanes.mjs
CHANGED
|
@@ -35,14 +35,13 @@ export const VARIANT_LANES = Object.freeze({
|
|
|
35
35
|
'source-size.schema-1': LANE_CHAT,
|
|
36
36
|
'source-size.layout': LANE_CHAT,
|
|
37
37
|
'gate-hook': LANE_HARNESS,
|
|
38
|
-
'gate-hook.
|
|
38
|
+
'gate-hook.not-current': LANE_KIT,
|
|
39
39
|
'commit-guard': LANE_HARNESS,
|
|
40
40
|
'hook-checks': LANE_HARNESS,
|
|
41
41
|
enforcement: LANE_HARNESS,
|
|
42
42
|
'read-lane': LANE_CHAT,
|
|
43
|
-
'read-lane.stale': LANE_HARNESS,
|
|
44
|
-
'read-lane.missing': LANE_HARNESS,
|
|
45
43
|
'state-block': LANE_HARNESS,
|
|
44
|
+
'state-block.not-current': LANE_KIT,
|
|
46
45
|
'mcp-channel': LANE_HARNESS,
|
|
47
46
|
'mcp-channel.differing': LANE_HARNESS,
|
|
48
47
|
agents: LANE_HARNESS,
|
|
@@ -59,7 +58,7 @@ export const VARIANT_LANES = Object.freeze({
|
|
|
59
58
|
'profile-gap': LANE_CHAT,
|
|
60
59
|
'jev-connect': LANE_USER,
|
|
61
60
|
'jev-skill': LANE_HARNESS,
|
|
62
|
-
'jev-skill.
|
|
61
|
+
'jev-skill.not-current': LANE_KIT,
|
|
63
62
|
'spec-adoption.adopting': LANE_CHAT,
|
|
64
63
|
});
|
|
65
64
|
|
|
@@ -93,8 +92,8 @@ export const isProtectedPath = (abs, { root, home, hooksDir }) => {
|
|
|
93
92
|
|
|
94
93
|
const SETTINGS_WRITES = [SETTINGS_PATH];
|
|
95
94
|
const LOCAL_SETTINGS_WRITES = [join('.claude', 'settings.local.json')];
|
|
96
|
-
const
|
|
97
|
-
const
|
|
95
|
+
const GATE_HOOK_FILE = [join('.claude', 'hooks', 'agent-workflow-gates.mjs')];
|
|
96
|
+
const STOP_HOOK_FILE = [join('.claude', 'hooks', 'state-block-guard.mjs')];
|
|
98
97
|
const MCP_WRITES = ['.mcp.json', ...SETTINGS_WRITES];
|
|
99
98
|
const AGENT_WRITES = [join('.claude', 'agents')];
|
|
100
99
|
|
|
@@ -139,8 +138,8 @@ const createForm = (file, preview, apply, writes, envDependent = false, userStep
|
|
|
139
138
|
});
|
|
140
139
|
|
|
141
140
|
const CORE_FORM = createForm('velocity-profile.mjs', ['--cwd', '<root>'], ['--apply', '--cwd', '<root>'], SETTINGS_WRITES);
|
|
142
|
-
|
|
143
|
-
const
|
|
141
|
+
// A hook's offer writes its file and the settings entry; its kit item, over a wired hook, the file alone.
|
|
142
|
+
const hookForm = (file, writes) => createForm(file, ['--cwd', '<root>'], ['--apply', '--cwd', '<root>'], writes);
|
|
144
143
|
const AGENT_FORM = createForm('cheap-agents.mjs', ['--cwd', '<root>'], ['--apply', '--cwd', '<root>'], AGENT_WRITES);
|
|
145
144
|
const SKILL_FORM = createForm('jev-skill.mjs', ['--claude-dir', '<dir>'], ['--apply', '--claude-dir', '<dir>'], getSkillPaths, true);
|
|
146
145
|
|
|
@@ -152,11 +151,10 @@ const FORMS = Object.freeze({
|
|
|
152
151
|
['--bridge-tier', '--cwd', '<root>'], ['--apply', '--bridge-tier', '--cwd', '<root>'], SETTINGS_WRITES, true),
|
|
153
152
|
'autonomy-render': createForm('velocity-profile.mjs',
|
|
154
153
|
['--autonomy', '--cwd', '<root>'], ['--autonomy', '--apply', '--cwd', '<root>'], SETTINGS_WRITES),
|
|
155
|
-
'gate-hook':
|
|
156
|
-
'
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'state-block': createForm('state-block-hook.mjs', ['--cwd', '<root>'], ['--apply', '--cwd', '<root>'], STOP_HOOK_WRITES),
|
|
154
|
+
'gate-hook': hookForm('gate-hook.mjs', [...GATE_HOOK_FILE, ...SETTINGS_WRITES]),
|
|
155
|
+
'gate-hook.not-current': hookForm('gate-hook.mjs', GATE_HOOK_FILE),
|
|
156
|
+
'state-block': hookForm('state-block-hook.mjs', [...STOP_HOOK_FILE, ...SETTINGS_WRITES]),
|
|
157
|
+
'state-block.not-current': hookForm('state-block-hook.mjs', STOP_HOOK_FILE),
|
|
160
158
|
'mcp-channel': createForm('mcp.mjs', ['--cwd', '<root>'], ['--apply', '--cwd', '<root>'], MCP_WRITES),
|
|
161
159
|
'mcp-channel.differing': createForm('mcp.mjs',
|
|
162
160
|
['--replace', '--cwd', '<root>'], ['--replace', '--apply', '--cwd', '<root>'], MCP_WRITES),
|
|
@@ -170,7 +168,7 @@ const FORMS = Object.freeze({
|
|
|
170
168
|
(facts, argv) => 'your own step (a sudo install; the doctor prints the --apply line to run next) — '
|
|
171
169
|
+ `${TERMINAL_STEP}cd ${quoteArg(facts.root)} && ${formatCommand(argv.preview)}`),
|
|
172
170
|
'jev-skill': SKILL_FORM,
|
|
173
|
-
'jev-skill.
|
|
171
|
+
'jev-skill.not-current': SKILL_FORM,
|
|
174
172
|
'jev-connect': createForm('jev-connect.mjs', null, [], getStartupPaths, true,
|
|
175
173
|
(facts, argv) => `${OWN_STEP}it asks for the key in your terminal and the key never goes into the chat — `
|
|
176
174
|
+ `${TERMINAL_STEP}${formatCommand(argv.apply)}`),
|