@open-tomato/rafa 0.14.0 → 0.16.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.
@@ -1,10 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  activeOutput,
4
- messageOf,
5
- parseTaskDeclaration,
6
4
  readRafaBlocks
7
- } from "./index-96pz9023.js";
5
+ } from "./index-6cw1n0qy.js";
6
+ import {
7
+ messageOf,
8
+ parseTaskDeclaration
9
+ } from "./index-n3rw8rhr.js";
8
10
  // src/preflight/prerequisites-md.ts
9
11
  import { basename, dirname, join } from "path";
10
12
  var SECTION_AUTO_RE = /\[auto\]/i;
@@ -1098,4 +1100,4 @@ function renderInjection(request) {
1098
1100
  }
1099
1101
  return { requested: mode, mode, text: RENDERERS[mode](model, location.task), fallback: null };
1100
1102
  }
1101
- export { isStampableStub, planStubFromPrompt, stampPrompt, planStubFromPath, REPORT_STATUSES, FINDING_KINDS, FINDING_SIGNALS, CHANGE_LEVELS, parseReport, escapeBlockerText, findNextTask, updateTrackerLine, writeTrackerBlocker, trackerPathFor, PLAN_BLOCK_KINDS, PLAN_HEADER_FIELDS, parsePlan, parsePrerequisites, planPrerequisites, mergePlanPrerequisites, prerequisitesPathForPlan, loadPlanPrerequisites, PROBE_TIMEOUT_MS, runShellProbe, runPreflight, renderInjection };
1103
+ export { isStampableStub, planStubFromPrompt, stampPrompt, planStubFromPath, REPORT_STATUSES, FINDING_KINDS, FINDING_SIGNALS, CHANGE_LEVELS, parseReport, escapeBlockerText, splitBlockerComment, findNextTask, updateTrackerLine, writeTrackerBlocker, trackerPathFor, PLAN_BLOCK_KINDS, PLAN_HEADER_FIELDS, parsePlan, parsePrerequisites, planPrerequisites, mergePlanPrerequisites, prerequisitesPathForPlan, loadPlanPrerequisites, PROBE_TIMEOUT_MS, runShellProbe, runPreflight, renderInjection };
@@ -0,0 +1,397 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ // src/pr/types.ts
5
+ var MERGE_METHODS = Object.freeze([
6
+ "squash",
7
+ "merge",
8
+ "rebase"
9
+ ]);
10
+ function isMergeMethod(value) {
11
+ return typeof value === "string" && MERGE_METHODS.includes(value);
12
+ }
13
+
14
+ // src/utils/declaration.ts
15
+ var DECLARATION_KEYS = [
16
+ "agent",
17
+ "model",
18
+ "effort",
19
+ "budget",
20
+ "tools",
21
+ "skills"
22
+ ];
23
+ var GRANULAR_KEYS = ["model", "effort", "tools"];
24
+ var AGENT_OWNED_KEYS = ["model", "tools"];
25
+ var MODEL_ALIASES = ["opus", "sonnet", "haiku", "fable"];
26
+ var EFFORT_LEVELS = [
27
+ "low",
28
+ "medium",
29
+ "high",
30
+ "xhigh",
31
+ "max"
32
+ ];
33
+ var DECLARATION_BLOCK = /\{([^{}]*)\}$/;
34
+ var ENTRY_TOKEN = /^([A-Za-z_][A-Za-z0-9_-]*)=(.*)$/;
35
+ var FULL_MODEL_NAME = /^claude-[a-z0-9][a-z0-9.-]*$/;
36
+ var AGENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
37
+ function isAgentName(value) {
38
+ return AGENT_NAME.test(value);
39
+ }
40
+ var TOOL_NAME = /^[A-Za-z][A-Za-z0-9_-]*$/;
41
+ var SKILL_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
42
+ var BUDGET_FLAG = "--max-budget-usd";
43
+ var BUDGET_VALUE = /^(?:0|[1-9]\d{0,5})(?:\.\d{1,6})?$/;
44
+ function parseBudgetUsd(value) {
45
+ if (!BUDGET_VALUE.test(value))
46
+ return null;
47
+ const usd = Number(value);
48
+ return usd > 0 ? usd : null;
49
+ }
50
+ function isEffortLevel(value) {
51
+ return EFFORT_LEVELS.includes(value);
52
+ }
53
+ function isModelValue(value) {
54
+ if (MODEL_ALIASES.includes(value))
55
+ return true;
56
+ return FULL_MODEL_NAME.test(value);
57
+ }
58
+ function parseToolList(value) {
59
+ const parts = value.split(",");
60
+ if (parts.length === 0)
61
+ return null;
62
+ const tools = [];
63
+ for (const part of parts) {
64
+ if (!TOOL_NAME.test(part))
65
+ return null;
66
+ if (!tools.includes(part))
67
+ tools.push(part);
68
+ }
69
+ return tools;
70
+ }
71
+ function parseSkillList(value) {
72
+ const parts = value.split(",");
73
+ if (parts.length === 0)
74
+ return null;
75
+ const skills = [];
76
+ for (const part of parts) {
77
+ if (!SKILL_NAME.test(part))
78
+ return null;
79
+ if (!skills.includes(part))
80
+ skills.push(part);
81
+ }
82
+ return skills;
83
+ }
84
+ function unusableValue(key, token) {
85
+ return { reason: "unusable-value", key, text: token };
86
+ }
87
+ function isDeclarationKey(key) {
88
+ return DECLARATION_KEYS.includes(key);
89
+ }
90
+ function tokenise(body) {
91
+ const trimmed = body.trim();
92
+ if (trimmed.length === 0)
93
+ return [];
94
+ return trimmed.split(/\s+/);
95
+ }
96
+ function readBlock(raw, body) {
97
+ const entries = [];
98
+ const extras = [];
99
+ const issues = [];
100
+ const seen = new Set;
101
+ let agent = null;
102
+ let model = null;
103
+ let effort = null;
104
+ let budget = null;
105
+ let tools = null;
106
+ let skills = null;
107
+ for (const token of tokenise(body)) {
108
+ const match = token.match(ENTRY_TOKEN);
109
+ const key = match?.[1];
110
+ const value = match?.[2];
111
+ if (key === undefined || value === undefined) {
112
+ issues.push({ reason: "stray-token", key: "", text: token });
113
+ continue;
114
+ }
115
+ const entry = { key, value };
116
+ entries.push(entry);
117
+ if (!isDeclarationKey(key)) {
118
+ extras.push(entry);
119
+ continue;
120
+ }
121
+ if (seen.has(key)) {
122
+ issues.push({ reason: "duplicate-key", key, text: token });
123
+ continue;
124
+ }
125
+ seen.add(key);
126
+ if (key === "agent") {
127
+ if (AGENT_NAME.test(value))
128
+ agent = value;
129
+ else
130
+ issues.push(unusableValue(key, token));
131
+ continue;
132
+ }
133
+ if (key === "model") {
134
+ if (isModelValue(value))
135
+ model = value;
136
+ else
137
+ issues.push(unusableValue(key, token));
138
+ continue;
139
+ }
140
+ if (key === "effort") {
141
+ if (isEffortLevel(value))
142
+ effort = value;
143
+ else
144
+ issues.push(unusableValue(key, token));
145
+ continue;
146
+ }
147
+ if (key === "budget") {
148
+ const usd = parseBudgetUsd(value);
149
+ if (usd === null)
150
+ issues.push(unusableValue(key, token));
151
+ else
152
+ budget = usd;
153
+ continue;
154
+ }
155
+ if (key === "tools") {
156
+ const parsed = parseToolList(value);
157
+ if (parsed === null)
158
+ issues.push(unusableValue(key, token));
159
+ else
160
+ tools = parsed;
161
+ continue;
162
+ }
163
+ const named = parseSkillList(value);
164
+ if (named === null)
165
+ issues.push(unusableValue(key, token));
166
+ else
167
+ skills = named;
168
+ }
169
+ if (seen.size === 0)
170
+ return null;
171
+ return {
172
+ raw,
173
+ entries,
174
+ extras,
175
+ issues,
176
+ agent,
177
+ model,
178
+ effort,
179
+ budget,
180
+ tools,
181
+ skills
182
+ };
183
+ }
184
+ function parseTaskDeclaration(taskText) {
185
+ const trimmed = taskText.trimEnd();
186
+ const match = trimmed.match(DECLARATION_BLOCK);
187
+ const raw = match?.[0];
188
+ const body = match?.[1];
189
+ if (raw === undefined || body === undefined) {
190
+ return { text: taskText, declaration: null };
191
+ }
192
+ const before = trimmed.slice(0, trimmed.length - raw.length).trimEnd();
193
+ if (before.length === 0)
194
+ return { text: taskText, declaration: null };
195
+ const declaration = readBlock(raw, body);
196
+ if (declaration === null)
197
+ return { text: taskText, declaration: null };
198
+ return { text: before, declaration };
199
+ }
200
+ function stripTaskDeclaration(taskText) {
201
+ return parseTaskDeclaration(taskText).text;
202
+ }
203
+ function budgetArgs(budget) {
204
+ return budget === null ? [] : [BUDGET_FLAG, String(budget)];
205
+ }
206
+ function resolveDeclarationFlags(declaration, agentDeclaresEffort) {
207
+ if (declaration === null)
208
+ return { args: [], suppressed: [] };
209
+ const { agent, effort } = declaration;
210
+ const isPresent = (key) => declaration[key] !== null;
211
+ const budget = budgetArgs(declaration.budget);
212
+ if (agent !== null) {
213
+ if (effort === null || agentDeclaresEffort(agent)) {
214
+ return { args: ["--agent", agent, ...budget], suppressed: GRANULAR_KEYS.filter(isPresent) };
215
+ }
216
+ return {
217
+ args: ["--agent", agent, "--effort", effort, ...budget],
218
+ suppressed: AGENT_OWNED_KEYS.filter(isPresent)
219
+ };
220
+ }
221
+ const args = [];
222
+ if (declaration.model !== null)
223
+ args.push("--model", declaration.model);
224
+ if (declaration.effort !== null)
225
+ args.push("--effort", declaration.effort);
226
+ args.push(...budget);
227
+ if (declaration.tools !== null) {
228
+ args.push("--tools", declaration.tools.join(","));
229
+ }
230
+ return { args, suppressed: [] };
231
+ }
232
+
233
+ // src/config-sections.ts
234
+ function isMapping(value) {
235
+ return typeof value === "object" && value !== null && !Array.isArray(value);
236
+ }
237
+ function describeValue(value) {
238
+ if (typeof value === "string")
239
+ return JSON.stringify(value);
240
+ if (value === null)
241
+ return "null";
242
+ if (Array.isArray(value))
243
+ return "a list";
244
+ if (typeof value === "object")
245
+ return "a mapping";
246
+ return String(value);
247
+ }
248
+ function messageOf(error) {
249
+ return error instanceof Error ? error.message : String(error);
250
+ }
251
+ var CONFIG_VERSIONS = [1];
252
+ var STORE_BACKENDS = ["sqlite", "ndjson"];
253
+ var INJECT_MODES = ["full", "stage", "task"];
254
+ var OUTPUT_MODES = ["text", "json"];
255
+ var CLAUDE_SETTING_SOURCES = ["user", "project", "local"];
256
+ var PR_PROVIDERS = ["gh", "none"];
257
+ var RELEASE_AUTO = "auto";
258
+ function accepted(value) {
259
+ return { value, problems: [], extras: [] };
260
+ }
261
+ function refused(at, raw, expected) {
262
+ const problem = `${at.label} is ${describeValue(raw)}, expected ${expected}`;
263
+ return { value: undefined, problems: [problem], extras: [] };
264
+ }
265
+ function refusedWith(problems) {
266
+ return { value: undefined, problems, extras: [] };
267
+ }
268
+ function mapReading(reading, map) {
269
+ return reading.value === undefined ? { ...reading, value: undefined } : { ...reading, value: map(reading.value) };
270
+ }
271
+ function below(at, step) {
272
+ return { label: `${at.label}${step}`, key: `${at.key}${step}` };
273
+ }
274
+ function oneOf(values) {
275
+ const expected = `one of: ${values.join(", ")}`;
276
+ return (raw, at) => {
277
+ const hit = values.find((value) => value === raw);
278
+ return hit === undefined ? refused(at, raw, expected) : accepted(hit);
279
+ };
280
+ }
281
+ function text(expected) {
282
+ return (raw, at) => typeof raw === "string" && raw.trim() !== "" ? accepted(raw) : refused(at, raw, expected);
283
+ }
284
+ var flag = (raw, at) => typeof raw === "boolean" ? accepted(raw) : refused(at, raw, "true or false");
285
+ var mergeMethod = oneOf(MERGE_METHODS);
286
+ var usdAmount = (raw, at) => {
287
+ const usd = typeof raw === "number" ? parseBudgetUsd(String(raw)) : null;
288
+ return usd === null ? refused(at, raw, "a number of US dollars above zero, at most six digits either side of the point") : accepted(usd);
289
+ };
290
+ var issueNumber = (raw, at) => typeof raw === "number" && Number.isSafeInteger(raw) && raw > 0 ? accepted(raw) : refused(at, raw, "an issue number, a whole number above zero");
291
+ var dayCount = (raw, at) => typeof raw === "number" && Number.isSafeInteger(raw) && raw > 0 ? accepted(raw) : refused(at, raw, "a number of days, a whole number above zero");
292
+ var releaseEnabled = (raw, at) => typeof raw === "boolean" || raw === RELEASE_AUTO ? accepted(raw) : refused(at, raw, `true, false or ${RELEASE_AUTO}`);
293
+ var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9-]*(?:\[bot\])?$/;
294
+ function isGitHubLogin(value) {
295
+ return typeof value === "string" && GITHUB_LOGIN.test(value);
296
+ }
297
+ var githubLogin = (raw, at) => isGitHubLogin(raw) ? accepted(raw) : refused(at, raw, "a GitHub login");
298
+ function listOf(item, expected) {
299
+ return (raw, at) => {
300
+ if (!Array.isArray(raw))
301
+ return refused(at, raw, `a list of ${expected}`);
302
+ const readings = raw.map((entry, index) => item(entry, below(at, `[${index}]`)));
303
+ const problems = readings.flatMap((reading) => reading.problems);
304
+ const extras = readings.flatMap((reading) => reading.extras);
305
+ if (problems.length > 0)
306
+ return { value: undefined, problems, extras };
307
+ const values = readings.flatMap((reading) => reading.value === undefined ? [] : [reading.value]);
308
+ return { value: Object.freeze(values), problems, extras };
309
+ };
310
+ }
311
+ function subsetOf(values) {
312
+ const expected = `a comma-separated subset of: ${values.join(", ")}`;
313
+ return (raw, at) => {
314
+ if (typeof raw !== "string")
315
+ return refused(at, raw, expected);
316
+ const named = [];
317
+ for (const entry of raw.split(",")) {
318
+ const hit = values.find((value) => value === entry.trim());
319
+ if (hit === undefined || named.includes(hit))
320
+ return refused(at, raw, expected);
321
+ named.push(hit);
322
+ }
323
+ return accepted(Object.freeze(named));
324
+ };
325
+ }
326
+ var itemText = text("a non-empty string");
327
+ function readKeyedItem(shape, raw, at) {
328
+ const choices = shape.kinds.join(", ");
329
+ if (!isMapping(raw))
330
+ return refused(at, raw, `a mapping naming one of: ${choices}`);
331
+ const entries = Object.entries(raw);
332
+ const kinds = shape.kinds.filter((kind2) => entries.some(([name]) => name === kind2));
333
+ const [kind] = kinds;
334
+ if (kind === undefined)
335
+ return refusedWith([`${at.label} names none of: ${choices}`]);
336
+ if (kinds.length > 1) {
337
+ const named2 = kinds.join(" and ");
338
+ return refusedWith([`${at.label} names ${named2}, expected exactly one of: ${choices}`]);
339
+ }
340
+ const optionalKeys = shape.optionalFor(kind);
341
+ const problems = [];
342
+ const extras = [];
343
+ const optional = new Map;
344
+ let named;
345
+ for (const [name, value] of entries) {
346
+ if (name !== kind && !optionalKeys.includes(name)) {
347
+ extras.push({ key: `${at.key}.${name}`, value });
348
+ continue;
349
+ }
350
+ if (name !== kind && value === null)
351
+ continue;
352
+ const reading = itemText(value, below(at, `.${name}`));
353
+ problems.push(...reading.problems);
354
+ if (reading.value === undefined)
355
+ continue;
356
+ if (name === kind)
357
+ named = reading.value;
358
+ else
359
+ optional.set(name, reading.value);
360
+ }
361
+ return problems.length > 0 || named === undefined ? { value: undefined, problems, extras } : { value: { kind, named, optional }, problems, extras };
362
+ }
363
+ var PREREQUISITE_KINDS = ["tool", "env", "service", "lsp"];
364
+ var REQUIRED_ITEM_KEYS = [...PREREQUISITE_KINDS, "probe"];
365
+ var OPTIONAL_ITEM_KEYS = [...REQUIRED_ITEM_KEYS, "reason"];
366
+ var requiredPrerequisite = (raw, at) => {
367
+ const shape = { kinds: PREREQUISITE_KINDS, optionalFor: () => ["probe"] };
368
+ return mapReading(readKeyedItem(shape, raw, at), (item) => Object.freeze({
369
+ kind: item.kind,
370
+ name: item.named,
371
+ probe: item.optional.get("probe") ?? null
372
+ }));
373
+ };
374
+ var optionalPrerequisite = (raw, at) => {
375
+ const shape = { kinds: PREREQUISITE_KINDS, optionalFor: () => ["probe", "reason"] };
376
+ return mapReading(readKeyedItem(shape, raw, at), (item) => Object.freeze({
377
+ kind: item.kind,
378
+ name: item.named,
379
+ probe: item.optional.get("probe") ?? null,
380
+ reason: item.optional.get("reason") ?? null
381
+ }));
382
+ };
383
+ var MODULE_SOURCE_KINDS = ["npm", "github", "path"];
384
+ var MODULE_SOURCE_KEYS = [...MODULE_SOURCE_KINDS, "ref"];
385
+ var moduleSource = (raw, at) => {
386
+ const shape = {
387
+ kinds: MODULE_SOURCE_KINDS,
388
+ optionalFor: (kind) => kind === "github" ? ["ref"] : []
389
+ };
390
+ return mapReading(readKeyedItem(shape, raw, at), (item) => Object.freeze({
391
+ kind: item.kind,
392
+ location: item.named,
393
+ ref: item.optional.get("ref") ?? null
394
+ }));
395
+ };
396
+
397
+ export { __require, MERGE_METHODS, isMergeMethod, isAgentName, BUDGET_FLAG, parseBudgetUsd, parseTaskDeclaration, stripTaskDeclaration, resolveDeclarationFlags, isMapping, describeValue, messageOf, CONFIG_VERSIONS, STORE_BACKENDS, INJECT_MODES, OUTPUT_MODES, CLAUDE_SETTING_SOURCES, PR_PROVIDERS, RELEASE_AUTO, oneOf, text, flag, mergeMethod, usdAmount, issueNumber, dayCount, releaseEnabled, isGitHubLogin, githubLogin, listOf, subsetOf, PREREQUISITE_KINDS, REQUIRED_ITEM_KEYS, OPTIONAL_ITEM_KEYS, requiredPrerequisite, optionalPrerequisite, MODULE_SOURCE_KINDS, MODULE_SOURCE_KEYS, moduleSource };
@@ -0,0 +1,124 @@
1
+ // @bun
2
+ import {
3
+ describeValue
4
+ } from "./index-n3rw8rhr.js";
5
+
6
+ // src/cli/spends.ts
7
+ var SPENDS_GLYPH = "\uD83E\uDE99";
8
+ var SPENDS_WHEN = ["always", "with", "unless", "through"];
9
+ var FLAGGED = ["with", "unless"];
10
+ var FLAG_SPELLING = /^--[^\s-]\S*$/;
11
+ function flagProblem(when, flag) {
12
+ if (FLAGGED.includes(when)) {
13
+ return typeof flag === "string" && FLAG_SPELLING.test(flag) ? null : `spends.flag is ${describeValue(flag)}, expected a flag as typed, starting with --`;
14
+ }
15
+ return flag === undefined ? null : `spends.flag is ${describeValue(flag)}, expected absent when spends.when is "${when}"`;
16
+ }
17
+ function spendsProblem(value) {
18
+ if (value === undefined)
19
+ return null;
20
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
21
+ return `spends is ${describeValue(value)}, expected absent or a mapping`;
22
+ }
23
+ const { when, what, flag } = value;
24
+ if (!SPENDS_WHEN.includes(when)) {
25
+ return `spends.when is ${describeValue(when)}, expected one of ${SPENDS_WHEN.join(", ")}`;
26
+ }
27
+ if (typeof what !== "string") {
28
+ return `spends.what is ${describeValue(what)}, expected a string`;
29
+ }
30
+ return flagProblem(when, flag);
31
+ }
32
+
33
+ // src/cli/command.ts
34
+ var COMMAND_OUTPUTS = ["text", "json", "tui"];
35
+ var MAX_EXIT_CODE = 255;
36
+
37
+ class CommandExit extends Error {
38
+ exitCode;
39
+ constructor(exitCode, message = "") {
40
+ super(message);
41
+ if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > MAX_EXIT_CODE) {
42
+ throw new TypeError(`CommandExit: exit code is ${describeValue(exitCode)}, expected a whole number from 0 to ${MAX_EXIT_CODE}`);
43
+ }
44
+ this.name = "CommandExit";
45
+ this.exitCode = exitCode;
46
+ }
47
+ }
48
+ function isListOf(value, check) {
49
+ return Array.isArray(value) && value.every(check);
50
+ }
51
+ function hasStrings(value, keys) {
52
+ if (typeof value !== "object" || value === null)
53
+ return false;
54
+ const record = value;
55
+ return keys.every((key) => typeof record[key] === "string");
56
+ }
57
+ function isRoutingWord(value) {
58
+ return typeof value === "string" && /^[^\s/-][^\s/]*$/.test(value);
59
+ }
60
+ function isFlag(item) {
61
+ if (!hasStrings(item, ["name"]))
62
+ return false;
63
+ const { deprecated } = item;
64
+ return deprecated === undefined || hasStrings(deprecated, ["use"]);
65
+ }
66
+ function fieldProblem(fields) {
67
+ const checks = [
68
+ ["subject", isRoutingWord(fields.subject), "a word with no space, no slash and no leading dash"],
69
+ ["action", isRoutingWord(fields.action), "a word with no space, no slash and no leading dash"],
70
+ ["name", typeof fields.name === "string", "a string"],
71
+ ["summary", typeof fields.summary === "string", "a string"],
72
+ ["description", typeof fields.description === "string", "a string"],
73
+ ["args", isListOf(fields.args, (item) => hasStrings(item, ["name"])), "a list of named arguments"],
74
+ ["flags", isListOf(fields.flags, isFlag), "a list of named flags, each deprecation naming its use"],
75
+ ["examples", isListOf(fields.examples, (item) => hasStrings(item, ["cmd", "note"])), "a list of examples"],
76
+ [
77
+ "outputs",
78
+ isListOf(fields.outputs, (item) => COMMAND_OUTPUTS.includes(item)),
79
+ `a list of ${COMMAND_OUTPUTS.join(", ")}`
80
+ ],
81
+ [
82
+ "aliases",
83
+ fields.aliases === undefined || isListOf(fields.aliases, (item) => typeof item === "string"),
84
+ "absent or a list of strings"
85
+ ],
86
+ [
87
+ "deprecated",
88
+ fields.deprecated === undefined || hasStrings(fields.deprecated, ["since", "use"]),
89
+ "absent or a mapping of since and use"
90
+ ],
91
+ ["hidden", fields.hidden === undefined || typeof fields.hidden === "boolean", "absent or a boolean"],
92
+ [
93
+ "needsProject",
94
+ fields.needsProject === undefined || typeof fields.needsProject === "boolean",
95
+ "absent or a boolean"
96
+ ],
97
+ ["exec", fields.exec === undefined || fields.exec === true, "absent or true"],
98
+ ["run", typeof fields.run === "function", "a function"]
99
+ ];
100
+ const failed = checks.find(([, passes]) => !passes);
101
+ if (failed === undefined)
102
+ return null;
103
+ const [key, , expected] = failed;
104
+ return `${key} is ${describeValue(fields[key])}, expected ${expected}`;
105
+ }
106
+ function commandProblem(value) {
107
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
108
+ return `a command is ${describeValue(value)}, expected a mapping`;
109
+ }
110
+ const fields = value;
111
+ const problem = fieldProblem(fields) ?? spendsProblem(fields.spends);
112
+ if (problem === null)
113
+ return null;
114
+ const named = isRoutingWord(fields.subject) && isRoutingWord(fields.action) ? `command "${commandSpelling(fields)}"` : "a command";
115
+ return `${named}: ${problem}`;
116
+ }
117
+ function isTopLevel(command) {
118
+ return command.subject === command.action;
119
+ }
120
+ function commandSpelling(command) {
121
+ return isTopLevel(command) ? command.subject : `${command.subject} ${command.action}`;
122
+ }
123
+
124
+ export { SPENDS_GLYPH, CommandExit, isRoutingWord, commandProblem, isTopLevel, commandSpelling };
@@ -1,14 +1,19 @@
1
1
  // @bun
