@lnilluv/pi-ralph-loop 0.1.1 → 0.1.4-dev.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.
@@ -17,13 +17,16 @@ jobs:
17
17
  - name: Checkout
18
18
  uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
19
19
 
20
- - name: Setup Node.js 22
20
+ - name: Setup Node.js 22.22.1
21
21
  uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
22
22
  with:
23
- node-version: 22
23
+ node-version: 22.22.1
24
24
 
25
25
  - name: Install dependencies
26
26
  run: npm ci --ignore-scripts
27
27
 
28
+ - name: Test
29
+ run: npm test
30
+
28
31
  - name: Typecheck
29
32
  run: npm run typecheck
@@ -24,15 +24,18 @@ jobs:
24
24
  with:
25
25
  fetch-depth: 0
26
26
 
27
- - name: Setup Node.js 22
27
+ - name: Setup Node.js 24.14.1
28
28
  uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
29
29
  with:
30
- node-version: 22
30
+ node-version: 24.14.1
31
31
  registry-url: https://registry.npmjs.org
32
32
 
33
33
  - name: Install dependencies
34
34
  run: npm ci --ignore-scripts
35
35
 
36
+ - name: Test
37
+ run: npm test
38
+
36
39
  - name: Typecheck
37
40
  run: npm run typecheck
38
41
 
@@ -119,11 +122,11 @@ jobs:
119
122
 
120
123
  - name: Publish (main)
121
124
  if: steps.bump.outputs.should_release == 'true' && github.ref_name == 'main'
122
- run: npx npm@11 publish --access public --provenance
125
+ run: npx -y npm@11.12.1 publish --access public --provenance
123
126
 
124
127
  - name: Publish (dev prerelease)
125
128
  if: steps.bump.outputs.should_release == 'true' && github.ref_name == 'dev'
126
- run: npx npm@11 publish --access public --provenance --tag dev
129
+ run: npx -y npm@11.12.1 publish --access public --provenance --tag dev
127
130
 
128
131
  - name: Commit version bump and tag
129
132
  if: steps.bump.outputs.should_release == 'true'
package/README.md CHANGED
@@ -10,12 +10,14 @@ pi install npm:@lnilluv/pi-ralph-loop
10
10
 
11
11
  ## Quick start
12
12
 
13
+ ### Run an existing task folder
14
+
13
15
  ```md
14
16
  # my-task/RALPH.md
15
17
  ---
16
18
  commands:
17
19
  - name: tests
18
- run: npm test -- --runInBand
20
+ run: npm test
19
21
  timeout: 60
20
22
  ---
21
23
  Fix failing tests using this output:
@@ -23,11 +25,61 @@ Fix failing tests using this output:
23
25
  {{ commands.tests }}
24
26
  ```
25
27
 
26
- Run `/ralph my-task` in pi.
28
+ Run:
29
+
30
+ ```text
31
+ /ralph my-task
32
+ ```
33
+
34
+ ### Draft a loop from natural language
35
+
36
+ ```text
37
+ /ralph reverse engineer this app
38
+ ```
39
+
40
+ pi drafts `./reverse-engineer-this-app/RALPH.md`, shows a short Mission Brief, lets you edit the file, and only starts after you confirm.
41
+
42
+ ### Draft without starting
43
+
44
+ ```text
45
+ /ralph-draft fix flaky auth tests
46
+ ```
47
+
48
+ That saves the draft but does not launch the loop.
49
+
50
+ ### Smart drafting
51
+
52
+ Smart drafting sends the selected repo excerpts from the current repo context to the currently selected active pi model, including models chosen with `/model` or by cycling within `/scoped-models`. It excludes common secret-bearing paths from that context, and non-analysis drafts use the shared `policy:secret-bearing-paths` token so runtime write protection stays aligned with the same policy. It does not switch models automatically. If no active authenticated model is available, drafting falls back to the deterministic path.
27
53
 
28
54
  ## How it works
29
55
 
