ralph-review 0.1.3 → 0.1.4

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.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A CLI tool that orchestrates agentic review-fix cycles until your code is clean.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -618,15 +618,26 @@ export async function startReview(
618
618
  }
619
619
  }
620
620
 
621
- const modeOptions = [
622
- options.base !== undefined && "--base",
623
- options.uncommitted && "--uncommitted",
624
- options.commit !== undefined && "--commit",
625
- options.custom !== undefined && "--custom",
626
- ].filter(Boolean);
627
-
628
- if (modeOptions.length > 1) {
629
- runtime.prompt.log.error(`Cannot use ${modeOptions.join(" and ")} together`);
621
+ if (options.base !== undefined && options.commit !== undefined) {
622
+ runtime.prompt.log.error("Cannot use --base and --commit together");
623
+ runtime.process.exit(1);
624
+ return;
625
+ }
626
+
627
+ if (options.uncommitted && options.base !== undefined) {
628
+ runtime.prompt.log.error("Cannot use --uncommitted and --base together");
629
+ runtime.process.exit(1);
630
+ return;
631
+ }
632
+
633
+ if (options.uncommitted && options.commit !== undefined) {
634
+ runtime.prompt.log.error("Cannot use --uncommitted and --commit together");
635
+ runtime.process.exit(1);
636
+ return;
637
+ }
638
+
639
+ if (options.uncommitted && options.custom !== undefined) {
640
+ runtime.prompt.log.error("Cannot use --uncommitted and --custom together");
630
641
  runtime.process.exit(1);
631
642
  return;
632
643
  }
@@ -52,6 +52,12 @@ export const codexConfig: AgentConfig = {
52
52
 
53
53
  const baseReviewArgs = withReasoningEffort(["exec", "--json"], reasoning);
54
54
 
55
+ if (reviewOptions?.customInstructions) {
56
+ const fullPrompt = prompt ? `review ${prompt}` : "review";
57
+ const customArgs = withReasoningEffort(["exec", "--full-auto", "--json"], reasoning);
58
+ return withModel([...customArgs, fullPrompt], model);
59
+ }
60
+
55
61
  if (reviewOptions?.commitSha) {
56
62
  return withModel([...baseReviewArgs, "review", "--commit", reviewOptions.commitSha], model);
57
63
  }
@@ -60,12 +66,6 @@ export const codexConfig: AgentConfig = {
60
66
  return withModel([...baseReviewArgs, "review", "--base", reviewOptions.baseBranch], model);
61
67
  }
62
68
 
63
- if (reviewOptions?.customInstructions) {
64
- const fullPrompt = prompt ? `review ${prompt}` : "review";
65
- const customArgs = withReasoningEffort(["exec", "--full-auto", "--json"], reasoning);
66
- return withModel([...customArgs, fullPrompt], model);
67
- }
68
-
69
69
  return withModel([...baseReviewArgs, "review", "--uncommitted"], model);
70
70
  },
71
71
  buildEnv: defaultBuildEnv,
@@ -508,13 +508,7 @@ export async function runDiagnostics(
508
508
  }
509
509
  }
510
510
 
