architecture-harness 0.25.0 → 0.26.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.
Files changed (244) hide show
  1. package/package.json +3 -22
  2. package/src/cli/ask.mjs +42 -0
  3. package/src/cli/ask.test.mjs +40 -0
  4. package/src/cli/branch-sync.mjs +126 -0
  5. package/src/cli/branch-sync.test.mjs +428 -0
  6. package/src/cli/budget-guard.mjs +74 -5
  7. package/src/cli/budget-guard.test.mjs +185 -2
  8. package/src/cli/budget-report.mjs +85 -0
  9. package/src/cli/budget-report.test.mjs +173 -0
  10. package/src/cli/budget.mjs +8 -5
  11. package/src/cli/check-commands.mjs +123 -11
  12. package/src/cli/check-commands.test.mjs +360 -6
  13. package/src/cli/check-feature-switches.test.mjs +110 -0
  14. package/src/cli/check-full.test.mjs +152 -0
  15. package/src/cli/check-verdict.mjs +46 -0
  16. package/src/cli/check-verdict.test.mjs +32 -0
  17. package/src/cli/check.mjs +137 -4
  18. package/src/cli/check.test.mjs +45 -0
  19. package/src/cli/checkpoint.mjs +143 -0
  20. package/src/cli/checkpoint.test.mjs +146 -0
  21. package/src/cli/child-run.mjs +7 -2
  22. package/src/cli/child-run.test.mjs +17 -2
  23. package/src/cli/ci-failures.mjs +304 -0
  24. package/src/cli/ci-failures.test.mjs +615 -0
  25. package/src/cli/ci-preview.mjs +62 -0
  26. package/src/cli/ci-preview.test.mjs +85 -0
  27. package/src/cli/ci-state.mjs +25 -29
  28. package/src/cli/ci-state.test.mjs +174 -2
  29. package/src/cli/ci-template.test.mjs +86 -0
  30. package/src/cli/claude-core.test.mjs +37 -0
  31. package/src/cli/codex-implement.mjs +580 -47
  32. package/src/cli/codex-implement.test.mjs +1946 -29
  33. package/src/cli/codex-limit.mjs +85 -0
  34. package/src/cli/codex-limit.test.mjs +179 -0
  35. package/src/cli/codex-reset.mjs +78 -0
  36. package/src/cli/codex-reset.test.mjs +192 -0
  37. package/src/cli/codex-verify.mjs +230 -0
  38. package/src/cli/codex-verify.test.mjs +402 -0
  39. package/src/cli/comment-watch.mjs +391 -0
  40. package/src/cli/comment-watch.test.mjs +392 -0
  41. package/src/cli/commit-guard.mjs +219 -0
  42. package/src/cli/commit-guard.test.mjs +809 -0
  43. package/src/cli/context-budgets.mjs +47 -0
  44. package/src/cli/context-budgets.test.mjs +96 -0
  45. package/src/cli/context-watch.mjs +116 -0
  46. package/src/cli/context-watch.test.mjs +395 -0
  47. package/src/cli/contract-history.mjs +1 -1
  48. package/src/cli/controller-guard.mjs +38 -0
  49. package/src/cli/controller-guard.test.mjs +66 -2
  50. package/src/cli/cost-stop.mjs +5 -1
  51. package/src/cli/cost-stop.test.mjs +26 -0
  52. package/src/cli/diff-shape.mjs +162 -0
  53. package/src/cli/diff-shape.test.mjs +200 -0
  54. package/src/cli/direct-lane.mjs +32 -19
  55. package/src/cli/direct-lane.test.mjs +21 -3
  56. package/src/cli/dispatch-guard.mjs +11 -0
  57. package/src/cli/dispatch-guard.test.mjs +145 -10
  58. package/src/cli/dispatch-reminder.mjs +23 -10
  59. package/src/cli/dispatch-reminder.test.mjs +63 -11
  60. package/src/cli/dispatch-route.mjs +54 -0
  61. package/src/cli/dispatch-route.test.mjs +101 -0
  62. package/src/cli/dispatch-slot.mjs +2 -2
  63. package/src/cli/dispatch-slot.test.mjs +18 -19
  64. package/src/cli/dispatch.test.mjs +3 -3
  65. package/src/cli/e2e-affected.mjs +15 -0
  66. package/src/cli/e2e-affected.test.mjs +73 -0
  67. package/src/cli/fleet.mjs +180 -0
  68. package/src/cli/fleet.test.mjs +213 -0
  69. package/src/cli/gate-slot.mjs +2 -1
  70. package/src/cli/gh-merge-command.mjs +96 -31
  71. package/src/cli/gh-merge-command.test.mjs +74 -0
  72. package/src/cli/gh-run.mjs +64 -3
  73. package/src/cli/gh-run.test.mjs +66 -1
  74. package/src/cli/git-hooks.test.mjs +25 -3
  75. package/src/cli/git-read.mjs +2 -1
  76. package/src/cli/integrate-tree.mjs +47 -0
  77. package/src/cli/integrate.mjs +143 -40
  78. package/src/cli/integrate.test.mjs +347 -1
  79. package/src/cli/integration-lane.mjs +62 -0
  80. package/src/cli/integration-lane.test.mjs +213 -0
  81. package/src/cli/ledger.mjs +4 -2
  82. package/src/cli/ledger.test.mjs +12 -3
  83. package/src/cli/legs.mjs +53 -0
  84. package/src/cli/legs.test.mjs +70 -0
  85. package/src/cli/lint-changed.mjs +59 -10
  86. package/src/cli/lint-changed.test.mjs +112 -1
  87. package/src/cli/locked-tests.mjs +134 -0
  88. package/src/cli/locked-tests.test.mjs +188 -0
  89. package/src/cli/merge-guard.mjs +234 -62
  90. package/src/cli/merge-guard.test.mjs +768 -39
  91. package/src/cli/metrics.mjs +53 -0
  92. package/src/cli/metrics.test.mjs +73 -0
  93. package/src/cli/milestone.mjs +297 -0
  94. package/src/cli/milestone.test.mjs +294 -0
  95. package/src/cli/mutate.mjs +203 -0
  96. package/src/cli/mutate.test.mjs +134 -0
  97. package/src/cli/output-redaction.mjs +26 -0
  98. package/src/cli/output-redaction.test.mjs +117 -0
  99. package/src/cli/overview.mjs +131 -0
  100. package/src/cli/overview.test.mjs +137 -0
  101. package/src/cli/pause.mjs +93 -0
  102. package/src/cli/pause.test.mjs +109 -0
  103. package/src/cli/plan-check.mjs +84 -12
  104. package/src/cli/plan-check.test.mjs +152 -2
  105. package/src/cli/plan-stop.mjs +7 -4
  106. package/src/cli/plan-stop.test.mjs +87 -0
  107. package/src/cli/platform-risk.mjs +46 -0
  108. package/src/cli/platform-risk.test.mjs +38 -0
  109. package/src/cli/plugin-skills.test.mjs +25 -0
  110. package/src/cli/pr-guard.mjs +128 -0
  111. package/src/cli/pr-guard.test.mjs +154 -0
  112. package/src/cli/promotion-branch.mjs +2 -0
  113. package/src/cli/qc.mjs +160 -27
  114. package/src/cli/qc.test.mjs +93 -0
  115. package/src/cli/report-stop.mjs +5 -0
  116. package/src/cli/report-stop.test.mjs +23 -1
  117. package/src/cli/retry-failed.mjs +3 -1
  118. package/src/cli/review-gate.mjs +24 -6
  119. package/src/cli/review-gate.test.mjs +116 -0
  120. package/src/cli/review-promotion.mjs +107 -0
  121. package/src/cli/review-promotion.test.mjs +251 -0
  122. package/src/cli/role-budget.mjs +50 -0
  123. package/src/cli/role-budget.test.mjs +91 -0
  124. package/src/cli/run-log.mjs +73 -0
  125. package/src/cli/run-log.test.mjs +121 -0
  126. package/src/cli/secret-patterns.mjs +16 -0
  127. package/src/cli/secret-patterns.test.mjs +73 -0
  128. package/src/cli/setup-block.mjs +24 -0
  129. package/src/cli/setup-block.test.mjs +96 -0
  130. package/src/cli/setup-checks.mjs +65 -0
  131. package/src/cli/setup-checks.test.mjs +158 -0
  132. package/src/cli/setup-compaction.mjs +55 -0
  133. package/src/cli/setup-compaction.test.mjs +115 -0
  134. package/src/cli/setup-skills.mjs +65 -0
  135. package/src/cli/setup-skills.test.mjs +171 -0
  136. package/src/cli/setup.mjs +107 -0
  137. package/src/cli/setup.test.mjs +275 -0
  138. package/src/cli/skill-length.test.mjs +8 -0
  139. package/src/cli/spawn-command.mjs +47 -0
  140. package/src/cli/spawn-command.test.mjs +64 -0
  141. package/src/cli/task-gate-review.test.mjs +21 -2
  142. package/src/cli/task-gate.mjs +25 -12
  143. package/src/cli/task-gate.test.mjs +43 -5
  144. package/src/cli/tokens.mjs +46 -3
  145. package/src/cli/tokens.test.mjs +103 -3
  146. package/src/cli/tools.mjs +49 -0
  147. package/src/cli/tools.test.mjs +89 -0
  148. package/src/cli/transcript-usage.mjs +27 -0
  149. package/src/cli/transcript-usage.test.mjs +34 -0
  150. package/src/cli/user-config-package.mjs +1 -1
  151. package/src/cli/user-config-toml.mjs +63 -7
  152. package/src/cli/user-config.mjs +39 -7
  153. package/src/cli/user-config.test.mjs +238 -5
  154. package/src/cli/watch-arm.mjs +39 -0
  155. package/src/cli/watch-arm.test.mjs +87 -0
  156. package/src/cli/watch.mjs +80 -35
  157. package/src/cli/watch.test.mjs +233 -27
  158. package/src/cli/work-order-guard.mjs +2 -1
  159. package/src/cli/workflow-hooks.test.mjs +18 -4
  160. package/src/cli/workflow-settings.mjs +44 -8
  161. package/src/cli/workflow-settings.test.mjs +124 -1
  162. package/src/cli/worktree.mjs +14 -1
  163. package/src/cli/worktree.test.mjs +20 -1
  164. package/src/config.mjs +174 -7
  165. package/src/config.test.mjs +327 -5
  166. package/src/consumer-package.mjs +31 -0
  167. package/src/consumer-package.test.mjs +54 -0
  168. package/src/descriptions.mjs +2 -0
  169. package/src/eslint/index.mjs +12 -0
  170. package/src/eslint/jsx.mjs +20 -0
  171. package/src/eslint/preset.mjs +26 -2
  172. package/src/eslint/preset.test.mjs +104 -2
  173. package/src/eslint/rules/no-arbitrary-class-value.mjs +32 -0
  174. package/src/eslint/rules/no-literal-color.mjs +94 -0
  175. package/src/eslint/rules/no-static-inline-style.mjs +41 -0
  176. package/src/eslint/rules/one-component-per-file.mjs +70 -0
  177. package/src/eslint/rules/raw-element-in-primitive.mjs +31 -0
  178. package/src/eslint/rules/timeless-comment.mjs +92 -0
  179. package/src/eslint/rules.test.mjs +189 -0
  180. package/src/eslint/ui-regressions.test.mjs +39 -0
  181. package/src/gates/contract-operations.mjs +3 -3
  182. package/src/gates/contract-operations.test.mjs +28 -0
  183. package/src/gates/feature-switches.mjs +19 -0
  184. package/src/gates/feature-switches.test.mjs +55 -0
  185. package/src/gates/plain-language.mjs +396 -0
  186. package/src/gates/plain-language.test.mjs +210 -0
  187. package/src/gates/runtime-imports.test.mjs +114 -0
  188. package/src/gates/saga-key.test.mjs +1 -1
  189. package/src/global-skills.mjs +9 -0
  190. package/src/global-skills.test.mjs +53 -0
  191. package/src/plugin.test.mjs +3 -2
  192. package/src/ui/class-sites.mjs +38 -6
  193. package/src/ui/codemod.mjs +4 -1
  194. package/src/ui/codemod.test.mjs +52 -0
  195. package/src/ui/components.mjs +5 -3
  196. package/src/ui/components.test.mjs +8 -0
  197. package/src/ui/dupes.test.mjs +18 -0
  198. package/templates/docs/enforcement.md +12 -2
  199. package/templates/docs/ui.md +33 -0
  200. package/templates/githooks/pre-commit +1 -0
  201. package/templates/githooks/pre-push +11 -2
  202. package/templates/github/workflows/ci.yml +57 -3
  203. package/user-config/claude/CLAUDE.core.md +28 -0
  204. package/user-config/claude/settings.shared.json +41 -1
  205. package/src/cli/screens-discovery.mjs +0 -60
  206. package/src/cli/screens.mjs +0 -84
  207. package/src/cli/stack.mjs +0 -14
  208. package/src/cli/throwaway-db.mjs +0 -127
  209. package/src/cli/throwaway-db.test.mjs +0 -83
  210. package/src/screens/auth-context.test.mjs +0 -41
  211. package/src/screens/auth-run.test.mjs +0 -147
  212. package/src/screens/auth.mjs +0 -223
  213. package/src/screens/auth.test.mjs +0 -76
  214. package/src/screens/capture-idle.test.mjs +0 -27
  215. package/src/screens/capture.browser-test.mjs +0 -73
  216. package/src/screens/capture.mjs +0 -175
  217. package/src/screens/capture.test.mjs +0 -28
  218. package/src/screens/catalog.browser-test.mjs +0 -32
  219. package/src/screens/catalog.mjs +0 -72
  220. package/src/screens/catalog.test.mjs +0 -36
  221. package/src/screens/chrome.mjs +0 -21
  222. package/src/screens/compare.mjs +0 -40
  223. package/src/screens/compare.test.mjs +0 -30
  224. package/src/screens/discovery.browser-test.mjs +0 -29
  225. package/src/screens/discovery.mjs +0 -158
  226. package/src/screens/discovery.test.mjs +0 -27
  227. package/src/screens/inventory.mjs +0 -69
  228. package/src/screens/inventory.test.mjs +0 -10
  229. package/src/screens/map.mjs +0 -63
  230. package/src/screens/map.test.mjs +0 -35
  231. package/src/screens/open.browser-test.mjs +0 -50
  232. package/src/screens/regions.mjs +0 -137
  233. package/src/screens/regions.test.mjs +0 -38
  234. package/src/screens/session-files.mjs +0 -39
  235. package/src/screens/session-files.test.mjs +0 -39
  236. package/src/screens/setup.browser-test.mjs +0 -49
  237. package/src/screens/setup.mjs +0 -78
  238. package/src/screens/stack-auth.browser-test.mjs +0 -30
  239. package/src/screens/stack-auth.mjs +0 -106
  240. package/src/screens/stack-auth.test.mjs +0 -65
  241. package/src/screens/write-guard.mjs +0 -26
  242. package/src/stack/stack.mjs +0 -131
  243. package/src/stack/stack.test.mjs +0 -40
  244. package/src/stack/supervisor.mjs +0 -30
