@sabaiway/agent-workflow-kit 23.11.0 → 24.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 +87 -0
- package/README.md +4 -4
- package/SKILL.md +1 -1
- package/bridges/codex-cli-bridge/SKILL.md +7 -2
- package/bridges/codex-cli-bridge/bin/codex-exec-jev.test.mjs +11 -6
- package/bridges/codex-cli-bridge/bin/codex-exec.sh +72 -33
- package/bridges/codex-cli-bridge/bin/codex-exec.test.mjs +111 -3
- package/bridges/codex-cli-bridge/bin/codex-fixtures-harness.test.mjs +16 -1
- package/bridges/codex-cli-bridge/bin/codex-model-posture.test.mjs +5 -3
- package/bridges/codex-cli-bridge/bin/codex-review.sh +1 -1
- package/bridges/codex-cli-bridge/capability.json +2 -2
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/advisor-writers.md +2 -0
- package/references/agents/author.md +21 -0
- package/references/agents/executor.md +12 -6
- package/references/contracts.md +4 -4
- package/references/hooks/gate-approve.mjs +7 -8
- package/references/hooks/stage-write-guard.mjs +314 -0
- package/references/modes/agents.md +6 -4
- package/references/modes/bootstrap.md +1 -1
- package/references/modes/control-bytes.md +38 -32
- package/references/modes/flow-writer.md +10 -2
- package/references/modes/hook.md +4 -1
- package/references/modes/now.md +1 -1
- package/references/modes/procedures.md +49 -10
- package/references/modes/recipes.md +7 -7
- package/references/modes/recommendations.md +5 -4
- package/references/modes/robustness-brief.md +9 -8
- package/references/modes/set-recipe.md +1 -1
- package/references/modes/state-block-guard.md +4 -3
- package/references/modes/status.md +1 -1
- package/references/modes/upgrade.md +1 -1
- package/references/modes/worktrees.md +28 -5
- package/references/rules/story-sessions.md +2 -2
- package/references/scripts/archives/archive-caps.mjs +1 -1
- package/references/scripts/archives/archive-changelog.mjs +8 -8
- package/references/scripts/archives/archive-decisions.mjs +7 -7
- package/references/scripts/archives/archive-issues.mjs +5 -5
- package/references/scripts/archives/rotation-conservation.mjs +2 -1
- package/references/scripts/docs-size/check-docs-size.mjs +15 -15
- package/references/scripts/family.json +2 -0
- package/references/scripts/gates/kit-command-gates.mjs +7 -8
- package/references/scripts/gates/migrate-gates.mjs +10 -10
- package/references/scripts/git-hooks/install-git-hooks.mjs +13 -13
- package/references/scripts/run.mjs +1 -2
- package/references/scripts/shared/index.mjs +2 -0
- package/references/scripts/shared/locations.mjs +103 -0
- package/references/scripts/spec-schema/spec-schema.mjs +2 -1
- package/references/templates/orchestration.json +1 -1
- package/tools/ack-store.mjs +2 -1
- package/tools/advisor-matrix.mjs +2 -1
- package/tools/advisor-skip/index.mjs +73 -0
- package/tools/apply-danger-check.mjs +20 -6
- package/tools/atomic-write.mjs +3 -2
- package/tools/attribution.mjs +2 -1
- package/tools/autonomy-config.mjs +2 -1
- package/tools/bridge-wiring.mjs +13 -11
- package/tools/carriers.mjs +54 -14
- package/tools/cheap-agents-read.mjs +28 -7
- package/tools/cheap-agents.mjs +15 -10
- package/tools/checker-gates-read.mjs +6 -5
- package/tools/commands.mjs +2 -2
- package/tools/control-bytes.mjs +43 -20
- package/tools/coverage-declared/config.mjs +2 -1
- package/tools/coverage-producer.mjs +10 -9
- package/tools/delegation.mjs +7 -6
- package/tools/detect-backends.mjs +1 -1
- package/tools/dispatch-baseline.mjs +2 -1
- package/tools/distribution-files/scripts.mjs +4 -4
- package/tools/doc-parity/index.mjs +46 -0
- package/tools/doc-parity.mjs +27 -47
- package/tools/ensure-configs.mjs +2 -2
- package/tools/ensure-ops.mjs +24 -24
- package/tools/ensure-specs.mjs +7 -7
- package/tools/epic-shape-cli.mjs +2 -2
- package/tools/epic-shape-ledger.mjs +5 -5
- package/tools/epic-shape.mjs +5 -3
- package/tools/epic-store.mjs +2 -1
- package/tools/family-members.mjs +7 -5
- package/tools/family-registry.mjs +36 -30
- package/tools/feedback-record-cli.mjs +4 -5
- package/tools/flow-writer.mjs +26 -15
- package/tools/gate-hook.mjs +33 -28
- package/tools/gates-declaration.mjs +2 -1
- package/tools/gates-init.mjs +6 -5
- package/tools/git-hooks.mjs +64 -41
- package/tools/grounding.mjs +3 -2
- package/tools/hide-footprint.mjs +2 -1
- package/tools/hook-writer/index.mjs +147 -0
- package/tools/init-preflight.mjs +5 -4
- package/tools/init-project.mjs +12 -11
- package/tools/inject-methodology.mjs +3 -2
- package/tools/jev-guide.mjs +2 -2
- package/tools/known-footprint.mjs +27 -25
- package/tools/mcp-registration.mjs +6 -5
- package/tools/migration-blocks.mjs +2 -1
- package/tools/migration-notes.mjs +2 -2
- package/tools/node-evidence.mjs +4 -4
- package/tools/now-facts.mjs +5 -5
- package/tools/now-status.mjs +1 -5
- package/tools/orchestration-config.mjs +2 -1
- package/tools/orchestration-readme.mjs +7 -2
- package/tools/plan-approval/cli.mjs +45 -0
- package/tools/plan-approval/entries.mjs +109 -0
- package/tools/plan-approval/index.mjs +2 -0
- package/tools/plan-approval/record.mjs +198 -0
- package/tools/plan-files.mjs +6 -4
- package/tools/plan-shape-cli.mjs +10 -64
- package/tools/plan-shape-facts.mjs +240 -83
- package/tools/plan-shape.mjs +173 -160
- package/tools/plan-structure/cli.mjs +79 -0
- package/tools/plan-structure/index.mjs +67 -0
- package/tools/procedures.mjs +21 -17
- package/tools/profile-gaps.mjs +4 -6
- package/tools/project-rules/rules-priors.mjs +2 -0
- package/tools/project-rules/themes.mjs +6 -4
- package/tools/recipes.mjs +44 -29
- package/tools/recommendations.mjs +90 -39
- package/tools/reference-profile.mjs +2 -2
- package/tools/release-scan/index.mjs +30 -0
- package/tools/release-scan.mjs +46 -25
- package/tools/renderers.mjs +14 -8
- package/tools/repo-lex.mjs +84 -0
- package/tools/robustness-brief.mjs +14 -11
- package/tools/sandbox-masks.mjs +6 -4
- package/tools/satellite-locator.mjs +3 -2
- package/tools/script-priors.mjs +3 -2
- package/tools/session-close-check.mjs +71 -15
- package/tools/set-flow.mjs +2 -2
- package/tools/set-recipe.mjs +17 -9
- package/tools/source-size/help.mjs +4 -4
- package/tools/source-size/layout.mjs +2 -1
- package/tools/source-size/piles.mjs +2 -2
- package/tools/source-size-config.mjs +3 -3
- package/tools/source-size-refusal.mjs +4 -3
- package/tools/source-size-report.mjs +41 -13
- package/tools/spec-check-cli.mjs +159 -21
- package/tools/spec-check-ops.mjs +74 -5
- package/tools/spec-check.mjs +54 -45
- package/tools/spec-coverage-cli.mjs +3 -2
- package/tools/stage-render/cli.mjs +231 -0
- package/tools/stage-render/index.mjs +340 -0
- package/tools/stage-render/stages.json +115 -0
- package/tools/stage-write-guard/cli.mjs +64 -0
- package/tools/stage-write-guard/index.mjs +56 -0
- package/tools/state-block-hook.mjs +38 -163
- package/tools/task-brief.mjs +8 -13
- package/tools/task-thread.mjs +3 -1
- package/tools/tier-guide-facts.mjs +23 -9
- package/tools/tier-preview.mjs +15 -19
- package/tools/transition/index.mjs +10 -9
- package/tools/uninstall.mjs +26 -12
- package/tools/vehicle-settings.mjs +2 -1
- package/tools/velocity-profile.mjs +5 -6
- package/tools/view-model.mjs +7 -4
- package/tools/worktree-prompt.mjs +7 -3
- package/tools/worktrees.mjs +235 -159
- package/tools/write-lanes.mjs +20 -14
|
@@ -34,6 +34,7 @@ import { readFileSync, readdirSync, lstatSync, existsSync, statSync } from 'node
|
|
|
34
34
|
import { homedir, hostname } from 'node:os';
|
|
35
35
|
import { dirname, join, resolve, sep } from 'node:path';
|
|
36
36
|
import { fileURLToPath } from 'node:url';
|
|
37
|
+
import { DOCS_TREE, GATES, LANES, STAGE_GUARD_HOOK } from '../references/scripts/shared/index.mjs';
|
|
37
38
|
import {
|
|
38
39
|
preflightVelocityProfile,
|
|
39
40
|
planVelocityProfile,
|
|
@@ -49,11 +50,14 @@ import { deriveDoctorPlan, TRUSTED_DIRS } from './autonomy-doctor.mjs';
|
|
|
49
50
|
import { LANE_KIT, laneOf, applySlot, consoleArgv } from './write-lanes.mjs';
|
|
50
51
|
import { STATE_BLOCK_HOOK_COMMAND, STATE_BLOCK_HOOK_FILE_REL, STATE_BLOCK_HOOK_RUNTIME, isStopHookWired, writeStateBlockHook } from './state-block-hook.mjs';
|
|
51
52
|
import { HOOK_FILE_REL, HOOKS_DIR, writeGateHook } from './gate-hook.mjs';
|
|
53
|
+
import { isStageGuardWired, writeStageGuard } from './stage-write-guard/index.mjs';
|
|
52
54
|
import { detectBackends } from './detect-backends.mjs';
|
|
53
55
|
import { isDirectRun } from './direct-run.mjs';
|
|
54
56
|
import { ACTIVITIES, resolveActivityRecipe, composeReadiness, safeLine } from './recipes.mjs';
|
|
57
|
+
import { AUTHOR_ROLE, CARRY_ROLE, slotRole } from './carriers.mjs';
|
|
55
58
|
import { surveyFamily, surveyGateHook } from './family-registry.mjs';
|
|
56
59
|
import { probeSandboxMasks, needsMasksApply, patternToRel } from './sandbox-masks.mjs';
|
|
60
|
+
import { SKIP_REASON_CAP, composeSkip, renderSkip } from './advisor-skip/index.mjs';
|
|
57
61
|
import { shellQuoteArg } from './review-state.mjs';
|
|
58
62
|
import { isFinalCapableDeclaration } from './run-gates.mjs';
|
|
59
63
|
import { loadDeclaration, canonicalCheckerGates, coverageProducerPrecedes, isKitOwnedCheckerGate, movableEarlierForm } from './gates-declaration.mjs';
|
|
@@ -87,7 +91,7 @@ import { ATTRIBUTION_KEY, LEGACY_ATTRIBUTION_KEY, attributionHidesText, effectiv
|
|
|
87
91
|
import { planGlobalRemoval } from './hide-footprint.mjs';
|
|
88
92
|
import { readDeployedScripts, INSTALLER_REL, NODE_EVIDENCE, probeNodeEvidence } from './node-evidence.mjs';
|
|
89
93
|
// The vehicle READINESS comes from the read-only half — the same survey `recipes` and `status` read.
|
|
90
|
-
import { surveyExecutorVehicle, readExecutorPosture, agentsAccepted, readStamp, readFsDeps, AGENTS_DIR, WORKFLOW_STAMP, EXPECTED_WORKFLOW_VERSION } from './cheap-agents-read.mjs';
|
|
94
|
+
import { surveyExecutorVehicle, surveyAuthorVehicle, readExecutorPosture, agentsAccepted, readStamp, readFsDeps, AGENTS_DIR, AUTHOR_VEHICLE, WORKFLOW_STAMP, EXPECTED_WORKFLOW_VERSION } from './cheap-agents-read.mjs';
|
|
91
95
|
// The ack store's path, keys, lane registry, fingerprint and guarded reader live in their own leaf
|
|
92
96
|
// (contract: kit/ack-store) — `status` reads the same store, and a second copy is what drifts.
|
|
93
97
|
import {
|
|
@@ -136,7 +140,7 @@ const LAYOUT_RECORD_RECIPE = 'the hook is per clone and the config per branch: a
|
|
|
136
140
|
const REASON_AUTHOR_RECIPE = 'the reason is yours to write, with no question to the user: where you made the growth, say why this size is accepted; where an entry grew before this write (a raise after the schema move, a teammate\'s growth), write that it grew before this write and its cause was not recorded';
|
|
137
141
|
const SOURCE_SIZE_KEPT_WHAT = 'no source-size gate is declared — the size record is kept as it is; declaring the gate adds the size check to the gate matrix';
|
|
138
142
|
const LAYOUT_HELD = {
|
|
139
|
-
stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014
|
|
143
|
+
stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014 answer the size stop first, then re-run',
|
|
140
144
|
'store-root': ({ root }) => `the source-size config declares the root "${root}" at or inside the spec store docs/ai/specs \u2014 the layout record starts once that root is declared outside it`,
|
|
141
145
|
};
|
|
142
146
|
// ── the section contract tokens (doc-parity-bound in upgrade.md + the mode doc) ────────────────
|
|
@@ -205,6 +209,8 @@ export const SEVERITIES = Object.freeze({
|
|
|
205
209
|
'read-lane': SEVERITY_OPTIONAL,
|
|
206
210
|
'state-block': SEVERITY_OPTIONAL,
|
|
207
211
|
'state-block.not-current': SEVERITY_OPTIONAL,
|
|
212
|
+
'stage-guard': SEVERITY_OPTIONAL,
|
|
213
|
+
'stage-guard.not-current': SEVERITY_OPTIONAL,
|
|
208
214
|
'mcp-channel': SEVERITY_OPTIONAL,
|
|
209
215
|
'mcp-channel.differing': SEVERITY_ATTENTION,
|
|
210
216
|
agents: SEVERITY_OPTIONAL,
|
|
@@ -301,9 +307,11 @@ export const WHATS = Object.freeze({
|
|
|
301
307
|
'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',
|
|
302
308
|
'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',
|
|
303
309
|
'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`,
|
|
310
|
+
'stage-guard': 'refuse a code or test write through the edit tools while the recorded stage writes no code',
|
|
311
|
+
'stage-guard.not-current': `${STAGE_GUARD_HOOK} is absent or differs from the body the kit writes for it — written with that body, with no question`,
|
|
304
312
|
'mcp-channel': "the kit's read-only MCP server is not registered here — path questions and literal searches stay shell strings",
|
|
305
313
|
'mcp-channel.differing': 'an "{server}" MCP entry is already declared here and DIFFERS from the registration this kit copy would write',
|
|
306
|
-
agents: '{n} bundled subagent vehicle(s) not
|
|
314
|
+
agents: '{n} bundled subagent vehicle(s) not current (Claude Code) — {ro} read-only, {au} author, {ex} full-tool executor; the apply PREVIEWS first',
|
|
307
315
|
'agents.not-current': '{n} kit agent file(s) in .claude/agents/ not current — each is written with the body the kit writes for it, with no question',
|
|
308
316
|
'executor-vehicle': '{n} slot(s) configured subagent but the executor vehicle is {state}{reason} — every such slot runs solo until it is usable',
|
|
309
317
|
attribution: 'AGENTS.md says attribution off but .claude/settings.json does not hide the harness trailer and PR text',
|
|
@@ -323,7 +331,7 @@ export const WHATS = Object.freeze({
|
|
|
323
331
|
|
|
324
332
|
// ── the shape contract (D2): registry strings AND composed items stay one line under the cap ────
|
|
325
333
|
export const ITEM_LINE_CAP = 140;
|
|
326
|
-
export
|
|
334
|
+
export { SKIP_REASON_CAP };
|
|
327
335
|
|
|
328
336
|
const oneLineOf = (text) => String(text).replace(/\s*[\r\n]+\s*/g, ' ').trim();
|
|
329
337
|
// Scalar truncation-with-count — a capped value states what it dropped, never a silent cut.
|
|
@@ -363,15 +371,16 @@ export const BENEFITS = Object.freeze({
|
|
|
363
371
|
'review-recipe': 'recipe coverage — the review AND execution recipes you configured actually run instead of silently degrading',
|
|
364
372
|
'gates-declaration': 'velocity — your project’s gates run as ONE declared batch with a PASS/FAIL table',
|
|
365
373
|
'gates-inert': 'honest gates — the declared matrix verifies your project instead of reporting green over a check that ran nothing',
|
|
366
|
-
'source-size': 'maintainability — a module you can hold whole stays reviewable, and size
|
|
374
|
+
'source-size': 'maintainability — a module you can hold whole stays reviewable, and a justified size becomes a recorded exception with its reason',
|
|
367
375
|
'gate-hook': 'velocity — your own declared gate commands auto-approve byte-exactly (opt-in PreToolUse hook)',
|
|
368
376
|
'commit-guard': 'integrity — commits require the ONE green --final receipt at the exact staged fingerprint (consented pre-commit arm)',
|
|
369
377
|
'hook-checks': 'enforcement — every commit runs the checks armed here, so their findings stop the commit',
|
|
370
378
|
enforcement: 'enforcement — bundled checks and the pre-commit hook keep caps, archives, and the generated index current',
|
|
371
379
|
'read-lane': 'velocity — pipes/chains of your seeded read-only commands auto-approve instead of prompting (opt-in, conservatively classified)',
|
|
372
380
|
'state-block': 'no silent stalls — a turn ending on «you are not needed», or on work it never started, warns at once instead of waiting to be spotted',
|
|
381
|
+
'stage-guard': 'prevention — a stage that writes no code cannot write it through the edit tools',
|
|
373
382
|
'mcp-channel': 'velocity — path facts and literal searches arrive as typed tool calls whose arguments are JSON fields, never a shell string',
|
|
374
|
-
agents: 'cost and quiet — cheap-model mechanical work, no shell on a read-only vehicle
|
|
383
|
+
agents: 'cost and quiet — cheap-model mechanical work, no shell on a read-only vehicle or the author; the executor carries slices you verify',
|
|
375
384
|
'executor-vehicle': 'carrier readiness — a slot you configured subagent dispatches the subagent it names instead of silently running solo',
|
|
376
385
|
attribution: 'attribution — the harness adds no Co-Authored-By trailer, PR text or session link, as your AGENTS.md block requires',
|
|
377
386
|
'footprint-global': 'hygiene — the legacy machine-global excludes stop ignoring kit paths in every other repository on this host',
|
|
@@ -389,8 +398,9 @@ export const VARIANT_BENEFITS = Object.freeze({
|
|
|
389
398
|
'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',
|
|
390
399
|
'gate-hook.not-current': HOOK_CURRENCY_BENEFIT,
|
|
391
400
|
'state-block.not-current': HOOK_CURRENCY_BENEFIT,
|
|
401
|
+
'stage-guard.not-current': HOOK_CURRENCY_BENEFIT,
|
|
392
402
|
'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",
|
|
393
|
-
'source-size.layout': 'layout — piles past the layout limits become recorded
|
|
403
|
+
'source-size.layout': 'layout — justified piles past the layout limits become recorded exceptions with their reasons, so the commit hook can judge new ones once its layout line is armed',
|
|
394
404
|
'source-size.piles': 'layout — each recorded pile gets a queue row that plans its cleanup, so the debt is ordered work in the queue, not only a record',
|
|
395
405
|
});
|
|
396
406
|
|
|
@@ -433,6 +443,7 @@ export const OPT_IN_CAPABILITIES = Object.freeze([
|
|
|
433
443
|
{ id: 'attribution', mode: 'bootstrap', advisorKey: 'attribution' },
|
|
434
444
|
{ id: 'footprint-global', mode: 'bootstrap', advisorKey: 'footprint-global' },
|
|
435
445
|
{ id: 'state-block', mode: 'state-block-guard', advisorKey: 'state-block' },
|
|
446
|
+
{ id: 'stage-guard', mode: 'hook', advisorKey: 'stage-guard' },
|
|
436
447
|
{ id: 'sandbox-masks', mode: 'sandbox-masks', advisorKey: 'sandbox-masks' },
|
|
437
448
|
{ id: 'mcp-channel', mode: 'mcp', advisorKey: 'mcp-channel' },
|
|
438
449
|
{ id: 'worktrees-dir', mode: 'worktrees', advisorKey: 'worktrees-dir' },
|
|
@@ -605,7 +616,7 @@ const probeReviewRecipe = ({ root, deps, add, skip }) => {
|
|
|
605
616
|
const degraded = [];
|
|
606
617
|
for (const [activity, def] of Object.entries(ACTIVITIES)) {
|
|
607
618
|
for (const slot of Object.keys(def.slots)) {
|
|
608
|
-
if (config?.[activity]?.[slot] === 'subagent') continue; // the
|
|
619
|
+
if (config?.[activity]?.[slot] === 'subagent') continue; // the subagent vehicles have their own probe
|
|
609
620
|
const r = resolveActivityRecipe({ config, readiness, activity, slot });
|
|
610
621
|
if (r.degradedFrom) degraded.push(`${activity}.${slot}: configured ${r.degradedFrom} degrades to ${r.recipe} (${r.reason})`);
|
|
611
622
|
}
|
|
@@ -981,7 +992,7 @@ const probeCommitGuard = ({ root, deps, add, skip }) => {
|
|
|
981
992
|
const read = deps.readFile ?? readFileSync;
|
|
982
993
|
const gatesRaw = (() => {
|
|
983
994
|
try {
|
|
984
|
-
return String(read(join(root,
|
|
995
|
+
return String(read(join(root, GATES), 'utf8'));
|
|
985
996
|
} catch {
|
|
986
997
|
return null;
|
|
987
998
|
}
|
|
@@ -1009,7 +1020,7 @@ const probeCommitGuard = ({ root, deps, add, skip }) => {
|
|
|
1009
1020
|
const HOOK_CHECK_NAMES = { rules: 'project-rules check', layout: 'layout check', both: 'project-rules and layout checks' };
|
|
1010
1021
|
const probeHookChecks = ({ root, deps, add, skip, shared }) => {
|
|
1011
1022
|
try {
|
|
1012
|
-
if (!(deps.exists ?? existsSync)(join(root,
|
|
1023
|
+
if (!(deps.exists ?? existsSync)(join(root, DOCS_TREE))) return;
|
|
1013
1024
|
const unsafe = unsafeToolsPath(HERE);
|
|
1014
1025
|
if (unsafe !== null) throw new Error(unsafe);
|
|
1015
1026
|
const hook = readHookState(root, deps);
|
|
@@ -1045,7 +1056,7 @@ const readEnforcementNode = (path, lstat) => {
|
|
|
1045
1056
|
// a throw names the skip.
|
|
1046
1057
|
const enforcementOffer = (root, deps) => {
|
|
1047
1058
|
const lstat = deps.lstat ?? lstatSync;
|
|
1048
|
-
const docsAi = join(root,
|
|
1059
|
+
const docsAi = join(root, DOCS_TREE);
|
|
1049
1060
|
const docsAiNode = readEnforcementNode(docsAi, lstat);
|
|
1050
1061
|
if (docsAiNode === null) return false;
|
|
1051
1062
|
if (!docsAiNode.isDirectory()) throw new Error(`${docsAi} is not a plain directory`);
|
|
@@ -1115,16 +1126,31 @@ const probeStateBlockHook = ({ root, deps, add, skip }) => {
|
|
|
1115
1126
|
const local = readSettingsFile(join(root, SETTINGS_LOCAL_FILE), { ...deps, cwd: root });
|
|
1116
1127
|
if (isStopHookWired(project.data) || isStopHookWired(local.data)) {
|
|
1117
1128
|
probeKitHook({ key: 'state-block', write: writeStateBlockHook, rel: STATE_BLOCK_HOOK_FILE_REL, root, deps, add });
|
|
1118
|
-
|
|
1129
|
+
} else {
|
|
1130
|
+
add(
|
|
1131
|
+
'state-block',
|
|
1132
|
+
fillTemplate(WHATS['state-block'], {}),
|
|
1133
|
+
`node ${q(toolPath('state-block-hook.mjs'))} --apply --cwd ${q(root)}`,
|
|
1134
|
+
);
|
|
1119
1135
|
}
|
|
1120
|
-
add(
|
|
1121
|
-
'state-block',
|
|
1122
|
-
fillTemplate(WHATS['state-block'], {}),
|
|
1123
|
-
`node ${q(toolPath('state-block-hook.mjs'))} --apply --cwd ${q(root)}`,
|
|
1124
|
-
);
|
|
1125
1136
|
} catch (err) {
|
|
1126
1137
|
skip('state-block', err);
|
|
1127
1138
|
}
|
|
1139
|
+
offerStageGuard({ root, deps, add, skip });
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
const offerStageGuard = ({ root, deps, add, skip }) => {
|
|
1143
|
+
try {
|
|
1144
|
+
const project = readSettingsFile(join(root, SETTINGS_FILE), { ...deps, cwd: root });
|
|
1145
|
+
const local = readSettingsFile(join(root, SETTINGS_LOCAL_FILE), { ...deps, cwd: root });
|
|
1146
|
+
if (isStageGuardWired(project.data) || isStageGuardWired(local.data)) {
|
|
1147
|
+
probeKitHook({ key: 'stage-guard', write: writeStageGuard, rel: STAGE_GUARD_HOOK, root, deps, add });
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
add('stage-guard', fillTemplate(WHATS['stage-guard'], {}), formsApply('stage-guard', root));
|
|
1151
|
+
} catch (err) {
|
|
1152
|
+
skip('stage-guard', err);
|
|
1153
|
+
}
|
|
1128
1154
|
};
|
|
1129
1155
|
|
|
1130
1156
|
// The cheap-agents offer (OPT-IN-SHIPS-INVISIBLE). This item exists because the coverage registry
|
|
@@ -1159,7 +1185,8 @@ const probeCheapAgents = ({ root, deps, add, skip, shared }) => {
|
|
|
1159
1185
|
const bundled = new Set(readBundledAgents(deps).map((template) => template.name));
|
|
1160
1186
|
const toPlace = planned.filter((item) => bundled.has(item.name));
|
|
1161
1187
|
const executors = toPlace.filter((item) => item.name === EXECUTOR_VEHICLE).length;
|
|
1162
|
-
|
|
1188
|
+
const authors = toPlace.filter((item) => item.name === AUTHOR_VEHICLE).length;
|
|
1189
|
+
add('agents', fillTemplate(WHATS.agents, { n: toPlace.length, ex: executors, au: authors, ro: toPlace.length - executors - authors }),
|
|
1163
1190
|
`node ${q(toolPath('cheap-agents.mjs'))} --cwd ${q(root)}`, 'agents',
|
|
1164
1191
|
`hidden-mode deployments only: after the --apply the preview prints, run node ${q(toolPath('hide-footprint.mjs'))} --dir ${q(root)} --reconcile so the placed .claude/agents/ stays invisible to git status`,
|
|
1165
1192
|
);
|
|
@@ -1168,11 +1195,32 @@ const probeCheapAgents = ({ root, deps, add, skip, shared }) => {
|
|
|
1168
1195
|
}
|
|
1169
1196
|
};
|
|
1170
1197
|
|
|
1171
|
-
// The subagent carrier's
|
|
1198
|
+
// The subagent carrier's instrument per role (contract: kit/carriers). Neither neighbour can report this
|
|
1172
1199
|
// state: `probeReviewRecipe` skips a slot configured `subagent` by construction, and the `agents` key
|
|
1173
1200
|
// above names files to place or write, never a configured slot that runs solo. It yields to
|
|
1174
|
-
// `agents.not-current`, whose apply writes the
|
|
1201
|
+
// `agents.not-current`, whose apply writes the vehicles (the frozen order runs `agents` first).
|
|
1175
1202
|
const VEHICLE_BROKEN_STATES = Object.freeze(['missing', 'unusable']);
|
|
1203
|
+
const VEHICLES_SOLO_LEAD = 'slot(s) configured subagent run solo — ';
|
|
1204
|
+
|
|
1205
|
+
const formatVehicleWhat = (broken) => {
|
|
1206
|
+
const count = broken.reduce((total, vehicle) => total + vehicle.count, 0);
|
|
1207
|
+
if (broken.every((vehicle) => vehicle.role === CARRY_ROLE)) {
|
|
1208
|
+
const { state, reason } = broken[0];
|
|
1209
|
+
const room = templateBudget(WHATS['executor-vehicle']) - String(count).length - state.length - 2;
|
|
1210
|
+
return fillTemplate(WHATS['executor-vehicle'], {
|
|
1211
|
+
n: count,
|
|
1212
|
+
state,
|
|
1213
|
+
reason: reason && room > 0 ? `: ${truncatedTo(reason, room)}` : '',
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
const prefix = `${count} ${VEHICLES_SOLO_LEAD}`;
|
|
1217
|
+
const labels = broken.map(({ role, state }) => `${role === AUTHOR_ROLE ? 'author' : 'executor'} vehicle is ${state}`);
|
|
1218
|
+
const reasons = broken.filter(({ reason }) => reason).length;
|
|
1219
|
+
const room = ITEM_LINE_CAP - prefix.length - labels.join('; ').length - 2 * reasons;
|
|
1220
|
+
const reasonBudget = reasons ? Math.floor(room / reasons) : 0;
|
|
1221
|
+
return prefix + broken.map(({ reason }, index) =>
|
|
1222
|
+
labels[index] + (reason && reasonBudget > 0 ? `: ${truncatedTo(reason, reasonBudget)}` : '')).join('; ');
|
|
1223
|
+
};
|
|
1176
1224
|
|
|
1177
1225
|
// The writer's plain dry run, the call the `agents` key makes: its refusal is the last precondition.
|
|
1178
1226
|
const writerBlock = (root, deps) => {
|
|
@@ -1192,11 +1240,20 @@ const probeExecutorVehicle = ({ root, deps, add, skip, shared }) => {
|
|
|
1192
1240
|
// never an item computed over a shape nothing accepted.
|
|
1193
1241
|
const { config } = loadConfig(root, deps.readFile ?? readFileSync, deps.lstat ?? lstatSync);
|
|
1194
1242
|
const configured = Object.entries(ACTIVITIES).flatMap(([activity, def]) =>
|
|
1195
|
-
Object.keys(def.slots).filter((slot) => config?.[activity]?.[slot] === 'subagent'));
|
|
1196
|
-
if (configured.length === 0) return;
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1243
|
+
Object.keys(def.slots).filter((slot) => config?.[activity]?.[slot] === 'subagent').map((slot) => slotRole(activity, slot)));
|
|
1244
|
+
if (configured.length === 0 || shared?.agentsNotCurrent) return;
|
|
1245
|
+
const broken = [];
|
|
1246
|
+
const authorCount = configured.filter((role) => role === AUTHOR_ROLE).length;
|
|
1247
|
+
if (authorCount > 0) {
|
|
1248
|
+
const survey = (deps.surveyAuthorVehicle ?? surveyAuthorVehicle)(root, deps);
|
|
1249
|
+
if (survey.state !== 'placed') broken.push({ role: AUTHOR_ROLE, count: authorCount, state: survey.state, reason: safeLine(survey.reason ?? '') });
|
|
1250
|
+
}
|
|
1251
|
+
const carryCount = configured.filter((role) => role === CARRY_ROLE).length;
|
|
1252
|
+
if (carryCount > 0) {
|
|
1253
|
+
const survey = (deps.surveyVehicle ?? surveyExecutorVehicle)(root, deps);
|
|
1254
|
+
if (VEHICLE_BROKEN_STATES.includes(survey.state)) broken.push({ role: CARRY_ROLE, count: carryCount, state: survey.state, reason: safeLine(survey.reason ?? '') });
|
|
1255
|
+
}
|
|
1256
|
+
if (broken.length === 0) return;
|
|
1200
1257
|
const { posture, reason: settingsReason } = readExecutorPosture(root, deps);
|
|
1201
1258
|
const stamp = readStamp(join(root, WORKFLOW_STAMP), readFsDeps(deps));
|
|
1202
1259
|
const preconditions = [
|
|
@@ -1208,15 +1265,10 @@ const probeExecutorVehicle = ({ root, deps, add, skip, shared }) => {
|
|
|
1208
1265
|
// the posture is already unreadable so that reason is named once.
|
|
1209
1266
|
const blocked = posture === null ? null : writerBlock(root, deps);
|
|
1210
1267
|
if (blocked) preconditions.push(`${blocked} — fix that`);
|
|
1211
|
-
const room = templateBudget(WHATS['executor-vehicle']) - String(configured.length).length - survey.state.length - 2;
|
|
1212
1268
|
add(
|
|
1213
1269
|
'executor-vehicle',
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
state: survey.state,
|
|
1217
|
-
reason: reason && room > 0 ? `: ${truncatedTo(reason, room)}` : '',
|
|
1218
|
-
}),
|
|
1219
|
-
// The writer places a missing vehicle and writes a placed executor whose bytes differ from the derived body (an invalid
|
|
1270
|
+
formatVehicleWhat(broken),
|
|
1271
|
+
// The writer places a missing vehicle and writes a placed author or executor whose bytes differ from the kit's body (an invalid
|
|
1220
1272
|
// frontmatter or read-only tools included), so those states need no precondition; every precondition above is a refusal the apply would meet.
|
|
1221
1273
|
`node ${q(toolPath('cheap-agents.mjs'))} --apply --cwd ${q(root)}`,
|
|
1222
1274
|
'executor-vehicle',
|
|
@@ -1294,7 +1346,7 @@ export const recipeFingerprint = ({ hosts, dirs, home }) => {
|
|
|
1294
1346
|
|
|
1295
1347
|
// The opt-in read-lane toggle file (AD-055 Part II) — the SAME kit-owned docs/ai/lanes.json the
|
|
1296
1348
|
// placed hook reads live. The read-lane item offers to enable it once the hook is wired.
|
|
1297
|
-
export const LANES_FILE =
|
|
1349
|
+
export const LANES_FILE = LANES;
|
|
1298
1350
|
export const READ_LANE_KEY = 'readLane';
|
|
1299
1351
|
|
|
1300
1352
|
// The state-block-guard wiring the advisor looks for is the writer leaf's own rule (any Stop entry of
|
|
@@ -1331,7 +1383,7 @@ const readReadLaneToggle = (root, deps) => {
|
|
|
1331
1383
|
// D3: the risk-marked keys — every key here has a per-item posture note in the mode doc, surfaced
|
|
1332
1384
|
// at the consent moment; the static contract test asserts EXACT bidirectional coverage
|
|
1333
1385
|
// (risk-marked keys == mode-doc note keys — a dropped note goes red, not silent).
|
|
1334
|
-
export const RISK_NOTED_KEYS = Object.freeze(['bridge-tier', 'read-lane', 'worktrees-dir', 'gates-inert', 'source-size', 'gate-hook', 'mcp-channel', 'spec-adoption', 'enforcement', 'hook-checks', 'profile-gap', 'jev-connect', 'jev-skill', 'attribution', 'footprint-global']);
|
|
1386
|
+
export const RISK_NOTED_KEYS = Object.freeze(['bridge-tier', 'read-lane', 'worktrees-dir', 'gates-inert', 'source-size', 'gate-hook', 'stage-guard', 'mcp-channel', 'spec-adoption', 'enforcement', 'hook-checks', 'profile-gap', 'jev-connect', 'jev-skill', 'attribution', 'footprint-global']);
|
|
1335
1387
|
|
|
1336
1388
|
// The feature-spec layer's adoption state (contract: kit/spec-adoption). The canon lets a plan cite
|
|
1337
1389
|
// zero governing specs while a project adopts the layer, and nothing ever said whether adoption had
|
|
@@ -1628,9 +1680,7 @@ export const buildRecommendations = ({ cwd, deps = {} } = {}) => {
|
|
|
1628
1680
|
const root = resolve(cwd);
|
|
1629
1681
|
const items = [];
|
|
1630
1682
|
const skips = [];
|
|
1631
|
-
|
|
1632
|
-
// multiline or oversized message can never rebuild a prose wall (D2).
|
|
1633
|
-
const skip = (key, err) => skips.push({ key, reason: truncatedTo(oneLineOf(err?.message ?? String(err)), SKIP_REASON_CAP) });
|
|
1683
|
+
const skip = (key, err) => skips.push(composeSkip(key, err)); // docs/ai/specs/kit/advisor-skip.md
|
|
1634
1684
|
// The runtime shape backstop (D2): every COMPOSED item is validated at construction — a
|
|
1635
1685
|
// violation surfaces through the stated-skip lane, never a crash, never a rendered violation.
|
|
1636
1686
|
// `variant` defaults to the item key; a per-site arm passes its `<key>.<variant>` entry. It is
|
|
@@ -1723,7 +1773,7 @@ export const formatRecommendations = ({ items, skips }) => {
|
|
|
1723
1773
|
});
|
|
1724
1774
|
}
|
|
1725
1775
|
for (const s of skips) {
|
|
1726
|
-
|
|
1776
|
+
for (const line of renderSkip(s)) lines.push(line);
|
|
1727
1777
|
}
|
|
1728
1778
|
return lines.join('\n');
|
|
1729
1779
|
};
|
|
@@ -1740,7 +1790,8 @@ facts or its alternative, such as the bridge-tier missing-entries line or
|
|
|
1740
1790
|
the worktrees-dir ack fallback) · the harness or kit check line · the exact consent-gated apply one-liner}. --cwd is
|
|
1741
1791
|
REQUIRED (the target project is explicit, never inferred from the shell's current directory). The
|
|
1742
1792
|
section renders present-even-when-empty ("${RECOMMENDATIONS_EMPTY_LINE}"); a probe failure is a
|
|
1743
|
-
stated skipped-item line
|
|
1793
|
+
stated skipped-item line, its whole reason below it whenever that line lost anything.
|
|
1794
|
+
Apply lines are cwd-independent (absolute tool paths, a pinned --cwd;
|
|
1744
1795
|
the doctor item pins via a cd prefix; the ONE exception is the set-autonomy item — a
|
|
1745
1796
|
conversational skill invocation labeled "run IN the target project") and preserve each writer's
|
|
1746
1797
|
own consent semantics. The consented velocity-profile --bridge-tier seeds used bridges' code-mode
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
// No CLI (refuseDirectRun); every read goes through injected deps; nothing here writes.
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { PROFILE_DECLINES } from '../references/scripts/shared/index.mjs';
|
|
7
8
|
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
8
9
|
import { refuseDirectRun } from './direct-run.mjs';
|
|
9
10
|
|
|
10
11
|
const PROFILE_PATH = fileURLToPath(new URL('../references/reference-profile.json', import.meta.url));
|
|
11
|
-
const DECLINES_REL = 'docs/ai/profile-declines.json';
|
|
12
12
|
const PROFILE_KEYS = ['items', 'lineage', 'name', 'schema'];
|
|
13
13
|
const ITEM_KEYS = ['has', 'id', 'story'];
|
|
14
14
|
const RECORD_KEYS = ['declined', 'schema'];
|
|
@@ -53,7 +53,7 @@ export const readShippedProfile = (deps = {}) => {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
export const readDeclines = (root, deps = {}) => {
|
|
56
|
-
const read = readRegularFileNoFollow(join(root,
|
|
56
|
+
const read = readRegularFileNoFollow(join(root, PROFILE_DECLINES), deps);
|
|
57
57
|
if (read.outcome === ABSENT) return { absent: true };
|
|
58
58
|
if (read.outcome !== OK) {
|
|
59
59
|
return { refusal: read.className === SYMLINK_CLASS ? 'declines-symlink' : 'declines-unreadable' };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { composeCheckerBlock } from '../checker-block/index.mjs';
|
|
2
|
+
|
|
3
|
+
export const CHECKER_NAME = 'release-scan';
|
|
4
|
+
export const UNEXPECTED_REMEDY = 'fix the cause the stack below names, then re-run';
|
|
5
|
+
const TARGET_REMEDY = 'fix or drop each mis-aimed target above as its finding says, then re-run';
|
|
6
|
+
const SCAN_REMEDY = 'remove each attribution, reviewer identity, and hardcoded version claim above, then re-run';
|
|
7
|
+
|
|
8
|
+
export const composeScanBlock = ({ cwd, misaimed, findings, after }) => {
|
|
9
|
+
const classes = [];
|
|
10
|
+
const remedies = [];
|
|
11
|
+
if (misaimed.length) {
|
|
12
|
+
classes.push(`${misaimed.length} mis-aimed target(s)`);
|
|
13
|
+
remedies.push(TARGET_REMEDY);
|
|
14
|
+
}
|
|
15
|
+
if (findings.length) {
|
|
16
|
+
classes.push(`${findings.length} finding(s)`);
|
|
17
|
+
remedies.push(SCAN_REMEDY);
|
|
18
|
+
}
|
|
19
|
+
return composeCheckerBlock({
|
|
20
|
+
name: CHECKER_NAME,
|
|
21
|
+
root: cwd,
|
|
22
|
+
failed: classes.join('; '),
|
|
23
|
+
findings: [
|
|
24
|
+
...misaimed.map(({ path, status, remedy }) => ({ path, text: `${status} — ${remedy}` })),
|
|
25
|
+
...findings.map(({ file, line, kind, detail }) => ({ path: file, line, text: `${kind} — ${detail}` })),
|
|
26
|
+
],
|
|
27
|
+
remedies,
|
|
28
|
+
after,
|
|
29
|
+
});
|
|
30
|
+
};
|
package/tools/release-scan.mjs
CHANGED
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Pure `scanText` for unit fixtures; `scanPaths`/CLI for the release tree. Dependency-free, Node >= 22.
|
|
12
12
|
|
|
13
|
-
import { readFileSync,
|
|
13
|
+
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
14
14
|
import { join, extname, basename, resolve } from 'node:path';
|
|
15
|
+
import { composeUsageRefusal } from '../references/scripts/shared/index.mjs';
|
|
16
|
+
import { runCheckerTail } from './checker-block/index.mjs';
|
|
15
17
|
import { isDirectRun } from './direct-run.mjs';
|
|
18
|
+
import { CHECKER_NAME, UNEXPECTED_REMEDY, composeScanBlock } from './release-scan/index.mjs';
|
|
16
19
|
|
|
17
20
|
export const ALLOWLIST = [
|
|
18
21
|
'codex-cli-bridge',
|
|
@@ -204,16 +207,25 @@ export const TARGET = Object.freeze({
|
|
|
204
207
|
|
|
205
208
|
const GLOB_META_RE = /[*?[\]]/;
|
|
206
209
|
|
|
210
|
+
const statTarget = (path) => {
|
|
211
|
+
try {
|
|
212
|
+
return statSync(path);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (error?.code !== 'ENOENT') throw error;
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
207
219
|
// PURE-ish (one fs read): classify ONE caller-named target and collect the files it contributes.
|
|
208
220
|
// Every zero-contribution status names its own cause, so the refusal can state the remedy rather
|
|
209
221
|
// than a bare count (a count without a location is the defect class this family bans).
|
|
210
222
|
export const classifyTarget = (path) => {
|
|
211
|
-
|
|
223
|
+
const st = statTarget(path);
|
|
224
|
+
if (st === null) {
|
|
212
225
|
return GLOB_META_RE.test(path)
|
|
213
226
|
? { path, status: TARGET.unmatchedGlob, files: [] }
|
|
214
227
|
: { path, status: TARGET.missing, files: [] };
|
|
215
228
|
}
|
|
216
|
-
const st = statSync(path);
|
|
217
229
|
const name = basename(path);
|
|
218
230
|
if (st.isDirectory() && EXCLUDE_DIR_NAMES.has(name)) return { path, status: TARGET.excluded, files: [] };
|
|
219
231
|
if (st.isFile() && (EXCLUDE_FILE_NAMES.has(name) || !TEXT_EXT.has(extname(path)) || path.endsWith('.tgz'))) {
|
|
@@ -244,34 +256,43 @@ const findingsIn = (targets, opts) => {
|
|
|
244
256
|
|
|
245
257
|
export const scanPaths = (paths, opts = {}) => findingsIn(paths.map((p) => classifyTarget(resolve(p))), opts);
|
|
246
258
|
|
|
247
|
-
|
|
259
|
+
const USAGE = 'usage: release-scan.mjs [--report] <path>...';
|
|
260
|
+
|
|
261
|
+
export const runScan = (argv, cwd = process.cwd()) => {
|
|
248
262
|
const reportOnly = argv.includes('--report');
|
|
249
263
|
const paths = argv.filter((a) => a !== '--report');
|
|
250
264
|
if (paths.length === 0) {
|
|
251
|
-
|
|
252
|
-
return 2;
|
|
265
|
+
return { code: 2, lines: composeUsageRefusal({ name: CHECKER_NAME, failed: 'no path was given to scan', usage: USAGE }) };
|
|
253
266
|
}
|
|
254
|
-
const targets = paths.map((
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
console.log(`[release-scan] target ${target.path} contributed NO file (${target.status}) — ${TARGET_REMEDY[target.status]}`);
|
|
267
|
+
const targets = paths.map((path) => classifyTarget(resolve(cwd, path)));
|
|
268
|
+
const skipped = targets.filter(({ status }) => status === TARGET.unmatchedGlob)
|
|
269
|
+
.map(({ path }) => `[release-scan] skipped ${path} — no file matched this glob (an optional target, stated not silent).`);
|
|
270
|
+
const misaimed = targets.filter(({ status }) => TARGET_REMEDY[status] !== undefined)
|
|
271
|
+
.map(({ path, status }) => ({ path, status, remedy: TARGET_REMEDY[status] }));
|
|
272
|
+
const findings = findingsIn(targets);
|
|
273
|
+
if (findings.length === 0 && misaimed.length === 0) {
|
|
274
|
+
return { code: 0, lines: [...skipped, '[release-scan] clean — no AI attribution or reviewer-round identity found.'] };
|
|
263
275
|
}
|
|
264
|
-
|
|
265
|
-
|
|
276
|
+
if (!reportOnly) return { code: 1, lines: composeScanBlock({ cwd: resolve(cwd), misaimed, findings, after: skipped }) };
|
|
277
|
+
const lines = [
|
|
278
|
+
...skipped,
|
|
279
|
+
...misaimed.map(({ path, status, remedy }) => `[release-scan] target ${path} contributed NO file (${status}) — ${remedy}`),
|
|
280
|
+
...findings.map(({ kind, file, line, detail }) => `[${kind}] ${file}:${line} — ${detail}`),
|
|
281
|
+
];
|
|
266
282
|
if (misaimed.length > 0) {
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
if (report.length > 0) console.log(`\n[release-scan] ${report.length} finding(s).`);
|
|
270
|
-
if (report.length === 0 && misaimed.length === 0) {
|
|
271
|
-
console.log('[release-scan] clean — no AI attribution or reviewer-round identity found.');
|
|
272
|
-
return 0;
|
|
283
|
+
lines.push('', `[release-scan] ${misaimed.length} mis-aimed target(s) — this run proves nothing about them, so the clean verdict is refused.`);
|
|
273
284
|
}
|
|
274
|
-
|
|
285
|
+
if (findings.length > 0) lines.push('', `[release-scan] ${findings.length} finding(s).`);
|
|
286
|
+
return { code: 0, lines };
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export const main = (argv) => {
|
|
290
|
+
const { code, lines } = runScan(argv);
|
|
291
|
+
for (const line of lines) console.log(line);
|
|
292
|
+
return code;
|
|
275
293
|
};
|
|
276
294
|
|
|
277
|
-
if (isDirectRun(import.meta.url))
|
|
295
|
+
if (isDirectRun(import.meta.url)) {
|
|
296
|
+
runCheckerTail({ name: CHECKER_NAME, exitCode: 1, remedy: UNEXPECTED_REMEDY },
|
|
297
|
+
() => runScan(process.argv.slice(2)), process);
|
|
298
|
+
}
|
package/tools/renderers.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { BLOCK_TITLES, SETTINGS_LABELS, glyphsFor, NO_DEPLOYMENT } from './presentation.mjs';
|
|
11
11
|
import { describeAdoption } from './spec-adoption.mjs';
|
|
12
|
+
import { AUTHOR_ROLE } from './carriers.mjs';
|
|
12
13
|
|
|
13
14
|
const MEMBER_COL = 20;
|
|
14
15
|
const VERSION_COL = 12;
|
|
@@ -22,7 +23,7 @@ const ACTIONABLE_ADR_LAYOUTS = Object.freeze(['old', 'old-unrotated']);
|
|
|
22
23
|
|
|
23
24
|
const DEGRADE_ARROW = '←';
|
|
24
25
|
const EMPTY_CELL = '—';
|
|
25
|
-
const
|
|
26
|
+
const UNKNOWN_VEHICLE = 'unknown (the installed kit predates the field)';
|
|
26
27
|
|
|
27
28
|
const SGR = Object.freeze({ bold: '\x1b[1m', reset: '\x1b[0m' });
|
|
28
29
|
const ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
@@ -127,7 +128,7 @@ const renderSettings = (vm, { color, glyph }) => {
|
|
|
127
128
|
else if (s.recipes) {
|
|
128
129
|
const rows = s.recipes.pairs.map((p) => {
|
|
129
130
|
const source = p.source ? ` (${p.source})` : '';
|
|
130
|
-
const recovery = p.degradedFrom === 'subagent' ?
|
|
131
|
+
const recovery = p.degradedFrom === 'subagent' ? ` — runs solo until the ${p.role === AUTHOR_ROLE ? 'author' : 'executor'} vehicle is usable (/agent-workflow-kit agents)` : '';
|
|
131
132
|
const degraded = p.degradedFrom ? ` ${DEGRADE_ARROW} degraded from ${p.degradedFrom}${recovery}` : '';
|
|
132
133
|
return `${p.key}: ${p.recipe}${source}${degraded}`;
|
|
133
134
|
});
|
|
@@ -150,16 +151,21 @@ const renderSettings = (vm, { color, glyph }) => {
|
|
|
150
151
|
lines.push(` ${pad(SETTINGS_LABELS.velocity, SETTINGS_COL)}defaultMode=${String(s.velocity.defaultMode)} · allow project/local=${s.velocity.allow.project}/${s.velocity.allow.local}`);
|
|
151
152
|
}
|
|
152
153
|
// cheap agents — the kit-placed .claude/agents/ vehicles: placed count vs the bundle, then the
|
|
153
|
-
// split the subagent carrier turns on — the read-only vehicles and the
|
|
154
|
-
//
|
|
154
|
+
// split the subagent carrier turns on — the read-only vehicles, the author and the executor, whose states
|
|
155
|
+
// decide whether a slot configured `subagent` can ride its role's vehicle (an unusable one carries its reason).
|
|
155
156
|
if (s.agents?.error) {
|
|
156
|
-
const partial =
|
|
157
|
-
|
|
157
|
+
const partial = [
|
|
158
|
+
s.agents.author ? `author ${s.agents.author}${s.agents.authorReason ? ` (${s.agents.authorReason})` : ''}` : '',
|
|
159
|
+
s.agents.executor ? `executor ${s.agents.executor}${s.agents.executorReason ? ` (${s.agents.executorReason})` : ''}` : '',
|
|
160
|
+
].filter(Boolean).join(', ');
|
|
161
|
+
lines.push(` ${pad(SETTINGS_LABELS.agents, SETTINGS_COL)}error: ${s.agents.error}${partial ? ` — ${partial}` : ''}`);
|
|
158
162
|
}
|
|
159
163
|
else if (s.agents) {
|
|
164
|
+
const authorReason = s.agents.authorReason ? ` (${s.agents.authorReason})` : '';
|
|
160
165
|
const reason = s.agents.executorReason ? ` (${s.agents.executorReason})` : '';
|
|
161
|
-
const
|
|
162
|
-
|
|
166
|
+
const author = s.agents.author == null ? UNKNOWN_VEHICLE : `${s.agents.author}${authorReason}`;
|
|
167
|
+
const executor = s.agents.executor == null ? UNKNOWN_VEHICLE : `${s.agents.executor}${reason}`;
|
|
168
|
+
lines.push(` ${pad(SETTINGS_LABELS.agents, SETTINGS_COL)}${s.agents.placed}/${s.agents.bundled} placed — ${s.agents.readOnly} read-only, author ${author}, executor ${executor}`);
|
|
163
169
|
}
|
|
164
170
|
// gate hook — the opt-in PreToolUse gate-approval hook: wired / file placed / declaration present /
|
|
165
171
|
// declared gate count (null → '?' — unknown is shown as unknown, never as a number).
|
package/tools/repo-lex.mjs
CHANGED
|
@@ -22,6 +22,8 @@ export const lexicalRepoRelative = (rel) => {
|
|
|
22
22
|
export const RESERVED_DIR = '.agent-workflow';
|
|
23
23
|
export const NEVER_WALKED = Object.freeze(['.git', 'node_modules', RESERVED_DIR]);
|
|
24
24
|
|
|
25
|
+
export const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\/]/gu, '\\$&');
|
|
26
|
+
|
|
25
27
|
// POSIX single-quote for pasteable command rendering (display only — never an execution boundary).
|
|
26
28
|
export const shellQuoteArg = (s) => (/^[A-Za-z0-9_/.\-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`);
|
|
27
29
|
|
|
@@ -93,3 +95,85 @@ export const isSeedablePathToken = (token) =>
|
|
|
93
95
|
!/\s/u.test(token) &&
|
|
94
96
|
!hasShellMetacharacter(token) &&
|
|
95
97
|
!PATH_BREAKING_CHARACTERS.some((ch) => token.includes(ch));
|
|
98
|
+
|
|
99
|
+
export const parseStrictJson = (text) => {
|
|
100
|
+
const source = String(text);
|
|
101
|
+
const cursor = { index: 0 };
|
|
102
|
+
const skipWhitespace = () => {
|
|
103
|
+
while (/\s/.test(source[cursor.index] ?? '')) cursor.index += 1;
|
|
104
|
+
};
|
|
105
|
+
const readString = () => {
|
|
106
|
+
const start = cursor.index;
|
|
107
|
+
cursor.index += 1;
|
|
108
|
+
while (cursor.index < source.length) {
|
|
109
|
+
if (source[cursor.index] === '\\') {
|
|
110
|
+
cursor.index += 2;
|
|
111
|
+
} else if (source[cursor.index] === '"') {
|
|
112
|
+
cursor.index += 1;
|
|
113
|
+
return JSON.parse(source.slice(start, cursor.index));
|
|
114
|
+
} else {
|
|
115
|
+
cursor.index += 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
};
|
|
120
|
+
const childPath = (path, key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)
|
|
121
|
+
? `${path}.${key}`
|
|
122
|
+
: `${path}[${JSON.stringify(key)}]`;
|
|
123
|
+
const scanValue = (path) => {
|
|
124
|
+
skipWhitespace();
|
|
125
|
+
if (source[cursor.index] === '{') {
|
|
126
|
+
cursor.index += 1;
|
|
127
|
+
skipWhitespace();
|
|
128
|
+
const seen = new Set();
|
|
129
|
+
if (source[cursor.index] === '}') {
|
|
130
|
+
cursor.index += 1;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
while (cursor.index < source.length) {
|
|
134
|
+
const key = readString();
|
|
135
|
+
if (seen.has(key)) throw new SyntaxError(`duplicate JSON key ${JSON.stringify(key)} at ${path}`);
|
|
136
|
+
seen.add(key);
|
|
137
|
+
skipWhitespace();
|
|
138
|
+
cursor.index += 1;
|
|
139
|
+
scanValue(childPath(path, key));
|
|
140
|
+
skipWhitespace();
|
|
141
|
+
if (source[cursor.index] === '}') {
|
|
142
|
+
cursor.index += 1;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
cursor.index += 1;
|
|
146
|
+
skipWhitespace();
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (source[cursor.index] === '[') {
|
|
151
|
+
cursor.index += 1;
|
|
152
|
+
skipWhitespace();
|
|
153
|
+
if (source[cursor.index] === ']') {
|
|
154
|
+
cursor.index += 1;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const position = { item: 0 };
|
|
158
|
+
while (cursor.index < source.length) {
|
|
159
|
+
scanValue(`${path}[${position.item}]`);
|
|
160
|
+
position.item += 1;
|
|
161
|
+
skipWhitespace();
|
|
162
|
+
if (source[cursor.index] === ']') {
|
|
163
|
+
cursor.index += 1;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
cursor.index += 1;
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (source[cursor.index] === '"') {
|
|
171
|
+
readString();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
while (cursor.index < source.length && !/[\s,}\]]/.test(source[cursor.index])) cursor.index += 1;
|
|
175
|
+
};
|
|
176
|
+
// the duplicate scan tolerates malformed tails (EOF-safe returns); JSON.parse then rejects them
|
|
177
|
+
scanValue('$');
|
|
178
|
+
return JSON.parse(source);
|
|
179
|
+
};
|