ralph-lisa-loop 3.0.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 ADDED
@@ -0,0 +1,226 @@
1
+ # Ralph-Lisa Loop
2
+
3
+ Turn-based dual-agent collaboration: Ralph codes, Lisa reviews, consensus required.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![npm version](https://img.shields.io/npm/v/ralph-lisa-loop.svg)](https://www.npmjs.com/package/ralph-lisa-loop)
7
+
8
+ ## The Problem
9
+
10
+ Single-agent coding is like grading your own exam. The same model writes code AND decides if it's done. No external validation. No second opinion.
11
+
12
+ ## The Solution
13
+
14
+ **Ralph-Lisa Loop** enforces a strict turn-based workflow:
15
+
16
+ ```
17
+ Ralph writes → Lisa reviews → Consensus → Next step
18
+ ↑ |
19
+ └────────────────────────────────────────┘
20
+ ```
21
+
22
+ - **Ralph** (Claude Code): Lead developer - researches, plans, codes, tests
23
+ - **Lisa** (Codex): Code reviewer - reviews, provides feedback
24
+ - **Turn Control**: Only one agent works at a time
25
+ - **Consensus Required**: Both must agree before proceeding
26
+ - **Research First**: When involving reference implementations/protocols/APIs, Ralph must submit [RESEARCH] before coding
27
+ - **Test Results Required**: [CODE] and [FIX] submissions must include test results
28
+ - **Policy Layer**: Configurable warn/block mode for submission quality checks
29
+
30
+ ## Quick Start
31
+
32
+ ### 1. Install
33
+
34
+ ```bash
35
+ npm i -g ralph-lisa-loop
36
+ ```
37
+
38
+ ### 2. Initialize Project
39
+
40
+ ```bash
41
+ cd your-project
42
+ ralph-lisa init
43
+ ```
44
+
45
+ ### 3. Start Collaboration
46
+
47
+ ```bash
48
+ # Manual mode (recommended)
49
+ ralph-lisa start "implement login feature"
50
+
51
+ # Or auto mode (experimental, requires tmux)
52
+ ralph-lisa auto "implement login feature"
53
+ ```
54
+
55
+ ### 4. Work Flow
56
+
57
+ **Terminal 1 - Ralph (Claude Code)**:
58
+ ```bash
59
+ ralph-lisa whose-turn # Check turn
60
+ # ... do work ...
61
+ ralph-lisa submit-ralph "[PLAN] Login feature design
62
+
63
+ 1. Create login form component
64
+ 2. Add validation
65
+ 3. Connect to API"
66
+ ```
67
+
68
+ **Terminal 2 - Lisa (Codex)**:
69
+ ```bash
70
+ ralph-lisa whose-turn # Check turn
71
+ ralph-lisa read work.md # Read Ralph's work
72
+ ralph-lisa submit-lisa "[PASS] Plan looks good
73
+
74
+ - Clear structure
75
+ - Good separation of concerns"
76
+ ```
77
+
78
+ ## Features
79
+
80
+ ### Turn Control
81
+ Agents must check `whose-turn` before any action. Submissions automatically pass the turn.
82
+
83
+ ### Tag System
84
+ Every submission requires a tag:
85
+
86
+ | Ralph Tags | Lisa Tags | Shared |
87
+ |------------|-----------|--------|
88
+ | `[PLAN]` | `[PASS]` | `[CHALLENGE]` |
89
+ | `[RESEARCH]` | `[NEEDS_WORK]` | `[DISCUSS]` |
90
+ | `[CODE]` | | `[QUESTION]` |
91
+ | `[FIX]` | | `[CONSENSUS]` |
92
+
93
+ - `[RESEARCH]`: Submit research results before coding (when involving reference implementations, protocols, or external APIs)
94
+ - `[CHALLENGE]`: Explicitly disagree with the other agent's suggestion, providing counter-argument
95
+ - `[CODE]`/`[FIX]`: Must include Test Results section
96
+
97
+ ### Consensus Protocol
98
+ Lisa's verdict is advisory. Ralph can agree or use `[CHALLENGE]` to disagree. Both must reach genuine consensus before `/next-step`. Silent acceptance (bare `[FIX]` without reasoning) is not allowed.
99
+
100
+ ### Minimal Init (Zero Intrusion)
101
+
102
+ When using the Claude Code plugin + Codex global config, you don't need project-level role files:
103
+
104
+ ```bash
105
+ ralph-lisa init --minimal
106
+ ```
107
+
108
+ This only creates `.dual-agent/` session state. No CLAUDE.md, CODEX.md, or command files are written. Requires:
109
+ - Claude Code plugin installed (provides Ralph role via hooks)
110
+ - Codex global config at `~/.codex/` (provides Lisa role)
111
+
112
+ `start` and `auto` commands work with both full and minimal init.
113
+
114
+ ### Policy Layer
115
+
116
+ **Inline checks** (during `submit-ralph`/`submit-lisa`):
117
+
118
+ ```bash
119
+ # Enable warn mode (prints warnings, doesn't block)
120
+ export RL_POLICY_MODE=warn
121
+
122
+ # Enable block mode (rejects non-compliant submissions)
123
+ export RL_POLICY_MODE=block
124
+
125
+ # Disable (default)
126
+ export RL_POLICY_MODE=off
127
+ ```
128
+
129
+ **Standalone checks** (for scripts/hooks — always exit non-zero on violations, ignoring `RL_POLICY_MODE`):
130
+
131
+ ```bash
132
+ ralph-lisa policy check ralph # Check Ralph's latest submission
133
+ ralph-lisa policy check lisa # Check Lisa's latest submission
134
+ ralph-lisa policy check-consensus # Both agents submitted [CONSENSUS]?
135
+ ralph-lisa policy check-next-step # Comprehensive: consensus + all policy checks
136
+ ```
137
+
138
+ Policy rules:
139
+ - Ralph's [CODE]/[FIX] must include "Test Results" section
140
+ - Ralph's [RESEARCH] must have substantive content
141
+ - Lisa's [PASS]/[NEEDS_WORK] must include at least 1 reason
142
+
143
+ ### Deadlock Escape
144
+ After 5 rounds without consensus: `[OVERRIDE]` (proceed anyway) or `[HANDOFF]` (escalate to human).
145
+
146
+ ## Commands
147
+
148
+ ```bash
149
+ # Project setup
150
+ ralph-lisa init [dir] # Initialize project (full)
151
+ ralph-lisa init --minimal [dir] # Minimal init (session only, no project files)
152
+ ralph-lisa uninit # Remove from project
153
+ ralph-lisa start "task" # Launch both agents
154
+ ralph-lisa start --full-auto "task" # Launch without permission prompts
155
+ ralph-lisa auto "task" # Auto mode (tmux)
156
+ ralph-lisa auto --full-auto "task" # Auto mode without permission prompts
157
+
158
+ # Turn control
159
+ ralph-lisa whose-turn # Check whose turn
160
+ ralph-lisa submit-ralph "[TAG] ..." # Ralph submits
161
+ ralph-lisa submit-lisa "[TAG] ..." # Lisa submits
162
+
163
+ # Information
164
+ ralph-lisa status # Current status
165
+ ralph-lisa read work.md # Ralph's latest
166
+ ralph-lisa read review.md # Lisa's latest
167
+ ralph-lisa history # Full history
168
+
169
+ # Flow control
170
+ ralph-lisa step "phase-name" # Enter new phase
171
+ ralph-lisa archive [name] # Archive session
172
+ ralph-lisa clean # Clean session
173
+
174
+ # Policy
175
+ ralph-lisa policy check <ralph|lisa> # Check submission (hard gate)
176
+ ralph-lisa policy check-consensus # Check if both [CONSENSUS]
177
+ ralph-lisa policy check-next-step # Comprehensive pre-step check
178
+ ```
179
+
180
+ ## Project Structure After Init
181
+
182
+ **Full init** (`ralph-lisa init`):
183
+ ```
184
+ your-project/
185
+ ├── CLAUDE.md # Ralph's role (auto-loaded by Claude Code)
186
+ ├── CODEX.md # Lisa's role (loaded via .codex/config.toml)
187
+ ├── .claude/
188
+ │ └── commands/ # Claude slash commands
189
+ ├── .codex/
190
+ │ ├── config.toml # Codex configuration
191
+ │ └── skills/ # Codex skills
192
+ └── .dual-agent/ # Session state
193
+ ├── turn.txt # Current turn
194
+ ├── work.md # Ralph's submissions
195
+ ├── review.md # Lisa's submissions
196
+ └── history.md # Full history
197
+ ```
198
+
199
+ **Minimal init** (`ralph-lisa init --minimal`):
200
+ ```
201
+ your-project/
202
+ └── .dual-agent/ # Session state only (zero project files)
203
+ ```
204
+
205
+ ## Requirements
206
+
207
+ - [Node.js](https://nodejs.org/) >= 18
208
+ - [Claude Code](https://claude.ai/code) - for Ralph
209
+ - [Codex CLI](https://github.com/openai/codex) - for Lisa
210
+
211
+ For auto mode:
212
+ - tmux
213
+ - fswatch (macOS) or inotify-tools (Linux)
214
+
215
+ ## Ecosystem
216
+
217
+ Part of the [TigerHill](https://github.com/Click-Intelligence-LLC/TigerHill) project family.
218
+
219
+ ## See Also
220
+
221
+ - [CONCEPT.md](CONCEPT.md) - Why dual-agent collaboration works
222
+ - [UPGRADE_PLAN_V3.md](UPGRADE_PLAN_V3.md) - V3 design document
223
+
224
+ ## License
225
+
226
+ [MIT](LICENSE)
package/dist/cli.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ralph-lisa CLI - Turn-based dual-agent collaboration.
4
+ * Replaces io.sh with Node/TS implementation.
5
+ *
6
+ * Usage: ralph-lisa <command> [args...]
7
+ */
8
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * ralph-lisa CLI - Turn-based dual-agent collaboration.
5
+ * Replaces io.sh with Node/TS implementation.
6
+ *
7
+ * Usage: ralph-lisa <command> [args...]
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ const commands_js_1 = require("./commands.js");
11
+ const args = process.argv.slice(2);
12
+ const cmd = args[0] || "";
13
+ const rest = args.slice(1);
14
+ switch (cmd) {
15
+ case "init":
16
+ // If first arg after init looks like a path, use cmdInitProject
17
+ // If it looks like a task description, also use cmdInitProject (with no path)
18
+ (0, commands_js_1.cmdInitProject)(rest);
19
+ break;
20
+ case "uninit":
21
+ (0, commands_js_1.cmdUninit)();
22
+ break;
23
+ case "whose-turn":
24
+ (0, commands_js_1.cmdWhoseTurn)();
25
+ break;
26
+ case "submit-ralph":
27
+ (0, commands_js_1.cmdSubmitRalph)(rest);
28
+ break;
29
+ case "submit-lisa":
30
+ (0, commands_js_1.cmdSubmitLisa)(rest);
31
+ break;
32
+ case "status":
33
+ (0, commands_js_1.cmdStatus)();
34
+ break;
35
+ case "read":
36
+ (0, commands_js_1.cmdRead)(rest);
37
+ break;
38
+ case "step":
39
+ (0, commands_js_1.cmdStep)(rest);
40
+ break;
41
+ case "history":
42
+ (0, commands_js_1.cmdHistory)();
43
+ break;
44
+ case "archive":
45
+ (0, commands_js_1.cmdArchive)(rest);
46
+ break;
47
+ case "clean":
48
+ (0, commands_js_1.cmdClean)();
49
+ break;
50
+ case "start":
51
+ (0, commands_js_1.cmdStart)(rest);
52
+ break;
53
+ case "auto":
54
+ (0, commands_js_1.cmdAuto)(rest);
55
+ break;
56
+ case "policy":
57
+ (0, commands_js_1.cmdPolicy)(rest);
58
+ break;
59
+ case "help":
60
+ case "--help":
61
+ case "-h":
62
+ case "":
63
+ showHelp();
64
+ break;
65
+ case "--version":
66
+ case "-v":
67
+ showVersion();
68
+ break;
69
+ default:
70
+ console.error(`Unknown command: ${cmd}`);
71
+ console.error('Run "ralph-lisa --help" for usage.');
72
+ process.exit(1);
73
+ }
74
+ function showHelp() {
75
+ console.log("Ralph Lisa Dual-Agent Loop - CLI");
76
+ console.log("");
77
+ console.log("Project Setup:");
78
+ console.log(" ralph-lisa init [dir] Initialize project");
79
+ console.log(" ralph-lisa init --minimal [dir] Minimal init (session only, no project files)");
80
+ console.log(" ralph-lisa uninit Remove from project");
81
+ console.log(' ralph-lisa start "task" Launch both agents');
82
+ console.log(' ralph-lisa start --full-auto "task" Launch without permission prompts');
83
+ console.log(' ralph-lisa auto "task" Auto mode (tmux)');
84
+ console.log(' ralph-lisa auto --full-auto "task" Auto mode without permission prompts');
85
+ console.log("");
86
+ console.log("Turn Control:");
87
+ console.log(" ralph-lisa whose-turn Check whose turn");
88
+ console.log(' ralph-lisa submit-ralph "[TAG]..." Ralph submits');
89
+ console.log(' ralph-lisa submit-lisa "[TAG]..." Lisa submits');
90
+ console.log("");
91
+ console.log("Tags:");
92
+ console.log(" Ralph: [PLAN] [RESEARCH] [CODE] [FIX] [CHALLENGE] [DISCUSS] [QUESTION] [CONSENSUS]");
93
+ console.log(" Lisa: [PASS] [NEEDS_WORK] [CHALLENGE] [DISCUSS] [QUESTION] [CONSENSUS]");
94
+ console.log("");
95
+ console.log("Information:");
96
+ console.log(" ralph-lisa status Show current status");
97
+ console.log(" ralph-lisa read <file> Read work.md/review.md");
98
+ console.log(" ralph-lisa history Show full history");
99
+ console.log("");
100
+ console.log("Flow Control:");
101
+ console.log(' ralph-lisa step "name" Enter new step');
102
+ console.log(" ralph-lisa archive [name] Archive session");
103
+ console.log(" ralph-lisa clean Clean session");
104
+ console.log("");
105
+ console.log("Policy:");
106
+ console.log(" ralph-lisa policy check <ralph|lisa> Check submission (hard gate)");
107
+ console.log(" ralph-lisa policy check-consensus Check if both [CONSENSUS]");
108
+ console.log(" ralph-lisa policy check-next-step Comprehensive pre-step check");
109
+ console.log("");
110
+ console.log(" Standalone policy check always exits non-zero on violations.");
111
+ console.log(" RL_POLICY_MODE (warn|block|off) only affects inline submit checks.");
112
+ }
113
+ function showVersion() {
114
+ try {
115
+ const pkg = require("../package.json");
116
+ console.log(`ralph-lisa-loop v${pkg.version}`);
117
+ }
118
+ catch {
119
+ console.log("ralph-lisa-loop v3.0.0");
120
+ }
121
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * CLI commands for Ralph-Lisa Loop.
3
+ * Direct port of io.sh logic to Node/TS.
4
+ */
5
+ export declare function cmdInit(args: string[]): void;
6
+ export declare function cmdWhoseTurn(): void;
7
+ export declare function cmdSubmitRalph(args: string[]): void;
8
+ export declare function cmdSubmitLisa(args: string[]): void;
9
+ export declare function cmdStatus(): void;
10
+ export declare function cmdRead(args: string[]): void;
11
+ export declare function cmdStep(args: string[]): void;
12
+ export declare function cmdHistory(): void;
13
+ export declare function cmdArchive(args: string[]): void;
14
+ export declare function cmdClean(): void;
15
+ export declare function cmdUninit(): void;
16
+ export declare function cmdInitProject(args: string[]): void;
17
+ export declare function cmdStart(args: string[]): void;
18
+ export declare function cmdAuto(args: string[]): void;
19
+ export declare function cmdPolicy(args: string[]): void;