audit-tools 0.41.0 → 0.42.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 (209) hide show
  1. package/dist/audit/cli/args.d.ts +0 -1
  2. package/dist/audit/cli/args.d.ts.map +1 -1
  3. package/dist/audit/cli/args.js +0 -7
  4. package/dist/audit/cli/args.js.map +1 -1
  5. package/dist/audit/cli/auditStep.d.ts +18 -0
  6. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  7. package/dist/audit/cli/auditStep.js +35 -1
  8. package/dist/audit/cli/auditStep.js.map +1 -1
  9. package/dist/audit/cli/cleanup.d.ts +1 -0
  10. package/dist/audit/cli/cleanup.d.ts.map +1 -1
  11. package/dist/audit/cli/cleanup.js +22 -7
  12. package/dist/audit/cli/cleanup.js.map +1 -1
  13. package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
  14. package/dist/audit/cli/confirmIntentStep.js +11 -0
  15. package/dist/audit/cli/confirmIntentStep.js.map +1 -1
  16. package/dist/audit/cli/dispatch/hostHandoff.d.ts.map +1 -1
  17. package/dist/audit/cli/dispatch/hostHandoff.js +110 -29
  18. package/dist/audit/cli/dispatch/hostHandoff.js.map +1 -1
  19. package/dist/audit/cli/envelope.d.ts +0 -24
  20. package/dist/audit/cli/envelope.d.ts.map +1 -1
  21. package/dist/audit/cli/envelope.js +0 -18
  22. package/dist/audit/cli/envelope.js.map +1 -1
  23. package/dist/audit/cli/fanoutLanes.d.ts +24 -0
  24. package/dist/audit/cli/fanoutLanes.d.ts.map +1 -1
  25. package/dist/audit/cli/fanoutLanes.js +46 -2
  26. package/dist/audit/cli/fanoutLanes.js.map +1 -1
  27. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  28. package/dist/audit/cli/nextStepCommand.js +19 -24
  29. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  30. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  31. package/dist/audit/cli/nextStepHelpers.js +20 -6
  32. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  33. package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
  34. package/dist/audit/cli/semanticReviewStep.js +5 -1
  35. package/dist/audit/cli/semanticReviewStep.js.map +1 -1
  36. package/dist/audit/cli/workerResult.d.ts +0 -13
  37. package/dist/audit/cli/workerResult.d.ts.map +1 -1
  38. package/dist/audit/cli/workerResult.js +0 -15
  39. package/dist/audit/cli/workerResult.js.map +1 -1
  40. package/dist/audit/contracts/workerSchemas.d.ts +13 -83
  41. package/dist/audit/contracts/workerSchemas.d.ts.map +1 -1
  42. package/dist/audit/contracts/workerSchemas.js +10 -4
  43. package/dist/audit/contracts/workerSchemas.js.map +1 -1
  44. package/dist/audit/orchestrator/advance.d.ts +30 -0
  45. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  46. package/dist/audit/orchestrator/advance.js +45 -2
  47. package/dist/audit/orchestrator/advance.js.map +1 -1
  48. package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
  49. package/dist/audit/orchestrator/designReviewPrompt.js +6 -4
  50. package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
  51. package/dist/audit/orchestrator/ingestionExecutors.d.ts.map +1 -1
  52. package/dist/audit/orchestrator/ingestionExecutors.js +13 -16
  53. package/dist/audit/orchestrator/ingestionExecutors.js.map +1 -1
  54. package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts +8 -0
  55. package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts.map +1 -1
  56. package/dist/audit/orchestrator/intentCheckpointExecutor.js +2 -0
  57. package/dist/audit/orchestrator/intentCheckpointExecutor.js.map +1 -1
  58. package/dist/audit/orchestrator/lensSelection.d.ts +19 -0
  59. package/dist/audit/orchestrator/lensSelection.d.ts.map +1 -1
  60. package/dist/audit/orchestrator/lensSelection.js +24 -0
  61. package/dist/audit/orchestrator/lensSelection.js.map +1 -1
  62. package/dist/audit/orchestrator/planningExecutors.d.ts +1 -12
  63. package/dist/audit/orchestrator/planningExecutors.d.ts.map +1 -1
  64. package/dist/audit/orchestrator/planningExecutors.js +14 -64
  65. package/dist/audit/orchestrator/planningExecutors.js.map +1 -1
  66. package/dist/audit/orchestrator/requeueFold.d.ts +43 -0
  67. package/dist/audit/orchestrator/requeueFold.d.ts.map +1 -0
  68. package/dist/audit/orchestrator/requeueFold.js +50 -0
  69. package/dist/audit/orchestrator/requeueFold.js.map +1 -0
  70. package/dist/audit/orchestrator/reviewPacketSizing.d.ts +0 -1
  71. package/dist/audit/orchestrator/reviewPacketSizing.d.ts.map +1 -1
  72. package/dist/audit/orchestrator/reviewPacketSizing.js +0 -5
  73. package/dist/audit/orchestrator/reviewPacketSizing.js.map +1 -1
  74. package/dist/audit/orchestrator/reviewPackets.d.ts +8 -2
  75. package/dist/audit/orchestrator/reviewPackets.d.ts.map +1 -1
  76. package/dist/audit/orchestrator/reviewPackets.js +7 -8
  77. package/dist/audit/orchestrator/reviewPackets.js.map +1 -1
  78. package/dist/audit/orchestrator/taskAffinityGraph.d.ts +0 -6
  79. package/dist/audit/orchestrator/taskAffinityGraph.d.ts.map +1 -1
  80. package/dist/audit/orchestrator/taskAffinityGraph.js +0 -16
  81. package/dist/audit/orchestrator/taskAffinityGraph.js.map +1 -1
  82. package/dist/audit/orchestrator/taskBuilder.d.ts.map +1 -1
  83. package/dist/audit/orchestrator/taskBuilder.js +1 -2
  84. package/dist/audit/orchestrator/taskBuilder.js.map +1 -1
  85. package/dist/audit/reporting/workBlocks.d.ts +0 -1
  86. package/dist/audit/reporting/workBlocks.d.ts.map +1 -1
  87. package/dist/audit/reporting/workBlocks.js +0 -3
  88. package/dist/audit/reporting/workBlocks.js.map +1 -1
  89. package/dist/audit/systemic/systemicChallengeLoop.d.ts +0 -8
  90. package/dist/audit/systemic/systemicChallengeLoop.d.ts.map +1 -1
  91. package/dist/audit/systemic/systemicChallengeLoop.js +0 -9
  92. package/dist/audit/systemic/systemicChallengeLoop.js.map +1 -1
  93. package/dist/audit/types.d.ts +4 -4
  94. package/dist/remediate/contractPipeline/artifactStore.d.ts +19 -23
  95. package/dist/remediate/contractPipeline/artifactStore.d.ts.map +1 -1
  96. package/dist/remediate/contractPipeline/artifactStore.js +22 -29
  97. package/dist/remediate/contractPipeline/artifactStore.js.map +1 -1
  98. package/dist/remediate/contractPipeline/changeClassification.d.ts +0 -12
  99. package/dist/remediate/contractPipeline/changeClassification.d.ts.map +1 -1
  100. package/dist/remediate/contractPipeline/changeClassification.js +0 -101
  101. package/dist/remediate/contractPipeline/changeClassification.js.map +1 -1
  102. package/dist/remediate/contractPipeline/derive.d.ts +0 -42
  103. package/dist/remediate/contractPipeline/derive.d.ts.map +1 -1
  104. package/dist/remediate/contractPipeline/derive.js +0 -108
  105. package/dist/remediate/contractPipeline/derive.js.map +1 -1
  106. package/dist/remediate/index.d.ts +0 -1
  107. package/dist/remediate/index.d.ts.map +1 -1
  108. package/dist/remediate/index.js +5 -132
  109. package/dist/remediate/index.js.map +1 -1
  110. package/dist/remediate/intake.d.ts +0 -55
  111. package/dist/remediate/intake.d.ts.map +1 -1
  112. package/dist/remediate/intake.js +1 -81
  113. package/dist/remediate/intake.js.map +1 -1
  114. package/dist/remediate/phases/plan.d.ts +0 -1
  115. package/dist/remediate/phases/plan.d.ts.map +1 -1
  116. package/dist/remediate/phases/plan.js +1 -207
  117. package/dist/remediate/phases/plan.js.map +1 -1
  118. package/dist/remediate/state/types.d.ts +4 -4
  119. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  120. package/dist/remediate/steps/contractPipeline.js +6 -6
  121. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  122. package/dist/remediate/steps/contractPipelinePrompts.d.ts +9 -9
  123. package/dist/remediate/steps/contractPipelinePrompts.d.ts.map +1 -1
  124. package/dist/remediate/steps/contractPipelinePrompts.js +25 -17
  125. package/dist/remediate/steps/contractPipelinePrompts.js.map +1 -1
  126. package/dist/remediate/steps/dispatch/hostHandoff.d.ts +0 -1
  127. package/dist/remediate/steps/dispatch/hostHandoff.d.ts.map +1 -1
  128. package/dist/remediate/steps/dispatch/hostHandoff.js +3 -2
  129. package/dist/remediate/steps/dispatch/hostHandoff.js.map +1 -1
  130. package/dist/remediate/steps/dispatch.d.ts +0 -8
  131. package/dist/remediate/steps/dispatch.d.ts.map +1 -1
  132. package/dist/remediate/steps/dispatch.js +3 -9
  133. package/dist/remediate/steps/dispatch.js.map +1 -1
  134. package/dist/remediate/steps/nextStep.d.ts +0 -1
  135. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  136. package/dist/remediate/steps/nextStep.js +0 -1
  137. package/dist/remediate/steps/nextStep.js.map +1 -1
  138. package/dist/remediate/utils/fileIntegrity.d.ts +0 -8
  139. package/dist/remediate/utils/fileIntegrity.d.ts.map +1 -1
  140. package/dist/remediate/utils/fileIntegrity.js +5 -65
  141. package/dist/remediate/utils/fileIntegrity.js.map +1 -1
  142. package/dist/remediate/validation/contractPipelineGates.js +3 -3
  143. package/dist/remediate/validation/contractPipelineGates.js.map +1 -1
  144. package/dist/shared/analyzers/candidates.d.ts +6 -6
  145. package/dist/shared/analyzers/candidates.d.ts.map +1 -1
  146. package/dist/shared/analyzers/candidates.js +6 -6
  147. package/dist/shared/analyzers/candidates.js.map +1 -1
  148. package/dist/shared/chunkByBudget.d.ts +8 -8
  149. package/dist/shared/decompose/contentCoherence.d.ts +0 -271
  150. package/dist/shared/decompose/contentCoherence.d.ts.map +1 -1
  151. package/dist/shared/decompose/contentCoherence.js +12 -59
  152. package/dist/shared/decompose/contentCoherence.js.map +1 -1
  153. package/dist/shared/decompose/systemicChallenge.d.ts +4 -4
  154. package/dist/shared/index.d.ts +5 -5
  155. package/dist/shared/index.d.ts.map +1 -1
  156. package/dist/shared/index.js +4 -4
  157. package/dist/shared/index.js.map +1 -1
  158. package/dist/shared/io/auditToolsPaths.d.ts +0 -20
  159. package/dist/shared/io/auditToolsPaths.d.ts.map +1 -1
  160. package/dist/shared/io/auditToolsPaths.js +0 -24
  161. package/dist/shared/io/auditToolsPaths.js.map +1 -1
  162. package/dist/shared/loopCorePaths.d.ts.map +1 -1
  163. package/dist/shared/loopCorePaths.js +15 -9
  164. package/dist/shared/loopCorePaths.js.map +1 -1
  165. package/dist/shared/types/finding.d.ts +30 -264
  166. package/dist/shared/types/finding.d.ts.map +1 -1
  167. package/dist/shared/types/finding.js +60 -0
  168. package/dist/shared/types/finding.js.map +1 -1
  169. package/dist/shared/validation/findingGrounding.d.ts +11 -0
  170. package/dist/shared/validation/findingGrounding.d.ts.map +1 -1
  171. package/dist/shared/validation/findingGrounding.js +21 -0
  172. package/dist/shared/validation/findingGrounding.js.map +1 -1
  173. package/dist/shared/validation/findingsReport.d.ts.map +1 -1
  174. package/dist/shared/validation/findingsReport.js +0 -6
  175. package/dist/shared/validation/findingsReport.js.map +1 -1
  176. package/docs/audit-pkg/contracts.md +2 -2
  177. package/docs/audit-pkg/development.md +1 -1
  178. package/docs/audit-pkg/release.md +20 -114
  179. package/package.json +6 -2
  180. package/schemas/audit_result.schema.json +0 -20
  181. package/schemas/audit_results.schema.json +0 -20
  182. package/schemas/finding.schema.json +0 -20
  183. package/skills/audit-code/SKILL.md +3 -7
  184. package/skills/audit-code/audit-code.prompt.md +5 -9
  185. package/skills/remediate-code/SKILL.md +0 -1
  186. package/dist/remediate/steps/dispatch/common.d.ts +0 -126
  187. package/dist/remediate/steps/dispatch/common.d.ts.map +0 -1
  188. package/dist/remediate/steps/dispatch/common.js +0 -204
  189. package/dist/remediate/steps/dispatch/common.js.map +0 -1
  190. package/dist/remediate/steps/dispatch/dagNodeFields.d.ts +0 -25
  191. package/dist/remediate/steps/dispatch/dagNodeFields.d.ts.map +0 -1
  192. package/dist/remediate/steps/dispatch/dagNodeFields.js +0 -5
  193. package/dist/remediate/steps/dispatch/dagNodeFields.js.map +0 -1
  194. package/dist/remediate/steps/dispatch/implementPrompt.d.ts +0 -47
  195. package/dist/remediate/steps/dispatch/implementPrompt.d.ts.map +0 -1
  196. package/dist/remediate/steps/dispatch/implementPrompt.js +0 -165
  197. package/dist/remediate/steps/dispatch/implementPrompt.js.map +0 -1
  198. package/dist/remediate/steps/dispatch/verifyCommands.d.ts +0 -144
  199. package/dist/remediate/steps/dispatch/verifyCommands.d.ts.map +0 -1
  200. package/dist/remediate/steps/dispatch/verifyCommands.js +0 -331
  201. package/dist/remediate/steps/dispatch/verifyCommands.js.map +0 -1
  202. package/dist/remediate/steps/dispatch/writeScope.d.ts +0 -43
  203. package/dist/remediate/steps/dispatch/writeScope.d.ts.map +0 -1
  204. package/dist/remediate/steps/dispatch/writeScope.js +0 -81
  205. package/dist/remediate/steps/dispatch/writeScope.js.map +0 -1
  206. package/dist/remediate/utils/hostAssets.d.ts +0 -21
  207. package/dist/remediate/utils/hostAssets.d.ts.map +0 -1
  208. package/dist/remediate/utils/hostAssets.js +0 -34
  209. package/dist/remediate/utils/hostAssets.js.map +0 -1