@@ -2,10 +2,12 @@
2
2
  // The PreToolUse trigger that keeps the main session a controller while `swarm.dispatch` is on: it edits only `swarm.review.controllerPaths`,
3
3
  // or a small fix inside `swarm.direct`. It guards the edit tools; a shell write is only reported, by `bash-edit-guard.mjs`.
4
4
 
5
+ import { lstatSync, realpathSync } from "node:fs";
5
6
  import path from "node:path";
6
7
  import { fileURLToPath } from "node:url";
7
8
  import { pathMatcher } from "../glob.mjs";
8
9
  import { checkoutRootOf } from "./checkout-root.mjs";
10
+ import { checkpointPathOf } from "./checkpoint.mjs";
9
11
  import { editLane, sizeLine } from "./direct-lane.mjs";
10
12
  import { pathKey } from "./git-read.mjs";
11
13
  import { commonDirOf } from "./ledger.mjs";
@@ -21,6 +23,29 @@ function sameRepository(a, b) {
21
23
  return left !== null && right !== null && pathKey(left) === pathKey(right);
22
24
  }
23
25
 
26
+ /** The path as written, with no case on Windows. */
27
+ const lexicalKey = (file, platform) => (platform === "win32" ? path.resolve(file).toLowerCase() : path.resolve(file));
28
+
29
+ /** The fragment that resolves existing folders and preserves missing path parts for the first checkpoint write. */
30
+ function realFolder(folder) {
31
+ try {
32
+ return realpathSync.native(folder);
33
+ } catch (error) {
34
+ if (error.code !== "ENOENT" || isSymlink(folder)) throw error;
35
+ return path.join(realFolder(path.dirname(folder)), path.basename(folder));
36
+ }
37
+ }
38
+
39
+ /** True when `file` is a symlink. A file that does not exist yet is not one. */
40
+ function isSymlink(file) {
41
+ try {
42
+ return lstatSync(file).isSymbolicLink();
43
+ } catch (error) {
44
+ if (error.code === "ENOENT") return false;
45
+ throw error;
46
+ }
47
+ }
48
+
24
49
  /** True when `rel` matches a controller glob, with no case on Windows. */
