@contextrail/code-review-agent 0.1.2-alpha.2 → 0.1.2-alpha.5

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 CHANGED
@@ -34,14 +34,17 @@ npm i -g @contextrail/code-review-agent
34
34
  code-review-agent review --help
35
35
  ```
36
36
 
37
- ## Required Environment Variables
37
+ ## Configuration
38
+
39
+ ### Required (sensitive — use environment variables)
38
40
 
39
41
  ```bash
40
- export CONTEXTRAIL_MCP_SERVER_URL="https://<your-mcp-host>"
41
42
  export CONTEXTRAIL_MCP_JWT_TOKEN="<your-contextrail-jwt-token>"
42
43
  export OPENROUTER_API_KEY="<your-openrouter-key>"
43
44
  ```
44
45
 
46
+ These contain credentials and should not be passed as CLI flags to avoid exposure in shell history and process listings.
47
+
45
48
  ### Getting Your ContextRail MCP Token
46
49
 
47
50
  To get your `CONTEXTRAIL_MCP_JWT_TOKEN`:
@@ -51,14 +54,22 @@ To get your `CONTEXTRAIL_MCP_JWT_TOKEN`:
51
54
 
52
55
  The token is used to authenticate with the ContextRail MCP server to retrieve your organization's review standards and contexts.
53
56
 
54
- Optional:
57
+ ### Required (env var or CLI flag)
58
+
59
+ ```bash
60
+ export CONTEXTRAIL_MCP_SERVER_URL="https://<your-mcp-host>"
61
+ # or pass inline:
62
+ # --mcp-server-url https://<your-mcp-host>
63
+ ```
64
+
65
+ ### Optional
55
66
 
56
67
  ```bash
