ralph-review 0.2.1 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralph-review",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Orchestrating coding agents for code review, verification and fixing via the ralph loop.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -291,18 +291,24 @@ const FIXER_AGENT_PRIORITY: readonly AgentType[] = ["codex", "claude", "droid",
291
291
 
292
292
  const MODEL_PRIORITY_MATCHERS: Record<ConfiguredRole, readonly ((model: string) => boolean)[]> = {
293
293
  reviewer: [
294
- (model) => matchesModelId(model, "gpt-5.4"),
295
- (model) => matchesModelId(model, "gpt-5.3-codex"),
296
294
  (model) => matchesModelId(model, "gpt-5.2"),
297
- (model) => matchesModelId(model, "gpt-5.2-codex"),
298
295
  (model) => matchesModelId(model, "claude-opus-4-6"),
299
- (model) => matchesModelId(model, "gemini-3-pro-preview"),
296
+ (model) => matchesModelId(model, "claude-sonnet-4-6"),
297
+ (model) => matchesModelId(model, "claude-opus-4-7"),
298
+ (model) => matchesModelId(model, "glm-5.1"),
299
+ (model) => matchesModelId(model, "gpt-5.3-codex"),
300
+ (model) => matchesModelId(model, "gemini-3.1-pro-preview"),
301
+ (model) => matchesModelId(model, "kimi-k2.6"),
300
302
  ],
301
303
  fixer: [
304
+ (model) => matchesModelId(model, "gpt-5.5"),
302
305
  (model) => matchesModelId(model, "gpt-5.4"),
303
- (model) => matchesModelId(model, "gpt-5.3-codex"),
304
306
  (model) => matchesModelId(model, "claude-opus-4-6"),
305
- (model) => matchesModelId(model, "gemini-3-pro-preview"),
307
+ (model) => matchesModelId(model, "gpt-5.3-codex"),
308
+ (model) => matchesModelId(model, "kimi-k2.6"),
309
+ (model) => matchesModelId(model, "gemini-3.1-pro-preview"),
310
+ (model) => matchesModelId(model, "glm-5.1"),
311
+ (model) => matchesModelId(model, "claude-sonnet-4-6"),
306
312
  ],
307
313
  };
308
314
 
@@ -13,8 +13,8 @@ export const claudeModelOptions = [
13
13
  { value: "claude-opus-4-7", label: "Claude Opus 4.7" },
14
14
  { value: "claude-opus-4-6", label: "Claude Opus 4.6" },
15
15
  { value: "claude-opus-4-5", label: "Claude Opus 4.5" },
16
- { value: "sonnet", label: "Claude Sonnet 4.6" },
17
- { value: "haiku", label: "Claude Haiku 4.5" },
16
+ { value: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },
17
+ { value: "claude-haiku-4-5", label: "Claude Haiku 4.5" },
18
18
  ] as const;
19
19
 