@@ -1,331 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { gitEditedFilesForBranch } from "./common.js";
4
- // ---------------------------------------------------------------------------
5
- // Build-free per-node verification commands (residual CE-001)
6
- // ---------------------------------------------------------------------------
7
- /**
8
- * The host manages the build centrally; a per-node verify command that runs
9
- * `npm run build` (or a `npm test` whose package script prepends a build) races
10
- * the central build's dist/ and is therefore forbidden. A command is build-free
11
- * only when it neither builds nor invokes a build-prepending test script.
12
- *
13
- * Forbidden (return false):
14
- * - `npm run build` / `npm run build -w ...` / `tsc` emit (`tsc -b`, `tsc --build`)
15
- * - bare `npm test` / `npm t` / `npm run test` (the package script prepends build)
16
- *
17
- * Allowed (return true):
18
- * - `npm run check` (no emit)
19
- * - `npx vitest run <path>` / `vitest run <path>`
20
- * - `node --test <path>`
21
- */
22
- export function isBuildFreeVerifyCommand(cmd) {
23
- if (cmd.trim().length === 0)
24
- return false;
25
- // INV-RSM-VERIFY-01 (COR-8c497987): judge each shell-chained INVOCATION on its
26
- // own flags, never the whole string — `tsc --noEmit && tsc -p build` must not
27
- // pass because a `--noEmit` appears SOMEWHERE in the command. Split on the
28
- // shell chain separators (&&, ||, ;, |, newline) first, then validate every
29
- // segment independently; one emitting segment forbids the whole command.
30
- const segments = cmd
31
- .replace(/\r\n/g, "\n")
32
- .split(/&&|\|\||[;|\n]/)
33
- .map((s) => s.trim().toLowerCase().replace(/\s+/g, " "))
34
- .filter((s) => s.length > 0);
35
- if (segments.length === 0)
36
- return false;
37
- for (const c of segments) {
38
- // Any explicit build step is forbidden.
39
- if (/\bnpm\s+run\s+build\b/.test(c))
40
- return false;
41
- if (/\btsc\b.*(-b\b|--build\b)/.test(c))
42
- return false;
43
- if (/(^|\s)tsc(\s|$)/.test(c) && !/--noemit\b/.test(c)) {
44
- // A bare `tsc` (or `tsc -p ...`) emits unless --noEmit is set — judged
45
- // per invocation, so a sibling segment's --noEmit cannot vouch for it.
46
- return false;
47
- }
48
- // A build-prepending `npm test` / `npm t` / `npm run test` is forbidden; the
49
- // build-free runner (vitest run / node --test) must be invoked directly.
50
- if (/\bnpm\s+(test|t)\b/.test(c))
51
- return false;
52
- if (/\bnpm\s+run\s+test\b/.test(c))
53
- return false;
54
- }
55
- return true;
56
- }
57
- /**
58
- * Inject the tsx ESM loader into a bare `node --test <file>` command so the `.mjs`
59
- * node:test suites (which import `audit-tools/shared` via tsconfig `paths`, honored
60
- * only by tsx) resolve in a per-node worktree with no built `dist/`. A host- or
61
- * DAG-authored `node --test tests/audit/x.test.mjs` would otherwise fail module
62
- * resolution; the tool normalizes it so correctness can't depend on the host
63
- * remembering to add the loader. Idempotent: a command already carrying
64
- * `--import tsx/esm` or a `--loader` is left untouched. Mirrors the runner the
65
- * derived verify uses ({@link verifyCommandsForEdits}), so the displayed per-node
66
- * command and the in-process verify match.
67
- */
68
- export function normalizeNodeTestCommand(cmd) {
69
- const trimmed = cmd.trim();
70
- if (!/^node\b/.test(trimmed))
71
- return cmd;
72
- if (!/\s--test\b/.test(trimmed))
73
- return cmd;
74
- if (/--import\s+tsx\/esm\b/.test(trimmed) || /--loader\b/.test(trimmed))
75
- return cmd;
76
- return trimmed.replace(/^node\b/, "node --import tsx/esm");
77
- }
78
- /**
79
- * True when `cmd` is a test-runner invocation whose target is a whole directory
80
- * or the entire suite rather than specific test files — e.g. `npx vitest run
81
- * tests/remediate`, `vitest run` (no path), `node --test tests/audit/`. Such a
82
- * command, run as an *additional* per-node verify alongside the scoped derive,
83
- * re-enters the FULL suite inside a per-node worktree. That is the structural
84
- * deadlock proven 2026-06-30: a source node's whole-suite verify fails on a
85
- * stale test owned by a DIFFERENT node, and concurrent worktrees race shared
86
- * test temp dirs. The derived verify already runs this node's OWN touched
87
- * tests, so a host/DAG-authored whole-suite command adds only risk — the tool
88
- * drops it rather than relying on the author to scope it (enforce-in-tooling,
89
- * never host discretion). A command naming at least one concrete `.test.<ext>`
90
- * file is scoped and kept.
91
- */
92
- export function isWholeSuiteTestCommand(cmd) {
93
- const c = cmd.trim();
94
- const isVitest = /\bvitest\b\s+run\b/.test(c) || /\bvitest\b(?!\s+run)/.test(c);
95
- const isNodeTest = /^node\b/.test(c) && /\s--test\b/.test(c);
96
- if (!isVitest && !isNodeTest)
97
- return false;
98
- // Tokenise; a concrete test file makes it scoped. Anything that is a runner
99
- // with no concrete test-file target (bare runner, or a directory/glob target)
100
- // is whole-suite.
101
- const namesConcreteTestFile = /(^|\s)[^\s]*\.test\.(ts|tsx|mjs|cjs|js)(\s|$)/.test(c);
102
- return !namesConcreteTestFile;
103
- }
104
- /**
105
- * True when a verify command DEPENDS ON A BUILT `dist/` — either the command
106
- * string itself references a dist path (spawning the built CLI), or, when
107
- * `treeRoot` is supplied, a test FILE the command names imports/spawns dist in
108
- * its content. A per-node worktree has NO dist at all (`dist/` is gitignored
109
- * and only `node_modules` is junction-linked), so such a command false-reds
110
- * DETERMINISTICALLY under the by-design build-free accept gate — three accepts
111
- * in a row failed exactly this way (2026-07-23 dogfood, backlog "build-free
112
- * accept verify false-reds dist-importing targeted commands"). A central build
113
- * cannot fix it (it materializes MAIN's dist, not the worktree's), so the
114
- * remedy is the same as the whole-suite / cross-node families: drop from
115
- * per-node verify and defer to the central close gate, which runs on the
116
- * merged tree with a fresh build.
117
- *
118
- * Detection is deliberately conservative-toward-deferral: a false positive
119
- * (e.g. a comment mentioning `dist/`) only moves that command to the close
120
- * gate — never a lost signal, never a false-red.
121
- */
122
- export function isDistDependentVerifyCommand(cmd, treeRoot) {
123
- if (/\bdist[\/\\]/.test(cmd))
124
- return true;
125
- if (treeRoot === undefined)
126
- return false;
127
- for (const token of pathTokensInCommand(cmd)) {
128
- if (!/\.test\.(mjs|cjs|js|ts|tsx)$/.test(token))
129
- continue;
130
- const p = join(treeRoot, token);
131
- if (!existsSync(p))
132
- continue;
133
- let content;
134
- try {
135
- content = readFileSync(p, "utf8");
136
- }
137
- catch {
138
- continue;
139
- }
140
- // `dist/`-style path (import/spawn) or a `"dist"` path-segment argument
141
- // (join(root, "dist", ...) — how the wrapper e2es locate the built entry).
142
- if (/\bdist[\/\\]/.test(content) || /["']dist["']/.test(content))
143
- return true;
144
- }
145
- return false;
146
- }
147
- /**
148
- * True when a verify command names a test FILE that is WORKTREE-HOSTILE: its
149
- * content spawns the `audit-code` / `remediate-code` driver CLIs, which the
150
- * worker-context guard (v0.34.19, cwd-discriminated) mechanically refuses from
151
- * inside a node worktree — so the test deterministically fails there and the
152
- * node can NEVER accept (accept/reverify cluster defect 8). Same
153
- * conservative-toward-deferral contract as the dist probe: a false positive
154
- * only moves the command to the close gate (root cwd, where it runs fine).
155
- */
156
- export function isWorktreeHostileVerifyCommand(cmd, treeRoot) {
157
- for (const token of pathTokensInCommand(cmd)) {
158
- if (!/\.test\.(mjs|cjs|js|ts|tsx)$/.test(token))
159
- continue;
160
- const p = join(treeRoot, token);
161
- if (!existsSync(p))
162
- continue;
163
- let content;
164
- try {
165
- content = readFileSync(p, "utf8");
166
- }
167
- catch {
168
- continue;
169
- }
170
- // The driver CLI names (bin or wrapper .mjs) appearing in test content —
171
- // spawn targets the worker-context guard refuses inside a worktree.
172
- if (/\b(?:audit|remediate)-code(?:\.mjs)?\b/.test(content))
173
- return true;
174
- }
175
- return false;
176
- }
177
- /**
178
- * Partition verify commands into the per-node-runnable set and the DEFERRED set
179
- * (dist-dependent OR worktree-hostile — both deterministically false-red inside
180
- * a build-free node worktree; the central close gate runs them on the merged
181
- * tree at the repo root). Content-level detection: `treeRoot` should be the
182
- * WORKTREE the verify would run in, so the scanned test files are the node's
183
- * own post-edit versions. The deferred list is DEDUPLICATED — the close gate's
184
- * replay drains it verbatim, so a doubled entry would run twice there.
185
- */
186
- export function partitionDeferredVerifyCommands(commands, treeRoot) {
187
- const kept = [];
188
- const deferred = new Set();
189
- for (const c of commands) {
190
- if (isDistDependentVerifyCommand(c, treeRoot) || isWorktreeHostileVerifyCommand(c, treeRoot)) {
191
- deferred.add(c);
192
- }
193
- else {
194
- kept.push(c);
195
- }
196
- }
197
- return { kept, deferred: [...deferred] };
198
- }
199
- /**
200
- * cg-1: collapse the per-node DEFERRED verify commands into the close gate's
201
- * single residual run. Exact-duplicate commands collapse to one (first-seen
202
- * order); when the close phase's own full-suite leg ran green
203
- * (`fullSuiteCovers`), any command that leg already covers is SUBSUMED and
204
- * dropped — a whole-suite runner invocation, or a vitest run whose path tokens
205
- * are all test files (the full vitest sweep runs every test file). Everything
206
- * else (e.g. `npm run check`, dist-spawning scripts) survives as the residual
207
- * the close gate must run exactly once. The 2026-08-06 run drained the raw
208
- * per-node lists verbatim — duplicate full `tests/audit` passes, a 2h close.
209
- */
210
- export function dedupeDeferredVerifyCommands(deferred, opts) {
211
- const residual = [];
212
- const subsumed = [];
213
- const seen = new Set();
214
- for (const raw of deferred) {
215
- const cmd = raw.trim();
216
- if (cmd.length === 0 || seen.has(cmd))
217
- continue;
218
- seen.add(cmd);
219
- if (opts.fullSuiteCovers && isSubsumedByFullSuite(cmd)) {
220
- subsumed.push(cmd);
221
- continue;
222
- }
223
- residual.push(cmd);
224
- }
225
- return { residual, subsumed };
226
- }
227
- /** A green full-suite leg covers whole-suite runs and test-file-only vitest runs. */
228
- function isSubsumedByFullSuite(cmd) {
229
- if (isWholeSuiteTestCommand(cmd))
230
- return true;
231
- if (!/\bvitest\b/.test(cmd))
232
- return false;
233
- const tokens = pathTokensInCommand(cmd);
234
- return (tokens.length > 0 &&
235
- tokens.every((t) => /\.test\.(ts|tsx|mts|cts|js|mjs|cjs)$/.test(t)));
236
- }
237
- /**
238
- * Repo-relative path-like tokens in a shell command — tokens containing a `/` and a
239
- * file extension (e.g. `scripts/remediate/verify-hosts.mjs`, `tests/x.test.ts`).
240
- * Used to decide whether a targeted verify command is self-contained.
241
- */
242
- export function pathTokensInCommand(cmd) {
243
- const tokens = cmd.match(/(?:[\w.@-]+[\/\\])+[\w.@-]+\.\w+/g) ?? [];
244
- return [...new Set(tokens.map((t) => t.replace(/\\/g, "/")))];
245
- }
246
- /**
247
- * Keep only the targeted verify commands that are SELF-CONTAINED for this node:
248
- * every path-like token they reference is either one of the node's own paths (its
249
- * declared write set ∪ the files it actually edited on its branch) or already
250
- * present in the tree. A command referencing a path this node doesn't own and that
251
- * isn't in the tree depends on a SIBLING node's not-yet-created deliverable —
252
- * running it in per-node verify is a guaranteed-fail deadlock (proven 2026-07-03: a
253
- * node's `targeted_command` was `node scripts/remediate/verify-hosts.mjs`, another
254
- * node's pending output). Per-node verify must be self-contained; such a cross-node
255
- * command is dropped here and deferred to the integration/close gate. A command with
256
- * no path tokens (e.g. `npm run check`) is always kept.
257
- */
258
- export function selfContainedVerifyCommands(commands, ownPaths, treeRoot) {
259
- const owned = new Set([...ownPaths].map((p) => p.replace(/\\/g, "/")));
260
- return commands.filter((cmd) => {
261
- for (const token of pathTokensInCommand(cmd)) {
262
- if (owned.has(token))
263
- continue;
264
- if (existsSync(join(treeRoot, token)))
265
- continue;
266
- return false;
267
- }
268
- return true;
269
- });
270
- }
271
- /** A repo-relative test path → the runner that executes that file directly. */
272
- function verifyRunnerForTestFile(repoRelPath) {
273
- // ONE vitest runner across all suites (audit / shared / remediate). The node:test
274
- // split was retired 2026-07-02, so every tracked `.test.mjs` / `.test.ts` file is a
275
- // vitest file — running a `.mjs` vitest suite under `node --test` throws "Vitest
276
- // failed to access its internal state". vitest resolves `audit-tools/shared` via its
277
- // config alias, so a per-node worktree needs no prior build (`npx vitest run <file>`).
278
- if (/^tests\/.+\.test\.(mjs|ts|tsx)$/.test(repoRelPath))
279
- return "vitest";
280
- return undefined;
281
- }
282
- /**
283
- * Derive a node's per-node verify commands from the test files it ACTUALLY touched
284
- * on its worktree branch (the git ground truth), instead of trusting host-authored
285
- * `targeted_commands` whose paths/runner can drift from where the worker put the
286
- * test. Always typechecks (`npm run check`, no emit), then runs ONLY this node's
287
- * own touched test files with the repo's runners — never the whole suite (which
288
- * would re-enter worktree-spawning tests inside a nested worktree). Build-free: the
289
- * host owns the central build; a node's own test imports the source it changed via
290
- * the tsx loader. Returns `[]` when there is no git ground truth so the caller can
291
- * skip the gate rather than fabricate a command.
292
- */
293
- /** Pure assembly (git-free) of the verify commands for a set of edited paths —
294
- * the testable core of {@link deriveVerifyCommandsFromBranch}. */
295
- export function verifyCommandsForEdits(editedFiles) {
296
- const vitestTests = [];
297
- for (const f of editedFiles) {
298
- const rel = f.replace(/\\/g, "/");
299
- if (verifyRunnerForTestFile(rel) === "vitest")
300
- vitestTests.push(rel);
301
- }
302
- const cmds = ["npm run check"];
303
- if (vitestTests.length > 0) {
304
- cmds.push(`npx vitest run ${vitestTests.sort().join(" ")}`);
305
- }
306
- return cmds;
307
- }
308
- export function deriveVerifyCommandsFromBranch(root, branch) {
309
- const edited = gitEditedFilesForBranch(root, branch);
310
- if (!edited.available)
311
- return [];
312
- return verifyCommandsForEdits(edited.files);
313
- }
314
- /**
315
- * A node's own `targeted_commands` for the per-node verify (task_7d35176d) — the union
316
- * of the block's `targeted_commands` and its findings' `targeted_commands` (the
317
- * auditor-specified, fix-specific verification) bound into the host workload.
318
- */
319
- export function targetedCommandsForBlock(state, blockId) {
320
- const block = state.plan?.blocks?.find((b) => b.block_id === blockId);
321
- if (!block)
322
- return [];
323
- const out = [...(block.targeted_commands ?? [])];
324
- for (const fid of block.items) {
325
- const finding = state.plan?.findings?.find((f) => f.id === fid);
326
- for (const c of finding?.targeted_commands ?? [])
327
- out.push(c);
328
- }
329
- return [...new Set(out)];
330
- }
331
- //# sourceMappingURL=verifyCommands.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verifyCommands.js","sourceRoot":"","sources":["../../../../src/remediate/steps/dispatch/verifyCommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,8EAA8E;AAC9E,8DAA8D;AAC9D,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,+EAA+E;IAC/E,8EAA8E;IAC9E,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,QAAQ,GAAG,GAAG;SACjB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;SACtB,KAAK,CAAC,gBAAgB,CAAC;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACvD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,KAAK,MAAM,CAA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AM,CAAC,IAAI,OAAO,EAAE,iBAAiB,IAAI,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC"}
@@ -1,43 +0,0 @@
1
- import { type GitEditedFiles } from "./common.js";
2
- /** The decision a write-scope gate makes given the resolved edit set. */
3
- export interface WriteScopeDecision {
4
- blocked: boolean;
5
- reason?: string;
6
- }
7
- /**
8
- * Pure write-scope gate decision (OBL-DS-06). Given the block's declared write
9
- * paths and the resolved git edit set:
10
- * - `not_a_repo` → no ground truth (no worktree workflow) → not blocked.
11
- * - `probe_failed` → git is a repo but the diff failed → FAIL CLOSED (blocked).
12
- * - available → block iff any edited file is outside declared scope.
13
- * The worker's self-reported `amended_files` is never an input here.
14
- */
15
- export declare function enforceWriteScope(declaredWritePaths: string[], edited: GitEditedFiles, root: string): WriteScopeDecision;
16
- /**
17
- * Pure write-scope adjudication (OBL-DS-06) — git-free so it is unit-testable with
18
- * a synthetic edit set. It normalizes the complete declared-scope snapshot and
19
- * checks the node's ACTUAL edits — git ground truth, never a self-report:
20
- * - an edit to a file no sibling block owns widens this node's effective scope;
21
- * effective scope (a too-narrow — or empty — declared scope no longer blocks a
22
- * correct fix; this is the sanctioned "extend into unowned files" path);
23
- * - an edit to a file in another block's declared scope is a seam conflict that
24
- * blocks until the host re-scopes or serializes the work.
25
- */
26
- export declare function adjudicateWriteScope(allBlockScopes: Array<{
27
- block_id: string;
28
- write_paths: string[];
29
- }>, blockId: string, edited: GitEditedFiles, root: string): WriteScopeDecision;
30
- /**
31
- * Git-backed write-scope gate. Thin wrapper around
32
- * {@link adjudicateWriteScope}: resolves the branch's actual edits and adjudicates.
33
- */
34
- export declare function enforceAcceptWriteScope(params: {
35
- root: string;
36
- branch: string;
37
- blockId: string;
38
- allBlockScopes: Array<{
39
- block_id: string;
40
- write_paths: string[];
41
- }>;
42
- }): WriteScopeDecision;
43
- //# sourceMappingURL=writeScope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeScope.d.ts","sourceRoot":"","sources":["../../../../src/remediate/steps/dispatch/writeScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAErB,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,MAAM,EAAE,EAC5B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,GACX,kBAAkB,CAsBpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,EAClE,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,GACX,kBAAkB,CAkCpB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CACpE,GAAG,kBAAkB,CAQrB"}
@@ -1,81 +0,0 @@
1
- import { toRepoRelative, writeScopeViolations, gitEditedFilesForBranch, } from "./common.js";
2
- /**
3
- * Pure write-scope gate decision (OBL-DS-06). Given the block's declared write
4
- * paths and the resolved git edit set:
5
- * - `not_a_repo` → no ground truth (no worktree workflow) → not blocked.
6
- * - `probe_failed` → git is a repo but the diff failed → FAIL CLOSED (blocked).
7
- * - available → block iff any edited file is outside declared scope.
8
- * The worker's self-reported `amended_files` is never an input here.
9
- */
10
- export function enforceWriteScope(declaredWritePaths, edited, root) {
11
- if (!edited.available) {
12
- if (edited.reason === "not_a_repo") {
13
- return { blocked: false };
14
- }
15
- // probe_failed: git is present but could not be queried → fail closed.
16
- return {
17
- blocked: true,
18
- reason: `Write-scope could not be verified: git probe failed (${edited.error}). ` +
19
- `Failing closed rather than trusting self-reported edits.`,
20
- };
21
- }
22
- const violations = writeScopeViolations(declaredWritePaths, edited.files, root);
23
- if (violations.length === 0)
24
- return { blocked: false };
25
- return {
26
- blocked: true,
27
- reason: `Worker edited files outside its declared write scope: ${violations.join(", ")}. ` +
28
- `Declared scope must be amended through the seam protocol; the self-reported ` +
29
- `amended_files set is not trusted for this gate.`,
30
- };
31
- }
32
- /**
33
- * Pure write-scope adjudication (OBL-DS-06) — git-free so it is unit-testable with
34
- * a synthetic edit set. It normalizes the complete declared-scope snapshot and
35
- * checks the node's ACTUAL edits — git ground truth, never a self-report:
36
- * - an edit to a file no sibling block owns widens this node's effective scope;
37
- * effective scope (a too-narrow — or empty — declared scope no longer blocks a
38
- * correct fix; this is the sanctioned "extend into unowned files" path);
39
- * - an edit to a file in another block's declared scope is a seam conflict that
40
- * blocks until the host re-scopes or serializes the work.
41
- */
42
- export function adjudicateWriteScope(allBlockScopes, blockId, edited, root) {
43
- const normalizedScopes = allBlockScopes.map((scope) => ({
44
- blockId: scope.block_id,
45
- paths: scope.write_paths.map((path) => toRepoRelative(path, root)),
46
- }));
47
- const effectiveScope = new Set(normalizedScopes.find((scope) => scope.blockId === blockId)?.paths ?? []);
48
- if (!edited.available)
49
- return enforceWriteScope([...effectiveScope], edited, root);
50
- const candidates = writeScopeViolations([...effectiveScope], edited.files, root);
51
- const conflicts = [];
52
- for (const candidate of candidates) {
53
- const owners = normalizedScopes
54
- .filter((scope) => scope.blockId !== blockId && scope.paths.includes(candidate))
55
- .map((scope) => scope.blockId)
56
- .sort();
57
- if (owners.length > 0) {
58
- conflicts.push(`${candidate} owned by ${owners.join(", ")}`);
59
- }
60
- else {
61
- effectiveScope.add(candidate);
62
- }
63
- }
64
- if (conflicts.length > 0) {
65
- return {
66
- blocked: true,
67
- reason: `Node edited files owned by another block (seam conflict): ${conflicts.join("; ")}. ` +
68
- `Re-scope or serialize the work before this result can be accepted.`,
69
- };
70
- }
71
- return enforceWriteScope([...effectiveScope], edited, root);
72
- }
73
- /**
74
- * Git-backed write-scope gate. Thin wrapper around
75
- * {@link adjudicateWriteScope}: resolves the branch's actual edits and adjudicates.
76
- */
77
- export function enforceAcceptWriteScope(params) {
78
- const { root, branch, blockId, allBlockScopes } = params;
79
- return adjudicateWriteScope(allBlockScopes, blockId, gitEditedFilesForBranch(root, branch), root);
80
- }
81
- //# sourceMappingURL=writeScope.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeScope.js","sourceRoot":"","sources":["../../../../src/remediate/steps/dispatch/writeScope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,uBAAuB,GAExB,MAAM,aAAa,CAAC;AAQrB;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,kBAA4B,EAC5B,MAAsB,EACtB,IAAY;IAEZ,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;YACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,uEAAuE;QACvE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EACJ,wDAAwD,MAAM,CAAC,KAAK,KAAK;gBACzE,0DAA0D;SAC7D,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,oBAAoB,CAAC,kBAAkB,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,O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C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;aAC7B,IAAI,EAAE,CAAC;QACV,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,aAAa,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EACJ,6DAA6D,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;gBACrF,oEAAoE;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC,CAAC,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAKvC;IACC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IACzD,OAAO,oBAAoB,CACzB,cAAc,EACd,OAAO,EACP,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,EACrC,IAAI,CACL,CAAC;AACJ,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Strip YAML frontmatter from a text file, returning only the body.
3
- * Consumed by `ensureGlobalAssets` (the `remediate-code ensure` CLI command,
4
- * src/remediate/index.ts). scripts/remediate/postinstall.mjs has its own
5
- * copy in scripts/shared/install-host-assets.mjs — that script runs before
6
- * `tsc` has produced dist/, so it cannot import this TS module.
7
- */
8
- export declare function splitFrontmatter(text: string): {
9
- body: string;
10
- };
11
- /**
12
- * Write a generated file, creating parent directories as needed.
13
- * Returns "installed" on first write, "updated" on subsequent writes.
14
- */
15
- export declare function writeGeneratedFile(path: string, content: Buffer): string;
16
- /**
17
- * Coerce an unknown value to a plain object (non-array).
18
- * Returns {} for primitives, arrays, and null.
19
- */
20
- export declare function objectValue(value: unknown): Record<string, unknown>;
21
- //# sourceMappingURL=hostAssets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostAssets.d.ts","sourceRoot":"","sources":["../../../src/remediate/utils/hostAssets.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAI/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKxE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAInE"}
@@ -1,34 +0,0 @@
1
- import { mkdirSync, existsSync, writeFileSync } from "node:fs";
2
- import { dirname } from "node:path";
3
- /**
4
- * Strip YAML frontmatter from a text file, returning only the body.
5
- * Consumed by `ensureGlobalAssets` (the `remediate-code ensure` CLI command,
6
- * src/remediate/index.ts). scripts/remediate/postinstall.mjs has its own
7
- * copy in scripts/shared/install-host-assets.mjs — that script runs before
8
- * `tsc` has produced dist/, so it cannot import this TS module.
9
- */
10
- export function splitFrontmatter(text) {
11
- const normalized = text.replace(/\r\n/g, "\n");
12
- const match = normalized.match(/^---\n[\s\S]*?\n---\n?/u);
13
- return { body: match ? normalized.slice(match[0].length) : normalized };
14
- }
15
- /**
16
- * Write a generated file, creating parent directories as needed.
17
- * Returns "installed" on first write, "updated" on subsequent writes.
18
- */
19
- export function writeGeneratedFile(path, content) {
20
- const action = existsSync(path) ? "updated" : "installed";
21
- mkdirSync(dirname(path), { recursive: true });
22
- writeFileSync(path, content);
23
- return action;
24
- }
25
- /**
26
- * Coerce an unknown value to a plain object (non-array).
27
- * Returns {} for primitives, arrays, and null.
28
- */
29
- export function objectValue(value) {
30
- return value && typeof value === "object" && !Array.isArray(value)
31
- ? value
32
- : {};
33
- }
34
- //# sourceMappingURL=hostAssets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostAssets.js","sourceRoot":"","sources":["../../../src/remediate/utils/hostAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC1D,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,OAAe;IAC9D,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAC1D,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAChE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}