57
- export LLM_MODEL_ORCHESTRATOR="google/gemini-3-flash-preview"
58
- export LLM_MODEL_REVIEWER="qwen/qwen3-coder-next"
59
- export LLM_MODEL_CRITIC="qwen/qwen3-coder-next"
60
- export REVIEW_DOMAINS="security,architecture"
61
- export PR_DESCRIPTION="Optional PR context"
68
+ export LLM_MODEL_ORCHESTRATOR="google/gemini-3-flash-preview" # or --orchestrator-model
69
+ export LLM_MODEL_REVIEWER="qwen/qwen3-coder-next" # or --reviewer-model
70
+ export LLM_MODEL_CRITIC="qwen/qwen3-coder-next" # or --critic-model
71
+ export REVIEW_DOMAINS="security,architecture" # or --domains
72
+ export PR_DESCRIPTION="Optional PR context" # or --pr-description
62
73
  ```
63
74
 
64
75
  ## Run Against a PR Diff
@@ -153,7 +164,8 @@ Exit codes:
153
164
  - **`Command "code-review-agent" not found`**
154
165
  - use `npx -y @contextrail/code-review-agent ...` or install globally
155
166
  - **Missing required env vars**
156
- - set `CONTEXTRAIL_MCP_SERVER_URL`, `CONTEXTRAIL_MCP_JWT_TOKEN`, and `OPENROUTER_API_KEY`
167
+ - set `CONTEXTRAIL_MCP_JWT_TOKEN` and `OPENROUTER_API_KEY` as environment variables
168
+ - set `CONTEXTRAIL_MCP_SERVER_URL` as an environment variable or pass `--mcp-server-url`
157
169
  - **One reviewer failed with structured-output/schema errors**
158
170
  - inspect `./.review/reviewers/<reviewer>/failures.md`
159
171
  - inspect `./.review/reviewers/<reviewer>/progress.json`
package/dist/cli/help.js CHANGED
@@ -10,34 +10,41 @@ Commands:
10
10
  review Run code review on git diff
11
11
 
12
12
  Options:
13
- --repo <path> Repository path (default: current directory)
14
- --from <sha> Base commit SHA (required)
15
- --to <sha> Head commit SHA (required)
16
- --files <list> Comma-separated list of files to review
17
- --file <path> File to review (repeatable)
18
- --output <dir> Output directory (default: ./review)
19
- --log-level <lv> Log level: debug|info|warn|error|silent (overrides DEBUG)
20
- --max-steps <n> Maximum LLM steps per call (default: 10)
21
- --max-iterations <n> Maximum reviewer validation iterations (default: 2)
22
- --aggregation-max-steps <n> Maximum steps for aggregation (default: 5)
23
- --max-tokens-per-file <n> Token budget for surrounding context per file (default: 20000)
24
- --context-lines <n> Lines of context around changes (default: 10)
25
- --pr-description <text> PR description to include as context (optional)
26
- --domains <list> Comma-separated review focus domains (optional)
27
- -h, --help Show this help message
13
+ --repo <path> Repository path (default: current directory)
14
+ --from <sha> Base commit SHA (required)
15
+ --to <sha> Head commit SHA (required)
16
+ --files <list> Comma-separated list of files to review
17
+ --file <path> File to review (repeatable)
18
+ --output <dir> Output directory (default: ./review)
19
+ --mcp-server-url <url> ContextRail MCP server URL (overrides CONTEXTRAIL_MCP_SERVER_URL)
20
+ --orchestrator-model <model> Model for orchestrator (overrides LLM_MODEL_ORCHESTRATOR)
21
+ --reviewer-model <model> Model for reviewers (overrides LLM_MODEL_REVIEWER)
22
+ --critic-model <model> Model for critic pass (overrides LLM_MODEL_CRITIC)
23
+ --log-level <lv> Log level: debug|info|warn|error|silent (overrides DEBUG)
24
+ --max-steps <n> Maximum LLM steps per call (default: 10)
25
+ --max-iterations <n> Maximum reviewer validation iterations (default: 2)
26
+ --aggregation-max-steps <n> Maximum steps for aggregation (default: 5)
27
+ --max-tokens-per-file <n> Token budget for surrounding context per file (default: 20000)
28
+ --context-lines <n> Lines of context around changes (default: 10)
29
+ --pr-description <text> PR description to include as context (optional)
30
+ --domains <list> Comma-separated review focus domains (optional)
31
+ -h, --help Show this help message
28
32
 
29
- Environment Variables:
30
- CONTEXTRAIL_MCP_SERVER_URL ContextRail MCP server URL (required)
33
+ Environment Variables (sensitive — use env vars, not CLI flags):
31
34
  CONTEXTRAIL_MCP_JWT_TOKEN ContextRail MCP authentication token (required)
32
- OPENROUTER_API_KEY OpenRouter API key (required)
33
- LLM_MODEL_ORCHESTRATOR Model for orchestrator (default: anthropic/claude-haiku-4.5)
34
- LLM_MODEL_REVIEWER Model for reviewers (default: anthropic/claude-haiku-4.5)
35
- MAX_STEPS Maximum LLM steps per call (default: 10)
36
- MAX_ITERATIONS Maximum reviewer validation iterations (default: 2)
37
- AGGREGATION_MAX_STEPS Maximum steps for aggregation (default: 5)
38
- MAX_TOKENS_PER_FILE Token budget for surrounding context per file (default: 20000)
39
- CONTEXT_LINES Lines of context around changes (default: 10)
40
- REVIEW_DOMAINS Comma-separated review focus domains (optional)
35
+ OPENROUTER_API_KEY OpenRouter API key (required)
36
+
37
+ Environment Variables (can also be set via CLI flags above):
38
+ CONTEXTRAIL_MCP_SERVER_URL ContextRail MCP server URL (required)
39
+ LLM_MODEL_ORCHESTRATOR Model for orchestrator
40
+ LLM_MODEL_REVIEWER Model for reviewers
41
+ LLM_MODEL_CRITIC Model for critic pass
42
+ MAX_STEPS Maximum LLM steps per call (default: 10)
43
+ MAX_ITERATIONS Maximum reviewer validation iterations (default: 2)
44
+ AGGREGATION_MAX_STEPS Maximum steps for aggregation (default: 5)
45
+ MAX_TOKENS_PER_FILE Token budget for surrounding context per file (default: 20000)
46
+ CONTEXT_LINES Lines of context around changes (default: 10)
47
+ REVIEW_DOMAINS Comma-separated review focus domains (optional)
41
48
 
42
49
  Examples:
43
50
  code-review-agent review --repo . --from HEAD^ --to HEAD
@@ -56,6 +56,22 @@ export const parseArgs = (args) => {
56
56
  parsed.logLevel = args[i + 1];
57
57
  i += 2;
58
58
  }
59
+ else if (arg === '--mcp-server-url' && i + 1 < args.length) {
60
+ parsed.mcpServerUrl = args[i + 1];
61
+ i += 2;
62
+ }
63
+ else if (arg === '--orchestrator-model' && i + 1 < args.length) {
64
+ parsed.orchestratorModel = args[i + 1];
65
+ i += 2;
66
+ }
67
+ else if (arg === '--reviewer-model' && i + 1 < args.length) {
68
+ parsed.reviewerModel = args[i + 1];
69
+ i += 2;
70
+ }
71
+ else if (arg === '--critic-model' && i + 1 < args.length) {
72
+ parsed.criticModel = args[i + 1];
73
+ i += 2;
74
+ }
59
75
  else if (arg === '--pr-description' && i + 1 < args.length) {
60
76
  parsed.prDescription = args[i + 1];
61
77
  i += 2;
@@ -7,6 +7,10 @@ export interface CliArgs {
7
7
  logLevel?: string;
8
8
  files?: string[];
9
9
  help?: boolean;
10
+ mcpServerUrl?: string;
11
+ orchestratorModel?: string;
12
+ reviewerModel?: string;
13
+ criticModel?: string;
10
14
  maxSteps?: number;
11
15
  maxIterations?: number;
12
16
  aggregationMaxSteps?: number;
@@ -31,6 +31,14 @@ export type ValidatedReviewAgentConfig = {
31
31
  contextLines: number;
32
32
  reviewDomains?: string[];
33
33
  };
34
+ /**
35
+ * Shared base config for agent-level operations (orchestrator, executor, etc.).
36
+ * Derived from ValidatedReviewAgentConfig to eliminate duplicated field definitions.
37
+ */
38
+ export type SharedAgentOpConfig = Pick<ValidatedReviewAgentConfig, 'openRouterApiKey' | 'reviewDomains'> & {
39
+ maxSteps?: number;
40
+ prDescription?: string;
41
+ };
34
42
  export declare const loadConfig: () => ReviewAgentConfig;
35
43
  export declare const applyCliArgs: (config: ReviewAgentConfig, args: CliArgs) => void;
36
44
  export declare const validateConfig: (config: ReviewAgentConfig) => ValidatedReviewAgentConfig;
@@ -55,15 +55,17 @@ export const loadConfig = () => {
55
55
  prDescription: normalizeOptionalString(process.env.PR_DESCRIPTION),
56
56
  reviewDomains,
57
57
  };
58
- // Fail fast when required environment variables are missing.
59
- // Note: CLI --help bypasses loadConfig in src/index.ts so help remains accessible.
60
- const missingRequired = getMissingRequiredEnvVars(config);
61
- if (missingRequired.length > 0) {
62
- throw new Error(`Missing required environment variables: ${missingRequired.join(', ')}`);
63
- }
64
58
  return config;
65
59
  };
66
60
  export const applyCliArgs = (config, args) => {
61
+ if (args.mcpServerUrl !== undefined)
62
+ config.mcpServerUrl = args.mcpServerUrl;
63
+ if (args.orchestratorModel !== undefined)
64
+ config.orchestratorModel = args.orchestratorModel;
65
+ if (args.reviewerModel !== undefined)
66
+ config.reviewerModel = args.reviewerModel;
67
+ if (args.criticModel !== undefined)
68
+ config.criticModel = args.criticModel;
67
69
  if (args.maxSteps !== undefined)
68
70
  config.maxSteps = args.maxSteps;
69
71
  if (args.maxIterations !== undefined)
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import type { ReviewInputs } from '../review-inputs/index.js';
3
3
  import type { McpClient } from '../mcp/client.js';
4
4
  import type { Logger } from '../logging/logger.js';
5
+ import type { SharedAgentOpConfig } from '../config/index.js';
5
6
  import type { LlmService } from '../llm/service.js';
6
7
  declare const orchestratorOutputSchema: z.ZodObject<{
7
8
  understanding: z.ZodString;
@@ -14,12 +15,8 @@ declare const orchestratorOutputSchema: z.ZodObject<{
14
15
  reviewers: string[];
15
16
  }>;
16
17
  export type OrchestratorOutput = z.infer<typeof orchestratorOutputSchema>;
17
- export type AgenticOrchestratorConfig = {
18
- openRouterApiKey: string;
18
+ export type AgenticOrchestratorConfig = SharedAgentOpConfig & {
19
19
  orchestratorModel: string;
20
- maxSteps?: number;
21
- prDescription?: string;
22
- reviewDomains?: string[];
23
20
  };
24
21
  export type AgenticOrchestratorDeps = {
25
22
  mcpClient: McpClient;
@@ -3,6 +3,7 @@ import { type ChunkingConfig } from '../review-inputs/chunking.js';
3
3
  import { type FilePatterns } from '../review-inputs/file-patterns.js';
4
4
  import type { McpClient } from '../mcp/client.js';
5
5
  import type { ReviewerFindings } from '../output/schema.js';
6
+ import type { SharedAgentOpConfig } from '../config/index.js';
6
7
  import type { Logger } from '../logging/logger.js';
7
8
  import type { LlmService } from '../llm/service.js';
8
9
  /**
@@ -12,15 +13,11 @@ import type { LlmService } from '../llm/service.js';
12
13
  * @returns FilePatterns if found, undefined otherwise
13
14
  */
14
15
  export declare function extractFilePatterns(metadata: unknown): FilePatterns | undefined;
15
- export type AgenticExecutorConfig = {
16
- openRouterApiKey: string;
16
+ export type AgenticExecutorConfig = SharedAgentOpConfig & {
17
17
  reviewerModel: string;
18
18
  criticModel?: string;
19
- maxSteps?: number;
20
19
  maxIterations?: number;
21
20
  chunking?: ChunkingConfig;
22
- prDescription?: string;
23
- reviewDomains?: string[];
24
21
  };
25
22
  export type AgenticExecutorDeps = {
26
23
  mcpClient: McpClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextrail/code-review-agent",
3
- "version": "0.1.2-alpha.2",
3
+ "version": "0.1.2-alpha.5",
4
4
  "description": "CLI tool for orchestrating ContextRail-powered code reviews",
5
5
  "homepage": "https://contextrail.app",
6
6
  "repository": {