30
- On each iteration, pi-ralph reads `RALPH.md`, runs the configured commands, injects their output into the prompt through `{{ commands.<name> }}` placeholders, starts a fresh session, sends the prompt, and waits for completion. Failed test output appears in the next iteration, which creates a self-healing loop.
56
+ On each iteration, pi-ralph reads `RALPH.md`, runs the configured commands, injects their output into the prompt through `{{ commands.<name> }}` placeholders, starts a fresh session, sends the prompt, and waits for completion. Failed command output appears in the next iteration, which creates a self-healing loop.
57
+
58
+ ## Smart `/ralph` behavior
59
+
60
+ `/ralph` is path-first:
61
+
62
+ - task folder with `RALPH.md` -> runs it
63
+ - direct `RALPH.md` path -> runs it
64
+ - no args in a folder without `RALPH.md` -> asks what the loop should work on, drafts `./RALPH.md`, then asks before starting
65
+ - natural-language task -> drafts `./<slug>/RALPH.md`, then asks before starting
66
+ - unresolved path-like input like `foo/bar` or `notes.md` -> offers recovery choices and normalizes missing markdown targets to `./<folder>/RALPH.md`
67
+ - arbitrary markdown files like `README.md` -> rejected instead of auto-run
68
+
69
+ ### Explicit flags
70
+
71
+ Use these when you want to skip heuristics:
72
+
73
+ ```text
74
+ /ralph --path my-task
75
+ /ralph --task "reverse engineer the billing flow"
76
+ /ralph-draft --path my-task
77
+ /ralph-draft --task "fix flaky auth tests"
78
+ ```
79
+
80
+ ### Interactive review
81
+
82
+ Draft flows require an interactive UI because the extension uses a Mission Brief and editor dialog before saving or starting. In non-interactive contexts, pass an existing task folder or `RALPH.md` path instead.
31
83
 
32
84
  ## RALPH.md format
33
85
 
@@ -35,12 +87,14 @@ On each iteration, pi-ralph reads `RALPH.md`, runs the configured commands, inje
35
87
  ---
36
88
  commands:
37
89
  - name: tests
38
- run: npm test -- --runInBand
90
+ run: npm test
39
91
  timeout: 90
40
92
  - name: lint
41
93
  run: npm run lint
42
94
  timeout: 60
43
95
  max_iterations: 25
96
+ timeout: 300
97
+ completion_promise: "DONE"
44
98
  guardrails:
45
99
  block_commands:
46
100
  - "rm\\s+-rf\\s+/"
@@ -51,12 +105,15 @@ guardrails:
51
105
  ---
52
106
  You are fixing flaky tests in the auth module.
53
107
 
108
+ <!-- This comment is stripped before sending to the agent -->
109
+
54
110
  Latest test output:
55
111
  {{ commands.tests }}
56
112
 
57
113
  Latest lint output:
58
114
  {{ commands.lint }}
59
115
 
116
+ Iteration {{ ralph.iteration }} of {{ ralph.name }}.
60
117
  Apply the smallest safe fix and explain why it works.
