@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
|
@@ -17,6 +17,9 @@ import { nearestExistingDir, worktreesGrantDir, worktreesGrantHoldsHome } from '
|
|
|
17
17
|
import { loadConfig } from './orchestration-config.mjs';
|
|
18
18
|
import { HOOK_FILE_REL, HOOKS_DIR, buildHookSettingsEntry, isHookWired, mergeHookEntry, writeGateHook } from './gate-hook.mjs';
|
|
19
19
|
import { STATE_BLOCK_HOOK_FILE_REL, buildStopHookEntry, isStopHookWired, mergeStopEntry, writeStateBlockHook } from './state-block-hook.mjs';
|
|
20
|
+
import { buildStageGuardEntry, isStageGuardWired, writeStageGuard } from './stage-write-guard/index.mjs';
|
|
21
|
+
import { mergeHookEntryInto } from './hook-writer/index.mjs';
|
|
22
|
+
import { STAGE_GUARD_HOOK } from '../references/scripts/shared/index.mjs';
|
|
20
23
|
import { writeMcp } from './mcp.mjs';
|
|
21
24
|
import { ENABLED_KEY, MCP_JSON_REL, SERVERS_KEY, SERVER_NAME, allowRulesFor, buildServerEntry } from './mcp-registration.mjs';
|
|
22
25
|
import { AGENTS_DIR, agentsAccepted, kitAgentNames, writeCheapAgents } from './cheap-agents.mjs';
|
|
@@ -35,7 +38,10 @@ const SKILL_KIT = 'jev-skill.not-current';
|
|
|
35
38
|
const SKILL_VARIANTS = ['jev-skill', SKILL_KIT];
|
|
36
39
|
const VELOCITY_VARIANTS = ['velocity-core', 'kit-tools-tier', 'bridge-tier'];
|
|
37
40
|
const [GATE_KIT, STOP, STOP_KIT] = ['gate-hook.not-current', 'state-block', 'state-block.not-current'];
|
|
38
|
-
const [
|
|
41
|
+
const [GUARD, GUARD_KIT] = ['stage-guard', 'stage-guard.not-current'];
|
|
42
|
+
const [HOOK_VARIANTS, STOP_VARIANTS, GUARD_VARIANTS, KIT_HOOKS] = [['gate-hook', GATE_KIT], [STOP, STOP_KIT], [GUARD, GUARD_KIT], [GATE_KIT, STOP_KIT, GUARD_KIT]];
|
|
43
|
+
const KIT_HOOK_WIRED = Object.freeze({ [GATE_KIT]: isHookWired, [STOP_KIT]: isStopHookWired, [GUARD_KIT]: isStageGuardWired });
|
|
44
|
+
const PRE_TOOL_USE = 'PreToolUse';
|
|
39
45
|
const MCP_VARIANTS = ['mcp-channel', 'mcp-channel.differing'];
|
|
40
46
|
const AGENTS_KIT = 'agents.not-current';
|
|
41
47
|
const AGENT_VARIANTS = ['agents', 'executor-vehicle', AGENTS_KIT];
|
|
@@ -43,7 +49,7 @@ const GIT_VARIANTS = ['enforcement', 'commit-guard', 'hook-checks'];
|
|
|
43
49
|
const WORKTREES = 'worktrees-dir';
|
|
44
50
|
const ATTRIBUTION = 'attribution';
|
|
45
51
|
const FOOTPRINT = 'footprint-global';
|
|
46
|
-
const VARIANTS = [...VELOCITY_VARIANTS, 'autonomy-render', ...HOOK_VARIANTS, ...STOP_VARIANTS, ...MCP_VARIANTS, ...AGENT_VARIANTS, ...SKILL_VARIANTS, ...GIT_VARIANTS, WORKTREES, ATTRIBUTION, FOOTPRINT];
|
|
52
|
+
const VARIANTS = [...VELOCITY_VARIANTS, 'autonomy-render', ...HOOK_VARIANTS, ...STOP_VARIANTS, ...GUARD_VARIANTS, ...MCP_VARIANTS, ...AGENT_VARIANTS, ...SKILL_VARIANTS, ...GIT_VARIANTS, WORKTREES, ATTRIBUTION, FOOTPRINT];
|
|
47
53
|
const HOOK_KEYS = ['hooks.PreToolUse', 'hooks.Stop'];
|
|
48
54
|
const CREDENTIALS = 'sandbox.credentials.envVars';
|
|
49
55
|
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -171,7 +177,9 @@ const unmaskedLstat = (facts) => (path, ...args) => {
|
|
|
171
177
|
if (stat?.isCharacterDevice() && SETTINGS_FILES.some((rel) => path === join(facts.root, rel))) throw Object.assign(new Error(`ENOENT: ${path}`), { code: 'ENOENT' });
|
|
172
178
|
return stat;
|
|
173
179
|
};
|
|
174
|
-
const kitHookWired = (variant, facts) => SETTINGS_FILES.some((rel) =>
|
|
180
|
+
const kitHookWired = (variant, facts) => SETTINGS_FILES.some((rel) => KIT_HOOK_WIRED[variant](readSettingsFile(join(facts.root, rel), { lstat: unmaskedLstat(facts), cwd: facts.root }).data));
|
|
181
|
+
const hookFileOf = (variant) => HOOK_VARIANTS.includes(variant) ? HOOK_FILE_REL
|
|
182
|
+
: STOP_VARIANTS.includes(variant) ? STATE_BLOCK_HOOK_FILE_REL : GUARD_VARIANTS.includes(variant) ? STAGE_GUARD_HOOK : null;
|
|
175
183
|
const skillIo = (deps) => ({ lstat: deps.lstat ?? lstatSync, readdir: deps.readdir ?? readdirSync, readFile: deps.readFile ?? readFileSync, pins: deps.pins });
|
|
176
184
|
|
|
177
185
|
export const scopeOf = (variant, facts, deps = {}) => {
|
|
@@ -207,6 +215,7 @@ export const scopeOf = (variant, facts, deps = {}) => {
|
|
|
207
215
|
}
|
|
208
216
|
if (variant === 'gate-hook') set('hooks.PreToolUse', [buildHookSettingsEntry()]);
|
|
209
217
|
else if (variant === STOP) set('hooks.Stop', [buildStopHookEntry()]);
|
|
218
|
+
else if (variant === GUARD) set(`hooks.${PRE_TOOL_USE}`, [buildStageGuardEntry()]);
|
|
210
219
|
else if (MCP_VARIANTS.includes(variant)) {
|
|
211
220
|
set(`${SERVERS_KEY}.${SERVER_NAME}`, [buildServerEntry(join(facts.toolsDir, 'mcp-server.mjs'))]);
|
|
212
221
|
set(ENABLED_KEY, [SERVER_NAME]);
|
|
@@ -217,11 +226,12 @@ export const scopeOf = (variant, facts, deps = {}) => {
|
|
|
217
226
|
// The kit skill variant's scope holds only while the check's own judgement accepts the component, never read from the plan.
|
|
218
227
|
const targets = variant !== SKILL_KIT || skillAccepted(judged.map((target) => ({ ...target, ...skillState(target, skillIo(deps)) }))) ? judged : [];
|
|
219
228
|
const accepted = !KIT_HOOKS.includes(variant) || kitHookWired(variant, facts);
|
|
220
|
-
const
|
|
229
|
+
const hookFile = accepted ? hookFileOf(variant) : null;
|
|
230
|
+
const filePaths = hookFile === null ? [] : [join(facts.root, hookFile)];
|
|
221
231
|
const directories = !accepted || SKILL_VARIANTS.includes(variant) || variant === FOOTPRINT ? [] : [join(facts.root, CLAUDE_DIR)];
|
|
222
232
|
const globalFile = variant === FOOTPRINT ? footprintPlan(facts, deps)?.source : undefined;
|
|
223
233
|
if (globalFile) filePaths.push(globalFile);
|
|
224
|
-
if (
|
|
234
|
+
if (hookFile !== null) directories.push(join(facts.root, HOOKS_DIR));
|
|
225
235
|
if (AGENT_VARIANTS.includes(variant)) directories.push(join(facts.root, AGENTS_DIR));
|
|
226
236
|
const kitNames = variant === AGENTS_KIT ? kitAgentNames(facts.root) : [];
|
|
227
237
|
if (kitNames.length && agentsAccepted(facts.root, kitNames)) filePaths.push(...kitNames.map((name) => join(facts.root, AGENTS_DIR, name)));
|
|
@@ -265,7 +275,7 @@ const regularBytes = (path) => lstatSync(path, { throwIfNoEntry: false })?.isFil
|
|
|
265
275
|
const halted = (lines) => Object.assign(new Error(lines.join('\n')), { code: 'CHECK_HALTED', lines });
|
|
266
276
|
const maskedFiles = (variant, facts) => {
|
|
267
277
|
const paths = VELOCITY_VARIANTS.includes(variant) || variant === 'autonomy-render' || variant === 'gate-hook'
|
|
268
|
-
|| variant === STOP || variant === WORKTREES || variant === ATTRIBUTION ? [SETTINGS_FILE, SETTINGS_LOCAL_FILE] : MCP_VARIANTS.includes(variant) ? [MCP_JSON_REL, SETTINGS_FILE] : [];
|
|
278
|
+
|| variant === STOP || variant === GUARD || variant === WORKTREES || variant === ATTRIBUTION ? [SETTINGS_FILE, SETTINGS_LOCAL_FILE] : MCP_VARIANTS.includes(variant) ? [MCP_JSON_REL, SETTINGS_FILE] : [];
|
|
269
279
|
return paths.flatMap((path) => lstatSync(join(facts.root, path), { throwIfNoEntry: false })?.isCharacterDevice()
|
|
270
280
|
? [`masked: ${path}`] : []);
|
|
271
281
|
};
|
|
@@ -310,6 +320,10 @@ export const plannedChange = (variant, facts, deps = {}) => {
|
|
|
310
320
|
const plan = (deps.writeStateBlockHook ?? writeStateBlockHook)({ cwd: facts.root, dryRun: true }, writerDeps);
|
|
311
321
|
if (plan.mergePlanned) addFile(SETTINGS_FILE, plan.projectSettings.data, mergeStopEntry(plan.projectSettings.data));
|
|
312
322
|
if (['create', 'replace'].includes(plan.placement)) writes.push({ path: join(facts.root, STATE_BLOCK_HOOK_FILE_REL), bytes: plan.bundleContent });
|
|
323
|
+
} else if (GUARD_VARIANTS.includes(variant)) {
|
|
324
|
+
const plan = (deps.writeStageGuard ?? writeStageGuard)({ cwd: facts.root, dryRun: true }, writerDeps);
|
|
325
|
+
if (plan.mergePlanned) addFile(SETTINGS_FILE, plan.projectSettings.data, mergeHookEntryInto(plan.projectSettings.data, PRE_TOOL_USE, buildStageGuardEntry()));
|
|
326
|
+
if (plan.placePlanned) writes.push({ path: join(facts.root, STAGE_GUARD_HOOK), bytes: plan.bundleContent });
|
|
313
327
|
} else if (MCP_VARIANTS.includes(variant)) {
|
|
314
328
|
const result = writeMcp({ cwd: facts.root, dryRun: true, replace: variant === 'mcp-channel.differing' }, writerDeps);
|
|
315
329
|
const { plan, registration } = result;
|
package/tools/atomic-write.mjs
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import { lstatSync, writeFileSync, renameSync, linkSync, rmSync, mkdirSync } from 'node:fs';
|
|
35
35
|
import { randomBytes } from 'node:crypto';
|
|
36
36
|
import { dirname, join } from 'node:path';
|
|
37
|
+
import { DOCS, DOCS_TREE } from '../references/scripts/shared/index.mjs';
|
|
37
38
|
import { assertContainedRealPath } from './fs-safe.mjs';
|
|
38
39
|
|
|
39
40
|
export const ATOMIC_WRITE_STOP = 'ATOMIC_WRITE_STOP';
|
|
@@ -61,7 +62,7 @@ export const assertDocsAiDeployment = (cwd, deps = {}, opts = {}) => {
|
|
|
61
62
|
const stop = opts.stop ?? defaultStop;
|
|
62
63
|
const noun = opts.noun ?? 'a file';
|
|
63
64
|
const rel = opts.rel ?? 'under docs/ai';
|
|
64
|
-
const docsAi = join(cwd,
|
|
65
|
+
const docsAi = join(cwd, DOCS_TREE);
|
|
65
66
|
// Parent-chain preflight (AD-052, Issue-011 residual 3): refuse a symlinked cwd ROOT or a
|
|
66
67
|
// symlinked `docs` PARENT before any read — the walk the write path already enforces
|
|
67
68
|
// (writeContainedFileAtomic), aligned onto the gate every consumer runs first. The walk covers
|
|
@@ -71,7 +72,7 @@ export const assertDocsAiDeployment = (cwd, deps = {}, opts = {}) => {
|
|
|
71
72
|
// "no deployment" STOP below. The walk throws a plain Error; re-throw as the CALLER's typed
|
|
72
73
|
// stop so every consumer's `.code` contract holds.
|
|
73
74
|
try {
|
|
74
|
-
assertContainedRealPath(cwd, join(cwd,
|
|
75
|
+
assertContainedRealPath(cwd, join(cwd, DOCS), { lstat });
|
|
75
76
|
} catch (err) {
|
|
76
77
|
throw stop(String(err?.message ?? err).replace(/^\[agent-workflow-kit\] /, ''));
|
|
77
78
|
}
|
package/tools/attribution.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// harness adds no Co-Authored-By trailer, PR text or session link. Preview by default; --apply writes.
|
|
5
5
|
import { mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
6
6
|
import { join, resolve } from 'node:path';
|
|
7
|
+
import { AGENTS_FILE } from '../references/scripts/shared/index.mjs';
|
|
7
8
|
import { CLAUDE_DIR, EXPECTED_WORKFLOW_VERSION, SETTINGS_FILE, preflightVelocityProfile } from './velocity-profile.mjs';
|
|
8
9
|
import { formatJson } from './gate-hook.mjs';
|
|
9
10
|
import { isDirectRun } from './direct-run.mjs';
|
|
@@ -31,7 +32,7 @@ const usageError = (message) => Object.assign(new Error(message), { exitCode: EX
|
|
|
31
32
|
export const readAttributionChoice = (root, deps = {}) => {
|
|
32
33
|
let text;
|
|
33
34
|
try {
|
|
34
|
-
text = String((deps.readFile ?? readFileSync)(join(root,
|
|
35
|
+
text = String((deps.readFile ?? readFileSync)(join(root, AGENTS_FILE), 'utf8'));
|
|
35
36
|
} catch (error) {
|
|
36
37
|
if (error?.code === 'ENOENT') return null;
|
|
37
38
|
throw error;
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
import { readFileSync, lstatSync } from 'node:fs';
|
|
22
22
|
import { join } from 'node:path';
|
|
23
|
+
import { AUTONOMY } from '../references/scripts/shared/index.mjs';
|
|
23
24
|
import { POLICY_ACTIVITIES as ACTIVITIES } from './recipes.mjs';
|
|
24
25
|
|
|
25
26
|
// The hand-editable / agent-writable, per-project policy (strict JSON). cwd-relative — the error prefix
|
|
26
27
|
// uses this rel path so a user sees a path they can open, never an absolute temp/host path.
|
|
27
|
-
export const AUTONOMY_REL =
|
|
28
|
+
export const AUTONOMY_REL = AUTONOMY;
|
|
28
29
|
|
|
29
30
|
// A tagged failure: a plain Error carrying the intended process exit code (2 usage / 1 config). Avoids
|
|
30
31
|
// a class (project rule) while letting a CLI main() map a throw to the right code in one place. Shared
|
package/tools/bridge-wiring.mjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { closeSync, constants, fstatSync, openSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { homedir } from 'node:os';
|
|
7
|
-
import { join } from 'node:path';
|
|
7
|
+
import { basename, join } from 'node:path';
|
|
8
|
+
import { SETTINGS, SETTINGS_LOCAL } from '../references/scripts/shared/index.mjs';
|
|
8
9
|
import { bundledSandboxRecipe, usedBridges } from './bridge-sandbox-recipe.mjs';
|
|
9
10
|
import { missingStateDirs, stateDirsOf } from './bridge-state-dirs.mjs';
|
|
10
11
|
import { loadConfig } from './orchestration-config.mjs';
|
|
@@ -20,9 +21,6 @@ export const WIRING_ROUTE_UNUSED = 'no slot uses it for review — once one does
|
|
|
20
21
|
export const SANDBOX_ENABLED_CONDITION = `enabled in the project settings — ready means wired ${HOST_HONORS_QUALIFIER}`;
|
|
21
22
|
export const SANDBOX_NOT_ENABLED_CONDITION = 'not enabled in the project settings — ready means installed';
|
|
22
23
|
|
|
23
|
-
const PROJECT_FILE = 'settings.json';
|
|
24
|
-
const LOCAL_FILE = 'settings.local.json';
|
|
25
|
-
const SETTINGS_DIR = '.claude';
|
|
26
24
|
const UTF8 = 'utf8';
|
|
27
25
|
const ABSENT = 'ENOENT';
|
|
28
26
|
const NOT_REGULAR = 'not a regular file';
|
|
@@ -33,6 +31,9 @@ const ENABLED = 'enabled';
|
|
|
33
31
|
const SANDBOX = 'sandbox';
|
|
34
32
|
const SURFACE_KEYS = Object.freeze(['excludedCommands', 'hosts', 'dirs']);
|
|
35
33
|
|
|
34
|
+
const PROJECT_LABEL = basename(SETTINGS);
|
|
35
|
+
const LOCAL_LABEL = basename(SETTINGS_LOCAL);
|
|
36
|
+
|
|
36
37
|
const isPlainObject = (value) => value !== null && typeof value === 'object'
|
|
37
38
|
&& (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
38
39
|
|
|
@@ -49,11 +50,11 @@ const sandboxOf = (data, file) => {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
export const sandboxEnabled = (projectData, localData) => {
|
|
52
|
-
const project = sandboxOf(projectData,
|
|
53
|
-
const local = sandboxOf(localData,
|
|
53
|
+
const project = sandboxOf(projectData, PROJECT_LABEL);
|
|
54
|
+
const local = sandboxOf(localData, LOCAL_LABEL);
|
|
54
55
|
const useLocal = local !== undefined && Object.hasOwn(local, ENABLED);
|
|
55
56
|
const judged = useLocal ? local : project;
|
|
56
|
-
const file = useLocal ?
|
|
57
|
+
const file = useLocal ? LOCAL_LABEL : PROJECT_LABEL;
|
|
57
58
|
if (judged === undefined || !Object.hasOwn(judged, ENABLED)) return false;
|
|
58
59
|
if (typeof judged.enabled !== 'boolean') throw new Error(`${file}: enabled must be a boolean`);
|
|
59
60
|
return judged.enabled === true;
|
|
@@ -104,8 +105,9 @@ const readRegular = (path) => {
|
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
107
|
|
|
107
|
-
const readSettings = (root,
|
|
108
|
-
const path = join(root,
|
|
108
|
+
const readSettings = (root, relativePath) => {
|
|
109
|
+
const path = join(root, relativePath);
|
|
110
|
+
const file = basename(relativePath);
|
|
109
111
|
const raw = (() => {
|
|
110
112
|
try {
|
|
111
113
|
return readRegular(path);
|
|
@@ -166,8 +168,8 @@ const judgeBridge = (bridge, used, sandbox, context, deps) => {
|
|
|
166
168
|
export const composeBridgeWiring = ({ root, readiness }, deps = {}) => {
|
|
167
169
|
const ready = BACKEND_PRIORITY.filter((bridge) => readiness.some((row) => row.name === bridge && row.readiness === READY));
|
|
168
170
|
try {
|
|
169
|
-
const project = readSettings(root,
|
|
170
|
-
const local = readSettings(root,
|
|
171
|
+
const project = readSettings(root, SETTINGS);
|
|
172
|
+
const local = readSettings(root, SETTINGS_LOCAL);
|
|
171
173
|
if (!sandboxEnabled(project, local)) {
|
|
172
174
|
return {
|
|
173
175
|
enabled: false,
|
package/tools/carriers.mjs
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
// carriers.mjs — the activity/slot registry plus the subagent carrier's readiness composition.
|
|
2
2
|
// ACTIVITIES + SLOT_RECIPES are the ONE table: recipes.mjs re-exports them, so no importer's path
|
|
3
|
-
// moves. The carrier half declares the `subagent` recipe, appends the executor
|
|
4
|
-
// readiness array as the single
|
|
5
|
-
//
|
|
3
|
+
// moves. The carrier half declares the `subagent` recipe, appends the executor and author vehicles to a
|
|
4
|
+
// readiness array as the single providers of their roles, words the degrade an unready
|
|
5
|
+
// vehicle causes, and holds the dispatch-form wording every render prints (one source, a
|
|
6
6
|
// red line where it is a red line). Governing contract: docs/ai/specs/kit/carriers/index.md.
|
|
7
7
|
// Leaf — imports only the direct-run guard (recipes.mjs imports THIS), no fs, nothing on import.
|
|
8
8
|
import { refuseDirectRun } from './direct-run.mjs';
|
|
9
9
|
|
|
10
|
+
export const CARRY_ROLE = 'carry';
|
|
11
|
+
export const AUTHOR_ROLE = 'author';
|
|
12
|
+
|
|
10
13
|
// The slot VALUE is the slot's TYPE; SLOT_RECIPES lists the values each type accepts. A `switch`
|
|
11
14
|
// slot is a flag, not a recipe: it resolves outside the recipe lattice and never degrades.
|
|
12
15
|
// `policy` marks an activity that is a SESSION with an autonomy level of its own; a routine chore
|
|
13
16
|
// runs inside such a session and carries none.
|
|
14
17
|
export const ACTIVITIES = {
|
|
15
|
-
'plan-authoring': { slots: { author: 'carrier', fold: 'carrier', review: 'review' }, policy: true },
|
|
16
|
-
'plan-execution': { slots: { execute: 'execute', review: 'review' }, policy: true },
|
|
17
|
-
routine: { slots: { carrier: 'carrier', parallel: 'switch' }, policy: false },
|
|
18
|
-
'feedback-triage': { slots: { review: 'review' }, policy: false },
|
|
19
|
-
epic: { slots: { author: 'carrier', review: 'review' }, policy: false },
|
|
20
|
-
task: { slots: { author: 'execute', execute: 'execute' }, policy: false },
|
|
18
|
+
'plan-authoring': { slots: { author: 'carrier', fold: 'carrier', review: 'review' }, roles: { author: AUTHOR_ROLE, fold: AUTHOR_ROLE }, policy: true },
|
|
19
|
+
'plan-execution': { slots: { execute: 'execute', review: 'review' }, roles: { execute: CARRY_ROLE }, policy: true },
|
|
20
|
+
routine: { slots: { carrier: 'carrier', parallel: 'switch' }, roles: { carrier: CARRY_ROLE }, policy: false },
|
|
21
|
+
'feedback-triage': { slots: { review: 'review' }, roles: {}, policy: false },
|
|
22
|
+
epic: { slots: { author: 'carrier', review: 'review' }, roles: { author: AUTHOR_ROLE }, policy: false },
|
|
23
|
+
task: { slots: { author: 'execute', execute: 'execute' }, roles: { author: CARRY_ROLE, execute: CARRY_ROLE }, policy: false },
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
export const POLICY_ACTIVITIES = Object.fromEntries(
|
|
@@ -48,7 +51,6 @@ export const LENS_VERDICTS = Object.freeze(['ship', 'ship with nits', 'revise',
|
|
|
48
51
|
|
|
49
52
|
export const isSwitchSlot = (slotType) => slotType === SWITCH_SLOT;
|
|
50
53
|
|
|
51
|
-
export const CARRY_ROLE = 'carry';
|
|
52
54
|
export const EXECUTOR_PROVIDER = 'executor';
|
|
53
55
|
|
|
54
56
|
export const SUBAGENT_RECIPE = {
|
|
@@ -61,6 +63,13 @@ export const SUBAGENT_RECIPE = {
|
|
|
61
63
|
'a full-tool frontier subagent from the placed executor vehicle carries a bounded, file-disjoint slice; the orchestrator verifies it and commits.',
|
|
62
64
|
};
|
|
63
65
|
|
|
66
|
+
export const AUTHOR_SUBAGENT_RECIPE = {
|
|
67
|
+
...SUBAGENT_RECIPE,
|
|
68
|
+
role: AUTHOR_ROLE,
|
|
69
|
+
summary:
|
|
70
|
+
'a frontier subagent from the placed no-shell author vehicle drafts a bounded authoring slice; the orchestrator reviews the draft as its own and commits.',
|
|
71
|
+
};
|
|
72
|
+
|
|
64
73
|
// The readiness tokens the planner judges on. Mirrored from detect-backends.mjs rather than
|
|
65
74
|
// imported: this module is the leaf the planner itself imports.
|
|
66
75
|
const READY = 'ready';
|
|
@@ -80,6 +89,15 @@ export const withVehicle = (readiness = [], survey = null) => [
|
|
|
80
89
|
},
|
|
81
90
|
];
|
|
82
91
|
|
|
92
|
+
export const withAuthorVehicle = (readiness = [], survey = null) => [
|
|
93
|
+
...readiness.filter((entry) => entry?.name !== AUTHOR_ROLE),
|
|
94
|
+
{
|
|
95
|
+
name: AUTHOR_ROLE,
|
|
96
|
+
readiness: survey?.state === 'placed' ? READY : MISSING,
|
|
97
|
+
vehicle: survey,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
83
101
|
export const EXECUTOR_APPLY = '/agent-workflow-kit agents';
|
|
84
102
|
|
|
85
103
|
// A survey reason may quote a file the user wrote; it is collapsed to one safe line before it rides
|
|
@@ -91,10 +109,16 @@ export const safeLine = (text) => String(text ?? '')
|
|
|
91
109
|
.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\s]+/gu, ' ')
|
|
92
110
|
.trim();
|
|
93
111
|
|
|
94
|
-
export const vehicleDegradeReason = (survey, applyHint = EXECUTOR_APPLY) => {
|
|
112
|
+
export const vehicleDegradeReason = (survey, applyHint = EXECUTOR_APPLY, role = CARRY_ROLE) => {
|
|
95
113
|
const state = survey?.state ?? MISSING;
|
|
96
114
|
const reason = safeLine(survey?.reason);
|
|
97
115
|
const detail = reason ? ` (${reason})` : '';
|
|
116
|
+
if (role === AUTHOR_ROLE) {
|
|
117
|
+
const remedy = state === 'unusable'
|
|
118
|
+
? `fix or remove ${safeLine(survey?.rel) || '.claude/agents/author.md'}, then place it with: ${applyHint}`
|
|
119
|
+
: state === MISSING ? `place it with: ${applyHint}` : `write it current with: ${applyHint}`;
|
|
120
|
+
return `the author vehicle is ${state}${detail} — ${remedy}`;
|
|
121
|
+
}
|
|
98
122
|
const remedy = state === 'unusable'
|
|
99
123
|
? `fix or remove ${safeLine(survey?.rel) || '.claude/agents/executor.md'}, then place it with: ${applyHint}`
|
|
100
124
|
: `place it with: ${applyHint}`;
|
|
@@ -125,6 +149,13 @@ export const DISPATCH_LINES = [
|
|
|
125
149
|
'honest limit: a Claude Code lane — on a host that cannot dispatch the vehicle, follow this form by hand and say so',
|
|
126
150
|
];
|
|
127
151
|
|
|
152
|
+
const AUTHOR_DISPATCH_LINES = [
|
|
153
|
+
`dispatch: the author vehicle (.claude/agents/author.md — ${VEHICLE_STATE_TOKEN}), in the background`,
|
|
154
|
+
'the orchestrator reviews every returned draft as its own',
|
|
155
|
+
DISPATCH_LINES[2],
|
|
156
|
+
"honest limit: a Claude Code lane loaded at session start — dispatch only when this session's agent list shows author with exactly Read, Grep, Glob, Write and Edit; otherwise, a file placed or written during this session included, carry the slice solo and say so; never another subagent",
|
|
157
|
+
];
|
|
158
|
+
|
|
128
159
|
export const PARALLEL_SOLO_NOTE = '(no effect while the carrier is solo)';
|
|
129
160
|
|
|
130
161
|
export const PARALLEL_LINES = {
|
|
@@ -137,6 +168,14 @@ export const SUBAGENT_SLOT_TYPES = Object.entries(SLOT_RECIPES)
|
|
|
137
168
|
.filter(([, values]) => values.includes(SUBAGENT_RECIPE.id))
|
|
138
169
|
.map(([slotType]) => slotType);
|
|
139
170
|
|
|
171
|
+
export const slotRole = (activity, slot, activities = ACTIVITIES) => {
|
|
172
|
+
const definition = activities[activity];
|
|
173
|
+
if (!SUBAGENT_SLOT_TYPES.includes(definition?.slots?.[slot])) return null;
|
|
174
|
+
const role = definition.roles?.[slot];
|
|
175
|
+
if (role !== AUTHOR_ROLE && role !== CARRY_ROLE) throw new Error(`missing or invalid subagent role for ${activity}.${slot}`);
|
|
176
|
+
return role;
|
|
177
|
+
};
|
|
178
|
+
|
|
140
179
|
// dispatchForm({ activity, slot, state }) → the lines a `subagent`-resolved slot renders: the
|
|
141
180
|
// slot's slice sentence, then the four shared lines with the surveyed vehicle state filled in.
|
|
142
181
|
// A slot type that cannot hold `subagent` (review) and an unknown activity render nothing; a slot
|
|
@@ -144,9 +183,10 @@ export const SUBAGENT_SLOT_TYPES = Object.entries(SLOT_RECIPES)
|
|
|
144
183
|
const UNDISPATCHED_SLOTS = new Set(['task.author']);
|
|
145
184
|
export const dispatchForm = ({ activity, slot, state } = {}) => {
|
|
146
185
|
const slice = SLICE_BY_SLOT[`${activity}.${slot}`];
|
|
147
|
-
const
|
|
148
|
-
if (!slice ||
|
|
149
|
-
|
|
186
|
+
const role = slotRole(activity, slot);
|
|
187
|
+
if (!slice || role === null) return [];
|
|
188
|
+
const lines = role === AUTHOR_ROLE ? AUTHOR_DISPATCH_LINES : DISPATCH_LINES;
|
|
189
|
+
return UNDISPATCHED_SLOTS.has(`${activity}.${slot}`) ? [slice] : [slice, ...lines.map((line) => line.replace(VEHICLE_STATE_TOKEN, state ?? MISSING))];
|
|
150
190
|
};
|
|
151
191
|
|
|
152
192
|
// parallelLine({ value, carrier }) → the `routine` switch line. The concurrency claim is TRUE only
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// cheap-agents-read.mjs — the READ-ONLY core of the subagent-vehicle surface: the bundle, the
|
|
2
|
-
// placement plan and the executor
|
|
2
|
+
// placement plan and the executor and author vehicles' readiness. Split from cheap-agents.mjs (the writer) so
|
|
3
3
|
// the read-only advisor graph (procedures -> recipes) reaches these facts WITHOUT importing a module
|
|
4
4
|
// that can create `.claude/agents/` — by construction, pinned by the read-graph purity walk.
|
|
5
5
|
|
|
6
6
|
import { existsSync, lstatSync, readFileSync, readdirSync } from 'node:fs';
|
|
7
7
|
import { dirname, join, resolve } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { AGENTS_DIR, CLAUDE_DIR } from '../references/scripts/shared/index.mjs';
|
|
9
10
|
import { refuseDirectRun } from './direct-run.mjs';
|
|
10
11
|
import { deriveLensTemplate } from './review-roster-resolve.mjs';
|
|
11
12
|
import { EXECUTOR_DEFAULTS, VEHICLES_REL, readVehicles, resolveExecutor, resolveReviewLens } from './vehicle-settings.mjs';
|
|
12
13
|
|
|
13
14
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
-
export const CLAUDE_DIR = '.claude';
|
|
17
|
-
export const WORKFLOW_STAMP = 'docs/ai/.workflow-version';
|
|
16
|
+
export { AGENTS_DIR, CLAUDE_DIR, WORKFLOW_STAMP } from '../references/scripts/shared/index.mjs';
|
|
18
17
|
export const EXPECTED_WORKFLOW_VERSION = '5.0.0';
|
|
19
18
|
export const BUNDLED_AGENTS_DIR = resolve(HERE, '..', 'references', 'agents');
|
|
20
19
|
|
|
@@ -113,13 +112,16 @@ export const planPlacement = (templates, projectDir, deps = {}) => {
|
|
|
113
112
|
});
|
|
114
113
|
};
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
export const AUTHOR_VEHICLE = 'author.md';
|
|
116
|
+
export const AUTHOR_VEHICLE_REL = `${AGENTS_DIR}/${AUTHOR_VEHICLE}`;
|
|
117
|
+
|
|
118
|
+
// The component is accepted when a kit agent path other than author.md holds a regular file, never followed.
|
|
117
119
|
export const agentsAccepted = (projectDir, names, deps = {}) => {
|
|
118
120
|
const fs = readFsDeps(deps);
|
|
119
|
-
return names.some((name) => lstatNoFollow(join(projectDir, AGENTS_DIR, name), fs)?.isFile() === true);
|
|
121
|
+
return names.some((name) => name !== AUTHOR_VEHICLE && lstatNoFollow(join(projectDir, AGENTS_DIR, name), fs)?.isFile() === true);
|
|
120
122
|
};
|
|
121
123
|
|
|
122
|
-
// ── the executor vehicle's readiness (the
|
|
124
|
+
// ── the executor vehicle's readiness (the carry role's instrument) ──────────
|
|
123
125
|
|
|
124
126
|
export const EXECUTOR_VEHICLE = 'executor.md';
|
|
125
127
|
export const EXECUTOR_VEHICLE_REL = `${AGENTS_DIR}/${EXECUTOR_VEHICLE}`;
|
|
@@ -174,6 +176,7 @@ export const executorBodyDiffers = (projectDir, deps = {}) => {
|
|
|
174
176
|
};
|
|
175
177
|
|
|
176
178
|
const READ_ONLY_TOOLS = new Set(['Read', 'Grep', 'Glob']);
|
|
179
|
+
const AUTHOR_TOOLS = new Set([...READ_ONLY_TOOLS, 'Write', 'Edit']);
|
|
177
180
|
|
|
178
181
|
// The YAML subset a vehicle's frontmatter is read with: a bare scalar, a single- or double-quoted
|
|
179
182
|
// scalar, or a flow sequence; an unquoted ` #comment` and surrounding whitespace are dropped first.
|
|
@@ -213,6 +216,15 @@ const listedTools = (frontmatter) => {
|
|
|
213
216
|
return (inline || blockItems(frontmatter).join(', ')).split(',').map((tool) => cleanValue(tool)).filter(Boolean);
|
|
214
217
|
};
|
|
215
218
|
|
|
219
|
+
const authorFrontmatterRefusal = (frontmatter) => {
|
|
220
|
+
const count = (frontmatter.match(/^tools:/gmu) ?? []).length;
|
|
221
|
+
if (count !== 1) return count === 0 ? 'frontmatter has no `tools:` key' : 'duplicate `tools:` key in the frontmatter';
|
|
222
|
+
const tools = listedTools(frontmatter);
|
|
223
|
+
if (tools.length === 0) return 'tools: is empty';
|
|
224
|
+
const outside = tools.find((tool) => !AUTHOR_TOOLS.has(tool));
|
|
225
|
+
return outside ? `tools: grants tool outside the author's five: ${outside}` : null;
|
|
226
|
+
};
|
|
227
|
+
|
|
216
228
|
const executorFrontmatterRefusal = (frontmatter, stem) => {
|
|
217
229
|
for (const key of ['name', 'tools']) {
|
|
218
230
|
if ((frontmatter.match(new RegExp(`^${key}:`, 'gmu')) ?? []).length > 1) return `duplicate \`${key}:\` key in the frontmatter`;
|
|
@@ -274,6 +286,12 @@ export const surveyVehicle = (projectDir, spec, deps = {}) => {
|
|
|
274
286
|
? { state: 'placed', reason: null, rel, model: lens.model, effort: lens.effort }
|
|
275
287
|
: { state: 'unusable', reason: lens.refusal, rel };
|
|
276
288
|
}
|
|
289
|
+
if (spec.tools === 'author') {
|
|
290
|
+
const refusal = authorFrontmatterRefusal(frontmatter);
|
|
291
|
+
return refusal === null
|
|
292
|
+
? { state: 'stale', reason: 'differs from the body the kit writes for it', rel }
|
|
293
|
+
: { state: 'widened', reason: refusal, rel };
|
|
294
|
+
}
|
|
277
295
|
if (spec.tools !== 'read-only') {
|
|
278
296
|
const refusal = executorFrontmatterRefusal(frontmatter, spec.stem);
|
|
279
297
|
return refusal === null
|
|
@@ -302,4 +320,7 @@ export const surveyExecutorVehicle = (projectDir, deps = {}) => {
|
|
|
302
320
|
return surveyVehicle(projectDir, executorVehicleSpec(posture), deps);
|
|
303
321
|
};
|
|
304
322
|
|
|
323
|
+
export const surveyAuthorVehicle = (projectDir, deps = {}) =>
|
|
324
|
+
surveyVehicle(projectDir, { stem: 'author', template: 'author', tools: 'author' }, deps);
|
|
325
|
+
|
|
305
326
|
refuseDirectRun(import.meta.url);
|
package/tools/cheap-agents.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// cheap-agents.mjs — the onboarding writer behind `/agent-workflow-kit agents`: places the bundled
|
|
3
|
-
// subagent definitions (references/agents/*.md) into a project's .claude/agents/. FOUR vehicles
|
|
3
|
+
// subagent definitions (references/agents/*.md) into a project's .claude/agents/. FOUR read-only vehicles
|
|
4
4
|
// grant NO shell — three ride the cheap lane (haiku/low-effort) so mechanical work (sweeps,
|
|
5
5
|
// changelog skeletons, gate triage) stops running on a frontier model by default, and review-lens
|
|
6
|
-
// is the read-only review opinion. The
|
|
7
|
-
// only for a bounded execution
|
|
8
|
-
//
|
|
6
|
+
// is the read-only review opinion. The author carries authoring slices with Read, Grep, Glob, Write, Edit and no shell.
|
|
7
|
+
// The executor is the ONE full-tool vehicle: dispatched only for a bounded execution or write-capable
|
|
8
|
+
// routine slice the orchestrator verifies, never for read-only work, and it never commits.
|
|
9
|
+
// `surveyExecutorVehicle` and `surveyAuthorVehicle` judge the readiness of their respective roles.
|
|
9
10
|
//
|
|
10
11
|
// The family's second `.claude/` writer, the velocity-profile.mjs discipline:
|
|
11
12
|
// • preview-then-mutate — `--dry-run` is the DEFAULT and writes nothing; `--apply` writes;
|
|
@@ -44,7 +45,7 @@ import { loadVehicles, resolveExecutor, resolveReviewLens } from './vehicle-sett
|
|
|
44
45
|
import { safeLine } from './carriers.mjs';
|
|
45
46
|
import { writeContainedFileAtomic } from './atomic-write.mjs';
|
|
46
47
|
import { fileLine } from './distribution-files/index.mjs';
|
|
47
|
-
// The READ core, never a second copy: the bundle, the placement plan and the
|
|
48
|
+
// The READ core, never a second copy: the bundle, the placement plan and the vehicle surveys live
|
|
48
49
|
// there so the read-only advisor graph can reach them without reaching this writer.
|
|
49
50
|
import {
|
|
50
51
|
AGENTS_DIR,
|
|
@@ -56,6 +57,7 @@ import {
|
|
|
56
57
|
CHEAP_AGENTS_BUNDLE,
|
|
57
58
|
CHEAP_AGENTS_CONFIG,
|
|
58
59
|
CHEAP_AGENTS_VEHICLES,
|
|
60
|
+
AUTHOR_VEHICLE,
|
|
59
61
|
EXECUTOR_VEHICLE,
|
|
60
62
|
REVIEW_LENS_VEHICLE,
|
|
61
63
|
executorTemplate,
|
|
@@ -104,11 +106,12 @@ export const FALLBACK_LENS_ADDITIONAL_ONLY = 'review-lens is an ADDITIONAL read-
|
|
|
104
106
|
|
|
105
107
|
const USAGE = `usage: cheap-agents [--dry-run | --apply] [--cwd <dir>] [--help]
|
|
106
108
|
|
|
107
|
-
Places the bundled subagent definitions into the project's ${AGENTS_DIR}/. Four vehicles grant NO
|
|
109
|
+
Places the bundled subagent definitions into the project's ${AGENTS_DIR}/. Four read-only vehicles grant NO
|
|
108
110
|
shell: three ride a cheap model (haiku/low) for mechanical work — extraction sweeps, changelog
|
|
109
111
|
fact-skeletons, gate triage — and review-lens is a read-only REVIEW vehicle, opus/high unless
|
|
110
|
-
docs/ai/vehicles.json sets another posture. The
|
|
111
|
-
|
|
112
|
+
docs/ai/vehicles.json sets another posture. The author carries authoring slices with Read, Grep, Glob, Write, Edit and no shell.
|
|
113
|
+
The executor is the ONE full-tool vehicle: dispatched only for a bounded execution
|
|
114
|
+
or write-capable routine slice the orchestrator verifies, never for read-only work, and
|
|
112
115
|
it never commits.
|
|
113
116
|
Default is --dry-run (a preview; writes nothing). --apply writes.
|
|
114
117
|
Configured derived review lenses are planned and placed beside the bundled vehicles.
|
|
@@ -138,6 +141,7 @@ export const preflightCheapAgents = ({ cwd, derived = [] }, deps = {}) => {
|
|
|
138
141
|
const projectDir = cwd ?? process.cwd();
|
|
139
142
|
refuseSymlinkedRoot(projectDir, deps);
|
|
140
143
|
const templatesByName = new Map(readBundledAgents(deps).map((template) => [template.name, template]));
|
|
144
|
+
if (!templatesByName.has(AUTHOR_VEHICLE)) throw makeCheapAgentsError(CHEAP_AGENTS_BUNDLE, `${AUTHOR_VEHICLE} is missing from the bundle`);
|
|
141
145
|
for (const template of derived) templatesByName.set(template.name, template);
|
|
142
146
|
const templates = [...templatesByName.values()];
|
|
143
147
|
const stamp = readStamp(join(projectDir, WORKFLOW_STAMP), fs);
|
|
@@ -238,11 +242,12 @@ export const formatResult = (result) => {
|
|
|
238
242
|
if (!result.stampOk) {
|
|
239
243
|
lines.push(`note: no current deployment stamp found (${result.stamp ?? 'none'}) — --apply will refuse until init/upgrade runs.`);
|
|
240
244
|
}
|
|
241
|
-
const readOnlyCount = result.plan.filter((item) => item.name !== EXECUTOR_VEHICLE).length;
|
|
245
|
+
const readOnlyCount = result.plan.filter((item) => item.name !== EXECUTOR_VEHICLE && item.name !== AUTHOR_VEHICLE).length;
|
|
242
246
|
lines.push(
|
|
243
247
|
`${readOnlyCount} vehicles are Claude Code subagents with READ-ONLY tools and NO shell as the kit writes them — so a fan-out on the shipped templates can never turn into a wave of approval prompts.`,
|
|
244
248
|
`three of those ride the cheap lane (model: haiku, effort: low) for mechanical work; ${FALLBACK_LENS_ADDITIONAL_ONLY}`,
|
|
245
|
-
'
|
|
249
|
+
'author writes files with no shell and carries authoring slices.',
|
|
250
|
+
'executor is the one FULL-TOOL vehicle: dispatched only for a bounded execution or write-capable routine slice the orchestrator verifies, never for read-only work, and it never commits.',
|
|
246
251
|
`executor posture: model=${safeLine(posture.model)} effort=${safeLine(posture.effort)} fallback=${safeLine(posture.fallback)} (source: ${safeLine(posture.source)}) — set in docs/ai/vehicles.json`,
|
|
247
252
|
`review-lens posture: model=${safeLine(lensPosture.model)} effort=${safeLine(lensPosture.effort)} (source: ${safeLine(lensPosture.source)}) — set in docs/ai/vehicles.json`,
|
|
248
253
|
);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { lstatSync } from 'node:fs';
|
|
6
6
|
import { dirname, join, resolve } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { DOCS, DOCS_TREE, GIT_DIR, SPEC_COVERAGE, SPEC_STORE_INDEX } from '../references/scripts/shared/index.mjs';
|
|
8
9
|
import { CHECKER_CLAIM, classifyCheckerClaim, dqUnsafePath } from './checker-claim.mjs';
|
|
9
10
|
import { refuseDirectRun } from './direct-run.mjs';
|
|
10
11
|
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
@@ -12,15 +13,15 @@ import { GATES_REL, KIT_CHECKER_CLAIMS, coverageDeclarationDefects, validateDecl
|
|
|
12
13
|
import { escapeForLine, isLineUnsafe } from './source-size-core.mjs';
|
|
13
14
|
|
|
14
15
|
const KIT_TOOLS_DIR = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
const DEPLOYMENT_CHAIN = ['.',
|
|
16
|
+
const DEPLOYMENT_CHAIN = ['.', DOCS, DOCS_TREE];
|
|
16
17
|
const NOT_APPLICABLE_CODES = new Set(['ENOENT', 'ENOTDIR']);
|
|
17
18
|
const OK = 'ok';
|
|
18
19
|
const ABSENT = 'absent';
|
|
19
20
|
const FOREIGN = 'foreign';
|
|
20
21
|
const SYMLINK_CLASS = 'symlink';
|
|
21
|
-
const
|
|
22
|
-
const STORE_ROOT = Object.freeze({ rel:
|
|
23
|
-
const COVERAGE_SCOPE = Object.freeze({ rel:
|
|
22
|
+
const GIT_PROBE = Object.freeze({ rel: GIT_DIR, kinds: ['directory', 'file'], what: 'a directory or a regular gitfile' });
|
|
23
|
+
const STORE_ROOT = Object.freeze({ rel: SPEC_STORE_INDEX, kinds: ['file'], what: 'a regular file' });
|
|
24
|
+
const COVERAGE_SCOPE = Object.freeze({ rel: SPEC_COVERAGE, kinds: ['file'], what: 'a regular file' });
|
|
24
25
|
|
|
25
26
|
export const CANDIDATE_STATES = Object.freeze({
|
|
26
27
|
declared: 'declared',
|
|
@@ -72,7 +73,7 @@ const requiring = (...requirements) => (root, deps) => {
|
|
|
72
73
|
const candidate = (id, title, probe) => Object.freeze({ id, title, probe });
|
|
73
74
|
|
|
74
75
|
export const CHECKER_GATE_CANDIDATES = Object.freeze([
|
|
75
|
-
candidate('control-bytes', 'No raw control byte in the work tree', requiring(
|
|
76
|
+
candidate('control-bytes', 'No raw control byte in the work tree', requiring(GIT_PROBE)),
|
|
76
77
|
candidate('plan-shape', 'Plans in flight keep the structural planning shape', requiring()),
|
|
77
78
|
candidate('spec-check', 'Feature-spec store structure — the whole store', requiring(STORE_ROOT)),
|
|
78
79
|
candidate(
|
package/tools/commands.mjs
CHANGED
|
@@ -145,7 +145,7 @@ const CATALOG = [
|
|
|
145
145
|
invocation: invocationOf('agents'),
|
|
146
146
|
group: 'Configure',
|
|
147
147
|
kind: WRITER,
|
|
148
|
-
oneLine: 'Place the bundled subagent vehicles: four read-only ones, none granted a shell — three cheap-model ones for mechanical work (sweeps, changelog skeletons, gate triage) and a review lens — plus the one full-tool executor that carries bounded slices you verify (Claude Code; opt-in; preview first).',
|
|
148
|
+
oneLine: 'Place the bundled subagent vehicles: four read-only ones, none granted a shell — three cheap-model ones for mechanical work (sweeps, changelog skeletons, gate triage) and a review lens — plus the author for authoring (files, no shell) and the one full-tool executor that carries bounded slices you verify (Claude Code; opt-in; preview first).',
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
key: 'hook',
|
|
@@ -376,7 +376,7 @@ const TUNE_TAIL = Object.freeze([
|
|
|
376
376
|
'',
|
|
377
377
|
'Tune — opt-in accelerators (consent-first: every writer previews before writing; nothing runs without your yes)',
|
|
378
378
|
` ${BARE_INVOCATION} velocity routine read-only commands stop prompting (incl. the --kit-tools tier for the kit's own read-only tools)`,
|
|
379
|
-
` ${BARE_INVOCATION} agents subagent vehicles: four read-only (cheap ones take the mechanical work, a review lens gives another opinion) + the one full-tool executor that carries bounded slices you verify`,
|
|
379
|
+
` ${BARE_INVOCATION} agents subagent vehicles: four read-only (cheap ones take the mechanical work, a review lens gives another opinion) + the author for authoring (files, no shell) + the one full-tool executor that carries bounded slices you verify`,
|
|
380
380
|
` ${BARE_INVOCATION} gates run your declared gates (docs/ai/gates.json) as one batch; its guide also offers the consent-gated seeding preview — writes only on your yes`,
|
|
381
381
|
` ${BARE_INVOCATION} hook auto-approve exactly your declared gate commands (byte-exact matches only)`,
|
|
382
382
|
` ${BARE_INVOCATION} set-recipe put a ready review backend to work on plans and diffs`,
|