25
50
  export const isControllerPath = (rel, controllerPaths, platform = process.platform) => pathMatcher(controllerPaths, platform)(rel);
26
51
 
@@ -40,6 +65,19 @@ export function decide(call, platform = process.platform) {
40
65
  }
41
66
  if (!workflow) return null;
42
67
  const file = path.resolve(cwd, target);
68
+ try {
69
+ const checkpoint = checkpointPathOf(cwd, call.session_id);
70
+ if (checkpoint && lexicalKey(path.basename(file), platform) === lexicalKey(path.basename(checkpoint), platform)) {
71
+ const folder = path.dirname(checkpoint);
72
+ const git = path.dirname(path.dirname(folder));
73
+ const expected = lexicalKey(path.join(realFolder(git), "qc", "checkpoints"), platform);
74
+ if (lexicalKey(realFolder(folder), platform) === expected
75
+ && lexicalKey(realFolder(path.dirname(file)), platform) === expected
76
+ && !isSymlink(file)) return null;
77
+ }
78
+ } catch {
79
+ // An unresolved checkpoint grants no edit exception.
80
+ }
43
81
  const fileRoot = checkoutRootOf(path.dirname(file));
44
82
  if (!fileRoot || !sameRepository(fileRoot, workflow.root)) return null;
45
83
  const rel = path.relative(fileRoot, file).replaceAll("\\", "/");