20
20
  export const geminiModelOptions = [
@@ -13,11 +13,34 @@ type ReviewModeInputMode = Exclude<ReviewModeSelection, "uncommitted">;
13
13
  type ReviewModeStep = "picker" | "branch-picker" | "commit-picker" | "options";
14
14
  type ReviewExecutionMode = "review-only" | "auto-all" | "auto-priority";
15
15
  type OptionsFocusTarget =
16
- | "max-iterations"
16
+ | "iterations"
17
17
  | "force-max-iterations"
18
- | "execution-mode"
18
+ | "execution-review-only"
19
+ | "execution-auto-all"
20
+ | "execution-auto-priority"
19
21
  | "custom-instructions";
20
22
 
23
+ const OPTIONS_FOCUS_ORDER: OptionsFocusTarget[] = [
24
+ "iterations",
25
+ "force-max-iterations",
26
+ "execution-review-only",
27
+ "execution-auto-all",
28
+ "execution-auto-priority",
29
+ ];
30
+
31
+ function executionFocusToMode(focus: OptionsFocusTarget): ReviewExecutionMode | null {
32
+ if (focus === "execution-review-only") return "review-only";
33
+ if (focus === "execution-auto-all") return "auto-all";
34
+ if (focus === "execution-auto-priority") return "auto-priority";
35
+ return null;
36
+ }
37
+
38
+ function executionModeToFocus(mode: ReviewExecutionMode): OptionsFocusTarget {
39
+ if (mode === "review-only") return "execution-review-only";
40
+ if (mode === "auto-all") return "execution-auto-all";
41
+ return "execution-auto-priority";
42
+ }
43
+
21
44
  interface ReviewModeOption {
22
45
  label: string;
23
46
  description: string;
@@ -347,30 +370,6 @@ function clampMaxIterations(value: number): number {
347
370
  return Math.min(MAX_MAX_ITERATIONS, Math.max(MIN_MAX_ITERATIONS, Math.trunc(value)));
348
371
  }
349
372
 
350
- function cycleExecutionMode(current: ReviewExecutionMode, direction: 1 | -1): ReviewExecutionMode {
351
- const currentIndex = REVIEW_EXECUTION_OPTIONS.findIndex((option) => option.mode === current);
352
- const nextIndex = Math.min(
353
- REVIEW_EXECUTION_OPTIONS.length - 1,
354
- Math.max(0, currentIndex + direction)
355
- );
356
-
357
- return REVIEW_EXECUTION_OPTIONS[nextIndex]?.mode ?? current;
358
- }
359
-
360
- function getOptionsFocusOrder(showCustomInstructions: boolean): OptionsFocusTarget[] {
361
- const focusOrder: OptionsFocusTarget[] = [
362
- "max-iterations",
363
- "force-max-iterations",
364
- "execution-mode",
365
- ];
366
-
367
- if (showCustomInstructions) {
368
- focusOrder.push("custom-instructions");
369
- }
370
-
371
- return focusOrder;
372
- }
373
-
374
373
  export function ReviewModeOverlay({
375
374
  defaultReview,
376
375
  defaultMaxIterations,
@@ -396,7 +395,8 @@ export function ReviewModeOverlay({
396
395
  const [priorityCursorIndex, setPriorityCursorIndex] = useState(0);
397
396
  const [customInstructionsDraft, setCustomInstructionsDraft] = useState("");
398
397
  const [showCustomInstructions, setShowCustomInstructions] = useState(false);
399
- const [optionsFocus, setOptionsFocus] = useState<OptionsFocusTarget>("max-iterations");
398
+ const [optionsFocus, setOptionsFocus] = useState<OptionsFocusTarget>("iterations");
399
+ const lastNonCustomFocusRef = useRef<OptionsFocusTarget>("iterations");
400
400
  const customInstructionsRef = useRef<TextareaRenderable>(null);
401
401
  const maxIterationsInputRef = useRef<InputRenderable>(null);
402
402
 
@@ -490,34 +490,13 @@ export function ReviewModeOverlay({
490
490
  Math.min(68, configurationContentWidth - (showCustomInstructions ? 2 : 0))
491
491
  );
492
492
 
493
- if (step === "options" && !getOptionsFocusOrder(showCustomInstructions).includes(optionsFocus)) {
494
- setOptionsFocus("execution-mode");
495
- }
496
-
497
- function pruneEmptyCustomInstructions() {
498
- const nextValue = customInstructionsRef.current?.plainText ?? customInstructionsDraft;
499
- const normalizedValue = nextValue.trim().length === 0 ? "" : nextValue;
500
- if (normalizedValue !== customInstructionsDraft) {
501
- setCustomInstructionsDraft(normalizedValue);
502
- }
503
- if (normalizedValue.length === 0) {
504
- setShowCustomInstructions(false);
505
- }
506
- }
507
-
508
493
  function movePriorityCursor(direction: 1 | -1) {
509
494
  setPriorityCursorIndex((current) => clampPriorityCursorIndex(current + direction));
510
495
  setError(null);
511
496
  }
512
497
 
513
- function adjustMaxIterations(direction: 1 | -1) {
514
- const current = parseInt(maxIterationsDraft, 10);
515
- const base = Number.isFinite(current)
516
- ? current
517
- : direction > 0
518
- ? initialMaxIterations - 1
519
- : initialMaxIterations + 1;
520
- setMaxIterationsDraft(String(clampMaxIterations(base + direction)));
498
+ function advancePriorityCursor() {
499
+ setPriorityCursorIndex((current) => (current + 1) % PRIORITIES.length);
521
500
  setError(null);
522
501
  }
523
502
 
@@ -544,22 +523,6 @@ export function ReviewModeOverlay({
544
523
 
545
524
  useKeyboard((key) => {
546
525
  if (step === "options") {
547
- if (key.name === "tab") {
548
- const focusOrder = getOptionsFocusOrder(showCustomInstructions);
549
- const currentIndex = focusOrder.indexOf(optionsFocus);
550
- const direction = key.shift ? -1 : 1;
551
- const nextIndex = (currentIndex + direction + focusOrder.length) % focusOrder.length;
552
- const nextFocus = focusOrder[nextIndex];
553
- if (nextFocus) {
554
- if (optionsFocus === "custom-instructions" && nextFocus !== "custom-instructions") {
555
- pruneEmptyCustomInstructions();
556
- }
557
- setOptionsFocus(nextFocus);
558
- setError(null);
559
- }
560
- return;
561
- }
562
-
563
526
  if (isCustomInstructionsFocused) {
564
527
  if (key.name === "escape") {
565
528
  hideCustomInstructions();
@@ -579,52 +542,50 @@ export function ReviewModeOverlay({
579
542
  return;
580
543
  }
581
544
 
582
- if (optionsFocus === "max-iterations") {
583
- if (isUpNavigationKey(key.name)) {
584
- adjustMaxIterations(1);
585
- return;
586
- }
587
-
588
- if (isDownNavigationKey(key.name)) {
589
- adjustMaxIterations(-1);
590
- return;
545
+ if (isUpNavigationKey(key.name) || isDownNavigationKey(key.name)) {
546
+ const direction = isUpNavigationKey(key.name) ? -1 : 1;
547
+ const currentIndex = OPTIONS_FOCUS_ORDER.indexOf(optionsFocus);
548
+ const nextIndex = Math.min(
549
+ OPTIONS_FOCUS_ORDER.length - 1,
550
+ Math.max(0, currentIndex + direction)
551
+ );
552
+ const nextFocus = OPTIONS_FOCUS_ORDER[nextIndex];
553
+ if (nextFocus && nextFocus !== optionsFocus) {
554
+ setOptionsFocus(nextFocus);
555
+ const mode = executionFocusToMode(nextFocus);
556
+ if (mode) {
557
+ setExecutionMode(mode);
558
+ }
559
+ setError(null);
591
560
  }
561
+ return;
592
562
  }
593
563
 
594
- if (optionsFocus === "force-max-iterations") {
595
- if (key.name === "space") {
596
- toggleForceMaxIterations();
597
- return;
598
- }
564
+ if (optionsFocus === "force-max-iterations" && key.name === "space") {
565
+ toggleForceMaxIterations();
566
+ return;
599
567
  }
600
568
 
601
- if (optionsFocus === "execution-mode") {
602
- if (isUpNavigationKey(key.name)) {
603
- setExecutionMode((current) => cycleExecutionMode(current, -1));
604
- setError(null);
605
- return;
606
- }
607
-
608
- if (isDownNavigationKey(key.name)) {
609
- setExecutionMode((current) => cycleExecutionMode(current, 1));
610
- setError(null);
611
- return;
612
- }
613
-
614
- if (executionMode === "auto-priority" && isLeftNavigationKey(key.name)) {
569
+ if (optionsFocus === "execution-auto-priority") {
570
+ if (isLeftNavigationKey(key.name)) {
615
571
  movePriorityCursor(-1);
616
572
  return;
617
573
  }
618
574
 
619
- if (executionMode === "auto-priority" && isRightNavigationKey(key.name)) {
575
+ if (isRightNavigationKey(key.name)) {
620
576
  movePriorityCursor(1);
621
577
  return;
622
578
  }
623
579
 
624
- if (executionMode === "auto-priority" && key.name === "space") {
580
+ if (key.name === "space") {
625
581
  toggleSelectedPriority();
626
582
  return;
627
583
  }
584
+
585
+ if (key.name === "tab") {
586
+ advancePriorityCursor();
587
+ return;
588
+ }
628
589
  }
629
590
 
630
591
  if (key.name === "enter" || key.name === "return") {
@@ -712,7 +673,8 @@ export function ReviewModeOverlay({
712
673
  setSelectedPriorities([]);
713
674
  setPriorityCursorIndex(0);
714
675
  setShowCustomInstructions(false);
715
- setOptionsFocus("max-iterations");
676
+ setOptionsFocus("iterations");
677
+ lastNonCustomFocusRef.current = "iterations";
716
678
  setError(null);
717
679
  setStep("options");
718
680
  }
@@ -770,6 +732,9 @@ export function ReviewModeOverlay({
770
732
  }
771
733
 
772
734
  function openCustomInstructions() {
735
+ if (optionsFocus !== "custom-instructions") {
736
+ lastNonCustomFocusRef.current = optionsFocus;
737
+ }
773
738
  setShowCustomInstructions(true);
774
739
  setOptionsFocus("custom-instructions");
775
740
  setError(null);
@@ -778,7 +743,7 @@ export function ReviewModeOverlay({
778
743
  function hideCustomInstructions() {
779
744
  syncCustomInstructionsDraft();
780
745
  setShowCustomInstructions(false);
781
- setOptionsFocus("max-iterations");
746
+ setOptionsFocus(lastNonCustomFocusRef.current);
782
747
  setError(null);
783
748
  }
784
749
 
@@ -928,14 +893,13 @@ export function ReviewModeOverlay({
928
893
  <box flexDirection="column">
929
894
  {REVIEW_EXECUTION_OPTIONS.map((option) => {
930
895
  const isSelected = option.mode === executionMode;
931
- const isFocused = optionsFocus === "execution-mode" && isSelected;
932
- const showFocusMarker = isFocused && option.mode !== "auto-priority";
896
+ const isFocused = optionsFocus === executionModeToFocus(option.mode);
933
897
 
934
898
  return (
935
899
  <box key={option.mode} flexDirection="column" paddingX={1} paddingY={0}>
936
900
  <box flexDirection="row">
937
- <text fg={showFocusMarker ? TUI_COLORS.accent.key : TUI_COLORS.text.dim}>
938
- {showFocusMarker ? "▶ " : " "}
901
+ <text fg={isFocused ? TUI_COLORS.accent.key : TUI_COLORS.text.dim}>
902
+ {isFocused ? "▶ " : " "}
939
903
  </text>
940
904
  <text fg={isSelected ? TUI_COLORS.status.success : TUI_COLORS.text.dim}>
941
905
  {isSelected ? "◉" : "◎"}
@@ -989,30 +953,21 @@ export function ReviewModeOverlay({
989
953
  </text>
990
954
  <input
991
955
  ref={attachMaxIterationsInput}
992
- focused={optionsFocus === "max-iterations"}
956
+ focused={optionsFocus === "iterations"}
993
957
  value={maxIterationsDraft}
994
958
  placeholder={String(initialMaxIterations)}
995
959
  width={12}
996
960
  onChange={handleMaxIterationsInput}
997
961
  onInput={handleMaxIterationsInput}
998
- onKeyDown={(key) => {
999
- if (isUpNavigationKey(key.name)) {
1000
- key.preventDefault();
1001
- key.stopPropagation();
1002
- adjustMaxIterations(1);
1003
- return;
1004
- }
1005
-
1006
- if (isDownNavigationKey(key.name)) {
1007
- key.preventDefault();
1008
- key.stopPropagation();
1009
- adjustMaxIterations(-1);
1010
- }
1011
- }}
1012
962
  />
1013
- <box flexDirection="row" marginTop={1}>
963
+ </box>
964
+
965
+ <box marginTop={1} paddingX={1} paddingY={0} flexDirection="column" gap={0}>
966
+ <text fg={TUI_COLORS.text.dim}>
967
+ <strong>Force Max Iterations</strong>
968
+ </text>
969
+ <box flexDirection="row">
1014
970
  <text fg={isForceFocused ? TUI_COLORS.accent.key : TUI_COLORS.text.dim}>
1015
- {" "}
1016
971
  {isForceFocused ? "▶ " : " "}
1017
972
  </text>
1018
973
  <text fg={forceMaxIterations ? TUI_COLORS.status.success : TUI_COLORS.text.dim}>
@@ -1020,7 +975,7 @@ export function ReviewModeOverlay({
1020
975
  </text>
1021
976
  <text fg={forceMaxIterations ? TUI_COLORS.text.primary : TUI_COLORS.text.secondary}>
1022
977
  {" "}
1023
- Force max iterations
978
+ {forceMaxIterations ? "Enabled" : "Disabled"}
1024
979
  </text>
1025
980
  </box>
1026
981
  </box>
@@ -1032,15 +987,12 @@ export function ReviewModeOverlay({
1032
987
  {renderExecutionModeOptions()}
1033
988
  </box>
1034
989
 
1035
- {executionMode === "auto-priority" && (
990
+ {optionsFocus === "execution-auto-priority" && (
1036
991
  <box paddingX={1} paddingY={0} flexDirection="column" gap={0}>
1037
992
  <box flexDirection="row" paddingLeft={2}>
1038
993
  {PRIORITIES.map((priority, index) => {
1039
994
  const isSelected = selectedPriorities.includes(priority);
1040
- const isHighlighted =
1041
- optionsFocus === "execution-mode" &&
1042
- executionMode === "auto-priority" &&
1043
- priorityCursorIndex === index;
995
+ const isHighlighted = priorityCursorIndex === index;
1044
996
 
1045
997
  return (
1046
998
  <box key={priority} paddingLeft={1}>
@@ -1136,8 +1088,7 @@ export function ReviewModeOverlay({
1136
1088
  }
1137
1089
 
1138
1090
  function renderOptions() {
1139
- const isInlinePriorityControlActive =
1140
- optionsFocus === "execution-mode" && executionMode === "auto-priority";
1091
+ const isPriorityFocusActive = optionsFocus === "execution-auto-priority";
1141
1092
  const isForceControlActive = optionsFocus === "force-max-iterations";
1142
1093
  const reviewStartKeyLabel = isCustomInstructionsFocused ? "[Shift+Enter]" : "[Enter]";
1143
1094
 
@@ -1150,27 +1101,28 @@ export function ReviewModeOverlay({
1150
1101
  <text fg={optionsStatusColor}>
1151
1102
  {error ?? (
1152
1103
  <>
1153
- <span fg={TUI_COLORS.accent.key}>[Tab]</span>
1154
- <span fg={TUI_COLORS.text.muted}> moves focus </span>
1155
- {isInlinePriorityControlActive && (
1104
+ <span fg={TUI_COLORS.accent.key}>[↑/↓]</span>
1105
+ <span fg={TUI_COLORS.text.muted}> navigates </span>
1106
+ {isPriorityFocusActive && (
1156
1107
  <>
1108
+ <span fg={TUI_COLORS.accent.key}>[←/→]</span>
1109
+ <span fg={TUI_COLORS.text.muted}> priority cursor </span>
1110
+ <span fg={TUI_COLORS.accent.key}>[Tab]</span>
1111
+ <span fg={TUI_COLORS.text.muted}> next priority </span>
1157
1112
  <span fg={TUI_COLORS.accent.key}>[Space]</span>
1158
- <span fg={TUI_COLORS.text.muted}> to select </span>
1113
+ <span fg={TUI_COLORS.text.muted}> toggles priority </span>
1159
1114
  </>
1160
1115
  )}
1161
- {isForceControlActive ? (
1116
+ {isForceControlActive && (
1162
1117
  <>
1163
1118
  <span fg={TUI_COLORS.accent.key}>[Space]</span>
1164
1119
  <span fg={TUI_COLORS.text.muted}> toggles force </span>
1165
- <span fg={TUI_COLORS.accent.key}>{reviewStartKeyLabel}</span>
1166
- <span fg={TUI_COLORS.text.muted}> starts review</span>
1167
- </>
1168
- ) : (
1169
- <>
1170
- <span fg={TUI_COLORS.accent.key}>{reviewStartKeyLabel}</span>
1171
- <span fg={TUI_COLORS.text.muted}> starts review</span>
1172
1120
  </>
1173
1121
  )}
1122
+ <span fg={TUI_COLORS.accent.key}>[C]</span>
1123
+ <span fg={TUI_COLORS.text.muted}> custom instructions </span>
1124
+ <span fg={TUI_COLORS.accent.key}>{reviewStartKeyLabel}</span>
1125
+ <span fg={TUI_COLORS.text.muted}> starts review</span>
1174
1126
  </>
1175
1127
  )}
1176
1128
  </text>