@sabaiway/agent-workflow-kit 20.0.0 → 20.1.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 CHANGED
@@ -4,6 +4,48 @@ 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.1.0 — the size check leaves the kit's own folder `scripts/agent-workflow` alone (AD-218)
8
+
9
+ **A coming kit release can move its scripts into one folder of your project without stopping a single commit.** The
10
+ kit's scripts will live in `scripts/agent-workflow`, and the kit's own repository already judges their size. Before
11
+ they move, `source-size-check` stops judging that folder in your project:
12
+
13
+ - Every tracked entry at or under `scripts/agent-workflow` is taken away before anything is judged, under every
14
+ declared root, the root `.` and an absent `docs/ai/source-size.json` included: no line, byte, layout entry, files-per-root
15
+ count or aggregate line counts it, and its own name is counted by nothing in `scripts`. The comparison is by whole
16
+ path segment, so `scripts/agent-workflow-x/a.mjs` and `scripts/agent-workflowx.mjs` stay judged.
17
+ - Every `--check`, `--write-baseline` and `--override` run that judges the tree prints, as the last of its not-judged
18
+ lines: `source-size: NOTE — scripts/agent-workflow is the kit's own folder, so nothing in it is judged here; the
19
+ kit's own repository judges its files`. `--help` names the folder in its scope and layout sentences.
20
+ - A declared root at or inside the folder is a config stop, exit 2, naming the root; the roots `scripts` and `.` stay
21
+ valid, and so does an `exclude` entry inside the folder.
22
+ - A recorded `baseline` or `layout.directories` key under the folder reads as gone: it warns, exit 0, and your next
23
+ `--write-baseline` removes it with no reason.
24
+ - A declared scope whose only matches lie inside the folder judges no file on lines or bytes and is not refused as
25
+ empty; its empty-root note says the root matches nothing outside the kit's own folder.
26
+ - The plan-shape check's source scope takes the folder away by the same rule.
27
+
28
+ No project holds the folder yet, so the changes you see today are the new NOTE line and the `--help` text that names
29
+ the folder. Contract: source-size revision 8.
30
+
31
+ ## 20.0.1 — `init` removes the folders it leaves empty in the kit home (AD-217)
32
+
33
+ **A refresh no longer asks you to delete folders by hand.** `init` removes from an existing kit home every file in
34
+ the kit's folders that the package does not carry, but it kept the folders themselves and printed `kept <folder> (a
35
+ directory the package does not carry — yours to remove by hand)` for the topmost such folder of each tree, on every
36
+ run. Moving to 20.0.0, which ships no test suites, left 70 empty folders and 26 such lines. Now:
37
+
38
+ - After removing the files, `init` removes each folder the package does not carry that is left empty, children first,
39
+ with one `removed <folder> (not in the package)` line for the topmost folder of each removed tree. The next run over
40
+ the same home prints nothing for it.
41
+ - A folder that still holds something stays, with one `kept <folder> (a directory the package does not carry that
42
+ still holds an entry)` line for the topmost such folder of each tree. A symlink the package does not carry stays the owner's, unchanged.
43
+ - The removal is a single non-recursive `rmdir` behind the same guards as the file removal; a failure is reported by
44
+ folder and cause and fails the install, like a file that cannot be removed.
45
+
46
+ Your next `npx @sabaiway/agent-workflow-kit@latest init` removes the empty folders earlier refreshes left. Contract:
47
+ upgrade-delivery revision 10.
48
+
7
49
  ## 20.0.0 — the kit's text lives in kit files and one kit block; one upgrade moves your project once (AD-216)
8
50
 
9
51
  **Your project's own files can no longer lose the kit's updates.** Until now the kit kept its standing text inside
package/README.md CHANGED
@@ -207,7 +207,7 @@ other agent). The manual path works identically but **isn't reflected in install
207
207
  <summary><b>What <code>init</code> touches — and how to undo it</b></summary>
208
208
 
209
209
  `init` **never deletes your project settings**, and it installs only into a new or empty folder or an existing kit home: any other `--dir` is refused before anything is written. In an existing kit home it removes every file in the kit's
210
- `references/`, `tools/`, `migrations/`, `launchers/` and `bridges/` folders that the package does not carry, a file you put there included, one reported line per file. It writes its own namespaced slots, then
210
+ `references/`, `tools/`, `migrations/`, `launchers/` and `bridges/` folders that the package does not carry, a file you put there included, one reported line per file, and then each folder there that is left empty. It writes its own namespaced slots, then
211
211
  refreshes the other npm core members so a returning `init` leaves **no stale core member**:
212
212
 
213
213
  | Path | What |
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.0'
6
+ version: '20.1.0'
7
7
  ---
8
8
 
9
9
  # agent-workflow-kit
package/bin/install.mjs CHANGED
@@ -293,7 +293,7 @@ Installs/refreshes the kit at ~/.claude/skills/agent-workflow-kit
293
293
  stays /agent-workflow-kit setup, opt-in); once placed, init refreshes them from the kit's
294
294
  own bundled copies — local files only, never a downgrade — and --no-bridges skips that
295
295
  refresh. init never deletes your project settings; in an existing kit home it removes each
296
- file in its folders that the package does not carry, one line each. If the
296
+ file in its folders that the package does not carry and each folder left empty. If the
297
297
  installed kit is newer than the version you ran, init refuses (no network — it compares
298
298
  the version on disk) and points you at @latest; --allow-downgrade overrides that
299
299
  refusal (distinct from --force, which is launcher-only).
package/capability.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schema": 1,
4
4
  "name": "agent-workflow-kit",
5
5
  "kind": "composition-root",
6
- "version": "20.0.0",
6
+ "version": "20.1.0",
7
7
  "provides": [],
8
8
  "roles": {},
9
9
  "detect": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaiway/agent-workflow-kit",
3
- "version": "20.0.0",
3
+ "version": "20.1.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",
@@ -1,4 +1,4 @@
1
- import { lstatSync, readdirSync, readFileSync, unlinkSync } from 'node:fs';
1
+ import { lstatSync, readdirSync, readFileSync, rmdirSync, unlinkSync } from 'node:fs';
2
2
  import { resolve, sep } from 'node:path';
3
3
  import { assertContainedRealPath } from './fs-safe.mjs';
4
4
  import { lstatNoFollowRead } from './fs-read-nofollow.mjs';
@@ -107,9 +107,7 @@ const readTree = (root, entry, reports, directoryOnly = false) => {
107
107
  return entries;
108
108
  };
109
109
 
110
- // The walk lists a directory before its children, so a kept directory's line covers the directories beneath it.
111
- const planSubtree = (carried, installed, orphans, reports) => {
112
- const keptDirectories = [];
110
+ const planSubtree = (carried, installed, orphans, directories, reports) => {
113
111
  for (const [path, kind] of installed) {
114
112
  if (carried.has(path)) {
115
113
  const packageKind = carried.get(path);
@@ -121,10 +119,9 @@ const planSubtree = (carried, installed, orphans, reports) => {
121
119
  }
122
120
  } else if (kind === 'file') {
123
121
  orphans.push(path);
124
- } else if (kind === 'directory' && keptDirectories.some((kept) => path.startsWith(`${kept}/`))) {
125
- continue;
122
+ } else if (kind === 'directory') {
123
+ directories.push(path);
126
124
  } else {
127
- if (kind === 'directory') keptDirectories.push(path);
128
125
  reports.push({
129
126
  ok: true,
130
127
  line: `${PREFIX} kept ${path} (a ${kind} the package does not carry — yours to remove by hand)`,
@@ -151,9 +148,50 @@ const removeOrphan = (home, path, remove) => {
151
148
  }
152
149
  };
153
150
 
151
+ const removeEmptyDirectory = (home, path, remove) => {
152
+ const absolute = resolve(home, path);
153
+ try {
154
+ remove.assertContainedRealPath(home, absolute);
155
+ const stat = remove.lstatNoFollowRead(absolute);
156
+ if (stat === null) {
157
+ return { state: 'absent' };
158
+ }
159
+ if (!stat.isDirectory()) {
160
+ throw new Error('the path is no longer a real directory');
161
+ }
162
+ remove.rmdirSync(absolute);
163
+ return { state: 'removed' };
164
+ } catch (error) {
165
+ const settled = { ENOTEMPTY: 'kept', EEXIST: 'kept', ENOENT: 'absent' }[error.code];
166
+ return settled ? { state: settled } : { state: 'failed', report: reportFailure(path, error) };
167
+ }
168
+ };
169
+
170
+ // The walk lists a directory before its children: reversed, a child is removed before its parent.
171
+ const removeEmptyDirectories = (home, directories, remove) => {
172
+ const outcomes = new Map([...directories].reverse().map((path) => [path, removeEmptyDirectory(home, path, remove)]));
173
+ const isTop = (path) => !directories.some((other) => path.startsWith(`${other}/`));
174
+ return directories.flatMap((path) => {
175
+ const { state, report } = outcomes.get(path);
176
+ if (state === 'failed') {
177
+ return [report];
178
+ }
179
+ if (!isTop(path) || state === 'absent') {
180
+ return [];
181
+ }
182
+ return [{
183
+ ok: true,
184
+ line: state === 'removed'
185
+ ? `${PREFIX} removed ${path} (not in the package)`
186
+ : `${PREFIX} kept ${path} (a directory the package does not carry that still holds an entry)`,
187
+ }];
188
+ });
189
+ };
190
+
154
191
  export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
155
192
  const reports = [];
156
193
  const orphans = [];
194
+ const directories = [];
157
195
  for (const entry of new Set(payload)) {
158
196
  const path = entry.split(sep).join('/');
159
197
  const carried = readTree(packageRoot, path, reports, true);
@@ -161,7 +199,7 @@ export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
161
199
  continue;
162
200
  }
163
201
  const installed = readTree(home, path, reports);
164
- planSubtree(carried, installed, orphans, reports);
202
+ planSubtree(carried, installed, orphans, directories, reports);
165
203
  }
166
204
  if (reports.some((report) => !report.ok)) {
167
205
  return finishReport(reports);
@@ -170,9 +208,11 @@ export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
170
208
  assertContainedRealPath: deps.assertContainedRealPath ?? assertContainedRealPath,
171
209
  lstatNoFollowRead: deps.lstatNoFollowRead ?? lstatNoFollowRead,
172
210
  unlinkSync: deps.unlinkSync ?? unlinkSync,
211
+ rmdirSync: deps.rmdirSync ?? rmdirSync,
173
212
  };
174
213
  for (const path of orphans) {
175
214
  reports.push(...removeOrphan(home, path, remove));
176
215
  }
216
+ reports.push(...removeEmptyDirectories(home, directories, remove));
177
217
  return finishReport(reports);
178
218
  };
@@ -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
- // What a run does not judge is said once, before its warnings: no extension, no config, no layout.
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
- (rel) => `source-size: NOTE — the declared root "${escapeForLine(rel)}" matches no tracked file with a declared extension`);
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. An
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 disk, and the files of each declared root.
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. Symlinks and submodule gitlinks are skipped BY KIND.
8
- // An unmerged index, a non-UTF-8 in-scope FILENAME, an unverifiable in-scope file and an empty
9
- // declared scope are REFUSALS (exit 1); a failed enumeration is exit 2. The enumeration is
10
- // NUL-delimited and every path test runs on BYTES, so a tracked path carrying a tab or a newline
11
- // is judged byte-exactly instead of being mangled by line splitting.
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 a root, of any mode, as
77
- // a binary string below the root.
78
- // Every exclusion is BY RULE (root / extension / exclude prefix) or BY KIND (symlink, gitlink); an
79
- // in-scope path that cannot be addressed losslessly is a refusal, never a quiet skip. The root "."
80
- // covers every tracked path.
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 (!extensions.some((ext) => bufEndsWith(entry.path, ext))) continue;
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
- if (files.length === 0) {
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
- return { files, perRoot, layout, emptyRoots: [...perRoot].filter(([, list]) => list.length === 0).map(([rel]) => rel) };
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