@clossys/launcher 0.3.1 → 0.5.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 (290) hide show
  1. package/README.md +1373 -60
  2. package/contracts/conversation-contract.md +2 -2
  3. package/contracts/product-ci-workflow.yml +74 -0
  4. package/contracts/repository-inventory.json +53 -0
  5. package/dist/admission-fixture.d.ts +168 -0
  6. package/dist/admission-fixture.d.ts.map +1 -0
  7. package/dist/admission-fixture.js +467 -0
  8. package/dist/admission-fixture.js.map +1 -0
  9. package/dist/admission.d.ts +124 -0
  10. package/dist/admission.d.ts.map +1 -0
  11. package/dist/admission.js +804 -0
  12. package/dist/admission.js.map +1 -0
  13. package/dist/agents-guide.d.ts +9 -0
  14. package/dist/agents-guide.d.ts.map +1 -0
  15. package/dist/agents-guide.js +26 -0
  16. package/dist/agents-guide.js.map +1 -0
  17. package/dist/apply-command-options.check.d.ts +12 -0
  18. package/dist/apply-command-options.check.d.ts.map +1 -0
  19. package/dist/apply-command-options.check.js +20 -0
  20. package/dist/apply-command-options.check.js.map +1 -0
  21. package/dist/apply-plan-cli.d.ts +39 -1
  22. package/dist/apply-plan-cli.d.ts.map +1 -1
  23. package/dist/apply-plan-cli.js +432 -15
  24. package/dist/apply-plan-cli.js.map +1 -1
  25. package/dist/apply-plan.d.ts +46 -59
  26. package/dist/apply-plan.d.ts.map +1 -1
  27. package/dist/apply-plan.js +112 -97
  28. package/dist/apply-plan.js.map +1 -1
  29. package/dist/apply-step-fixture.d.ts +87 -0
  30. package/dist/apply-step-fixture.d.ts.map +1 -0
  31. package/dist/apply-step-fixture.js +199 -0
  32. package/dist/apply-step-fixture.js.map +1 -0
  33. package/dist/apply-store.d.ts +93 -0
  34. package/dist/apply-store.d.ts.map +1 -0
  35. package/dist/apply-store.js +625 -0
  36. package/dist/apply-store.js.map +1 -0
  37. package/dist/approval-sheet.d.ts +21 -0
  38. package/dist/approval-sheet.d.ts.map +1 -0
  39. package/dist/approval-sheet.js +163 -0
  40. package/dist/approval-sheet.js.map +1 -0
  41. package/dist/body-command.d.ts +42 -0
  42. package/dist/body-command.d.ts.map +1 -0
  43. package/dist/body-command.js +143 -0
  44. package/dist/body-command.js.map +1 -0
  45. package/dist/change-set-contract.d.ts +403 -0
  46. package/dist/change-set-contract.d.ts.map +1 -0
  47. package/dist/change-set-contract.js +781 -0
  48. package/dist/change-set-contract.js.map +1 -0
  49. package/dist/change-set-digest.d.ts +28 -0
  50. package/dist/change-set-digest.d.ts.map +1 -0
  51. package/dist/change-set-digest.js +65 -0
  52. package/dist/change-set-digest.js.map +1 -0
  53. package/dist/check-cli.d.ts.map +1 -1
  54. package/dist/check-cli.js +14 -3
  55. package/dist/check-cli.js.map +1 -1
  56. package/dist/cli.d.ts +17 -6
  57. package/dist/cli.d.ts.map +1 -1
  58. package/dist/cli.js +84 -23
  59. package/dist/cli.js.map +1 -1
  60. package/dist/core.d.ts +79 -22
  61. package/dist/core.d.ts.map +1 -1
  62. package/dist/core.js +843 -268
  63. package/dist/core.js.map +1 -1
  64. package/dist/dry-materialize.d.ts +63 -0
  65. package/dist/dry-materialize.d.ts.map +1 -0
  66. package/dist/dry-materialize.js +330 -0
  67. package/dist/dry-materialize.js.map +1 -0
  68. package/dist/existing-declaration-adoption.check.d.ts +2 -0
  69. package/dist/existing-declaration-adoption.check.d.ts.map +1 -0
  70. package/dist/existing-declaration-adoption.check.js +10 -0
  71. package/dist/existing-declaration-adoption.check.js.map +1 -0
  72. package/dist/generated/contract-schema.generated.d.ts +97 -0
  73. package/dist/generated/contract-schema.generated.d.ts.map +1 -0
  74. package/dist/generated/contract-schema.generated.js +496 -0
  75. package/dist/generated/contract-schema.generated.js.map +1 -0
  76. package/dist/generated/package-scope.generated.d.ts +6 -0
  77. package/dist/generated/package-scope.generated.d.ts.map +1 -0
  78. package/dist/generated/package-scope.generated.js +10 -0
  79. package/dist/generated/package-scope.generated.js.map +1 -0
  80. package/dist/generated/plan-contracts.generated.d.ts +3 -0
  81. package/dist/generated/plan-contracts.generated.d.ts.map +1 -0
  82. package/dist/generated/plan-contracts.generated.js +3101 -0
  83. package/dist/generated/plan-contracts.generated.js.map +1 -0
  84. package/dist/host.d.ts.map +1 -1
  85. package/dist/host.js +11 -0
  86. package/dist/host.js.map +1 -1
  87. package/dist/identity.d.ts +15 -0
  88. package/dist/identity.d.ts.map +1 -0
  89. package/dist/identity.js +48 -0
  90. package/dist/identity.js.map +1 -0
  91. package/dist/index.d.ts +35 -5
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +19 -2
  94. package/dist/index.js.map +1 -1
  95. package/dist/inventory-adoption.d.ts +24 -5
  96. package/dist/inventory-adoption.d.ts.map +1 -1
  97. package/dist/inventory-adoption.js +70 -25
  98. package/dist/inventory-adoption.js.map +1 -1
  99. package/dist/inventory-choice.d.ts +40 -0
  100. package/dist/inventory-choice.d.ts.map +1 -0
  101. package/dist/inventory-choice.js +156 -0
  102. package/dist/inventory-choice.js.map +1 -0
  103. package/dist/inventory-contract.d.ts +89 -0
  104. package/dist/inventory-contract.d.ts.map +1 -0
  105. package/dist/inventory-contract.js +121 -0
  106. package/dist/inventory-contract.js.map +1 -0
  107. package/dist/key-editor.d.ts +30 -0
  108. package/dist/key-editor.d.ts.map +1 -0
  109. package/dist/key-editor.js +445 -0
  110. package/dist/key-editor.js.map +1 -0
  111. package/dist/ledger-contract.d.ts +190 -0
  112. package/dist/ledger-contract.d.ts.map +1 -0
  113. package/dist/ledger-contract.js +555 -0
  114. package/dist/ledger-contract.js.map +1 -0
  115. package/dist/ledger-trust.d.ts +90 -0
  116. package/dist/ledger-trust.d.ts.map +1 -0
  117. package/dist/ledger-trust.js +203 -0
  118. package/dist/ledger-trust.js.map +1 -0
  119. package/dist/lockfile-invariants.d.ts +48 -0
  120. package/dist/lockfile-invariants.d.ts.map +1 -0
  121. package/dist/lockfile-invariants.js +375 -0
  122. package/dist/lockfile-invariants.js.map +1 -0
  123. package/dist/lockfile-readers.d.ts +72 -0
  124. package/dist/lockfile-readers.d.ts.map +1 -0
  125. package/dist/lockfile-readers.js +713 -0
  126. package/dist/lockfile-readers.js.map +1 -0
  127. package/dist/lockfile-regen.d.ts +106 -0
  128. package/dist/lockfile-regen.d.ts.map +1 -0
  129. package/dist/lockfile-regen.js +760 -0
  130. package/dist/lockfile-regen.js.map +1 -0
  131. package/dist/lockfile-tool-env.d.ts +29 -0
  132. package/dist/lockfile-tool-env.d.ts.map +1 -0
  133. package/dist/lockfile-tool-env.js +111 -0
  134. package/dist/lockfile-tool-env.js.map +1 -0
  135. package/dist/materialize.d.ts +113 -0
  136. package/dist/materialize.d.ts.map +1 -0
  137. package/dist/materialize.js +881 -0
  138. package/dist/materialize.js.map +1 -0
  139. package/dist/observe-repository.d.ts +90 -0
  140. package/dist/observe-repository.d.ts.map +1 -0
  141. package/dist/observe-repository.js +1367 -0
  142. package/dist/observe-repository.js.map +1 -0
  143. package/dist/plan-bundle-setup-fixture.d.ts +68 -0
  144. package/dist/plan-bundle-setup-fixture.d.ts.map +1 -0
  145. package/dist/plan-bundle-setup-fixture.js +167 -0
  146. package/dist/plan-bundle-setup-fixture.js.map +1 -0
  147. package/dist/plan-bundle.d.ts +256 -0
  148. package/dist/plan-bundle.d.ts.map +1 -0
  149. package/dist/plan-bundle.js +882 -0
  150. package/dist/plan-bundle.js.map +1 -0
  151. package/dist/plan-command.d.ts +29 -0
  152. package/dist/plan-command.d.ts.map +1 -0
  153. package/dist/plan-command.js +523 -0
  154. package/dist/plan-command.js.map +1 -0
  155. package/dist/plan-contract.d.ts +153 -0
  156. package/dist/plan-contract.d.ts.map +1 -0
  157. package/dist/plan-contract.js +61 -0
  158. package/dist/plan-contract.js.map +1 -0
  159. package/dist/plan-digest.d.ts +25 -0
  160. package/dist/plan-digest.d.ts.map +1 -0
  161. package/dist/plan-digest.js +106 -0
  162. package/dist/plan-digest.js.map +1 -0
  163. package/dist/plan-rules.d.ts +23 -0
  164. package/dist/plan-rules.d.ts.map +1 -0
  165. package/dist/plan-rules.js +177 -0
  166. package/dist/plan-rules.js.map +1 -0
  167. package/dist/planned-bundle.d.ts +20 -0
  168. package/dist/planned-bundle.d.ts.map +1 -0
  169. package/dist/planned-bundle.js +191 -0
  170. package/dist/planned-bundle.js.map +1 -0
  171. package/dist/product-repository.d.ts +4 -0
  172. package/dist/product-repository.d.ts.map +1 -1
  173. package/dist/product-repository.js +9 -1
  174. package/dist/product-repository.js.map +1 -1
  175. package/dist/provenance-gate.d.ts +48 -0
  176. package/dist/provenance-gate.d.ts.map +1 -0
  177. package/dist/provenance-gate.js +324 -0
  178. package/dist/provenance-gate.js.map +1 -0
  179. package/dist/pull-request-body.d.ts +45 -0
  180. package/dist/pull-request-body.d.ts.map +1 -0
  181. package/dist/pull-request-body.js +232 -0
  182. package/dist/pull-request-body.js.map +1 -0
  183. package/dist/registry-snapshot.d.ts +141 -0
  184. package/dist/registry-snapshot.d.ts.map +1 -0
  185. package/dist/registry-snapshot.js +483 -0
  186. package/dist/registry-snapshot.js.map +1 -0
  187. package/dist/release-age-edit.d.ts +52 -0
  188. package/dist/release-age-edit.d.ts.map +1 -0
  189. package/dist/release-age-edit.js +413 -0
  190. package/dist/release-age-edit.js.map +1 -0
  191. package/dist/root-entries.d.ts +36 -0
  192. package/dist/root-entries.d.ts.map +1 -0
  193. package/dist/root-entries.js +80 -0
  194. package/dist/root-entries.js.map +1 -0
  195. package/dist/setup-template-scripts.d.ts +36 -0
  196. package/dist/setup-template-scripts.d.ts.map +1 -0
  197. package/dist/setup-template-scripts.js +568 -0
  198. package/dist/setup-template-scripts.js.map +1 -0
  199. package/dist/setup-templates.d.ts +55 -0
  200. package/dist/setup-templates.d.ts.map +1 -0
  201. package/dist/setup-templates.js +438 -0
  202. package/dist/setup-templates.js.map +1 -0
  203. package/dist/skills.d.ts +34 -1
  204. package/dist/skills.d.ts.map +1 -1
  205. package/dist/skills.js +129 -17
  206. package/dist/skills.js.map +1 -1
  207. package/dist/status.d.ts +63 -0
  208. package/dist/status.d.ts.map +1 -0
  209. package/dist/status.js +539 -0
  210. package/dist/status.js.map +1 -0
  211. package/dist/types.d.ts +151 -13
  212. package/dist/types.d.ts.map +1 -1
  213. package/package.json +4 -4
  214. package/skeleton/README.md +14 -9
  215. package/skeleton/package.json +2 -1
  216. package/skill/SKILL.md +23 -7
  217. package/skill-catalogue/advisor/SKILL.md +59 -6
  218. package/skill-catalogue/architect/SKILL.md +2 -2
  219. package/skill-catalogue/bouncer/SKILL.md +2 -2
  220. package/skill-catalogue/builder/SKILL.md +2 -2
  221. package/skill-catalogue/butler/SKILL.md +2 -2
  222. package/skill-catalogue/controller/SKILL.md +2 -2
  223. package/skill-catalogue/customer/SKILL.md +2 -2
  224. package/skill-catalogue/designer/SKILL.md +4 -2
  225. package/skill-catalogue/giver/SKILL.md +2 -2
  226. package/skill-catalogue/influencer/SKILL.md +2 -2
  227. package/skill-catalogue/inspector/SKILL.md +2 -2
  228. package/skill-catalogue/integrator/SKILL.md +2 -2
  229. package/skill-catalogue/keeper/SKILL.md +2 -2
  230. package/skill-catalogue/launcher/SKILL.md +23 -7
  231. package/skill-catalogue/locksmith/SKILL.md +2 -2
  232. package/skill-catalogue/messenger/SKILL.md +2 -2
  233. package/skill-catalogue/observer/SKILL.md +2 -2
  234. package/skill-catalogue/publisher/SKILL.md +2 -2
  235. package/skill-catalogue/starter/SKILL.md +3 -2
  236. package/skill-catalogue/strategist/SKILL.md +12 -4
  237. package/skill-catalogue/writer/SKILL.md +2 -2
  238. package/src/admission-fixture.ts +585 -0
  239. package/src/admission.ts +819 -0
  240. package/src/agents-guide.ts +29 -0
  241. package/src/apply-command-options.check.ts +27 -0
  242. package/src/apply-plan-cli.ts +454 -14
  243. package/src/apply-plan.ts +112 -124
  244. package/src/apply-step-fixture.ts +236 -0
  245. package/src/apply-store.ts +584 -0
  246. package/src/approval-sheet.ts +170 -0
  247. package/src/body-command.ts +162 -0
  248. package/src/change-set-contract.ts +987 -0
  249. package/src/change-set-digest.ts +70 -0
  250. package/src/check-cli.ts +14 -3
  251. package/src/cli.ts +90 -22
  252. package/src/core.ts +973 -275
  253. package/src/dry-materialize.ts +353 -0
  254. package/src/existing-declaration-adoption.check.ts +12 -0
  255. package/src/generated/contract-schema.generated.ts +520 -0
  256. package/src/generated/package-scope.generated.ts +10 -0
  257. package/src/generated/plan-contracts.generated.ts +3101 -0
  258. package/src/host.ts +10 -0
  259. package/src/identity.ts +51 -0
  260. package/src/index.ts +74 -3
  261. package/src/inventory-adoption.ts +107 -29
  262. package/src/inventory-choice.ts +172 -0
  263. package/src/inventory-contract.ts +166 -0
  264. package/src/key-editor.ts +446 -0
  265. package/src/ledger-contract.ts +660 -0
  266. package/src/ledger-trust.ts +272 -0
  267. package/src/lockfile-invariants.ts +421 -0
  268. package/src/lockfile-readers.ts +749 -0
  269. package/src/lockfile-regen.ts +851 -0
  270. package/src/lockfile-tool-env.ts +131 -0
  271. package/src/materialize.ts +915 -0
  272. package/src/observe-repository.ts +1365 -0
  273. package/src/plan-bundle-setup-fixture.ts +200 -0
  274. package/src/plan-bundle.ts +1014 -0
  275. package/src/plan-command.ts +532 -0
  276. package/src/plan-contract.ts +179 -0
  277. package/src/plan-digest.ts +102 -0
  278. package/src/plan-rules.ts +188 -0
  279. package/src/planned-bundle.ts +211 -0
  280. package/src/product-repository.ts +10 -1
  281. package/src/provenance-gate.ts +352 -0
  282. package/src/pull-request-body.ts +261 -0
  283. package/src/registry-snapshot.ts +534 -0
  284. package/src/release-age-edit.ts +430 -0
  285. package/src/root-entries.ts +81 -0
  286. package/src/setup-template-scripts.ts +580 -0
  287. package/src/setup-templates.ts +479 -0
  288. package/src/skills.ts +161 -18
  289. package/src/status.ts +557 -0
  290. package/src/types.ts +148 -13