511
- if (
512
- !options.baseBranch &&
513
- !options.commitSha &&
514
- !options.customInstructions &&
515
- insideGitRepo &&
516
- !gitRepoError
517
- ) {
511
+ if (!options.baseBranch && !options.commitSha && insideGitRepo && !gitRepoError) {
518
512
  let hasChanges = false;
519
513
  let hasChangesError: string | null = null;
520
514
  try {
package/src/lib/format.ts CHANGED
@@ -1,23 +1,31 @@
1
1
  import type { ReviewOptions } from "@/lib/types";
2
2
 
3
+ function formatCustomReviewType(customInstructions: string): string {
4
+ const instruction = customInstructions.slice(0, 40);
5
+ return customInstructions.length > 40 ? `custom (${instruction}...)` : `custom (${instruction})`;
6
+ }
7
+
3
8
  export function formatReviewType(reviewOptions: ReviewOptions | undefined): string {
4
9
  if (!reviewOptions) return "uncommitted changes";
5
10
 
6
- if (reviewOptions.customInstructions) {
7
- const instruction = reviewOptions.customInstructions.slice(0, 40);
8
- return reviewOptions.customInstructions.length > 40
9
- ? `custom (${instruction}...)`
10
- : `custom (${instruction})`;
11
- }
12
-
13
11
  if (reviewOptions.commitSha) {
14
12
  const shortSha = reviewOptions.commitSha.slice(0, 7);
13
+ if (reviewOptions.customInstructions) {
14
+ return `commit (${shortSha}) + ${formatCustomReviewType(reviewOptions.customInstructions)}`;
15
+ }
15
16
  return `commit (${shortSha})`;
16
17
  }
17
18
 
18
19
  if (reviewOptions.baseBranch) {
20
+ if (reviewOptions.customInstructions) {
21
+ return `base (${reviewOptions.baseBranch}) + ${formatCustomReviewType(reviewOptions.customInstructions)}`;
22
+ }
19
23
  return `base (${reviewOptions.baseBranch})`;
20
24
  }
21
25
 
26
+ if (reviewOptions.customInstructions) {
27
+ return formatCustomReviewType(reviewOptions.customInstructions);
28
+ }
29
+
22
30
  return "uncommitted changes";
23
31
  }
@@ -19,6 +19,16 @@ const BASE_BRANCH_PROMPT_BACKUP = (branch: string) =>
19
19
  const COMMIT_PROMPT = (commitHash: string) =>
20
20
  `Review the code changes for the commit ${commitHash}. Provide prioritized, actionable findings.`;
21
21
 
22
+ const CUSTOM_FOCUS_PROMPT = (customInstructions: string) =>
23
+ `Additional review focus from user instructions:\n${customInstructions}`;
24
+
25
+ function withCustomFocus(instruction: string, customInstructions?: string): string {
26
+ if (!customInstructions) {
27
+ return instruction;
28
+ }
29
+ return `${instruction}\n\n${CUSTOM_FOCUS_PROMPT(customInstructions)}`;
30
+ }
31
+
22
32
  export interface ReviewerPromptOptions {
23
33
  repoPath: string;
24
34
  baseBranch?: string;
@@ -26,19 +36,20 @@ export interface ReviewerPromptOptions {
26
36
  customInstructions?: string;
27
37
  }
28
38
 
29
- /** Priority: commitSha > baseBranch > customInstructions > uncommitted (default) */
39
+ /** Target priority: commitSha > baseBranch > uncommitted (default), with custom focus overlay. */
30
40
  export function createReviewerPrompt(options: ReviewerPromptOptions): string {
31
41
  const { repoPath, baseBranch, commitSha, customInstructions } = options;
32
42
 
33
43
  let instruction: string;
34
44
 
35
45
  if (commitSha) {
36
- instruction = COMMIT_PROMPT(commitSha);
46
+ instruction = withCustomFocus(COMMIT_PROMPT(commitSha), customInstructions);
37
47
  } else if (baseBranch) {
38
48
  const mergeBaseSha = mergeBaseWithHead(repoPath, baseBranch);
39
- instruction = mergeBaseSha
49
+ const baseInstruction = mergeBaseSha
40
50
  ? BASE_BRANCH_PROMPT(baseBranch, mergeBaseSha)
41
51
  : BASE_BRANCH_PROMPT_BACKUP(baseBranch);
52
+ instruction = withCustomFocus(baseInstruction, customInstructions);
42
53
  } else if (customInstructions) {
43
54
  instruction = customInstructions;
44
55
  } else {
@@ -1,5 +1,6 @@
1
1
  import { useTerminalDimensions } from "@opentui/react";
2
2
  import { useEffect, useMemo, useRef } from "react";
3
+ import { formatReviewType } from "@/lib/format";
3
4
  import type { LockData } from "@/lib/lockfile";
4
5
  import { TUI_COLORS } from "@/lib/tui/colors";
5
6
  import type {
@@ -81,24 +82,6 @@ function toSingleLine(value: string): string {
81
82
  return value.replace(/\s+/g, " ").trim();
82
83
  }
83
84
 
84
- function formatReviewType(reviewOptions: ReviewOptions | undefined): string {
85
- if (!reviewOptions) return "uncommitted changes";
86
-
87
- if (reviewOptions.customInstructions) {
88
- return `custom (${toSingleLine(reviewOptions.customInstructions)})`;
89
- }
90
-
91
- if (reviewOptions.commitSha) {
92
- return `commit (${toSingleLine(reviewOptions.commitSha)})`;
93
- }
94
-
95
- if (reviewOptions.baseBranch) {
96
- return `base (${toSingleLine(reviewOptions.baseBranch)})`;
97
- }
98
-
99
- return "uncommitted changes";
100
- }
101
-
102
85
  interface FixListProps {
103
86
  fixes: FixEntry[];
104
87
  showFiles: boolean;
@@ -566,7 +549,7 @@ export function SessionPanel({
566
549
  <box flexDirection="row" gap={1}>
567
550
  <text fg={TUI_COLORS.text.muted}>Review Type:</text>
568
551
  <text fg={TUI_COLORS.text.primary} wrapMode="none">
569
- {formatReviewType(reviewOptions)}
552
+ {toSingleLine(formatReviewType(reviewOptions))}
570
553
  </text>
571
554
  </box>
572
555