@sabaiway/agent-workflow-kit 23.12.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 +58 -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/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 +4 -3
- 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/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/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/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 +84 -33
- package/tools/reference-profile.mjs +2 -2
- package/tools/renderers.mjs +14 -8
- package/tools/repo-lex.mjs +84 -0
- package/tools/robustness-brief.mjs +14 -11
- 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
package/tools/delegation.mjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// Pure (dependency-injectable validator + fs), dependency-free, Node >= 22.
|
|
10
10
|
|
|
11
11
|
import { statSync } from 'node:fs';
|
|
12
|
-
import { join, resolve } from 'node:path';
|
|
12
|
+
import { join, posix, resolve } from 'node:path';
|
|
13
|
+
import { AGENTS_FILE, DOCS_TREE, MEMORY_STAMP, RULES, WORKFLOW_STAMP } from '../references/scripts/shared/index.mjs';
|
|
13
14
|
import { isDirectRun } from './direct-run.mjs';
|
|
14
15
|
import { validateManifest, VALID } from './manifest/validate.mjs';
|
|
15
16
|
|
|
@@ -86,10 +87,10 @@ export const handoffPlan = (delegate) =>
|
|
|
86
87
|
delegate
|
|
87
88
|
? {
|
|
88
89
|
mode: 'delegate',
|
|
89
|
-
memoryWrites: [
|
|
90
|
+
memoryWrites: [`${DOCS_TREE}/`, AGENTS_FILE, MEMORY_STAMP],
|
|
90
91
|
// The kit block and the rules themes run AFTER the substrate deploy, over memory's seed.
|
|
91
|
-
kitWrites: [
|
|
92
|
-
stampsPresent: [
|
|
92
|
+
kitWrites: [`${AGENTS_FILE} kit block`, `${RULES}/ theme files`, WORKFLOW_STAMP],
|
|
93
|
+
stampsPresent: [posix.basename(MEMORY_STAMP), posix.basename(WORKFLOW_STAMP)],
|
|
93
94
|
memoryRaisesCommitGate: false,
|
|
94
95
|
commitGate: 'kit-only-after-injection',
|
|
95
96
|
}
|
|
@@ -98,8 +99,8 @@ export const handoffPlan = (delegate) =>
|
|
|
98
99
|
memoryWrites: [],
|
|
99
100
|
// Fallback ships the kit's OWN AGENTS.md; the kit block is written into it exactly as on the
|
|
100
101
|
// delegate path, so both paths end with the same block.
|
|
101
|
-
kitWrites: [
|
|
102
|
-
stampsPresent: [
|
|
102
|
+
kitWrites: [`${DOCS_TREE}/`, AGENTS_FILE, `${AGENTS_FILE} kit block`, `${RULES}/ theme files`, WORKFLOW_STAMP],
|
|
103
|
+
stampsPresent: [posix.basename(WORKFLOW_STAMP)],
|
|
103
104
|
memoryRaisesCommitGate: false,
|
|
104
105
|
commitGate: 'kit-only-after-injection',
|
|
105
106
|
};
|
|
@@ -80,7 +80,7 @@ const RAW_BACKENDS = [
|
|
|
80
80
|
'codex-exec --resume-last [--nonce <n>] <plan-file|->',
|
|
81
81
|
'codex-exec --resume <session-id> [--nonce <n>] <plan-file|->',
|
|
82
82
|
],
|
|
83
|
-
receipt: "side effect — a NONCED run mints ONE exec receipt beside the delegation store: the dispatch nonce seam is the AW_DISPATCH_NONCE environment value or its plain-argument equivalent --nonce <n>, recognised ONLY before the prompt operand (after the operand or a literal '--' it is passthrough payload, never a flag), under the safe grammar [A-Za-z0-9._-]{1,64} — anything else, a duplicate, or a flag disagreeing with a non-empty env value refuses PRE-SPEND. The store directory resolves exactly as the kit's delegation store does: the dirname of an ABSOLUTE AW_DELEGATION_STORE (a relative one, or one ending in a path separator, refuses), else the git common dir. The artifact is agent-workflow-exec-receipt-<backendLength>-<backend>-<nonce>.json in two states: 'reserved' is written atomically and NO-CLOBBER immediately before the CLI runs — that write IS the nonce reservation, so a second dispatch on the same nonce, or an already-taken report name, refuses BEFORE any spend — and 'terminal' replaces it in place at exit. A nonced run also refuses pre-spend when no timeout/gtimeout binary can cap it (an accounted dispatch that cannot be capped can never honour the terminal-exit rule; a nonce-LESS run still warns and runs uncapped), when node is missing (the mint core), and when the prompt rides on stdin instead of a contract FILE — contractDigest is computed BY THIS WRAPPER from the dispatch file it was actually handed, so the kit can refuse a run that executed a different contract than the one it opened. That digest is taken from the SAME bytes already read as the prompt, never a second open of the path: two reads leave a window in which the file can be swapped, and the run would then execute one contract while its receipt claimed the digest of another. The header's own nonce must EQUAL the dispatch nonce — 'dispatch open' copies the nonce FROM the header, so a disagreeing --nonce could only reserve an identity no return would ever absorb, and it refuses pre-spend. A contract file edited BETWEEN 'dispatch open' and the run is caught at ABSORB by the contractDigest comparison, not pre-spend: the wrapper never reads the ledger, and that boundary is what the whole lane rests on. At exit the wrapper FIRST re-reads its reservation and verifies its own opaque owner token — a foreign owner refuses having published NOTHING, neither report nor receipt — THEN writes the delegate's final message atomically to agent-workflow-exec-report-<backendLength>-<backend>-<nonce>.txt, THEN re-verifies the owner and REPLACES the reservation with the terminal receipt {schema, kind, state, backend, nonce, owner, contractDigest, wrapperVersion, posture {model, effort, tier}, capS, killGraceS, sessionId, exitStatus, outcome, reportDigest, reportLength, timestamp}: the report is complete on disk before any artifact says the run arrived. capS and killGraceS are the cap the run ACTUALLY applied. outcome is the wrapper's own SUBSET of the ledger's vocabulary — exit 0 with a session id -> success, exit 0 without one -> missing-identity, ANY nonzero exit including the timeout codes 124 and 137 -> transport-failure; every orchestrator judgment is recorded at absorb time, never claimed here. The session id is captured BEFORE outcome branching, so a FAILED run records one too; in resume mode it is the validated resume id. FAIL-CLOSED, deliberately NOT the review lane's warn-only receipt: a publication that cannot complete exits nonzero with a DISTINCT status, and the message states only what the run can still prove. 70: the reservation could not be verified BEFORE any publication — NOTHING was published, not the report and not the receipt, and because the artifact found there belongs to another run it is never a '--no-receipt' source. 71: a publication stopped after that point — either the report write failed (nothing beyond the reservation was published; the '--no-receipt' absorb then records reportLength 0, ineligible by the name empty-report) or the report IS on disk and the terminal receipt was not completed (the absorb reads it, report-if-present). The post-report lane never claims the reservation still stands, because after that point its fate is no longer something this run observed. Every lane names the tree as partial/dirtied rather than untouched. A nonce-LESS invocation is byte-unchanged: no reservation, no receipt, no artifact, and it needs no node.",
|
|
83
|
+
receipt: "side effect — a NONCED run mints ONE exec receipt beside the delegation store: the dispatch nonce seam is the AW_DISPATCH_NONCE environment value or its plain-argument equivalent --nonce <n>, recognised ONLY before the prompt operand (after the operand or a literal '--' it is passthrough payload, never a flag), under the safe grammar [A-Za-z0-9._-]{1,64} — anything else, a duplicate, or a flag disagreeing with a non-empty env value refuses PRE-SPEND. The store directory resolves exactly as the kit's delegation store does: the dirname of an ABSOLUTE AW_DELEGATION_STORE (a relative one, or one ending in a path separator, refuses), else the git common dir. The artifact is agent-workflow-exec-receipt-<backendLength>-<backend>-<nonce>.json in two states: 'reserved' is written atomically and NO-CLOBBER immediately before the CLI runs — that write IS the nonce reservation, so a second dispatch on the same nonce, or an already-taken report name, refuses BEFORE any spend — and 'terminal' replaces it in place at exit. A nonced run also refuses pre-spend when no timeout/gtimeout binary can cap it (an accounted dispatch that cannot be capped can never honour the terminal-exit rule; a nonce-LESS run still warns and runs uncapped), when node is missing (the mint core), and when the prompt rides on stdin instead of a contract FILE — contractDigest is computed BY THIS WRAPPER from the dispatch file it was actually handed, so the kit can refuse a run that executed a different contract than the one it opened. That digest is taken from the SAME bytes already read as the prompt, never a second open of the path: two reads leave a window in which the file can be swapped, and the run would then execute one contract while its receipt claimed the digest of another. The header's own nonce must EQUAL the dispatch nonce — 'dispatch open' copies the nonce FROM the header, so a disagreeing --nonce could only reserve an identity no return would ever absorb, and it refuses pre-spend. A contract file edited BETWEEN 'dispatch open' and the run is caught at ABSORB by the contractDigest comparison, not pre-spend: the wrapper never reads the ledger, and that boundary is what the whole lane rests on. At exit the wrapper FIRST re-reads its reservation and verifies its own opaque owner token — a foreign owner refuses having published NOTHING, neither report nor receipt — THEN writes the delegate's final message atomically to agent-workflow-exec-report-<backendLength>-<backend>-<nonce>.txt, THEN re-verifies the owner and REPLACES the reservation with the terminal receipt {schema, kind, state, backend, nonce, owner, contractDigest, wrapperVersion, posture {model, effort, tier}, capS, killGraceS, sessionId, exitStatus, outcome, reportDigest, reportLength, timestamp}: the report is complete on disk before any artifact says the run arrived. capS and killGraceS are the cap the run ACTUALLY applied. outcome is the wrapper's own SUBSET of the ledger's vocabulary — exit 0 with a session id -> success, exit 0 without one -> missing-identity, ANY nonzero exit including the timeout codes 124 and 137 -> transport-failure; every orchestrator judgment is recorded at absorb time, never claimed here. The session id is captured BEFORE outcome branching, so a FAILED run records one too; in resume mode it is the validated resume id. FAIL-CLOSED, deliberately NOT the review lane's warn-only receipt: a publication that cannot complete exits nonzero with a DISTINCT status, and the message states only what the run can still prove. 70: the reservation could not be verified BEFORE any publication — NOTHING was published, not the report and not the receipt, and because the artifact found there belongs to another run it is never a '--no-receipt' source. 71: a publication stopped after that point — either the report write failed (nothing beyond the reservation was published; the '--no-receipt' absorb then records reportLength 0, ineligible by the name empty-report) or the report IS on disk and the terminal receipt was not completed (the absorb reads it, report-if-present). The post-report lane never claims the reservation still stands, because after that point its fate is no longer something this run observed. Every lane names the tree as partial/dirtied rather than untouched. A nonced run also refuses pre-spend, reserving nothing, unless its contract file carries exactly one top-level aw-plan-approval block of exactly plan, approval and check whose check (the kit's tools/plan-approval/cli.mjs check <plan> --digest <approval>) exits 0, so a nonced run never starts unless the approval record matches the block's own plan and approval; the kit's tools/stage-render/cli.mjs --dispatch <plan> prints that block. A nonce-LESS invocation is byte-unchanged: no reservation, no receipt, no artifact, and it needs no node.",
|
|
84
84
|
passthrough: {
|
|
85
85
|
policy: 'guarded',
|
|
86
86
|
blocked: ['-c*', '--config*', '-s*', '--sandbox*', '--dangerously-bypass-approvals-and-sandbox', '--dangerously-bypass-hook-trust', '--full-auto', '--oss', '--local-provider*', '-p*', '--profile*', '-m*', '--model*', '-o*', '--output-last-message*', '--json*', '--color*', '--output-schema*', '--ephemeral*'],
|
|
@@ -9,6 +9,7 @@ import { tmpdir } from 'node:os';
|
|
|
9
9
|
import { join, dirname, basename, relative } from 'node:path';
|
|
10
10
|
import { spawnSync } from 'node:child_process';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
|
+
import { MCP_FILE, PLANS, SETTINGS, SETTINGS_LOCAL } from '../references/scripts/shared/index.mjs';
|
|
12
13
|
import { computeFingerprintPayload, isTreeClean, isNeverCommittableStat } from './core-evidence.mjs';
|
|
13
14
|
import { KIT_OWN_PATHS, KNOWN_FOOTPRINT, patternToProbe, isDirPattern, expandGlob, isGlobPattern } from './known-footprint.mjs';
|
|
14
15
|
import { GIT_MAX_BUFFER, resolveGitLocation, withGitPath } from './git-env.mjs';
|
|
@@ -17,7 +18,7 @@ const TEMP_PREFIX = 'aw-dispatch-baseline-';
|
|
|
17
18
|
const INDEX_NAME = 'index';
|
|
18
19
|
const HASH_ALGORITHM = 'sha256';
|
|
19
20
|
const PAYLOAD_DIFF_ARGS = ['--no-ext-diff', '--no-textconv', '--ignore-submodules=none'];
|
|
20
|
-
const SCOPE_EXCLUSIONS = [
|
|
21
|
+
const SCOPE_EXCLUSIONS = [`/${PLANS}/`, `/${SETTINGS}`, `/${SETTINGS_LOCAL}`, `/${MCP_FILE}`];
|
|
21
22
|
const MISSING_PATH_CODES = ['ENOENT', 'ENOTDIR'];
|
|
22
23
|
const ABSENT_HEAD_STATUS = 1;
|
|
23
24
|
const CHECK_IGNORE_CLEAR_STATUS = 1;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// surveyed by proof before any write: absent, current, prior (a body the catalog lists for its manifest
|
|
6
6
|
// path) or edited. On every plain run a prior is refreshed, an edited one replaced in place and an
|
|
7
7
|
// absent one placed create-only, with no question and no copy kept; a current one is left. A project
|
|
8
|
-
// that did not accept the enforcement scripts gets every seed entry, the rotator and what it loads.
|
|
9
|
-
//
|
|
8
|
+
// that did not accept the enforcement scripts gets every seed entry, the rotator and what it loads.
|
|
9
|
+
// Every file is written after the family files it imports; after the last write
|
|
10
10
|
// the project's own rotator brings the ADR store current (`--ensure-current`); last, retired.mjs removes
|
|
11
11
|
// the kit's old flat files from scripts/ (distribution-files, part flat-move). It never imports
|
|
12
12
|
// ensure-specs.mjs or ensure-configs.mjs: the CLI composes this op from the module's index, and
|
|
@@ -41,8 +41,8 @@ const wrongKind = (rel, kind) => composeFailure(OP, 'wrong-node-kind', `${rel}:
|
|
|
41
41
|
|
|
42
42
|
// ── the survey: the component first, then every family file by proof, nothing written ────────────
|
|
43
43
|
|
|
44
|
-
// The installer
|
|
45
|
-
const inWriteOrder = (files) =>
|
|
44
|
+
// The installer follows the same dependency order as every other family file.
|
|
45
|
+
const inWriteOrder = (files) => dependenciesFirst(files);
|
|
46
46
|
|
|
47
47
|
// Each folder on the way, lstat-ed without following a link: → { refusal } | {}.
|
|
48
48
|
const surveyFolders = (cwd, family, lstat) => {
|
package/tools/ensure-configs.mjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// + docs/ai/specs/index.md a shipped prior refreshed, an edited one replaced, an absent
|
|
11
11
|
// one placed; then the store root seeded create-only
|
|
12
12
|
// scripts scripts/<every kit script> once a kit script outside the seed names, or the old flat installer, stands there, every file not current
|
|
13
|
-
// + the installer set written with no question and no copy kept;
|
|
13
|
+
// + the installer set written with no question and no copy kept; on a
|
|
14
14
|
// declined offer every seed file, the rotator included, and no other;
|
|
15
15
|
// then the project's rotator brings the ADR store current (--ensure-current)
|
|
16
16
|
// rules docs/ai/rules/<theme>.md the kit file seeded, refreshed on a shipped prior body, or any
|
|
@@ -86,7 +86,7 @@ The executor ensure writes nothing: a placed .claude/agents/executor.md whose by
|
|
|
86
86
|
body derived from docs/ai/vehicles.json is pending and an absent one is not placed here — the
|
|
87
87
|
advisor's agents item writes the derived body.
|
|
88
88
|
A fifth writes too: once a kit script outside the seed names stands in scripts/agent-workflow/, or the hook installer under its old
|
|
89
|
-
flat name in scripts/, the enforcement-script ensure writes every kit script that is not the bundled body,
|
|
89
|
+
flat name in scripts/, the enforcement-script ensure writes every kit script that is not the bundled body,
|
|
90
90
|
with no question and no copy kept: a body a release shipped is refreshed, an edited one replaced (its line names where an edit meant
|
|
91
91
|
to last goes) and an absent one placed; on a project that declined the enforcement offer, every seed file, the rotator included,
|
|
92
92
|
is kept current the same way, an absent one placed, and no other kit script is placed; after the writes the project's
|
package/tools/ensure-ops.mjs
CHANGED
|
@@ -38,6 +38,7 @@ import { VEHICLES_REL } from './vehicle-settings.mjs';
|
|
|
38
38
|
import { ENSURE_TOKENS, FAILURE_CAUSES } from './ensure-vocabulary.mjs';
|
|
39
39
|
import { readDeployedScripts, NODE_EVIDENCE, describeNodeProbes, probeNodeEvidence } from './node-evidence.mjs';
|
|
40
40
|
import { classifyDeployedScript } from './script-priors.mjs';
|
|
41
|
+
import { INDEX } from '../references/scripts/shared/index.mjs';
|
|
41
42
|
import { parseFrontmatter } from '../references/scripts/docs-size/index.mjs';
|
|
42
43
|
|
|
43
44
|
// The closed vocabulary lives in its own PURE leaf so the read-only doc-parity lint can bind the
|
|
@@ -230,7 +231,6 @@ export const nodeEvidenceRefusal = (op, cwd, lstat) => {
|
|
|
230
231
|
// the ensure framework is synchronous, and a second index implementation here would be the drift
|
|
231
232
|
// the one-generator rule exists to prevent. Under a hook module that is not the bundled one, the
|
|
232
233
|
// project's own checker judges the navigator and a write it rejects is put back (spec docs-navigator).
|
|
233
|
-
const INDEX_REL = 'docs/ai/index.md';
|
|
234
234
|
// The docs checker is the docs-size module's one deployed entry: bundled, it is the generator; deployed,
|
|
235
235
|
// the kept probe. A flat scripts/check-docs-size.mjs is no deployed checker (story S4 reads it).
|
|
236
236
|
const readChecker = () => readDeployedScripts().find(({ module }) => module === 'docs-size');
|
|
@@ -313,7 +313,7 @@ const judgeKept = ({ cwd, spawn, read, lstat, deps }) => {
|
|
|
313
313
|
const result = spawn(process.execPath, [pathIn(cwd, readChecker().deployed), '--check-index'], { cwd, encoding: 'utf8', timeout: deps.keptProbeTimeoutMs ?? KEPT_PROBE_TIMEOUT_MS, killSignal: 'SIGKILL' });
|
|
314
314
|
if (result.error) return { error: `${causeOf(result.error)}${result.signal ? `, killed on signal ${result.signal}` : ''}` };
|
|
315
315
|
if (result.status !== 0) return { accepted: false, said: describeExitWithOutput(result), half: 'its index check' };
|
|
316
|
-
const text = lstatNoFollow(join(cwd,
|
|
316
|
+
const text = lstatNoFollow(join(cwd, INDEX), lstat)?.isFile() ? String(read(join(cwd, INDEX), 'utf8')) : null;
|
|
317
317
|
const cap = text === null ? undefined : readStampedCap(text);
|
|
318
318
|
if (cap !== undefined && countLines(text) <= Number(cap)) return { accepted: true };
|
|
319
319
|
const why = text === null ? 'no navigator file stands' : cap === undefined ? 'the navigator stamps no maxLines' : `${countLines(text)} lines against the maxLines ${cap} it stamps`;
|
|
@@ -322,7 +322,7 @@ const judgeKept = ({ cwd, spawn, read, lstat, deps }) => {
|
|
|
322
322
|
|
|
323
323
|
const removeIndexIfPresent = (cwd, deps) => {
|
|
324
324
|
try {
|
|
325
|
-
(deps.unlink ?? unlinkSync)(join(cwd,
|
|
325
|
+
(deps.unlink ?? unlinkSync)(join(cwd, INDEX));
|
|
326
326
|
} catch (err) {
|
|
327
327
|
if (err?.code !== 'ENOENT') throw err;
|
|
328
328
|
}
|
|
@@ -330,7 +330,7 @@ const removeIndexIfPresent = (cwd, deps) => {
|
|
|
330
330
|
|
|
331
331
|
const putBackIndex = (cwd, found, deps) => {
|
|
332
332
|
try {
|
|
333
|
-
if (found !== null) writeDocsAiFileAtomic(cwd,
|
|
333
|
+
if (found !== null) writeDocsAiFileAtomic(cwd, INDEX, found, deps, { noun: 'the navigator' });
|
|
334
334
|
else removeIndexIfPresent(cwd, deps);
|
|
335
335
|
} catch (err) {
|
|
336
336
|
return causeOf(err);
|
|
@@ -340,28 +340,28 @@ const putBackIndex = (cwd, found, deps) => {
|
|
|
340
340
|
|
|
341
341
|
const ensureKeptIndex = ({ cwd, drive, spawn, read, lstat, deps }) => {
|
|
342
342
|
const judge = () => judgeKept({ cwd, spawn, read, lstat, deps });
|
|
343
|
-
const reportUnanswered = (verdict, after) => loud('index', 'index-probe-failed', `${
|
|
343
|
+
const reportUnanswered = (verdict, after) => loud('index', 'index-probe-failed', `${INDEX}: ${describeKeptJudge()} could not be launched or did not answer in time (${verdict.error}) — ${after}`);
|
|
344
344
|
const first = judge();
|
|
345
345
|
if (first.error) return reportUnanswered(first, 'nothing was written');
|
|
346
|
-
if (first.accepted) return ok('index', 'already-current', `${
|
|
347
|
-
const found = lstatNoFollow(join(cwd,
|
|
346
|
+
if (first.accepted) return ok('index', 'already-current', `${INDEX}: ${describeKeptFits()} — nothing written`);
|
|
347
|
+
const found = lstatNoFollow(join(cwd, INDEX), lstat) === null ? null : read(join(cwd, INDEX));
|
|
348
348
|
const restored = found === null ? 'the navigator was put back: found absent, it was removed again' : 'the navigator was put back byte for byte';
|
|
349
349
|
const restoreThen = (failure, compose) => {
|
|
350
350
|
const refused = putBackIndex(cwd, found, deps);
|
|
351
|
-
return refused === null ? compose() : loud('index', 'write-refused', `${
|
|
351
|
+
return refused === null ? compose() : loud('index', 'write-refused', `${INDEX}: putting the navigator back failed (${refused})${failure ? ` after ${failure}` : ''} — a navigator ${describeKeptJudge()} rejects may stand; re-read it before re-running`);
|
|
352
352
|
};
|
|
353
353
|
const run = drive('--ensure-index');
|
|
354
354
|
const refusal = String(run.stderr ?? '').match(ENSURE_INDEX_REFUSAL);
|
|
355
355
|
if (run.error || run.status !== 0 || !String(run.stdout ?? '').match(ENSURE_INDEX_OUTCOME)) {
|
|
356
356
|
const cause = run.error ? 'generator-unlaunchable' : run.status === 2 && refusal ? (refusal[1] === 'write-refused' ? 'write-refused' : 'index-probe-failed') : 'generator-failed';
|
|
357
357
|
const what = run.error ? `the bundled generator could not be started (${causeOf(run.error)})` : describeExitWithOutput(run, 'the bundled generator');
|
|
358
|
-
return restoreThen(what, () => loud('index', cause, `${
|
|
358
|
+
return restoreThen(what, () => loud('index', cause, `${INDEX}: ${what} — ${restored}`));
|
|
359
359
|
}
|
|
360
360
|
let second;
|
|
361
|
-
try { second = judge(); } catch (err) { return restoreThen(`the navigator could not be read back (${causeOf(err)})`, () => loud('index', 'unexpected-error', `${
|
|
361
|
+
try { second = judge(); } catch (err) { return restoreThen(`the navigator could not be read back (${causeOf(err)})`, () => loud('index', 'unexpected-error', `${INDEX}: the navigator could not be read back after the bundled write (${causeOf(err)}) — ${restored}`)); }
|
|
362
362
|
if (second.error) return restoreThen(`${describeKeptJudge()} could not answer (${second.error})`, () => reportUnanswered(second, restored));
|
|
363
|
-
if (second.accepted) return ok('index', 'regenerated', `${
|
|
364
|
-
return restoreThen(null, () => ok('index', 'customized-preserved', `${
|
|
363
|
+
if (second.accepted) return ok('index', 'regenerated', `${INDEX}: written by the bundled generator — ${describeKeptFits()}`);
|
|
364
|
+
return restoreThen(null, () => ok('index', 'customized-preserved', `${INDEX}: ${describeKeptJudge()} rejected the bundled render on ${second.half} (${second.said}), and the navigator as found did not pass it either (${first.half}) — ${restored}. The route: ${KEPT_ROUTE}`));
|
|
365
365
|
};
|
|
366
366
|
|
|
367
367
|
const buildKeptDryRunNote = (hook) =>
|
|
@@ -374,11 +374,11 @@ export const ensureIndex = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
|
374
374
|
const generator = pathIn(kitRoot, readChecker().bundled);
|
|
375
375
|
const drive = (mode) => spawn(process.execPath, [generator, mode, `--root=${cwd}`], { encoding: 'utf8' });
|
|
376
376
|
const unlaunchable = (result) =>
|
|
377
|
-
loud('index', 'generator-unlaunchable', `${
|
|
377
|
+
loud('index', 'generator-unlaunchable', `${INDEX}: the bundled generator could not be started, so nothing was probed or written — reinstall the kit. ${causeOf(result.error)}`);
|
|
378
378
|
|
|
379
|
-
const probe = probeSeedTarget(join(cwd,
|
|
379
|
+
const probe = probeSeedTarget(join(cwd, INDEX), lstat);
|
|
380
380
|
if (probe.wrongKind) {
|
|
381
|
-
return loud('index', 'wrong-node-kind', `${
|
|
381
|
+
return loud('index', 'wrong-node-kind', `${INDEX}: exists but is ${probe.wrongKind} — the navigator is a generated file and this is not one; nothing was read or written, resolve it by hand and re-run`);
|
|
382
382
|
}
|
|
383
383
|
const hook = surveyHook(cwd, kitRoot, read, lstat);
|
|
384
384
|
const wrong = hook.find((entry) => entry.state === 'wrong-kind');
|
|
@@ -392,9 +392,9 @@ export const ensureIndex = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
|
392
392
|
const check = drive('--check-index');
|
|
393
393
|
if (check.error) return unlaunchable(check);
|
|
394
394
|
const out = bothStreams(check);
|
|
395
|
-
if (check.status === 0 && PROBE_FRESH.test(out)) return ok('index', 'already-current', `${
|
|
396
|
-
if (check.status === 1 && PROBE_STALE.test(out)) return ok('index', 'would-regenerate', `${
|
|
397
|
-
return loud('index', 'index-probe-failed', `${
|
|
395
|
+
if (check.status === 0 && PROBE_FRESH.test(out)) return ok('index', 'already-current', `${INDEX}: in sync with the source frontmatter — nothing would be written`, ...dryNote);
|
|
396
|
+
if (check.status === 1 && PROBE_STALE.test(out)) return ok('index', 'would-regenerate', `${INDEX}: missing or stale — would be written from the source frontmatter`, ...dryNote);
|
|
397
|
+
return loud('index', 'index-probe-failed', `${INDEX}: the freshness probe answered neither fresh nor stale (exited ${describeExit(check)}), so nothing was written. ${out}`, ...dryNote);
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
const run = drive('--ensure-index');
|
|
@@ -405,12 +405,12 @@ export const ensureIndex = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
|
405
405
|
// The generator's OWN closed refusals: a write it would not publish, and a probe that could not
|
|
406
406
|
// answer. Each keeps its identity here rather than collapsing into "the generator failed".
|
|
407
407
|
const cause = refusal[1] === 'write-refused' ? 'write-refused' : 'index-probe-failed';
|
|
408
|
-
return loud('index', cause, `${
|
|
408
|
+
return loud('index', cause, `${INDEX}: ${bothStreams(run)}`);
|
|
409
409
|
}
|
|
410
410
|
if (run.status !== 0 || !outcome) {
|
|
411
|
-
return loud('index', 'generator-failed', `${
|
|
411
|
+
return loud('index', 'generator-failed', `${INDEX}: the generator exited ${describeExit(run)} without a recognized outcome line — ${MAY_HAVE_WRITTEN}. ${bothStreams(run)}`);
|
|
412
412
|
}
|
|
413
|
-
if (outcome[1] === 'already-current') return ok('index', 'already-current', `${
|
|
413
|
+
if (outcome[1] === 'already-current') return ok('index', 'already-current', `${INDEX}: in sync with the source frontmatter — nothing written`);
|
|
414
414
|
|
|
415
415
|
// A claimed regeneration is not a verified one: re-probe, so `regenerated` names a state this run
|
|
416
416
|
// PROVED rather than a line the generator printed. The verdict is read from the probe's own two
|
|
@@ -419,12 +419,12 @@ export const ensureIndex = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
|
419
419
|
const verify = drive('--check-index');
|
|
420
420
|
const verdict = verify.error ? '' : bothStreams(verify);
|
|
421
421
|
if (!verify.error && verify.status === 0 && PROBE_FRESH.test(verdict)) {
|
|
422
|
-
return ok('index', 'regenerated', `${
|
|
422
|
+
return ok('index', 'regenerated', `${INDEX}: written from the source frontmatter — the navigator is in sync again`);
|
|
423
423
|
}
|
|
424
424
|
if (!verify.error && verify.status === 1 && PROBE_STALE.test(verdict)) {
|
|
425
|
-
return loud('index', 'index-stale-after-write', `${
|
|
425
|
+
return loud('index', 'index-stale-after-write', `${INDEX}: the generator reported a regeneration, but the re-probe still reads the navigator as missing or stale — ${MAY_HAVE_WRITTEN}. ${verdict}`);
|
|
426
426
|
}
|
|
427
|
-
return loud('index', 'index-probe-failed', `${
|
|
427
|
+
return loud('index', 'index-probe-failed', `${INDEX}: the generator reported a regeneration, but the verifying probe answered neither fresh nor stale — ${MAY_HAVE_WRITTEN}. ${verify.error ? causeOf(verify.error) : verdict}`);
|
|
428
428
|
};
|
|
429
429
|
|
|
430
430
|
// The ops this module owns, by name. The CLI composes the full ENSURE_OPS table from these plus
|
package/tools/ensure-specs.mjs
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { readFileSync, lstatSync } from 'node:fs';
|
|
25
25
|
import { join } from 'node:path';
|
|
26
|
+
import { SPEC_STORE_INDEX } from '../references/scripts/shared/index.mjs';
|
|
26
27
|
import { lstatNoFollow, writeContainedFileAtomic, writeProjectFileCreateOnly } from './atomic-write.mjs';
|
|
27
28
|
import { readDeployedScripts } from './node-evidence.mjs';
|
|
28
29
|
import { SCRIPT_PRIORS, classifyDeployedScript } from './script-priors.mjs';
|
|
@@ -30,7 +31,6 @@ import { bundledImportsOf, composeFailure, composeOutcome, dependenciesFirst, no
|
|
|
30
31
|
import { fileLine, hookLine } from './distribution-files/index.mjs';
|
|
31
32
|
|
|
32
33
|
const OP = 'specs';
|
|
33
|
-
const STORE_ROOT_REL = 'docs/ai/specs/index.md';
|
|
34
34
|
const STORE_ROOT_TEMPLATE = ['references', 'templates', 'specs', 'index.md'];
|
|
35
35
|
const DATE_PLACEHOLDER = '{{DATE}}';
|
|
36
36
|
|
|
@@ -87,9 +87,9 @@ const surveyScript = (cwd, f, deps, read, lstat) => {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
const surveyStoreRoot = (cwd, lstat) => {
|
|
90
|
-
const probe = probeSeedTarget(join(cwd,
|
|
91
|
-
if (probe.wrongKind) return { rel:
|
|
92
|
-
return { rel:
|
|
90
|
+
const probe = probeSeedTarget(join(cwd, SPEC_STORE_INDEX), lstat);
|
|
91
|
+
if (probe.wrongKind) return { rel: SPEC_STORE_INDEX, state: 'wrong-kind', wrongKind: probe.wrongKind };
|
|
92
|
+
return { rel: SPEC_STORE_INDEX, state: probe.present ? 'present' : 'absent' };
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
// ── the lines (composed from what HAPPENED: each file's state and the fate of its write) ─────────
|
|
@@ -107,7 +107,7 @@ const STORE_LINES = {
|
|
|
107
107
|
};
|
|
108
108
|
const composeLines = ({ files, store, fates, dryRun }) => [
|
|
109
109
|
...files.map((f) => (f.state === 'current' ? `${f.rel}: ${CURRENT}` : fileLine(f, fates.get(f.rel), dryRun))),
|
|
110
|
-
`${
|
|
110
|
+
`${SPEC_STORE_INDEX}: ${STORE_LINES[store.state === 'present' ? 'present' : fates.get(SPEC_STORE_INDEX) ?? (dryRun ? 'would' : 'stopped')]}`,
|
|
111
111
|
];
|
|
112
112
|
|
|
113
113
|
// A per-file loop can stop partway; the run says which files already landed — never "nothing happened".
|
|
@@ -128,7 +128,7 @@ const writeAll = ({ cwd, due, storeBody, deps, read }) => {
|
|
|
128
128
|
const fates = new Map();
|
|
129
129
|
const notes = [];
|
|
130
130
|
for (const f of due) {
|
|
131
|
-
const isStore = f.rel ===
|
|
131
|
+
const isStore = f.rel === SPEC_STORE_INDEX;
|
|
132
132
|
let result;
|
|
133
133
|
try {
|
|
134
134
|
result = isStore ? writeProjectFileCreateOnly(cwd, f.rel, storeBody, deps, { noun: 'the spec store root' })
|
|
@@ -182,7 +182,7 @@ export const ensureSpecs = ({ cwd, kitRoot, dryRun = false, deps = {} }) => {
|
|
|
182
182
|
try {
|
|
183
183
|
storeBody = renderStoreRoot(kitRoot, read, deps.today ?? todayIso());
|
|
184
184
|
} catch (err) {
|
|
185
|
-
return composeFailure(OP, 'template-unreadable', `${
|
|
185
|
+
return composeFailure(OP, 'template-unreadable', `${SPEC_STORE_INDEX}: ${causeOf(err)}`, ...composeLines({ files, store, fates: new Map(), dryRun }));
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
const { fates, notes, failure } = writeAll({ cwd, due, storeBody, deps, read });
|
package/tools/epic-shape-cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { constants, openSync, closeSync, fstatSync, writeSync, ftruncateSync } from 'node:fs';
|
|
3
3
|
import { basename, dirname, resolve } from 'node:path';
|
|
4
|
-
import { fail } from '../references/scripts/shared/index.mjs';
|
|
4
|
+
import { EPIC_STORE, fail } from '../references/scripts/shared/index.mjs';
|
|
5
5
|
import { isDirectRun } from './direct-run.mjs';
|
|
6
6
|
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
7
7
|
import { readEpicEntries } from './epic-store.mjs';
|
|
@@ -21,7 +21,7 @@ const VERB_ARITY = 2;
|
|
|
21
21
|
const FIRST_LINE = 1;
|
|
22
22
|
const PREFIX = 'epic-shape:';
|
|
23
23
|
const INFO = 'info';
|
|
24
|
-
const STORE_TO_PROJECT = '
|
|
24
|
+
const STORE_TO_PROJECT = EPIC_STORE.split('/').map(() => '..').join('/');
|
|
25
25
|
const LANDED_BYTES = Buffer.from('landed');
|
|
26
26
|
const HELP = `Usage:
|
|
27
27
|
node epic-shape-cli.mjs --check <epic>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { posix } from 'node:path';
|
|
2
|
-
import { tokenizeMarkdown } from '../references/scripts/shared/index.mjs';
|
|
2
|
+
import { EPIC_STORE, QUEUE, tokenizeMarkdown } from '../references/scripts/shared/index.mjs';
|
|
3
3
|
import { parseHeader, checkEpic } from './epic-shape.mjs';
|
|
4
4
|
import { auditQueue } from './queue-audit.mjs';
|
|
5
5
|
import { hasPathOverlap, findReachable, listStories, unique } from './claim-relation.mjs';
|
|
6
|
+
import { escapeRegExp } from './repo-lex.mjs';
|
|
6
7
|
|
|
7
8
|
const FIRST_LINE = 1;
|
|
8
9
|
const ERROR = 'error';
|
|
@@ -15,10 +16,9 @@ const OWN = 'owns';
|
|
|
15
16
|
const FRONT_DELIMITER = '---';
|
|
16
17
|
const CR_END = /\r$/;
|
|
17
18
|
const MARKDOWN_SUFFIX = '.md';
|
|
18
|
-
export const STORE_PATH =
|
|
19
|
-
export const QUEUE_PATH =
|
|
19
|
+
export const STORE_PATH = new RegExp(`^(?:(.*)/)?${escapeRegExp(EPIC_STORE)}/([^/]+)\\.md$`);
|
|
20
|
+
export const QUEUE_PATH = QUEUE;
|
|
20
21
|
const TOKEN_EDGE = '[\\p{L}\\p{N}_-]';
|
|
21
|
-
const REGEX_BYTES = /[.*+?^${}()|[\]\\]/g;
|
|
22
22
|
const PARSE_REFUSALS = Object.freeze([1, 2]);
|
|
23
23
|
const makeFinding = (path, line, code, message, severity = ERROR) => ({ path, line, code, message: `${path}: ${message}`, severity });
|
|
24
24
|
const finishJudgement = (findings, data = {}) => ({ ...data, ok: !findings.some((finding) => finding.severity === ERROR), findings });
|
|
@@ -120,7 +120,7 @@ export const sweepSiblings = (entries, root) => {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
const carriesToken = (title, id) => {
|
|
123
|
-
const escaped = id
|
|
123
|
+
const escaped = escapeRegExp(id);
|
|
124
124
|
return new RegExp(`(?<!${TOKEN_EDGE})${escaped}(?!${TOKEN_EDGE})`, 'u').test(title);
|
|
125
125
|
};
|
|
126
126
|
const describeQueue = (queue) => [queue?.outcome, queue?.reason].filter((part) => part !== undefined).join(': ')
|
package/tools/epic-shape.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { PLANS, QUEUE as QUEUE_LOCATION, tokenizeMarkdown } from '../references/scripts/shared/index.mjs';
|
|
2
3
|
import { bulletBlocks, getLineCount, unique } from './plan-shape.mjs';
|
|
4
|
+
import { escapeRegExp } from './repo-lex.mjs';
|
|
3
5
|
|
|
4
6
|
export const EPIC_SECTIONS = Object.freeze([
|
|
5
7
|
'## Intent', '## Value', '## Non-goals', '## Acceptance', '## Specs', '## Stories ledger', '## Queue',
|
|
@@ -29,8 +31,8 @@ const STATE_FIELD = /^state: (planned|in-flight|landed (\d{4}-\d{2}-\d{2}))$/;
|
|
|
29
31
|
const HEADER_FIELD = /^([A-Za-z][A-Za-z0-9]*):([ \t]*)(.*?)[ \t]*\r?$/;
|
|
30
32
|
const QUEUE_LINE = /^Row (\S+) in (\S(?:.*\S)?)$/;
|
|
31
33
|
const RESULT_LINE = /^Result line: (\d{4}-\d{2}-\d{2})$/;
|
|
32
|
-
const PLAN_PATH = /
|
|
33
|
-
const QUEUE_NAME =
|
|
34
|
+
const PLAN_PATH = new RegExp(`${escapeRegExp(PLANS)}/([^\\s\`()[\\]{}<>|,:;"']+\\.md)(?=$|[\\s\`()[\\]{}<>|,:;"'.!?])`, 'g');
|
|
35
|
+
const QUEUE_NAME = posix.basename(QUEUE_LOCATION);
|
|
34
36
|
const FENCE_LINE = /^\s*(?:`{3,}[^`]*|~{3,}.*)$/;
|
|
35
37
|
const BACKTICK_RUN = /`+/g;
|
|
36
38
|
const CITATION = /[^\s`()[\]{}<>|:;,"'!?]+[./][^\s`()[\]{}<>|:;,"'!?]+:\d+(?![\dA-Za-z_])/;
|
package/tools/epic-store.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { lstatSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { EPIC_STORE } from '../references/scripts/shared/index.mjs';
|
|
3
4
|
import { describeNonRegular, readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
4
5
|
|
|
5
|
-
export const EPICS_REL =
|
|
6
|
+
export const EPICS_REL = EPIC_STORE;
|
|
6
7
|
const MARKDOWN_SUFFIX = '.md';
|
|
7
8
|
const ABSENT_CODE = 'ENOENT';
|
|
8
9
|
const REGULAR_FILE = 'regular file';
|
package/tools/family-members.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// family-members.mjs — the
|
|
1
|
+
// family-members.mjs — the one authoritative table of agent-workflow family members.
|
|
2
2
|
//
|
|
3
3
|
// Extracted from family-registry.mjs so the two consumers that only need the static table — the npx
|
|
4
4
|
// installer (bin/install.mjs, which derives its init-refresh cascade from it) and family-registry
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
// (detect-backends, the manifest validator, hide-footprint, engine-source, recipes, the renderers …).
|
|
7
7
|
// install.mjs runs on the npx cold-start hot path, so the leaner import matters; single-source-of-truth
|
|
8
8
|
// + the drift-guard (family-registry.test.mjs pins FAMILY_MEMBERS to the 6 in-repo capability.json)
|
|
9
|
-
// are preserved
|
|
9
|
+
// are preserved.
|
|
10
10
|
//
|
|
11
|
-
// Pure data
|
|
11
|
+
// Pure data with stamps from the shared index, no side effects, Node >= 22.
|
|
12
|
+
|
|
13
|
+
import { MEMORY_STAMP, WORKFLOW_STAMP } from '../references/scripts/shared/index.mjs';
|
|
12
14
|
|
|
13
15
|
// ── the unified registry ───────────────────────────────────────────────────────
|
|
14
16
|
// One entry per family member. `installed` is the detect.installed spec (env + home-relative default
|
|
@@ -24,7 +26,7 @@ export const FAMILY_MEMBERS = [
|
|
|
24
26
|
name: 'agent-workflow-kit',
|
|
25
27
|
kind: 'composition-root',
|
|
26
28
|
installed: { env: 'AGENT_WORKFLOW_KIT_DIR', default: '~/.claude/skills/agent-workflow-kit', file: 'SKILL.md' },
|
|
27
|
-
deployed: { file:
|
|
29
|
+
deployed: { file: WORKFLOW_STAMP },
|
|
28
30
|
npm: '@sabaiway/agent-workflow-kit',
|
|
29
31
|
wrapperCmds: [],
|
|
30
32
|
},
|
|
@@ -32,7 +34,7 @@ export const FAMILY_MEMBERS = [
|
|
|
32
34
|
name: 'agent-workflow-memory',
|
|
33
35
|
kind: 'memory-substrate',
|
|
34
36
|
installed: { env: 'AGENT_WORKFLOW_MEMORY_DIR', default: '~/.claude/skills/agent-workflow-memory', file: 'SKILL.md' },
|
|
35
|
-
deployed: { file:
|
|
37
|
+
deployed: { file: MEMORY_STAMP },
|
|
36
38
|
npm: '@sabaiway/agent-workflow-memory',
|
|
37
39
|
wrapperCmds: [],
|
|
38
40
|
},
|
|
@@ -52,10 +52,10 @@ import { HOOK_FILE_REL as GATE_HOOK_FILE_REL, isHookWired } from './gate-hook.mj
|
|
|
52
52
|
// writer, which pulls in the atomic-write core) so the status survey stays a pure reader.
|
|
53
53
|
import { settingsSnapshot } from './bridge-settings-read.mjs';
|
|
54
54
|
import { GATES_REL, loadDeclaration } from './run-gates.mjs';
|
|
55
|
-
// The cheap-agents READ core's bundle reader, placement planner and executor
|
|
55
|
+
// The cheap-agents READ core's bundle reader, placement planner and executor and author vehicle surveys —
|
|
56
56
|
// reused by the settings survey (one implementation, never a drifting copy; the read core imports
|
|
57
57
|
// only node builtins, no cycle).
|
|
58
|
-
import { readBundledAgents, planPlacement, surveyExecutorVehicle, EXECUTOR_VEHICLE, assertDirSafe, readFsDeps, CLAUDE_DIR, AGENTS_DIR } from './cheap-agents-read.mjs';
|
|
58
|
+
import { readBundledAgents, planPlacement, surveyExecutorVehicle, surveyAuthorVehicle, EXECUTOR_VEHICLE, AUTHOR_VEHICLE, assertDirSafe, readFsDeps, CLAUDE_DIR, AGENTS_DIR } from './cheap-agents-read.mjs';
|
|
59
59
|
// The status vocabulary (manifestState constants, internal→public maps, display names, the no-leak
|
|
60
60
|
// forbidden set) lives in the frozen labels.mjs LEAF (Plan §4.2 B1) so the import graph is acyclic —
|
|
61
61
|
// nothing imports family-registry for vocabulary. Imported here for internal use; the public subset is
|
|
@@ -87,6 +87,7 @@ import { render } from './renderers.mjs';
|
|
|
87
87
|
import { ADOPTION, readDeclineAck, surveySpecAdoption } from './spec-adoption.mjs';
|
|
88
88
|
import { KIT_COMMANDS } from '../references/scripts/run.mjs';
|
|
89
89
|
import { KIT_SCRIPTS_DIR } from './node-evidence.mjs';
|
|
90
|
+
import { ADR_STORE, DECISIONS, DECISIONS_ARCHIVE, DECISIONS_ARCHIVE_EARLY, DOCS_TREE, GIT_EXCLUDE } from '../references/scripts/shared/index.mjs';
|
|
90
91
|
|
|
91
92
|
// ── manifestState values — re-export the EXACT public subset family-registry exported before B1 ─────
|
|
92
93
|
// (the 7 state constants + DISPLAY_NAMES) so every existing importer (uninstall.mjs, the test suites)
|
|
@@ -104,7 +105,7 @@ export {
|
|
|
104
105
|
|
|
105
106
|
// ── the unified registry ───────────────────────────────────────────────────────
|
|
106
107
|
// FAMILY_MEMBERS (+ isGlobalSkill) is the one authoritative member table. It moved to the
|
|
107
|
-
//
|
|
108
|
+
// data module family-members.mjs (shared index only) so the npx installer can derive its init-refresh cascade
|
|
108
109
|
// from the table WITHOUT importing this whole status/presenter graph (a leaner npx cold-start path).
|
|
109
110
|
// Re-exported here so every existing importer (uninstall.mjs, the test suites) stays green, and the
|
|
110
111
|
// drift-guard (family-registry.test.mjs) still pins the table to the 5 in-repo capability.json.
|
|
@@ -334,7 +335,7 @@ const hasHiddenFence = (projectDir, deps = {}) => {
|
|
|
334
335
|
try {
|
|
335
336
|
return excludePath(deps, projectDir);
|
|
336
337
|
} catch {
|
|
337
|
-
return join(projectDir,
|
|
338
|
+
return join(projectDir, GIT_EXCLUDE);
|
|
338
339
|
}
|
|
339
340
|
})();
|
|
340
341
|
try {
|
|
@@ -347,18 +348,18 @@ const hasHiddenFence = (projectDir, deps = {}) => {
|
|
|
347
348
|
// The retired 3-tier ADR monoliths (AD-051): their presence is the old-layout signal the status
|
|
348
349
|
// view reports; the upgrade's run of the kit's rotator moves it. Stable relative paths (a status
|
|
349
350
|
// probe never imports the rotator).
|
|
350
|
-
// The ADR-layout probe
|
|
351
|
-
// `status` view
|
|
352
|
-
//
|
|
351
|
+
// The ADR-layout probe shares its paths with the rotator through the shared index. The read-only
|
|
352
|
+
// `status` view reads the deployed rotator as text. A drift guard in family-registry.test.mjs
|
|
353
|
+
// checks the paths against the rotator's exports and the scheme marker against its declaration.
|
|
353
354
|
export const ADR_LAYOUT_PATHS = Object.freeze({
|
|
354
|
-
hot:
|
|
355
|
-
monoliths: Object.freeze([
|
|
356
|
-
store:
|
|
357
|
-
// The DEPLOYED rotator
|
|
358
|
-
//
|
|
355
|
+
hot: DECISIONS,
|
|
356
|
+
monoliths: Object.freeze([DECISIONS_ARCHIVE, DECISIONS_ARCHIVE_EARLY]),
|
|
357
|
+
store: ADR_STORE,
|
|
358
|
+
// The DEPLOYED rotator identifies the new scheme by a line starting with the ADR_DIR_REL export.
|
|
359
|
+
// Never "has decisions.md, lacks adr/" — that shape false-positives a
|
|
359
360
|
// tree whose NEW rotator already reds its own gate, and every No-Node project.
|
|
360
361
|
rotator: posix.join(KIT_SCRIPTS_DIR, KIT_COMMANDS['archive-decisions']),
|
|
361
|
-
storeMarker: '
|
|
362
|
+
storeMarker: 'export const ADR_DIR_REL',
|
|
362
363
|
});
|
|
363
364
|
const ENOENT = 'ENOENT';
|
|
364
365
|
|
|
@@ -396,13 +397,14 @@ export const surveyAdrLayoutStrict = (dir, deps = {}) => {
|
|
|
396
397
|
|
|
397
398
|
if (ADR_LAYOUT_PATHS.monoliths.some((rel) => isA(rel, PATH_FILE))) return 'old';
|
|
398
399
|
|
|
399
|
-
//
|
|
400
|
-
//
|
|
401
|
-
//
|
|
400
|
+
// Without a monolith, the rotator's scheme decides the answer for an existing store too: an
|
|
401
|
+
// old-scheme rotator beside a store is not finished — until `upgrade` replaces it with the
|
|
402
|
+
// bundled rotator, it will write a monolith again the next time it rotates.
|
|
402
403
|
const rotatorScheme = (() => {
|
|
403
404
|
if (!isA(ADR_LAYOUT_PATHS.rotator, PATH_FILE)) return null;
|
|
404
405
|
try {
|
|
405
|
-
|
|
406
|
+
const rotatorSource = String(read(join(dir, ADR_LAYOUT_PATHS.rotator), 'utf8'));
|
|
407
|
+
return rotatorSource.split('\n').some((line) => line.startsWith(ADR_LAYOUT_PATHS.storeMarker)) ? 'new' : 'old';
|
|
406
408
|
} catch (err) {
|
|
407
409
|
if (absent(err)) return null;
|
|
408
410
|
throw err;
|
|
@@ -465,7 +467,7 @@ export const surveyProject = (projectDir, deps = {}) => {
|
|
|
465
467
|
.map((m) => ({ name: m.name, file: m.deployed.file, version: readStamp(join(dir, m.deployed.file), deps) }));
|
|
466
468
|
const docsAiPresent = (() => {
|
|
467
469
|
try {
|
|
468
|
-
return exists(join(dir,
|
|
470
|
+
return exists(join(dir, DOCS_TREE));
|
|
469
471
|
} catch {
|
|
470
472
|
return false;
|
|
471
473
|
}
|
|
@@ -525,7 +527,7 @@ export const surveyVisibility = (dir, deps = {}) => {
|
|
|
525
527
|
|
|
526
528
|
// orchestration recipes: the EFFECTIVE recipe per slot (config · default · effective), engine-free —
|
|
527
529
|
// shared loadConfig + resolveActivityRecipe + the ONE readiness composition (detected backends +
|
|
528
|
-
// the executor
|
|
530
|
+
// the executor and author vehicles). A malformed config → a localized error field; a detection failure floors
|
|
529
531
|
// at solo (a corrupt bridge must not break the view) but is surfaced as `detectError`, so the
|
|
530
532
|
// render says "couldn't check backends" instead of letting a real solo-default look identical.
|
|
531
533
|
export const surveyRecipes = (dir, deps = {}) => {
|
|
@@ -615,33 +617,37 @@ export const surveyGateHook = (dir, deps = {}) => {
|
|
|
615
617
|
};
|
|
616
618
|
|
|
617
619
|
// cheap agents: the kit-placed .claude/agents/ vehicles (Mode: agents) — how many of the bundled
|
|
618
|
-
// definitions
|
|
619
|
-
// copy counts as PLACED (it exists; the writer
|
|
620
|
-
// zero placed, so the counts span every vehicle, the executor included.
|
|
621
|
-
// from the read core's
|
|
622
|
-
//
|
|
620
|
+
// definitions count as placed in the project, plus the author and executor vehicles' own states. A customized executor
|
|
621
|
+
// copy counts as PLACED (it exists; the agents writer writes it current) — the welcome-mat agents rung keys on
|
|
622
|
+
// zero placed, so the counts span every vehicle, the author and executor included. Their states come
|
|
623
|
+
// from the read core's surveys (the subagent carrier's instrument per role — one implementation each), which
|
|
624
|
+
// answer a state instead of throwing; each reason rides along when the survey carries one.
|
|
623
625
|
export const surveyCheapAgents = (dir, deps = {}) => {
|
|
624
626
|
try {
|
|
625
627
|
const projectDir = resolve(dir);
|
|
626
628
|
const templates = readBundledAgents(deps);
|
|
627
629
|
const vehicle = (deps.surveyVehicle ?? surveyExecutorVehicle)(projectDir, deps);
|
|
628
|
-
|
|
629
|
-
//
|
|
630
|
+
const authorVehicle = (deps.surveyAuthorVehicle ?? surveyAuthorVehicle)(projectDir, deps);
|
|
631
|
+
// The author and executor are judged by their own surveys (which answer a state where the placement plan
|
|
632
|
+
// would throw); the plan covers the read-only vehicles, so a broken author or executor never hides them,
|
|
630
633
|
// and it never follows a symlinked ancestor — the writer's own guard refuses first.
|
|
631
634
|
const executor = { executor: vehicle.state, ...(vehicle.reason ? { executorReason: safeLine(vehicle.reason) } : {}) };
|
|
635
|
+
const author = { author: authorVehicle.state, ...(authorVehicle.reason ? { authorReason: safeLine(authorVehicle.reason) } : {}) };
|
|
632
636
|
try {
|
|
633
637
|
const fs = readFsDeps(deps);
|
|
634
638
|
assertDirSafe(join(projectDir, CLAUDE_DIR), CLAUDE_DIR, fs);
|
|
635
639
|
assertDirSafe(join(projectDir, AGENTS_DIR), AGENTS_DIR, fs);
|
|
636
|
-
const
|
|
640
|
+
const readOnly = templates.filter((t) => t.name !== EXECUTOR_VEHICLE && t.name !== AUTHOR_VEHICLE);
|
|
641
|
+
const plan = planPlacement(readOnly, projectDir, deps);
|
|
637
642
|
return {
|
|
638
643
|
bundled: templates.length,
|
|
639
|
-
readOnly:
|
|
640
|
-
placed: plan.filter((p) => p.action !== 'place').length + (['placed', 'customized'].includes(vehicle.state) ? 1 : 0),
|
|
644
|
+
readOnly: readOnly.length,
|
|
645
|
+
placed: plan.filter((p) => p.action !== 'place').length + (['placed', 'customized'].includes(vehicle.state) ? 1 : 0) + (authorVehicle.state === 'placed' ? 1 : 0),
|
|
646
|
+
...author,
|
|
641
647
|
...executor,
|
|
642
648
|
};
|
|
643
649
|
} catch (err) {
|
|
644
|
-
return { error: localizeError(err), ...executor };
|
|
650
|
+
return { error: localizeError(err), ...author, ...executor };
|
|
645
651
|
}
|
|
646
652
|
} catch (err) {
|
|
647
653
|
return { error: localizeError(err) };
|