ralph-lisa-loop 0.3.10 → 0.3.11

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
@@ -1,268 +1,94 @@
1
1
  # Ralph-Lisa Loop
2
2
 
3
3
  <p align="center">
4
- <img src="../rll_cat.png" alt="Ralph-Lisa Loop" width="256" />
4
+ <img src="https://raw.githubusercontent.com/YW1975/Ralph-Lisa-Loop/main/rll_cat.png" alt="Ralph-Lisa Loop" width="256" />
5
5
  </p>
6
6
 
7
7
  Turn-based dual-agent collaboration: Ralph codes, Lisa reviews, consensus required.
8
8
 
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/LICENSE)
10
10
  [![npm version](https://img.shields.io/npm/v/ralph-lisa-loop.svg)](https://www.npmjs.com/package/ralph-lisa-loop)
11
11
 
12
- ## The Problem
13
-
14
- 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.
15
-
16
- ## The Solution
17
-
18
- **Ralph-Lisa Loop** enforces a strict turn-based workflow:
19
-
20
- ```
21
- Ralph writes → Lisa reviews → Consensus → Next step
22
- ↑ |
23
- └────────────────────────────────────────┘
24
- ```
25
-
26
- - **Ralph** (Claude Code): Lead developer - researches, plans, codes, tests
27
- - **Lisa** (Codex): Code reviewer - reviews, provides feedback
28
- - **Turn Control**: Only one agent works at a time
29
- - **Consensus Required**: Both must agree before proceeding
30
- - **Research First**: When involving reference implementations/protocols/APIs, Ralph must submit [RESEARCH] before coding
31
- - **Test Results Required**: [CODE] and [FIX] submissions must include test results
32
- - **Policy Layer**: Configurable warn/block mode for submission quality checks
33
-
34
12
  ## Quick Start
35
13
 
36
- ### 1. Install
37
-
38
14
  ```bash
39
15
  npm i -g ralph-lisa-loop
40
- ```
41
-
42
- ### 2. Initialize Project
43
-
44
- ```bash
45
16
  cd your-project
46
17
  ralph-lisa init
47
- ```
48
-
49
- ### 3. Start Collaboration
50
-
51
- ```bash
52
- # Manual mode (recommended)
53
18
  ralph-lisa start "implement login feature"
54
-
55
- # Or auto mode (experimental, requires tmux)
56
- ralph-lisa auto "implement login feature"
57
19
  ```
58
20
 
59
- ### 4. Work Flow
21
+ ## How It Works
60
22
 
61
- **Terminal 1 - Ralph (Claude Code)**:
62
- ```bash
63
- ralph-lisa whose-turn # Check turn
64
- # ... do work, write submission to .dual-agent/submit.md ...
65
- ralph-lisa submit-ralph --file .dual-agent/submit.md
66
23
  ```
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
- # ... write review to .dual-agent/submit.md ...
73
- ralph-lisa submit-lisa --file .dual-agent/submit.md
74
- ```
75
-
76
- ## Features
77
-
78
- ### Turn Control
79
- Agents must check `whose-turn` before any action. Submissions automatically pass the turn.
80
-
81
- ### Tag System
82
- Every submission requires a tag:
83
-
84
- | Ralph Tags | Lisa Tags | Shared |
85
- |------------|-----------|--------|
86
- | `[PLAN]` | `[PASS]` | `[CHALLENGE]` |
87
- | `[RESEARCH]` | `[NEEDS_WORK]` | `[DISCUSS]` |
88
- | `[CODE]` | | `[QUESTION]` |
89
- | `[FIX]` | | `[CONSENSUS]` |
90
-
91
- - `[RESEARCH]`: Submit research results before coding (when involving reference implementations, protocols, or external APIs)
92
- - `[CHALLENGE]`: Explicitly disagree with the other agent's suggestion, providing counter-argument
93
- - `[CODE]`/`[FIX]`: Must include Test Results section
94
-
95
- ### Consensus Protocol
96
- 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.
97
-
98
- ### Minimal Init (Zero Intrusion)
99
-
100
- When using the Claude Code plugin + Codex global config, you don't need project-level role files:
101
-
102
- ```bash
103
- ralph-lisa init --minimal
104
- ```
105
-
106
- This only creates `.dual-agent/` session state. No CLAUDE.md, CODEX.md, or command files are written. Requires:
107
- - Claude Code plugin installed (provides Ralph role via hooks)
108
- - Codex global config at `~/.codex/` (provides Lisa role)
109
-
110
- `start` and `auto` commands work with both full and minimal init.
111
-
112
- ### Policy Layer
113
-
114
- **Inline checks** (during `submit-ralph`/`submit-lisa`):
115
-
116
- ```bash
117
- # Enable warn mode (prints warnings, doesn't block)
118
- export RL_POLICY_MODE=warn
119
-
120
- # Enable block mode (rejects non-compliant submissions)
121
- export RL_POLICY_MODE=block
122
-
123
- # Disable
124
- export RL_POLICY_MODE=off
125
- ```
126
-
127
- **Standalone checks** (for scripts/hooks — always exit non-zero on violations, ignoring `RL_POLICY_MODE`):
128
-
129
- ```bash
130
- ralph-lisa policy check ralph # Check Ralph's latest submission
131
- ralph-lisa policy check lisa # Check Lisa's latest submission
132
- ralph-lisa policy check-consensus # Both agents submitted [CONSENSUS]?
133
- ralph-lisa policy check-next-step # Comprehensive: consensus + all policy checks
134
- ```
135
-
136
- Policy rules:
137
- - Ralph's [CODE]/[FIX] must include "Test Results" section
138
- - Ralph's [RESEARCH] must have substantive content
139
- - Lisa's [PASS]/[NEEDS_WORK] must include at least 1 reason
140
-
141
- ### Mid-Session Task Update
142
- Change direction without restarting:
143
- ```bash
144
- ralph-lisa update-task "switch to REST instead of GraphQL"
24
+ Ralph writes → Lisa reviews → Consensus → Next step
25
+ ↑ |
26
+ └────────────────────────────────────────┘
145
27
  ```
146
- Appends to task.md (preserving history). Task context is auto-injected into work.md submissions and watcher trigger messages so both agents always see the current goal.
147
28
 
148
- ### Round 1 Mandatory Plan
149
- Ralph's first submission must be `[PLAN]` gives Lisa a chance to verify task understanding before coding begins.
29
+ - **Ralph** (Claude Code): Lead developer — researches, plans, codes, tests
30
+ - **Lisa** (Codex): Code reviewerreviews diffs, checks edge cases
31
+ - **You**: Tech lead — architecture, scope, tiebreaking
150
32
 
151
- ### Goal Guardian
152
- Lisa reads task.md before every review and checks for direction drift. Catching misalignment early is prioritized over code-level review.
33
+ ## Key Features
153
34
 
154
- ### Watcher v3
155
- - **Fire-and-forget triggering**: Removed output stability wait and delivery verification for faster turn transitions
156
- - **30s cooldown**: Prevents re-triggering during normal work
157
- - **Checkpoint system**: Set `RL_CHECKPOINT_ROUNDS=N` to pause for human review every N rounds
158
- - **Auto-restart**: Watcher automatically restarts on crash (session-guarded)
159
- - **Configurable log threshold**: `RL_LOG_MAX_MB` (default 5, min 1) with proportional tail retention
160
- - **Heartbeat file**: `.dual-agent/.watcher_heartbeat` for external liveness checks
35
+ - **Turn Control** — Only one agent works at a time; submissions pass the turn automatically
36
+ - **Tag System** `[PLAN]`, `[CODE]`, `[FIX]`, `[PASS]`, `[NEEDS_WORK]`, `[CHALLENGE]`, `[CONSENSUS]`
37
+ - **Consensus Protocol** Both agents must agree before proceeding; advisory verdicts, not commands
38
+ - **Policy Layer** Configurable `warn`/`block` mode for submission quality checks
39
+ - **Auto Mode** — tmux-based automation with file watcher for hands-off operation
40
+ - **Round 1 Mandatory Plan** — Ralph must submit `[PLAN]` first for Lisa to verify understanding
41
+ - **Goal Guardian** Lisa checks for direction drift before every review
42
+ - **Mid-Session Task Update** — Change direction without restarting
43
+ - **Deadlock Escape** — After 5 rounds: `[OVERRIDE]` or `[HANDOFF]` to human
44
+ - **Minimal Init** — Zero-intrusion mode with plugin/global config architecture
161
45
 
162
- ### Deadlock Escape
163
- After 5 rounds without consensus: `[OVERRIDE]` (proceed anyway) or `[HANDOFF]` (escalate to human).
164
-
165
- ## Commands
46
+ ## Essential Commands
166
47
 
167
48
  ```bash
168
- # Project setup
169
- ralph-lisa init [dir] # Initialize project (full)
170
- ralph-lisa init --minimal [dir] # Minimal init (session only, no project files)
171
- ralph-lisa uninit # Remove from project
49
+ # Setup
50
+ ralph-lisa init [dir] # Initialize project
172
51
  ralph-lisa start "task" # Launch both agents
173
- ralph-lisa start --full-auto "task" # Launch without permission prompts
174
52
  ralph-lisa auto "task" # Auto mode (tmux)
175
- ralph-lisa auto --full-auto "task" # Auto mode without permission prompts
176
53
 
177
54
  # Turn control
178
55
  ralph-lisa whose-turn # Check whose turn
179
- ralph-lisa check-turn # Alias for whose-turn
180
- ralph-lisa submit-ralph --file f.md # Ralph submits (recommended)
181
- ralph-lisa submit-lisa --file f.md # Lisa submits (recommended)
182
- ralph-lisa submit-ralph --stdin # Submit via stdin pipe
183
- ralph-lisa submit-lisa --stdin # Lisa submit via stdin pipe
184
- ralph-lisa submit-ralph "[TAG] ..." # Inline (deprecated)
56
+ ralph-lisa submit-ralph --file f.md # Ralph submits
57
+ ralph-lisa submit-lisa --file f.md # Lisa submits
185
58
 
186
59
  # Information
187
60
  ralph-lisa status # Current status
188
61
  ralph-lisa read work.md # Ralph's latest
189
62
  ralph-lisa read review.md # Lisa's latest
190
- ralph-lisa read-review # Alias for read review.md
191
- ralph-lisa read review --round N # Read review from round N
192
63
  ralph-lisa history # Full history
193
- ralph-lisa recap # Context recovery summary
194
- ralph-lisa logs # List transcript logs
195
- ralph-lisa logs cat [name] # View a specific log
196
64
 
197
65
  # Flow control
198
- ralph-lisa step "phase-name" # Enter new phase (requires consensus)
199
- ralph-lisa step --force "phase-name" # Enter new phase (skip consensus check)
200
- ralph-lisa update-task "new direction" # Update task direction mid-session
201
- ralph-lisa archive [name] # Archive session
202
- ralph-lisa clean # Clean session
203
-
204
- # Policy
205
- ralph-lisa policy check <ralph|lisa> # Check submission (hard gate)
206
- ralph-lisa policy check-consensus # Check if both [CONSENSUS]
207
- ralph-lisa policy check-next-step # Comprehensive pre-step check
66
+ ralph-lisa step "phase-name" # Enter new step
67
+ ralph-lisa update-task "new direction" # Change task mid-session
208
68
 
209
69
  # Diagnostics
210
- ralph-lisa doctor # Check all dependencies
211
- ralph-lisa doctor --strict # Exit 1 if any missing (for CI)
212
- ```
213
-
214
- ## Project Structure After Init
215
-
216
- **Full init** (`ralph-lisa init`):
217
- ```
218
- your-project/
219
- ├── CLAUDE.md # Ralph's role (auto-loaded by Claude Code)
220
- ├── CODEX.md # Lisa's role (loaded via .codex/config.toml)
221
- ├── .claude/
222
- │ └── commands/ # Claude slash commands
223
- ├── .codex/
224
- │ ├── config.toml # Codex configuration
225
- │ └── skills/ # Codex skills
226
- └── .dual-agent/ # Session state
227
- ├── turn.txt # Current turn
228
- ├── task.md # Task goal (updated via update-task)
229
- ├── work.md # Ralph's submissions
230
- ├── review.md # Lisa's submissions
231
- └── history.md # Full history
232
- ```
233
-
234
- **Minimal init** (`ralph-lisa init --minimal`):
235
- ```
236
- your-project/
237
- └── .dual-agent/ # Session state only (zero project files)
70
+ ralph-lisa doctor # Check dependencies
238
71
  ```
239
72
 
240
73
  ## Requirements
241
74
 
242
75
  - [Node.js](https://nodejs.org/) >= 18
243
- - [Claude Code](https://claude.ai/code) - for Ralph
244
- - [Codex CLI](https://github.com/openai/codex) - for Lisa
245
-
246
- For auto mode:
247
- - tmux (required)
248
- - fswatch (macOS) or inotify-tools (Linux) — optional, speeds up turn detection; falls back to polling without them
249
-
250
- ## Environment Variables
251
-
252
- | Variable | Default | Description |
253
- |----------|---------|-------------|
254
- | `RL_POLICY_MODE` | `warn` | Policy check mode: `off`, `warn`, `block` |
255
- | `RL_CHECKPOINT_ROUNDS` | `0` (disabled) | Pause for human review every N rounds |
256
- | `RL_LOG_MAX_MB` | `5` | Pane log truncation threshold in MB (min 1) |
76
+ - [Claude Code](https://claude.ai/code) for Ralph
77
+ - [Codex CLI](https://github.com/openai/codex) for Lisa
78
+ - tmux — for auto mode (`brew install tmux` / `apt install tmux`)
257
79
 
258
- ## Ecosystem
80
+ ## Documentation
259
81
 
260
- Part of the [TigerHill](https://github.com/Click-Intelligence-LLC/TigerHill) project family.
82
+ Full documentation on GitHub:
261
83
 
262
- ## See Also
84
+ - **[User Guide](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/docs/en/guide.md)** — Setup, workflows, configuration
85
+ - **[Command Reference](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/docs/en/reference.md)** — All CLI commands
86
+ - **[FAQ](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/docs/en/faq.md)** — Common questions and troubleshooting
87
+ - **[Changelog](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/docs/en/changelog.md)** — Version history
88
+ - **[Design Philosophy](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/CONCEPT.md)** — Why dual-agent works
263
89
 
264
- - [CONCEPT.md](../CONCEPT.md) - Why dual-agent collaboration works
90
+ Other languages: [日本語](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/docs/ja/guide.md) | [中文](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/docs/zh-CN/guide.md)
265
91
 
266
92
  ## License
267
93
 
268
- [MIT](LICENSE)
94
+ [MIT](https://github.com/YW1975/Ralph-Lisa-Loop/blob/main/LICENSE)
package/dist/cli.js CHANGED
@@ -70,9 +70,28 @@ switch (cmd) {
70
70
  case "logs":
71
71
  (0, commands_js_1.cmdLogs)(rest);
72
72
  break;
73
+ case "scope-update":
73
74
  case "update-task":
74
75
  (0, commands_js_1.cmdUpdateTask)(rest);
75
76
  break;
77
+ case "force-turn":
78
+ (0, commands_js_1.cmdForceTurn)(rest);
79
+ break;
80
+ case "remote":
81
+ (0, commands_js_1.cmdRemote)(rest);
82
+ break;
83
+ case "state-dir":
84
+ (0, commands_js_1.cmdStateDir)(rest);
85
+ break;
86
+ case "subtask":
87
+ (0, commands_js_1.cmdSubtask)(rest);
88
+ break;
89
+ case "add-context":
90
+ (0, commands_js_1.cmdAddContext)(rest);
91
+ break;
92
+ case "stop":
93
+ (0, commands_js_1.cmdStop)(rest);
94
+ break;
76
95
  case "help":
77
96
  case "--help":
78
97
  case "-h":
@@ -99,6 +118,9 @@ function showHelp() {
99
118
  console.log(' ralph-lisa start --full-auto "task" Launch without permission prompts');
100
119
  console.log(' ralph-lisa auto "task" Auto mode (tmux)');
101
120
  console.log(' ralph-lisa auto --full-auto "task" Auto mode without permission prompts');
121
+ console.log(" ralph-lisa stop Graceful stop (archive + cleanup)");
122
+ console.log(" ralph-lisa stop --force Force stop (SIGKILL)");
123
+ console.log(" ralph-lisa stop --no-archive Stop without archiving");
102
124
  console.log("");
103
125
  console.log("Turn Control:");
104
126
  console.log(" ralph-lisa check-turn Check whose turn (alias: whose-turn)");
@@ -121,10 +143,16 @@ function showHelp() {
121
143
  console.log(" ralph-lisa history Show full history");
122
144
  console.log("");
123
145
  console.log("Flow Control:");
124
- console.log(' ralph-lisa next-step "name" Enter new step (alias: step)');
125
- console.log(' ralph-lisa update-task "desc" Update task direction');
126
- console.log(" ralph-lisa archive [name] Archive session");
127
- console.log(" ralph-lisa clean Clean session");
146
+ console.log(' ralph-lisa next-step "name" Enter new step (alias: step)');
147
+ console.log(' ralph-lisa next-step "name" --task "t" Enter step with first subtask');
148
+ console.log(' ralph-lisa scope-update "desc" Update task scope (alias: update-task)');
149
+ console.log(' ralph-lisa subtask add "desc" Add subtask to current step');
150
+ console.log(" ralph-lisa subtask done <N> Mark subtask N as complete");
151
+ console.log(" ralph-lisa subtask list List all subtasks");
152
+ console.log(' ralph-lisa add-context "note" Add context note (visible to Lisa)');
153
+ console.log(" ralph-lisa force-turn <agent> Manual turn override (disabled in auto mode)");
154
+ console.log(" ralph-lisa archive [name] Archive session");
155
+ console.log(" ralph-lisa clean Clean session");
128
156
  console.log("");
129
157
  console.log("Policy:");
130
158
  console.log(" ralph-lisa policy check <ralph|lisa> Check submission (hard gate)");
@@ -139,7 +167,15 @@ function showHelp() {
139
167
  console.log(" ralph-lisa logs cat View live pane logs");
140
168
  console.log(" ralph-lisa logs cat <file> View specific log file");
141
169
  console.log("");
170
+ console.log("Remote Access:");
171
+ console.log(" ralph-lisa remote Start ttyd server (default port 7681)");
172
+ console.log(" ralph-lisa remote --port 8080 Custom port");
173
+ console.log(" ralph-lisa remote --auth user:pass Enable basic auth");
174
+ console.log(" ralph-lisa remote --stop Stop ttyd server");
175
+ console.log("");
142
176
  console.log("Diagnostics:");
177
+ console.log(" ralph-lisa state-dir Show state directory resolution");
178
+ console.log(" ralph-lisa state-dir /path Set state directory (tmux env)");
143
179
  console.log(" ralph-lisa doctor Check all dependencies");
144
180
  console.log(" ralph-lisa doctor --strict Exit 1 if any missing (for CI)");
145
181
  }
@@ -9,6 +9,15 @@
9
9
  * tmux session names cannot contain '.' or ':'.
10
10
  */
11
11
  export declare function generateSessionName(projectDir: string): string;
12
+ /**
13
+ * V4-01: Ralph Auto Gate — run test/lint commands before CODE/FIX submission.
14
+ * Config via env vars only (config file deferred to future version):
15
+ * RL_RALPH_GATE=true — enable gate (default: false)
16
+ * RL_GATE_COMMANDS=cmd1|cmd2 — pipe-separated commands
17
+ * RL_GATE_MODE=warn|block — warn (default) or block on failure
18
+ * Gate results are NOT written to work.md (prevents Lisa anchoring).
19
+ */
20
+ export declare function runGate(tag: string): void;
12
21
  export declare function cmdInit(args: string[]): void;
13
22
  export declare function cmdWhoseTurn(): void;
14
23
  export declare function cmdSubmitRalph(args: string[]): void;
@@ -17,14 +26,29 @@ export declare function cmdStatus(): void;
17
26
  export declare function cmdRead(args: string[]): void;
18
27
  export declare function cmdRecap(): void;
19
28
  export declare function cmdStep(args: string[]): void;
29
+ interface Subtask {
30
+ index: number;
31
+ text: string;
32
+ done: boolean;
33
+ line: string;
34
+ }
35
+ export declare function parseSubtasks(taskContent: string): Subtask[];
36
+ export declare function cmdSubtask(args: string[]): void;
20
37
  export declare function cmdHistory(): void;
21
38
  export declare function cmdArchive(args: string[]): void;
22
39
  export declare function cmdClean(): void;
40
+ export declare function cmdStop(args: string[]): void;
23
41
  export declare function cmdUpdateTask(args: string[]): void;
42
+ export declare function cmdForceTurn(args: string[], confirmed?: boolean): void;
43
+ export declare function executeForceTurn(agent: string, dir: string): void;
24
44
  export declare function cmdUninit(): void;
25
45
  export declare function cmdInitProject(args: string[]): void;
26
46
  export declare function cmdStart(args: string[]): void;
27
47
  export declare function cmdAuto(args: string[]): void;
28
48
  export declare function cmdPolicy(args: string[]): void;
29
49
  export declare function cmdLogs(args: string[]): void;
50
+ export declare function cmdRemote(args: string[]): void;
51
+ export declare function cmdStateDir(args: string[]): void;
52
+ export declare function cmdAddContext(args: string[]): void;
30
53
  export declare function cmdDoctor(args: string[]): void;
54
+ export {};