@sabaiway/agent-workflow-kit 23.6.0 → 23.8.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 +51 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/recommendations.md +1 -1
- package/tools/gates-init.mjs +5 -5
- package/tools/recommendations.mjs +25 -26
- package/tools/source-size/help.mjs +56 -0
- package/tools/source-size/index.mjs +14 -0
- package/tools/source-size/reason.mjs +32 -0
- package/tools/source-size-check.mjs +31 -280
- package/tools/source-size-config.mjs +1 -3
- package/tools/source-size-core.mjs +7 -0
- package/tools/source-size-judge.mjs +10 -4
- package/tools/source-size-report.mjs +97 -108
- package/tools/source-size-runs.mjs +290 -0
- package/tools/source-size-scope.mjs +70 -24
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,57 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 23.8.0 — the size record's reasons stay honest, and every run says what its scope left out (AD-236)
|
|
8
|
+
|
|
9
|
+
**After `/agent-workflow-kit upgrade`, the kit writes its own reason `initial adoption` only into record entries the
|
|
10
|
+
write itself creates, and every size check, regeneration and override says what its declared scope did not judge.**
|
|
11
|
+
Before, the recovery line of a half-written size record printed `--reason "initial adoption"`, and run as printed it
|
|
12
|
+
replaced a reason a person had written on a grown entry; an `exclude` entry that matched nothing, and a new file git
|
|
13
|
+
did not know yet, were said by no line.
|
|
14
|
+
|
|
15
|
+
- **`initial adoption` is accepted only for a part of the record the config does not hold yet.** A regeneration that
|
|
16
|
+
raises an entry in a part that already exists refuses it by name and prints the whole change it would write;
|
|
17
|
+
`--override` never takes it.
|
|
18
|
+
- **Every line the kit prints to mint or recover a record carries the placeholder `<why this size is accepted>`**
|
|
19
|
+
wherever the kit's sentence would be refused, and the command line refuses a placeholder as a reason (exit 2,
|
|
20
|
+
`--reason still carries the placeholder …`). The reason is the agent's to write, with no question to the user.
|
|
21
|
+
- **A minted schema-1 config whose tree grew moves to schema 2 even when the regeneration is refused:** the move is written
|
|
22
|
+
and said first, then the raise is refused.
|
|
23
|
+
- **One note per `exclude` entry** on every check, regeneration and override: how many tracked paths under the
|
|
24
|
+
declared roots it left out, or that it left out nothing and why (no tracked path carries it, or the paths that do
|
|
25
|
+
lie outside every declared root). An entry is a literal path prefix, never a pattern.
|
|
26
|
+
- **Two warnings, echoed by `run-gates`:** paths the run would judge that are untracked and not ignored, so the
|
|
27
|
+
index-based scope did not include them, and judged files whose work-tree bytes differ from the index, which the check measures as they stand on
|
|
28
|
+
disk. Each names the first few paths. A refused regeneration or override prints them ahead of its refusal.
|
|
29
|
+
- **The advisor's size item says what holds:** with no gate declared it says so, and never that sizes go unmeasured;
|
|
30
|
+
over a minted record it says the record is kept, and its `--adopt` line carries no reason.
|
|
31
|
+
- **Stated limits:** `--adopt` prints no note and no warning when its check is green; a placeholder already in a
|
|
32
|
+
config, or pasted by hand from the check's hand-record entries, keeps reading; the spec store's layout is counted
|
|
33
|
+
from disk; a judged file differs only where git reports a work-tree change and its bytes differ from the index, so
|
|
34
|
+
a change of file mode alone or a line-ending conversion is no differing file.
|
|
35
|
+
|
|
36
|
+
## 23.7.0 — a failed size check shows what failed and the fix first (AD-235)
|
|
37
|
+
|
|
38
|
+
**After `/agent-workflow-kit upgrade`, a red `source-size-check.mjs --check` run opens with its failure, and so do, in
|
|
39
|
+
every mode, a tree the check cannot judge, a config error, a usage refusal and an unexpected error.** Before, a `--check`
|
|
40
|
+
that stopped printed the five limit lines, the notes and the warnings first, and the findings came last, indented under
|
|
41
|
+
a FAIL line; a refusal of the tree, the config or the command line went to standard error, apart from everything else.
|
|
42
|
+
|
|
43
|
+
- **A stop leads with three parts:** `source-size: FAIL — <what failed>`, each finding at column one starting with its
|
|
44
|
+
file or folder, and `source-size: REMEDY — <the command that fixes it>` (where the command cannot be printed safely,
|
|
45
|
+
the way to run it by hand). The limits, the not-judged notes, the warnings and the hand-record lines follow, in
|
|
46
|
+
their old order.
|
|
47
|
+
- **Every red output goes to standard output**, standard error stays empty: a file past its cap, a schema-1 or
|
|
48
|
+
unminted config, a tree the check cannot judge, a config error and a usage refusal of any mode.
|
|
49
|
+
- **The refusals the writing modes print themselves keep their lines**, as before — among them `--write-baseline`
|
|
50
|
+
raising a record without `--reason`, `--override` on a record the tree outgrew, and `--adopt` or `--override` on an
|
|
51
|
+
absent config. `--adopt` on a record the tree outgrew prints the check's new block, after any schema-1 move it wrote,
|
|
52
|
+
then that the gate was not declared.
|
|
53
|
+
- **An unexpected error exits 2** (it exited 1) and prints `source-size: FAIL — unexpected error: <its message>`, a
|
|
54
|
+
REMEDY line and the stack.
|
|
55
|
+
- **`--help`** states the new order and the new exit code. Every other run that exits 0 prints what it printed
|
|
56
|
+
before, and every other exit code is unchanged.
|
|
57
|
+
|
|
7
58
|
## 23.6.0 — a changed file that a test runs elsewhere can be committed through the final run (AD-234)
|
|
8
59
|
|
|
9
60
|
**After `/agent-workflow-kit upgrade`, a project can list in `docs/ai/coverage-declared.json` the changed files that
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: agent-workflow-kit
|
|
|
3
3
|
description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
|
-
version: '23.
|
|
6
|
+
version: '23.8.0'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# agent-workflow-kit
|
package/capability.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sabaiway/agent-workflow-kit",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.8.0",
|
|
4
4
|
"description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
|
@@ -37,7 +37,7 @@ A variant's posture note, where its key has one, is printed by `init` from this
|
|
|
37
37
|
|
|
38
38
|
- `gates-inert` — the gate matrix is DECLARED but verifies nothing, and the two causes have different remedies, so the item renders a different apply for each. **Cause A** — a canonical `coverage-check` gate with no producer gate declared BEFORE it (none at all, or one declared after it, which writes the lcov too late): the run certifies no coverage of its own — `coverage=not-run` when nothing wrote an lcov, or a verdict over STALE bytes an earlier run left in the git dir, which is worse because it reads as `coverage=certified`. The remedy needs the producer to run BEFORE the checker — declared or MOVED there. When the checker is the LAST declared gate and the project's own scripts yield an offerable producer, the fill PLACES that producer before it, so the apply is the ordinary `gates-init` dry-run preview. Otherwise — no offerable producer, or a checker that is not last — it is the user item `gates-inert.unfillable`: the user's own step is to edit `docs/ai/gates.json` (the exact producer form lives in `${CLAUDE_SKILL_DIR}/references/modes/gates.md`), because the fill never reorders entries it did not write. When the declaration carries, anywhere, a gate in a form an earlier kit wrote that the upgrade moves (one whose tail holds only test paths), or the fill withheld its `node --test` script because the kit folder does not hold this kit's command and reporter, the apply is `/agent-workflow-kit upgrade` in place of both: it moves an earlier kit's gate with no question, or a line of its report names what stops it. **Cause B** — every declared gate is one of the kit's own canonical checkers, so the matrix runs no project-verification command at all: the apply is the `gates-init` dry-run preview, the same consent-gated seeder the `gates-declaration` item renders, and after the SAME confirmation you run the `--apply` line it prints. Neither cause changes any gate result, exit code or receipt — the item adds no enforcement, only the offer. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file (a declared gate is auto-approvable by the wired hook), so both causes land in the same place — where the fill can help, it declares a project-controlled command on your explicit yes; where it cannot, the edit is the user's own step.
|
|
39
39
|
|
|
40
|
-
- `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading:
|
|
40
|
+
- `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading: the gate matrix reads as running the size check while it runs none, so it is the user's own step (rename the id, or repoint the cmd at this `--check`). **`unminted`**, for both copies: a gate refusing every run over an authored or incomplete record (over an absent one the check judges layout alone), attention, and NO acknowledgement silences it; only the verb differs (with the gate declared elsewhere, `--write-baseline`); a line carrying the placeholder takes your own sentence, by the `recipe:` line. **`schema-1`** — the check stops on a minted schema-1 config, so this arm comes first: its `--write-baseline` line carries NO reason (a pinned one would launder a raise; a raise riding the move refuses, and the agent writes that raise's reason from what the run shows, with no question to the user), every run until the move. **`layout`** — on a config with no layout record, the record of the piles already there comes first, as its own item: a no writes nothing and the item returns every run; its `recipe:` line names the branch states, and `source-size.layout` is applied before the `hook-checks` check line runs, whose layout line follows that record. **`piles`** — each recorded pile with no queue row gets one, at the end of the queue's Later bucket; a write the queue's own declared check would refuse is not made and the stated skip says why. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file, so every arm here either records an acknowledgement or hands you an edit — the kit declares nothing on its own.
|
|
41
41
|
- `gate-hook` — the offer wires the hook on the harness lane: the agent applies it on the chat yes after the check; `init` previews and applies it on the terminal yes as the route the user may take instead. Over a wired hook the key renders the kit item `gate-hook.not-current` instead: the placed hook file is absent or differs from the body the kit writes for it. An older body validates your declaration through its OWN baked copy and goes dark on a key it does not know, such as `lcovProducer` (present, whatever its value), so every gate prompts again with no error anywhere. The agent applies the kit item with no question after the check, whose result names the file with its new digest, and the old one too over a differing file; it writes only the hook file. Risk profile: the offer places a hook file and wires one settings entry; the kit item writes one hook file with the kit's body; the declaration is never touched.
|
|
42
42
|
- `enforcement` — copies the bundled runtime files of `references/scripts/` into the kit folder `scripts/agent-workflow/`, then runs the project's own hook installer, which installs the pre-commit hook. The lane is harness: the agent applies the item on the chat yes after the check, whose result shows each script the kit places with its bytes and the installer it runs with its bytes; `init` applies it on the batch terminal yes as the route the user may take instead. The copy is create-only: an existing file stands and nothing is written through a link, and the offer renders only on no Node evidence. The hook invokes `node` directly, so a committer without it on PATH gets a loud failure. The installer refuses to overwrite a pre-commit hook it did not write: an install it refuses removes the scripts this apply copied, and the item is offered again with the installer's output shown; over a pre-commit hook the installer did not write the item is not offered — its skip names the user's own step. Risk profile: local tooling and a Git hook are added on the chat yes after the check, or on init's y.
|
|
43
43
|
- `hook-checks` — the agent applies the item on the chat yes after the check; `init` applies it on the terminal y as the route the user may take instead. Risk profile: future commits stop on the rules check and, where judged, on the size check's findings — lines, aggregate and layout; over a clone with no pre-commit hook the installer writes its whole hook, so commits also stop on its docs and archive lines.
|
package/tools/gates-init.mjs
CHANGED
|
@@ -71,12 +71,12 @@ import { assertDocsAiDeployment, writeDocsAiFileAtomic, lstatNoFollow } from './
|
|
|
71
71
|
// The source-size practice, through its PURE READ core only (D-18): this module asks whether the
|
|
72
72
|
// practice is minted, never how to mint it — the checker's writer half stays outside the read graph.
|
|
73
73
|
import {
|
|
74
|
-
INITIAL_ADOPTION_REASON,
|
|
75
74
|
SOURCE_SIZE_GATE_ID,
|
|
76
75
|
SOURCE_SIZE_TOOL_PATH,
|
|
77
76
|
escapeForLine,
|
|
78
77
|
isLineUnsafe,
|
|
79
78
|
loadSourceSizeConfig,
|
|
79
|
+
mintReasonOf,
|
|
80
80
|
} from './source-size-core.mjs';
|
|
81
81
|
|
|
82
82
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
@@ -469,7 +469,7 @@ export const sourceSizeCandidate = (cwd, deps = {}) => {
|
|
|
469
469
|
// every run, so pointing there would hand the reader their next failure as the way out.
|
|
470
470
|
const lane = state === 'minted'
|
|
471
471
|
? `${schema1 ? 'move the record to schema 2 first — run source-size-check.mjs --write-baseline with the working directory set to this project, then ' : ''}declare the gate by hand`
|
|
472
|
-
: `mint the record first — run source-size-check.mjs --adopt --reason "${
|
|
472
|
+
: `mint the record first — run source-size-check.mjs --adopt --reason "${mintReasonOf(config)}" with the working directory set to this project, then declare the gate by hand`;
|
|
473
473
|
return {
|
|
474
474
|
candidate: null,
|
|
475
475
|
note:
|
|
@@ -480,14 +480,14 @@ export const sourceSizeCandidate = (cwd, deps = {}) => {
|
|
|
480
480
|
}
|
|
481
481
|
if (state !== 'minted') {
|
|
482
482
|
// The named recovery is the reader's next keystroke, so it is a command they can actually run:
|
|
483
|
-
// the resolved absolute path and an explicit --cwd, carrying the reason
|
|
483
|
+
// the resolved absolute path and an explicit --cwd, carrying the reason the mint's rule gives
|
|
484
484
|
// (recording a value for the first time is a raise, and the bare verb would refuse). The
|
|
485
485
|
// PROJECT path is screened by the same predicate — a rendered command naming a path the shell
|
|
486
486
|
// would read differently could run somewhere other than the project it names.
|
|
487
487
|
const project = resolve(cwd);
|
|
488
488
|
const recovery = unrenderableToolPath(project)
|
|
489
|
-
? `run source-size-check.mjs --adopt --reason "${
|
|
490
|
-
: `run node "${toolPath}" --adopt --reason "${
|
|
489
|
+
? `run source-size-check.mjs --adopt --reason "${mintReasonOf(config)}" yourself, with the working directory set to this project (no command is printed: this project's path cannot be rendered into one)`
|
|
490
|
+
: `run node "${toolPath}" --adopt --reason "${mintReasonOf(config)}" --cwd "${project}"`;
|
|
491
491
|
return {
|
|
492
492
|
candidate: null,
|
|
493
493
|
note:
|
|
@@ -71,7 +71,7 @@ import { takeCensus, censusFact, CENSUS_VERDICT } from './tracked-tree-census.mj
|
|
|
71
71
|
// fill's own WRITER is never called from here — the advisor renders its consent-gated command, it
|
|
72
72
|
// does not run it.
|
|
73
73
|
import { buildOffer } from './gates-init.mjs';
|
|
74
|
-
import { CHECKER_CLAIM,
|
|
74
|
+
import { CHECKER_CLAIM, SOURCE_SIZE_GATE_ID, classifySourceSizeGate, loadSourceSizeConfig, mintReasonOf, presentHalves, readLayoutSetup, readPileOffer } from './source-size-core.mjs';
|
|
75
75
|
// The declared-path resolution + segment containment this item's convergence lane shares with the
|
|
76
76
|
// autonomy render's allowWrite degrade — ONE leaf, so the two answers cannot drift.
|
|
77
77
|
import { resolveDeclaredDir, dirCovers, isResolvableDeclaredEntry } from './declared-paths.mjs';
|
|
@@ -133,6 +133,8 @@ const HOOK_CHECKS_UNMANAGED_HOOK = 'an UNMANAGED pre-commit hook exists \u2014 t
|
|
|
133
133
|
const HOOK_CHECKS_WAIT = 'the layout line follows the source-size.layout record \u2014 apply that item first; this item\'s check line then arms the layout line too';
|
|
134
134
|
const HOOK_CHECKS_COMMAND = "the hook runs the kit's checks by flat paths this upgrade removes — once they are gone every commit stops until this item is applied";
|
|
135
135
|
const LAYOUT_RECORD_RECIPE = 'the hook is per clone and the config per branch: a branch or linked worktree with no size config is judged under the kit\'s values and stops on its piles until it takes the record (a hidden deployment\'s linked worktree carries none); one with an older config without layout is not judged on layout; one whose config is schema 1 or unminted stops every commit on that config\'s own stop until it takes the current config';
|
|
136
|
+
const REASON_AUTHOR_RECIPE = 'the reason is yours to write, with no question to the user: where you made the growth, say why this size is accepted; where an entry grew before this write (a half-written record, a raise after the schema move, a teammate\'s growth), write that it grew before this write and its cause was not recorded';
|
|
137
|
+
const SOURCE_SIZE_KEPT_WHAT = 'no source-size gate is declared — the size record is kept as it is; declaring the gate adds the size check to the gate matrix';
|
|
136
138
|
const LAYOUT_HELD = {
|
|
137
139
|
stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014 record that growth first with the reasoned --write-baseline its stop names, then re-run',
|
|
138
140
|
'store-root': ({ root }) => `the source-size config declares the root "${root}" at or inside the spec store docs/ai/specs \u2014 the layout record starts once that root is declared outside it`,
|
|
@@ -284,13 +286,13 @@ export const WHATS = Object.freeze({
|
|
|
284
286
|
'gates-inert.no-verification': "all {n} declared gate(s) are the kit's own checkers — the matrix runs no project-verification command",
|
|
285
287
|
'gates-inert.producer-unrecognized': 'the coverage checker ({id}) has NO producer declared and none offerable, on a tree the changed-line domain barely reaches',
|
|
286
288
|
'gates-inert.coverage-domain-narrow': 'certification covers the assessable minority only — {ext} dominate(s) the tracked tree, and the changed-line domain excludes them',
|
|
287
|
-
'source-size': 'no source-size gate —
|
|
289
|
+
'source-size': 'no source-size gate is declared — the gate matrix runs no size check, so no gate run stops a file beyond its limits',
|
|
288
290
|
'source-size.unminted': 'the source-size gate is declared over an unminted record ({state}) — the check refuses it, or if absent judges layout alone, no line',
|
|
289
291
|
'source-size.schema-1': 'the source-size config is schema 1, which the check stops on — the writer moves it to schema 2 in one write',
|
|
290
292
|
'source-size.layout': 'the layout record is not started — starting it records any directory already beyond the layout limits, so the commit hook can judge layout',
|
|
291
293
|
'source-size.piles': '{n} recorded pile(s) have no queue row planning their cleanup — one row each goes to the end of the queue\'s Later bucket',
|
|
292
294
|
'source-size.adopted-elsewhere': "the source-size gate runs a DIFFERENT copy of this checker ({n} declared) — adopted here, just not through this kit's own tool",
|
|
293
|
-
'source-size.id-squatter': 'a gate carries the source-size id but is not this checker — the
|
|
295
|
+
'source-size.id-squatter': 'a gate carries the source-size id but is not this checker — the gate matrix reads as running the size check while it runs none',
|
|
294
296
|
'gate-hook': '{n} declared gate(s) prompt per run — the gate-approval hook is not wired',
|
|
295
297
|
'gate-hook.not-current': `${HOOK_FILE_REL} is absent or differs from the body the kit writes for it — written with that body, with no question`,
|
|
296
298
|
'commit-guard': 'the gate matrix is final-run-capable but no commit-guard arms the pre-commit hook — a commit needs no green receipt yet',
|
|
@@ -857,9 +859,13 @@ export const probeGatesInert = ({ root, deps, add, skip }) => {
|
|
|
857
859
|
// practice question outright; else any tool-elsewhere claim; else the id collision; else the offer.
|
|
858
860
|
// A MINTED schema-1 config is asked first, ahead of the gate arms: the check stops on it whatever is
|
|
859
861
|
// declared. Its line carries no reason, since a pinned one would launder a raise; an unreadable
|
|
860
|
-
// config keeps today's arms, which report it.
|
|
861
|
-
const
|
|
862
|
-
try {
|
|
862
|
+
// config (null here) keeps today's arms, which report it.
|
|
863
|
+
const readSizeConfig = (root, deps) => {
|
|
864
|
+
try {
|
|
865
|
+
return loadSourceSizeConfig(root, deps);
|
|
866
|
+
} catch {
|
|
867
|
+
return null;
|
|
868
|
+
}
|
|
863
869
|
};
|
|
864
870
|
|
|
865
871
|
// The layout setup's answer for the layout arm; its throw is a stated skip, and the other arms still speak.
|
|
@@ -889,8 +895,10 @@ const pilesArm = (root, declaration, deps, add, skip) => {
|
|
|
889
895
|
const probeSourceSize = ({ root, deps, add, skip, shared }) => {
|
|
890
896
|
try {
|
|
891
897
|
const tool = toolPath('source-size-check.mjs');
|
|
892
|
-
|
|
893
|
-
|
|
898
|
+
const loaded = readSizeConfig(root, deps);
|
|
899
|
+
const recipe = presentHalves(loaded?.config).length > 0 ? REASON_AUTHOR_RECIPE : null;
|
|
900
|
+
if (loaded?.state === 'minted' && loaded.config.schema === 1) {
|
|
901
|
+
add('source-size', fillTemplate(WHATS['source-size.schema-1'], {}), `node ${q(tool)} --write-baseline --cwd ${q(root)}`, 'source-size.schema-1', REASON_AUTHOR_RECIPE);
|
|
894
902
|
return;
|
|
895
903
|
}
|
|
896
904
|
// The layout arm, additive: the record renders as its own item ahead of the other arms; a held answer
|
|
@@ -906,10 +914,8 @@ const probeSourceSize = ({ root, deps, add, skip, shared }) => {
|
|
|
906
914
|
pilesArm(root, declaration, deps, add, skip);
|
|
907
915
|
if (loadError !== null) throw loadError;
|
|
908
916
|
const gates = declaration.outcome === 'loaded' ? declaration.gates : [];
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
// carried when the practice arrived" is the one sentence that is true of all of them.
|
|
912
|
-
const adoptLine = `node ${q(tool)} --adopt --reason "${INITIAL_ADOPTION_REASON}" --cwd ${q(root)}`;
|
|
917
|
+
const mintReason = mintReasonOf(loaded?.config);
|
|
918
|
+
const adoptLine = `node ${q(tool)} --adopt --reason "${mintReason}" --cwd ${q(root)}`;
|
|
913
919
|
const claims = gates.map((gate) => ({ gate, claim: classifySourceSizeGate(gate.cmd, root) }));
|
|
914
920
|
const canonical = claims.filter((c) => c.claim === CHECKER_CLAIM.CANONICAL);
|
|
915
921
|
const elsewhere = claims.filter((c) => c.claim === CHECKER_CLAIM.ELSEWHERE);
|
|
@@ -919,18 +925,13 @@ const probeSourceSize = ({ root, deps, add, skip, shared }) => {
|
|
|
919
925
|
// absent one it judges layout alone and no line. The declaration alone would report that deployment
|
|
920
926
|
// as adopted and say nothing about the one thing wrong with it. The split changes NOTHING here —
|
|
921
927
|
// the outcome, its attention class and its immunity to every ack are the same whichever copy runs.
|
|
922
|
-
const { state } = loadSourceSizeConfig(root, deps);
|
|
928
|
+
const { state } = loaded ?? loadSourceSizeConfig(root, deps);
|
|
923
929
|
if (state !== 'minted') {
|
|
924
930
|
// Only the way OUT differs. With the gate declared through another copy, `--adopt` would
|
|
925
931
|
// mint the record and then be refused by the fill on the id it is already looking at, so the
|
|
926
932
|
// rendered verb is the mint alone: the declaration is not the half that is missing.
|
|
927
|
-
const mintLine = `node ${q(tool)} --write-baseline --reason "${
|
|
928
|
-
add(
|
|
929
|
-
'source-size',
|
|
930
|
-
fillTemplate(WHATS['source-size.unminted'], { state }),
|
|
931
|
-
canonical.length > 0 ? adoptLine : mintLine,
|
|
932
|
-
'source-size.unminted',
|
|
933
|
-
);
|
|
933
|
+
const mintLine = `node ${q(tool)} --write-baseline --reason "${mintReason}" --cwd ${q(root)}`;
|
|
934
|
+
add('source-size', fillTemplate(WHATS['source-size.unminted'], { state }), canonical.length > 0 ? adoptLine : mintLine, 'source-size.unminted', recipe);
|
|
934
935
|
return;
|
|
935
936
|
}
|
|
936
937
|
if (canonical.length > 0) return; // adopted through THIS copy and armed — converged
|
|
@@ -941,12 +942,9 @@ const probeSourceSize = ({ root, deps, add, skip, shared }) => {
|
|
|
941
942
|
// realpaths, which are machine-specific and would churn a committed ack between machines.
|
|
942
943
|
const fingerprint = factFingerprint(JSON.stringify([...new Set(elsewhere.map((c) => c.gate.cmd))].sort()));
|
|
943
944
|
if (readAckValue(root, deps, ACKS_SOURCE_SIZE_COPY_KEY) === fingerprint) return; // acknowledged
|
|
944
|
-
add(
|
|
945
|
-
'source-size',
|
|
946
|
-
fillTemplate(WHATS['source-size.adopted-elsewhere'], { n: elsewhere.length }),
|
|
945
|
+
add('source-size', fillTemplate(WHATS['source-size.adopted-elsewhere'], { n: elsewhere.length }),
|
|
947
946
|
`node ${q(toolPath('ack-write.mjs'))} --lane source-size-copy --fingerprint ${fingerprint} --cwd ${q(root)}`,
|
|
948
|
-
'source-size.adopted-elsewhere'
|
|
949
|
-
);
|
|
947
|
+
'source-size.adopted-elsewhere');
|
|
950
948
|
return;
|
|
951
949
|
}
|
|
952
950
|
// The id SQUATTER — the id says the practice is declared, the cmd is not this checker under any
|
|
@@ -958,7 +956,8 @@ const probeSourceSize = ({ root, deps, add, skip, shared }) => {
|
|
|
958
956
|
'source-size.id-squatter');
|
|
959
957
|
return;
|
|
960
958
|
}
|
|
961
|
-
add('source-size',
|
|
959
|
+
if (loaded?.state === 'minted') add('source-size', SOURCE_SIZE_KEPT_WHAT, `node ${q(tool)} --adopt --cwd ${q(root)}`, 'source-size', recipe);
|
|
960
|
+
else add('source-size', fillTemplate(WHATS['source-size'], {}), adoptLine, 'source-size', recipe);
|
|
962
961
|
} catch (err) {
|
|
963
962
|
skip('source-size', err);
|
|
964
963
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const helpText = ({ SOURCE_SIZE_CONFIG_REL, SOURCE_SIZE_SCHEMA, KIT_FOLDER_ROOT }) => `source-size-check — the declared source-size practice (agent-workflow family).
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
node source-size-check.mjs --check [--cwd <project-root>]
|
|
5
|
+
node source-size-check.mjs --write-baseline [--layout] [--reason "<text>"] [--cwd <project-root>]
|
|
6
|
+
node source-size-check.mjs --adopt [--reason "<text>"] [--cwd <project-root>]
|
|
7
|
+
node source-size-check.mjs --override <id> [--value <n>] [--tolerance <p>] --reason "<text>" [--cwd <project-root>]
|
|
8
|
+
node source-size-check.mjs --override <id> --kit-default --reason "<text>" [--cwd <project-root>]
|
|
9
|
+
|
|
10
|
+
Judges every in-scope file against ${SOURCE_SIZE_CONFIG_REL} (schema ${SOURCE_SIZE_SCHEMA}): git-tracked files
|
|
11
|
+
under a declared root carrying a declared extension, minus the excluded path-segment prefixes and
|
|
12
|
+
the kit's own folder ${KIT_FOLDER_ROOT}, which nothing here judges and no root may declare. An
|
|
13
|
+
absent "roots" is the one root ".", every tracked path; a config declaring no extension judges no
|
|
14
|
+
file, and every check says so. With the config absent the check judges layout alone under the
|
|
15
|
+
kit's values. Symlinks and submodule gitlinks are skipped by kind; an unmerged index, a non-UTF-8
|
|
16
|
+
in-scope path, an unverifiable in-scope file and an empty declared scope are refusals.
|
|
17
|
+
|
|
18
|
+
Limits: the kit's own five, kept in its code, each with a tolerance; the config holds only a
|
|
19
|
+
project's reasoned overrides under "limits". A value at or under its limit is clean, above it within
|
|
20
|
+
the band ceil(value x tolerance / 100) a WARNING printed on every run (exit 0), and beyond the band a
|
|
21
|
+
stop unless a record holds it. Every --check, --write-baseline and --override run that resolves the
|
|
22
|
+
config and ends in no usage, config, enumeration or scope error states all five limits with value,
|
|
23
|
+
tolerance and source, then what it does not judge, then its warnings, then its stops; a --check that
|
|
24
|
+
stops opens instead with its verdict line, its findings and its remedy, its limits, notes and warnings
|
|
25
|
+
after them.
|
|
26
|
+
|
|
27
|
+
Counting: lines, and the longest line in BYTES. A terminator never counts (the CR of a CRLF
|
|
28
|
+
included); a last line with no final newline still counts; an empty file is 0 lines. Layout: the
|
|
29
|
+
entries of each directory and its depth below its root, over every tracked entry under a declared
|
|
30
|
+
root outside the kit's own folder ${KIT_FOLDER_ROOT} plus the spec store docs/ai/specs walked from
|
|
31
|
+
disk, and the files of each declared root.
|
|
32
|
+
|
|
33
|
+
A recorded entry is DEBT: a finding stops exactly when the regeneration would raise it, and a record
|
|
34
|
+
above the tree or gone warns until the regeneration lowers or removes it. Each declared root carries
|
|
35
|
+
the same exact ratchet over its summed lines.
|
|
36
|
+
|
|
37
|
+
--write-baseline regenerates the machine keys (baseline, aggregate, and layout where it is judged)
|
|
38
|
+
from the tree; on an absent config it writes a schema-2 one. --layout starts the layout record on a
|
|
39
|
+
present config that has none. The authored keys keep their values and their order; the file is
|
|
40
|
+
canonically serialized. A regeneration that RAISES any recorded value needs --reason; the string is
|
|
41
|
+
recorded in the entry it raised. A pure tighten needs none. A schema-1 config is moved to schema 2 in
|
|
42
|
+
the same write, a minted one in a write of its own where the regeneration is refused; --check
|
|
43
|
+
stops on one until it is.
|
|
44
|
+
|
|
45
|
+
--adopt is the ONE-line adoption: it mints the record and declares the source-size gate (and NOTHING
|
|
46
|
+
else) in docs/ai/gates.json. It is idempotent on an already-adopted project. With the config absent
|
|
47
|
+
it refuses with the exact file to author. A refused declaration exits nonzero and reports both
|
|
48
|
+
halves: what was minted and what was not declared.
|
|
49
|
+
|
|
50
|
+
--override writes one override of a kit limit (lines-per-file, bytes-per-line, entries-per-directory,
|
|
51
|
+
depth: --value and/or --tolerance; files-per-root: --tolerance only), or with --kit-default removes
|
|
52
|
+
it; an option left out keeps the limit's current value or tolerance, and --reason is mandatory. It
|
|
53
|
+
runs only once regenerating the record under the current limits would raise nothing, and
|
|
54
|
+
regenerates the record in the same write.
|
|
55
|
+
|
|
56
|
+
Exit codes: 0 green, warnings included; 1 a stop or a refusal; 2 usage, config or enumeration error, or an unexpected error.`;
|
|
@@ -47,3 +47,17 @@ export {
|
|
|
47
47
|
queueChecksOf,
|
|
48
48
|
spliceLater,
|
|
49
49
|
} from './piles.mjs';
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
helpText,
|
|
53
|
+
} from './help.mjs';
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
INITIAL_ADOPTION_REASON,
|
|
57
|
+
GROWTH_REASON_PLACEHOLDER,
|
|
58
|
+
halfOf,
|
|
59
|
+
presentHalves,
|
|
60
|
+
refusedRaises,
|
|
61
|
+
mintReasonOf,
|
|
62
|
+
commandReasonDefect,
|
|
63
|
+
} from './reason.mjs';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const INITIAL_ADOPTION_REASON = 'initial adoption';
|
|
2
|
+
export const GROWTH_REASON_PLACEHOLDER = '<why this size is accepted>';
|
|
3
|
+
|
|
4
|
+
const HALF_OF_DIMENSION = Object.freeze({
|
|
5
|
+
lines: 'baseline',
|
|
6
|
+
maxLineBytes: 'baseline',
|
|
7
|
+
'aggregate lines': 'aggregate',
|
|
8
|
+
files: 'layout',
|
|
9
|
+
entries: 'layout',
|
|
10
|
+
depth: 'layout',
|
|
11
|
+
});
|
|
12
|
+
const MACHINE_HALVES = Object.freeze([...new Set(Object.values(HALF_OF_DIMENSION))]);
|
|
13
|
+
const PLACEHOLDER_RE = /^<.*>$/;
|
|
14
|
+
|
|
15
|
+
export const halfOf = ({ dimension }) => HALF_OF_DIMENSION[dimension];
|
|
16
|
+
|
|
17
|
+
export const presentHalves = (config) => MACHINE_HALVES.filter((half) => config?.[half] != null);
|
|
18
|
+
|
|
19
|
+
export const refusedRaises = ({ plan, config, reason }) => {
|
|
20
|
+
const present = presentHalves(config);
|
|
21
|
+
return reason === INITIAL_ADOPTION_REASON ? plan.raises.filter((delta) => present.includes(halfOf(delta))) : [];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const mintReasonOf = (config) => presentHalves(config).length > 0 ? GROWTH_REASON_PLACEHOLDER : INITIAL_ADOPTION_REASON;
|
|
25
|
+
|
|
26
|
+
export const commandReasonDefect = (reason, { override = false } = {}) => {
|
|
27
|
+
if (PLACEHOLDER_RE.test(reason)) return `--reason still carries the placeholder ${reason} — write the reason in its place; the command line never takes a placeholder as a reason`;
|
|
28
|
+
if (override && reason === INITIAL_ADOPTION_REASON) {
|
|
29
|
+
return `--override takes its own reason — "${INITIAL_ADOPTION_REASON}" is the kit's sentence for a record's first entries, and an override is a reasoned change of a kit number`;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|