@@ -1,20 +1,44 @@
1
1
  #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { readFileSync, statSync } from "node:fs";
4
+ import { realpathSync } from "node:fs";
5
+ import { dirname, resolve } from "node:path";
2
6
  import { isDirectInvocation } from "./cli.js";
7
+ import { ContractDocumentError, readContractDocument } from "./generated/contract-schema.generated.js";
3
8
  import { createNodeHost } from "./host.js";
4
9
  import { applyEngagementBrief, validateAdvisorPlan, validateEngagementBrief } from "./apply-plan.js";
10
+ import { MAX_RESPONSE_BYTES, REGISTRY_SNAPSHOT_REL, RegistrySnapshotError, requestedPackageNames, takeRegistrySnapshot, writeRegistrySnapshot, } from "./registry-snapshot.js";
11
+ import { listStoredChangeSets } from "./apply-store.js";
12
+ import { planMain } from "./plan-command.js";
13
+ import { BODY_USAGE, BodyUsageError, bodyRepository, parseBodyArgs } from "./body-command.js";
14
+ import { materializeRepository, verifyRepository } from "./materialize.js";
15
+ import { formatStatus, statusRepository } from "./status.js";
5
16
  export const APPLY_PLAN_USAGE = `Usage: launcher-apply-plan --plan <plan.json> --brief <brief.json> --repo <directory>
17
+ launcher-apply-plan plan [--agent codex|claude|cursor] [--adopt-existing <consent.json>] [--help]
18
+ launcher-apply-plan materialize --repo <id>
19
+ launcher-apply-plan verify --repo <id>
20
+ launcher-apply-plan status --repo <id>
21
+ launcher-apply-plan body --repo <id> --task-record <n> [--supersedes <n>]...
22
+ launcher-apply-plan snapshot --request <file> [--out <file>]
23
+
24
+ The plan subcommand is described by launcher-apply-plan plan --help, and the
25
+ snapshot subcommand by launcher-apply-plan snapshot --help.
6
26
 
7
27
  Writes clossys/brief.json into <directory> from the given brief, once the
8
28
  given plan's most recent decision is "approved". Refuses, and writes
9
- nothing, otherwise.
29
+ nothing, otherwise. This is the brief-only path: it does not check what an
30
+ approval binds, so it accepts an approval with or without a subjectDigest.
10
31
 
11
32
  Deterministic mechanics only: this does not decide whether a plan should be
12
33
  approved (that is Advisor's job) and does not compute the brief's content
13
- (that is @clossys/advisor's EngagementBrief, #1193) -- it validates the
14
- exact shapes recorded on issue #1175 and writes the one file.
34
+ (that is @clossys/advisor's EngagementBrief) -- it validates both files
35
+ against the same plan and brief contracts Advisor uses, refusing any field
36
+ those contracts do not declare, writes the one file, and prints the plan's
37
+ canonical digest.
15
38
 
16
39
  Exit codes: 0 = applied, 1 = refused (not approved, or a shape does not
17
- validate), 2 = a given file could not be read as JSON.`;
40
+ validate), 2 = a given file could not be read as strict JSON (unreadable,
41
+ not valid UTF-8, not valid JSON, or an object repeats a key).`;
18
42
  export class ApplyPlanInputError extends Error {
19
43
  }
20
44
  function parseArgs(argv) {
@@ -37,15 +61,25 @@ function parseArgs(argv) {
37
61
  }
38
62
  return { help: false, planPath, briefPath, repoDirectory };
39
63
  }
40
- function readJson(readText, path, label) {
41
- const raw = readText(path);
42
- if (raw === null)
43
- throw new ApplyPlanInputError(`${label} could not be read: ${path}`);
64
+ /**
65
+ * Reads a plan or brief file as strict JSON (#1475): invalid UTF-8, a JSON
66
+ * syntax error, or an object that repeats a key at any depth is refused, so
67
+ * the value validated and digested is exactly the one a reader of the file
68
+ * sees.
69
+ */
70
+ function readJson(path, label) {
71
+ let bytes;
44
72
  try {
45
- return JSON.parse(raw);
73
+ bytes = readFileSync(path);
46
74
  }
47
75
  catch {
48
- throw new ApplyPlanInputError(`${label} is not valid JSON: ${path}`);
76
+ throw new ApplyPlanInputError(`${label} could not be read: ${path}`);
77
+ }
78
+ try {
79
+ return readContractDocument(bytes);
80
+ }
81
+ catch (cause) {
82
+ throw new ApplyPlanInputError(`${label} ${cause instanceof Error ? cause.message : String(cause)}: ${path}`);
49
83
  }
50
84
  }
51
85
  export function main(argv, host) {
@@ -57,8 +91,8 @@ export function main(argv, host) {
57
91
  let planRaw;
58
92
  let briefRaw;
59
93
  try {
60
- planRaw = readJson(host.readText, parsed.planPath, "--plan");
61
- briefRaw = readJson(host.readText, parsed.briefPath, "--brief");
94
+ planRaw = readJson(parsed.planPath, "--plan");
95
+ briefRaw = readJson(parsed.briefPath, "--brief");
62
96
  }
63
97
  catch (cause) {
64
98
  console.error(`launcher-apply-plan: ${cause instanceof Error ? cause.message : String(cause)}`);
@@ -80,11 +114,394 @@ export function main(argv, host) {
80
114
  return 1;
81
115
  }
82
116
  console.log(`wrote ${result.path}`);
117
+ console.log(`plan digest ${result.planDigest}`);
83
118
  return 0;
84
119
  }
85
- function run() {
120
+ export const SNAPSHOT_USAGE = `Usage: launcher-apply-plan snapshot --request <file> [--out <file>]
121
+
122
+ Takes the registry snapshot a plan's exact packages are resolved from
123
+ (#1178). <file> is the report advisor-package-request prints, saved to a
124
+ file: every name in it must be a package in this package's publishing scope,
125
+ named once. For each name, in name order, this fetches the package's full
126
+ registry document from the registry this package was built for, with no
127
+ registry credential, no .npmrc and no npm CLI, refusing any redirect, any response
128
+ over ${MAX_RESPONSE_BYTES / (1024 * 1024)} MiB and any request that takes too long. It records only what
129
+ the registry snapshot contract declares, validates the whole snapshot against
130
+ that contract, and writes it atomically to --out, by default
131
+ ${REGISTRY_SNAPSHOT_REL} under the current directory (the hub).
132
+
133
+ This is the only step of applying a plan that reads the package registry. A
134
+ message names a package by its position in the request, names[<n>], never by
135
+ its name, and never quotes the request or a response.
136
+
137
+ Exit codes: 0 = the snapshot was written (or --help was shown), 2 = no snapshot was written
138
+ (a usage error, an unreadable or invalid request, or any registry answer
139
+ this step cannot record: a transport error, a timeout, a redirect, an
140
+ answer other than 200 or 404, an oversize or non-JSON body, or a snapshot
141
+ the contract refuses). A package the registry does not have (404) is
142
+ recorded as not-found, not refused. On exit 2 an earlier snapshot at the
143
+ output path is left untouched, and must not be used.`;
144
+ const REPO_ID_SHAPE = /^[^/]+\/[^/]+$/u;
145
+ function parseRepoSubcommand(argv, label) {
146
+ if (argv.length === 1 && (argv[0] === "--help" || argv[0] === "-h"))
147
+ return { help: true };
148
+ if (argv.length !== 2 || argv[0] !== "--repo")
149
+ throw new ApplyPlanInputError(`usage: launcher-apply-plan ${label} --repo <id>`);
150
+ const id = argv[1];
151
+ const slash = id.indexOf("/");
152
+ const name = slash === -1 ? "" : id.slice(slash + 1);
153
+ if (!REPO_ID_SHAPE.test(id) || name === "." || name === "..")
154
+ throw new ApplyPlanInputError(`usage: launcher-apply-plan ${label} --repo <id>`);
155
+ return { help: false, id };
156
+ }
157
+ function spawnGit(cwd, args) {
158
+ const run = spawnSync("git", ["-c", "commit.gpgsign=false", "-c", "core.hooksPath=/dev/null", ...args], {
159
+ cwd,
160
+ encoding: "utf8",
161
+ stdio: ["ignore", "pipe", "ignore"],
162
+ });
163
+ if ((run.status ?? 1) !== 0)
164
+ return null;
165
+ return (run.stdout ?? "").trim();
166
+ }
167
+ function resolveApplyInputs(id, options) {
168
+ const hub = options.cwd ?? process.cwd();
169
+ if (options.set !== undefined && options.set.repository.id !== id) {
170
+ return { exitCode: 2, verdict: "indeterminate", reason: "change-set-absent" };
171
+ }
172
+ let held = [];
173
+ try {
174
+ held = listStoredChangeSets(realpathSync(hub));
175
+ }
176
+ catch {
177
+ held = [];
178
+ }
179
+ if (options.heldChangeSets !== undefined)
180
+ held = [...options.heldChangeSets];
181
+ let set = options.set;
182
+ if (set === undefined) {
183
+ const matches = held.filter((entry) => entry.repository.id === id);
184
+ if (matches.length === 0)
185
+ return { exitCode: 2, verdict: "indeterminate", reason: "change-set-absent" };
186
+ if (matches.length === 1) {
187
+ set = matches[0];
188
+ }
189
+ else {
190
+ const clonePath = options.clone ?? resolve(dirname(realpathSync(hub)), id.slice(id.indexOf("/") + 1));
191
+ let root;
192
+ try {
193
+ root = realpathSync(clonePath);
194
+ }
195
+ catch {
196
+ return { exitCode: 2, verdict: "indeterminate", reason: "change-set-absent" };
197
+ }
198
+ const branch = matches[0].repository.defaultBranch;
199
+ const tip = spawnGit(root, ["rev-parse", `refs/heads/${branch}`]);
200
+ if (tip === null)
201
+ return { exitCode: 2, verdict: "indeterminate", reason: "change-set-absent" };
202
+ const filtered = matches.filter((entry) => entry.repository.baseCommit === tip);
203
+ if (filtered.length !== 1)
204
+ return { exitCode: 2, verdict: "indeterminate", reason: "change-set-absent" };
205
+ set = filtered[0];
206
+ }
207
+ }
208
+ const clone = options.clone ?? resolve(dirname(realpathSync(hub)), id.slice(id.indexOf("/") + 1));
209
+ const storedTexts = set.texts === undefined ? {} : Object.fromEntries(set.texts.map((row) => [row.path, row.text]));
210
+ return { hub, clone, set, held, texts: options.texts ?? storedTexts };
211
+ }
212
+ const MATERIALIZE_HELP = `Usage: launcher-apply-plan materialize --repo <id>
213
+
214
+ Writes a stored repository change set into the repository's local clone.
215
+
216
+ Refuses, and writes nothing, unless the plan committed at the hub's HEAD
217
+ approves a bundle that holds the change set, or the change set is an apply set
218
+ admitted under the one-approval rule: it follows the approved setup set and
219
+ changes nothing that approval did not already cover. When the change set has
220
+ package acts, the execution authorization in the hub's committed assessment
221
+ must also be current at the time of the run. The approval a change set's
222
+ ledger records is decided from the hub alone; it is never taken from an
223
+ option or defaulted.`;
224
+ const VERIFY_HELP = `Usage: launcher-apply-plan verify --repo <id>
225
+
226
+ Reports whether the repository's local clone matches its stored change set.
227
+ Verify re-checks everything materialize checks before writing, including the
228
+ committed approval and, for a change set with package acts, that the execution
229
+ authorization is still current at the time of the run: a clone whose approval
230
+ was withdrawn or whose authorization expired no longer verifies.`;
231
+ const STATUS_HELP = `Usage: launcher-apply-plan status --repo <id>
232
+
233
+ Reports what the pull request for the repository's stored change set is doing,
234
+ from read-only evidence: the open pull requests, the default branch's tip, and
235
+ the commits already in the local clone. It needs a full clone: a partial clone
236
+ is refused as indeterminate (partial-clone) before any object is read. It
237
+ changes nothing but the fetch of the default branch into its remote-tracking ref
238
+ that verify also makes: it does not fetch a pull request's head, check anything
239
+ out, or write a file or an index.
240
+
241
+ The state is one of: proposed (an open pull request of this change set, made
242
+ by the person running this, whose body is the one the body command recorded and whose
243
+ head passes every check verify makes),
244
+ applied (the default branch already holds the change set), planned (neither),
245
+ diverged (its pull request or its body does not match), superseded (an older change set of
246
+ this repository has a pull request, even beside this one's) or indeterminate
247
+ (something could not be read or trusted, including a partial clone, a change set
248
+ the body command never recorded a body for, any open pull request whose body names the
249
+ marker word but is not the person's own, and a listing of 100 or more open pull
250
+ requests). It prints the state, a fixed reason
251
+ and #<number> for each pull request it is about, and nothing else. proposed
252
+ does not check the head's ancestry to the base, and nothing in this unit does.
253
+
254
+ Exit codes: 0 = proposed or applied, 1 = diverged, 2 = anything else.`;
255
+ function printApplyOutcome(label, outcome) {
256
+ const suffix = outcome.exitCode === 0 ? outcome.verdict : `${outcome.verdict} (${outcome.reason})`;
257
+ const detail = outcome.detail === undefined ? "" : `; ${outcome.detail}`;
258
+ if (outcome.exitCode === 0)
259
+ console.log(`launcher-apply-plan ${label}: ${suffix}${detail}`);
260
+ else
261
+ console.error(`launcher-apply-plan ${label}: ${suffix}${detail}`);
262
+ return outcome.exitCode;
263
+ }
264
+ export async function materializeMain(argv, options = {}) {
265
+ try {
266
+ const parsed = parseRepoSubcommand(argv, "materialize");
267
+ if (parsed.help) {
268
+ console.log(MATERIALIZE_HELP);
269
+ return 0;
270
+ }
271
+ const resolved = resolveApplyInputs(parsed.id, options);
272
+ if ("exitCode" in resolved)
273
+ return printApplyOutcome("materialize", resolved);
274
+ const outcome = await materializeRepository({
275
+ clone: resolved.clone,
276
+ hub: resolved.hub,
277
+ set: resolved.set,
278
+ texts: resolved.texts,
279
+ heldChangeSets: resolved.held,
280
+ spawn: options.spawn,
281
+ now: options.now,
282
+ toolVersion: options.toolVersion,
283
+ runReadiness: options.runReadiness,
284
+ });
285
+ return printApplyOutcome("materialize", outcome);
286
+ }
287
+ catch (cause) {
288
+ console.error(`launcher-apply-plan materialize: ${cause instanceof ApplyPlanInputError ? cause.message : "usage: launcher-apply-plan materialize --repo <id>"}`);
289
+ return 2;
290
+ }
291
+ }
292
+ export async function verifyMain(argv, options = {}) {
293
+ try {
294
+ const parsed = parseRepoSubcommand(argv, "verify");
295
+ if (parsed.help) {
296
+ console.log(VERIFY_HELP);
297
+ return 0;
298
+ }
299
+ const resolved = resolveApplyInputs(parsed.id, options);
300
+ if ("exitCode" in resolved)
301
+ return printApplyOutcome("verify", resolved);
302
+ const outcome = await verifyRepository({
303
+ clone: resolved.clone,
304
+ hub: resolved.hub,
305
+ set: resolved.set,
306
+ heldChangeSets: resolved.held,
307
+ now: options.now,
308
+ runReadiness: options.runReadiness,
309
+ });
310
+ return printApplyOutcome("verify", outcome);
311
+ }
312
+ catch (cause) {
313
+ console.error(`launcher-apply-plan verify: ${cause instanceof ApplyPlanInputError ? cause.message : "usage: launcher-apply-plan verify --repo <id>"}`);
314
+ return 2;
315
+ }
316
+ }
317
+ export async function statusMain(argv, options = {}) {
318
+ try {
319
+ const parsed = parseRepoSubcommand(argv, "status");
320
+ if (parsed.help) {
321
+ console.log(STATUS_HELP);
322
+ return 0;
323
+ }
324
+ const resolved = resolveApplyInputs(parsed.id, options);
325
+ if ("exitCode" in resolved) {
326
+ console.log(formatStatus({ state: "indeterminate", reason: resolved.reason }));
327
+ return 2;
328
+ }
329
+ const outcome = await statusRepository({
330
+ clone: resolved.clone,
331
+ hub: resolved.hub,
332
+ set: resolved.set,
333
+ heldChangeSets: resolved.held,
334
+ now: options.now,
335
+ runReadiness: options.runReadiness,
336
+ ports: options.statusPorts,
337
+ });
338
+ console.log(formatStatus(outcome));
339
+ return outcome.exitCode;
340
+ }
341
+ catch (cause) {
342
+ console.error(`launcher-apply-plan status: ${cause instanceof ApplyPlanInputError ? cause.message : "usage: launcher-apply-plan status --repo <id>"}`);
343
+ return 2;
344
+ }
345
+ }
346
+ const BODY_HELP = `Usage: ${BODY_USAGE}
347
+
348
+ Prints the body of the pull request for the repository's stored change set, and
349
+ nothing else, and records the SHA-256 of exactly those bytes as the change set's
350
+ pullRequest.bodySha256. The approval the body shows is decided from the hub at
351
+ the time of the run, as materialize decides it; it is never taken from an
352
+ option. A planned bundle the hub stored for the change set must hold that same
353
+ approval. --task-record is the number of the task-record issue in the
354
+ repository; each --supersedes is the number of the pull request of an older
355
+ change set of this repository that this one replaces, and needs another stored
356
+ change set of the repository. A change set already bound to another body is
357
+ refused, and one already bound to this body prints it again. There is no way to
358
+ undo a binding: a mistyped --task-record or --supersedes leaves the change set
359
+ refused as body-bound. Pass the output to the pull request as a file with
360
+ --body-file; --body "$(...)" drops the final line feed the recorded hash covers.
361
+
362
+ Exit codes: 0 = the body was printed, 1 = refused (a fixed token on standard
363
+ error, nothing on standard output), 2 = indeterminate or a usage error.`;
364
+ /**
365
+ * The `body` subcommand. Standard output is the body and only the body, after it is recorded; a refusal prints one line of fixed
366
+ * tokens to standard error and never an argument.
367
+ */
368
+ export async function bodyMain(argv, options = {}) {
369
+ try {
370
+ const parsed = parseBodyArgs(argv);
371
+ if (parsed.help) {
372
+ console.log(BODY_HELP);
373
+ return 0;
374
+ }
375
+ const resolved = resolveApplyInputs(parsed.id, options);
376
+ if ("exitCode" in resolved) {
377
+ console.error(`launcher-apply-plan body: indeterminate (${resolved.reason ?? "refused"})`);
378
+ return 2;
379
+ }
380
+ const outcome = await bodyRepository({
381
+ clone: resolved.clone,
382
+ hub: resolved.hub,
383
+ set: resolved.set,
384
+ heldChangeSets: resolved.held,
385
+ taskRecord: parsed.taskRecord,
386
+ supersedes: parsed.supersedes,
387
+ now: options.now,
388
+ runReadiness: options.runReadiness,
389
+ });
390
+ if (outcome.exitCode !== 0) {
391
+ console.error(`launcher-apply-plan body: ${outcome.exitCode === 1 ? "refused" : "indeterminate"} (${outcome.reason})`);
392
+ return outcome.exitCode;
393
+ }
394
+ process.stdout.write(outcome.body);
395
+ return 0;
396
+ }
397
+ catch (cause) {
398
+ console.error(cause instanceof BodyUsageError ? `launcher-apply-plan body: usage: ${BODY_USAGE}` : "launcher-apply-plan body: indeterminate (body-failed)");
399
+ return 2;
400
+ }
401
+ }
402
+ function parseSnapshotArgs(argv) {
403
+ if (argv.length === 1 && (argv[0] === "--help" || argv[0] === "-h"))
404
+ return { help: true };
405
+ const flags = new Map();
406
+ for (let index = 0; index < argv.length; index += 2) {
407
+ const name = argv[index];
408
+ const value = argv[index + 1];
409
+ if ((name !== "--request" && name !== "--out") || value === undefined || flags.has(name)) {
410
+ throw new RegistrySnapshotError("usage: launcher-apply-plan snapshot --request <file> [--out <file>]");
411
+ }
412
+ flags.set(name, value);
413
+ }
414
+ const requestPath = flags.get("--request");
415
+ if (requestPath === undefined)
416
+ throw new RegistrySnapshotError("--request is required");
417
+ const outPath = flags.get("--out");
418
+ return outPath === undefined ? { help: false, requestPath } : { help: false, requestPath, outPath };
419
+ }
420
+ /** Reads the request strictly; a refusal names the rule and a position, never the file's text. */
421
+ function readSnapshotRequest(path) {
422
+ let bytes;
423
+ try {
424
+ if (!statSync(path).isFile())
425
+ throw new RegistrySnapshotError("the --request file is not a file");
426
+ bytes = readFileSync(path);
427
+ }
428
+ catch (cause) {
429
+ if (cause instanceof RegistrySnapshotError)
430
+ throw cause;
431
+ throw new RegistrySnapshotError("the --request file could not be read");
432
+ }
433
+ try {
434
+ return readContractDocument(bytes);
435
+ }
436
+ catch (cause) {
437
+ if (!(cause instanceof ContractDocumentError))
438
+ throw new RegistrySnapshotError("the --request file is not strict JSON");
439
+ const where = cause.position === undefined ? "" : ` at position ${cause.position}`;
440
+ const why = cause.reason === "encoding" ? "is not valid UTF-8" : cause.reason === "repeated-key" ? "repeats a key in one object" : "is not valid JSON";
441
+ throw new RegistrySnapshotError(`the --request file ${why}${where}`);
442
+ }
443
+ }
444
+ /**
445
+ * The `snapshot` subcommand. Never throws: every refusal prints one line and
446
+ * returns 2, and nothing is written unless the whole snapshot validates.
447
+ */
448
+ export async function snapshotMain(argv, options = {}) {
449
+ try {
450
+ const parsed = parseSnapshotArgs(argv);
451
+ if (parsed.help) {
452
+ console.log(SNAPSHOT_USAGE);
453
+ return 0;
454
+ }
455
+ const cwd = options.cwd ?? process.cwd();
456
+ const names = requestedPackageNames(readSnapshotRequest(resolve(cwd, parsed.requestPath)));
457
+ const snapshot = await takeRegistrySnapshot(names, options);
458
+ const out = resolve(cwd, parsed.outPath ?? REGISTRY_SNAPSHOT_REL);
459
+ try {
460
+ writeRegistrySnapshot(out, snapshot);
461
+ }
462
+ catch (cause) {
463
+ if (cause instanceof RegistrySnapshotError)
464
+ throw cause;
465
+ throw new RegistrySnapshotError(`the snapshot could not be written to ${out}`);
466
+ }
467
+ const notFound = snapshot.packages.filter((entry) => entry.status === "not-found").length;
468
+ console.log(`wrote ${out}: ${snapshot.packages.length} package(s), ${snapshot.packages.length - notFound} found, ${notFound} not found`);
469
+ return 0;
470
+ }
471
+ catch (cause) {
472
+ const reason = cause instanceof RegistrySnapshotError ? cause.message : `failed unexpectedly (${cause instanceof Error ? cause.name : typeof cause})`;
473
+ console.error(`launcher-apply-plan snapshot: ${reason}; no snapshot was written`);
474
+ return 2;
475
+ }
476
+ }
477
+ async function run() {
478
+ const argv = process.argv.slice(2);
479
+ if (argv[0] === "plan") {
480
+ process.exitCode = await planMain(argv.slice(1));
481
+ return;
482
+ }
483
+ if (argv[0] === "materialize") {
484
+ process.exitCode = await materializeMain(argv.slice(1));
485
+ return;
486
+ }
487
+ if (argv[0] === "verify") {
488
+ process.exitCode = await verifyMain(argv.slice(1));
489
+ return;
490
+ }
491
+ if (argv[0] === "status") {
492
+ process.exitCode = await statusMain(argv.slice(1));
493
+ return;
494
+ }
495
+ if (argv[0] === "body") {
496
+ process.exitCode = await bodyMain(argv.slice(1));
497
+ return;
498
+ }
499
+ if (argv[0] === "snapshot") {
500
+ process.exitCode = await snapshotMain(argv.slice(1));
501
+ return;
502
+ }
86
503
  try {
87
- process.exitCode = main(process.argv.slice(2), createNodeHost());
504
+ process.exitCode = main(argv, createNodeHost());
88
505
  }
89
506
  catch (cause) {
90
507
  console.error(`launcher-apply-plan: ${cause instanceof Error ? cause.message : String(cause)}`);
@@ -92,5 +509,5 @@ function run() {
92
509
  }
93
510
  }
94
511
  if (isDirectInvocation(import.meta.url, process.argv[1]))
95
- run();
512
+ void run();
96
513
  //# sourceMappingURL=apply-plan-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-plan-cli.js","sourceRoot":"","sources":["../src/apply-plan-cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;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C3B,OAAO,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AACD,IAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAAE,KAAK,GAAG,EAAE,CAAC"}
@@ -1,71 +1,50 @@
1
+ import type { AdvisorPlan, EngagementBrief } from "./plan-contract.js";
1
2
  import type { WorkspaceHost } from "./types.js";
2
- export interface EngagementBriefRole {
3
- readonly role: string;
4
- readonly why: string;
5
- readonly goal: {
6
- readonly metric: string;
7
- readonly direction: "increase" | "decrease";
8
- };
9
- readonly inputsFrom: readonly string[];
10
- readonly outputsTo: readonly string[];
11
- }
12
- export interface EngagementBrief {
13
- readonly schemaVersion: 1;
14
- readonly problem: string;
15
- readonly roles: readonly EngagementBriefRole[];
16
- readonly sequence: readonly string[];
17
- readonly deliverables: readonly string[];
18
- }
19
- export type BlockerKind = "missing-input" | "missing-authority" | "failing-evidence" | "unavailable-environment" | "contradiction";
20
- export interface PlanBlocker {
21
- readonly kind: BlockerKind;
22
- readonly description: string;
23
- readonly owner: string;
24
- readonly dueDate?: string;
25
- }
26
- export interface PlanDecision {
27
- readonly at: string;
28
- readonly recommended: string;
29
- readonly chosen: string;
30
- readonly by: string;
31
- }
32
- export interface AdvisorPlan {
33
- readonly schemaVersion: 1;
34
- readonly asOf: string;
35
- readonly mandate: {
36
- readonly problem: string;
37
- readonly primaryProblemId: string;
38
- readonly roles: readonly string[];
39
- };
40
- readonly whereWeAre: readonly string[];
41
- readonly recommendedNext: {
42
- readonly action: string;
43
- readonly owner: string;
44
- readonly due: string;
45
- } | null;
46
- readonly decisions: readonly PlanDecision[];
47
- readonly blockers: readonly PlanBlocker[];
48
- }
49
- export type ValidationResult = {
50
- readonly valid: true;
51
- } | {
52
- readonly valid: false;
53
- readonly reason: string;
54
- };
55
- /** Validates an EngagementBrief's shape exactly against the #1175 contract. Never mutates, never re-derives content. */
56
- export declare function validateEngagementBrief(value: unknown): ValidationResult;
57
- /** Validates an AdvisorPlan's shape exactly against the #1175 contract. */
58
- export declare function validateAdvisorPlan(value: unknown): ValidationResult;
3
+ export { validateAdvisorPlan, validateEngagementBrief } from "./plan-contract.js";
4
+ export type { AdvisorPlan, BlockerKind, EngagementBrief, EngagementBriefRole, EngagementContext, EngagementContextField, EngagementContextFieldId, GoalDirection, PlanBlocker, PlanDecision, PlanKit, PlanPackageAct, PlanStaffing, ValidationResult, } from "./plan-contract.js";
5
+ /**
6
+ * What an approval binds (#1178): the `subjectDigest` of the plan's latest
7
+ * decision, by `at`, when that decision has chosen "approved" -- the digest of
8
+ * the exact change the approver was shown. Otherwise null, and null binds
9
+ * nothing. Fails closed:
10
+ *
11
+ * - a plan that does not validate against the plan contract, rules
12
+ * included: null. It checks this itself rather than trusting its caller,
13
+ * because on an unchecked plan a time with no offset parses as local time,
14
+ * so the machine's time zone could decide which decision is latest;
15
+ * - no decisions, or any decision time that does not parse: null;
16
+ * - a latest decision that is not "approved": null;
17
+ * - an approval with no `subjectDigest`, or one that is not a sha256 digest:
18
+ * null -- an approval that names no bytes approves no bytes;
19
+ * - several decisions at the latest instant: their subject only when every
20
+ * one of them is "approved" with the same `subjectDigest`, else null.
21
+ *
22
+ * It says what was approved, not whether that is what is about to be applied:
23
+ * the caller recomputes the digest of the change it holds and refuses unless
24
+ * the two are equal.
25
+ */
26
+ export declare function approvedSubject(plan: AdvisorPlan): string | null;
59
27
  /**
60
28
  * The plan is approved when its most recent decision (by `at`) records
61
29
  * chosen === "approved". No decisions, or a most-recent decision that
62
30
  * isn't "approved", is not approved -- this never assumes approval from
63
- * absence.
31
+ * absence. Fails closed on anything that would let array order decide
32
+ * instead of time: a decision whose `at` does not parse to a finite time
33
+ * (the plan contract already refuses one; this does not rely on that), or
34
+ * two decisions at the same latest instant that do not all say "approved".
35
+ *
36
+ * It binds no bytes (#1178): it does not look at `subjectDigest`, so it is
37
+ * true for an approval that names no change at all. It says only that the
38
+ * latest decision is an approval. Anything that applies a plan must use
39
+ * `approvedSubject()` instead, and compare the subject it returns with the
40
+ * digest of the change it holds. The one stated exception is the legacy
41
+ * brief-only path, `applyEngagementBrief()`, which predates the binding.
64
42
  */
65
43
  export declare function isPlanApproved(plan: AdvisorPlan): boolean;
66
44
  export type ApplyBriefResult = {
67
45
  readonly state: "applied";
68
46
  readonly path: string;
47
+ readonly planDigest: string;
69
48
  } | {
70
49
  readonly state: "refused";
71
50
  readonly reason: string;
@@ -73,7 +52,15 @@ export type ApplyBriefResult = {
73
52
  /**
74
53
  * Writes clossys/brief.json into `repositoryDirectory`, byte-identically
75
54
  * from the validated brief -- never re-authors its prose. Refuses (does
76
- * not write) unless both the plan is approved and the brief validates.
55
+ * not write) unless the plan validates and is approved and the brief,
56
+ * including its context snapshot, validates. Reports the canonical digest
57
+ * of the plan it applied.
58
+ *
59
+ * LEGACY (#1178): this path predates the approval binding. It accepts an
60
+ * approval whether or not it carries a `subjectDigest` and checks no
61
+ * binding (it uses `isPlanApproved()`), exactly as before; it is kept
62
+ * working, not extended. Anything that must know what an approval binds uses
63
+ * `approvedSubject()`.
77
64
  */
78
65
  export declare function applyEngagementBrief(host: WorkspaceHost, repositoryDirectory: string, plan: AdvisorPlan, brief: EngagementBrief, briefRelPath: string): ApplyBriefResult;
79
66
  //# sourceMappingURL=apply-plan.d.ts.map