@sabaiway/agent-workflow-kit 20.0.1 → 20.2.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 +47 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/gates.md +1 -1
- package/tools/checker-gates-read.mjs +4 -1
- package/tools/gates-declaration.mjs +8 -4
- package/tools/plan-shape-facts.mjs +2 -1
- package/tools/source-size-config.mjs +6 -0
- package/tools/source-size-report.mjs +13 -7
- package/tools/source-size-scope.mjs +26 -15
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,53 @@ 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
|
+
## 20.2.0 — the project rules check is offered as a gate of every project (AD-219)
|
|
8
|
+
|
|
9
|
+
**Your project's rules can now stop a red gate run, not only a commit.** The check that each rules theme's effective
|
|
10
|
+
file still matches the record it was built from, `project-rules/rules-cli.mjs --check`, joins the kit checkers that
|
|
11
|
+
`checker-gates.mjs` and the upgrade's `tier` step offer as gates of your project:
|
|
12
|
+
|
|
13
|
+
- `node <kit>/tools/checker-gates.mjs --cwd <project>` previews a fifth line, `project-rules`, after `spec-coverage`,
|
|
14
|
+
offered on every deployment, one with no rules theme laid yet included; an offered line is followed by its entry,
|
|
15
|
+
`node "<kit>/tools/project-rules/rules-cli.mjs" --check`, and `--apply` (or the `tier` yes) writes it add-only, as
|
|
16
|
+
for the other four.
|
|
17
|
+
- The gate passes over a theme the check answers `current` or `absent` and stops on one it answers `drift` or `record`,
|
|
18
|
+
naming the remedy `/agent-workflow-kit upgrade`; unlike the commit hook's rules line, it waits for no theme to be
|
|
19
|
+
`current` first.
|
|
20
|
+
- A decline of `checker-gates-declared` you recorded earlier stays current and covers the new candidate; the preview
|
|
21
|
+
above and `--apply --only project-rules` still reach it.
|
|
22
|
+
- If your `docs/ai/gates.json` already declares a `project-rules` gate with `--cwd .` (the form `/agent-workflow-kit
|
|
23
|
+
rules` runs), the preview prints `project-rules: id-taken` and, once no other candidate is offered, every upgrade reads its
|
|
24
|
+
`checker-gates-declared` item as undecidable. Drop `--cwd`
|
|
25
|
+
and its value from that gate's cmd: the gate runner already runs every cmd from the project root, and the preview
|
|
26
|
+
then prints `project-rules: declared`.
|
|
27
|
+
|
|
28
|
+
Contracts: checker-gates revision 2, project-rules revision 11.
|
|
29
|
+
|
|
30
|
+
## 20.1.0 — the size check leaves the kit's own folder `scripts/agent-workflow` alone (AD-218)
|
|
31
|
+
|
|
32
|
+
**A coming kit release can move its scripts into one folder of your project without stopping a single commit.** The
|
|
33
|
+
kit's scripts will live in `scripts/agent-workflow`, and the kit's own repository already judges their size. Before
|
|
34
|
+
they move, `source-size-check` stops judging that folder in your project:
|
|
35
|
+
|
|
36
|
+
- Every tracked entry at or under `scripts/agent-workflow` is taken away before anything is judged, under every
|
|
37
|
+
declared root, the root `.` and an absent `docs/ai/source-size.json` included: no line, byte, layout entry, files-per-root
|
|
38
|
+
count or aggregate line counts it, and its own name is counted by nothing in `scripts`. The comparison is by whole
|
|
39
|
+
path segment, so `scripts/agent-workflow-x/a.mjs` and `scripts/agent-workflowx.mjs` stay judged.
|
|
40
|
+
- Every `--check`, `--write-baseline` and `--override` run that judges the tree prints, as the last of its not-judged
|
|
41
|
+
lines: `source-size: NOTE — scripts/agent-workflow is the kit's own folder, so nothing in it is judged here; the
|
|
42
|
+
kit's own repository judges its files`. `--help` names the folder in its scope and layout sentences.
|
|
43
|
+
- A declared root at or inside the folder is a config stop, exit 2, naming the root; the roots `scripts` and `.` stay
|
|
44
|
+
valid, and so does an `exclude` entry inside the folder.
|
|
45
|
+
- A recorded `baseline` or `layout.directories` key under the folder reads as gone: it warns, exit 0, and your next
|
|
46
|
+
`--write-baseline` removes it with no reason.
|
|
47
|
+
- A declared scope whose only matches lie inside the folder judges no file on lines or bytes and is not refused as
|
|
48
|
+
empty; its empty-root note says the root matches nothing outside the kit's own folder.
|
|
49
|
+
- The plan-shape check's source scope takes the folder away by the same rule.
|
|
50
|
+
|
|
51
|
+
No project holds the folder yet, so the changes you see today are the new NOTE line and the `--help` text that names
|
|
52
|
+
the folder. Contract: source-size revision 8.
|
|
53
|
+
|
|
7
54
|
## 20.0.1 — `init` removes the folders it leaves empty in the kit home (AD-217)
|
|
8
55
|
|
|
9
56
|
**A refresh no longer asks you to delete folders by hand.** `init` removes from an existing kit home every file in
|
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: '20.0
|
|
6
|
+
version: '20.2.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": "20.0
|
|
3
|
+
"version": "20.2.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",
|
|
@@ -23,7 +23,7 @@ Declared gates can also be **auto-approved** (no permission prompt on a byte-exa
|
|
|
23
23
|
|
|
24
24
|
**Candidate line — the source-size gate (opt-in, never auto-seeded).** A project declaring the source-size practice (`docs/ai/source-size.json`) can declare its checker as one more gate, offered **only over a MINTED schema-2 practice** — an absent config has nothing to offer, an authored-but-unminted one is withheld by name rather than declaring a gate that would refuse, and a minted schema-1 one is withheld naming its `--write-baseline` move. Adoption is ONE consented verb, `node ${CLAUDE_SKILL_DIR}/tools/source-size-check.mjs --adopt --reason "<text>" [--cwd <project>]`: it mints the record and declares this gate and NOTHING else, is idempotent once adopted, and with no config refuses with the exact file to author. The advisor surfaces it as the `source-size` item, reading a declared cmd as one of THREE claims rather than a yes/no — **canonical** (this copy — answered), **tool-elsewhere** (the same shape resolving to a DIFFERENT real copy — a vendored deployment, converging on a `source-size-copy` acknowledgement, never on `--adopt`, which would collide on the declared id), **not-the-tool** (a gate merely CARRYING the id is a squatter: rename it, or repoint its cmd at this `--check` form) — in that precedence. An unminted record stays the same attention outcome for either copy, and no acknowledgement silences it.
|
|
25
25
|
|
|
26
|
-
**Candidate lines — the kit's own checkers (opt-in, one consented verb).** `control-bytes`, `plan-shape`, `spec-check` and `
|
|
26
|
+
**Candidate lines — the kit's own checkers (opt-in, one consented verb).** `control-bytes`, `plan-shape`, `spec-check`, `spec-coverage` and `project-rules` can each be declared as a gate of your project: `node ${CLAUDE_SKILL_DIR}/tools/checker-gates.mjs --cwd <project>` previews them and writes nothing. Each is offered only over a state where its checker runs by design: `control-bytes` over a `.git` directory or gitfile at the project root, `plan-shape` and `project-rules` on any deployment, `spec-check` over a regular `docs/ai/specs/index.md`, `spec-coverage` over a regular `docs/ai/spec-coverage.json` beside that store root. An offered checker prints its paste-ready entry line; the upgrade's `tier` ask writes the offered entries on your explicit yes — add-only, placed by the rule below, not stamp-gated, after the preview printed the disclosure below. An entry it wrote is removed by hand from `docs/ai/gates.json`: the verb never un-declares. `epic-shape` and `queue-audit` take a project operand and `doc-parity` checks only the kit's own package, so none of them is offered.
|
|
27
27
|
|
|
28
28
|
**Consent-gated filling — the init preview, not part of the runner (D9).** The template `gates.json` is seeded EMPTY; FILLING it is a consented preview at init (`node ${CLAUDE_SKILL_DIR}/tools/gates-init.mjs --cwd <project>`, dry-run by default — prints the derived entries and **writes NOTHING**; `--apply [--only <id>]…` writes exactly the consented entries on your explicit yes; add-only, id collisions refused). **Placement, not blind appending:** a consented entry lands at the END, except that a non-checker entry goes **BEFORE** a trailing canonical coverage checker — that checker must stay last, so appending after it would write a declaration the validator refuses, leaving a hand edit as the only lane on any final-capable declaration. Existing entries are never modified, removed or reordered. The offer derivation is **closed-world** (AD-052): only a terminating-class script NAME (test / lint / type-check / build — never dev/watch/serve, never a write-mode or release/publish/deploy variant) whose BODY is a member of the literal runner allowlist is offered — membership, never blocklist screening: the worst case is a legit command not offered, never a dangerous one offered. The offered cmd is the uniform hook-free **`COREPACK_ENABLE_NETWORK=0 <pm> exec -- <allowlisted-body>`** — `exec` runs a command, not a named script, so no pre/post hook can fire (npm/pnpm/yarn alike; never `<pm> run <name>`, which re-exposes hooks), and the Corepack env prefix blocks a hostile `packageManager` pin from fetching the PM binary before exec. npm is pinned `--offline --script-shell /bin/sh`; pnpm/yarn refuse an absent runner without network (a user-installed cache/global/PATH runner executing is user machine state — part of the disclosed residual); a family without a verified fail-closed exec contract is WITHHELD loudly. A screened-out body is always named — and when nothing but kit checkers remains, the preview says so in plain words: the offer carries **no project-verification gate at all**. **Disclose before the yes** (the preview prints it): gates.json is a PRIVILEGED file — the wired hook auto-approves byte-exact declared commands — and a script gate runs project-controlled tooling the preview does not sandbox (safe-by-construction = the OFFER DERIVATION). At upgrade, step 3's run-list changes an existing gates.json only through the consented legacy migration and, under the `tier` ask, `tools/checker-gates.mjs` (`${CLAUDE_SKILL_DIR}/references/modes/upgrade.md`).
|
|
29
29
|
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
// (part checker-gates-read). No CLI (refuseDirectRun); nothing here writes.
|
|
5
5
|
import { lstatSync } from 'node:fs';
|
|
6
6
|
import { dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
7
8
|
import { CHECKER_CLAIM, classifyCheckerClaim, dqUnsafePath } from './checker-claim.mjs';
|
|
8
9
|
import { refuseDirectRun } from './direct-run.mjs';
|
|
9
10
|
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
10
11
|
import { GATES_REL, KIT_CHECKER_CLAIMS, coverageDeclarationDefects, validateDeclaration } from './gates-declaration.mjs';
|
|
11
12
|
import { escapeForLine, isLineUnsafe } from './source-size-core.mjs';
|
|
12
13
|
|
|
14
|
+
const KIT_TOOLS_DIR = dirname(fileURLToPath(import.meta.url));
|
|
13
15
|
const DEPLOYMENT_CHAIN = ['.', 'docs', 'docs/ai'];
|
|
14
16
|
const NOT_APPLICABLE_CODES = new Set(['ENOENT', 'ENOTDIR']);
|
|
15
17
|
const OK = 'ok';
|
|
@@ -78,6 +80,7 @@ export const CHECKER_GATE_CANDIDATES = Object.freeze([
|
|
|
78
80
|
'No work without a specification — every in-scope tool is governed by a contract, or named in the shrink-only debt',
|
|
79
81
|
requiring(COVERAGE_SCOPE, STORE_ROOT),
|
|
80
82
|
),
|
|
83
|
+
candidate('project-rules', 'Project rules — each theme\'s effective file matches the record of what it was built from', requiring()),
|
|
81
84
|
]);
|
|
82
85
|
|
|
83
86
|
const claimOf = (id) => KIT_CHECKER_CLAIMS.find((claim) => claim.id === id);
|
|
@@ -119,7 +122,7 @@ const claimState = ({ id, screen }, gates, root) => {
|
|
|
119
122
|
return taken ? { state: CANDIDATE_STATES.idTaken, detail: taken.cmd } : {};
|
|
120
123
|
};
|
|
121
124
|
|
|
122
|
-
const toolPathOf = ({
|
|
125
|
+
const toolPathOf = ({ path }, deps) => join(deps.kitToolsDir ?? KIT_TOOLS_DIR, path);
|
|
123
126
|
const isUnrenderable = (path) => dqUnsafePath(path) || isLineUnsafe(path);
|
|
124
127
|
|
|
125
128
|
const judgeCandidate = ({ id, title, probe }, rendered, gates, root, deps) => {
|
|
@@ -225,16 +225,20 @@ export const isReviewDependentGate = (gate, projectDir) =>
|
|
|
225
225
|
// "does this declaration verify the PROJECT?" through the review-dependent predicate alone read a
|
|
226
226
|
// matrix of nothing but that gate as project verification. Three surfaces asked it, each knowing a
|
|
227
227
|
// different half; this is the one home, so a future kit checker is added once.
|
|
228
|
-
// KIT_CHECKER_CLAIMS is the one statement of the
|
|
228
|
+
// KIT_CHECKER_CLAIMS is the one statement of the declarable kit checkers' basenames, paths, tails and
|
|
229
229
|
// canonical paths (docs/ai/specs/kit/tier/checker-gates/, part checker-claim-tail).
|
|
230
|
-
const kitCheckerClaim = (id,
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
const kitCheckerClaim = (id, path, tail) => {
|
|
231
|
+
const basename = path.split('/').at(-1);
|
|
232
|
+
return Object.freeze({
|
|
233
|
+
id, basename, path, tail, screen: checkerClaimTool(basename, fileURLToPath(new URL(`./${path}`, import.meta.url)), tail),
|
|
234
|
+
});
|
|
235
|
+
};
|
|
233
236
|
export const KIT_CHECKER_CLAIMS = Object.freeze([
|
|
234
237
|
kitCheckerClaim('control-bytes', 'control-bytes.mjs', '--check'),
|
|
235
238
|
kitCheckerClaim('plan-shape', 'plan-shape-cli.mjs', '--check --in-flight'),
|
|
236
239
|
kitCheckerClaim('spec-check', 'spec-check-cli.mjs', '--all'),
|
|
237
240
|
kitCheckerClaim('spec-coverage', 'spec-coverage-cli.mjs', '--check'),
|
|
241
|
+
kitCheckerClaim('project-rules', 'project-rules/rules-cli.mjs', '--check'),
|
|
238
242
|
]);
|
|
239
243
|
|
|
240
244
|
export const isKitOwnedCheckerGate = (gate, projectDir) =>
|
|
@@ -2,7 +2,7 @@ import { lstatSync, readdirSync, realpathSync } from 'node:fs';
|
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
3
3
|
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
4
4
|
import { classIds, readShippedRobustnessLiterals } from './robustness-literals.mjs';
|
|
5
|
-
import { segmentPrefixOf, validateSourceSizeConfig } from './source-size-config.mjs';
|
|
5
|
+
import { KIT_FOLDER_ROOT, segmentPrefixOf, validateSourceSizeConfig } from './source-size-config.mjs';
|
|
6
6
|
import { getLineCount, isSweep, resolveAnchorCandidates, unique } from './plan-shape.mjs';
|
|
7
7
|
import { listStories } from './claim-relation.mjs';
|
|
8
8
|
import { EPICS_REL, readEpicStore } from './epic-store.mjs';
|
|
@@ -99,6 +99,7 @@ const loadRobustClasses = (deps) => {
|
|
|
99
99
|
|
|
100
100
|
const isInScope = (path, config) => Boolean(config &&
|
|
101
101
|
config.roots.some((root) => segmentPrefixOf(root, path)) &&
|
|
102
|
+
!segmentPrefixOf(KIT_FOLDER_ROOT, path) &&
|
|
102
103
|
!config.exclude.some((excluded) => segmentPrefixOf(excluded, path)) &&
|
|
103
104
|
config.extensions.some((extension) => path.endsWith(extension)));
|
|
104
105
|
|
|
@@ -31,6 +31,8 @@ export const REASON_MAX_BYTES = 300;
|
|
|
31
31
|
export const INITIAL_ADOPTION_REASON = 'initial adoption';
|
|
32
32
|
// The root an absent `roots` declares: every tracked path. Admitted only as the sole root.
|
|
33
33
|
export const WHOLE_TREE_ROOT = '.';
|
|
34
|
+
// The kit's own folder: taken away from every judgment by this fixed path, with no config key.
|
|
35
|
+
export const KIT_FOLDER_ROOT = 'scripts/agent-workflow';
|
|
34
36
|
|
|
35
37
|
export const AUTHORED_KEYS = Object.freeze(['_README', 'schema', 'roots', 'exclude', 'extensions', 'limits']);
|
|
36
38
|
const SCHEMA1_AUTHORED_KEYS = Object.freeze(['_README', 'schema', 'defaults', 'roots', 'exclude', 'extensions']);
|
|
@@ -214,6 +216,10 @@ export const validateSourceSizeConfig = (parsed) => {
|
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
218
|
}
|
|
219
|
+
const kitRoot = roots.find((root) => segmentPrefixOf(KIT_FOLDER_ROOT, root));
|
|
220
|
+
if (kitRoot !== undefined) {
|
|
221
|
+
throw configFail(`"roots" declares "${kitRoot}", at or inside the kit's own folder ${KIT_FOLDER_ROOT} — nothing in it is judged here, so declare a root outside it`);
|
|
222
|
+
}
|
|
217
223
|
if (Object.hasOwn(parsed, 'exclude')) {
|
|
218
224
|
if (!Array.isArray(parsed.exclude)) throw configFail('"exclude" must be an array of literal path prefixes');
|
|
219
225
|
for (const value of parsed.exclude) {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// Dependency-free, Node >= 22. No writes, no side effects on import.
|
|
17
17
|
|
|
18
18
|
import { SOURCE_SIZE_CONFIG_REL, SOURCE_SIZE_WARNING_PREFIX, SOURCE_SIZE_WHY, configPathFor, escapeForLine, isLineUnsafe, jsonForLine } from './source-size-refusal.mjs';
|
|
19
|
-
import { INITIAL_ADOPTION_REASON, SOURCE_SIZE_SCHEMA, practiceFacts } from './source-size-config.mjs';
|
|
19
|
+
import { INITIAL_ADOPTION_REASON, KIT_FOLDER_ROOT, SOURCE_SIZE_SCHEMA, practiceFacts } from './source-size-config.mjs';
|
|
20
20
|
import { SOURCE_SIZE_TOOL_PATH, dqUnsafePath } from './source-size-gate-cmd.mjs';
|
|
21
21
|
import { hasLoweredRecord, hasStoreRecord, stopsOf, warningsOf } from './source-size-judge.mjs';
|
|
22
22
|
import { isRaise, limitLines } from './source-size/index.mjs';
|
|
@@ -48,12 +48,16 @@ export const authoringTemplate = () => JSON.stringify({
|
|
|
48
48
|
export const statedLimitLines = (config) =>
|
|
49
49
|
limitLines(config.limits, { escape: escapeForLine, recorded: config.layout !== null }).map((line) => `source-size: ${line}`);
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
const KIT_FOLDER_LINE = `source-size: NOTE — ${KIT_FOLDER_ROOT} is the kit's own folder, so nothing in it is judged here; the kit's own repository judges its files`;
|
|
52
|
+
|
|
53
|
+
// What a run does not judge is said once, before its warnings: no extension, no config, no layout,
|
|
54
|
+
// and last the kit's own folder.
|
|
52
55
|
export const notJudgedLines = (cwd, { absent, config, layout }) => {
|
|
53
|
-
if (absent) return [`source-size: NOTE — ${namedConfig(cwd)} is absent, so the kit's values judge layout alone and no file is judged on lines or bytes
|
|
56
|
+
if (absent) return [`source-size: NOTE — ${namedConfig(cwd)} is absent, so the kit's values judge layout alone and no file is judged on lines or bytes`, KIT_FOLDER_LINE];
|
|
54
57
|
return [
|
|
55
58
|
...(config.extensions.length === 0 ? [`source-size: NOTE — ${namedConfig(cwd)} declares no extension, so no file is judged on lines or bytes`] : []),
|
|
56
59
|
...(layout ? [] : [`source-size: NOTE — ${namedConfig(cwd)} records no "layout", so entries per directory, depth and files per root are not judged; --write-baseline --layout --reason "<text>" starts it`]),
|
|
60
|
+
KIT_FOLDER_LINE,
|
|
57
61
|
];
|
|
58
62
|
};
|
|
59
63
|
|
|
@@ -200,8 +204,8 @@ const tightenLine = (cwd) => {
|
|
|
200
204
|
|
|
201
205
|
// The order every check prints: its notes, its warnings, then the green line or its stops.
|
|
202
206
|
export const checkReportLines = ({ cwd, config, verdict, absent = false }) => {
|
|
203
|
-
const lines = verdict.scope.emptyRoots.map(
|
|
204
|
-
|
|
207
|
+
const lines = verdict.scope.emptyRoots.map((rel) =>
|
|
208
|
+
`source-size: NOTE — the declared root "${escapeForLine(rel)}" matches no tracked file with a declared extension${verdict.scope.kitFolderRoots.includes(rel) ? ` outside the kit's own folder ${KIT_FOLDER_ROOT}` : ''}`);
|
|
205
209
|
const stops = stopsOf(verdict.findings);
|
|
206
210
|
const warnings = warningsOf(verdict.findings);
|
|
207
211
|
lines.push(...warningLines(warnings));
|
|
@@ -349,7 +353,8 @@ Usage:
|
|
|
349
353
|
node source-size-check.mjs --override <id> --kit-default --reason "<text>" [--cwd <project-root>]
|
|
350
354
|
|
|
351
355
|
Judges every in-scope file against ${SOURCE_SIZE_CONFIG_REL} (schema ${SOURCE_SIZE_SCHEMA}): git-tracked files
|
|
352
|
-
under a declared root carrying a declared extension, minus the excluded path-segment prefixes
|
|
356
|
+
under a declared root carrying a declared extension, minus the excluded path-segment prefixes and
|
|
357
|
+
the kit's own folder ${KIT_FOLDER_ROOT}, which nothing here judges and no root may declare. An
|
|
353
358
|
absent "roots" is the one root ".", every tracked path; a config declaring no extension judges no
|
|
354
359
|
file, and every check says so. With the config absent the check judges layout alone under the
|
|
355
360
|
kit's values. Symlinks and submodule gitlinks are skipped by kind; an unmerged index, a non-UTF-8
|
|
@@ -365,7 +370,8 @@ tolerance and source, then what it does not judge, then its warnings, then its s
|
|
|
365
370
|
Counting: lines, and the longest line in BYTES. A terminator never counts (the CR of a CRLF
|
|
366
371
|
included); a last line with no final newline still counts; an empty file is 0 lines. Layout: the
|
|
367
372
|
entries of each directory and its depth below its root, over every tracked entry under a declared
|
|
368
|
-
root plus the spec store docs/ai/specs walked from
|
|
373
|
+
root outside the kit's own folder ${KIT_FOLDER_ROOT} plus the spec store docs/ai/specs walked from
|
|
374
|
+
disk, and the files of each declared root.
|
|
369
375
|
|
|
370
376
|
A recorded entry is DEBT: a finding stops exactly when the regeneration would raise it, and a record
|
|
371
377
|
above the tree or gone warns until the regeneration lowers or removes it. Each declared root carries
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
// refuse through the same fail-closed lane.
|
|
5
5
|
//
|
|
6
6
|
// • SCOPE (fail-closed) — git-tracked files under a declared root carrying a declared extension,
|
|
7
|
-
// minus the excluded path-segment prefixes
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// is
|
|
7
|
+
// minus the excluded path-segment prefixes and the kit's own folder scripts/agent-workflow
|
|
8
|
+
// (KIT_FOLDER_ROOT). Symlinks and submodule gitlinks are skipped BY KIND. An unmerged index, a
|
|
9
|
+
// non-UTF-8 in-scope FILENAME, an unverifiable in-scope file and a declared scope matching no
|
|
10
|
+
// tracked file, the kit's own folder included, are REFUSALS (exit 1); a failed enumeration is
|
|
11
|
+
// exit 2. The enumeration is NUL-delimited and every path test runs on BYTES, so a tracked path
|
|
12
|
+
// carrying a tab or a newline is judged byte-exactly instead of being mangled by line splitting.
|
|
12
13
|
// • COUNTING — lines, and the longest line in BYTES. Terminators never count, CR included.
|
|
13
14
|
//
|
|
14
15
|
// Dependency-free, Node >= 22. No side effects on import; the only child process is a read-only git
|
|
@@ -18,7 +19,7 @@ import { lstatSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
18
19
|
import { join } from 'node:path';
|
|
19
20
|
import { spawnSync } from 'node:child_process';
|
|
20
21
|
import { configFail, configPathFor, scopeFail } from './source-size-refusal.mjs';
|
|
21
|
-
import { WHOLE_TREE_ROOT } from './source-size-config.mjs';
|
|
22
|
+
import { KIT_FOLDER_ROOT, WHOLE_TREE_ROOT } from './source-size-config.mjs';
|
|
22
23
|
import { SPEC_STORE_ROOT, walkSpecStore } from './source-size/index.mjs';
|
|
23
24
|
import { GIT_MAX_BUFFER, parseIndexEntries, resolveGitLocation, withGitPath } from './git-env.mjs';
|
|
24
25
|
|
|
@@ -27,6 +28,7 @@ const CR = 0x0d;
|
|
|
27
28
|
const SLASH = 0x2f;
|
|
28
29
|
|
|
29
30
|
const SPEC_STORE = Buffer.from(SPEC_STORE_ROOT, 'utf8');
|
|
31
|
+
const KIT_FOLDER = Buffer.from(KIT_FOLDER_ROOT, 'utf8');
|
|
30
32
|
const SYMLINK_MODE = '120000';
|
|
31
33
|
const GITLINK_MODE = '160000';
|
|
32
34
|
|
|
@@ -73,11 +75,12 @@ export const enumerateIndex = (cwd, deps = {}) => {
|
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
// resolveScope(cwd, config) → { files: [rel…] sorted, perRoot: Map<root, [rel…]>, layout: Map<root,
|
|
76
|
-
// [{ path, dir }…]>, emptyRoots: [root…] }; `layout` holds every entry under
|
|
77
|
-
// a binary string below the root
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
78
|
+
// [{ path, dir }…]>, emptyRoots: [root…], kitFolderRoots: [root…] }; `layout` holds every entry under
|
|
79
|
+
// a root, of any mode, as a binary string below the root; `kitFolderRoots` are the empty roots whose
|
|
80
|
+
// matches all lie inside the kit's own folder.
|
|
81
|
+
// Every exclusion is BY RULE (root / extension / exclude prefix / the kit's own folder) or BY KIND
|
|
82
|
+
// (symlink, gitlink); an in-scope path that cannot be addressed losslessly is a refusal, never a quiet
|
|
83
|
+
// skip. The root "." covers every tracked path.
|
|
81
84
|
export const resolveScope = (cwd, config, deps = {}) => {
|
|
82
85
|
const entries = enumerateIndex(cwd, deps);
|
|
83
86
|
const unmerged = entries.filter((e) => e.stage !== 0);
|
|
@@ -90,16 +93,22 @@ export const resolveScope = (cwd, config, deps = {}) => {
|
|
|
90
93
|
const perRoot = new Map(config.roots.map((rel) => [rel, []]));
|
|
91
94
|
const layout = new Map(config.roots.map((rel) => [rel, []]));
|
|
92
95
|
const files = [];
|
|
96
|
+
const kitMatched = new Set();
|
|
93
97
|
for (const entry of entries) {
|
|
94
98
|
const root = roots.find((r) => r.rel === WHOLE_TREE_ROOT || bufSegmentPrefix(entry.path, r.buf));
|
|
95
99
|
if (!root) continue;
|
|
96
100
|
if (excludes.some((ex) => bufSegmentPrefix(entry.path, ex))) continue;
|
|
101
|
+
const extended = extensions.some((ext) => bufEndsWith(entry.path, ext));
|
|
102
|
+
if (bufSegmentPrefix(entry.path, KIT_FOLDER)) {
|
|
103
|
+
if (extended) kitMatched.add(root.rel);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
97
106
|
// Layout counts every entry of any mode, the spec store's aside: the store is a root of its own.
|
|
98
107
|
if (!bufSegmentPrefix(entry.path, SPEC_STORE)) {
|
|
99
108
|
const below = root.rel === WHOLE_TREE_ROOT ? entry.path : entry.path.subarray(root.buf.length + 1);
|
|
100
109
|
if (below.length > 0) layout.get(root.rel).push({ path: below.toString('latin1'), dir: false });
|
|
101
110
|
}
|
|
102
|
-
if (!
|
|
111
|
+
if (!extended) continue;
|
|
103
112
|
if (entry.mode === SYMLINK_MODE || entry.mode === GITLINK_MODE) continue;
|
|
104
113
|
const rel = decodeStrict(entry.path);
|
|
105
114
|
if (rel === null) {
|
|
@@ -109,13 +118,15 @@ export const resolveScope = (cwd, config, deps = {}) => {
|
|
|
109
118
|
perRoot.get(root.rel).push(rel);
|
|
110
119
|
}
|
|
111
120
|
// A config declaring no extension judges no file, and the check says so instead of refusing.
|
|
112
|
-
if (extensions.length === 0) return { files, perRoot, layout, emptyRoots: [] };
|
|
113
|
-
|
|
121
|
+
if (extensions.length === 0) return { files, perRoot, layout, emptyRoots: [], kitFolderRoots: [] };
|
|
122
|
+
// A scope the kit's own folder alone matches judges no line, and is no misdeclaration.
|
|
123
|
+
if (files.length === 0 && kitMatched.size === 0) {
|
|
114
124
|
throw scopeFail(`the declared scope matches ZERO tracked files (roots: ${config.roots.join(', ')}; extensions: ${config.extensions.join(', ')}) — an empty scope is a misdeclaration, never an empty green; either widen "roots" / "extensions" in ${configPathFor(cwd)}, or track a file the declared scope covers`);
|
|
115
125
|
}
|
|
116
126
|
files.sort();
|
|
117
127
|
for (const list of perRoot.values()) list.sort();
|
|
118
|
-
|
|
128
|
+
const emptyRoots = [...perRoot].filter(([, list]) => list.length === 0).map(([rel]) => rel);
|
|
129
|
+
return { files, perRoot, layout, emptyRoots, kitFolderRoots: emptyRoots.filter((rel) => kitMatched.has(rel)) };
|
|
119
130
|
};
|
|
120
131
|
|
|
121
132
|
// specStoreEntries(cwd) → the spec store's entries walked from disk, or null where it is absent. A
|