@venizia/vulcan 0.4.8 → 0.4.9-1

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.
Files changed (179) hide show
  1. package/base/extensions/vulcan-guards.ts +48 -41
  2. package/base/hooks/antigravity-guards.ts +4 -3
  3. package/base/hooks/codex-guards.ts +17 -6
  4. package/base/hooks/guard-git.ts +8 -8
  5. package/base/hooks/guard-manifest.ts +5 -5
  6. package/base/hooks/guard-outside.ts +8 -8
  7. package/base/hooks/guard-package.ts +6 -6
  8. package/base/hooks/guard-remote-hosts.ts +14 -9
  9. package/base/hooks/guard-scripting.ts +6 -6
  10. package/base/hooks/guard-writes.ts +20 -11
  11. package/base/hooks/post-tool.ts +4 -3
  12. package/base/hooks/prompt-submit.ts +4 -3
  13. package/base/hooks/session-start.ts +5 -3
  14. package/base/hooks/stop.ts +4 -3
  15. package/base/hooks/subagent-start.ts +2 -2
  16. package/base/make/vulcan.mk +1 -4
  17. package/base/skills/build-a-feature/SKILL.md +1 -1
  18. package/base/skills/docs-update/SKILL.md +11 -5
  19. package/base/skills/docs-update/evals/evals.json +1 -1
  20. package/base/skills/docs-writing/SKILL.md +1 -1
  21. package/base/skills/plan-a-change/references/spec-card.md +1 -1
  22. package/base/skills/ship/SKILL.md +1 -1
  23. package/base/skills/visualize-work/SKILL.md +29 -6
  24. package/base/skills/visualize-work/references/spec.md +16 -5
  25. package/package.json +5 -6
  26. package/src/agents/atlas-block.ts +43 -43
  27. package/src/agents/codex-hooks.ts +55 -52
  28. package/src/agents/common/types.ts +1 -1
  29. package/src/agents/detect.ts +19 -16
  30. package/src/agents/exclude.ts +97 -98
  31. package/src/agents/hooks-json.ts +41 -43
  32. package/src/agents/local.ts +46 -43
  33. package/src/agents/prompt.ts +45 -42
  34. package/src/agents/render.ts +203 -201
  35. package/src/agents/resolve.ts +133 -134
  36. package/src/agents/table.ts +12 -8
  37. package/src/cli.ts +3 -1
  38. package/src/commands/add.command.ts +2 -2
  39. package/src/commands/agents.command.ts +11 -17
  40. package/src/commands/clean.command.ts +6 -6
  41. package/src/commands/doctor.command.ts +6 -4
  42. package/src/commands/help.command.ts +11 -9
  43. package/src/commands/init.command.ts +14 -8
  44. package/src/commands/preset.command.ts +2 -2
  45. package/src/commands/profile.command.ts +43 -50
  46. package/src/commands/sync.command.ts +109 -111
  47. package/src/commands/upgrade.command.ts +85 -78
  48. package/src/commands/visualize.command.ts +20 -5
  49. package/src/commands/x.command.ts +55 -50
  50. package/src/common/format.ts +23 -21
  51. package/src/common/index.ts +2 -0
  52. package/src/common/json.ts +8 -5
  53. package/src/common/layout-folder.ts +96 -111
  54. package/src/common/paths.ts +14 -12
  55. package/src/common/record.ts +7 -0
  56. package/src/common/text.ts +7 -0
  57. package/src/config/common/constants.ts +13 -1
  58. package/src/config/common/types.ts +8 -1
  59. package/src/config/loader.ts +53 -48
  60. package/src/config/packages.ts +17 -11
  61. package/src/config/schema.ts +54 -7
  62. package/src/create/add-app.ts +604 -493
  63. package/src/create/add-lib.ts +249 -242
  64. package/src/create/bunfig.ts +26 -23
  65. package/src/create/checks.ts +36 -34
  66. package/src/create/common/constants.ts +1 -0
  67. package/src/create/common/failure.ts +10 -0
  68. package/src/create/common/index.ts +2 -0
  69. package/src/create/common/preset-path.ts +11 -0
  70. package/src/create/common/types.ts +7 -2
  71. package/src/create/diff.ts +21 -23
  72. package/src/create/dockerignore.ts +26 -24
  73. package/src/create/files.ts +7 -5
  74. package/src/create/init-monorepo.ts +78 -80
  75. package/src/create/lib-preset.ts +62 -61
  76. package/src/create/manifest-json.ts +10 -4
  77. package/src/create/names.ts +217 -210
  78. package/src/create/next.ts +27 -24
  79. package/src/create/plan.ts +15 -12
  80. package/src/create/preset-diff.ts +415 -240
  81. package/src/create/preset-menu.ts +40 -34
  82. package/src/create/preset.ts +207 -194
  83. package/src/create/process.ts +80 -71
  84. package/src/create/scratch.ts +49 -48
  85. package/src/create/workspace.ts +423 -398
  86. package/src/doctor/checks.ts +1069 -998
  87. package/src/doctor/makefile.ts +17 -13
  88. package/src/doctor/runner.ts +88 -116
  89. package/src/doctor/skills.ts +97 -95
  90. package/src/doctor/tags.ts +44 -41
  91. package/src/hooks/codex-patch.ts +27 -24
  92. package/src/hooks/command-view.ts +44 -39
  93. package/src/hooks/common/constants.ts +0 -3
  94. package/src/hooks/common/types.ts +15 -1
  95. package/src/hooks/decision.ts +38 -42
  96. package/src/hooks/guard-git.ts +52 -50
  97. package/src/hooks/guard-manifest.ts +58 -55
  98. package/src/hooks/guard-outside.ts +109 -88
  99. package/src/hooks/guard-package.ts +86 -77
  100. package/src/hooks/guard-scripting.ts +20 -15
  101. package/src/hooks/guard-writes.ts +169 -111
  102. package/src/hooks/owner-reply.ts +128 -128
  103. package/src/hooks/post-tool.ts +94 -93
  104. package/src/hooks/project-guards.ts +93 -55
  105. package/src/hooks/project-tmp.ts +27 -24
  106. package/src/hooks/remote-hosts.ts +157 -149
  107. package/src/hooks/session-digest.ts +99 -95
  108. package/src/hooks/shell.ts +519 -500
  109. package/src/hooks/subagent-card.ts +11 -7
  110. package/src/hooks/trusted-scripts.ts +158 -80
  111. package/src/init/common/types.ts +1 -1
  112. package/src/init/scaffold.ts +137 -134
  113. package/src/local/clean.ts +39 -37
  114. package/src/local/format.ts +21 -17
  115. package/src/local/scan.ts +146 -140
  116. package/src/manifest/render.ts +127 -112
  117. package/src/owner/card.ts +51 -46
  118. package/src/owner/profile.ts +100 -96
  119. package/src/owner/reply-switch.ts +9 -6
  120. package/src/owner/shape.ts +72 -70
  121. package/src/owner/survey.ts +175 -164
  122. package/src/owner/view.ts +62 -59
  123. package/src/owner/violations.ts +119 -123
  124. package/src/router.ts +4 -1
  125. package/src/rules/base.ts +15 -11
  126. package/src/rules/common/types.ts +1 -1
  127. package/src/rules/parser.ts +39 -32
  128. package/src/rules/slots.ts +8 -6
  129. package/src/signals/claims.ts +30 -28
  130. package/src/signals/classify.ts +36 -33
  131. package/src/signals/loop.ts +39 -37
  132. package/src/signals/state.ts +80 -85
  133. package/src/skills/frontmatter.ts +28 -28
  134. package/src/sync/agent-files.ts +217 -199
  135. package/src/sync/agent-removal.ts +62 -68
  136. package/src/sync/atlas-block.ts +45 -43
  137. package/src/sync/base-rules.ts +32 -30
  138. package/src/sync/claude-launch.ts +74 -37
  139. package/src/sync/common/constants.ts +4 -0
  140. package/src/sync/common/index.ts +1 -0
  141. package/src/sync/common/symlink.ts +9 -0
  142. package/src/sync/common/types.ts +2 -2
  143. package/src/sync/exclude.ts +77 -69
  144. package/src/sync/local-choice.ts +50 -47
  145. package/src/sync/planner.ts +64 -68
  146. package/src/sync/prune.ts +52 -48
  147. package/src/sync/settings.ts +167 -168
  148. package/src/ui/capability.ts +12 -7
  149. package/src/ui/keyboard.ts +35 -33
  150. package/src/ui/prompt.ts +81 -77
  151. package/src/visualize/assets.ts +379 -195
  152. package/src/visualize/charts.ts +188 -176
  153. package/src/visualize/compare-css.ts +31 -0
  154. package/src/visualize/compare-render.ts +196 -0
  155. package/src/visualize/compare-schema.ts +81 -0
  156. package/src/visualize/compare-validate.ts +126 -0
  157. package/src/visualize/constants.ts +29 -3
  158. package/src/visualize/diagrams.ts +189 -174
  159. package/src/visualize/gate.ts +136 -0
  160. package/src/visualize/grid-span.ts +34 -0
  161. package/src/visualize/icons.ts +9 -4
  162. package/src/visualize/index.ts +2 -0
  163. package/src/visualize/kinds-css.ts +54 -0
  164. package/src/visualize/kinds-render.ts +698 -0
  165. package/src/visualize/kinds-schema.ts +148 -0
  166. package/src/visualize/kinds-validate.ts +186 -0
  167. package/src/visualize/labels-vi.ts +109 -0
  168. package/src/visualize/labels.ts +53 -0
  169. package/src/visualize/layout.ts +112 -92
  170. package/src/visualize/page.ts +140 -114
  171. package/src/visualize/render.ts +158 -114
  172. package/src/visualize/schema.ts +21 -1
  173. package/src/visualize/sections.ts +401 -309
  174. package/src/visualize/sources.ts +270 -0
  175. package/src/visualize/theme.ts +474 -0
  176. package/src/visualize/validate.ts +15 -5
  177. package/src/wiki/anchors.ts +39 -37
  178. package/src/wiki/command.ts +4 -4
  179. package/src/wiki/source-links.ts +49 -49
