@open-tomato/rafa 0.46.0 → 0.47.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 +65 -35
- package/dist/adapters/logger/settings.d.ts +2 -2
- package/dist/bugs/record.d.ts +1 -1
- package/dist/bundled/skills/dev-planner/SKILL.md +1 -1
- package/dist/cli.js +74711 -74226
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +6 -3
- package/dist/config/shape.d.ts +8 -5
- package/dist/config/templates.d.ts +64 -0
- package/dist/config-registry.d.ts +21 -12
- package/dist/config-schema-bugs.d.ts +3 -3
- package/dist/config-schema-checks.d.ts +114 -0
- package/dist/config-schema-errors.d.ts +3 -3
- package/dist/config-schema-features.d.ts +4 -4
- package/dist/config-schema-hub.d.ts +3 -1
- package/dist/config-schema-issues.d.ts +2 -2
- package/dist/config-schema-logger.d.ts +3 -3
- package/dist/config-schema-release.d.ts +11 -12
- package/dist/config-schema-tests.d.ts +32 -24
- package/dist/core/command/command.d.ts +1 -1
- package/dist/core/command/confirm.d.ts +11 -5
- package/dist/core/command/index.d.ts +27 -9
- package/dist/core/command/shared-flags.d.ts +40 -0
- package/dist/core/config/config-load-module.d.ts +43 -0
- package/dist/core/config/config-load.d.ts +43 -12
- package/dist/core/config/config-origins.d.ts +31 -30
- package/dist/core/config/config-schema.d.ts +5 -0
- package/dist/core/config/config.d.ts +90 -25
- package/dist/core/config/core-section.d.ts +1 -1
- package/dist/core/config/index.d.ts +10 -6
- package/dist/core/config/merge-method.d.ts +40 -0
- package/dist/core/config/scope.d.ts +2 -2
- package/dist/core/config/section.d.ts +81 -1
- package/dist/core/config/sections.d.ts +13 -5
- package/dist/core/loop/hop-record.d.ts +6 -6
- package/dist/core/loop/index.d.ts +6 -6
- package/dist/core/loop/session-record-parse.d.ts +9 -2
- package/dist/core/loop/sessions.d.ts +22 -10
- package/dist/core/plan/block-reader.d.ts +1 -1
- package/dist/effort/store/index.js +5 -5
- package/dist/errors/rafa-codes.d.ts +1 -1
- package/dist/{index-77ajfffn.js → index-38ktnyvz.js} +1 -1
- package/dist/{index-jh1r4kcn.js → index-3mwsr6wg.js} +333 -330
- package/dist/{index-gqz4jn6j.js → index-7dgc5g1t.js} +4755 -4722
- package/dist/{index-gvek4r8m.js → index-cbqvgda6.js} +82 -26
- package/dist/{index-cy98y87p.js → index-eay1bd2w.js} +143 -108
- package/dist/{index-2a7nb3an.js → index-f1y86zbb.js} +31 -31
- package/dist/{index-j4k2vdz3.js → index-n3e31fmw.js} +205 -289
- package/dist/{index-39kbcw68.js → index-nwzx41g1.js} +4 -4
- package/dist/index-pzpb1rf7.js +153 -0
- package/dist/{index-ykggr043.js → index-r5q2pdky.js} +10 -5
- package/dist/index.js +14602 -14328
- package/dist/learning/index.js +1 -1
- package/dist/plan/index.js +3 -3
- package/dist/ports/index.d.ts +1 -1
- package/dist/{ready-4f8edezt.js → ready-6p40c3gw.js} +260 -269
- package/package.json +22 -1
- package/dist/pr/checks.d.ts +0 -133
- package/dist/pr/types.d.ts +0 -422
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
tierPins,
|
|
41
41
|
tierSwitch,
|
|
42
42
|
trackerKind
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-r5q2pdky.js";
|
|
44
44
|
|
|
45
45
|
// packages/rafa/src/core/config/config-items.ts
|
|
46
46
|
var itemText = text("a non-empty string");
|
|
@@ -230,7 +230,12 @@ var CORE_SPECS = {
|
|
|
230
230
|
taskSkills: { key: "task.skills", read: skillResolverName, cli: true },
|
|
231
231
|
taskLessons: { key: "task.lessons", read: lessonSwitch, cli: false },
|
|
232
232
|
mergeDuplicates: { key: "merge.duplicates", read: duplicatesLevel, cli: false },
|
|
233
|
-
namingBranch: { key: "naming.branch", read: branchTemplate, cli: false }
|
|
233
|
+
namingBranch: { key: "naming.branch", read: branchTemplate, cli: false },
|
|
234
|
+
templates: {
|
|
235
|
+
key: "templates",
|
|
236
|
+
read: listOf(text("a template name"), "template names"),
|
|
237
|
+
cli: false
|
|
238
|
+
}
|
|
234
239
|
};
|
|
235
240
|
var CORE_DEFAULTS = Object.freeze({
|
|
236
241
|
version: 1,
|
|
@@ -276,7 +281,8 @@ var CORE_DEFAULTS = Object.freeze({
|
|
|
276
281
|
taskSkills: "planner",
|
|
277
282
|
taskLessons: "on",
|
|
278
283
|
mergeDuplicates: "warn",
|
|
279
|
-
namingBranch: DEFAULT_BRANCH_TEMPLATE
|
|
284
|
+
namingBranch: DEFAULT_BRANCH_TEMPLATE,
|
|
285
|
+
templates: Object.freeze([])
|
|
280
286
|
});
|
|
281
287
|
var CORE_SECTION = Object.freeze({
|
|
282
288
|
package: CORE_PACKAGE,
|
|
@@ -288,11 +294,15 @@ var CORE_SECTION = Object.freeze({
|
|
|
288
294
|
import { join as join2 } from "path";
|
|
289
295
|
|
|
290
296
|
// packages/rafa/src/core/config/config-origins.ts
|
|
291
|
-
function originOf(source, setting,
|
|
292
|
-
|
|
293
|
-
|
|
297
|
+
function originOf(source, setting, answeredBy) {
|
|
298
|
+
if (answeredBy === null || source === "cli" || source === "default")
|
|
299
|
+
return null;
|
|
300
|
+
if (source !== "template")
|
|
301
|
+
return Object.freeze({ file: answeredBy.path, entry: answeredBy.entries?.get(setting) ?? 0 });
|
|
302
|
+
const template = answeredBy.templates?.get(setting);
|
|
303
|
+
if (template === undefined)
|
|
294
304
|
return null;
|
|
295
|
-
return Object.freeze({ file:
|
|
305
|
+
return Object.freeze({ file: answeredBy.path, entry: answeredBy.entries?.get("templates") ?? 0, template });
|
|
296
306
|
}
|
|
297
307
|
|
|
298
308
|
// packages/rafa/src/core/config/section.ts
|
|
@@ -408,6 +418,21 @@ function activeDefaults() {
|
|
|
408
418
|
function activeChecks() {
|
|
409
419
|
return active.checks;
|
|
410
420
|
}
|
|
421
|
+
function requireRegistered(reader) {
|
|
422
|
+
if (active.sections.length > 0)
|
|
423
|
+
return;
|
|
424
|
+
throw new ConfigSectionError([
|
|
425
|
+
`no config section is registered: call registerCoreConfigSections from src/config-registry.ts before ${reader}`
|
|
426
|
+
]);
|
|
427
|
+
}
|
|
428
|
+
function registeredDefaults() {
|
|
429
|
+
requireRegistered("registeredDefaults");
|
|
430
|
+
return active.defaults;
|
|
431
|
+
}
|
|
432
|
+
function registeredSettings() {
|
|
433
|
+
requireRegistered("registeredSettings");
|
|
434
|
+
return active.settings;
|
|
435
|
+
}
|
|
411
436
|
function prefixesOf(key) {
|
|
412
437
|
const parts = key.split(".");
|
|
413
438
|
return parts.slice(1).map((_, index) => parts.slice(0, index + 1).join("."));
|
|
@@ -470,6 +495,15 @@ function setConfigLoadHook(hook) {
|
|
|
470
495
|
function activeConfigLoadHook() {
|
|
471
496
|
return loadHook;
|
|
472
497
|
}
|
|
498
|
+
var templateHook = null;
|
|
499
|
+
function setConfigTemplateHook(hook) {
|
|
500
|
+
const previous = templateHook;
|
|
501
|
+
templateHook = hook;
|
|
502
|
+
return previous;
|
|
503
|
+
}
|
|
504
|
+
function activeConfigTemplateHook() {
|
|
505
|
+
return templateHook;
|
|
506
|
+
}
|
|
473
507
|
|
|
474
508
|
// packages/rafa/src/core/config/config.ts
|
|
475
509
|
class ConfigError extends Error {
|
|
@@ -605,6 +639,28 @@ function unloadedPinWarnings(layer) {
|
|
|
605
639
|
];
|
|
606
640
|
return pins.flatMap(([key, map]) => [...map ?? []].filter(([, pin]) => pin === "rafa").map(([name]) => `rafa config: ${key}.${name} in ${layer.path} pins the rafa tier, ` + "which is not loaded (tiers.rafa is off), so the pin has no effect"));
|
|
607
641
|
}
|
|
642
|
+
function layTemplatesUnder(file, templates) {
|
|
643
|
+
if (templates.length === 0)
|
|
644
|
+
return file;
|
|
645
|
+
const answered = new Map;
|
|
646
|
+
const entries = registeredNames().map((setting) => {
|
|
647
|
+
const own = file.values[setting];
|
|
648
|
+
const under = templates.filter((template) => template.values[setting] !== undefined);
|
|
649
|
+
const last = under.at(-1);
|
|
650
|
+
if (last === undefined)
|
|
651
|
+
return [setting, own];
|
|
652
|
+
if (own === undefined)
|
|
653
|
+
answered.set(setting, last.name);
|
|
654
|
+
if (isMapSetting(setting))
|
|
655
|
+
return [setting, mergeMaps(...under.map((template) => template.values[setting]), own)];
|
|
656
|
+
return [setting, own ?? last.values[setting]];
|
|
657
|
+
});
|
|
658
|
+
const values = Object.fromEntries(entries);
|
|
659
|
+
return { ...file, values, templates: answered };
|
|
660
|
+
}
|
|
661
|
+
function sourceIn(layer, setting, own) {
|
|
662
|
+
return layer.templates?.has(setting) === true ? "template" : own;
|
|
663
|
+
}
|
|
608
664
|
function unknownKeyWarning(key, path) {
|
|
609
665
|
const quoted2 = JSON.stringify(key);
|
|
610
666
|
const [under, names] = activeKnownKeysAbove(key);
|
|
@@ -612,41 +668,38 @@ function unknownKeyWarning(key, path) {
|
|
|
612
668
|
return `rafa config: unknown key ${quoted2} in ${path} has no effect ` + `in this version (known keys${where}: ${names.join(", ")})`;
|
|
613
669
|
}
|
|
614
670
|
function resolveConfig(layers = {}) {
|
|
671
|
+
const local = layers.local ?? null;
|
|
615
672
|
const file = layers.file ?? null;
|
|
673
|
+
const userLocal = layers.userLocal ?? null;
|
|
616
674
|
const user = layers.user ?? null;
|
|
617
675
|
const overrides = layers.cli ?? {};
|
|
618
676
|
const { layer: cli, problems } = readLayer((setting) => isCommandLineSetting(setting) ? overrides[setting] : undefined, (setting) => ({ label: `command line: ${setting}`, key: setting }));
|
|
619
677
|
if (problems.length > 0)
|
|
620
678
|
throw new ConfigError(problems);
|
|
679
|
+
const order = [[local, "local"], [file, "file"], [userLocal, "user"], [user, "user"]];
|
|
680
|
+
const files = order.flatMap(([layer, source]) => layer === null ? [] : [{ layer, source }]);
|
|
621
681
|
const defaults = activeDefaults();
|
|
622
682
|
const rank = (setting) => {
|
|
623
683
|
const fromCli = cli[setting];
|
|
624
684
|
if (fromCli !== undefined)
|
|
625
|
-
return { value: fromCli, source: "cli" };
|
|
626
|
-
const
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return { value: merged, source };
|
|
632
|
-
}
|
|
633
|
-
if (fromFile !== undefined)
|
|
634
|
-
return { value: fromFile, source: "file" };
|
|
635
|
-
if (fromUser !== undefined)
|
|
636
|
-
return { value: fromUser, source: "user" };
|
|
637
|
-
return { value: defaults[setting], source: "default" };
|
|
685
|
+
return { value: fromCli, source: "cli", answeredBy: null };
|
|
686
|
+
const answered = files.find(({ layer }) => layer.values[setting] !== undefined);
|
|
687
|
+
const value = isMapSetting(setting) ? mergeMaps(defaults[setting], ...files.map(({ layer }) => layer.values[setting]).reverse()) : answered === undefined ? defaults[setting] : answered.layer.values[setting];
|
|
688
|
+
if (answered === undefined)
|
|
689
|
+
return { value, source: "default", answeredBy: null };
|
|
690
|
+
return { value, source: sourceIn(answered.layer, setting, answered.source), answeredBy: answered.layer };
|
|
638
691
|
};
|
|
639
692
|
const ranked = registeredNames().map((setting) => [setting, rank(setting)]);
|
|
640
693
|
const config = Object.fromEntries(ranked.map(([setting, { value }]) => [setting, value]));
|
|
641
694
|
const sources = Object.fromEntries(ranked.map(([setting, { source }]) => [setting, source]));
|
|
642
|
-
const provenance = Object.fromEntries(ranked.map(([setting, { source }]) => [setting, originOf(source, setting,
|
|
695
|
+
const provenance = Object.fromEntries(ranked.map(([setting, { source, answeredBy }]) => [setting, originOf(source, setting, answeredBy)]));
|
|
643
696
|
const path = file?.path ?? null;
|
|
644
697
|
const userPath = user?.path ?? null;
|
|
645
|
-
const checkProblems = activeChecks().flatMap((check) => check({ config, sources, path, userPath }));
|
|
698
|
+
const checkProblems = activeChecks().flatMap((check) => check({ config, sources, path, userPath, provenance }));
|
|
646
699
|
if (checkProblems.length > 0)
|
|
647
700
|
throw new ConfigError(checkProblems);
|
|
648
701
|
const rafaLoaded = ranked.find(([setting]) => setting === "tiersRafa")?.[1].value !== "off";
|
|
649
|
-
const warnings = [
|
|
702
|
+
const warnings = [...files].reverse().flatMap(({ layer }) => [
|
|
650
703
|
...layer.extras.map((extra) => unknownKeyWarning(extra.key, layer.path)),
|
|
651
704
|
...rafaLoaded ? [] : unloadedPinWarnings(layer)
|
|
652
705
|
]);
|
|
@@ -654,12 +707,15 @@ function resolveConfig(layers = {}) {
|
|
|
654
707
|
config,
|
|
655
708
|
sources,
|
|
656
709
|
path,
|
|
710
|
+
localPath: local?.path ?? null,
|
|
657
711
|
userPath,
|
|
712
|
+
userLocalPath: userLocal?.path ?? null,
|
|
658
713
|
extras: file?.extras ?? [],
|
|
714
|
+
localExtras: local?.extras ?? [],
|
|
659
715
|
userExtras: user?.extras ?? [],
|
|
716
|
+
userLocalExtras: userLocal?.extras ?? [],
|
|
660
717
|
warnings,
|
|
661
|
-
provenance
|
|
662
|
-
shadowed: []
|
|
718
|
+
provenance
|
|
663
719
|
};
|
|
664
720
|
}
|
|
665
721
|
|
|
@@ -707,4 +763,4 @@ function writeDangerousPassLines(resolved, warn, invocation) {
|
|
|
707
763
|
warn(line);
|
|
708
764
|
}
|
|
709
765
|
}
|
|
710
|
-
export { PREREQUISITE_KINDS, requiredPrerequisite, optionalPrerequisite, MODULE_SOURCE_KINDS, DEFAULT_ROUTING, CONFIG_FILE, SCOPE_DIR, CORE_SECTION, registerConfigSections, activeSections, activeSettings, activeDefaults, activeSettingByKey, setConfigLoadHook, activeConfigLoadHook, ConfigError, parseConfigDocument, configFilePath, parseConfigText, readConfigDocument, resolveConfig, writeDangerousPassLines, scopeAt };
|
|
766
|
+
export { PREREQUISITE_KINDS, requiredPrerequisite, optionalPrerequisite, MODULE_SOURCE_KINDS, DEFAULT_ROUTING, CONFIG_FILE, SCOPE_DIR, CORE_SECTION, registerConfigSections, activeSections, activeSettings, activeDefaults, registeredDefaults, registeredSettings, activeSettingByKey, setConfigLoadHook, activeConfigLoadHook, setConfigTemplateHook, activeConfigTemplateHook, ConfigError, parseConfigDocument, configFilePath, parseConfigText, readConfigDocument, layTemplatesUnder, resolveConfig, writeDangerousPassLines, scopeAt };
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
activeOutput,
|
|
4
4
|
activeOutputMode,
|
|
5
5
|
isStampableStub
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-f1y86zbb.js";
|
|
7
7
|
import {
|
|
8
8
|
CORE_SECTION,
|
|
9
9
|
SCOPE_DIR,
|
|
10
10
|
scopeAt
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-cbqvgda6.js";
|
|
12
12
|
import {
|
|
13
13
|
BUSY_TIMEOUT_MAX_MS,
|
|
14
14
|
BUSY_TIMEOUT_MIN_MS,
|
|
@@ -17,8 +17,112 @@ import {
|
|
|
17
17
|
describeValue,
|
|
18
18
|
isBusyTimeoutMs,
|
|
19
19
|
messageOf
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-r5q2pdky.js";
|
|
21
21
|
|
|
22
|
+
// packages/rafa/src/core/command/spends.ts
|
|
23
|
+
var SPENDS_GLYPH = "\uD83E\uDE99";
|
|
24
|
+
|
|
25
|
+
// packages/rafa/src/core/command/command.ts
|
|
26
|
+
var MAX_EXIT_CODE = 255;
|
|
27
|
+
|
|
28
|
+
class CommandExit extends Error {
|
|
29
|
+
exitCode;
|
|
30
|
+
constructor(exitCode, message = "", options) {
|
|
31
|
+
super(message, options);
|
|
32
|
+
if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > MAX_EXIT_CODE) {
|
|
33
|
+
throw new TypeError(`CommandExit: exit code is ${describeValue(exitCode)}, expected a whole number from 0 to ${MAX_EXIT_CODE}`);
|
|
34
|
+
}
|
|
35
|
+
this.name = "CommandExit";
|
|
36
|
+
this.exitCode = exitCode;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isTopLevel(command) {
|
|
40
|
+
return command.subject === command.action;
|
|
41
|
+
}
|
|
42
|
+
function commandSpelling(command) {
|
|
43
|
+
return isTopLevel(command) ? command.subject : `${command.subject} ${command.action}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// packages/rafa/src/core/command/confirm.ts
|
|
47
|
+
import { createInterface } from "readline";
|
|
48
|
+
var YES_ANSWERS = Object.freeze(["y", "yes"]);
|
|
49
|
+
function createLinePrompter(input, output) {
|
|
50
|
+
const buffered = [];
|
|
51
|
+
const waiting = [];
|
|
52
|
+
let ended = false;
|
|
53
|
+
const lines = createInterface({ input, terminal: false, crlfDelay: Infinity });
|
|
54
|
+
lines.on("line", (line) => {
|
|
55
|
+
const reader = waiting.shift();
|
|
56
|
+
if (reader === undefined)
|
|
57
|
+
buffered.push(line);
|
|
58
|
+
else
|
|
59
|
+
reader(line);
|
|
60
|
+
});
|
|
61
|
+
lines.on("close", () => {
|
|
62
|
+
ended = true;
|
|
63
|
+
for (const reader of waiting.splice(0))
|
|
64
|
+
reader(null);
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
say: (text) => {
|
|
68
|
+
output.write(`${text}
|
|
69
|
+
`);
|
|
70
|
+
},
|
|
71
|
+
ask: async (question) => {
|
|
72
|
+
output.write(question);
|
|
73
|
+
const next = buffered.shift();
|
|
74
|
+
if (next !== undefined)
|
|
75
|
+
return next;
|
|
76
|
+
if (ended)
|
|
77
|
+
return null;
|
|
78
|
+
return new Promise((settle) => {
|
|
79
|
+
waiting.push(settle);
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
close: () => {
|
|
83
|
+
lines.close();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function lazyPrompter(open) {
|
|
88
|
+
let prompter = null;
|
|
89
|
+
const askLine = async (question) => {
|
|
90
|
+
prompter ??= open();
|
|
91
|
+
return prompter.ask(question);
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
askLine,
|
|
95
|
+
ask: async (question) => {
|
|
96
|
+
const answer = await askLine(question);
|
|
97
|
+
return answer !== null && YES_ANSWERS.includes(answer.trim().toLowerCase());
|
|
98
|
+
},
|
|
99
|
+
close: () => {
|
|
100
|
+
prompter?.close();
|
|
101
|
+
prompter = null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// packages/rafa/src/core/command/running.ts
|
|
106
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
107
|
+
var scopes = new AsyncLocalStorage;
|
|
108
|
+
var running = null;
|
|
109
|
+
function runningCommand() {
|
|
110
|
+
return scopes.getStore() ?? running;
|
|
111
|
+
}
|
|
112
|
+
// packages/rafa/src/core/command/shared-flags.ts
|
|
113
|
+
var HINT_FLAG = "hint";
|
|
114
|
+
var HINT_FLAG_SPEC = Object.freeze({
|
|
115
|
+
name: HINT_FLAG,
|
|
116
|
+
description: "Ends by naming the one step that follows, asking it where there is a terminal to answer on;" + " `--no-hint` reads nothing and prints nothing.",
|
|
117
|
+
type: "boolean",
|
|
118
|
+
default: true
|
|
119
|
+
});
|
|
120
|
+
var DEFAULT_CI_TIMEOUT_MIN = 20;
|
|
121
|
+
// package.json
|
|
122
|
+
var version = "0.47.0";
|
|
123
|
+
|
|
124
|
+
// packages/rafa/src/core/command/version.ts
|
|
125
|
+
var RAFA_VERSION = version;
|
|
22
126
|
// packages/rafa/src/core/adapters/registry.ts
|
|
23
127
|
var REFUSAL = "adapter registry";
|
|
24
128
|
var PORT_VERSIONS = Object.freeze({
|
|
@@ -125,106 +229,6 @@ var CORE_ADAPTER_REGISTRY = Object.freeze({
|
|
|
125
229
|
resolve: (port, kind) => registered().resolve(port, kind),
|
|
126
230
|
kinds: (port) => registered().kinds(port)
|
|
127
231
|
});
|
|
128
|
-
// packages/rafa/src/effort/store/types.ts
|
|
129
|
-
function keyOrNull(value) {
|
|
130
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
131
|
-
}
|
|
132
|
-
var EFFORT_KEY_PROJECTIONS = {
|
|
133
|
-
sessions: (row) => keyOrNull(row.sessionId),
|
|
134
|
-
commits: (row) => keyOrNull(row.sha)
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// packages/rafa/src/core/command/spends.ts
|
|
138
|
-
var SPENDS_GLYPH = "\uD83E\uDE99";
|
|
139
|
-
|
|
140
|
-
// packages/rafa/src/core/command/command.ts
|
|
141
|
-
var MAX_EXIT_CODE = 255;
|
|
142
|
-
|
|
143
|
-
class CommandExit extends Error {
|
|
144
|
-
exitCode;
|
|
145
|
-
constructor(exitCode, message = "", options) {
|
|
146
|
-
super(message, options);
|
|
147
|
-
if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > MAX_EXIT_CODE) {
|
|
148
|
-
throw new TypeError(`CommandExit: exit code is ${describeValue(exitCode)}, expected a whole number from 0 to ${MAX_EXIT_CODE}`);
|
|
149
|
-
}
|
|
150
|
-
this.name = "CommandExit";
|
|
151
|
-
this.exitCode = exitCode;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
function isTopLevel(command) {
|
|
155
|
-
return command.subject === command.action;
|
|
156
|
-
}
|
|
157
|
-
function commandSpelling(command) {
|
|
158
|
-
return isTopLevel(command) ? command.subject : `${command.subject} ${command.action}`;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// packages/rafa/src/core/command/confirm.ts
|
|
162
|
-
import { createInterface } from "readline";
|
|
163
|
-
var YES_ANSWERS = Object.freeze(["y", "yes"]);
|
|
164
|
-
function createLinePrompter(input, output) {
|
|
165
|
-
const buffered = [];
|
|
166
|
-
const waiting = [];
|
|
167
|
-
let ended = false;
|
|
168
|
-
const lines = createInterface({ input, terminal: false, crlfDelay: Infinity });
|
|
169
|
-
lines.on("line", (line) => {
|
|
170
|
-
const reader = waiting.shift();
|
|
171
|
-
if (reader === undefined)
|
|
172
|
-
buffered.push(line);
|
|
173
|
-
else
|
|
174
|
-
reader(line);
|
|
175
|
-
});
|
|
176
|
-
lines.on("close", () => {
|
|
177
|
-
ended = true;
|
|
178
|
-
for (const reader of waiting.splice(0))
|
|
179
|
-
reader(null);
|
|
180
|
-
});
|
|
181
|
-
return {
|
|
182
|
-
say: (text) => {
|
|
183
|
-
output.write(`${text}
|
|
184
|
-
`);
|
|
185
|
-
},
|
|
186
|
-
ask: async (question) => {
|
|
187
|
-
output.write(question);
|
|
188
|
-
const next = buffered.shift();
|
|
189
|
-
if (next !== undefined)
|
|
190
|
-
return next;
|
|
191
|
-
if (ended)
|
|
192
|
-
return null;
|
|
193
|
-
return new Promise((settle) => {
|
|
194
|
-
waiting.push(settle);
|
|
195
|
-
});
|
|
196
|
-
},
|
|
197
|
-
close: () => {
|
|
198
|
-
lines.close();
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function lazyPrompter(open) {
|
|
203
|
-
let prompter = null;
|
|
204
|
-
return {
|
|
205
|
-
ask: async (question) => {
|
|
206
|
-
prompter ??= open();
|
|
207
|
-
const answer = await prompter.ask(question);
|
|
208
|
-
return answer !== null && YES_ANSWERS.includes(answer.trim().toLowerCase());
|
|
209
|
-
},
|
|
210
|
-
close: () => {
|
|
211
|
-
prompter?.close();
|
|
212
|
-
prompter = null;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
// packages/rafa/src/core/command/running.ts
|
|
217
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
218
|
-
var scopes = new AsyncLocalStorage;
|
|
219
|
-
var running = null;
|
|
220
|
-
function runningCommand() {
|
|
221
|
-
return scopes.getStore() ?? running;
|
|
222
|
-
}
|
|
223
|
-
// package.json
|
|
224
|
-
var version = "0.46.0";
|
|
225
|
-
|
|
226
|
-
// packages/rafa/src/core/command/version.ts
|
|
227
|
-
var RAFA_VERSION = version;
|
|
228
232
|
// packages/rafa/src/core/git/git.ts
|
|
229
233
|
import { spawnSync } from "child_process";
|
|
230
234
|
function createGitRunner(cwd) {
|
|
@@ -509,6 +513,15 @@ function commitTaskWork(options) {
|
|
|
509
513
|
message: ""
|
|
510
514
|
};
|
|
511
515
|
}
|
|
516
|
+
// packages/rafa/src/effort/store/types.ts
|
|
517
|
+
function keyOrNull(value) {
|
|
518
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
519
|
+
}
|
|
520
|
+
var EFFORT_KEY_PROJECTIONS = {
|
|
521
|
+
sessions: (row) => keyOrNull(row.sessionId),
|
|
522
|
+
commits: (row) => keyOrNull(row.sha)
|
|
523
|
+
};
|
|
524
|
+
|
|
512
525
|
// packages/rafa/src/effort/store/sqlite.ts
|
|
513
526
|
import { existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
|
|
514
527
|
import { dirname as dirname7, join as join5 } from "path";
|
|
@@ -597,7 +610,8 @@ var SESSION_PHASES = Object.freeze(["task", "wrap-up", "pull-request", "ci", "re
|
|
|
597
610
|
var RECORD_EXTENSION = ".json";
|
|
598
611
|
var SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
599
612
|
var SESSION_STEP_KINDS = Object.freeze(["baseline", "task", "stage", "pre-wrap-up"]);
|
|
600
|
-
var SESSION_STEP_REASONS = Object.freeze(["declared", "trigger", "fallback", "no-module-tests", "stage"]);
|
|
613
|
+
var SESSION_STEP_REASONS = Object.freeze(["declared", "trigger", "fallback", "no-module-tests", "stage", "no-check", "unit"]);
|
|
614
|
+
var NONE_STEP_SCOPE = "none";
|
|
601
615
|
var SESSION_DECISION_STRATEGIES = Object.freeze(["jump", "defer"]);
|
|
602
616
|
|
|
603
617
|
class SessionRecordError extends Error {
|
|
@@ -678,21 +692,38 @@ function stepInterruptedProblem(step, at) {
|
|
|
678
692
|
const interrupted = field(step, "interrupted");
|
|
679
693
|
return interrupted === true ? null : `${at}.interrupted is ${describeValue2(interrupted)}, expected true or no key`;
|
|
680
694
|
}
|
|
695
|
+
function stepScopeProblem(scope, at) {
|
|
696
|
+
return TEST_SCOPES.includes(scope) || scope === NONE_STEP_SCOPE || isTextList(scope) ? null : `${at}.scope is ${describeValue2(scope)}, expected one of ${TEST_SCOPES.join(", ")}, ${NONE_STEP_SCOPE} or a list of paths`;
|
|
697
|
+
}
|
|
698
|
+
function stepCommandProblem(command, scope, at) {
|
|
699
|
+
if (scope === NONE_STEP_SCOPE) {
|
|
700
|
+
return Array.isArray(command) && command.length === 0 ? null : `${at}.command is ${describeValue2(command)}, expected an empty list on a ${NONE_STEP_SCOPE} step`;
|
|
701
|
+
}
|
|
702
|
+
return isTextList(command) && command.length > 0 ? null : `${at}.command is ${describeValue2(command)}, expected a non-empty list of arguments`;
|
|
703
|
+
}
|
|
704
|
+
function noneStepProblems(step, at) {
|
|
705
|
+
const exitCode = field(step, "exitCode");
|
|
706
|
+
const failures = field(step, "failures");
|
|
707
|
+
return [
|
|
708
|
+
Number.isSafeInteger(exitCode) && exitCode !== 0 ? `${at}.exitCode is ${describeValue2(exitCode)}, expected 0 on a ${NONE_STEP_SCOPE} step` : null,
|
|
709
|
+
Array.isArray(failures) && failures.length > 0 ? `${at}.failures is ${describeValue2(failures)}, expected none on a ${NONE_STEP_SCOPE} step` : null
|
|
710
|
+
].filter((problem) => problem !== null);
|
|
711
|
+
}
|
|
681
712
|
function stepProblems(step, at) {
|
|
682
713
|
if (!isObject(step))
|
|
683
714
|
return [`${at} is ${describeValue2(step)}, expected a step`];
|
|
684
715
|
const kind = field(step, "kind");
|
|
685
716
|
const scope = field(step, "scope");
|
|
686
|
-
const command = field(step, "command");
|
|
687
717
|
const exitCode = field(step, "exitCode");
|
|
688
718
|
const summary = field(step, "summary");
|
|
689
719
|
const problems = [
|
|
690
720
|
SESSION_STEP_KINDS.includes(kind) ? null : `${at}.kind is ${describeValue2(kind)}, expected one of ${SESSION_STEP_KINDS.join(", ")}`,
|
|
691
|
-
|
|
692
|
-
|
|
721
|
+
stepScopeProblem(scope, at),
|
|
722
|
+
stepCommandProblem(field(step, "command"), scope, at),
|
|
693
723
|
typeof exitCode === "number" && Number.isSafeInteger(exitCode) ? null : `${at}.exitCode is ${describeValue2(exitCode)}, expected a whole number`,
|
|
694
724
|
summary === null || typeof summary === "string" ? null : `${at}.summary is ${describeValue2(summary)}, expected null or a string`,
|
|
695
725
|
stepFailuresProblem(step, at),
|
|
726
|
+
...scope === NONE_STEP_SCOPE ? noneStepProblems(step, at) : [],
|
|
696
727
|
stepInterruptedProblem(step, at)
|
|
697
728
|
];
|
|
698
729
|
return problems.filter((problem) => problem !== null);
|
|
@@ -833,11 +864,15 @@ function isSessionStepReason(value) {
|
|
|
833
864
|
function reasonEntry(reason) {
|
|
834
865
|
return isSessionStepReason(reason) ? { reason } : {};
|
|
835
866
|
}
|
|
867
|
+
function declaredEntry(scope, declared) {
|
|
868
|
+
return scope === NONE_STEP_SCOPE && TEST_SCOPES.includes(declared) ? { declared } : {};
|
|
869
|
+
}
|
|
836
870
|
function freezeStep(step) {
|
|
837
871
|
return Object.freeze({
|
|
838
872
|
kind: step.kind,
|
|
839
873
|
scope: typeof step.scope === "string" ? step.scope : Object.freeze([...step.scope]),
|
|
840
874
|
...reasonEntry(field(step, "reason")),
|
|
875
|
+
...declaredEntry(step.scope, field(step, "declared")),
|
|
841
876
|
command: Object.freeze([...step.command]),
|
|
842
877
|
exitCode: step.exitCode,
|
|
843
878
|
summary: step.summary,
|
|
@@ -2594,4 +2629,4 @@ function openSqliteStore(repoRoot) {
|
|
|
2594
2629
|
// packages/rafa/src/effort/store/trusted-permissions.ts
|
|
2595
2630
|
var TRUSTED_PERMISSIONS = ["admin", "maintain", "write"];
|
|
2596
2631
|
|
|
2597
|
-
export {
|
|
2632
|
+
export { SPENDS_GLYPH, CommandExit, commandSpelling, createLinePrompter, lazyPrompter, HINT_FLAG, HINT_FLAG_SPEC, DEFAULT_CI_TIMEOUT_MIN, RAFA_VERSION, setActiveStoreSettings, activeStoreSettings, PORT_VERSIONS, createAdapterRegistry, registerAdapters, restoreAdapters, activeAdapterRegistry, CORE_ADAPTER_REGISTRY, readRuntimeIdentity, isRecord, asPlace, asHopRecord, SessionRecordError, isSessionId, sessionSteps, sessionDecisions, SessionConflictError, runsDir, sessionFilePath, errorCode, isPidAlive, readSessions, readSession, samePlan, beginSession, updateSession, claudeArgs, interruptClaudeSessions, spawnClaude, runClaude, spawnClaudeCaptured, runClaudeCaptured, effortStoreFileName, readStoreRows, collectedKeys, appendRows, EFFORT_DIR_VARIABLE, effortStoreDir, guardTestProcess, DEVELOPMENT_NEXT_STEP, appliedByName, DevelopmentBuildRefusedError, storeProjectRoot, refuseUnownedDevelopmentWrite, SQLITE_MIGRATIONS, sqliteCatalogue, planSchema, MIGRATION_LOG_TABLE, bringForward, readStoreSchema, writeNames, ACROSS_STORES_ORDER, STAMPED_COLUMNS, stampedValues, writeStoreGeneration, createGitRunner, gitSaid, commitTaskWork, PROJECT_ID_LENGTH, PROJECT_ID_PATTERN, normalizeRemote, gitRemoteUrl, readProjectIdentity, readReplacedStoreIds, readStoreMeta, carryStoreIdentity, EFFORT_KEY_PROJECTIONS, SQLITE_STORE_FILE_NAME, sqliteStorePath, LONE_SURROGATE, withSqliteStore, writeSqliteStore, openSqliteStore, TRUSTED_PERMISSIONS };
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/rafa/src/core/plan/plan-stamp.ts
|
|
3
|
+
var STUB_PATTERN = "[A-Za-z0-9._-]+";
|
|
4
|
+
var STAMP_PATTERN = new RegExp(`<!--\\s*ralph:plan=(${STUB_PATTERN})\\s*-->`);
|
|
5
|
+
function isStampableStub(stub) {
|
|
6
|
+
return new RegExp(`^${STUB_PATTERN}$`).test(stub);
|
|
7
|
+
}
|
|
8
|
+
function planStampLine(stub) {
|
|
9
|
+
if (!isStampableStub(stub)) {
|
|
10
|
+
throw new Error(`rafa plan stamp: unusable stub ${JSON.stringify(stub)}`);
|
|
11
|
+
}
|
|
12
|
+
return `<!-- ralph:plan=${stub} -->`;
|
|
13
|
+
}
|
|
14
|
+
function planStubFromPrompt(content) {
|
|
15
|
+
if (typeof content !== "string" || content.length === 0)
|
|
16
|
+
return null;
|
|
17
|
+
const match = STAMP_PATTERN.exec(content);
|
|
18
|
+
const stub = match?.[1];
|
|
19
|
+
return stub !== undefined && isStampableStub(stub) ? stub : null;
|
|
20
|
+
}
|
|
21
|
+
function stampPrompt(stub, prompt) {
|
|
22
|
+
return `${prompt}
|
|
23
|
+
${planStampLine(stub)}`;
|
|
24
|
+
}
|
|
25
|
+
function planStubFromPath(planPath) {
|
|
26
|
+
const base = planPath.split("/").pop() ?? planPath;
|
|
27
|
+
const match = /^PLAN(?:_TRACKER)?-(.+)\.md$/.exec(base);
|
|
28
|
+
const stub = match?.[1];
|
|
29
|
+
return stub !== undefined && isStampableStub(stub) ? stub : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
2
32
|
// packages/rafa/src/core/output/text.ts
|
|
3
33
|
var DEBUG_VERBOSITY = 2;
|
|
4
34
|
function formatPayload(payload) {
|
|
@@ -92,34 +122,4 @@ function activeOutputMode() {
|
|
|
92
122
|
return scopes.getStore()?.mode ?? activeMode;
|
|
93
123
|
}
|
|
94
124
|
|
|
95
|
-
|
|
96
|
-
var STUB_PATTERN = "[A-Za-z0-9._-]+";
|
|
97
|
-
var STAMP_PATTERN = new RegExp(`<!--\\s*ralph:plan=(${STUB_PATTERN})\\s*-->`);
|
|
98
|
-
function isStampableStub(stub) {
|
|
99
|
-
return new RegExp(`^${STUB_PATTERN}$`).test(stub);
|
|
100
|
-
}
|
|
101
|
-
function planStampLine(stub) {
|
|
102
|
-
if (!isStampableStub(stub)) {
|
|
103
|
-
throw new Error(`rafa plan stamp: unusable stub ${JSON.stringify(stub)}`);
|
|
104
|
-
}
|
|
105
|
-
return `<!-- ralph:plan=${stub} -->`;
|
|
106
|
-
}
|
|
107
|
-
function planStubFromPrompt(content) {
|
|
108
|
-
if (typeof content !== "string" || content.length === 0)
|
|
109
|
-
return null;
|
|
110
|
-
const match = STAMP_PATTERN.exec(content);
|
|
111
|
-
const stub = match?.[1];
|
|
112
|
-
return stub !== undefined && isStampableStub(stub) ? stub : null;
|
|
113
|
-
}
|
|
114
|
-
function stampPrompt(stub, prompt) {
|
|
115
|
-
return `${prompt}
|
|
116
|
-
${planStampLine(stub)}`;
|
|
117
|
-
}
|
|
118
|
-
function planStubFromPath(planPath) {
|
|
119
|
-
const base = planPath.split("/").pop() ?? planPath;
|
|
120
|
-
const match = /^PLAN(?:_TRACKER)?-(.+)\.md$/.exec(base);
|
|
121
|
-
const stub = match?.[1];
|
|
122
|
-
return stub !== undefined && isStampableStub(stub) ? stub : null;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { createTextOutput, activeOutput, activeOutputMode, isStampableStub, planStubFromPrompt, stampPrompt, planStubFromPath };
|
|
125
|
+
export { isStampableStub, planStubFromPrompt, stampPrompt, planStubFromPath, createTextOutput, activeOutput, activeOutputMode };
|