2
2
  import {
3
- STORE_BACKENDS,
4
3
  activeOutput,
5
4
  activeOutputMode,
6
5
  createTextOutput,
6
+ readRafaBlocks
7
+ } from "./index-6cw1n0qy.js";
8
+ import {
9
+ commandSpelling
10
+ } from "./index-p901zs2p.js";
11
+ import {
12
+ STORE_BACKENDS,
7
13
  describeValue,
8
14
  isMapping,
9
- messageOf,
10
- readRafaBlocks
11
- } from "./index-96pz9023.js";
15
+ messageOf
16
+ } from "./index-n3rw8rhr.js";
12
17
 
13
18
  // src/effort/store.ts
14
19
  import {
@@ -840,27 +845,6 @@ function parseSpecReview(output) {
840
845
  return judged(verdict, readGaps(document, issues), block, issues);
841
846
  }
842
847
 
843
- // src/cli/command.ts
844
- var MAX_EXIT_CODE = 255;
845
-
846
- class CommandExit extends Error {
847
- exitCode;
848
- constructor(exitCode, message = "") {
849
- super(message);
850
- if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > MAX_EXIT_CODE) {
851
- throw new TypeError(`CommandExit: exit code is ${describeValue(exitCode)}, expected a whole number from 0 to ${MAX_EXIT_CODE}`);
852
- }
853
- this.name = "CommandExit";
854
- this.exitCode = exitCode;
855
- }
856
- }
857
- function isTopLevel(command) {
858
- return command.subject === command.action;
859
- }
860
- function commandSpelling(command) {
861
- return isTopLevel(command) ? command.subject : `${command.subject} ${command.action}`;
862
- }
863
-
864
848
  // src/cli/running.ts