@@ -1,11 +1,75 @@
1
1
  import { strict as assert } from "node:assert";
2
2
  import { execFileSync, spawnSync } from "node:child_process";
3
- import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
3
+ import { mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { test } from "node:test";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { decide, isControllerPath } from "./controller-guard.mjs";
9
+ import { checkpointPathOf } from "./checkpoint.mjs";
10
+
11
+ test("the session can write and edit its own checkpoint under Git", (t) => {
12
+ const ws = workspace(t);
13
+ for (const cwd of [ws.main, ws.linked]) {
14
+ const file = checkpointPathOf(cwd, "s");
15
+ for (const tool of ["Write", "Edit"]) assert.equal(decide(edit(cwd, file, tool)), null);
16
+ }
17
+ });
18
+
19
+ test("sibling checkpoints and other Git paths stay refused", (t) => {
20
+ const ws = workspace(t);
21
+ for (const cwd of [ws.main, ws.linked]) {
22
+ const file = checkpointPathOf(cwd, "s");
23
+ assert.ok(denied(decide(edit(cwd, path.join(path.dirname(file), "other.md")))));
24
+ assert.ok(denied(decide(edit(cwd, path.join(ws.main, ".git", "config")))));
25
+ }
26
+ });
27
+
28
+ test("a checkpoint that is a symlink grants no edit exception for it or its target", (t) => {
29
+ const ws = workspace(t);
30
+ const file = checkpointPathOf(ws.main, "s");
31
+ const target = path.join(ws.main, "app.js");
32
+ writeFileSync(target, "x\n");
33
+ mkdirSync(path.dirname(file), { recursive: true });
34
+ try {
35
+ symlinkSync(target, file);
36
+ } catch (error) {
37
+ t.skip(`this platform cannot create a symlink (${error.code})`);
38
+ return;
39
+ }
40
+ assert.ok(denied(decide(edit(ws.main, file))));
41
+ assert.ok(denied(decide(edit(ws.main, target, "Write"))));
42
+ });
43
+
44
+ test("a linked checkpoint folder does not let the session edit the folder it points to", (t) => {
45
+ const ws = workspace(t);
46
+ const file = checkpointPathOf(ws.main, "s");
47
+ const src = path.join(ws.main, "src");
48
+ mkdirSync(src);
49
+ mkdirSync(path.dirname(path.dirname(file)), { recursive: true });
50
+ try {
51
+ symlinkSync(src, path.dirname(file), "junction");
52
+ } catch (error) {
53
+ t.skip(`this platform cannot link a folder (${error.code})`);
54
+ return;
55
+ }
56
+ assert.ok(denied(decide(edit(ws.main, path.join(src, "s.md"), "Write"))));
57
+ assert.ok(denied(decide(edit(ws.main, file, "Write"))));
58
+ });
59
+
60
+ test("checkpoint paths through a checkout junction compare equal", (t) => {
61
+ const ws = workspace(t);
62
+ const alias = path.join(path.dirname(ws.main), "alias");
63
+ symlinkSync(ws.main, alias, "junction");
64
+ for (const exists of [false, true]) {
65
+ if (exists) mkdirSync(path.dirname(checkpointPathOf(ws.main, "s")), { recursive: true });
66
+ for (const cwd of [ws.main, alias, ws.linked]) {
67
+ for (const from of [ws.main, alias, ws.linked]) {
68
+ assert.equal(decide(edit(cwd, checkpointPathOf(from, "s"), "Write")), null);
69
+ }
70
+ }
71
+ }
72
+ });
9
73
 
10
74
  const HOOK = fileURLToPath(new URL("./controller-guard.mjs", import.meta.url));
11
75
  const git = (cwd, ...args) => execFileSync("git", args, { cwd, stdio: "pipe", encoding: "utf8" }).trim();
@@ -174,7 +238,7 @@ test("the lane reads its limits from the base, and names a base that holds no co
174
238
  const bare = laneWorkspace(t, null);
175
239
  writeFileSync(path.join(bare.main, "qc.config.json"), JSON.stringify({ swarm: { dispatch: {} } }));
176
240
  const closed = decide(edit(bare.main, path.join(bare.linked, "src", "a.ts"), "Edit", { tool_input: { file_path: path.join(bare.linked, "src", "a.ts"), ...small } }));
177
- assert.match(denied(closed) ?? "", /does not apply: git cannot read qc\.config\.json at origin\/main/);
241
+ assert.match(denied(closed) ?? "", /does not apply: qc\.config\.json is absent at origin\/main/);
178
242
  });
179
243
 
