@bastani/atomic 0.5.31 → 0.5.32-1
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/dist/sdk/runtime/tmux.d.ts +13 -0
- package/dist/sdk/runtime/tmux.d.ts.map +1 -1
- package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts +7 -2
- package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts.map +1 -1
- package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts +7 -2
- package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts.map +1 -1
- package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts +48 -40
- package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts.map +1 -1
- package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts +9 -5
- package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts.map +1 -1
- package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts +7 -2
- package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts.map +1 -1
- package/dist/sdk/workflows/index.d.ts +1 -1
- package/dist/sdk/workflows/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/commands/cli/chat/index.ts +7 -0
- package/src/commands/cli/workflow-command.test.ts +12 -0
- package/src/sdk/runtime/tmux.conf +11 -8
- package/src/sdk/runtime/tmux.ts +22 -0
- package/src/sdk/workflows/builtin/ralph/claude/index.ts +13 -35
- package/src/sdk/workflows/builtin/ralph/copilot/index.ts +13 -29
- package/src/sdk/workflows/builtin/ralph/helpers/prompts.ts +224 -205
- package/src/sdk/workflows/builtin/ralph/helpers/review.ts +12 -11
- package/src/sdk/workflows/builtin/ralph/opencode/index.ts +13 -35
- package/src/sdk/workflows/index.ts +1 -0
|
@@ -65,6 +65,19 @@ export declare function tmuxRun(args: string[]): TmuxResult;
|
|
|
65
65
|
* @returns The pane ID of the initial pane (e.g., "%0")
|
|
66
66
|
*/
|
|
67
67
|
export declare function createSession(sessionName: string, initialCommand: string, windowName?: string, cwd?: string, envVars?: Record<string, string>): string;
|
|
68
|
+
/**
|
|
69
|
+
* Install a hook that kills the entire session when the given pane's
|
|
70
|
+
* process exits. Used by chat sessions so the session is torn down
|
|
71
|
+
* when the agent CLI exits — whether via `/exit`, a deliberate double
|
|
72
|
+
* Ctrl+C, or a crash — without leaving the footer pane keeping the
|
|
73
|
+
* session alive.
|
|
74
|
+
*
|
|
75
|
+
* The hook is session-scoped (pane-scoped hooks don't fire because the
|
|
76
|
+
* pane is already gone when `pane-exited` would run) and guarded with
|
|
77
|
+
* `#{hook_pane}` so the footer pane's eventual exit cascade doesn't
|
|
78
|
+
* re-trigger it. `kill-session` is idempotent in any case.
|
|
79
|
+
*/
|
|
80
|
+
export declare function killSessionOnPaneExit(sessionName: string, paneId: string): void;
|
|
68
81
|
/**
|
|
69
82
|
* Create a new window in an existing session without switching focus.
|
|
70
83
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/tmux.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAMtC,4FAA4F;AAC5F,eAAO,MAAM,WAAW,WAAW,CAAC;AAUpC,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAalC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAsB5C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;;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OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,WAAW,EAAE,CAyB5C;AAWD;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAYvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAI9D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CASjD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAMxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAiB/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEjD;AAMD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvD"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ralph workflow for Claude Code — plan → orchestrate → review
|
|
2
|
+
* Ralph workflow for Claude Code — plan → orchestrate → review loop.
|
|
3
3
|
*
|
|
4
4
|
* Each sub-agent invocation spawns its own visible session in the graph,
|
|
5
5
|
* so users can see each iteration's progress in real time. The loop
|
|
6
6
|
* terminates when:
|
|
7
7
|
* - `max_loops` iterations have completed (defaults to {@link DEFAULT_MAX_LOOPS}), OR
|
|
8
|
-
* -
|
|
8
|
+
* - Both parallel reviewer passes return `overall_correctness === "patch is correct"`.
|
|
9
|
+
*
|
|
10
|
+
* On a failed review the merged findings are formatted into a markdown
|
|
11
|
+
* brief by {@link formatReviewForReplan} and fed into the next iteration's
|
|
12
|
+
* planner, which is responsible for validating, deduping, and clustering
|
|
13
|
+
* them into shared root causes before revising the RFC.
|
|
9
14
|
*
|
|
10
15
|
* The reviewer stages run **headless** via the Claude Agent SDK with
|
|
11
16
|
* `outputFormat: { type: "json_schema", schema: REVIEW_RESULT_JSON_SCHEMA }`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/claude/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/claude/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;AA8CH,wBA6Ka"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ralph workflow for Copilot — plan → orchestrate → review
|
|
2
|
+
* Ralph workflow for Copilot — plan → orchestrate → review loop.
|
|
3
3
|
*
|
|
4
4
|
* Each sub-agent invocation spawns its own visible session in the graph,
|
|
5
5
|
* so users can see each iteration's progress in real time. The loop
|
|
6
6
|
* terminates when:
|
|
7
7
|
* - `max_loops` iterations have completed (defaults to {@link DEFAULT_MAX_LOOPS}), OR
|
|
8
|
-
* -
|
|
8
|
+
* - Both parallel reviewer passes return `overall_correctness === "patch is correct"`.
|
|
9
|
+
*
|
|
10
|
+
* On a failed review the merged findings are formatted into a markdown
|
|
11
|
+
* brief by {@link formatReviewForReplan} and fed into the next iteration's
|
|
12
|
+
* planner, which is responsible for validating, deduping, and clustering
|
|
13
|
+
* them into shared root causes before revising the RFC.
|
|
9
14
|
*
|
|
10
15
|
* The reviewer stages use a `submit_review` custom tool (defined via
|
|
11
16
|
* `defineTool` with Zod schema validation) to guarantee the review result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/copilot/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/copilot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;AA4DH,wBAsLa"}
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Ralph Prompt Utilities
|
|
3
3
|
*
|
|
4
|
-
* Prompts used by the Ralph plan → orchestrate → review
|
|
5
|
-
* - buildPlannerPrompt: initial planning OR re-planning from
|
|
4
|
+
* Prompts used by the Ralph plan → orchestrate → review loop:
|
|
5
|
+
* - buildPlannerPrompt: initial planning OR re-planning from reviewer findings
|
|
6
6
|
* - buildOrchestratorPrompt: spawn workers to execute the task list
|
|
7
7
|
* - buildInfraDiscoveryPrompts: prompts for parallel sub-agent infrastructure discovery
|
|
8
8
|
* - buildReviewPrompt: structured code review with injected changeset + discovery context
|
|
9
|
-
* - buildDebuggerReportPrompt: diagnose review findings, produce a re-plan brief
|
|
10
9
|
*
|
|
11
10
|
* Plus Zod schemas for structured output, parsing helpers for the reviewer
|
|
12
|
-
* JSON output, and
|
|
11
|
+
* JSON output, and {@link formatReviewForReplan} which renders the merged
|
|
12
|
+
* reviewer output as the markdown brief consumed by the next planner
|
|
13
|
+
* iteration.
|
|
13
14
|
*/
|
|
14
15
|
import { z } from "zod";
|
|
16
|
+
/**
|
|
17
|
+
* Caveman response-style directive injected into every Ralph prompt.
|
|
18
|
+
*
|
|
19
|
+
* Goal: shrink free-form prose across many loop iterations to cut tokens
|
|
20
|
+
* without dropping technical substance. Carve-outs preserve every
|
|
21
|
+
* machine-consumed contract (schemas, headers, enums, tool args, code).
|
|
22
|
+
*
|
|
23
|
+
* Placement: appended via {@link withCaveman} so each builder's strict
|
|
24
|
+
* output-format block remains the final instruction the model reads.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CAVEMAN_INSTRUCTION = "## Response Style \u2014 Terse Caveman\n\nRespond terse like smart caveman. All technical substance stay. Only fluff die.\n\n### Persistence\nACTIVE EVERY RESPONSE. No revert after many turns. No filler drift. Still active if unsure.\n\n### Rules\nDrop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not \"implement a solution for\"). Technical terms exact. Code blocks unchanged. Errors quoted exact.\n\nPattern: `[thing] [action] [reason]. [next step].`\n\nNot: \"Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by...\"\nYes: \"Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:\"\n\n### Intensity\nDrop articles, fragments OK, short synonyms.\n\nExample \u2014 \"Why React component re-render?\"\n\"New object ref each render. Inline object prop = new ref = re-render. Wrap in `useMemo`.\"\n\nExample \u2014 \"Explain database connection pooling.\"\n\"Pool reuse open DB connections. No new connection per request. Skip handshake overhead.\"\n\n### Auto-Clarity\nDrop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question. Resume caveman after clear part done.\n\nExample \u2014 destructive op:\n> **Warning:** This will permanently delete all rows in the `users` table and cannot be undone.\n> ```sql\n> DROP TABLE users;\n> ```\n> Caveman resume. Verify backup exist first.\n\n### Boundaries \u2014 caveman MUST NOT touch\nCaveman compresses free-form prose only. Leave the following exactly as the prompt or schema specifies:\n\n- Code blocks, commit messages, PR descriptions: write normal.\n- Exact enum / literal strings the schema or prompt specifies (e.g. `\"patch is correct\"`, `\"patch is incorrect\"`, task statuses `pending` / `in_progress` / `completed` / `error`).\n- Required section headers and template scaffolding (e.g. `# Debugger Report`, `## Issues Identified`, RFC section names) \u2014 verbatim.\n- Tool names, tool arguments, JSON keys, schema field names.\n- File paths, URLs, command invocations, error text quoted from tools.\n- SQL, JSON, Markdown templates: compress prose inside, never the structure.\n- Task titles / descriptions persisted via task-management tools: keep them self-contained and unambiguous.\n- When the prompt says output ONLY a path / ONLY a fenced block / ONLY a JSON payload, obey that exactly \u2014 caveman does not override output contracts.";
|
|
15
27
|
/** Zod schema for a single review finding. */
|
|
16
28
|
export declare const ReviewFindingSchema: z.ZodObject<{
|
|
17
29
|
title: z.ZodString;
|
|
@@ -41,7 +53,10 @@ export declare const ReviewResultSchema: z.ZodObject<{
|
|
|
41
53
|
}, z.core.$strip>;
|
|
42
54
|
}, z.core.$strip>>;
|
|
43
55
|
}, z.core.$strip>>;
|
|
44
|
-
overall_correctness: z.
|
|
56
|
+
overall_correctness: z.ZodEnum<{
|
|
57
|
+
"patch is correct": "patch is correct";
|
|
58
|
+
"patch is incorrect": "patch is incorrect";
|
|
59
|
+
}>;
|
|
45
60
|
overall_explanation: z.ZodString;
|
|
46
61
|
overall_confidence_score: z.ZodOptional<z.ZodNumber>;
|
|
47
62
|
}, z.core.$strip>;
|
|
@@ -68,7 +83,10 @@ export declare const REVIEW_RESULT_JSON_SCHEMA: z.core.ZodStandardJSONSchemaPayl
|
|
|
68
83
|
}, z.core.$strip>;
|
|
69
84
|
}, z.core.$strip>>;
|
|
70
85
|
}, z.core.$strip>>;
|
|
71
|
-
overall_correctness: z.
|
|
86
|
+
overall_correctness: z.ZodEnum<{
|
|
87
|
+
"patch is correct": "patch is correct";
|
|
88
|
+
"patch is incorrect": "patch is incorrect";
|
|
89
|
+
}>;
|
|
72
90
|
overall_explanation: z.ZodString;
|
|
73
91
|
overall_confidence_score: z.ZodOptional<z.ZodNumber>;
|
|
74
92
|
}, z.core.$strip>>;
|
|
@@ -93,17 +111,23 @@ export declare function mergeReviewResults(a: StructuredReviewResult, b: Structu
|
|
|
93
111
|
export interface PlannerContext {
|
|
94
112
|
/** 1-indexed loop iteration. Iteration 1 = initial plan; >1 = re-plan. */
|
|
95
113
|
iteration: number;
|
|
96
|
-
/**
|
|
97
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Markdown rendering of the previous iteration's merged reviewer
|
|
116
|
+
* findings. Produced by {@link formatReviewForReplan}. The planner is
|
|
117
|
+
* responsible for validating, deduping, and clustering findings into
|
|
118
|
+
* shared root causes before revising the RFC — there is no separate
|
|
119
|
+
* debugger stage.
|
|
120
|
+
*/
|
|
121
|
+
reviewReport?: string;
|
|
98
122
|
}
|
|
99
123
|
/**
|
|
100
124
|
* Build the planner prompt. The first iteration authors an RFC from the
|
|
101
|
-
* original spec; subsequent iterations revise the RFC using the
|
|
102
|
-
*
|
|
125
|
+
* original spec; subsequent iterations revise the RFC using the merged
|
|
126
|
+
* reviewer findings from the previous loop iteration.
|
|
103
127
|
*
|
|
104
128
|
* The planner's deliverable is a filled-in Technical Design Document / RFC
|
|
105
|
-
* rendered as markdown text
|
|
106
|
-
*
|
|
129
|
+
* rendered as markdown text; the orchestrator consumes the RFC as design
|
|
130
|
+
* context.
|
|
107
131
|
*/
|
|
108
132
|
export declare function buildPlannerPrompt(spec: string, context?: PlannerContext): string;
|
|
109
133
|
export interface OrchestratorContext {
|
|
@@ -203,28 +227,6 @@ export interface ReviewContext {
|
|
|
203
227
|
* both committed and uncommitted — without expensive tool calls.
|
|
204
228
|
*/
|
|
205
229
|
export declare function buildReviewPrompt(spec: string, context: ReviewContext): string;
|
|
206
|
-
export interface DebuggerContext {
|
|
207
|
-
/** 1-indexed loop iteration the debugger is investigating. */
|
|
208
|
-
iteration: number;
|
|
209
|
-
/**
|
|
210
|
-
* Branch changeset captured immediately before the review. Provides the
|
|
211
|
-
* debugger with the same file-level context as the reviewer.
|
|
212
|
-
*/
|
|
213
|
-
changeset: {
|
|
214
|
-
baseBranch: string;
|
|
215
|
-
diffStat: string;
|
|
216
|
-
uncommitted: string;
|
|
217
|
-
nameStatus: string;
|
|
218
|
-
errors: string[];
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Build a prompt asking the debugger sub-agent to investigate a set of review
|
|
223
|
-
* findings and produce a structured report. The debugger MUST NOT apply
|
|
224
|
-
* fixes — its only deliverable is the report, which the next iteration's
|
|
225
|
-
* planner consumes.
|
|
226
|
-
*/
|
|
227
|
-
export declare function buildDebuggerReportPrompt(review: ReviewResult | null, rawReview: string, context: DebuggerContext): string;
|
|
228
230
|
export declare function filterActionable(parsed: {
|
|
229
231
|
findings: ReviewFinding[];
|
|
230
232
|
overall_correctness: string;
|
|
@@ -232,12 +234,18 @@ export declare function filterActionable(parsed: {
|
|
|
232
234
|
overall_confidence_score?: number;
|
|
233
235
|
}): ReviewResult;
|
|
234
236
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
237
|
+
* Render the merged reviewer result as the markdown brief consumed by the
|
|
238
|
+
* next iteration's planner.
|
|
239
|
+
*
|
|
240
|
+
* Findings are grouped by file path so the planner sees clusters of related
|
|
241
|
+
* symptoms together (often a hint at a shared root cause). Within each
|
|
242
|
+
* group findings are ordered by ascending priority (P0 first). The
|
|
243
|
+
* `overall_explanation` is included verbatim so the planner has the
|
|
244
|
+
* reviewers' overall narrative.
|
|
238
245
|
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
246
|
+
* When `parsed === null` (SDK validation failed) the raw transcript is
|
|
247
|
+
* surfaced inside a clearly-labelled fenced block so the planner knows the
|
|
248
|
+
* data is unstructured and must be investigated rather than trusted.
|
|
241
249
|
*/
|
|
242
|
-
export declare function
|
|
250
|
+
export declare function formatReviewForReplan(parsed: ReviewResult | null, rawText: string): string;
|
|
243
251
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/helpers/prompts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/helpers/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,+iFA4CuH,CAAC;AAexJ,8CAA8C;AAC9C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;iBAsC9B,CAAC;AAEH,wDAAwD;AACxD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;iBAkB7B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;kBAEpC,CAAC;AAEH,mEAAmE;AACnE,MAAM,WAAW,sBAAsB;IACrC,oFAAoF;IACpF,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,sBAAsB,EACzB,CAAC,EAAE,sBAAsB,GACxB,sBAAsB,CAoCxB;AAMD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAiC,GACzC,MAAM,CA0HR;AAKD,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,mBAAwB,GAChC,MAAM,CAsJR;AAMD,0EAA0E;AAC1E,MAAM,WAAW,qBAAqB;IACpC,iDA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gB,CAAC,MAAM,EAAE;IACvC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,GAAG,YAAY,CAUf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,OAAO,EAAE,MAAM,GACd,MAAM,CA4DR"}
|
|
@@ -6,14 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ReviewResult } from "./prompts.ts";
|
|
8
8
|
/**
|
|
9
|
-
* Check whether the
|
|
9
|
+
* Check whether the loop should iterate again.
|
|
10
10
|
*
|
|
11
11
|
* Returns true when:
|
|
12
|
-
* 1. The parsed
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* 1. The review could not be parsed (null) but the raw response text is
|
|
13
|
+
* non-empty — treat unparseable output as actionable so the loop keeps
|
|
14
|
+
* iterating instead of silently exiting on a missing reviewer.
|
|
15
|
+
* 2. The merged review reports `overall_correctness === "patch is incorrect"`.
|
|
16
|
+
* {@link mergeReviewResults} sets the merged value to "patch is incorrect"
|
|
17
|
+
* if EITHER reviewer flagged it, so "patch is correct" here means BOTH
|
|
18
|
+
* reviewers signed off — the only stop condition.
|
|
15
19
|
*
|
|
16
|
-
* @param review - Parsed ReviewResult, or null if parsing failed.
|
|
20
|
+
* @param review - Parsed (merged) ReviewResult, or null if parsing failed.
|
|
17
21
|
* @param rawText - The raw reviewer response text.
|
|
18
22
|
*/
|
|
19
23
|
export declare function hasActionableFindings(review: ReviewResult | null, rawText: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/helpers/review.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/helpers/review.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAKT"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ralph workflow for OpenCode — plan → orchestrate → review
|
|
2
|
+
* Ralph workflow for OpenCode — plan → orchestrate → review loop.
|
|
3
3
|
*
|
|
4
4
|
* Each sub-agent invocation spawns its own visible session in the graph,
|
|
5
5
|
* so users can see each iteration's progress in real time. The loop
|
|
6
6
|
* terminates when:
|
|
7
7
|
* - `max_loops` iterations have completed (defaults to {@link DEFAULT_MAX_LOOPS}), OR
|
|
8
|
-
* -
|
|
8
|
+
* - Both parallel reviewer passes return `overall_correctness === "patch is correct"`.
|
|
9
|
+
*
|
|
10
|
+
* On a failed review the merged findings are formatted into a markdown
|
|
11
|
+
* brief by {@link formatReviewForReplan} and fed into the next iteration's
|
|
12
|
+
* planner, which is responsible for validating, deduping, and clustering
|
|
13
|
+
* them into shared root causes before revising the RFC.
|
|
9
14
|
*
|
|
10
15
|
* The reviewer stages use the OpenCode SDK's structured output
|
|
11
16
|
* (`format: { type: "json_schema" }`) to guarantee the review result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/opencode/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/sdk/workflows/builtin/ralph/opencode/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;AAwDH,wBAyKa"}
|
|
@@ -15,7 +15,7 @@ export type { ClaudeSessionOptions, ClaudeQueryOptions } from "../providers/clau
|
|
|
15
15
|
export { validateCopilotWorkflow } from "../providers/copilot.ts";
|
|
16
16
|
export { validateOpenCodeWorkflow } from "../providers/opencode.ts";
|
|
17
17
|
export type { TmuxResult, TmuxSession, SessionType } from "../runtime/tmux.ts";
|
|
18
|
-
export { SOCKET_NAME, isTmuxInstalled, getMuxBinary, resetMuxBinaryCache, isInsideTmux, isInsideAtomicSocket, createSession, createWindow, createPane, sendLiteralText, sendSpecialKey, capturePane, capturePaneVisible, capturePaneScrollback, killSession, killWindow, sessionExists, listSessions, attachSession, spawnMuxAttach, switchClient, getCurrentSession, attachOrSwitch, detachAndAttachAtomic, selectWindow, setSessionEnv, getSessionEnv, parseSessionName, tmuxRun, normalizeTmuxCapture, normalizeTmuxLines, } from "../runtime/tmux.ts";
|
|
18
|
+
export { SOCKET_NAME, isTmuxInstalled, getMuxBinary, resetMuxBinaryCache, isInsideTmux, isInsideAtomicSocket, createSession, createWindow, createPane, sendLiteralText, sendSpecialKey, capturePane, capturePaneVisible, capturePaneScrollback, killSession, killSessionOnPaneExit, killWindow, sessionExists, listSessions, attachSession, spawnMuxAttach, switchClient, getCurrentSession, attachOrSwitch, detachAndAttachAtomic, selectWindow, setSessionEnv, getSessionEnv, parseSessionName, tmuxRun, normalizeTmuxCapture, normalizeTmuxLines, } from "../runtime/tmux.ts";
|
|
19
19
|
export { AGENTS, discoverWorkflows, findWorkflow, loadWorkflowsMetadata, WORKFLOWS_GITIGNORE, } from "../runtime/discovery.ts";
|
|
20
20
|
export type { DiscoveredWorkflow, WorkflowWithMetadata, WorkflowMetadataStatus, } from "../runtime/discovery.ts";
|
|
21
21
|
export { WorkflowLoader } from "../runtime/loader.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/workfl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a,EACb,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/workflows/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExE,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,qBAAqB,IAAI,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,YAAY,EAAE,cAAc,IAAI,oB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
"name": "@bastani/atomic",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.32-1",
|
|
4
4
|
"description": "Configuration management CLI and SDK for coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"src",
|
|
44
44
|
"dist",
|
|
45
45
|
"assets/settings.schema.json",
|
|
46
|
-
".agents/skills",
|
|
47
46
|
".claude/agents",
|
|
48
47
|
".claude/settings.json",
|
|
49
48
|
".opencode/agents",
|
|
50
49
|
".opencode/opencode.json",
|
|
51
50
|
".github/agents",
|
|
52
51
|
".github/lsp.json",
|
|
53
|
-
".mcp.json"
|
|
52
|
+
".mcp.json",
|
|
53
|
+
".agents/skills"
|
|
54
54
|
],
|
|
55
55
|
"scripts": {
|
|
56
56
|
"dev": "bun run src/cli.ts",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@j178/prek": "^0.3.10",
|
|
68
|
-
"@types/bun": "^1.3.
|
|
68
|
+
"@types/bun": "^1.3.13",
|
|
69
69
|
"@types/react": "^19.2.14",
|
|
70
70
|
"oxlint": "^1.61.0",
|
|
71
71
|
"typescript": "^6.0.3",
|
|
72
72
|
"typescript-language-server": "^5.1.3"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
75
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.118",
|
|
76
76
|
"@clack/prompts": "^1.2.0",
|
|
77
77
|
"@commander-js/extra-typings": "^14.0.0",
|
|
78
78
|
"@github/copilot-sdk": "^0.2.2",
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
createSession,
|
|
38
38
|
detachAndAttachAtomic,
|
|
39
39
|
killSession,
|
|
40
|
+
killSessionOnPaneExit,
|
|
40
41
|
setSessionEnv,
|
|
41
42
|
spawnMuxAttach,
|
|
42
43
|
switchClient,
|
|
@@ -263,6 +264,12 @@ export async function chatCommand(options: ChatCommandOptions = {}): Promise<num
|
|
|
263
264
|
const paneId = createSession(windowName, shellCmd, undefined, projectRoot);
|
|
264
265
|
setSessionEnv(windowName, "ATOMIC_AGENT", agentType);
|
|
265
266
|
|
|
267
|
+
// When the agent CLI exits (via `/exit`, double Ctrl+C, or crash),
|
|
268
|
+
// tear down the whole session so the footer pane doesn't keep it
|
|
269
|
+
// alive in the background. Pane-scoped so the footer's own exit
|
|
270
|
+
// (which cascades from the kill-session) doesn't re-trigger.
|
|
271
|
+
killSessionOnPaneExit(windowName, paneId);
|
|
272
|
+
|
|
266
273
|
// Split the pane so the agent CLI runs on top and the React footer
|
|
267
274
|
// (provider pill + window name) runs in a 5% bottom pane. Matches
|
|
268
275
|
// the workflow-window layout, minus the keyboard hints (chat sessions
|
|
@@ -51,6 +51,12 @@ import type {
|
|
|
51
51
|
const realDiscoverWorkflows = realWorkflows.discoverWorkflows;
|
|
52
52
|
const realLoadWorkflowsMetadata = realWorkflows.loadWorkflowsMetadata;
|
|
53
53
|
const realIsCommandInstalled = realDetect.isCommandInstalled;
|
|
54
|
+
// Snapshot the real `auth.ts` exports before `mock.module` rebinds them.
|
|
55
|
+
// Bun 1.3.13 canonicalizes `mock.module` specifiers to an absolute path, so
|
|
56
|
+
// our registration for `"../../services/system/auth.ts"` now shares a key with
|
|
57
|
+
// `auth.test.ts`'s `"./auth.ts"` — the mock leaks across files unless we
|
|
58
|
+
// explicitly restore on teardown. See `afterAll` at the bottom of this file.
|
|
59
|
+
const realAuthSnapshot = { ...realAuth };
|
|
54
60
|
|
|
55
61
|
// ─── Dependency mocks ───────────────────────────────────────────────────────
|
|
56
62
|
// Every mock is a wrapper around the real implementation by default so
|
|
@@ -133,6 +139,12 @@ mock.module("../../lib/spawn.ts", () => ({
|
|
|
133
139
|
// binds to the mocked dependencies. Top-level await is fine under Bun.
|
|
134
140
|
const { workflowCommand } = await import("./workflow.ts");
|
|
135
141
|
|
|
142
|
+
// Restore `auth.ts` to its real exports once this file's tests finish so the
|
|
143
|
+
// leaked `checkAgentAuthMock` doesn't hijack `auth.test.ts` when it loads next.
|
|
144
|
+
afterAll(() => {
|
|
145
|
+
mock.module("../../services/system/auth.ts", () => realAuthSnapshot);
|
|
146
|
+
});
|
|
147
|
+
|
|
136
148
|
// ─── Output capture ─────────────────────────────────────────────────────────
|
|
137
149
|
// The CLI writes error banners to stderr via `console.error`, success content
|
|
138
150
|
// to stdout via `process.stdout.write`. Wrap both so tests can snapshot the
|
|
@@ -53,14 +53,17 @@ bind -n C-g select-window -t :0
|
|
|
53
53
|
# Ctrl+\: cycle to next agent window from anywhere
|
|
54
54
|
bind -n C-\\ next-window
|
|
55
55
|
|
|
56
|
-
# Ctrl+C
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
|
|
56
|
+
# Ctrl+C handling — for workflow sessions, debounce bursts so the agent's
|
|
57
|
+
# "double-tap to exit" doesn't trigger on accidental spam. For chat
|
|
58
|
+
# sessions (atomic-chat-*) the user is in direct control of the single
|
|
59
|
+
# agent CLI and a deliberate double-tap exit must reach the agent
|
|
60
|
+
# verbatim, so we forward Ctrl+C unmodified.
|
|
61
|
+
#
|
|
62
|
+
# @atomic-bun and @atomic-cc-debounce are set to absolute paths by
|
|
63
|
+
# tmux.ts on session creation — no PATH lookup needed inside run-shell.
|
|
64
|
+
bind -n C-c if-shell -F '#{m:atomic-chat-*,#{session_name}}' \
|
|
65
|
+
'send-keys C-c' \
|
|
66
|
+
'run-shell -b "\"#{@atomic-bun}\" \"#{@atomic-cc-debounce}\" \"#{pane_id}\""'
|
|
64
67
|
|
|
65
68
|
# Escape exits copy-mode (clear selection first if one exists, otherwise cancel)
|
|
66
69
|
bind-key -T copy-mode-vi Escape if-shell -F "#{selection_present}" "send-keys -X clear-selection" "send-keys -X cancel"
|
package/src/sdk/runtime/tmux.ts
CHANGED
|
@@ -220,6 +220,28 @@ export function createSession(
|
|
|
220
220
|
return paneId || tmux(["list-panes", "-t", sessionName, "-F", "#{pane_id}"]).split("\n")[0]!;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Install a hook that kills the entire session when the given pane's
|
|
225
|
+
* process exits. Used by chat sessions so the session is torn down
|
|
226
|
+
* when the agent CLI exits — whether via `/exit`, a deliberate double
|
|
227
|
+
* Ctrl+C, or a crash — without leaving the footer pane keeping the
|
|
228
|
+
* session alive.
|
|
229
|
+
*
|
|
230
|
+
* The hook is session-scoped (pane-scoped hooks don't fire because the
|
|
231
|
+
* pane is already gone when `pane-exited` would run) and guarded with
|
|
232
|
+
* `#{hook_pane}` so the footer pane's eventual exit cascade doesn't
|
|
233
|
+
* re-trigger it. `kill-session` is idempotent in any case.
|
|
234
|
+
*/
|
|
235
|
+
export function killSessionOnPaneExit(sessionName: string, paneId: string): void {
|
|
236
|
+
const guard = `if -F '#{==:#{hook_pane},${paneId}}' 'kill-session -t ${sessionName}'`;
|
|
237
|
+
tmuxRun([
|
|
238
|
+
"set-hook",
|
|
239
|
+
"-t", sessionName,
|
|
240
|
+
"pane-exited",
|
|
241
|
+
guard,
|
|
242
|
+
]);
|
|
243
|
+
}
|
|
244
|
+
|
|
223
245
|
/**
|
|
224
246
|
* Create a new window in an existing session without switching focus.
|
|
225
247
|
*
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ralph workflow for Claude Code — plan → orchestrate → review
|
|
2
|
+
* Ralph workflow for Claude Code — plan → orchestrate → review loop.
|
|
3
3
|
*
|
|
4
4
|
* Each sub-agent invocation spawns its own visible session in the graph,
|
|
5
5
|
* so users can see each iteration's progress in real time. The loop
|
|
6
6
|
* terminates when:
|
|
7
7
|
* - `max_loops` iterations have completed (defaults to {@link DEFAULT_MAX_LOOPS}), OR
|
|
8
|
-
* -
|
|
8
|
+
* - Both parallel reviewer passes return `overall_correctness === "patch is correct"`.
|
|
9
|
+
*
|
|
10
|
+
* On a failed review the merged findings are formatted into a markdown
|
|
11
|
+
* brief by {@link formatReviewForReplan} and fed into the next iteration's
|
|
12
|
+
* planner, which is responsible for validating, deduping, and clustering
|
|
13
|
+
* them into shared root causes before revising the RFC.
|
|
9
14
|
*
|
|
10
15
|
* The reviewer stages run **headless** via the Claude Agent SDK with
|
|
11
16
|
* `outputFormat: { type: "json_schema", schema: REVIEW_RESULT_JSON_SCHEMA }`,
|
|
@@ -25,9 +30,8 @@ import {
|
|
|
25
30
|
buildOrchestratorPrompt,
|
|
26
31
|
buildInfraDiscoveryPrompts,
|
|
27
32
|
buildReviewPrompt,
|
|
28
|
-
buildDebuggerReportPrompt,
|
|
29
|
-
extractMarkdownBlock,
|
|
30
33
|
filterActionable,
|
|
34
|
+
formatReviewForReplan,
|
|
31
35
|
mergeReviewResults,
|
|
32
36
|
REVIEW_RESULT_JSON_SCHEMA,
|
|
33
37
|
type ReviewResult,
|
|
@@ -65,8 +69,7 @@ function extractReview(
|
|
|
65
69
|
|
|
66
70
|
export default defineWorkflow({
|
|
67
71
|
name: "ralph",
|
|
68
|
-
description:
|
|
69
|
-
"Plan → orchestrate → review → debug loop with bounded iteration",
|
|
72
|
+
description: "Plan → orchestrate → review loop with bounded iteration",
|
|
70
73
|
inputs: [
|
|
71
74
|
{
|
|
72
75
|
name: "prompt",
|
|
@@ -86,7 +89,7 @@ export default defineWorkflow({
|
|
|
86
89
|
.run(async (ctx) => {
|
|
87
90
|
const prompt = ctx.inputs.prompt ?? "";
|
|
88
91
|
const maxLoops = ctx.inputs.max_loops ?? DEFAULT_MAX_LOOPS;
|
|
89
|
-
let
|
|
92
|
+
let reviewReport = "";
|
|
90
93
|
|
|
91
94
|
for (let iteration = 1; iteration <= maxLoops; iteration++) {
|
|
92
95
|
// ── Plan ────────────────────────────────────────────────────────────
|
|
@@ -105,7 +108,7 @@ export default defineWorkflow({
|
|
|
105
108
|
await s.session.query(
|
|
106
109
|
buildPlannerPrompt(prompt, {
|
|
107
110
|
iteration,
|
|
108
|
-
|
|
111
|
+
reviewReport: reviewReport || undefined,
|
|
109
112
|
}),
|
|
110
113
|
);
|
|
111
114
|
s.save(s.sessionId);
|
|
@@ -233,33 +236,8 @@ export default defineWorkflow({
|
|
|
233
236
|
// Both reviewers agree the code is clean → done
|
|
234
237
|
if (!hasActionableFindings(parsed, reviewRaw)) break;
|
|
235
238
|
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
const debugger_ = await ctx.stage(
|
|
239
|
-
{ name: `debugger-${iteration}` },
|
|
240
|
-
{
|
|
241
|
-
chatFlags: [
|
|
242
|
-
"--agent",
|
|
243
|
-
"debugger",
|
|
244
|
-
"--allow-dangerously-skip-permissions",
|
|
245
|
-
"--dangerously-skip-permissions",
|
|
246
|
-
],
|
|
247
|
-
},
|
|
248
|
-
{},
|
|
249
|
-
async (s) => {
|
|
250
|
-
const result = await s.session.query(
|
|
251
|
-
buildDebuggerReportPrompt(parsed, reviewRaw, {
|
|
252
|
-
iteration,
|
|
253
|
-
changeset,
|
|
254
|
-
}),
|
|
255
|
-
);
|
|
256
|
-
s.save(s.sessionId);
|
|
257
|
-
return extractAssistantText(result, 0);
|
|
258
|
-
},
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
debuggerReport = extractMarkdownBlock(debugger_.result);
|
|
262
|
-
}
|
|
239
|
+
// Findings exist — format them for the next iteration's planner.
|
|
240
|
+
reviewReport = formatReviewForReplan(parsed, reviewRaw);
|
|
263
241
|
}
|
|
264
242
|
})
|
|
265
243
|
.compile();
|