@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
package/dist/learning/index.js
CHANGED
package/dist/plan/index.js
CHANGED
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
renderInjection,
|
|
20
20
|
runPreflight,
|
|
21
21
|
runShellProbe
|
|
22
|
-
} from "../index-
|
|
23
|
-
import"../index-
|
|
22
|
+
} from "../index-nwzx41g1.js";
|
|
23
|
+
import"../index-f1y86zbb.js";
|
|
24
24
|
import {
|
|
25
25
|
INJECT_MODES
|
|
26
|
-
} from "../index-
|
|
26
|
+
} from "../index-r5q2pdky.js";
|
|
27
27
|
import"../index-z1w83f81.js";
|
|
28
28
|
export {
|
|
29
29
|
runShellProbe,
|
package/dist/ports/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* subpath, declared in phase 0 and filled in phase 1. Phase 1 puts one
|
|
8
8
|
* adapter per port under `src/adapters/` and lets an add-on register
|
|
9
9
|
* more by name; core imports an add-on only from a `path` source the
|
|
10
|
-
* config's `allowList:` names (`src/modules/load.ts`). What those adapters
|
|
10
|
+
* config's `allowList:` names (`packages/rafa/src/modules/load.ts`). What those adapters
|
|
11
11
|
* implement is declared here first, so a service (the orchestrator's
|
|
12
12
|
* worker pool, a Drizzle-backed store) can type an implementation
|
|
13
13
|
* against the subpath without importing the CLI.
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
typeOfLabels,
|
|
49
49
|
writeHopRecord,
|
|
50
50
|
writePositionFile
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-7dgc5g1t.js";
|
|
52
52
|
import {
|
|
53
53
|
countTasks,
|
|
54
54
|
isFile,
|
|
@@ -56,25 +56,27 @@ import {
|
|
|
56
56
|
planFileName,
|
|
57
57
|
plural,
|
|
58
58
|
stubOfPlanFile
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-nwzx41g1.js";
|
|
60
60
|
import {
|
|
61
61
|
CommandExit,
|
|
62
|
+
HINT_FLAG,
|
|
63
|
+
HINT_FLAG_SPEC,
|
|
62
64
|
commandSpelling,
|
|
63
65
|
createGitRunner,
|
|
64
66
|
createLinePrompter,
|
|
65
67
|
gitSaid,
|
|
66
68
|
lazyPrompter
|
|
67
|
-
} from "./index-
|
|
68
|
-
import"./index-
|
|
69
|
-
import"./index-
|
|
69
|
+
} from "./index-eay1bd2w.js";
|
|
70
|
+
import"./index-f1y86zbb.js";
|
|
71
|
+
import"./index-pzpb1rf7.js";
|
|
70
72
|
import {
|
|
71
73
|
ConfigError
|
|
72
|
-
} from "./index-
|
|
74
|
+
} from "./index-cbqvgda6.js";
|
|
73
75
|
import {
|
|
74
76
|
DEFAULT_BRANCH_TEMPLATE,
|
|
75
77
|
branchFromTemplate,
|
|
76
78
|
messageOf
|
|
77
|
-
} from "./index-
|
|
79
|
+
} from "./index-r5q2pdky.js";
|
|
78
80
|
import"./index-z1w83f81.js";
|
|
79
81
|
|
|
80
82
|
// src/cli/core/parseArgs.ts
|
|
@@ -158,32 +160,8 @@ function parseArgs(argv, spec = {}) {
|
|
|
158
160
|
return { positional, flags };
|
|
159
161
|
}
|
|
160
162
|
|
|
161
|
-
// src/next/
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
return (await loadConfig({ root, home }, {}, () => {
|
|
165
|
-
return;
|
|
166
|
-
})).config;
|
|
167
|
-
} catch (error) {
|
|
168
|
-
if (error instanceof ConfigError)
|
|
169
|
-
return null;
|
|
170
|
-
throw error;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
async function openNextRelations(context, seams) {
|
|
174
|
-
const { project } = context;
|
|
175
|
-
if (project === null)
|
|
176
|
-
return;
|
|
177
|
-
const config = await modeConfig(project.root, project.home);
|
|
178
|
-
if (config?.boardRelationships !== "native")
|
|
179
|
-
return;
|
|
180
|
-
const provider = resolvePrProvider({ configured: config.prProvider, dir: project.root, readRemote: seams.readRemote });
|
|
181
|
-
if (provider.provider !== "gh")
|
|
182
|
-
return;
|
|
183
|
-
const gh = (seams.openGh ?? ((root) => createGhRunner({ cwd: root })))(project.root);
|
|
184
|
-
const repository = await readBoardRepository(gh);
|
|
185
|
-
return selectBoardRelations(config, { gh, repository });
|
|
186
|
-
}
|
|
163
|
+
// src/next/hop-action.ts
|
|
164
|
+
import { rmSync } from "fs";
|
|
187
165
|
|
|
188
166
|
// src/plan/list.ts
|
|
189
167
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
@@ -595,6 +573,252 @@ async function readHopDry(world) {
|
|
|
595
573
|
};
|
|
596
574
|
}
|
|
597
575
|
|
|
576
|
+
// src/next/hop-action.ts
|
|
577
|
+
var NO_REHOME = "--no-rehome";
|
|
578
|
+
function hopLogLine(opening) {
|
|
579
|
+
const { from, blocked, target, targetEpic, targetBoard } = opening;
|
|
580
|
+
if (opening.kind === "dry" || blocked === null || target === null) {
|
|
581
|
+
return dryHopSentence({ number: from.epic ?? from.board }, { number: targetEpic, board: targetBoard });
|
|
582
|
+
}
|
|
583
|
+
return hopMoveSentence({ from, blocked, blocker: target, epic: targetEpic });
|
|
584
|
+
}
|
|
585
|
+
function homeLogLine(home) {
|
|
586
|
+
return `back home: ${placeText(home)}`;
|
|
587
|
+
}
|
|
588
|
+
function openedRecord(opening, now) {
|
|
589
|
+
return {
|
|
590
|
+
...opening,
|
|
591
|
+
state: "away",
|
|
592
|
+
pullRequest: null,
|
|
593
|
+
startedAt: now.toISOString()
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function writeRecord(root, record) {
|
|
597
|
+
try {
|
|
598
|
+
writeHopRecord(root, record);
|
|
599
|
+
} catch (error) {
|
|
600
|
+
throw new CommandExit(1, `\u274C Could not write ${hopFilePath(root)}: ${messageOf(error)}`);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function restoreRecord(root, before) {
|
|
604
|
+
if (before.set)
|
|
605
|
+
writeHopRecord(root, before.record);
|
|
606
|
+
else
|
|
607
|
+
rmSync(hopFilePath(root), { force: true });
|
|
608
|
+
}
|
|
609
|
+
async function runHop(world, step) {
|
|
610
|
+
const { opening } = step;
|
|
611
|
+
const before = readHopRecord(world.root);
|
|
612
|
+
const record = openedRecord(opening, world.now());
|
|
613
|
+
writeRecord(world.root, record);
|
|
614
|
+
try {
|
|
615
|
+
await world.switchTo([String(opening.targetEpic), NO_REHOME]);
|
|
616
|
+
} catch (error) {
|
|
617
|
+
restoreRecord(world.root, before);
|
|
618
|
+
throw error;
|
|
619
|
+
}
|
|
620
|
+
world.info(hopLogLine(opening));
|
|
621
|
+
return record;
|
|
622
|
+
}
|
|
623
|
+
function writePosition(root, position) {
|
|
624
|
+
try {
|
|
625
|
+
writePositionFile(root, position);
|
|
626
|
+
} catch (error) {
|
|
627
|
+
throw new CommandExit(1, `\u274C Could not write ${positionFilePath(root)}: ${messageOf(error)}`);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
function movedHome(world, step) {
|
|
631
|
+
const reading = readPositionFile(world.root);
|
|
632
|
+
if (reading.set) {
|
|
633
|
+
if (samePlace(reading.position.current, reading.position.home))
|
|
634
|
+
return { now: reading.position, written: false };
|
|
635
|
+
return { now: goHome(reading.position), written: true };
|
|
636
|
+
}
|
|
637
|
+
if (reading.reason === "absent")
|
|
638
|
+
return { now: null, written: false };
|
|
639
|
+
world.warn(`${reading.detail}, so it is written afresh at home`);
|
|
640
|
+
return { now: positionAt(step.home), written: true };
|
|
641
|
+
}
|
|
642
|
+
function awayToClose(world, position) {
|
|
643
|
+
const reading = readHopRecord(world.root);
|
|
644
|
+
if (!reading.set) {
|
|
645
|
+
if (reading.reason !== "absent")
|
|
646
|
+
world.warn(`${reading.detail}, so no hop record is closed`);
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
const { record } = reading;
|
|
650
|
+
if (record.state !== "away" || position === null)
|
|
651
|
+
return null;
|
|
652
|
+
return staleAgainst(record, position) ? null : record;
|
|
653
|
+
}
|
|
654
|
+
function runHome(world, step) {
|
|
655
|
+
const moved = movedHome(world, step);
|
|
656
|
+
if (moved.written && moved.now !== null)
|
|
657
|
+
writePosition(world.root, moved.now);
|
|
658
|
+
const away = awayToClose(world, moved.now);
|
|
659
|
+
const closed = away === null ? null : { ...away, state: step.closing, pullRequest: step.pullRequest ?? away.pullRequest };
|
|
660
|
+
if (closed !== null)
|
|
661
|
+
writeRecord(world.root, closed);
|
|
662
|
+
const line = homeLogLine(moved.now?.home ?? step.home);
|
|
663
|
+
world.info(line);
|
|
664
|
+
return Object.freeze({
|
|
665
|
+
position: moved.written ? moved.now : null,
|
|
666
|
+
record: closed,
|
|
667
|
+
line
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// src/next/actions.ts
|
|
672
|
+
var PREFIX = "rafa next";
|
|
673
|
+
var NEXT_IN_PROCESS_ACTIONS = Object.freeze(["sync", "hop", "home"]);
|
|
674
|
+
var SWITCH_COMMAND = Object.freeze({ subject: "switch", action: "switch" });
|
|
675
|
+
var ROADMAP_WORD = "--roadmap";
|
|
676
|
+
var ROADMAP_PASSED_ACTIONS = new Set(["plan", "start", "resume"]);
|
|
677
|
+
var CLAIM_AHEAD_WORD = "--claim-ahead";
|
|
678
|
+
function passedWords(action, options) {
|
|
679
|
+
if (options.roadmap !== true || !ROADMAP_PASSED_ACTIONS.has(action))
|
|
680
|
+
return [];
|
|
681
|
+
return options.claimAhead === true && action === "plan" ? [ROADMAP_WORD, CLAIM_AHEAD_WORD] : [ROADMAP_WORD];
|
|
682
|
+
}
|
|
683
|
+
function needed(state, value, what) {
|
|
684
|
+
if (value === null) {
|
|
685
|
+
throw new Error(`${PREFIX}: state "${state.id}" proposes "${state.action}" and names no ${what}`);
|
|
686
|
+
}
|
|
687
|
+
return String(value);
|
|
688
|
+
}
|
|
689
|
+
function pullRequestOf(state) {
|
|
690
|
+
return needed(state, state.pullRequest, "pull request");
|
|
691
|
+
}
|
|
692
|
+
function issueOf(state) {
|
|
693
|
+
return needed(state, state.issue, "issue");
|
|
694
|
+
}
|
|
695
|
+
function planFlagOf(state) {
|
|
696
|
+
return `--plan=${needed(state, state.planPath, "plan file")}`;
|
|
697
|
+
}
|
|
698
|
+
var ACTION_COMMANDS = Object.freeze({
|
|
699
|
+
resume: { subject: "loop", action: "start", argv: (state) => [planFlagOf(state)] },
|
|
700
|
+
wait: { subject: "pr", action: "wait", argv: (state) => [pullRequestOf(state)] },
|
|
701
|
+
triage: { subject: "pr", action: "triage", argv: (state) => [pullRequestOf(state)] },
|
|
702
|
+
merge: { subject: "pr", action: "merge", argv: (state) => [pullRequestOf(state), "--yes"] },
|
|
703
|
+
"merge-unchecked": { subject: "pr", action: "merge", argv: (state) => [pullRequestOf(state), "--skip-checks"] },
|
|
704
|
+
settle: { subject: "release", action: "settle", argv: () => [] },
|
|
705
|
+
start: { subject: "loop", action: "start", argv: (state) => [planFlagOf(state), "--create-branch"] },
|
|
706
|
+
plan: { subject: "plan", action: "create", argv: () => ["--next"] },
|
|
707
|
+
unblock: { subject: "issue", action: "unblock", argv: (state) => [issueOf(state)] },
|
|
708
|
+
ready: { subject: "issue", action: "ready", argv: (state) => [issueOf(state)] }
|
|
709
|
+
});
|
|
710
|
+
var NEXT_COMMAND_ACTIONS = Object.freeze(Object.keys(ACTION_COMMANDS));
|
|
711
|
+
var LABELS_ONLY_ACTIONS = new Set(["unblock"]);
|
|
712
|
+
var OFFERED_COMMAND_ACTIONS = Object.freeze({
|
|
713
|
+
labels: NEXT_COMMAND_ACTIONS,
|
|
714
|
+
native: Object.freeze(NEXT_COMMAND_ACTIONS.filter((action) => !LABELS_ONLY_ACTIONS.has(action)))
|
|
715
|
+
});
|
|
716
|
+
function offeredCommandActions(mode) {
|
|
717
|
+
return OFFERED_COMMAND_ACTIONS[mode];
|
|
718
|
+
}
|
|
719
|
+
function notOffered(state, mode) {
|
|
720
|
+
return new Error(`${PREFIX}: state "${state.id}" proposes "${state.action}", which is offered in labels mode only` + ` and board.relationships is ${mode}: the tracker clears a blocker when it closes`);
|
|
721
|
+
}
|
|
722
|
+
function runsCommand(action) {
|
|
723
|
+
return NEXT_COMMAND_ACTIONS.includes(action);
|
|
724
|
+
}
|
|
725
|
+
function actionInvocation(state, options = {}) {
|
|
726
|
+
if (!runsCommand(state.action))
|
|
727
|
+
return null;
|
|
728
|
+
const mode = options.mode ?? "labels";
|
|
729
|
+
if (!offeredCommandActions(mode).includes(state.action))
|
|
730
|
+
throw notOffered(state, mode);
|
|
731
|
+
const spec = ACTION_COMMANDS[state.action];
|
|
732
|
+
return Object.freeze({
|
|
733
|
+
action: state.action,
|
|
734
|
+
command: commandSpelling(spec),
|
|
735
|
+
argv: Object.freeze([...spec.argv(state), ...passedWords(state.action, options)])
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
function actionContext(caller, command, argv) {
|
|
739
|
+
const { positional, flags } = parseArgs(argv, command);
|
|
740
|
+
return Object.freeze({
|
|
741
|
+
...caller,
|
|
742
|
+
args: Object.freeze(positional),
|
|
743
|
+
flags: Object.freeze({ ...flags, [HINT_FLAG]: false }),
|
|
744
|
+
argv: Object.freeze([...argv])
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
async function runRegistered(caller, name, argv, step) {
|
|
748
|
+
const command = caller.registry.find(name.subject, name.action);
|
|
749
|
+
if (command === undefined) {
|
|
750
|
+
throw new CommandExit(1, `\u274C ${PREFIX}: the "${step}" step runs "rafa ${commandSpelling(name)}", which is registered by nothing`);
|
|
751
|
+
}
|
|
752
|
+
await command.run(actionContext(caller, command, argv));
|
|
753
|
+
}
|
|
754
|
+
function hopWorld(caller, state) {
|
|
755
|
+
if (caller.project === null) {
|
|
756
|
+
throw new Error(`${PREFIX}: the action "${state.action}" of state "${state.id}" runs inside a project, and was handed none`);
|
|
757
|
+
}
|
|
758
|
+
return {
|
|
759
|
+
root: caller.project.root,
|
|
760
|
+
switchTo: (argv) => runRegistered(caller, SWITCH_COMMAND, argv, state.action),
|
|
761
|
+
info: (line) => {
|
|
762
|
+
caller.output.info(line);
|
|
763
|
+
},
|
|
764
|
+
warn: (line) => {
|
|
765
|
+
caller.output.warn(line);
|
|
766
|
+
},
|
|
767
|
+
now: () => new Date
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function noStep(state) {
|
|
771
|
+
return new Error(`${PREFIX}: state "${state.id}" proposes "${state.action}" and carries no ${state.action} step`);
|
|
772
|
+
}
|
|
773
|
+
async function runHopStep(caller, state) {
|
|
774
|
+
const step = state.hop;
|
|
775
|
+
if (step?.action !== state.action)
|
|
776
|
+
throw noStep(state);
|
|
777
|
+
if (step.action === "hop") {
|
|
778
|
+
await runHop(hopWorld(caller, state), step);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
runHome(hopWorld(caller, state), step);
|
|
782
|
+
}
|
|
783
|
+
async function runAction(caller, state, options = {}) {
|
|
784
|
+
if (state.action === "hop" || state.action === "home") {
|
|
785
|
+
await runHopStep(caller, state);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
const invocation = actionInvocation(state, options);
|
|
789
|
+
if (invocation === null) {
|
|
790
|
+
throw new Error(`${PREFIX}: the action "${state.action}" of state "${state.id}" runs no registered command`);
|
|
791
|
+
}
|
|
792
|
+
await runRegistered(caller, ACTION_COMMANDS[invocation.action], invocation.argv, invocation.action);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// src/next/relations-mode.ts
|
|
796
|
+
async function modeConfig(root, home) {
|
|
797
|
+
try {
|
|
798
|
+
return (await loadConfig({ root, home }, {}, () => {
|
|
799
|
+
return;
|
|
800
|
+
})).config;
|
|
801
|
+
} catch (error) {
|
|
802
|
+
if (error instanceof ConfigError)
|
|
803
|
+
return null;
|
|
804
|
+
throw error;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
async function openNextRelations(context, seams) {
|
|
808
|
+
const { project } = context;
|
|
809
|
+
if (project === null)
|
|
810
|
+
return;
|
|
811
|
+
const config = await modeConfig(project.root, project.home);
|
|
812
|
+
if (config?.boardRelationships !== "native")
|
|
813
|
+
return;
|
|
814
|
+
const provider = resolvePrProvider({ configured: config.prProvider, dir: project.root, readRemote: seams.readRemote });
|
|
815
|
+
if (provider.provider !== "gh")
|
|
816
|
+
return;
|
|
817
|
+
const gh = (seams.openGh ?? ((root) => createGhRunner({ cwd: root })))(project.root);
|
|
818
|
+
const repository = await readBoardRepository(gh);
|
|
819
|
+
return selectBoardRelations(config, { gh, repository });
|
|
820
|
+
}
|
|
821
|
+
|
|
598
822
|
// src/next/preconditions.ts
|
|
599
823
|
var MAX_NAMED_FILES = 5;
|
|
600
824
|
function nameFiles(paths) {
|
|
@@ -635,7 +859,7 @@ async function readPullsUnusable(world) {
|
|
|
635
859
|
}
|
|
636
860
|
|
|
637
861
|
// src/next/state.ts
|
|
638
|
-
var
|
|
862
|
+
var PREFIX2 = "rafa next";
|
|
639
863
|
var NEXT_PRECONDITIONS = Object.freeze([
|
|
640
864
|
"tree-modified",
|
|
641
865
|
"pulls-unusable"
|
|
@@ -901,11 +1125,10 @@ async function readNextState(sources) {
|
|
|
901
1125
|
const found = await firstAnswer(world, rows.filter((row) => ahead.has(row.id))) ?? readTreeModified(world) ?? await firstAnswer(world, rows.filter((row) => !ahead.has(row.id)));
|
|
902
1126
|
if (found !== null)
|
|
903
1127
|
return answer(found, world.problems());
|
|
904
|
-
throw new Error(`${
|
|
1128
|
+
throw new Error(`${PREFIX2}: no row of the table answered, and the last row answers for every reading`);
|
|
905
1129
|
}
|
|
906
1130
|
|
|
907
1131
|
// src/next/hint.ts
|
|
908
|
-
var HINT_FLAG = "hint";
|
|
909
1132
|
var HINT_TIMEOUT_MS = 2000;
|
|
910
1133
|
var HINT_MARK = "\uD83D\uDC49";
|
|
911
1134
|
var HINT_LEAD = "Next:";
|
|
@@ -986,233 +1209,7 @@ async function nextStepHint(context, seams = DEFAULT_HINT_SEAMS) {
|
|
|
986
1209
|
}
|
|
987
1210
|
}
|
|
988
1211
|
|
|
989
|
-
// src/next/hop-action.ts
|
|
990
|
-
import { rmSync } from "fs";
|
|
991
|
-
var NO_REHOME = "--no-rehome";
|
|
992
|
-
function hopLogLine(opening) {
|
|
993
|
-
const { from, blocked, target, targetEpic, targetBoard } = opening;
|
|
994
|
-
if (opening.kind === "dry" || blocked === null || target === null) {
|
|
995
|
-
return dryHopSentence({ number: from.epic ?? from.board }, { number: targetEpic, board: targetBoard });
|
|
996
|
-
}
|
|
997
|
-
return hopMoveSentence({ from, blocked, blocker: target, epic: targetEpic });
|
|
998
|
-
}
|
|
999
|
-
function homeLogLine(home) {
|
|
1000
|
-
return `back home: ${placeText(home)}`;
|
|
1001
|
-
}
|
|
1002
|
-
function openedRecord(opening, now) {
|
|
1003
|
-
return {
|
|
1004
|
-
...opening,
|
|
1005
|
-
state: "away",
|
|
1006
|
-
pullRequest: null,
|
|
1007
|
-
startedAt: now.toISOString()
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
function writeRecord(root, record) {
|
|
1011
|
-
try {
|
|
1012
|
-
writeHopRecord(root, record);
|
|
1013
|
-
} catch (error) {
|
|
1014
|
-
throw new CommandExit(1, `\u274C Could not write ${hopFilePath(root)}: ${messageOf(error)}`);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
function restoreRecord(root, before) {
|
|
1018
|
-
if (before.set)
|
|
1019
|
-
writeHopRecord(root, before.record);
|
|
1020
|
-
else
|
|
1021
|
-
rmSync(hopFilePath(root), { force: true });
|
|
1022
|
-
}
|
|
1023
|
-
async function runHop(world, step) {
|
|
1024
|
-
const { opening } = step;
|
|
1025
|
-
const before = readHopRecord(world.root);
|
|
1026
|
-
const record = openedRecord(opening, world.now());
|
|
1027
|
-
writeRecord(world.root, record);
|
|
1028
|
-
try {
|
|
1029
|
-
await world.switchTo([String(opening.targetEpic), NO_REHOME]);
|
|
1030
|
-
} catch (error) {
|
|
1031
|
-
restoreRecord(world.root, before);
|
|
1032
|
-
throw error;
|
|
1033
|
-
}
|
|
1034
|
-
world.info(hopLogLine(opening));
|
|
1035
|
-
return record;
|
|
1036
|
-
}
|
|
1037
|
-
function writePosition(root, position) {
|
|
1038
|
-
try {
|
|
1039
|
-
writePositionFile(root, position);
|
|
1040
|
-
} catch (error) {
|
|
1041
|
-
throw new CommandExit(1, `\u274C Could not write ${positionFilePath(root)}: ${messageOf(error)}`);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
function movedHome(world, step) {
|
|
1045
|
-
const reading = readPositionFile(world.root);
|
|
1046
|
-
if (reading.set) {
|
|
1047
|
-
if (samePlace(reading.position.current, reading.position.home))
|
|
1048
|
-
return { now: reading.position, written: false };
|
|
1049
|
-
return { now: goHome(reading.position), written: true };
|
|
1050
|
-
}
|
|
1051
|
-
if (reading.reason === "absent")
|
|
1052
|
-
return { now: null, written: false };
|
|
1053
|
-
world.warn(`${reading.detail}, so it is written afresh at home`);
|
|
1054
|
-
return { now: positionAt(step.home), written: true };
|
|
1055
|
-
}
|
|
1056
|
-
function awayToClose(world, position) {
|
|
1057
|
-
const reading = readHopRecord(world.root);
|
|
1058
|
-
if (!reading.set) {
|
|
1059
|
-
if (reading.reason !== "absent")
|
|
1060
|
-
world.warn(`${reading.detail}, so no hop record is closed`);
|
|
1061
|
-
return null;
|
|
1062
|
-
}
|
|
1063
|
-
const { record } = reading;
|
|
1064
|
-
if (record.state !== "away" || position === null)
|
|
1065
|
-
return null;
|
|
1066
|
-
return staleAgainst(record, position) ? null : record;
|
|
1067
|
-
}
|
|
1068
|
-
function runHome(world, step) {
|
|
1069
|
-
const moved = movedHome(world, step);
|
|
1070
|
-
if (moved.written && moved.now !== null)
|
|
1071
|
-
writePosition(world.root, moved.now);
|
|
1072
|
-
const away = awayToClose(world, moved.now);
|
|
1073
|
-
const closed = away === null ? null : { ...away, state: step.closing, pullRequest: step.pullRequest ?? away.pullRequest };
|
|
1074
|
-
if (closed !== null)
|
|
1075
|
-
writeRecord(world.root, closed);
|
|
1076
|
-
const line = homeLogLine(moved.now?.home ?? step.home);
|
|
1077
|
-
world.info(line);
|
|
1078
|
-
return Object.freeze({
|
|
1079
|
-
position: moved.written ? moved.now : null,
|
|
1080
|
-
record: closed,
|
|
1081
|
-
line
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
// src/next/actions.ts
|
|
1086
|
-
var PREFIX2 = "rafa next";
|
|
1087
|
-
var NEXT_IN_PROCESS_ACTIONS = Object.freeze(["sync", "hop", "home"]);
|
|
1088
|
-
var SWITCH_COMMAND = Object.freeze({ subject: "switch", action: "switch" });
|
|
1089
|
-
var ROADMAP_WORD = "--roadmap";
|
|
1090
|
-
var ROADMAP_PASSED_ACTIONS = new Set(["plan", "start", "resume"]);
|
|
1091
|
-
var CLAIM_AHEAD_WORD = "--claim-ahead";
|
|
1092
|
-
function passedWords(action, options) {
|
|
1093
|
-
if (options.roadmap !== true || !ROADMAP_PASSED_ACTIONS.has(action))
|
|
1094
|
-
return [];
|
|
1095
|
-
return options.claimAhead === true && action === "plan" ? [ROADMAP_WORD, CLAIM_AHEAD_WORD] : [ROADMAP_WORD];
|
|
1096
|
-
}
|
|
1097
|
-
function needed(state, value, what) {
|
|
1098
|
-
if (value === null) {
|
|
1099
|
-
throw new Error(`${PREFIX2}: state "${state.id}" proposes "${state.action}" and names no ${what}`);
|
|
1100
|
-
}
|
|
1101
|
-
return String(value);
|
|
1102
|
-
}
|
|
1103
|
-
function pullRequestOf(state) {
|
|
1104
|
-
return needed(state, state.pullRequest, "pull request");
|
|
1105
|
-
}
|
|
1106
|
-
function issueOf(state) {
|
|
1107
|
-
return needed(state, state.issue, "issue");
|
|
1108
|
-
}
|
|
1109
|
-
function planFlagOf(state) {
|
|
1110
|
-
return `--plan=${needed(state, state.planPath, "plan file")}`;
|
|
1111
|
-
}
|
|
1112
|
-
var ACTION_COMMANDS = Object.freeze({
|
|
1113
|
-
resume: { subject: "loop", action: "start", argv: (state) => [planFlagOf(state)] },
|
|
1114
|
-
wait: { subject: "pr", action: "wait", argv: (state) => [pullRequestOf(state)] },
|
|
1115
|
-
triage: { subject: "pr", action: "triage", argv: (state) => [pullRequestOf(state)] },
|
|
1116
|
-
merge: { subject: "pr", action: "merge", argv: (state) => [pullRequestOf(state), "--yes"] },
|
|
1117
|
-
"merge-unchecked": { subject: "pr", action: "merge", argv: (state) => [pullRequestOf(state), "--skip-checks"] },
|
|
1118
|
-
settle: { subject: "release", action: "settle", argv: () => [] },
|
|
1119
|
-
start: { subject: "loop", action: "start", argv: (state) => [planFlagOf(state), "--create-branch"] },
|
|
1120
|
-
plan: { subject: "plan", action: "create", argv: () => ["--next"] },
|
|
1121
|
-
unblock: { subject: "issue", action: "unblock", argv: (state) => [issueOf(state)] },
|
|
1122
|
-
ready: { subject: "issue", action: "ready", argv: (state) => [issueOf(state)] }
|
|
1123
|
-
});
|
|
1124
|
-
var NEXT_COMMAND_ACTIONS = Object.freeze(Object.keys(ACTION_COMMANDS));
|
|
1125
|
-
var LABELS_ONLY_ACTIONS = new Set(["unblock"]);
|
|
1126
|
-
var OFFERED_COMMAND_ACTIONS = Object.freeze({
|
|
1127
|
-
labels: NEXT_COMMAND_ACTIONS,
|
|
1128
|
-
native: Object.freeze(NEXT_COMMAND_ACTIONS.filter((action) => !LABELS_ONLY_ACTIONS.has(action)))
|
|
1129
|
-
});
|
|
1130
|
-
function offeredCommandActions(mode) {
|
|
1131
|
-
return OFFERED_COMMAND_ACTIONS[mode];
|
|
1132
|
-
}
|
|
1133
|
-
function notOffered(state, mode) {
|
|
1134
|
-
return new Error(`${PREFIX2}: state "${state.id}" proposes "${state.action}", which is offered in labels mode only` + ` and board.relationships is ${mode}: the tracker clears a blocker when it closes`);
|
|
1135
|
-
}
|
|
1136
|
-
function runsCommand(action) {
|
|
1137
|
-
return NEXT_COMMAND_ACTIONS.includes(action);
|
|
1138
|
-
}
|
|
1139
|
-
function actionInvocation(state, options = {}) {
|
|
1140
|
-
if (!runsCommand(state.action))
|
|
1141
|
-
return null;
|
|
1142
|
-
const mode = options.mode ?? "labels";
|
|
1143
|
-
if (!offeredCommandActions(mode).includes(state.action))
|
|
1144
|
-
throw notOffered(state, mode);
|
|
1145
|
-
const spec = ACTION_COMMANDS[state.action];
|
|
1146
|
-
return Object.freeze({
|
|
1147
|
-
action: state.action,
|
|
1148
|
-
command: commandSpelling(spec),
|
|
1149
|
-
argv: Object.freeze([...spec.argv(state), ...passedWords(state.action, options)])
|
|
1150
|
-
});
|
|
1151
|
-
}
|
|
1152
|
-
function actionContext(caller, command, argv) {
|
|
1153
|
-
const { positional, flags } = parseArgs(argv, command);
|
|
1154
|
-
return Object.freeze({
|
|
1155
|
-
...caller,
|
|
1156
|
-
args: Object.freeze(positional),
|
|
1157
|
-
flags: Object.freeze({ ...flags, [HINT_FLAG]: false }),
|
|
1158
|
-
argv: Object.freeze([...argv])
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
async function runRegistered(caller, name, argv, step) {
|
|
1162
|
-
const command = caller.registry.find(name.subject, name.action);
|
|
1163
|
-
if (command === undefined) {
|
|
1164
|
-
throw new CommandExit(1, `\u274C ${PREFIX2}: the "${step}" step runs "rafa ${commandSpelling(name)}", which is registered by nothing`);
|
|
1165
|
-
}
|
|
1166
|
-
await command.run(actionContext(caller, command, argv));
|
|
1167
|
-
}
|
|
1168
|
-
function hopWorld(caller, state) {
|
|
1169
|
-
if (caller.project === null) {
|
|
1170
|
-
throw new Error(`${PREFIX2}: the action "${state.action}" of state "${state.id}" runs inside a project, and was handed none`);
|
|
1171
|
-
}
|
|
1172
|
-
return {
|
|
1173
|
-
root: caller.project.root,
|
|
1174
|
-
switchTo: (argv) => runRegistered(caller, SWITCH_COMMAND, argv, state.action),
|
|
1175
|
-
info: (line) => {
|
|
1176
|
-
caller.output.info(line);
|
|
1177
|
-
},
|
|
1178
|
-
warn: (line) => {
|
|
1179
|
-
caller.output.warn(line);
|
|
1180
|
-
},
|
|
1181
|
-
now: () => new Date
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
function noStep(state) {
|
|
1185
|
-
return new Error(`${PREFIX2}: state "${state.id}" proposes "${state.action}" and carries no ${state.action} step`);
|
|
1186
|
-
}
|
|
1187
|
-
async function runHopStep(caller, state) {
|
|
1188
|
-
const step = state.hop;
|
|
1189
|
-
if (step?.action !== state.action)
|
|
1190
|
-
throw noStep(state);
|
|
1191
|
-
if (step.action === "hop") {
|
|
1192
|
-
await runHop(hopWorld(caller, state), step);
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
runHome(hopWorld(caller, state), step);
|
|
1196
|
-
}
|
|
1197
|
-
async function runAction(caller, state, options = {}) {
|
|
1198
|
-
if (state.action === "hop" || state.action === "home") {
|
|
1199
|
-
await runHopStep(caller, state);
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
const invocation = actionInvocation(state, options);
|
|
1203
|
-
if (invocation === null) {
|
|
1204
|
-
throw new Error(`${PREFIX2}: the action "${state.action}" of state "${state.id}" runs no registered command`);
|
|
1205
|
-
}
|
|
1206
|
-
await runRegistered(caller, ACTION_COMMANDS[invocation.action], invocation.argv, invocation.action);
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
1212
|
// src/next/ending.ts
|
|
1210
|
-
var HINT_FLAG_SPEC = Object.freeze({
|
|
1211
|
-
name: HINT_FLAG,
|
|
1212
|
-
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.",
|
|
1213
|
-
type: "boolean",
|
|
1214
|
-
default: true
|
|
1215
|
-
});
|
|
1216
1213
|
function actionOutput(output) {
|
|
1217
1214
|
return Object.freeze({ ...output, result: () => {
|
|
1218
1215
|
return;
|
|
@@ -1273,12 +1270,6 @@ var ISSUE_TRIAGE_MODULE = "unassigned";
|
|
|
1273
1270
|
var ISSUE_READY_LABEL = "spec:ready";
|
|
1274
1271
|
var ISSUE_NEEDS_WORK_LABEL = "spec:needs-work";
|
|
1275
1272
|
var ISSUE_BLOCKED_LABEL = "spec:blocked";
|
|
1276
|
-
var ISSUE_HINT_FLAG_SPEC = Object.freeze({
|
|
1277
|
-
name: "hint",
|
|
1278
|
-
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.",
|
|
1279
|
-
type: "boolean",
|
|
1280
|
-
default: true
|
|
1281
|
-
});
|
|
1282
1273
|
var DEFAULT_ISSUE_TYPE = "code";
|
|
1283
1274
|
var PRIORITY_FLAG = "priority";
|
|
1284
1275
|
var STAMP_FLAG = "stamp";
|
|
@@ -1614,7 +1605,7 @@ var ISSUE_READY_DECLARATION = Object.freeze({
|
|
|
1614
1605
|
description: "Prints both readings and writes nothing, asking no question whatever the terminal;" + " a check that refuses still exits 2. Not with --yes.",
|
|
1615
1606
|
type: "boolean"
|
|
1616
1607
|
},
|
|
1617
|
-
|
|
1608
|
+
HINT_FLAG_SPEC
|
|
1618
1609
|
],
|
|
1619
1610
|
examples: [
|
|
1620
1611
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tomato/rafa",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Alpha. Runs a plan through the ralph loop: one Claude Code session per task, one commit per task, then a pull request and a CI wait.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -72,6 +72,21 @@
|
|
|
72
72
|
},
|
|
73
73
|
"./store/check-rows": {
|
|
74
74
|
"types": "./dist/effort/store/check-rows.d.ts"
|
|
75
|
+
},
|
|
76
|
+
"./bugs/record": {
|
|
77
|
+
"types": "./dist/bugs/record.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./config-schema-bugs": {
|
|
80
|
+
"types": "./dist/config-schema-bugs.d.ts"
|
|
81
|
+
},
|
|
82
|
+
"./config-schema-errors": {
|
|
83
|
+
"types": "./dist/config-schema-errors.d.ts"
|
|
84
|
+
},
|
|
85
|
+
"./config-schema-features": {
|
|
86
|
+
"types": "./dist/config-schema-features.d.ts"
|
|
87
|
+
},
|
|
88
|
+
"./config-schema-logger": {
|
|
89
|
+
"types": "./dist/config-schema-logger.d.ts"
|
|
75
90
|
}
|
|
76
91
|
},
|
|
77
92
|
"files": [
|
|
@@ -98,8 +113,14 @@
|
|
|
98
113
|
"@eslint/js": "^9.39.4",
|
|
99
114
|
"@eslint/markdown": "^8.0.3",
|
|
100
115
|
"@open-tomato/define-config": "0.5.0",
|
|
116
|
+
"@open-tomato/rafa-board": "workspace:*",
|
|
101
117
|
"@open-tomato/rafa-core": "workspace:*",
|
|
118
|
+
"@open-tomato/rafa-effort": "workspace:*",
|
|
102
119
|
"@open-tomato/rafa-eslint-config": "workspace:*",
|
|
120
|
+
"@open-tomato/rafa-inventory": "workspace:*",
|
|
121
|
+
"@open-tomato/rafa-pr": "workspace:*",
|
|
122
|
+
"@open-tomato/rafa-release": "workspace:*",
|
|
123
|
+
"@open-tomato/rafa-run": "workspace:*",
|
|
103
124
|
"@open-tomato/rafa-typescript-config": "workspace:*",
|
|
104
125
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
105
126
|
"@types/bun": "^1.4.0",
|