865
849
  var running = null;
866
850
  function runningCommand() {
@@ -1855,4 +1839,4 @@ function selectEffortStore(repoRoot, config) {
1855
1839
  return adapter.create({ repoRoot });
1856
1840
  }
1857
1841
 
1858
- export { EFFORT_KEY_PROJECTIONS, openNdjsonStore, sqliteStorePath, LONE_SURROGATE, withSqliteStore, writeSqliteStore, openSqliteStore, CommandExit, commandSpelling, getClaudeUsagePercent, checkUsage, interruptClaudeSessions, runClaude, runClaudeCaptured, planFilePath, ClaudePlannerError, createGhRunner, createLocalTracker, PORT_VERSIONS, createAdapterRegistry, CORE_ADAPTER_REGISTRY, selectEffortStore };
1842
+ export { EFFORT_STORE_DIR, effortStorePath, EFFORT_KEY_PROJECTIONS, openNdjsonStore, sqliteStorePath, LONE_SURROGATE, withSqliteStore, writeSqliteStore, openSqliteStore, sessionSpawnEnv, getClaudeUsagePercent, checkUsage, claudeArgs, interruptClaudeSessions, runClaude, spawnClaudeCaptured, runClaudeCaptured, planFilePath, ClaudePlannerError, ISSUE_TYPES, ISSUE_PRIORITIES, ISSUE_STATES, GITHUB_LABELS, createGhRunner, typeOfLabels, moduleOfLabels, createLocalTracker, PORT_VERSIONS, createAdapterRegistry, CORE_ADAPTER_REGISTRY, selectEffortStore };