61
118
  ```
62
119
 
@@ -67,19 +124,32 @@ Apply the smallest safe fix and explain why it works.
67
124
  | `commands[].run` | string | required | Shell command |
68
125
  | `commands[].timeout` | number | `60` | Seconds before kill |
69
126
  | `max_iterations` | number | `50` | Stop after N iterations |
127
+ | `timeout` | number | `300` | Per-iteration timeout in seconds; stops the loop if the agent is stuck |
128
+ | `completion_promise` | string | — | Agent signals completion by sending `<promise>DONE</promise>`; loop breaks on match |
70
129
  | `guardrails.block_commands` | string[] | `[]` | Regex patterns to block in bash |
71
- | `guardrails.protected_files` | string[] | `[]` | Glob patterns to block writes |
130
+ | `guardrails.protected_files` | string[] | `[]` | Glob patterns, or the shared `policy:secret-bearing-paths` token, enforced on `write`/`edit` tool calls |
131
+
132
+ ### Placeholders
133
+
134
+ | Placeholder | Description |
135
+ |-------------|-------------|
136
+ | `{{ commands.<name> }}` | Output from the named command |
137
+ | `{{ ralph.iteration }}` | Current 1-based iteration number |
138
+ | `{{ ralph.name }}` | Directory name containing the `RALPH.md` |
139
+
140
+ HTML comments (`<!-- ... -->`) are stripped from the prompt body after placeholder resolution, so you can annotate your `RALPH.md` freely. Generated drafts also escape literal `<!--` and `-->` in the visible task line, and the leading metadata comment is URL-encoded so task text can safely contain comment-like sequences.
72
141
 
73
142
  ## Commands
74
143
 
75
- - `/ralph <path>`: Start the loop from a `RALPH.md` file or directory.
76
- - `/ralph-stop`: Request a graceful stop after the current iteration.
144
+ - `/ralph [path-or-task]` - Start Ralph from a task folder or `RALPH.md`, or draft a new loop from natural language.
145
+ - `/ralph-draft [path-or-task]` - Draft or edit a Ralph task without starting it.
146
+ - `/ralph-stop` - Request a graceful stop after the current iteration.
77
147
 
78
148
  ## Pi-only features
79
149
 
80
150
  ### Guardrails
81
151
 
82
- `guardrails.block_commands` and `guardrails.protected_files` come from RALPH frontmatter. The extension enforces them in the `tool_call` hook. Matching bash commands are blocked, and writes/edits to protected file globs are denied.
152
+ `guardrails.block_commands` and `guardrails.protected_files` come from RALPH frontmatter. The extension enforces them in the `tool_call` hook — but only for sessions created by the loop, so they don't leak into unrelated conversations. Matching bash commands are blocked, and `write`/`edit` tool calls targeting protected file globs or the shared secret-path policy token are denied.
83
153
 
84
154
  ### Cross-iteration memory
85
155
 
@@ -89,17 +159,33 @@ After each iteration, the extension stores a short summary with iteration number
89
159
 
90
160
  In the `tool_result` hook, bash outputs are scanned for failure patterns. After three or more failures in the same iteration, the extension appends a stop-and-think warning to push root-cause analysis before another retry.
91
161
 
162
+ ### Completion promise
163
+
164
+ When `completion_promise` is set (for example, `"DONE"`), the loop scans the agent's messages for `<promise>DONE</promise>` after each iteration. If found, the loop stops early.
165
+
166
+ ### Iteration timeout
167
+
168
+ Each iteration has a configurable timeout (default 300 seconds). If the agent is stuck and doesn't become idle within the timeout, the loop stops with a warning.
169
+
170
+ ### Input validation
171
+
172
+ The extension validates `RALPH.md` frontmatter before starting and on each re-parse: `max_iterations` must be a positive integer, `timeout` must be positive, `block_commands` regexes must compile, and commands must have non-empty names and run strings with positive timeouts.
173
+
92
174
  ## Comparison table
93
175
 
94
176
  | Feature | **@lnilluv/pi-ralph-loop** | pi-ralph | pi-ralph-wiggum | ralphi | ralphify |
95
- |---------|------------------------|----------------------|-----------------|--------|----------|
177
+ |---------|----------------------------|----------|-----------------|--------|----------|
96
178
  | Command output injection | ✓ | ✗ | ✗ | ✗ | ✓ |
97
179
  | Fresh-context sessions | ✓ | ✓ | ✗ | ✓ | ✓ |
98
180
  | Mid-turn guardrails | ✓ | ✗ | ✗ | ✗ | ✗ |
99
181
  | Cross-iteration memory | ✓ | ✗ | ✗ | ✗ | ✗ |
100
182
  | Mid-turn steering | ✓ | ✗ | ✗ | ✗ | ✗ |
101
- | Live prompt editing | ✓ | ✗ | ✗ | ✗ | |
102
- | Setup required | RALPH.md | config | RALPH.md | PRD pipeline | RALPH.md |
183
+ | Guided task drafting | ✓ | ✗ | ✗ | ✗ | separate scaffold |
184
+ | Completion promise | | | | | |
185
+ | Iteration timeout | ✓ | ✗ | ✗ | ✗ | ✗ |
186
+ | Session-scoped hooks | ✓ | ✗ | ✗ | ✗ | ✗ |
187
+ | Input validation | ✓ | ✗ | ✗ | ✗ | ✗ |
188
+ | Setup required | task folder or draft flow | config | RALPH.md | PRD pipeline | scaffold + RALPH.md |
103
189
 
104
190
  ## License
105
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lnilluv/pi-ralph-loop",
3
- "version": "0.1.1",
3
+ "version": "0.1.4-dev.0",
4
4
  "description": "Pi-native ralph loop — autonomous coding iterations with mid-turn supervision",
5
5
  "type": "module",
6
6
  "pi": {
@@ -8,7 +8,11 @@
8
8
  "./src/index.ts"
9
9
  ]
10
10
  },
11
+ "engines": {
12
+ "node": "22.22.1 || 24.14.1"
13
+ },
11
14
  "scripts": {
15
+ "test": "node --test --experimental-strip-types $(find tests -type f -name '*.ts' | sort)",
12
16
  "typecheck": "tsc --noEmit"
13
17
  },
14
18
  "repository": {
@@ -16,8 +20,9 @@
16
20
  "url": "git+https://github.com/lnilluv/pi-ralph-loop.git"
17
21
  },
18
22
  "dependencies": {
19
- "yaml": "2.8.3",
20
- "minimatch": "10.2.3"
23
+ "@mariozechner/pi-ai": "0.66.1",
24
+ "minimatch": "10.2.3",
25
+ "yaml": "2.8.3"
21
26
  },
22
27
  "peerDependencies": {
23
28
  "@mariozechner/pi-coding-agent": "*"
@@ -28,5 +33,9 @@
28
33
  "autonomous",
29
34
  "loop"
30
35
  ],
31
- "license": "MIT"
36
+ "license": "MIT",
37
+ "devDependencies": {
38
+ "@types/node": "25.6.0",
39
+ "typescript": "6.0.2"
40
+ }
32
41
  }