@rasensio/aidlc 1.15.2 → 1.17.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/README.md +1 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +4 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/compliance.d.ts +36 -0
  6. package/dist/commands/compliance.d.ts.map +1 -0
  7. package/dist/commands/compliance.js +275 -0
  8. package/dist/commands/compliance.js.map +1 -0
  9. package/dist/commands/constitution.d.ts +26 -0
  10. package/dist/commands/constitution.d.ts.map +1 -0
  11. package/dist/commands/constitution.js +145 -0
  12. package/dist/commands/constitution.js.map +1 -0
  13. package/dist/commands/cost.d.ts.map +1 -1
  14. package/dist/commands/cost.js +54 -35
  15. package/dist/commands/cost.js.map +1 -1
  16. package/dist/commands/doctor.js +7 -0
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/gate.d.ts.map +1 -1
  19. package/dist/commands/gate.js +13 -0
  20. package/dist/commands/gate.js.map +1 -1
  21. package/dist/commands/init.d.ts.map +1 -1
  22. package/dist/commands/init.js +119 -10
  23. package/dist/commands/init.js.map +1 -1
  24. package/dist/commands/metrics.d.ts.map +1 -1
  25. package/dist/commands/metrics.js +6 -1
  26. package/dist/commands/metrics.js.map +1 -1
  27. package/dist/commands/review.d.ts +2 -27
  28. package/dist/commands/review.d.ts.map +1 -1
  29. package/dist/commands/review.js +10 -166
  30. package/dist/commands/review.js.map +1 -1
  31. package/dist/commands/status.d.ts.map +1 -1
  32. package/dist/commands/status.js +7 -0
  33. package/dist/commands/status.js.map +1 -1
  34. package/dist/commands/transition.d.ts.map +1 -1
  35. package/dist/commands/transition.js +24 -1
  36. package/dist/commands/transition.js.map +1 -1
  37. package/dist/compile/adapters/claude-code.d.ts.map +1 -1
  38. package/dist/compile/adapters/claude-code.js +2 -1
  39. package/dist/compile/adapters/claude-code.js.map +1 -1
  40. package/dist/compile/adapters/codex.d.ts +22 -1
  41. package/dist/compile/adapters/codex.d.ts.map +1 -1
  42. package/dist/compile/adapters/codex.js +61 -27
  43. package/dist/compile/adapters/codex.js.map +1 -1
  44. package/dist/compile/adapters/cursor.d.ts.map +1 -1
  45. package/dist/compile/adapters/cursor.js +2 -19
  46. package/dist/compile/adapters/cursor.js.map +1 -1
  47. package/dist/compile/adapters/kiro.d.ts.map +1 -1
  48. package/dist/compile/adapters/kiro.js +1 -19
  49. package/dist/compile/adapters/kiro.js.map +1 -1
  50. package/dist/compile/adapters/windsurf.d.ts.map +1 -1
  51. package/dist/compile/adapters/windsurf.js +2 -1
  52. package/dist/compile/adapters/windsurf.js.map +1 -1
  53. package/dist/compile/guidance-install.d.ts +16 -19
  54. package/dist/compile/guidance-install.d.ts.map +1 -1
  55. package/dist/compile/guidance-install.js +26 -111
  56. package/dist/compile/guidance-install.js.map +1 -1
  57. package/dist/compile/layer-install.d.ts +122 -0
  58. package/dist/compile/layer-install.d.ts.map +1 -0
  59. package/dist/compile/layer-install.js +195 -0
  60. package/dist/compile/layer-install.js.map +1 -0
  61. package/dist/compile/loaders.d.ts +14 -0
  62. package/dist/compile/loaders.d.ts.map +1 -1
  63. package/dist/compile/loaders.js +23 -18
  64. package/dist/compile/loaders.js.map +1 -1
  65. package/dist/compile/skill-format.d.ts +39 -0
  66. package/dist/compile/skill-format.d.ts.map +1 -0
  67. package/dist/compile/skill-format.js +50 -0
  68. package/dist/compile/skill-format.js.map +1 -0
  69. package/dist/compliance/check.d.ts +79 -0
  70. package/dist/compliance/check.d.ts.map +1 -0
  71. package/dist/compliance/check.js +224 -0
  72. package/dist/compliance/check.js.map +1 -0
  73. package/dist/compliance/config.d.ts +91 -0
  74. package/dist/compliance/config.d.ts.map +1 -0
  75. package/dist/compliance/config.js +173 -0
  76. package/dist/compliance/config.js.map +1 -0
  77. package/dist/compliance/findings.d.ts +70 -0
  78. package/dist/compliance/findings.d.ts.map +1 -0
  79. package/dist/compliance/findings.js +132 -0
  80. package/dist/compliance/findings.js.map +1 -0
  81. package/dist/compliance/gate-criterion.d.ts +87 -0
  82. package/dist/compliance/gate-criterion.d.ts.map +1 -0
  83. package/dist/compliance/gate-criterion.js +168 -0
  84. package/dist/compliance/gate-criterion.js.map +1 -0
  85. package/dist/compliance/install.d.ts +135 -0
  86. package/dist/compliance/install.d.ts.map +1 -0
  87. package/dist/compliance/install.js +291 -0
  88. package/dist/compliance/install.js.map +1 -0
  89. package/dist/compliance/report.d.ts +144 -0
  90. package/dist/compliance/report.d.ts.map +1 -0
  91. package/dist/compliance/report.js +347 -0
  92. package/dist/compliance/report.js.map +1 -0
  93. package/dist/compliance/resolver.d.ts +65 -0
  94. package/dist/compliance/resolver.d.ts.map +1 -0
  95. package/dist/compliance/resolver.js +176 -0
  96. package/dist/compliance/resolver.js.map +1 -0
  97. package/dist/compliance/schema.d.ts +74 -0
  98. package/dist/compliance/schema.d.ts.map +1 -0
  99. package/dist/compliance/schema.js +474 -0
  100. package/dist/compliance/schema.js.map +1 -0
  101. package/dist/compliance/types.d.ts +140 -0
  102. package/dist/compliance/types.d.ts.map +1 -0
  103. package/dist/compliance/types.js +29 -0
  104. package/dist/compliance/types.js.map +1 -0
  105. package/dist/constitution/check.d.ts +22 -0
  106. package/dist/constitution/check.d.ts.map +1 -0
  107. package/dist/constitution/check.js +89 -0
  108. package/dist/constitution/check.js.map +1 -0
  109. package/dist/constitution/docx.d.ts +51 -0
  110. package/dist/constitution/docx.d.ts.map +1 -0
  111. package/dist/constitution/docx.js +157 -0
  112. package/dist/constitution/docx.js.map +1 -0
  113. package/dist/constitution/entries.d.ts +27 -0
  114. package/dist/constitution/entries.d.ts.map +1 -0
  115. package/dist/constitution/entries.js +65 -0
  116. package/dist/constitution/entries.js.map +1 -0
  117. package/dist/constitution/extract.d.ts +34 -0
  118. package/dist/constitution/extract.d.ts.map +1 -0
  119. package/dist/constitution/extract.js +117 -0
  120. package/dist/constitution/extract.js.map +1 -0
  121. package/dist/constitution/snapshot.d.ts +47 -0
  122. package/dist/constitution/snapshot.d.ts.map +1 -0
  123. package/dist/constitution/snapshot.js +159 -0
  124. package/dist/constitution/snapshot.js.map +1 -0
  125. package/dist/constitution/statements.d.ts +37 -0
  126. package/dist/constitution/statements.d.ts.map +1 -0
  127. package/dist/constitution/statements.js +64 -0
  128. package/dist/constitution/statements.js.map +1 -0
  129. package/dist/constitution/types.d.ts +80 -0
  130. package/dist/constitution/types.d.ts.map +1 -0
  131. package/dist/constitution/types.js +9 -0
  132. package/dist/constitution/types.js.map +1 -0
  133. package/dist/core/gate.d.ts +10 -0
  134. package/dist/core/gate.d.ts.map +1 -1
  135. package/dist/core/gate.js.map +1 -1
  136. package/dist/core/paths.d.ts +48 -0
  137. package/dist/core/paths.d.ts.map +1 -0
  138. package/dist/core/paths.js +57 -0
  139. package/dist/core/paths.js.map +1 -0
  140. package/dist/core/types.d.ts +12 -1
  141. package/dist/core/types.d.ts.map +1 -1
  142. package/dist/cost/hooks/registry.d.ts +44 -0
  143. package/dist/cost/hooks/registry.d.ts.map +1 -0
  144. package/dist/cost/hooks/registry.js +66 -0
  145. package/dist/cost/hooks/registry.js.map +1 -0
  146. package/dist/cost/pin.d.ts +63 -0
  147. package/dist/cost/pin.d.ts.map +1 -0
  148. package/dist/cost/pin.js +95 -0
  149. package/dist/cost/pin.js.map +1 -0
  150. package/dist/cost/providers/claude-code.d.ts +9 -2
  151. package/dist/cost/providers/claude-code.d.ts.map +1 -1
  152. package/dist/cost/providers/claude-code.js +10 -5
  153. package/dist/cost/providers/claude-code.js.map +1 -1
  154. package/dist/cost/providers/codex.d.ts +107 -0
  155. package/dist/cost/providers/codex.d.ts.map +1 -0
  156. package/dist/cost/providers/codex.js +283 -0
  157. package/dist/cost/providers/codex.js.map +1 -0
  158. package/dist/cost/providers/index.d.ts.map +1 -1
  159. package/dist/cost/providers/index.js +6 -0
  160. package/dist/cost/providers/index.js.map +1 -1
  161. package/dist/cost/rates.d.ts.map +1 -1
  162. package/dist/cost/rates.js +14 -0
  163. package/dist/cost/rates.js.map +1 -1
  164. package/dist/cost/report.d.ts +23 -1
  165. package/dist/cost/report.d.ts.map +1 -1
  166. package/dist/cost/report.js +26 -5
  167. package/dist/cost/report.js.map +1 -1
  168. package/dist/cost/sessions.d.ts +10 -1
  169. package/dist/cost/sessions.d.ts.map +1 -1
  170. package/dist/cost/sessions.js +10 -2
  171. package/dist/cost/sessions.js.map +1 -1
  172. package/dist/cost/sync.d.ts.map +1 -1
  173. package/dist/cost/sync.js +190 -5
  174. package/dist/cost/sync.js.map +1 -1
  175. package/dist/doctor/migrations/compliance-pack-drift.d.ts +62 -0
  176. package/dist/doctor/migrations/compliance-pack-drift.d.ts.map +1 -0
  177. package/dist/doctor/migrations/compliance-pack-drift.js +255 -0
  178. package/dist/doctor/migrations/compliance-pack-drift.js.map +1 -0
  179. package/dist/doctor/migrations/index.d.ts.map +1 -1
  180. package/dist/doctor/migrations/index.js +11 -0
  181. package/dist/doctor/migrations/index.js.map +1 -1
  182. package/dist/doctor/migrations/legacy-cost-hooks.d.ts.map +1 -1
  183. package/dist/doctor/migrations/legacy-cost-hooks.js +7 -4
  184. package/dist/doctor/migrations/legacy-cost-hooks.js.map +1 -1
  185. package/dist/doctor/migrations/missing-cost-shim.d.ts.map +1 -1
  186. package/dist/doctor/migrations/missing-cost-shim.js +5 -4
  187. package/dist/doctor/migrations/missing-cost-shim.js.map +1 -1
  188. package/dist/doctor/migrations/outdated-cost-hooks.d.ts.map +1 -1
  189. package/dist/doctor/migrations/outdated-cost-hooks.js +7 -4
  190. package/dist/doctor/migrations/outdated-cost-hooks.js.map +1 -1
  191. package/dist/doctor/runner.js +14 -0
  192. package/dist/doctor/runner.js.map +1 -1
  193. package/dist/doctor/types.d.ts +35 -3
  194. package/dist/doctor/types.d.ts.map +1 -1
  195. package/dist/menu/roster.d.ts.map +1 -1
  196. package/dist/menu/roster.js +5 -0
  197. package/dist/menu/roster.js.map +1 -1
  198. package/dist/metrics/report.d.ts.map +1 -1
  199. package/dist/metrics/report.js +11 -2
  200. package/dist/metrics/report.js.map +1 -1
  201. package/dist/review/findings-parser.d.ts +92 -0
  202. package/dist/review/findings-parser.d.ts.map +1 -0
  203. package/dist/review/findings-parser.js +196 -0
  204. package/dist/review/findings-parser.js.map +1 -0
  205. package/dist/setup/setup-compute.d.ts +10 -15
  206. package/dist/setup/setup-compute.d.ts.map +1 -1
  207. package/dist/setup/setup-compute.js +39 -0
  208. package/dist/setup/setup-compute.js.map +1 -1
  209. package/package.json +2 -2
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Pack install, remove and upgrade.
3
+ *
4
+ * Uses the layer-install primitive with the **recorded-hash** detector, never the
5
+ * bundled-body one. That choice is the whole reason the primitive takes a detector:
6
+ * comparing a pack layer against the currently bundled body conflates "the user
7
+ * edited this" with "we published a new version", which would make every layer read
8
+ * as edited after any content update — so `remove` would refuse to delete anything
9
+ * and corrected control text would never land.
10
+ *
11
+ * Three rules govern what happens to files:
12
+ *
13
+ * - **Install never overwrites.** A layer already on disk is left alone and
14
+ * classified, exactly as framework install does.
15
+ * - **Remove deletes only what it can prove it wrote.** Unmodified means the disk
16
+ * hash matches the hash recorded at install. Anything else is the project's file
17
+ * now, and stays.
18
+ * - **A left-behind file loses its registration.** Keeping bytes is respect for the
19
+ * user's edit; keeping the registration would keep feeding an uninstalled pack's
20
+ * constraints to every agent.
21
+ *
22
+ * Requirements: compliance-packs/AC-9, AC-10, AC-11, AC-12, AC-13, AC-16, AC-54,
23
+ * AC-68, AC-69, AC-70, AC-71, AC-72
24
+ */
25
+ import { existsSync, readFileSync, rmSync } from 'node:fs';
26
+ import { join } from 'node:path';
27
+ import { installLayers, readIndexEntries, unregisterLayers } from '../compile/layer-install.js';
28
+ import { findInstalledPack, hashContent, isStale, readComplianceConfig, recordedHashDiffers, writeComplianceConfig, } from './config.js';
29
+ import { availablePackIds, packsRoot, resolvePack } from './resolver.js';
30
+ /** Where a project's guidance layers live. */
31
+ function guidanceDir(projectRoot) {
32
+ return join(projectRoot, '.aidlc', 'guidance');
33
+ }
34
+ /**
35
+ * Install a pack into a project.
36
+ *
37
+ * Idempotent: a second run writes nothing new and reports `unchanged`. Validation
38
+ * happens first and covers the whole pack, so a pack with one malformed control
39
+ * installs nothing at all.
40
+ */
41
+ export function installPack(projectRoot, id, opts = {}) {
42
+ const resolved = resolvePack(id);
43
+ if (!resolved.ok)
44
+ return { ok: false, error: resolved.error };
45
+ const pack = resolved.pack;
46
+ const config = readComplianceConfig(projectRoot);
47
+ const existing = findInstalledPack(config, id);
48
+ const target = guidanceDir(projectRoot);
49
+ const report = installLayers(join(packsRoot(), id, 'guidance'), target, pack.layers.map((l) => ({ name: l.name, file: l.file, always_pointer: true })), {
50
+ isModified: recordedHashDiffers(existing),
51
+ relPrefix: '.aidlc/guidance',
52
+ label: `pack '${id}' layer`,
53
+ ...(opts.dryRun !== undefined && { dryRun: opts.dryRun }),
54
+ });
55
+ // Record the hash of what is on disk for every layer we own — including layers
56
+ // that were already current, so a record is never partial. A layer we chose not to
57
+ // touch because the project edited it keeps its ORIGINAL recorded hash, so it
58
+ // stays classified as modified rather than being silently adopted.
59
+ const files = [];
60
+ for (const layer of pack.layers) {
61
+ if (report.locallyModified.includes(layer.name)) {
62
+ const prior = existing?.files.find((f) => f.path === layer.file);
63
+ if (prior)
64
+ files.push(prior);
65
+ continue;
66
+ }
67
+ const onDisk = join(target, layer.file);
68
+ if (opts.dryRun) {
69
+ // Nothing was written, so hash the source we would have written.
70
+ const sourcePath = join(packsRoot(), id, 'guidance', layer.file);
71
+ if (existsSync(sourcePath)) {
72
+ files.push({ path: layer.file, sha256: hashContent(readFileSync(sourcePath, 'utf8')) });
73
+ }
74
+ continue;
75
+ }
76
+ if (existsSync(onDisk)) {
77
+ files.push({ path: layer.file, sha256: hashContent(readFileSync(onDisk, 'utf8')) });
78
+ }
79
+ }
80
+ const unchanged = existing !== null &&
81
+ existing.version === pack.meta.version &&
82
+ report.installed.length === 0 &&
83
+ report.indexUpdated === false;
84
+ if (!opts.dryRun) {
85
+ const record = {
86
+ id,
87
+ version: pack.meta.version,
88
+ // An existing install keeps its original timestamp: it bounds which instances
89
+ // the pack can evidence, and re-running install must not quietly widen that.
90
+ installed_at: existing?.installed_at ?? (opts.now ?? new Date()).toISOString(),
91
+ files,
92
+ };
93
+ writeComplianceConfig(projectRoot, {
94
+ enforce: config.enforce,
95
+ packs: [...config.packs.filter((p) => p.id !== id), record].sort((a, b) => a.id.localeCompare(b.id)),
96
+ });
97
+ }
98
+ return {
99
+ ok: true,
100
+ installed: report.installed,
101
+ alreadyCurrent: report.alreadyCurrent,
102
+ locallyModified: report.locallyModified,
103
+ unchanged,
104
+ warnings: report.warnings,
105
+ };
106
+ }
107
+ /**
108
+ * Remove an installed pack.
109
+ *
110
+ * Deletes only layers whose on-disk hash matches the hash recorded at install.
111
+ * Every registration is dropped either way, so nothing an uninstalled pack owns
112
+ * keeps influencing an agent.
113
+ *
114
+ * Resolution of the pack is **not** required: a pack must remain removable after the
115
+ * content package stops shipping it, which is precisely when a user most wants it
116
+ * gone. The config record alone is enough.
117
+ */
118
+ export function removePack(projectRoot, id, opts = {}) {
119
+ const config = readComplianceConfig(projectRoot);
120
+ const record = findInstalledPack(config, id);
121
+ if (record === null) {
122
+ return {
123
+ ok: false,
124
+ error: {
125
+ code: 'not-found',
126
+ id,
127
+ errors: [
128
+ config.packs.length === 0
129
+ ? `no compliance pack is installed`
130
+ : `pack '${id}' is not installed (installed: ${config.packs.map((p) => p.id).join(', ')})`,
131
+ ],
132
+ },
133
+ };
134
+ }
135
+ const target = guidanceDir(projectRoot);
136
+ const isModified = recordedHashDiffers(record);
137
+ const deleted = [];
138
+ const keptPaths = [];
139
+ const warnings = [];
140
+ // The files to account for are the union of what we recorded and what the pack
141
+ // currently registers.
142
+ //
143
+ // The record alone is not enough. A record whose `files` list is empty or stale —
144
+ // hand-edited, or written before the pack's layer set changed — would leave both
145
+ // the layer file and its index entry on disk while the config record disappeared:
146
+ // an orphaned registration still feeding an uninstalled pack's constraints to every
147
+ // agent, which is exactly the state AC-68 forbids and AC-52 asks doctor to report.
148
+ // Consulting the resolvable pack as well means a drifted record still cleans up.
149
+ const resolved = resolvePack(id);
150
+ const files = new Set(record.files.map((f) => f.path));
151
+ if (resolved.ok) {
152
+ for (const layer of resolved.pack.layers)
153
+ files.add(layer.file);
154
+ }
155
+ for (const file of [...files].sort()) {
156
+ const path = join(target, file);
157
+ if (!existsSync(path)) {
158
+ warnings.push(`.aidlc/guidance/${file} was already gone`);
159
+ continue;
160
+ }
161
+ if (isModified(path, '')) {
162
+ keptPaths.push(`.aidlc/guidance/${file}`);
163
+ continue;
164
+ }
165
+ deleted.push(`.aidlc/guidance/${file}`);
166
+ if (!opts.dryRun)
167
+ rmSync(path);
168
+ }
169
+ // Registrations go regardless. Names come from the index rather than the record,
170
+ // because a record stores filenames and the index is keyed by layer name — so the
171
+ // mapping is read from the index we are about to edit.
172
+ const layerNames = layerNamesForFiles(target, [...files]);
173
+ const unregistered = unregisterLayers(target, layerNames, opts.dryRun !== undefined ? { dryRun: opts.dryRun } : {});
174
+ if (!opts.dryRun) {
175
+ writeComplianceConfig(projectRoot, {
176
+ enforce: config.enforce,
177
+ packs: config.packs.filter((p) => p.id !== id),
178
+ });
179
+ }
180
+ return { ok: true, deleted, keptPaths, unregistered, warnings };
181
+ }
182
+ /**
183
+ * Layer names in the target index that register any of `files`.
184
+ *
185
+ * The config record stores filenames because that is what a hash belongs to; the
186
+ * index is keyed by name. Reading the mapping from the index avoids storing the same
187
+ * relationship twice and lets a renamed registration still be found by its file.
188
+ */
189
+ function layerNamesForFiles(targetDir, files) {
190
+ const wanted = new Set(files);
191
+ const entries = readIndexEntries(join(targetDir, 'index.yaml')) ?? [];
192
+ return entries.filter((e) => wanted.has(e.file)).map((e) => e.name);
193
+ }
194
+ /** Status of every available pack, plus any installed pack that no longer ships. */
195
+ export function packStatuses(projectRoot) {
196
+ const config = readComplianceConfig(projectRoot);
197
+ const target = guidanceDir(projectRoot);
198
+ const statuses = [];
199
+ const errors = [];
200
+ const seen = new Set();
201
+ for (const id of availablePackIds()) {
202
+ const resolved = resolvePack(id);
203
+ if (!resolved.ok) {
204
+ errors.push(resolved.error);
205
+ continue;
206
+ }
207
+ seen.add(id);
208
+ const record = findInstalledPack(config, id);
209
+ statuses.push({
210
+ id,
211
+ regime: resolved.pack.meta.regime,
212
+ available: resolved.pack.meta.version,
213
+ installed: record?.version ?? null,
214
+ stale: isStale(record, resolved.pack.meta.version),
215
+ reviewed: resolved.pack.meta.reviewed_by !== null,
216
+ drifted: driftedFiles(target, record),
217
+ });
218
+ }
219
+ // An installed pack the content package no longer ships still has to appear, or
220
+ // `remove` would be the only way to discover it exists.
221
+ for (const record of config.packs) {
222
+ if (seen.has(record.id))
223
+ continue;
224
+ statuses.push({
225
+ id: record.id,
226
+ regime: record.id,
227
+ available: null,
228
+ installed: record.version,
229
+ stale: false,
230
+ reviewed: false,
231
+ drifted: driftedFiles(target, record),
232
+ });
233
+ }
234
+ return { statuses: statuses.sort((a, b) => a.id.localeCompare(b.id)), errors };
235
+ }
236
+ /** Recorded files whose bytes on disk no longer match the recorded hash. */
237
+ function driftedFiles(targetDir, record) {
238
+ if (record === null)
239
+ return [];
240
+ const isModified = recordedHashDiffers(record);
241
+ return record.files
242
+ .filter((f) => existsSync(join(targetDir, f.path)) && isModified(join(targetDir, f.path), ''))
243
+ .map((f) => `.aidlc/guidance/${f.path}`);
244
+ }
245
+ /**
246
+ * Upgrade an installed pack to the version the content package ships.
247
+ *
248
+ * Deliberately its own command. Neither `aidlc update` nor `aidlc doctor` may do
249
+ * this: pack content is what a buyer is told they are being governed by, and
250
+ * changing it under them without a word is not an upgrade, it is a substitution.
251
+ *
252
+ * A locally edited layer is never overwritten. It is left in place and reported, so
253
+ * the user decides whether to discard their edit.
254
+ */
255
+ export function upgradePack(projectRoot, id, opts = {}) {
256
+ const config = readComplianceConfig(projectRoot);
257
+ const record = findInstalledPack(config, id);
258
+ if (record === null) {
259
+ return {
260
+ ok: false,
261
+ error: { code: 'not-found', id, errors: [`pack '${id}' is not installed`] },
262
+ };
263
+ }
264
+ const resolved = resolvePack(id);
265
+ if (!resolved.ok)
266
+ return { ok: false, error: resolved.error };
267
+ const target = guidanceDir(projectRoot);
268
+ const isModified = recordedHashDiffers(record);
269
+ const replaced = [];
270
+ const keptPaths = [];
271
+ const warnings = [];
272
+ for (const file of record.files) {
273
+ const path = join(target, file.path);
274
+ if (existsSync(path) && isModified(path, '')) {
275
+ keptPaths.push(`.aidlc/guidance/${file.path}`);
276
+ continue;
277
+ }
278
+ replaced.push(`.aidlc/guidance/${file.path}`);
279
+ if (!opts.dryRun && existsSync(path))
280
+ rmSync(path);
281
+ }
282
+ // Re-install writes only what is now absent, which is exactly the set we removed.
283
+ // The record is rewritten with the new version and fresh hashes, and the original
284
+ // `installed_at` is preserved so the report's scope does not move.
285
+ const reinstalled = installPack(projectRoot, id, opts.dryRun !== undefined ? { dryRun: opts.dryRun } : {});
286
+ if (!reinstalled.ok)
287
+ return { ok: false, error: reinstalled.error };
288
+ warnings.push(...reinstalled.warnings);
289
+ return { ok: true, from: record.version, to: resolved.pack.meta.version, replaced, keptPaths, warnings };
290
+ }
291
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/compliance/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,aAAa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IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/C,SAAS;QACX,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,kFAAkF;IAClF,kFAAkF;IAClF,mEAAmE;IACnE,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3G,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC;IACpE,QAAQ,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEvC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAC3G,CAAC"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * The evidence report — the artifact a buyer hands to an auditor.
3
+ *
4
+ * Derived entirely from state already on disk. That is the bet this whole feature
5
+ * rests on: if producing the report required a developer to write anything they would
6
+ * not otherwise write, the remaining feature would be a text file with a command
7
+ * group around it, and the design's stated fallback would be to ship that instead.
8
+ *
9
+ * Three properties are load-bearing, and each exists because its absence would make
10
+ * the report actively misleading:
11
+ *
12
+ * **A checked-only control never carries evidence.** CC8.1 is a control over the
13
+ * change process, and the artifact trail genuinely demonstrates it. The CC6 and CC7
14
+ * controls operate over a running system — no markdown file evidences "the entity
15
+ * monitors system components for anomalies". Reporting design-intent prose as
16
+ * evidence of an operating control is the overclaim this feature exists to prevent,
17
+ * and it would happen in precisely the document least able to survive it.
18
+ *
19
+ * **Absence is reported by name.** A control with no evidence appears as absent, not
20
+ * omitted. A report that silently drops what it could not find reads as a clean bill
21
+ * of health.
22
+ *
23
+ * **The unreviewed-draft notice is emitted from code.** Not copied from pack text: a
24
+ * notice living only in an installed file can be edited away permanently, because a
25
+ * locally edited layer is preserved forever by design.
26
+ *
27
+ * Read-only. Writes nothing under `.aidlc/`, and reads only from an allowlist.
28
+ *
29
+ * Requirements: compliance-packs/AC-30, AC-32, AC-33, AC-34, AC-59, AC-60, AC-61,
30
+ * AC-83, AC-84, AC-85, AC-90, AC-107
31
+ */
32
+ import type { Control, PackMeta } from './types.js';
33
+ /** Why an instance is outside the report's scope. */
34
+ export type ExclusionReason = 'predates-pack' | 'not-complete' | 'filtered';
35
+ /** An instance the report deliberately does not cover. */
36
+ export interface ExcludedInstance {
37
+ instance: string;
38
+ reason: ExclusionReason;
39
+ detail: string;
40
+ }
41
+ /** One finding referenced by a control row. Ids and status only — never bodies. */
42
+ export interface ReportFinding {
43
+ id: string;
44
+ severity: Control['severity'];
45
+ status: string;
46
+ /** Repo-relative path of the findings file. */
47
+ source: string;
48
+ }
49
+ /** One control's row in the report. */
50
+ export interface ControlRow {
51
+ packId: string;
52
+ control: string;
53
+ kind: Control['kind'];
54
+ /** The control's requirement, from the pack. */
55
+ requires: string;
56
+ /**
57
+ * The artifact that evidences this control, repo-relative.
58
+ *
59
+ * Present only on an `evidenced` control. A `checked-only` control has no evidence
60
+ * artifact by construction, and the renderer asserts the field's absence.
61
+ */
62
+ evidenceArtifact?: string;
63
+ /** Whether that evidence was found. `evidenced` controls only. */
64
+ evidenceFound?: boolean;
65
+ /** Findings raised against this control across the in-scope instances. */
66
+ findings: ReportFinding[];
67
+ /** Instances that explicitly recorded this control as checked with no issue. */
68
+ clearedIn: string[];
69
+ }
70
+ /** A pack's section of the report. */
71
+ export interface PackSection {
72
+ meta: PackMeta;
73
+ /** Emitted from code when `reviewed_by` is null. Never copied from pack text. */
74
+ unreviewedNotice: string | null;
75
+ controls: ControlRow[];
76
+ /** Criteria the pack states it does not cover, with the reason it gives. */
77
+ exclusions: {
78
+ id: string;
79
+ reason: string;
80
+ note?: string;
81
+ }[];
82
+ }
83
+ /** The whole report. */
84
+ export interface ComplianceReport {
85
+ generatedAt: string;
86
+ /** Instances the report covers. */
87
+ instances: string[];
88
+ /** Instances left out, each with a reason. Never silently dropped. */
89
+ excluded: ExcludedInstance[];
90
+ packs: PackSection[];
91
+ warnings: string[];
92
+ }
93
+ export interface ReportOptions {
94
+ /** Limit to one instance. */
95
+ instance?: string;
96
+ /** Limit to instances completed on or after this ISO date. */
97
+ since?: string;
98
+ /** Injected clock, for deterministic tests. */
99
+ now?: Date;
100
+ /**
101
+ * Called with every path this module reads.
102
+ *
103
+ * A real seam rather than a test convenience: it is how the read allowlist is
104
+ * *checked* rather than asserted in prose. Without it, "the report reads only
105
+ * these paths" is a claim no test can falsify — and the claim matters, because a
106
+ * report that quietly slurped an unrelated file would be handing a buyer whatever
107
+ * that file contained.
108
+ */
109
+ onRead?: (path: string) => void;
110
+ }
111
+ /**
112
+ * Whether a path is one the report is permitted to read.
113
+ *
114
+ * Exported so a test can assert against the same predicate the module documents,
115
+ * rather than a re-typed copy of it that could drift.
116
+ */
117
+ export declare function isAllowedReadPath(projectRoot: string, path: string): boolean;
118
+ /**
119
+ * The notice text, emitted from code for any pack whose control text is unreviewed.
120
+ *
121
+ * One of the notice's three enforcement points. The others are pack-source validation
122
+ * and a doctor check for the case where someone edits it out of an installed layer.
123
+ */
124
+ export declare function unreviewedNoticeFor(meta: PackMeta): string | null;
125
+ /** The sentence stating what a checked-only control does and does not establish. */
126
+ export declare function checkedOnlyCaveat(controlId: string): string;
127
+ /**
128
+ * Build the report.
129
+ *
130
+ * Reads only: `.aidlc/config.yaml`, each in-scope instance's `instance.yaml` and
131
+ * `phase-*.yaml`, its compliance findings files, and the pack sources through the
132
+ * resolver. Creates and writes nothing.
133
+ */
134
+ export declare function computeComplianceReport(projectRoot: string, opts?: ReportOptions): ComplianceReport;
135
+ /**
136
+ * Render the report as markdown.
137
+ *
138
+ * Every path is already repo-relative by construction. A final assertion checks the
139
+ * home directory does not appear, because that is the decidable form of the guarantee
140
+ * and it does not depend on secret redaction — the redaction helper explicitly does
141
+ * not classify paths as secrets.
142
+ */
143
+ export declare function renderComplianceReport(report: ComplianceReport): string;
144
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/compliance/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAWH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEpD,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,UAAU,CAAC;AAE5E,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uCAAuC;AACvC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OA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