180
244
  test("a pending edit of qc.config.json leaves the lane when the controller does not own the file", (t) => {
@@ -4,10 +4,11 @@
4
4
 
5
5
  import os from "node:os";
6
6
  import { checkoutRootOf } from "./checkout-root.mjs";
7
+ import { estimateOf } from "./context-signal.mjs";
7
8
  import { pathKey } from "./git-read.mjs";
8
9
  import { appendRecord, readLedger } from "./ledger.mjs";
9
10
  import { roleOf } from "./report-stop.mjs";
10
- import { agentTranscriptOf, agentTypeOf, readRequests, toolCallsIn } from "./transcript-usage.mjs";
11
+ import { agentTranscriptOf, agentTypeOf, contextOf, readRequests, toolCallsIn } from "./transcript-usage.mjs";
11
12
  import { firstUserText, resolveNamedWorktree, workflowOfRepo } from "./workflow-place.mjs";
12
13
  import { workflowOf } from "./workflow-settings.mjs";
13
14
  import { fileURLToPath } from "node:url";
@@ -74,7 +75,10 @@ function record(call, tmp) {
74
75
  output: sum(requests, "output_tokens"),
75
76
  cacheRead: sum(requests, "cache_read_input_tokens"),
76
77
  cacheCreation: sum(requests, "cache_creation_input_tokens"),
78
+ endContext: contextOf(requests.at(-1).usage),
79
+ peakContext: Math.max(...requests.map((request) => contextOf(request.usage))),
77
80
  toolCalls: toolCallsIn(transcript),
81
+ estimate: estimateOf(text),
78
82
  branch: dispatch?.branch ?? null,
79
83
  head: dispatch?.head ?? null,
80
84
  });
@@ -69,6 +69,29 @@ const stop = (ws, file, agentType, extra = {}) => ({
69
69
 
70
70
  const costs = (ws) => readLedger(ws.ledger).filter((record) => record.type === "cost");
71
71
 
72
+ test("the cost record carries endContext and peakContext", (t) => {
73
+ const ws = workspace(t);
74
+ const file = path.join(ws.base, "context.jsonl");
75
+ writeFileSync(file, [
76
+ prompt("No worktree named."),
77
+ ...[10_000, 90_000, 60_000].map((context, index) =>
78
+ assistant(`m${index}`, "claude-sonnet-5-5", usage(context - 3000, 500, 2000, 1000))),
79
+ ].join("\n") + "\n");
80
+ decide(stop(ws, file, "sdd-implementer"), ws.tmp);
81
+ const [record] = costs(ws);
82
+ assert.equal(record.endContext, 60_000);
83
+ assert.equal(record.peakContext, 90_000);
84
+ });
85
+
86
+ test("cost records carry the task Estimate value, or null when absent", (t) => {
87
+ const ws = workspace(t);
88
+ for (const [index, text, estimate] of [[0, "Estimate: 25 tool calls", 25], [1, "**Estimate:** 30 tool calls", 30], [2, "No estimate.", null]]) {
89
+ const file = transcript(ws, `estimate-${index}`, text);
90
+ assert.equal(decide(stop(ws, file, "sdd-implementer", { agent_id: `estimate-${index}` }), ws.tmp), null);
91
+ assert.equal(costs(ws).at(-1).estimate, estimate);
92
+ }
93
+ });
94
+
72
95
  test("a subagent stop records its tokens once per request, its tool calls, and the branch and head of its dispatch", (t) => {
73
96
  const ws = workspace(t);
74
97
  appendRecord(ws.ledger, { type: "dispatch", session: "s", agentType: "sdd-implementer", task: true, worktree: ws.repo, branch: "feat/1-x", head: ws.head });
@@ -89,7 +112,10 @@ test("a subagent stop records its tokens once per request, its tool calls, and t
89
112
  output: 150,
90
113
  cacheRead: 4000,
91
114
  cacheCreation: 200,
115
+ endContext: 3005,
116
+ peakContext: 3005,
92
117
  toolCalls: 4,
118
+ estimate: null,
93
119
  branch: "feat/1-x",
94
120
  head: ws.head,
95
121
  },
@@ -0,0 +1,162 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { lstatSync, readFileSync } from "node:fs";
3
+ import path from "node:path";
4
+
5
+ const normalize = (file) => file.replace(/\\/g, "/").replace(/^\.\//, "");
6
+ const splitNames = (text) => text.split("\0").filter(Boolean);
7
+
8
+ /** Fragment: matches owned files, folder boundaries and the brief's globs. */
9
+ function ownership(paths) {
10
+ const patterns = paths.map(normalize).flatMap((file) => {
11
+ const name = file.replace(/\/$/, "");
12
+ return file.includes("*") ? [file] : [name, `${name}/**`];
13
+ }).map((glob) => {
14
+ // Each recursive directory segment can independently consume zero or more folders.
15
+ const body = glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&")
16
+ .replace(/\*\*\/|\*\*|\*/g, (token) => token === "**/" ? "(?:[^/]+/)*" : token === "**" ? ".*" : "[^/]*");
17
+ return new RegExp(`^${body}$`, process.platform === "win32" ? "i" : "");
18
+ });
19
+ return (file) => patterns.some((pattern) => pattern.test(file));
20
+ }
21
+
22
+ /** Fragment: parses NUL-delimited numstat without Git's quoted-path ambiguity. */
23
+ function changedLines(text, totals) {
24
+ for (const entry of splitNames(text)) {
25
+ const match = /^(\d+|-)\t(\d+|-)\t([\s\S]+)$/.exec(entry);
26
+ if (!match) continue;
27
+ const count = (Number(match[1]) || 0) + (Number(match[2]) || 0);
28
+ totals.set(match[3], Math.max(totals.get(match[3]) ?? 0, count));
29
+ }
30
+ }
31
+
32
+ /** Fragment: manifest failures identify the file, without printing its contents. */
33
+ function manifest(text, file) {
34
+ try {
35
+ const value = JSON.parse(text);
36
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error();
37
+ for (const key of ["dependencies", "devDependencies"]) {
38
+ if (value[key] !== undefined && (!value[key] || typeof value[key] !== "object" || Array.isArray(value[key]))) throw new Error();
39
+ }
40
+ return value;
41
+ } catch {
42
+ throw new Error(`${file}: invalid package manifest JSON`);
43
+ }
44
+ }
45
+
46
+ /** Branch: new dependency keys (including aliases) need their exact names in Design. */
47
+ function dependencyProblems(file, originalOf, versions, design) {
48
+ const problems = new Set();
49
+ const approved = new Set((design.match(/[@\w][@\w./-]*/g) ?? []).flatMap((name) => [name, name.replace(/\.+$/, "")]));
50
+ for (const { text, tip } of versions) {
51
+ const original = originalOf(tip);
52
+ const current = manifest(text, file);
53
+ for (const section of ["dependencies", "devDependencies"]) {
54
+ for (const name of Object.keys(current[section] ?? {})) {
55
+ if (!Object.hasOwn(original[section] ?? {}, name) && !approved.has(name)) problems.add(`${file}: added ${section} ${name} is absent from Design`);
56
+ }
57
+ }
58
+ }
59
+ return [...problems];
60
+ }
61
+
62
+ /** Branch: checks every changed path, manifest addition and added/deleted line against a frozen brief. */
63
+ export function checkDiffShape({ worktree, base, baseRef, paths, design = "", maxDiffLines = 400 }) {
64
+ const git = (...args) => execFileSync("git", ["--literal-pathspecs", ...args], { cwd: worktree, encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], maxBuffer: 64 * 1024 * 1024 });
65
+ const empty = git("hash-object", "-w", "-t", "tree", "--stdin").trim();
66
+ const contains = (ancestor, revision) => {
67
+ try { git("merge-base", "--is-ancestor", ancestor, revision); return true; }
68
+ catch (error) { if (error.status === 1) return false; throw error; }
69
+ };
70
+ const hasHead = git("rev-parse", "--revs-only", "HEAD").trim();
71
+ const boundaries = new Map();
72
+ const boundaryOf = (revision) => {
73
+ let tip;
74
+ if (base && baseRef && revision) {
75
+ try { tip = git("merge-base", revision, baseRef).trim(); } catch { /* Missing or invalid base refs keep the frozen boundary. */ }
76
+ }
77
+ if (!tip) return { boundary: base || empty };
78
+ if (boundaries.has(tip)) return boundaries.get(tip);
79
+ let result = { boundary: base };
80
+ if (!contains(tip, base)) {
81
+ let merged;
82
+ try { merged = git("merge-tree", "--write-tree", base, tip); }
83
+ catch (error) { if (error.status !== 1) throw error; merged = error.stdout; }
84
+ result = { boundary: merged.split("\n")[0].trim(), tip };
85
+ }
86
+ boundaries.set(tip, result);
87
+ return result;
88
+ };
89
+ const { boundary, tip } = boundaryOf(hasHead ? "HEAD" : undefined);
90
+ // Incoming commits belong to the base; retain the run's commits on either side of the merge.
91
+ const commits = hasHead ? git("rev-list", "--reverse", ...(base ? [`${base}..HEAD`] : ["HEAD"]), ...(tip ? [`^${tip}`] : [])).trim().split("\n").filter(Boolean) : [];
92
+ const changed = new Set();
93
+ const totals = new Map();
94
+ const versions = new Map();
95
+ const collect = (args, revision, versionTip) => {
96
+ const files = splitNames(git("diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--name-only", "-z", ...args, "--"));
97
+ changedLines(git("diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--numstat", "-z", ...args, "--"), totals);
98
+ for (const file of files) {
99
+ changed.add(file);
100
+ if (path.posix.basename(file) !== "package.json" || revision === undefined) continue;
101
+ const exists = splitNames(git("ls-tree", "-r", "--name-only", "-z", revision, "--", file)).includes(file);
102
+ if (exists) {
103
+ const list = versions.get(file) ?? [];
104
+ list.push({ text: git("show", `${revision}:${file}`), tip: versionTip }); versions.set(file, list);
105
+ }
106
+ }
107
+ };
108
+ for (const commit of commits) {
109
+ const commitBoundary = tip ? boundaryOf(commit) : { boundary };
110
+ collect([commitBoundary.boundary, commit], commit, commitBoundary.tip);
111
+ }
112
+ collect(["--cached", boundary]);
113
+ collect([boundary]);
114
+ const staged = splitNames(git("diff", "--cached", "--no-renames", "--name-only", "-z", boundary, "--"));
115
+ for (const file of staged.filter((name) => path.posix.basename(name) === "package.json")) {
116
+ const entries = splitNames(git("ls-files", "-z", "--", file));
117
+ if (entries.includes(file)) {
118
+ const list = versions.get(file) ?? []; list.push({ text: git("show", `:${file}`), tip }); versions.set(file, list);
119
+ }
120
+ }
121
+ const untracked = splitNames(git("ls-files", "--others", "--exclude-standard", "-z"));
122
+ for (const file of untracked) {
123
+ changed.add(file);
124
+ const target = path.join(worktree, file);
125
+ const stat = lstatSync(target);
126
+ const text = stat.isSymbolicLink() ? "link\n" : readFileSync(target, "utf8");
127
+ const lines = text.includes("\0") ? 0 : text.split("\n").length - (text.endsWith("\n") ? 1 : 0);
128
+ totals.set(file, (totals.get(file) ?? 0) + lines);
129
+ }
130
+ const owns = ownership(Array.isArray(paths) ? paths : [paths]);
131
+ const problems = [...changed].filter((file) => !owns(normalize(file))).map((file) => `${file}: outside Paths`);
132
+ for (const file of [...changed].filter((name) => path.posix.basename(name) === "package.json")) {
133
+ try {
134
+ const originals = new Map();
135
+ const originalOf = (versionTip) => {
136
+ if (originals.has(versionTip)) return originals.get(versionTip);
137
+ const original = {};
138
+ // A merge tree can contain conflict markers; read dependency keys from its parents instead.
139
+ for (const revision of [base || empty, ...(versionTip ? [versionTip] : [])]) {
140
+ const exists = splitNames(git("ls-tree", "-r", "--name-only", "-z", revision, "--", file)).includes(file);
141
+ if (!exists) continue;
142
+ const value = manifest(git("show", `${revision}:${file}`), file);
143
+ for (const section of ["dependencies", "devDependencies"]) {
144
+ original[section] = { ...original[section], ...value[section] };
145
+ }
146
+ }
147
+ originals.set(versionTip, original);
148
+ return original;
149
+ };
150
+ const list = versions.get(file) ?? [];
151
+ try {
152
+ const target = path.join(worktree, file);
153
+ if (lstatSync(target).isSymbolicLink()) throw new Error(`${file}: package manifest must be a regular file`);
154
+ list.push({ text: readFileSync(target, "utf8"), tip });
155
+ } catch (error) { if (error.code !== "ENOENT") throw error; }
156
+ problems.push(...dependencyProblems(file, originalOf, list, design));
157
+ } catch (error) { problems.push(error.message); }
158
+ }
159
+ const lines = [...totals.values()].reduce((sum, count) => sum + count, 0);
160
+ if (lines > maxDiffLines) problems.push(`${lines} changed lines exceeds codex.maxDiffLines ${maxDiffLines}; split the issue`);
161
+ return { problems: [...new Set(problems)] };
162
+ }
@@ -0,0 +1,200 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync } from "node:child_process";
3
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { test } from "node:test";
7
+ import { checkDiffShape } from "./diff-shape.mjs";
8
+
9
+ function fixture(t) {
10
+ const worktree = mkdtempSync(path.join(os.tmpdir(), "qc-diff-shape-"));
11
+ t.after(() => rmSync(worktree, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }));
12
+ const git = (...args) => execFileSync("git", ["-c", "user.name=Shape Test", "-c", "user.email=shape@example.test", ...args], { cwd: worktree, encoding: "utf8" }).trim();
13
+ git("init", "-q");
14
+ const write = (name, text) => { mkdirSync(path.dirname(path.join(worktree, name)), { recursive: true }); writeFileSync(path.join(worktree, name), text); };
15
+ const commit = () => { git("add", "."); git("commit", "-qm", "fixture"); return git("rev-parse", "HEAD"); };
16
+ return { worktree, git, write, commit, check: (base, paths, extra = {}) => checkDiffShape({ worktree, base, paths, design: "", maxDiffLines: 400, ...extra }).problems };
17
+ }
18
+
19
+ test("diff shape: file outside Paths → one problem naming the file", (t) => {
20
+ const f = fixture(t); f.write("owned/a.mjs", "before\n"); const base = f.commit();
21
+ f.write("outside.mjs", "after\n");
22
+ const problems = f.check(base, ["owned/**"]);
23
+ assert.equal(problems.length, 1); assert.match(problems[0], /outside\.mjs/);
24
+ });
25
+
26
+ test('diff shape: 401 changed lines → one problem with "split the issue"', (t) => {
27
+ const f = fixture(t); f.write("a.mjs", "before\n"); const base = f.commit();
28
+ f.write("a.mjs", "after\n".repeat(400));
29
+ const problems = f.check(base, ["a.mjs"]);
30
+ assert.equal(problems.length, 1); assert.match(problems[0], /split the issue/);
31
+ {
32
+ const f = fixture(t); f.write("a.mjs", "new\n".repeat(400));
33
+ assert.deepEqual(f.check(null, ["a.mjs"]), []);
34
+ assert.match(f.check(null, ["a.mjs"], { maxDiffLines: 399 })[0], /split the issue/);
35
+ }
36
+ {
37
+ const f = fixture(t); f.write("a.mjs", "old\n".repeat(400)); const base = f.commit();
38
+ f.git("rm", "a.mjs"); f.write("a.mjs", "new\n");
39
+ const problems = f.check(base, ["a.mjs"]);
40
+ assert.equal(problems.length, 1); assert.match(problems[0], /401.*split the issue/);
41
+ }
42
+ });
43
+
44
+ function baseMergeFixture(t) {
45
+ const f = fixture(t);
46
+ f.write("package.json", "{}\n"); f.write("owned/a.mjs", "before\n"); const initial = f.commit();
47
+ f.git("checkout", "-qb", "run");
48
+ f.write("existing.mjs", "already on the run branch\n"); const base = f.commit();
49
+ f.git("checkout", "-qb", "incoming", initial);
50
+ f.write("base.mjs", "from base\n".repeat(500)); f.commit();
51
+ f.write("package.json", '{"devDependencies":{"base-tool":"1"}}\n'); f.commit();
52
+ f.git("checkout", "-q", "run");
53
+ return { ...f, base, baseRef: "incoming" };
54
+ }
55
+
56
+ test("base merge adds 500 lines and a devDependency; three own lines stay within the shape", (t) => {
57
+ for (const state of ["committed", "staged", "working"]) {
58
+ const f = baseMergeFixture(t);
59
+ f.write("owned/before.mjs", "own before merge\n"); f.commit();
60
+ f.git("merge", "--no-edit", "incoming");
61
+ f.write("package.json", '{"name":"own-change","devDependencies":{"base-tool":"1"}}\n');
62
+ if (state === "committed") f.commit();
63
+ else {
64
+ f.git("add", ".");
65
+ if (state === "working") f.git("reset", "--quiet");
66
+ }
67
+ const paths = ["owned/**", "package.json"];
68
+ assert.deepEqual(f.check(f.base, paths, { baseRef: f.baseRef }), [], state);
69
+ assert.ok(f.check(f.base, paths).some((problem) => /split the issue/.test(problem)));
70
+ assert.deepEqual(f.check(f.base, paths, { baseRef: "missing-ref" }), f.check(f.base, paths));
71
+ }
72
+ });
73
+
74
+ test("conflicted manifest keeps dependencies from both the frozen base and incoming base", (t) => {
75
+ const f = fixture(t);
76
+ f.write("package.json", "{}\n"); const initial = f.commit();
77
+ f.git("checkout", "-qb", "run");
78
+ f.write("package.json", '{"devDependencies":{"existing-tool":"1"}}\n'); const base = f.commit();
79
+ f.git("checkout", "-qb", "incoming", initial);
80
+ f.write("package.json", '{"devDependencies":{"base-tool":"1"}}\n'); f.commit();
81
+ f.git("checkout", "-q", "run");
82
+ assert.throws(() => f.git("merge", "--no-edit", "incoming"));
83
+ f.write("package.json", '{"devDependencies":{"existing-tool":"1","base-tool":"1"}}\n'); f.commit();
84
+ assert.deepEqual(f.check(base, ["package.json"], { baseRef: "incoming" }), []);
85
+ });
86
+
87
+ test("two base merges use separate boundaries and count only two owned lines", (t) => {
88
+ for (const state of ["committed", "staged", "working"]) {
89
+ const f = baseMergeFixture(t);
90
+ f.git("merge", "--no-edit", "incoming");
91
+ f.git("checkout", "-q", "incoming");
92
+ f.write("next-base.mjs", "more from base\n".repeat(500)); f.commit();
93
+ f.git("checkout", "-q", "run");
94
+ f.git("merge", "--no-edit", "incoming");
95
+ f.write("owned/after.mjs", "own first line\nown second line\n");
96
+ if (state === "committed") f.commit();
97
+ else if (state === "staged") f.git("add", ".");
98
+ assert.deepEqual(f.check(f.base, ["owned/**"], { baseRef: f.baseRef, maxDiffLines: 2 }), [], state);
99
+ }
100
+ });
101
+
102
+ function removedBaseDependencyFixture(t, ownDependencies = {}) {
103
+ const f = baseMergeFixture(t);
104
+ f.git("merge", "--no-edit", "incoming");
105
+ f.write("package.json", JSON.stringify({ name: "own-change", devDependencies: { "base-tool": "1", ...ownDependencies } }));
106
+ f.commit();
107
+ f.git("checkout", "-q", "incoming");
108
+ f.write("package.json", "{}\n"); f.commit();
109
+ f.git("checkout", "-q", "run");
110
+ assert.throws(() => f.git("merge", "--no-edit", "incoming"));
111
+ f.write("package.json", JSON.stringify({ name: "own-change", devDependencies: ownDependencies }));
112
+ f.commit();
113
+ return f;
114
+ }
115
+
116
+ test("upstream devDependency added and removed across two merges uses each manifest's baseline", (t) => {
117
+ const f = removedBaseDependencyFixture(t);
118
+ assert.deepEqual(f.check(f.base, ["package.json"], { baseRef: f.baseRef }), []);
119
+ });
120
+
121
+ test("upstream devDependency removed after two merges still rejects an own devDependency", (t) => {
122
+ const f = removedBaseDependencyFixture(t, { "own-tool": "1" });
123
+ assert.deepEqual(f.check(f.base, ["package.json"], { baseRef: f.baseRef }), [
124
+ "package.json: added devDependencies own-tool is absent from Design",
125
+ ]);
126
+ });
127
+
128
+ test("base merge still refuses 401 own lines in Paths", (t) => {
129
+ for (const state of ["committed", "staged", "working"]) {
130
+ const f = baseMergeFixture(t);
131
+ f.git("merge", "--no-edit", "incoming");
132
+ f.write("owned/after.mjs", "own line\n".repeat(401));
133
+ if (state === "committed") f.commit();
134
+ else {
135
+ f.git("add", ".");
136
+ if (state === "working") f.git("reset", "--quiet");
137
+ }
138
+ assert.deepEqual(f.check(f.base, ["owned/**"], { baseRef: f.baseRef }), [
139
+ "401 changed lines exceeds codex.maxDiffLines 400; split the issue",
140
+ ], state);
141
+ }
142
+ });
143
+
144
+ test("diff shape: Windows backslash path inside Paths → no problem", (t) => {
145
+ const f = fixture(t); f.write("src/a.mjs", "before\n"); const base = f.commit(); f.write("src/a.mjs", "after\n");
146
+ assert.deepEqual(f.check(base, ["src\\a.mjs"]), []);
147
+ f.git("checkout", "--", "src/a.mjs");
148
+ for (const name of ["src/fixtures/unit/a.mjs", "src/nested/fixtures/a.mjs", "src/fixtures/a.mjs", "src/nested/fixtures/unit/a.mjs"]) {
149
+ f.write(name, "new\n");
150
+ }
151
+ assert.deepEqual(f.check(base, ["src/**/fixtures/**/*.mjs"]), []);
152
+ {
153
+ const f = fixture(t); f.write("src/nested/test.mjs", "ok\n");
154
+ assert.deepEqual(f.check(null, ["src/"]), []);
155
+ assert.deepEqual(f.check(null, ["src/**/*.mjs"]), []);
156
+ assert.equal(f.check(null, ["sr"]).length, 1);
157
+ }
158
+ });
159
+
160
+ test("scope covers committed, index, tracked and untracked files including an unborn HEAD", (t) => {
161
+ const f = fixture(t); f.write("new.mjs", "new\n");
162
+ assert.deepEqual(f.check(null, ["new.mjs"]), []);
163
+ assert.equal(f.check(null, ["other.mjs"]).length, 1);
164
+ const base = f.commit(); f.write("committed.mjs", "commit\n"); f.commit();
165
+ f.write("staged.mjs", "stage\n"); f.git("add", "."); f.write("new.mjs", "edit\n"); f.write("untracked.mjs", "new\n");
166
+ const problems = f.check(base, ["none/**"]);
167
+ for (const name of ["committed", "staged", "new", "untracked"]) assert.ok(problems.some((p) => p.includes(`${name}.mjs`)));
168
+ {
169
+ const oldPath = process.platform === "win32" ? "outside space/old quote.mjs" : 'outside space/old "quote".mjs';
170
+ const f = fixture(t); f.write(oldPath, "same\n"); const base = f.commit();
171
+ mkdirSync(path.join(f.worktree, "owned")); f.git("mv", oldPath, "owned/new.mjs");
172
+ assert.ok(f.check(base, ["owned/**"]).some((p) => p.includes(oldPath)));
173
+ f.git("rm", "-f", "owned/new.mjs");
174
+ assert.ok(f.check(base, ["owned/**"]).some((p) => p.includes(oldPath)));
175
+ }
176
+ {
177
+ const f = fixture(t); f.write("owned.mjs", "ok\n"); const base = f.commit();
178
+ f.write("outside.mjs", "new\n"); f.commit(); f.git("rm", "outside.mjs"); f.commit();
179
+ assert.ok(f.check(base, ["owned.mjs"]).some((p) => p.includes("outside.mjs")));
180
+ }
181
+ });
182
+
183
+ test("dependency additions require exact Design names, including aliases and devDependencies", (t) => {
184
+ const prose = fixture(t); prose.write("package.json", "{}\n"); const proseBase = prose.commit();
185
+ prose.write("package.json", JSON.stringify({ dependencies: { "new-library": "1" } }));
186
+ assert.deepEqual(prose.check(proseBase, ["package.json"], { design: "Add new-library." }), []);
187
+ const f = fixture(t);
188
+ f.write("package.json", JSON.stringify({ dependencies: { existing: "1" } })); const base = f.commit();
189
+ f.write("package.json", JSON.stringify({ dependencies: { existing: "2", added: "npm:actual@1" }, devDependencies: { tool: "1" } }));
190
+ assert.equal(f.check(base, ["package.json"]).length, 2);
191
+ assert.equal(f.check(base, ["package.json"], { design: "Use added-extra and toolbox" }).length, 2);
192
+ assert.deepEqual(f.check(base, ["package.json"], { design: "Dependencies: `added` (npm:actual@1), tool" }), []);
193
+ {
194
+ const f = fixture(t); f.write("package.json", "{}\n"); const base = f.commit();
195
+ f.write("package.json", '{"devDependencies":{"tool":"1"}}'); f.git("add", "."); f.write("package.json", "{}\n");
196
+ assert.ok(f.check(base, ["package.json"]).some((p) => p.includes("tool")));
197
+ f.write("package.json", "{bad");
198
+ assert.ok(f.check(base, ["package.json"]).some((p) => /JSON|manifest/i.test(p)));
199
+ }
200
+ });