@open-tomato/rafa 0.34.1 → 0.35.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.
- package/README.md +18 -18
- package/dist/bundled/agents/doc-updater.md +1 -1
- package/dist/bundled/operators/.claude-plugin/plugin.json +5 -0
- package/dist/bundled/operators/agents/rafa-stretch-engineer.md +36 -15
- package/dist/bundled/operators/skills/rafa-stretch-pit-stop/SKILL.md +2 -2
- package/dist/cli.js +11408 -10529
- package/dist/describe-59899b0p.js +11 -0
- package/dist/effort/store/index.js +33 -36
- package/dist/index-21jcfatr.js +16 -0
- package/dist/{index-vp0xghk2.js → index-2tjmxwvp.js} +519 -114
- package/dist/{index-v8d7c6sw.js → index-41vzahew.js} +69 -33
- package/dist/{index-bebv92ha.js → index-ckqfhynj.js} +824 -547
- package/dist/{index-s8ff86xt.js → index-dvrq9nfb.js} +4646 -3954
- package/dist/{index-d6d0942q.js → index-hgcvjke7.js} +17 -17
- package/dist/{index-nr4hdb35.js → index-se13pvag.js} +2471 -2303
- package/dist/index.js +147 -154
- package/dist/learning/index.js +20 -20
- package/dist/plan/index.js +42 -45
- package/package.json +1 -1
- package/dist/describe-5hqfwbjc.js +0 -14
- package/dist/index-3mzw3kzh.js +0 -129
- package/dist/index-fzhd3d4y.js +0 -446
- package/dist/index-k6sd4ym5.js +0 -243
- package/dist/index-wp8c28fd.js +0 -18
package/dist/index-fzhd3d4y.js
DELETED
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
CONFIDENCE_MAX,
|
|
4
|
-
CONFIDENCE_MIN
|
|
5
|
-
} from "./index-wp8c28fd.js";
|
|
6
|
-
|
|
7
|
-
// src/pr/types.ts
|
|
8
|
-
var MERGE_METHODS = Object.freeze([
|
|
9
|
-
"squash",
|
|
10
|
-
"merge",
|
|
11
|
-
"rebase"
|
|
12
|
-
]);
|
|
13
|
-
function isMergeMethod(value) {
|
|
14
|
-
return typeof value === "string" && MERGE_METHODS.includes(value);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// src/schema/tiers.ts
|
|
18
|
-
import { existsSync, realpathSync } from "fs";
|
|
19
|
-
import { dirname, join } from "path";
|
|
20
|
-
var SKILL_TIERS = ["project", "rafa", "user"];
|
|
21
|
-
var INSTINCT_SCOPES = ["project", "user"];
|
|
22
|
-
var CLAUDE_SKILLS_PATH = join(".claude", "skills");
|
|
23
|
-
var RAFA_INSTINCTS_PATH = join(".rafa", "instincts");
|
|
24
|
-
var BUNDLED_SKILLS_DIR = join("bundled", "skills");
|
|
25
|
-
var BUNDLED_BIN_DIR = join("bundled", "bin");
|
|
26
|
-
function isSkillTier(value) {
|
|
27
|
-
return SKILL_TIERS.includes(value);
|
|
28
|
-
}
|
|
29
|
-
function realEntry(entry) {
|
|
30
|
-
try {
|
|
31
|
-
return realpathSync(entry);
|
|
32
|
-
} catch {
|
|
33
|
-
return entry;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function bundledSkillsDirectory(entry) {
|
|
37
|
-
return join(dirname(realEntry(entry ?? Bun.main)), BUNDLED_SKILLS_DIR);
|
|
38
|
-
}
|
|
39
|
-
function bundledBinDirectory(entry) {
|
|
40
|
-
return join(dirname(realEntry(entry ?? Bun.main)), BUNDLED_BIN_DIR);
|
|
41
|
-
}
|
|
42
|
-
function skillTierDirectory(tier, seams) {
|
|
43
|
-
if (tier === "user")
|
|
44
|
-
return join(seams.home, CLAUDE_SKILLS_PATH);
|
|
45
|
-
if (tier === "rafa")
|
|
46
|
-
return bundledSkillsDirectory(seams.entry);
|
|
47
|
-
return seams.projectRoot === null ? null : join(seams.projectRoot, CLAUDE_SKILLS_PATH);
|
|
48
|
-
}
|
|
49
|
-
function resolveSkillTiers(seams) {
|
|
50
|
-
const located = [];
|
|
51
|
-
for (const tier of SKILL_TIERS) {
|
|
52
|
-
const dir = skillTierDirectory(tier, seams);
|
|
53
|
-
if (dir !== null)
|
|
54
|
-
located.push({ tier, dir });
|
|
55
|
-
}
|
|
56
|
-
return located;
|
|
57
|
-
}
|
|
58
|
-
function instinctScopeDirectory(scope, seams) {
|
|
59
|
-
if (scope === "user")
|
|
60
|
-
return join(seams.home, RAFA_INSTINCTS_PATH);
|
|
61
|
-
return seams.projectRoot === null ? null : join(seams.projectRoot, RAFA_INSTINCTS_PATH);
|
|
62
|
-
}
|
|
63
|
-
function resolveInstinctScopes(seams) {
|
|
64
|
-
const located = [];
|
|
65
|
-
for (const scope of INSTINCT_SCOPES) {
|
|
66
|
-
const dir = instinctScopeDirectory(scope, seams);
|
|
67
|
-
if (dir !== null)
|
|
68
|
-
located.push({ scope, dir });
|
|
69
|
-
}
|
|
70
|
-
return located;
|
|
71
|
-
}
|
|
72
|
-
function tierExists(dir) {
|
|
73
|
-
return existsSync(dir);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/utils/declaration.ts
|
|
77
|
-
var DECLARATION_KEYS = [
|
|
78
|
-
"agent",
|
|
79
|
-
"model",
|
|
80
|
-
"effort",
|
|
81
|
-
"budget",
|
|
82
|
-
"tools",
|
|
83
|
-
"skills",
|
|
84
|
-
"tests"
|
|
85
|
-
];
|
|
86
|
-
var GRANULAR_KEYS = ["model", "effort", "tools"];
|
|
87
|
-
var AGENT_OWNED_KEYS = ["model", "tools"];
|
|
88
|
-
var MODEL_ALIASES = ["opus", "sonnet", "haiku", "fable"];
|
|
89
|
-
var EFFORT_LEVELS = [
|
|
90
|
-
"low",
|
|
91
|
-
"medium",
|
|
92
|
-
"high",
|
|
93
|
-
"xhigh",
|
|
94
|
-
"max"
|
|
95
|
-
];
|
|
96
|
-
var TEST_SCOPES = ["affected", "module", "full"];
|
|
97
|
-
var DEFAULT_TEST_SCOPE = "affected";
|
|
98
|
-
var DECLARATION_BLOCK = /\{([^{}]*)\}$/;
|
|
99
|
-
var ENTRY_TOKEN = /^([A-Za-z_][A-Za-z0-9_-]*)=(.*)$/;
|
|
100
|
-
var FULL_MODEL_NAME = /^claude-[a-z0-9][a-z0-9.-]*$/;
|
|
101
|
-
var AGENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
102
|
-
function isAgentName(value) {
|
|
103
|
-
return AGENT_NAME.test(value);
|
|
104
|
-
}
|
|
105
|
-
var TOOL_NAME = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
106
|
-
var SKILL_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
107
|
-
var BUDGET_FLAG = "--max-budget-usd";
|
|
108
|
-
var BUDGET_VALUE = /^(?:0|[1-9]\d{0,5})(?:\.\d{1,6})?$/;
|
|
109
|
-
function parseBudgetUsd(value) {
|
|
110
|
-
if (!BUDGET_VALUE.test(value))
|
|
111
|
-
return null;
|
|
112
|
-
const usd = Number(value);
|
|
113
|
-
return usd > 0 ? usd : null;
|
|
114
|
-
}
|
|
115
|
-
function isEffortLevel(value) {
|
|
116
|
-
return EFFORT_LEVELS.includes(value);
|
|
117
|
-
}
|
|
118
|
-
function isTestScope(value) {
|
|
119
|
-
return TEST_SCOPES.includes(value);
|
|
120
|
-
}
|
|
121
|
-
function readTestScope(declaration) {
|
|
122
|
-
return declaration?.tests ?? DEFAULT_TEST_SCOPE;
|
|
123
|
-
}
|
|
124
|
-
function isModelValue(value) {
|
|
125
|
-
if (MODEL_ALIASES.includes(value))
|
|
126
|
-
return true;
|
|
127
|
-
return FULL_MODEL_NAME.test(value);
|
|
128
|
-
}
|
|
129
|
-
function parseToolList(value) {
|
|
130
|
-
const parts = value.split(",");
|
|
131
|
-
if (parts.length === 0)
|
|
132
|
-
return null;
|
|
133
|
-
const tools = [];
|
|
134
|
-
for (const part of parts) {
|
|
135
|
-
if (!TOOL_NAME.test(part))
|
|
136
|
-
return null;
|
|
137
|
-
if (!tools.includes(part))
|
|
138
|
-
tools.push(part);
|
|
139
|
-
}
|
|
140
|
-
return tools;
|
|
141
|
-
}
|
|
142
|
-
function parseSkillList(value) {
|
|
143
|
-
const parts = value.split(",");
|
|
144
|
-
if (parts.length === 0)
|
|
145
|
-
return null;
|
|
146
|
-
const skills = [];
|
|
147
|
-
for (const part of parts) {
|
|
148
|
-
if (!SKILL_NAME.test(part))
|
|
149
|
-
return null;
|
|
150
|
-
if (!skills.includes(part))
|
|
151
|
-
skills.push(part);
|
|
152
|
-
}
|
|
153
|
-
return skills;
|
|
154
|
-
}
|
|
155
|
-
function unusableValue(key, token) {
|
|
156
|
-
return { reason: "unusable-value", key, text: token };
|
|
157
|
-
}
|
|
158
|
-
function isDeclarationKey(key) {
|
|
159
|
-
return DECLARATION_KEYS.includes(key);
|
|
160
|
-
}
|
|
161
|
-
function tokenise(body) {
|
|
162
|
-
const trimmed = body.trim();
|
|
163
|
-
if (trimmed.length === 0)
|
|
164
|
-
return [];
|
|
165
|
-
return trimmed.split(/\s+/);
|
|
166
|
-
}
|
|
167
|
-
function readBlock(raw, body) {
|
|
168
|
-
const entries = [];
|
|
169
|
-
const extras = [];
|
|
170
|
-
const issues = [];
|
|
171
|
-
const seen = new Set;
|
|
172
|
-
let agent = null;
|
|
173
|
-
let model = null;
|
|
174
|
-
let effort = null;
|
|
175
|
-
let budget = null;
|
|
176
|
-
let tools = null;
|
|
177
|
-
let skills = null;
|
|
178
|
-
let tests = null;
|
|
179
|
-
for (const token of tokenise(body)) {
|
|
180
|
-
const match = token.match(ENTRY_TOKEN);
|
|
181
|
-
const key = match?.[1];
|
|
182
|
-
const value = match?.[2];
|
|
183
|
-
if (key === undefined || value === undefined) {
|
|
184
|
-
issues.push({ reason: "stray-token", key: "", text: token });
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
const entry = { key, value };
|
|
188
|
-
entries.push(entry);
|
|
189
|
-
if (!isDeclarationKey(key)) {
|
|
190
|
-
extras.push(entry);
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
if (seen.has(key)) {
|
|
194
|
-
issues.push({ reason: "duplicate-key", key, text: token });
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
seen.add(key);
|
|
198
|
-
if (key === "agent") {
|
|
199
|
-
if (AGENT_NAME.test(value))
|
|
200
|
-
agent = value;
|
|
201
|
-
else
|
|
202
|
-
issues.push(unusableValue(key, token));
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if (key === "model") {
|
|
206
|
-
if (isModelValue(value))
|
|
207
|
-
model = value;
|
|
208
|
-
else
|
|
209
|
-
issues.push(unusableValue(key, token));
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (key === "effort") {
|
|
213
|
-
if (isEffortLevel(value))
|
|
214
|
-
effort = value;
|
|
215
|
-
else
|
|
216
|
-
issues.push(unusableValue(key, token));
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
if (key === "budget") {
|
|
220
|
-
const usd = parseBudgetUsd(value);
|
|
221
|
-
if (usd === null)
|
|
222
|
-
issues.push(unusableValue(key, token));
|
|
223
|
-
else
|
|
224
|
-
budget = usd;
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
if (key === "tools") {
|
|
228
|
-
const parsed = parseToolList(value);
|
|
229
|
-
if (parsed === null)
|
|
230
|
-
issues.push(unusableValue(key, token));
|
|
231
|
-
else
|
|
232
|
-
tools = parsed;
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (key === "tests") {
|
|
236
|
-
if (isTestScope(value))
|
|
237
|
-
tests = value;
|
|
238
|
-
else
|
|
239
|
-
issues.push(unusableValue(key, token));
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
const named = parseSkillList(value);
|
|
243
|
-
if (named === null)
|
|
244
|
-
issues.push(unusableValue(key, token));
|
|
245
|
-
else
|
|
246
|
-
skills = named;
|
|
247
|
-
}
|
|
248
|
-
if (seen.size === 0)
|
|
249
|
-
return null;
|
|
250
|
-
return {
|
|
251
|
-
raw,
|
|
252
|
-
entries,
|
|
253
|
-
extras,
|
|
254
|
-
issues,
|
|
255
|
-
agent,
|
|
256
|
-
model,
|
|
257
|
-
effort,
|
|
258
|
-
budget,
|
|
259
|
-
tools,
|
|
260
|
-
skills,
|
|
261
|
-
tests
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
function parseTaskDeclaration(taskText) {
|
|
265
|
-
const trimmed = taskText.trimEnd();
|
|
266
|
-
const match = trimmed.match(DECLARATION_BLOCK);
|
|
267
|
-
const raw = match?.[0];
|
|
268
|
-
const body = match?.[1];
|
|
269
|
-
if (raw === undefined || body === undefined) {
|
|
270
|
-
return { text: taskText, declaration: null };
|
|
271
|
-
}
|
|
272
|
-
const before = trimmed.slice(0, trimmed.length - raw.length).trimEnd();
|
|
273
|
-
if (before.length === 0)
|
|
274
|
-
return { text: taskText, declaration: null };
|
|
275
|
-
const declaration = readBlock(raw, body);
|
|
276
|
-
if (declaration === null)
|
|
277
|
-
return { text: taskText, declaration: null };
|
|
278
|
-
return { text: before, declaration };
|
|
279
|
-
}
|
|
280
|
-
function stripTaskDeclaration(taskText) {
|
|
281
|
-
return parseTaskDeclaration(taskText).text;
|
|
282
|
-
}
|
|
283
|
-
function budgetArgs(budget) {
|
|
284
|
-
return budget === null ? [] : [BUDGET_FLAG, String(budget)];
|
|
285
|
-
}
|
|
286
|
-
function resolveDeclarationFlags(declaration, agentDeclaresEffort) {
|
|
287
|
-
if (declaration === null)
|
|
288
|
-
return { args: [], suppressed: [] };
|
|
289
|
-
const { agent, effort } = declaration;
|
|
290
|
-
const isPresent = (key) => declaration[key] !== null;
|
|
291
|
-
const budget = budgetArgs(declaration.budget);
|
|
292
|
-
if (agent !== null) {
|
|
293
|
-
if (effort === null || agentDeclaresEffort(agent)) {
|
|
294
|
-
return { args: ["--agent", agent, ...budget], suppressed: GRANULAR_KEYS.filter(isPresent) };
|
|
295
|
-
}
|
|
296
|
-
return {
|
|
297
|
-
args: ["--agent", agent, "--effort", effort, ...budget],
|
|
298
|
-
suppressed: AGENT_OWNED_KEYS.filter(isPresent)
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
const args = [];
|
|
302
|
-
if (declaration.model !== null)
|
|
303
|
-
args.push("--model", declaration.model);
|
|
304
|
-
if (declaration.effort !== null)
|
|
305
|
-
args.push("--effort", declaration.effort);
|
|
306
|
-
args.push(...budget);
|
|
307
|
-
if (declaration.tools !== null) {
|
|
308
|
-
args.push("--tools", declaration.tools.join(","));
|
|
309
|
-
}
|
|
310
|
-
return { args, suppressed: [] };
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// src/config-sections.ts
|
|
314
|
-
function isMapping(value) {
|
|
315
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
316
|
-
}
|
|
317
|
-
function describeValue(value) {
|
|
318
|
-
if (typeof value === "string")
|
|
319
|
-
return JSON.stringify(value);
|
|
320
|
-
if (value === null)
|
|
321
|
-
return "null";
|
|
322
|
-
if (Array.isArray(value))
|
|
323
|
-
return "a list";
|
|
324
|
-
if (typeof value === "object")
|
|
325
|
-
return "a mapping";
|
|
326
|
-
return String(value);
|
|
327
|
-
}
|
|
328
|
-
function messageOf(error) {
|
|
329
|
-
return error instanceof Error ? error.message : String(error);
|
|
330
|
-
}
|
|
331
|
-
var CONFIG_VERSIONS = [1];
|
|
332
|
-
var STORE_BACKENDS = ["sqlite", "ndjson"];
|
|
333
|
-
var SYNC_STRATEGIES = ["local", "file", "git", "service", "p2p"];
|
|
334
|
-
var BOARD_RELATIONSHIP_MODES = ["labels", "native"];
|
|
335
|
-
var INJECT_MODES = ["full", "stage", "task"];
|
|
336
|
-
var OUTPUT_MODES = ["text", "json", "events"];
|
|
337
|
-
var CLAUDE_SETTING_SOURCES = ["user", "project", "local"];
|
|
338
|
-
var PR_PROVIDERS = ["gh", "none"];
|
|
339
|
-
var RELEASE_AUTO = "auto";
|
|
340
|
-
var TIER_SWITCHES = ["on", "off"];
|
|
341
|
-
var SKILL_RESOLVERS = ["planner", "tag", "none"];
|
|
342
|
-
var LESSON_SWITCHES = ["on", "off"];
|
|
343
|
-
var CLAIMS_STALE_DISABLED = "disabled";
|
|
344
|
-
var CLAIMS_AHEAD = ["off", "allow"];
|
|
345
|
-
function accepted(value) {
|
|
346
|
-
return { value, problems: [], extras: [] };
|
|
347
|
-
}
|
|
348
|
-
function refused(at, raw, expected) {
|
|
349
|
-
const problem = `${at.label} is ${describeValue(raw)}, expected ${expected}`;
|
|
350
|
-
return { value: undefined, problems: [problem], extras: [] };
|
|
351
|
-
}
|
|
352
|
-
function refusedWith(problems) {
|
|
353
|
-
return { value: undefined, problems, extras: [] };
|
|
354
|
-
}
|
|
355
|
-
function mapReading(reading, map) {
|
|
356
|
-
return reading.value === undefined ? { ...reading, value: undefined } : { ...reading, value: map(reading.value) };
|
|
357
|
-
}
|
|
358
|
-
function below(at, step) {
|
|
359
|
-
return { label: `${at.label}${step}`, key: `${at.key}${step}` };
|
|
360
|
-
}
|
|
361
|
-
function oneOf(values) {
|
|
362
|
-
const expected = `one of: ${values.join(", ")}`;
|
|
363
|
-
return (raw, at) => {
|
|
364
|
-
const hit = values.find((value) => value === raw);
|
|
365
|
-
return hit === undefined ? refused(at, raw, expected) : accepted(hit);
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
function text(expected) {
|
|
369
|
-
return (raw, at) => typeof raw === "string" && raw.trim() !== "" ? accepted(raw) : refused(at, raw, expected);
|
|
370
|
-
}
|
|
371
|
-
var flag = (raw, at) => typeof raw === "boolean" ? accepted(raw) : refused(at, raw, "true or false");
|
|
372
|
-
var mergeMethod = oneOf(MERGE_METHODS);
|
|
373
|
-
var usdAmount = (raw, at) => {
|
|
374
|
-
const usd = typeof raw === "number" ? parseBudgetUsd(String(raw)) : null;
|
|
375
|
-
return usd === null ? refused(at, raw, "a number of US dollars above zero, at most six digits either side of the point") : accepted(usd);
|
|
376
|
-
};
|
|
377
|
-
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");
|
|
378
|
-
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");
|
|
379
|
-
var BUSY_TIMEOUT_MIN_MS = 1;
|
|
380
|
-
var BUSY_TIMEOUT_MAX_MS = 60000;
|
|
381
|
-
function isBusyTimeoutMs(raw) {
|
|
382
|
-
return typeof raw === "number" && Number.isSafeInteger(raw) && raw >= BUSY_TIMEOUT_MIN_MS && raw <= BUSY_TIMEOUT_MAX_MS;
|
|
383
|
-
}
|
|
384
|
-
var busyTimeoutMs = (raw, at) => isBusyTimeoutMs(raw) ? accepted(raw) : refused(at, raw, `a lock wait in milliseconds, a whole number from ${String(BUSY_TIMEOUT_MIN_MS)} to ${String(BUSY_TIMEOUT_MAX_MS)}`);
|
|
385
|
-
var confidence = (raw, at) => typeof raw === "number" && Number.isFinite(raw) && toHundredths(raw) >= toHundredths(CONFIDENCE_MIN) && toHundredths(raw) <= toHundredths(CONFIDENCE_MAX) ? accepted(raw) : refused(at, raw, `a confidence from ${String(CONFIDENCE_MIN)} to ${String(CONFIDENCE_MAX)}`);
|
|
386
|
-
function toHundredths(value) {
|
|
387
|
-
return Math.round(value * 100);
|
|
388
|
-
}
|
|
389
|
-
var recurrenceCount = (raw, at) => typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 1 ? accepted(raw) : refused(at, raw, "a count, a whole number of 1 or more");
|
|
390
|
-
var releaseEnabled = (raw, at) => typeof raw === "boolean" || raw === RELEASE_AUTO ? accepted(raw) : refused(at, raw, `true, false or ${RELEASE_AUTO}`);
|
|
391
|
-
var tierSwitch = oneOf(TIER_SWITCHES);
|
|
392
|
-
var tierPin = (raw, at) => {
|
|
393
|
-
if (raw === false)
|
|
394
|
-
return accepted(false);
|
|
395
|
-
const tier = SKILL_TIERS.find((name) => name === raw);
|
|
396
|
-
return tier === undefined ? refused(at, raw, `false or one of: ${SKILL_TIERS.join(", ")}`) : accepted(tier);
|
|
397
|
-
};
|
|
398
|
-
var routeTarget = (raw, at) => raw === false || typeof raw === "string" && raw.trim() !== "" ? accepted(raw) : refused(at, raw, "false or an agent name");
|
|
399
|
-
var skillResolverName = oneOf(SKILL_RESOLVERS);
|
|
400
|
-
var lessonSwitch = oneOf(LESSON_SWITCHES);
|
|
401
|
-
var CLAIM_DURATION = /^(\d+)([hd])$/;
|
|
402
|
-
var HOURS_PER_DAY = 24;
|
|
403
|
-
function claimDurationHours(raw) {
|
|
404
|
-
const match = typeof raw === "string" ? CLAIM_DURATION.exec(raw) : null;
|
|
405
|
-
if (match === null)
|
|
406
|
-
return null;
|
|
407
|
-
const hours = Number(match[1]) * (match[2] === "d" ? HOURS_PER_DAY : 1);
|
|
408
|
-
return Number.isSafeInteger(hours) && hours > 0 ? hours : null;
|
|
409
|
-
}
|
|
410
|
-
var claimsStaleAfter = (raw, at) => raw === CLAIMS_STALE_DISABLED || claimDurationHours(raw) !== null ? accepted(raw) : refused(at, raw, `a duration of whole hours or days above zero, such as 36h or 3d, or ${CLAIMS_STALE_DISABLED}`);
|
|
411
|
-
var claimsAhead = oneOf(CLAIMS_AHEAD);
|
|
412
|
-
var GITHUB_LOGIN = /^[A-Za-z0-9][A-Za-z0-9-]*(?:\[bot\])?$/;
|
|
413
|
-
function isGitHubLogin(value) {
|
|
414
|
-
return typeof value === "string" && GITHUB_LOGIN.test(value);
|
|
415
|
-
}
|
|
416
|
-
var githubLogin = (raw, at) => isGitHubLogin(raw) ? accepted(raw) : refused(at, raw, "a GitHub login");
|
|
417
|
-
function listOf(item, expected) {
|
|
418
|
-
return (raw, at) => {
|
|
419
|
-
if (!Array.isArray(raw))
|
|
420
|
-
return refused(at, raw, `a list of ${expected}`);
|
|
421
|
-
const readings = raw.map((entry, index) => item(entry, below(at, `[${index}]`)));
|
|
422
|
-
const problems = readings.flatMap((reading) => reading.problems);
|
|
423
|
-
const extras = readings.flatMap((reading) => reading.extras);
|
|
424
|
-
if (problems.length > 0)
|
|
425
|
-
return { value: undefined, problems, extras };
|
|
426
|
-
const values = readings.flatMap((reading) => reading.value === undefined ? [] : [reading.value]);
|
|
427
|
-
return { value: Object.freeze(values), problems, extras };
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
function subsetOf(values) {
|
|
431
|
-
const expected = `a comma-separated subset of: ${values.join(", ")}`;
|
|
432
|
-
return (raw, at) => {
|
|
433
|
-
if (typeof raw !== "string")
|
|
434
|
-
return refused(at, raw, expected);
|
|
435
|
-
const named = [];
|
|
436
|
-
for (const entry of raw.split(",")) {
|
|
437
|
-
const hit = values.find((value) => value === entry.trim());
|
|
438
|
-
if (hit === undefined || named.includes(hit))
|
|
439
|
-
return refused(at, raw, expected);
|
|
440
|
-
named.push(hit);
|
|
441
|
-
}
|
|
442
|
-
return accepted(Object.freeze(named));
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
export { MERGE_METHODS, isMergeMethod, SKILL_TIERS, RAFA_INSTINCTS_PATH, BUNDLED_SKILLS_DIR, isSkillTier, realEntry, bundledBinDirectory, skillTierDirectory, resolveSkillTiers, resolveInstinctScopes, tierExists, TEST_SCOPES, isAgentName, BUDGET_FLAG, parseBudgetUsd, readTestScope, parseTaskDeclaration, stripTaskDeclaration, resolveDeclarationFlags, isMapping, describeValue, messageOf, CONFIG_VERSIONS, STORE_BACKENDS, SYNC_STRATEGIES, BOARD_RELATIONSHIP_MODES, INJECT_MODES, OUTPUT_MODES, CLAUDE_SETTING_SOURCES, PR_PROVIDERS, RELEASE_AUTO, SKILL_RESOLVERS, CLAIMS_STALE_DISABLED, refused, refusedWith, mapReading, below, oneOf, text, flag, mergeMethod, usdAmount, issueNumber, dayCount, BUSY_TIMEOUT_MIN_MS, BUSY_TIMEOUT_MAX_MS, isBusyTimeoutMs, busyTimeoutMs, confidence, recurrenceCount, releaseEnabled, tierSwitch, tierPin, routeTarget, skillResolverName, lessonSwitch, claimDurationHours, claimsStaleAfter, claimsAhead, isGitHubLogin, githubLogin, listOf, subsetOf };
|
package/dist/index-k6sd4ym5.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
commandProblem,
|
|
4
|
-
commandSpelling,
|
|
5
|
-
isRoutingWord,
|
|
6
|
-
isTopLevel
|
|
7
|
-
} from "./index-3mzw3kzh.js";
|
|
8
|
-
import {
|
|
9
|
-
describeValue
|
|
10
|
-
} from "./index-fzhd3d4y.js";
|
|
11
|
-
|
|
12
|
-
// src/cli/registry.ts
|
|
13
|
-
var REFUSAL = "command registry";
|
|
14
|
-
var HELP_WORD = "help";
|
|
15
|
-
function mountKey(name) {
|
|
16
|
-
return `module/${name}`;
|
|
17
|
-
}
|
|
18
|
-
function pluralOf(name) {
|
|
19
|
-
return `${name}s`;
|
|
20
|
-
}
|
|
21
|
-
function rosterOf(commands, options = {}) {
|
|
22
|
-
return Object.freeze(options.includeHidden === true ? [...commands] : commands.filter((command) => command.hidden !== true));
|
|
23
|
-
}
|
|
24
|
-
function refuseHelpWord(word, as) {
|
|
25
|
-
if (word === HELP_WORD)
|
|
26
|
-
throw new Error(`${REFUSAL}: "${HELP_WORD}" is read as a help request, not ${as}`);
|
|
27
|
-
}
|
|
28
|
-
function indexSubjects(subjects) {
|
|
29
|
-
const names = new Map;
|
|
30
|
-
for (const subject of subjects) {
|
|
31
|
-
if (!isRoutingWord(subject.name) || typeof subject.summary !== "string") {
|
|
32
|
-
throw new TypeError(`${REFUSAL}: a subject has name ${describeValue(subject.name)} and summary ${describeValue(subject.summary)},` + " expected a word with no space, no slash and no leading dash, and a string");
|
|
33
|
-
}
|
|
34
|
-
refuseHelpWord(subject.name, "a subject");
|
|
35
|
-
if (names.has(subject.name))
|
|
36
|
-
throw new Error(`${REFUSAL}: subject "${subject.name}" is declared twice`);
|
|
37
|
-
names.set(subject.name, subject);
|
|
38
|
-
}
|
|
39
|
-
const words = new Map(names);
|
|
40
|
-
for (const subject of subjects) {
|
|
41
|
-
const plural = pluralOf(subject.name);
|
|
42
|
-
if (names.has(plural)) {
|
|
43
|
-
throw new Error(`${REFUSAL}: subject "${plural}" is spelled as the plural of subject "${subject.name}"`);
|
|
44
|
-
}
|
|
45
|
-
words.set(plural, subject);
|
|
46
|
-
}
|
|
47
|
-
return words;
|
|
48
|
-
}
|
|
49
|
-
function indexCommands(commands, subjects) {
|
|
50
|
-
const bySubject = new Map;
|
|
51
|
-
for (const command of commands) {
|
|
52
|
-
const problem = commandProblem(command);
|
|
53
|
-
if (problem !== null)
|
|
54
|
-
throw new TypeError(`${REFUSAL}: ${problem}`);
|
|
55
|
-
const spelling = commandSpelling(command);
|
|
56
|
-
if (isTopLevel(command)) {
|
|
57
|
-
refuseHelpWord(command.subject, "a command");
|
|
58
|
-
if (subjects.has(command.subject)) {
|
|
59
|
-
throw new Error(`${REFUSAL}: top-level command "${spelling}" is spelled as a subject`);
|
|
60
|
-
}
|
|
61
|
-
} else if (subjects.get(command.subject)?.name !== command.subject) {
|
|
62
|
-
throw new Error(`${REFUSAL}: command "${spelling}" is under subject "${command.subject}", which is not declared`);
|
|
63
|
-
}
|
|
64
|
-
const actions = bySubject.get(command.subject) ?? new Map;
|
|
65
|
-
if (actions.has(command.action))
|
|
66
|
-
throw new Error(`${REFUSAL}: command "${spelling}" is declared twice`);
|
|
67
|
-
actions.set(command.action, command);
|
|
68
|
-
bySubject.set(command.subject, actions);
|
|
69
|
-
}
|
|
70
|
-
return bySubject;
|
|
71
|
-
}
|
|
72
|
-
function topLevelOf(find, word) {
|
|
73
|
-
const command = find(word, word);
|
|
74
|
-
return command !== undefined && isTopLevel(command) ? command : undefined;
|
|
75
|
-
}
|
|
76
|
-
function shadowOf(words, find, subjects) {
|
|
77
|
-
const [first = "", second] = words;
|
|
78
|
-
if (words.length === 1)
|
|
79
|
-
return topLevelOf(find, first);
|
|
80
|
-
const subject = subjects.get(first);
|
|
81
|
-
if (words.length !== 2 || subject === undefined || second === undefined)
|
|
82
|
-
return;
|
|
83
|
-
return find(subject.name, second);
|
|
84
|
-
}
|
|
85
|
-
function typedAlias(alias) {
|
|
86
|
-
return alias.trim().split(/\s+/).join(" ");
|
|
87
|
-
}
|
|
88
|
-
function indexAliases(commands, find, subjects) {
|
|
89
|
-
const claimed = new Map;
|
|
90
|
-
const aliases = [];
|
|
91
|
-
for (const command of commands) {
|
|
92
|
-
const spelling = commandSpelling(command);
|
|
93
|
-
const lasting = new Set((command.lastingAliases ?? []).map(typedAlias));
|
|
94
|
-
for (const kept of lasting) {
|
|
95
|
-
if (!(command.aliases ?? []).map(typedAlias).includes(kept)) {
|
|
96
|
-
throw new Error(`${REFUSAL}: command "${spelling}" has lasting alias "${kept}", which is not one of its aliases`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
for (const alias of command.aliases ?? []) {
|
|
100
|
-
const typed = typedAlias(alias);
|
|
101
|
-
const words = Object.freeze(typed.split(" "));
|
|
102
|
-
if (!words.every(isRoutingWord)) {
|
|
103
|
-
throw new Error(`${REFUSAL}: command "${spelling}" has alias ${describeValue(alias)},` + " expected words with no slash and no leading dash");
|
|
104
|
-
}
|
|
105
|
-
refuseHelpWord(words[0] ?? "", "the first word of an alias");
|
|
106
|
-
const owner = claimed.get(typed);
|
|
107
|
-
if (owner !== undefined) {
|
|
108
|
-
throw new Error(`${REFUSAL}: alias "${typed}" is claimed by "${commandSpelling(owner)}" and by "${spelling}"`);
|
|
109
|
-
}
|
|
110
|
-
const shadow = shadowOf(words, find, subjects);
|
|
111
|
-
if (shadow !== undefined) {
|
|
112
|
-
throw new Error(`${REFUSAL}: alias "${typed}" of "${spelling}" is spelled as command "${commandSpelling(shadow)}"`);
|
|
113
|
-
}
|
|
114
|
-
claimed.set(typed, command);
|
|
115
|
-
aliases.push(Object.freeze({ words, command, lasting: lasting.has(typed) }));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return Object.freeze(aliases.sort((a, b) => b.words.length - a.words.length));
|
|
119
|
-
}
|
|
120
|
-
function checkMount(mount, held) {
|
|
121
|
-
if (typeof mount.name !== "string" || !/^[^\s-]\S*$/.test(mount.name)) {
|
|
122
|
-
throw new TypeError(`${REFUSAL}: a module is named ${describeValue(mount.name)}, expected a word with no leading dash`);
|
|
123
|
-
}
|
|
124
|
-
const label = `module "${mount.name}"`;
|
|
125
|
-
if (held.some((other) => other.name === mount.name))
|
|
126
|
-
throw new Error(`${REFUSAL}: ${label} is mounted twice`);
|
|
127
|
-
if (!Array.isArray(mount.commands)) {
|
|
128
|
-
throw new TypeError(`${REFUSAL}: ${label} has commands ${describeValue(mount.commands)}, expected a list`);
|
|
129
|
-
}
|
|
130
|
-
const actions = new Set;
|
|
131
|
-
for (const command of mount.commands) {
|
|
132
|
-
const problem = commandProblem(command);
|
|
133
|
-
if (problem !== null)
|
|
134
|
-
throw new TypeError(`${REFUSAL}: ${label}: ${problem}`);
|
|
135
|
-
if (command.exec === true) {
|
|
136
|
-
throw new Error(`${REFUSAL}: ${label}: action "${command.action}" declares exec, and a mounted action delegates to nothing`);
|
|
137
|
-
}
|
|
138
|
-
if (actions.has(command.action))
|
|
139
|
-
throw new Error(`${REFUSAL}: ${label}: action "${command.action}" is declared twice`);
|
|
140
|
-
actions.add(command.action);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function build(subjectList, commands, mounts) {
|
|
144
|
-
const subjects = indexSubjects(subjectList);
|
|
145
|
-
const bySubject = indexCommands(commands, subjects);
|
|
146
|
-
mounts.forEach((mount, index) => {
|
|
147
|
-
checkMount(mount, mounts.slice(0, index));
|
|
148
|
-
});
|
|
149
|
-
const mountsByName = new Map(mounts.map((mount) => [mount.name, mount]));
|
|
150
|
-
const mounted = new Map(mounts.map((mount) => [
|
|
151
|
-
mountKey(mount.name),
|
|
152
|
-
new Map(mount.commands.map((command) => [command.action, command]))
|
|
153
|
-
]));
|
|
154
|
-
const find = (subject, action) => (bySubject.get(subject) ?? mounted.get(subject))?.get(action);
|
|
155
|
-
const aliases = indexAliases(commands, find, subjects);
|
|
156
|
-
const registry = {
|
|
157
|
-
subjects: () => subjectList,
|
|
158
|
-
subjectOf: (word) => subjects.get(word),
|
|
159
|
-
commands: (options) => rosterOf(commands, options),
|
|
160
|
-
actionsOf: (subject, options) => {
|
|
161
|
-
const mountedActions = mounted.get(subject);
|
|
162
|
-
if (mountedActions !== undefined)
|
|
163
|
-
return rosterOf([...mountedActions.values()], options);
|
|
164
|
-
const actions = [...bySubject.get(subject)?.values() ?? []].filter((command) => !isTopLevel(command));
|
|
165
|
-
return rosterOf(actions, options);
|
|
166
|
-
},
|
|
167
|
-
find,
|
|
168
|
-
topLevel: (word) => topLevelOf(find, word),
|
|
169
|
-
aliases: () => aliases,
|
|
170
|
-
mounts: () => mounts,
|
|
171
|
-
mountOf: (name) => mountsByName.get(name),
|
|
172
|
-
mount: (mount) => {
|
|
173
|
-
checkMount(mount, mounts);
|
|
174
|
-
return build(subjectList, commands, Object.freeze([
|
|
175
|
-
...mounts,
|
|
176
|
-
Object.freeze({ name: mount.name, entry: mount.entry, commands: Object.freeze([...mount.commands]) })
|
|
177
|
-
]));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
return Object.freeze(registry);
|
|
181
|
-
}
|
|
182
|
-
function createCommandRegistry(input) {
|
|
183
|
-
return build(Object.freeze([...input.subjects]), Object.freeze([...input.commands]), Object.freeze([]));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// src/cli/describe.ts
|
|
187
|
-
var DESCRIBE_SCHEMA_VERSION = 2;
|
|
188
|
-
var DESCRIBE_BINARY = "rafa";
|
|
189
|
-
function describeArg(arg) {
|
|
190
|
-
return {
|
|
191
|
-
name: arg.name,
|
|
192
|
-
description: arg.description,
|
|
193
|
-
type: arg.type,
|
|
194
|
-
required: arg.required === true,
|
|
195
|
-
default: arg.default ?? null
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function describeFlag(flag) {
|
|
199
|
-
return { ...describeArg(flag), aliases: [...flag.aliases ?? []] };
|
|
200
|
-
}
|
|
201
|
-
function typedAlias2(alias) {
|
|
202
|
-
return alias.trim().split(/\s+/).join(" ");
|
|
203
|
-
}
|
|
204
|
-
function describeCommand(command, name, module) {
|
|
205
|
-
const { deprecated, spends } = command;
|
|
206
|
-
return {
|
|
207
|
-
name,
|
|
208
|
-
summary: command.summary,
|
|
209
|
-
description: command.description,
|
|
210
|
-
args: command.args.map(describeArg),
|
|
211
|
-
flags: command.flags.map(describeFlag),
|
|
212
|
-
examples: command.examples.map(({ cmd, note }) => ({ cmd, note })),
|
|
213
|
-
outputs: [...command.outputs],
|
|
214
|
-
aliases: module === null ? (command.aliases ?? []).map(typedAlias2) : [],
|
|
215
|
-
deprecated: deprecated === undefined ? null : { since: deprecated.since, use: deprecated.use },
|
|
216
|
-
module,
|
|
217
|
-
spends: spends === undefined ? null : { ...spends }
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function mountedThrough(exec, registry) {
|
|
221
|
-
return registry.mounts().flatMap((mount) => registry.actionsOf(mountKey(mount.name)).map((command) => describeCommand(command, `${exec.action} ${mount.name} ${command.action}`, mount.name)));
|
|
222
|
-
}
|
|
223
|
-
function describeRoster(commands, registry) {
|
|
224
|
-
return [
|
|
225
|
-
...commands.map((command) => describeCommand(command, command.action, null)),
|
|
226
|
-
...commands.filter((command) => command.exec === true).flatMap((exec) => mountedThrough(exec, registry))
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
function describeRegistry(registry, version) {
|
|
230
|
-
return {
|
|
231
|
-
schemaVersion: DESCRIBE_SCHEMA_VERSION,
|
|
232
|
-
binary: DESCRIBE_BINARY,
|
|
233
|
-
version,
|
|
234
|
-
subjects: registry.subjects().map((subject) => ({
|
|
235
|
-
name: subject.name,
|
|
236
|
-
summary: subject.summary,
|
|
237
|
-
actions: describeRoster(registry.actionsOf(subject.name), registry)
|
|
238
|
-
})),
|
|
239
|
-
commands: describeRoster(registry.commands().filter(isTopLevel), registry)
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export { mountKey, pluralOf, createCommandRegistry, DESCRIBE_SCHEMA_VERSION, DESCRIBE_BINARY, describeRegistry };
|