@@ -1,28 +1,16 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { existsSync, lstatSync, rmSync, unlinkSync } from 'node:fs';
3
3
  import { LocalConstants } from './constants.ts';
4
- import { isInsideLocal, scanLocal } from './scan.ts';
4
+ import { LocalScan } from './scan.ts';
5
5
  import type { ILocalEntry } from './scan.ts';
6
6
 
7
- export interface ICleanPlan {
7
+ interface ICleanPlan {
8
8
  /** What the chosen scopes would remove. */
9
9
  remove: ILocalEntry[];
10
10
  /** In a chosen scope but not removable (an unmerged worktree, a worktree git could not read). */
11
11
  keep: ILocalEntry[];
12
12
  }
13
13
 
14
- /** What the chosen scopes hold: what `clean` would remove and what it keeps, with the reason. */
15
- export const planClean = (opts: { root: string; scopes: string[]; now?: number }): ICleanPlan => {
16
- const inScope = scanLocal({ root: opts.root, now: opts.now }).filter((entry) =>
17
- opts.scopes.includes(entry.scope),
18
- );
19
-
20
- return {
21
- remove: inScope.filter((entry) => entry.removable),
22
- keep: inScope.filter((entry) => !entry.removable),
23
- };
24
- };
25
-
26
14
  const git = (opts: { cwd: string; args: string[] }): boolean =>
27
15
  spawnSync('git', opts.args, {
28
16
  cwd: opts.cwd,
@@ -33,7 +21,7 @@ const git = (opts: { cwd: string; args: string[] }): boolean =>
33
21
  const removeEntry = (opts: { root: string; entry: ILocalEntry }): string | undefined => {
34
22
  const { entry } = opts;
35
23
 
36
- if (!isInsideLocal({ root: opts.root, path: entry.path })) {
24
+ if (!LocalScan.isInside({ root: opts.root, path: entry.path })) {
37
25
  return 'refused: the path is not inside .agents/local/';
38
26
  }
39
27
 
@@ -61,28 +49,42 @@ const removeEntry = (opts: { root: string; entry: ILocalEntry }): string | undef
61
49
  }
62
50
  };
63
51
 
64
- /** Removes the plan's entries, then prunes git's worktree list. Returns what went and what failed. */
65
- export const runClean = (opts: {
66
- root: string;
67
- plan: ICleanPlan;
68
- }): { removed: ILocalEntry[]; failed: { entry: ILocalEntry; error: string }[] } => {
69
- const removed: ILocalEntry[] = [];
70
- const failed: { entry: ILocalEntry; error: string }[] = [];
71
-
72
- for (const entry of opts.plan.remove) {
73
- const error = removeEntry({ root: opts.root, entry });
74
-
75
- if (error === undefined) {
76
- removed.push(entry);
77
- } else {
78
- failed.push({ entry, error });
79
- }
52
+ export class LocalClean {
53
+ /** What the chosen scopes hold: what `clean` would remove and what it keeps, with the reason. */
54
+ static plan(opts: { root: string; scopes: string[]; now?: number }): ICleanPlan {
55
+ const inScope = LocalScan.scan({ root: opts.root, now: opts.now }).filter((entry) =>
56
+ opts.scopes.includes(entry.scope),
57
+ );
58
+
59
+ return {
60
+ remove: inScope.filter((entry) => entry.removable),
61
+ keep: inScope.filter((entry) => !entry.removable),
62
+ };
80
63
  }
81
64
 
82
- // Pruned after any worktree entry goes, registered or not: git then forgets one whose folder is gone.
83
- if (removed.some((entry) => entry.scope === 'worktrees')) {
84
- git({ cwd: opts.root, args: ['worktree', 'prune'] });
85
- }
65
+ /** Removes the plan's entries, then prunes git's worktree list. Returns what went and what failed. */
66
+ static run(opts: { root: string; plan: ICleanPlan }): {
67
+ removed: ILocalEntry[];
68
+ failed: { entry: ILocalEntry; error: string }[];
69
+ } {
70
+ const removed: ILocalEntry[] = [];
71
+ const failed: { entry: ILocalEntry; error: string }[] = [];
72
+
73
+ for (const entry of opts.plan.remove) {
74
+ const error = removeEntry({ root: opts.root, entry });
75
+
76
+ if (error === undefined) {
77
+ removed.push(entry);
78
+ } else {
79
+ failed.push({ entry, error });
80
+ }
81
+ }
86
82
 
87
- return { removed, failed };
88
- };
83
+ // Pruned after any worktree entry goes, registered or not: git then forgets one whose folder is gone.
84
+ if (removed.some((entry) => entry.scope === 'worktrees')) {
85
+ git({ cwd: opts.root, args: ['worktree', 'prune'] });
86
+ }
87
+
88
+ return { removed, failed };
89
+ }
90
+ }
@@ -1,25 +1,29 @@
1
1
  const UNITS = ['B', 'KB', 'MB', 'GB'];
2
2
 
3
- /** `1536` as `1.5 KB`: one decimal from KB up, whole bytes below. */
4
- export const formatBytes = (opts: { bytes: number }): string => {
5
- let value = opts.bytes;
6
- let unit = 0;
3
+ export class LocalFormat {
4
+ /** `1536` as `1.5 KB`: one decimal from KB up, whole bytes below. */
5
+ static formatBytes(opts: { bytes: number }): string {
6
+ let value = opts.bytes;
7
+ let unit = 0;
7
8
 
8
- while (value >= 1024 && unit < UNITS.length - 1) {
9
- value /= 1024;
10
- unit += 1;
9
+ while (value >= 1024 && unit < UNITS.length - 1) {
10
+ value /= 1024;
11
+ unit += 1;
12
+ }
13
+
14
+ return unit === 0 ? `${value} B` : `${value.toFixed(1)} ${UNITS[unit]}`;
11
15
  }
12
16
 
13
- return unit === 0 ? `${value} B` : `${value.toFixed(1)} ${UNITS[unit]}`;
14
- };
17
+ /** An age in the largest whole unit: `5m`, `3h`, `2d`. */
18
+ static formatAge(opts: { ageMs: number }): string {
19
+ const minutes = Math.floor(opts.ageMs / 60_000);
15
20
 
16
- /** An age in the largest whole unit: `5m`, `3h`, `2d`. */
17
- export const formatAge = (opts: { ageMs: number }): string => {
18
- const minutes = Math.floor(opts.ageMs / 60_000);
21
+ if (minutes < 60) {
22
+ return `${Math.max(minutes, 0)}m`;
23
+ }
19
24
 
20
- if (minutes < 60) {
21
- return `${Math.max(minutes, 0)}m`;
25
+ return minutes < 60 * 24
26
+ ? `${Math.floor(minutes / 60)}h`
27
+ : `${Math.floor(minutes / (60 * 24))}d`;
22
28
  }
23
-
24
- return minutes < 60 * 24 ? `${Math.floor(minutes / 60)}h` : `${Math.floor(minutes / (60 * 24))}d`;
25
- };
29
+ }
package/src/local/scan.ts CHANGED
@@ -28,7 +28,7 @@ interface IRegistered {
28
28
  }
29
29
 
30
30
  /** The newest modification time under `path`, itself included: a folder's own time moves only when its direct children do. */
31
- export const newestModifiedAt = (opts: { path: string }): number => {
31
+ const newestModifiedAt = (opts: { path: string }): number => {
32
32
  let stat;
33
33
 
34
34
  try {
@@ -48,7 +48,7 @@ export const newestModifiedAt = (opts: { path: string }): number => {
48
48
  };
49
49
 
50
50
  /** The bytes under `path`, symlinks counted as themselves and never followed. */
51
- export const sizeOf = (opts: { path: string }): number => {
51
+ const sizeOf = (opts: { path: string }): number => {
52
52
  let stat;
53
53
 
54
54
  try {
@@ -67,29 +67,6 @@ export const sizeOf = (opts: { path: string }): number => {
67
67
  );
68
68
  };
69
69
 
70
- /**
71
- * The real path of the project's `.agents/local/`, or `undefined` when there is none or it cannot be
72
- * trusted: `.agents` or `.agents/local` is a symlink, or the folder resolves outside the project. Every
73
- * scan and every removal starts here, so a link can never move them out of the project.
74
- */
75
- export const localRootOf = (opts: { root: string }): string | undefined => {
76
- const agents = join(opts.root, '.agents');
77
- const local = join(opts.root, ProjectLayout.LOCAL_DIRECTORY);
78
-
79
- try {
80
- if (lstatSync(agents).isSymbolicLink() || lstatSync(local).isSymbolicLink()) {
81
- return undefined;
82
- }
83
-
84
- const real = realpathSync(local);
85
- const realRoot = realpathSync(opts.root);
86
-
87
- return real.startsWith(`${realRoot}${sep}`) && lstatSync(real).isDirectory() ? real : undefined;
88
- } catch {
89
- return undefined;
90
- }
91
- };
92
-
93
70
  const git = (opts: { cwd: string; args: string[] }): string | undefined => {
94
71
  const result = spawnSync('git', opts.args, {
95
72
  cwd: opts.cwd,
@@ -100,43 +77,6 @@ const git = (opts: { cwd: string; args: string[] }): string | undefined => {
100
77
  return result.status === 0 ? result.stdout : undefined;
101
78
  };
102
79
 
103
- /**
104
- * The output of `git worktree list --porcelain -z`: records end with an extra NUL and fields are NUL
105
- * separated, so a path with a line break or odd characters is read whole.
106
- */
107
- export const parseWorktreeList = (opts: { output: string }): Map<string, IRegistered> => {
108
- const map = new Map<string, IRegistered>();
109
-
110
- for (const record of opts.output.split('\0\0')) {
111
- const fields = record.split('\0').filter((field) => field !== '');
112
- const path = fields.find((field) => field.startsWith('worktree '))?.slice('worktree '.length);
113
- const branch = fields
114
- .find((field) => field.startsWith('branch refs/heads/'))
115
- ?.slice('branch refs/heads/'.length);
116
- const head = fields.find((field) => /^HEAD [0-9a-f]{7,64}$/.test(field))?.slice('HEAD '.length);
117
-
118
- if (path !== undefined) {
119
- map.set(existsSync(path) ? realpathSync(path) : path, { branch, head });
120
- }
121
- }
122
-
123
- return map;
124
- };
125
-
126
- /** The registered worktrees of the repository at `root`; `undefined` when git cannot list them. */
127
- const registeredWorktrees = (opts: { root: string }): Map<string, IRegistered> | undefined => {
128
- const listed = git({ cwd: opts.root, args: ['worktree', 'list', '--porcelain', '-z'] });
129
-
130
- return listed === undefined ? undefined : parseWorktreeList({ output: listed });
131
- };
132
-
133
- interface IVerdict {
134
- state: string;
135
- removable: boolean;
136
- registered: boolean;
137
- note: string;
138
- }
139
-
140
80
  const classifyBranch = (opts: {
141
81
  root: string;
142
82
  real: string;
@@ -262,107 +202,173 @@ const isRealDirectory = (opts: { path: string }): boolean => {
262
202
  }
263
203
  };
264
204
 
265
- /** Every entry of `.agents/local/`, with size, age and what may be removed. Nothing is followed outside it. */
266
- export const scanLocal = (opts: { root: string; now?: number }): ILocalEntry[] => {
267
- const local = localRootOf({ root: opts.root });
268
- const now = opts.now ?? Date.now();
205
+ export class LocalScan {
206
+ /** The registered worktrees of the repository at `root`; `undefined` when git cannot list them. */
207
+ private static registeredWorktrees(opts: { root: string }): Map<string, IRegistered> | undefined {
208
+ const listed = git({ cwd: opts.root, args: ['worktree', 'list', '--porcelain', '-z'] });
269
209
 
270
- if (local === undefined) {
271
- return [];
210
+ return listed === undefined ? undefined : LocalScan.parseWorktreeList({ output: listed });
272
211
  }
273
212
 
274
- const registered = registeredWorktrees({ root: opts.root });
275
- const entries: ILocalEntry[] = [];
213
+ /**
214
+ * The real path of the project's `.agents/local/`, or `undefined` when there is none or it cannot be
215
+ * trusted: `.agents` or `.agents/local` is a symlink, or the folder resolves outside the project. Every
216
+ * scan and every removal starts here, so a link can never move them out of the project.
217
+ */
218
+ static localRootOf(opts: { root: string }): string | undefined {
219
+ const agents = join(opts.root, '.agents');
220
+ const local = join(opts.root, ProjectLayout.LOCAL_DIRECTORY);
221
+
222
+ try {
223
+ if (lstatSync(agents).isSymbolicLink() || lstatSync(local).isSymbolicLink()) {
224
+ return undefined;
225
+ }
226
+
227
+ const real = realpathSync(local);
228
+ const realRoot = realpathSync(opts.root);
276
229
 
277
- for (const layout of ProjectLayout.LOCAL_LAYOUT) {
278
- const directory = join(local, layout.name);
230
+ return real.startsWith(`${realRoot}${sep}`) && lstatSync(real).isDirectory()
231
+ ? real
232
+ : undefined;
233
+ } catch {
234
+ return undefined;
235
+ }
236
+ }
279
237
 
280
- if (!isRealDirectory({ path: directory })) {
281
- continue;
238
+ /**
239
+ * The output of `git worktree list --porcelain -z`: records end with an extra NUL and fields are NUL
240
+ * separated, so a path with a line break or odd characters is read whole.
241
+ */
242
+ static parseWorktreeList(opts: { output: string }): Map<string, IRegistered> {
243
+ const map = new Map<string, IRegistered>();
244
+
245
+ for (const record of opts.output.split('\0\0')) {
246
+ const fields = record.split('\0').filter((field) => field !== '');
247
+ const path = fields.find((field) => field.startsWith('worktree '))?.slice('worktree '.length);
248
+ const branch = fields
249
+ .find((field) => field.startsWith('branch refs/heads/'))
250
+ ?.slice('branch refs/heads/'.length);
251
+ const head = fields
252
+ .find((field) => /^HEAD [0-9a-f]{7,64}$/.test(field))
253
+ ?.slice('HEAD '.length);
254
+
255
+ if (path !== undefined) {
256
+ map.set(existsSync(path) ? realpathSync(path) : path, { branch, head });
257
+ }
282
258
  }
283
259
 
284
- for (const name of readdirSync(directory)) {
285
- if (name === '.gitkeep') {
260
+ return map;
261
+ }
262
+
263
+ /** Every entry of `.agents/local/`, with size, age and what may be removed. Nothing is followed outside it. */
264
+ static scan(opts: { root: string; now?: number }): ILocalEntry[] {
265
+ const local = LocalScan.localRootOf({ root: opts.root });
266
+ const now = opts.now ?? Date.now();
267
+
268
+ if (local === undefined) {
269
+ return [];
270
+ }
271
+
272
+ const registered = LocalScan.registeredWorktrees({ root: opts.root });
273
+ const entries: ILocalEntry[] = [];
274
+
275
+ for (const layout of ProjectLayout.LOCAL_LAYOUT) {
276
+ const directory = join(local, layout.name);
277
+
278
+ if (!isRealDirectory({ path: directory })) {
286
279
  continue;
287
280
  }
288
281
 
289
- const path = join(directory, name);
290
- const stat = lstatSync(path);
291
- const ageMs = now - newestModifiedAt({ path });
292
- const staleAfter =
293
- 'staleAfterDays' in layout ? layout.staleAfterDays * LocalConstants.DAY_MS : undefined;
294
- let state: string = LocalStates.OK;
295
- let removable = true;
296
- let isRegistered = false;
297
- let note = '';
298
-
299
- if (layout.name === CleanScopes.WORKTREES) {
300
- const verdict = classifyWorktree({
301
- root: opts.root,
302
- real: stat.isSymbolicLink() ? resolve(path) : realpathSync(path),
303
- registered,
282
+ for (const name of readdirSync(directory)) {
283
+ if (name === '.gitkeep') {
284
+ continue;
285
+ }
286
+
287
+ const path = join(directory, name);
288
+ const stat = lstatSync(path);
289
+ const ageMs = now - newestModifiedAt({ path });
290
+ const staleAfter =
291
+ 'staleAfterDays' in layout ? layout.staleAfterDays * LocalConstants.DAY_MS : undefined;
292
+ let state: string = LocalStates.OK;
293
+ let removable = true;
294
+ let isRegistered = false;
295
+ let note = '';
296
+
297
+ if (layout.name === CleanScopes.WORKTREES) {
298
+ const verdict = classifyWorktree({
299
+ root: opts.root,
300
+ real: stat.isSymbolicLink() ? resolve(path) : realpathSync(path),
301
+ registered,
302
+ });
303
+
304
+ ({ state, removable, registered: isRegistered, note } = verdict);
305
+ } else if (staleAfter !== undefined && ageMs > staleAfter) {
306
+ state = LocalStates.STALE;
307
+ }
308
+
309
+ entries.push({
310
+ scope: layout.name,
311
+ name,
312
+ path,
313
+ bytes: sizeOf({ path }),
314
+ ageMs,
315
+ state,
316
+ removable,
317
+ isSymlink: stat.isSymbolicLink(),
318
+ registered: isRegistered,
319
+ note,
304
320
  });
305
-
306
- ({ state, removable, registered: isRegistered, note } = verdict);
307
- } else if (staleAfter !== undefined && ageMs > staleAfter) {
308
- state = LocalStates.STALE;
309
321
  }
322
+ }
323
+
324
+ const profile = join(local, 'profile.json');
325
+
326
+ if (existsSync(profile)) {
327
+ const stat = lstatSync(profile);
310
328
 
311
329
  entries.push({
312
- scope: layout.name,
313
- name,
314
- path,
315
- bytes: sizeOf({ path }),
316
- ageMs,
317
- state,
318
- removable,
330
+ scope: CleanScopes.PROFILE,
331
+ name: 'profile.json',
332
+ path: profile,
333
+ bytes: stat.size,
334
+ ageMs: now - stat.mtimeMs,
335
+ state: LocalStates.OK,
336
+ removable: true,
319
337
  isSymlink: stat.isSymbolicLink(),
320
- registered: isRegistered,
321
- note,
338
+ registered: false,
339
+ note: '',
322
340
  });
323
341
  }
324
- }
325
-
326
- const profile = join(local, 'profile.json');
327
342
 
328
- if (existsSync(profile)) {
329
- const stat = lstatSync(profile);
330
-
331
- entries.push({
332
- scope: CleanScopes.PROFILE,
333
- name: 'profile.json',
334
- path: profile,
335
- bytes: stat.size,
336
- ageMs: now - stat.mtimeMs,
337
- state: LocalStates.OK,
338
- removable: true,
339
- isSymlink: stat.isSymbolicLink(),
340
- registered: false,
341
- note: '',
342
- });
343
+ return entries;
343
344
  }
344
345
 
345
- return entries;
346
- };
346
+ /**
347
+ * Whether `path` sits under the project's trusted `.agents/local/` once its parent is resolved; a final
348
+ * symlink is not followed. A symlinked `.agents` or `.agents/local` makes it false for everything.
349
+ */
350
+ static isInside(opts: { root: string; path: string }): boolean {
351
+ const local = LocalScan.localRootOf({ root: opts.root });
347
352
 
348
- /**
349
- * Whether `path` sits under the project's trusted `.agents/local/` once its parent is resolved; a final
350
- * symlink is not followed. A symlinked `.agents` or `.agents/local` makes it false for everything.
351
- */
352
- export const isInsideLocal = (opts: { root: string; path: string }): boolean => {
353
- const local = localRootOf({ root: opts.root });
353
+ if (local === undefined) {
354
+ return false;
355
+ }
354
356
 
355
- if (local === undefined) {
356
- return false;
357
- }
357
+ const parent = resolve(opts.path, '..');
358
358
 
359
- const parent = resolve(opts.path, '..');
359
+ if (!existsSync(parent)) {
360
+ return false;
361
+ }
360
362
 
361
- if (!existsSync(parent)) {
362
- return false;
363
- }
363
+ const target = join(realpathSync(parent), resolve(opts.path).split(sep).at(-1) ?? '');
364
364
 
365
- const target = join(realpathSync(parent), resolve(opts.path).split(sep).at(-1) ?? '');
365
+ return target.startsWith(`${local}${sep}`);
366
+ }
367
+ }
366
368
 
367
- return target.startsWith(`${local}${sep}`);
368
- };
369
+ interface IVerdict {
370
+ state: string;
371
+ removable: boolean;
372
+ registered: boolean;
373
+ note: string;
374
+ }