@crewbie/cli 0.1.0-alpha.49

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 (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +253 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +506 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/config.d.ts +84 -0
  7. package/dist/config.js +178 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/core.d.ts +31 -0
  10. package/dist/core.js +186 -0
  11. package/dist/core.js.map +1 -0
  12. package/dist/execution/attribution.d.ts +10 -0
  13. package/dist/execution/attribution.js +102 -0
  14. package/dist/execution/attribution.js.map +1 -0
  15. package/dist/execution/cancel.d.ts +3 -0
  16. package/dist/execution/cancel.js +59 -0
  17. package/dist/execution/cancel.js.map +1 -0
  18. package/dist/execution/capabilities.d.ts +22 -0
  19. package/dist/execution/capabilities.js +101 -0
  20. package/dist/execution/capabilities.js.map +1 -0
  21. package/dist/execution/controls.d.ts +51 -0
  22. package/dist/execution/controls.js +257 -0
  23. package/dist/execution/controls.js.map +1 -0
  24. package/dist/execution/dispatch.d.ts +69 -0
  25. package/dist/execution/dispatch.js +831 -0
  26. package/dist/execution/dispatch.js.map +1 -0
  27. package/dist/execution/fix.d.ts +3 -0
  28. package/dist/execution/fix.js +267 -0
  29. package/dist/execution/fix.js.map +1 -0
  30. package/dist/execution/github.d.ts +15 -0
  31. package/dist/execution/github.js +43 -0
  32. package/dist/execution/github.js.map +1 -0
  33. package/dist/execution/merge.d.ts +15 -0
  34. package/dist/execution/merge.js +133 -0
  35. package/dist/execution/merge.js.map +1 -0
  36. package/dist/execution/planning-approval.d.ts +33 -0
  37. package/dist/execution/planning-approval.js +227 -0
  38. package/dist/execution/planning-approval.js.map +1 -0
  39. package/dist/execution/pr-review.d.ts +86 -0
  40. package/dist/execution/pr-review.js +339 -0
  41. package/dist/execution/pr-review.js.map +1 -0
  42. package/dist/execution/review-loop.d.ts +63 -0
  43. package/dist/execution/review-loop.js +463 -0
  44. package/dist/execution/review-loop.js.map +1 -0
  45. package/dist/execution/test-feature.d.ts +29 -0
  46. package/dist/execution/test-feature.js +240 -0
  47. package/dist/execution/test-feature.js.map +1 -0
  48. package/dist/execution/watch.d.ts +12 -0
  49. package/dist/execution/watch.js +34 -0
  50. package/dist/execution/watch.js.map +1 -0
  51. package/dist/memory/context.d.ts +14 -0
  52. package/dist/memory/context.js +82 -0
  53. package/dist/memory/context.js.map +1 -0
  54. package/dist/memory/improvement.d.ts +25 -0
  55. package/dist/memory/improvement.js +168 -0
  56. package/dist/memory/improvement.js.map +1 -0
  57. package/dist/memory/launch.d.ts +9 -0
  58. package/dist/memory/launch.js +65 -0
  59. package/dist/memory/launch.js.map +1 -0
  60. package/dist/memory/runner.d.ts +4 -0
  61. package/dist/memory/runner.js +74 -0
  62. package/dist/memory/runner.js.map +1 -0
  63. package/dist/memory/state.d.ts +10 -0
  64. package/dist/memory/state.js +42 -0
  65. package/dist/memory/state.js.map +1 -0
  66. package/dist/presentation.d.ts +19 -0
  67. package/dist/presentation.js +128 -0
  68. package/dist/presentation.js.map +1 -0
  69. package/dist/reporting/dashboard.d.ts +2 -0
  70. package/dist/reporting/dashboard.js +106 -0
  71. package/dist/reporting/dashboard.js.map +1 -0
  72. package/dist/reporting/pr-usage.d.ts +24 -0
  73. package/dist/reporting/pr-usage.js +179 -0
  74. package/dist/reporting/pr-usage.js.map +1 -0
  75. package/dist/reporting/records.d.ts +28 -0
  76. package/dist/reporting/records.js +152 -0
  77. package/dist/reporting/records.js.map +1 -0
  78. package/dist/setup/agents.d.ts +8 -0
  79. package/dist/setup/agents.js +83 -0
  80. package/dist/setup/agents.js.map +1 -0
  81. package/dist/setup/assessment.d.ts +31 -0
  82. package/dist/setup/assessment.js +75 -0
  83. package/dist/setup/assessment.js.map +1 -0
  84. package/dist/setup/auto-loaded.d.ts +17 -0
  85. package/dist/setup/auto-loaded.js +49 -0
  86. package/dist/setup/auto-loaded.js.map +1 -0
  87. package/dist/setup/copilot-version.d.ts +7 -0
  88. package/dist/setup/copilot-version.js +39 -0
  89. package/dist/setup/copilot-version.js.map +1 -0
  90. package/dist/setup/copilot.d.ts +22 -0
  91. package/dist/setup/copilot.js +164 -0
  92. package/dist/setup/copilot.js.map +1 -0
  93. package/dist/setup/init.d.ts +41 -0
  94. package/dist/setup/init.js +315 -0
  95. package/dist/setup/init.js.map +1 -0
  96. package/dist/setup/install.d.ts +12 -0
  97. package/dist/setup/install.js +211 -0
  98. package/dist/setup/install.js.map +1 -0
  99. package/dist/setup/instruction-quality.d.ts +25 -0
  100. package/dist/setup/instruction-quality.js +258 -0
  101. package/dist/setup/instruction-quality.js.map +1 -0
  102. package/dist/setup/inventory.d.ts +26 -0
  103. package/dist/setup/inventory.js +78 -0
  104. package/dist/setup/inventory.js.map +1 -0
  105. package/dist/setup/onboarding.d.ts +40 -0
  106. package/dist/setup/onboarding.js +472 -0
  107. package/dist/setup/onboarding.js.map +1 -0
  108. package/dist/setup/package.d.ts +2 -0
  109. package/dist/setup/package.js +8 -0
  110. package/dist/setup/package.js.map +1 -0
  111. package/dist/setup/planning-workflow.d.ts +3 -0
  112. package/dist/setup/planning-workflow.js +250 -0
  113. package/dist/setup/planning-workflow.js.map +1 -0
  114. package/dist/setup/repository-map.d.ts +34 -0
  115. package/dist/setup/repository-map.js +89 -0
  116. package/dist/setup/repository-map.js.map +1 -0
  117. package/dist/setup/review.d.ts +8 -0
  118. package/dist/setup/review.js +137 -0
  119. package/dist/setup/review.js.map +1 -0
  120. package/dist/setup/team.d.ts +18 -0
  121. package/dist/setup/team.js +172 -0
  122. package/dist/setup/team.js.map +1 -0
  123. package/dist/setup/templates.d.ts +11 -0
  124. package/dist/setup/templates.js +494 -0
  125. package/dist/setup/templates.js.map +1 -0
  126. package/dist/setup/terminal.d.ts +12 -0
  127. package/dist/setup/terminal.js +11 -0
  128. package/dist/setup/terminal.js.map +1 -0
  129. package/dist/setup/update.d.ts +6 -0
  130. package/dist/setup/update.js +71 -0
  131. package/dist/setup/update.js.map +1 -0
  132. package/dist/specification/batch.d.ts +50 -0
  133. package/dist/specification/batch.js +127 -0
  134. package/dist/specification/batch.js.map +1 -0
  135. package/dist/specification/plan-checks.d.ts +6 -0
  136. package/dist/specification/plan-checks.js +73 -0
  137. package/dist/specification/plan-checks.js.map +1 -0
  138. package/dist/specification/planning.d.ts +26 -0
  139. package/dist/specification/planning.js +507 -0
  140. package/dist/specification/planning.js.map +1 -0
  141. package/dist/specification/prose.d.ts +1 -0
  142. package/dist/specification/prose.js +15 -0
  143. package/dist/specification/prose.js.map +1 -0
  144. package/dist/tracking/ado.d.ts +19 -0
  145. package/dist/tracking/ado.js +128 -0
  146. package/dist/tracking/ado.js.map +1 -0
  147. package/dist/tracking/github.d.ts +8 -0
  148. package/dist/tracking/github.js +112 -0
  149. package/dist/tracking/github.js.map +1 -0
  150. package/dist/tracking/issues.d.ts +28 -0
  151. package/dist/tracking/issues.js +180 -0
  152. package/dist/tracking/issues.js.map +1 -0
  153. package/dist/tracking/native.d.ts +5 -0
  154. package/dist/tracking/native.js +30 -0
  155. package/dist/tracking/native.js.map +1 -0
  156. package/dist/tracking/refs.d.ts +14 -0
  157. package/dist/tracking/refs.js +56 -0
  158. package/dist/tracking/refs.js.map +1 -0
  159. package/dist/tracking/sources.d.ts +5 -0
  160. package/dist/tracking/sources.js +29 -0
  161. package/dist/tracking/sources.js.map +1 -0
  162. package/docs/operations.md +1114 -0
  163. package/examples/batch.json +27 -0
  164. package/examples/runs.json +22 -0
  165. package/package.json +50 -0
@@ -0,0 +1,315 @@
1
+ import { json, optionalText, readJson, record, safePath, string, textHash, writeAtomic } from "../core.js";
2
+ import { modelProfile, parseConfig } from "../config.js";
3
+ import { cloudAgentAccepts } from "../execution/controls.js";
4
+ import { requireWriter } from "../tracking/github.js";
5
+ import { ensureLabels, setupLabels } from "../tracking/issues.js";
6
+ import { assess } from "./assessment.js";
7
+ import { applyInstallation, installation, setupConfiguration } from "./install.js";
8
+ import { proposeSetup, selectGuidance } from "./onboarding.js";
9
+ import { explicitModel, listCopilotModels } from "./copilot.js";
10
+ import { describeInstallationFile, renderInstallationPreview, renderSetupMarkdown, setupReportPath } from "./review.js";
11
+ import { terminalPrompts } from "./terminal.js";
12
+ import { COPILOT_VERSION_VARIABLE, copilotVersion as copilotVersionOf, copilotVersionCommand, copilotVersionVariable, setCopilotVersion } from "./copilot-version.js";
13
+ import { suggestedStartCommand } from "../execution/test-feature.js";
14
+ async function planningVariable(client, repository, version) {
15
+ let existing;
16
+ try {
17
+ existing = await copilotVersionVariable(client, repository);
18
+ if (existing)
19
+ return `Hosted planning uses Copilot CLI ${existing} (${COPILOT_VERSION_VARIABLE}).`;
20
+ if (version) {
21
+ await setCopilotVersion(client, repository, version);
22
+ return `${COPILOT_VERSION_VARIABLE} set to ${version} for hosted planning.`;
23
+ }
24
+ }
25
+ catch (error) {
26
+ return `Could not check or set ${COPILOT_VERSION_VARIABLE} (${error instanceof Error ? error.message : "GitHub request failed"}). Hosted planning fails until it is set: ${copilotVersionCommand(repository, version)}`;
27
+ }
28
+ return `Hosted planning fails until an approved Copilot CLI version is set: ${copilotVersionCommand(repository)}`;
29
+ }
30
+ export async function installSetup(root, value, options, client) {
31
+ const raw = record(value, "setup proposal");
32
+ if (raw.status === "clarification")
33
+ throw new Error("Answer the setup questions and rerun init before creating a team.");
34
+ const config = setupConfiguration(raw);
35
+ const existingConstitution = config.constitution && await optionalText(await safePath(root, config.constitution)) !== null ? config.constitution : null;
36
+ const proposal = options.guidance === "apply" ? { ...raw, config } : {
37
+ ...raw, instructions: [], constitutionText: null,
38
+ config: { ...config, constitution: raw.constitutionText ? existingConstitution : config.constitution },
39
+ };
40
+ const kept = [];
41
+ const changes = await installation(root, proposal, undefined, kept);
42
+ const labels = options.skipLabels ? [] : setupLabels(config);
43
+ const copilotVersion = options.copilotVersion === undefined ? undefined : copilotVersionOf(options.copilotVersion);
44
+ const planning = config.planning?.enabled === true && !options.skipLabels;
45
+ if (!options.apply)
46
+ return options.json ? json({ files: changes.map(describeInstallationFile), kept, labels, repository: config.repository, ...(planning && copilotVersion ? { copilotVersion } : {}) })
47
+ : renderInstallationPreview(changes, labels, config.repository, kept)
48
+ + (planning && copilotVersion ? `\nACTIONS VARIABLE | ${COPILOT_VERSION_VARIABLE}=${copilotVersion} if unset` : "");
49
+ if (!options.skipLabels) {
50
+ if (!config.repository)
51
+ throw new Error("Set repository before creating GitHub labels, or explicitly use --skip-labels for offline setup.");
52
+ if (!client)
53
+ throw new Error("GitHub authentication is required to create setup labels.");
54
+ await requireWriter(client, config.repository);
55
+ }
56
+ await applyInstallation(root, changes);
57
+ if (!options.skipLabels && client) {
58
+ try {
59
+ await ensureLabels(client, config);
60
+ }
61
+ catch (error) {
62
+ throw new Error(`Local setup was applied, but GitHub labels are incomplete. Rerun the same init --proposal ... --apply command; matching labels are preserved. ${error instanceof Error ? error.message : "Label creation failed."}`);
63
+ }
64
+ }
65
+ const variable = planning && client ? ` ${await planningVariable(client, config.repository, copilotVersion)}` : "";
66
+ return `Applied ${changes.length} reviewed file changes (${changes.filter((change) => change.before !== null && change.after !== null).length} existing files updated, ${changes.filter((change) => change.after === null).length} original agents archived). ${options.skipLabels ? "GitHub labels explicitly skipped." : "All Crewbie workflow and specialist labels are available."}${variable}`;
67
+ }
68
+ export async function initCommand(root, options, io) {
69
+ const report = io.report ?? console.log;
70
+ const terminal = !io.ask && !options.json && process.stdin.isTTY && process.stdout.isTTY ? terminalPrompts() : undefined;
71
+ const ask = io.ask ?? terminal?.ask;
72
+ const select = io.select ?? terminal?.select;
73
+ const confirm = io.confirm ?? terminal?.confirm;
74
+ try {
75
+ if (options.guidance !== undefined && !["apply", "skip"].includes(options.guidance))
76
+ throw new Error("--guidance must be apply or skip.");
77
+ if (options.approver !== undefined)
78
+ throw new Error("--approver is no longer supported; repository write access authorizes setup.");
79
+ if (options["model-policy"] !== undefined && !["fixed", "cost-aware"].includes(options["model-policy"]))
80
+ throw new Error("--model-policy must be fixed or cost-aware.");
81
+ if (options["model-profile"] !== undefined)
82
+ modelProfile(options["model-profile"]);
83
+ if (options.start !== undefined)
84
+ parseConfig({ schemaVersion: 1, repository: "", roles: [{ id: "developer", purpose: "Validate start.", model: "model" }], constitution: null, maxActive: 1, nightly: { enabled: false, maxRecords: 1, allowedPaths: [] }, ado: null, local: { start: options.start } });
85
+ if (options["assessment-only"] && (options.proposal || options.apply || options.guidance))
86
+ throw new Error("--assessment-only cannot apply setup or guidance.");
87
+ if (options.proposal) {
88
+ const proposal = record(await readJson(await safePath(root, options.proposal)), "setup proposal");
89
+ if (proposal.review && !options.json) {
90
+ const review = record(proposal.review, "setup review");
91
+ report(string(review.summary, "assessment summary"));
92
+ }
93
+ const markdown = setupReportPath(options.proposal);
94
+ await writeAtomic(root, markdown, renderSetupMarkdown(proposal));
95
+ if (!options.json)
96
+ report(`Readable assessment: ${markdown}`);
97
+ const hasGuidance = (Array.isArray(proposal.instructions) && proposal.instructions.length > 0) || proposal.constitutionText;
98
+ if (!hasGuidance && !options.json)
99
+ report("No existing guidance edits proposed; recommendations in the assessment are advisory only.");
100
+ let guidance = options.guidance;
101
+ if (options.apply && hasGuidance && !guidance && select)
102
+ guidance = await select("Apply proposed guidance and constitution too?", [
103
+ { value: "skip", name: "Team only", description: "Keep existing guidance unchanged." },
104
+ { value: "apply", name: "Team + guidance", description: "Apply the concrete replacements in the reviewed proposal." },
105
+ ], "skip");
106
+ else if (options.apply && hasGuidance && !guidance && ask)
107
+ guidance = (await ask("Apply proposed guidance/constitution too? Enter apply or skip (team only).")).trim();
108
+ if (options.apply && hasGuidance && !guidance)
109
+ throw new Error("Choose --guidance apply or --guidance skip; guidance changes need a separate decision.");
110
+ if (guidance && !["apply", "skip"].includes(guidance))
111
+ throw new Error("Choose apply or skip for guidance.");
112
+ report(await installSetup(root, proposal, {
113
+ apply: options.apply === true, guidance: guidance === "skip" ? "skip" : "apply", skipLabels: options["skip-labels"] === true, json: options.json === true,
114
+ copilotVersion: options["copilot-version"],
115
+ }, options.apply && !options["skip-labels"] ? io.client() : undefined));
116
+ return;
117
+ }
118
+ if (options.apply)
119
+ throw new Error("Use --proposal with --apply; review the generated setup before noninteractive installation.");
120
+ const assessment = await assess(root);
121
+ if (options.update && assessment.configBeforeHash === null)
122
+ throw new Error("No installed crew to reassess. Run init without --update first.");
123
+ if (options.repo !== undefined)
124
+ assessment.config.repository = options.repo;
125
+ if (options["model-profile"] !== undefined)
126
+ assessment.config.modelProfile = modelProfile(options["model-profile"]);
127
+ assessment.config = parseConfig(assessment.config);
128
+ if (options["assessment-only"]) {
129
+ if (options.out)
130
+ await writeAtomic(root, options.out, json(assessment));
131
+ report(json(assessment));
132
+ return;
133
+ }
134
+ if (!options.json)
135
+ report(`\nCrewbie | Setup\n${options.update ? "Reassess the installed team" : "Build a repository-specific team"}\n\n1. Assess > 2. Review > 3. Apply\n`);
136
+ let model = options.model ?? "";
137
+ let catalog;
138
+ if (!model && ask) {
139
+ const models = await (io.listModels ?? listCopilotModels)();
140
+ catalog = models;
141
+ if (!models.length)
142
+ throw new Error("No available models were returned. Check Copilot access before onboarding.");
143
+ if (select) {
144
+ model = await select("Assessment model (specialist models are reviewed separately)", models.map((choice) => ({
145
+ value: choice.id, name: `${choice.name} (${choice.id})`,
146
+ description: choice.multiplier === undefined ? "Billing multiplier unavailable; assessment may consume AI credits." : `${choice.multiplier}x billing multiplier; not a token-price estimate.`,
147
+ })), models[0].id);
148
+ if (!models.some((choice) => choice.id === model))
149
+ throw new Error("Choose an assessment model from the inspected catalog.");
150
+ }
151
+ else {
152
+ report("Choose a Copilot model for the assessment (specialist choices are reviewed separately):\n" + models.map((choice, index) => `${index + 1}. ${choice.name} (${choice.id})${choice.multiplier === undefined ? "" : ` - ${choice.multiplier}x billing multiplier`}`).join("\n"));
153
+ while (!model) {
154
+ const selected = (await ask("Enter a model number or an exact model ID from the list (q to cancel).")).trim();
155
+ if (selected.toLowerCase() === "q")
156
+ throw new Error("Setup cancelled before analysis. No files or labels were changed.");
157
+ const choice = /^\d+$/.test(selected) ? models[Number(selected) - 1] : models.find((item) => item.id === selected);
158
+ if (choice)
159
+ model = choice.id;
160
+ else
161
+ report("Invalid choice. Select one of the listed models.");
162
+ }
163
+ }
164
+ }
165
+ if (!model)
166
+ throw new Error("Use --model MODEL for LLM onboarding, or --assessment-only for offline inventory.");
167
+ const dynamic = options["model-policy"] !== "fixed" && !options["specialist-model"];
168
+ if (dynamic)
169
+ catalog ??= await (io.listModels ?? listCopilotModels)();
170
+ if (dynamic && !catalog?.length)
171
+ throw new Error("No available models were returned for specialist selection.");
172
+ if (options["specialist-model"])
173
+ explicitModel(options["specialist-model"]);
174
+ let description = options.description ?? "";
175
+ if (!description && assessment.inventory.mode === "greenfield" && ask) {
176
+ description = await ask("Describe the greenfield project: purpose, users, main behavior, platform/stack (or freedom to choose), and constraints.");
177
+ }
178
+ if (!ask && !description.trim() && assessment.inventory.mode === "greenfield") {
179
+ throw new Error("Greenfield setup needs a project description. Rerun init --description \"purpose, users, behavior, platform and constraints\"; no team was generated.");
180
+ }
181
+ report(`\n1. Assess\n Model: ${model}\n Reviewing instructions, agents, constitution and MCP metadata; application code and project files are not read, only their names are mapped to check cited paths.\n This may take several minutes and consume AI credits; press Ctrl+C to cancel.\n No project scripts or MCP servers are run; installation requires confirmation.\n`);
182
+ const propose = () => proposeSetup(assessment, description, model, {
183
+ ...(io.analyze ? { analyze: io.analyze } : {}), ...(ask ? { ask } : {}), report,
184
+ models: dynamic ? catalog ?? [] : [], specialistModel: options["specialist-model"] ?? model,
185
+ });
186
+ let proposal = await propose();
187
+ if (options.start !== undefined)
188
+ proposal.config.local = { start: parseConfig({ ...proposal.config, local: { start: options.start } }).local.start };
189
+ else if (!proposal.config.local?.start && terminal?.ask) {
190
+ const suggestion = await suggestedStartCommand(root);
191
+ const prompt = suggestion
192
+ ? `Command to start the app locally when testing a feature? Press Enter for ${suggestion}. Leave empty to skip.`
193
+ : "Command to start the app locally when testing a feature? Leave empty to skip.";
194
+ const answer = (await terminal.ask(prompt)).trim() || suggestion || "";
195
+ if (answer)
196
+ proposal.config.local = { start: parseConfig({ ...proposal.config, local: { start: answer } }).local.start };
197
+ }
198
+ // The CLI catalog includes models the cloud agent rejects; check only the chosen ones, since each check leaves a failed task.
199
+ const checked = new Map();
200
+ while (proposal.status === "ready" && proposal.config.repository) {
201
+ const installed = new Map(assessment.installedRoles.map((role) => [role.id, role.model]));
202
+ const unchecked = [...new Set(proposal.config.roles.map((role) => role.model))].filter((id) => !checked.has(id));
203
+ if (unchecked.length) {
204
+ let client;
205
+ try {
206
+ client = io.client();
207
+ }
208
+ catch {
209
+ report(" Cloud-agent model support not checked (no GitHub credential); dispatch checks it before launch.");
210
+ break;
211
+ }
212
+ for (const id of unchecked)
213
+ checked.set(id, await cloudAgentAccepts(client, proposal.config.repository, id));
214
+ }
215
+ const kept = proposal.config.roles.filter((role) => installed.get(role.id) === role.model && checked.get(role.model) === false);
216
+ for (const role of kept)
217
+ report(` Warning: the Copilot cloud agent rejects installed model ${role.model} for ${role.id}; its launches stay blocked until you choose another model for it.`);
218
+ const rejected = [...new Set(proposal.config.roles.filter((role) => installed.get(role.id) !== role.model && checked.get(role.model) === false).map((role) => role.model))];
219
+ if (!rejected.length)
220
+ break;
221
+ if (!dynamic)
222
+ throw new Error(`The Copilot cloud agent rejects specialist model ${rejected.join(", ")} for this account, although the CLI lists it. Choose another --specialist-model; no team was installed.`);
223
+ catalog = (catalog ?? []).filter((choice) => !rejected.includes(choice.id));
224
+ if (!catalog.length)
225
+ throw new Error("The Copilot cloud agent accepts none of the catalog models for this account; no team was installed.");
226
+ report(` The Copilot cloud agent rejects ${rejected.join(", ")} for this account, although the CLI lists it. Reassessing without it.`);
227
+ proposal = await propose();
228
+ }
229
+ const output = options.out ?? "crewbie-setup.json";
230
+ const markdown = setupReportPath(output);
231
+ await writeAtomic(root, output, json(proposal));
232
+ await writeAtomic(root, markdown, renderSetupMarkdown(proposal));
233
+ report(`\nSaved for review\n Assessment: ${markdown}\n Editable setup: ${output}\n`);
234
+ if (proposal.status === "clarification") {
235
+ throw new Error(`Setup needs clarification; questions saved in ${output}. Rerun init with an expanded --description. No team was installed.`);
236
+ }
237
+ if (!ask) {
238
+ report(`Assessment and tailored team saved to ${output}. Review, then run init --proposal ${output} --apply --guidance apply|skip. GitHub labels are created on apply.`);
239
+ return;
240
+ }
241
+ const choices = [
242
+ { value: "team", name: "Team", description: "Adopt/create the proposed agents; leave existing guidance unchanged." },
243
+ { value: "all", name: "All", description: `Create the team and apply ${proposal.instructions.length} guidance edits${proposal.constitutionText ? " plus the proposed constitution" : ""}.` },
244
+ { value: "save", name: "Save", description: "Keep the assessment and proposal for later. No installation or GitHub changes." },
245
+ ];
246
+ const choice = select ? await select("Install this proposal?", choices, "save")
247
+ : (await ask(`Install this proposal? Enter team (adopt/create agents; skip guidance edits), all (also apply ${proposal.instructions.length} guidance edits${proposal.constitutionText ? " and the proposed constitution" : ""}), or save (no installation).`)).trim().toLowerCase();
248
+ if (!["team", "all", "save"].includes(choice))
249
+ throw new Error(`Unknown choice; proposal saved to ${output}. Nothing installed.`);
250
+ if (choice === "save") {
251
+ report(`Saved only. No files installed or GitHub labels changed.\nResume: crewbie init --proposal "${output}" --apply --guidance apply|skip`);
252
+ return;
253
+ }
254
+ if (!proposal.config.planning?.enabled) {
255
+ let planning;
256
+ const message = `Enable hosted planning using ${model}? New installations allow paid implementation after your exact-head approval and merge; existing execution opt-outs are preserved.`;
257
+ if (confirm)
258
+ planning = await confirm(message, false) ? "yes" : "no";
259
+ else {
260
+ do {
261
+ planning = (await ask(`${message} Enter yes or no.`)).trim().toLowerCase();
262
+ } while (!["yes", "no"].includes(planning));
263
+ }
264
+ if (planning === "yes")
265
+ proposal.config.planning = { enabled: true, model,
266
+ executeOnMerge: assessment.configBeforeHash === null ? true : proposal.config.planning?.executeOnMerge === true };
267
+ else
268
+ report("Hosted planning stays disabled. The ready-for-planning label will not create a plan.");
269
+ }
270
+ if (!proposal.config.repository && !options["skip-labels"])
271
+ proposal.config.repository = (await ask("GitHub repository (owner/name) for workflow labels?")).trim();
272
+ let copilotVersion = options["copilot-version"] === undefined ? undefined : copilotVersionOf(options["copilot-version"]);
273
+ if (proposal.config.planning?.enabled && !options["skip-labels"] && proposal.config.repository && copilotVersion === undefined
274
+ && await Promise.resolve().then(() => copilotVersionVariable(io.client(), proposal.config.repository)).catch(() => null) === null) {
275
+ const latest = await io.latestCopilotVersion?.();
276
+ const message = `Copilot CLI version for hosted planning? Sets the missing ${COPILOT_VERSION_VARIABLE} Actions variable.`
277
+ + (latest ? ` Press Enter for the latest release, ${latest}.` : " Leave empty to set it later.");
278
+ for (;;) {
279
+ const answer = (await ask(message)).trim() || latest;
280
+ if (!answer) {
281
+ report(`Hosted planning fails until you run: ${copilotVersionCommand(proposal.config.repository)}`);
282
+ break;
283
+ }
284
+ try {
285
+ copilotVersion = copilotVersionOf(answer);
286
+ break;
287
+ }
288
+ catch (error) {
289
+ report(error instanceof Error ? error.message : String(error));
290
+ }
291
+ }
292
+ }
293
+ const selected = selectGuidance(proposal, choice === "all");
294
+ await writeAtomic(root, output, json(proposal));
295
+ await writeAtomic(root, markdown, renderSetupMarkdown(proposal, await installation(root, selected))
296
+ + `\n## Installation choice\n\n${choice === "all" ? "Team plus the concrete guidance edits listed above." : "Team only. Proposed guidance edits remain in the saved proposal but will not be applied in this run."}\n`);
297
+ report("\n3. Apply");
298
+ report(await installSetup(root, selected, { apply: false, guidance: "apply", skipLabels: options["skip-labels"] === true, copilotVersion }));
299
+ const approved = confirm ? await confirm("Apply exactly these files and labels?", false)
300
+ : (await ask("Apply exactly these files and labels? Enter yes to confirm.")).trim().toLowerCase() === "yes";
301
+ if (!approved) {
302
+ report("Not applied. The saved proposal remains available for review.");
303
+ return;
304
+ }
305
+ report(await installSetup(root, selected, { apply: true, guidance: "apply", skipLabels: options["skip-labels"] === true, copilotVersion }, options["skip-labels"] ? undefined : io.client()));
306
+ proposal.configBeforeHash = textHash(json(selected.config));
307
+ await writeAtomic(root, output, json(proposal));
308
+ }
309
+ catch (error) {
310
+ if (error instanceof Error && error.name === "ExitPromptError")
311
+ throw new Error("Setup cancelled. Any saved proposal remains available; no installation was performed.");
312
+ throw error;
313
+ }
314
+ }
315
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/setup/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAgB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,cAAc,IAAI,gBAAgB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtK,OAAO,EAAE,qBAAqB,EAAE,MAAM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QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5D,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;YAAE,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAC;QACzK,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type Config } from "../config.js";
2
+ export interface FileChange {
3
+ path: string;
4
+ before: string | null;
5
+ after: string | null;
6
+ merged?: boolean;
7
+ }
8
+ export declare function setupConfiguration(value: unknown): Config;
9
+ export declare const SHARED_HOT_SEED = "# Shared decisions\n\nActive cross-role choices only, one or two lines each with the reason and a PR or file link. Replace superseded entries; move older detail to cold/ and link it from index.md. Link existing ADRs rather than copying them.\n";
10
+ export declare const SHARED_INDEX_SEED = "# Shared decisions: index\n\nLink shared cold topics (cold/name.md) and archived decisions (archive/name.md) here. Read detail only when needed.\n";
11
+ export declare function installation(root: string, proposal: unknown, conflicts?: string[], kept?: string[]): Promise<FileChange[]>;
12
+ export declare function applyInstallation(root: string, changes: FileChange[]): Promise<void>;
@@ -0,0 +1,211 @@
1
+ import { readdir, unlink } from "node:fs/promises";
2
+ import { agentPrompt, bounded, errorCode, hash, json, matchesTextHash, optionalText, readJson, record, safePath, string, textHash, writeAtomic } from "../core.js";
3
+ import { agentArchivePath, limitsFor, parseConfig } from "../config.js";
4
+ import { PR_TEMPLATE, SHARED_INSTRUCTIONS, SKILL, workflows } from "./templates.js";
5
+ import { mergeManagedBlock, roleProfile } from "./agents.js";
6
+ import { editableGuidance, validateInstructionScope } from "./instruction-quality.js";
7
+ import { LEGACY_DECISIONS, SHARED_HOT, SHARED_INDEX } from "../memory/context.js";
8
+ async function hasPrTemplate(root) {
9
+ for (const directory of ["", ".github", "docs"]) {
10
+ try {
11
+ const names = await readdir(directory ? await safePath(root, directory) : root);
12
+ if (names.some((name) => /^pull_request_template(?:\.[^.]+)?$/i.test(name)))
13
+ return true;
14
+ }
15
+ catch (error) {
16
+ if (!errorCode(error, "ENOENT"))
17
+ throw error;
18
+ }
19
+ }
20
+ return false;
21
+ }
22
+ /** Crewbie Markdown a human may edit after init; their version wins over a regenerated one. */
23
+ function humanEditable(path) {
24
+ return /^\.github\/agents\/crewbie-[^/]+\.agent\.md$/.test(path)
25
+ || [".crewbie/instructions.md", ".github/skills/crewbie/SKILL.md", ".github/PULL_REQUEST_TEMPLATE.md"].includes(path);
26
+ }
27
+ export function setupConfiguration(value) {
28
+ const data = record(value, "setup proposal");
29
+ const config = parseConfig(data.config);
30
+ return data.configBeforeHash === null && config.planning?.enabled && config.planning.executeOnMerge === undefined
31
+ ? { ...config, planning: { ...config.planning, executeOnMerge: true } } : config;
32
+ }
33
+ function memorySeed(id, tier) {
34
+ return tier === "hot" ? `# ${id}: gotchas\n\nNon-obvious traps and surprising constraints only, one or two lines each with a link. No implementation summaries, scope notes or verification logs. Replace stale entries.\n` : `# ${id}: memory index\n\nLink relevant cold topics and archived decisions here. Read detail only when needed.\n`;
35
+ }
36
+ const LEGACY_DECISIONS_SEED = "# Shared decisions\n\nRecord approved choices, short reasons, scope and evidence links. Link existing ADRs rather than copying them.\n";
37
+ export const SHARED_HOT_SEED = "# Shared decisions\n\nActive cross-role choices only, one or two lines each with the reason and a PR or file link. Replace superseded entries; move older detail to cold/ and link it from index.md. Link existing ADRs rather than copying them.\n";
38
+ export const SHARED_INDEX_SEED = "# Shared decisions: index\n\nLink shared cold topics (cold/name.md) and archived decisions (archive/name.md) here. Read detail only when needed.\n";
39
+ /** Seeds shared hot/index memory and moves a pre-split .crewbie/decisions.md into the shared hot file. */
40
+ async function sharedDecisions(root, files, adopted, limit) {
41
+ const hot = await optionalText(await safePath(root, SHARED_HOT));
42
+ const legacy = await optionalText(await safePath(root, LEGACY_DECISIONS));
43
+ if (legacy !== null) {
44
+ const seeded = textHash(legacy) === textHash(LEGACY_DECISIONS_SEED);
45
+ if (!seeded) {
46
+ if (hot !== null)
47
+ throw new Error(`Both ${LEGACY_DECISIONS} and ${SHARED_HOT} exist. Merge the old decisions into ${SHARED_HOT}, delete ${LEGACY_DECISIONS}, then update again.`);
48
+ bounded(legacy, limit, `${LEGACY_DECISIONS} (moving to ${SHARED_HOT})`);
49
+ files[SHARED_HOT] = legacy.replace(/\]\((?:\.\/)?decisions\//g, "](");
50
+ }
51
+ files[LEGACY_DECISIONS] = null;
52
+ adopted[LEGACY_DECISIONS] = hash(legacy);
53
+ }
54
+ if (hot === null && files[SHARED_HOT] === undefined)
55
+ files[SHARED_HOT] = SHARED_HOT_SEED;
56
+ if (await optionalText(await safePath(root, SHARED_INDEX)) === null)
57
+ files[SHARED_INDEX] = SHARED_INDEX_SEED;
58
+ }
59
+ async function checkedChanges(root, files, owned, adopted = {}, conflicts, kept) {
60
+ const changes = [];
61
+ for (const [path, after] of Object.entries(files)) {
62
+ const before = await optionalText(await safePath(root, path));
63
+ if (before === after || (before !== null && after !== null && textHash(before) === textHash(after)))
64
+ continue;
65
+ if (before !== null && !matchesTextHash(before, owned[path]) && adopted[path] !== hash(before)) {
66
+ // Edits to Crewbie Markdown after init are the human's: refresh only Crewbie's block, otherwise keep their file.
67
+ if (owned[path] !== undefined && after !== null && humanEditable(path)) {
68
+ const merged = path.startsWith(".github/agents/") ? mergeManagedBlock(before, after) : null;
69
+ if (merged !== null)
70
+ agentPrompt(merged, `${path} with your edits`);
71
+ if (merged !== null && textHash(merged) !== textHash(before))
72
+ changes.push({ path, before, after: merged, merged: true });
73
+ else if (merged === null)
74
+ kept?.push(path);
75
+ continue;
76
+ }
77
+ if (conflicts) {
78
+ conflicts.push(path);
79
+ continue;
80
+ }
81
+ throw new Error(`Preserving user-owned or edited file: ${path}. Reconcile it manually before installation.`);
82
+ }
83
+ changes.push({ path, before, after });
84
+ }
85
+ return changes;
86
+ }
87
+ export async function installation(root, proposal, conflicts, kept) {
88
+ const data = record(proposal, "setup proposal");
89
+ if (data.status === "clarification")
90
+ throw new Error("Resolve setup clarification questions before installation.");
91
+ const config = setupConfiguration(data);
92
+ if (data.configBeforeHash !== undefined) {
93
+ const current = await optionalText(await safePath(root, ".crewbie/config.json"));
94
+ const expected = data.configBeforeHash;
95
+ if (expected !== null && (typeof expected !== "string" || !/^[a-f0-9]{64}$/.test(expected)))
96
+ throw new Error("configBeforeHash must be a SHA-256 hash or null.");
97
+ const proposed = json(config);
98
+ const alreadyApplied = current !== null && textHash(current) === textHash(proposed);
99
+ const unchanged = current === null ? expected === null : expected !== null && matchesTextHash(current, expected);
100
+ if (!alreadyApplied && !unchanged) {
101
+ throw new Error("Crewbie configuration changed since assessment. Reassess the team before applying this proposal.");
102
+ }
103
+ }
104
+ const limits = limitsFor(config);
105
+ bounded(SHARED_INSTRUCTIONS, limits.constitution, "Shared working rules");
106
+ const adopted = {};
107
+ const files = { ".crewbie/config.json": json(config), ".crewbie/instructions.md": SHARED_INSTRUCTIONS, ".github/skills/crewbie/SKILL.md": SKILL, ...workflows(config.nightly.enabled, config.planning?.enabled, config.planning?.executeOnMerge) };
108
+ const adoptions = record(data.agentAdoptions ?? {}, "agent adoption hashes");
109
+ for (const role of config.roles) {
110
+ if (!role.sourceAgent)
111
+ continue;
112
+ const path = role.sourceAgent, archive = agentArchivePath(path);
113
+ const original = await optionalText(await safePath(root, path));
114
+ const archived = await optionalText(await safePath(root, archive));
115
+ const expected = adoptions[path];
116
+ if (typeof expected !== "string" || !/^[a-f0-9]{64}$/.test(expected))
117
+ throw new Error(`Missing reviewed adoption hash for ${path}. Reassess before archiving.`);
118
+ if ((original === null && archived === null) || (original !== null && !matchesTextHash(original, expected))
119
+ || (archived !== null && !matchesTextHash(archived, expected)))
120
+ throw new Error(`Agent changed since assessment: ${path}. Reassess before archiving.`);
121
+ if (archived === null && original !== null)
122
+ files[archive] = original;
123
+ if (original !== null) {
124
+ files[path] = null;
125
+ adopted[path] = hash(original);
126
+ }
127
+ }
128
+ if (data.constitutionText !== null && data.constitutionText !== undefined) {
129
+ const content = string(data.constitutionText, "constitution text");
130
+ if (!config.constitution)
131
+ throw new Error("Select a constitution path before proposing its contents.");
132
+ bounded(content, limits.constitution, "Constitution");
133
+ files[config.constitution] = content.endsWith("\n") ? content : content + "\n";
134
+ }
135
+ if (data.adopt !== undefined) {
136
+ for (const [path, digest] of Object.entries(record(data.adopt, "approved adoption hashes"))) {
137
+ adopted[path] = string(digest, "adoption hash");
138
+ }
139
+ }
140
+ if (data.instructions !== undefined) {
141
+ if (!Array.isArray(data.instructions))
142
+ throw new Error("instructions must be a list of reviewed file changes.");
143
+ for (const raw of data.instructions) {
144
+ const instruction = record(raw, "instruction proposal");
145
+ const path = string(instruction.path, "instruction path");
146
+ if (config.roles.some((role) => role.sourceAgent === path))
147
+ throw new Error(`Cannot both archive and rewrite original agent ${path}. Propose additional guidance on its Crewbie role instead.`);
148
+ if (!editableGuidance(path)) {
149
+ throw new Error(`Unsupported instruction path: ${path}`);
150
+ }
151
+ const content = string(instruction.content, "instruction content");
152
+ validateInstructionScope(path, content);
153
+ bounded(content, limits.constitution, path);
154
+ files[path] = content;
155
+ const current = await optionalText(await safePath(root, path));
156
+ const alreadyApplied = current !== null && textHash(current) === textHash(content);
157
+ if (!alreadyApplied && (instruction.beforeHash === null ? current !== null : current === null || !matchesTextHash(current, instruction.beforeHash))) {
158
+ throw new Error(`Guidance changed since assessment: ${path}. Reassess before applying.`);
159
+ }
160
+ if (current !== null)
161
+ adopted[path] = hash(current);
162
+ }
163
+ }
164
+ const allRoles = [
165
+ ...config.roles,
166
+ { id: "coordinator", purpose: "Clarify work, propose ownership and dependencies, and route only human-approved tasks.", model: "" },
167
+ { id: "improver", purpose: "Propose small, evidence-linked improvements to managed guidance and memory for human review.", model: "" },
168
+ ];
169
+ for (const role of allRoles) {
170
+ const charter = await roleProfile(root, role, config);
171
+ agentPrompt(charter, `${role.id} charter`);
172
+ files[`.github/agents/crewbie-${role.id}.agent.md`] = charter;
173
+ for (const tier of ["hot", "index"]) {
174
+ const path = `.crewbie/team/${role.id}/${tier}.md`;
175
+ if (await optionalText(await safePath(root, path)) === null) {
176
+ files[path] = memorySeed(role.id, tier);
177
+ }
178
+ }
179
+ }
180
+ await sharedDecisions(root, files, adopted, limits.hot);
181
+ let owned = {};
182
+ const manifestPath = await safePath(root, ".crewbie/managed.json");
183
+ if (await optionalText(manifestPath) !== null)
184
+ owned = record(await readJson(manifestPath), "managed file manifest");
185
+ const templatePath = ".github/PULL_REQUEST_TEMPLATE.md";
186
+ if (owned[templatePath] !== undefined || !(await hasPrTemplate(root)))
187
+ files[templatePath] = PR_TEMPLATE;
188
+ return checkedChanges(root, files, owned, adopted, conflicts, kept);
189
+ }
190
+ export async function applyInstallation(root, changes) {
191
+ const manifest = await optionalText(await safePath(root, ".crewbie/managed.json"));
192
+ const hashes = manifest === null ? {} : record(JSON.parse(manifest), "managed file manifest");
193
+ for (const change of changes) {
194
+ if (await optionalText(await safePath(root, change.path)) !== change.before)
195
+ throw new Error(`${change.path} changed since preview. Preview again.`);
196
+ }
197
+ for (const change of changes) {
198
+ if (change.after === null) {
199
+ await unlink(await safePath(root, change.path));
200
+ delete hashes[change.path];
201
+ }
202
+ else {
203
+ await writeAtomic(root, change.path, change.after);
204
+ // A merged charter keeps its last Crewbie fingerprint so later updates still treat it as human-edited.
205
+ if (!change.merged)
206
+ hashes[change.path] = textHash(change.after);
207
+ }
208
+ await writeAtomic(root, ".crewbie/managed.json", json(hashes));
209
+ }
210
+ }
211
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/setup/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,OAAO,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IAAI,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,wCAAwC,CAAC,CAAC;IACvJ,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1B,MAAM,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACnD,uGAAuG;YACvG,IAAI,CAAC,MAAM,CAAC,MAAM;gBAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,WAAW,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare const INSTRUCTION_STUDY = "https://www.sri.inf.ethz.ch/publications/gloaguen2026agentsmd";
2
+ export interface InstructionSignal {
3
+ code: "generic-only" | "duplicated-documentation" | "shared-profile-boilerplate" | "unverified-reference" | "missing-npm-script" | "missing-package-manifest" | "unconditional-full-suite" | "missing-path-scope" | "broad-root-guidance" | "auto-loaded-reference" | "agent-only-context";
4
+ level: "warning" | "advisory";
5
+ path: string;
6
+ line: number;
7
+ related?: string;
8
+ detail: string;
9
+ recommendation: string;
10
+ }
11
+ export interface InstructionQuality {
12
+ basis: string;
13
+ interpretation: string;
14
+ inspected: string[];
15
+ omitted: {
16
+ path: string;
17
+ reason: string;
18
+ }[];
19
+ signals: InstructionSignal[];
20
+ signalsOmitted: number;
21
+ }
22
+ export declare function instructionFile(path: string): boolean;
23
+ export declare function editableGuidance(path: string): boolean;
24
+ export declare function validateInstructionScope(path: string, content: string): void;
25
+ export declare function assessInstructions(root: string, paths: readonly string[]): Promise<InstructionQuality>;