@open-tomato/rafa 0.7.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,59 @@
1
+ rafa
2
+ Copyright 2026 Marcos Tomatti and the open-tomato contributors
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ This product builds on the following works. Each is named here because
7
+ rafa would not exist in this shape without it.
8
+
9
+ 1. template-agentic-research
10
+ https://github.com/marcostomatti/template-agentic-research
11
+ Copyright 2026 Marcos Tomatti. Licensed under the Apache License,
12
+ Version 2.0.
13
+ The loop implementation (the task runner, the plan and report
14
+ parsers, the effort collection and the tracker) was imported from
15
+ its `tools/ralph` directory and has been developed here since.
16
+
17
+ 2. Open Tomato
18
+ https://github.com/open-tomato
19
+ Copyright Marcos Tomatti and the open-tomato contributors. Licensed
20
+ under the MIT License.
21
+ rafa's first loop, the Tracker port's shape, the CLI event format and
22
+ the hive-learning design that rafa's learning port follows come from
23
+ projects of that organisation, most of which are not public yet.
24
+
25
+ 3. everything-claude-code, the `continuous-learning-v2` skill
26
+ https://github.com/affaan-m/everything-claude-code
27
+ Copyright (c) 2026 Affaan Mustafa. Licensed under the MIT License.
28
+ rafa's instinct record (trigger, action, confidence, evidence,
29
+ project and user scope) is adapted from that skill's instinct model.
30
+ No source file of that project is redistributed in this package.
31
+
32
+ The MIT License, under which works 2 and 3 are made available:
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining
35
+ a copy of this software and associated documentation files (the
36
+ "Software"), to deal in the Software without restriction, including
37
+ without limitation the rights to use, copy, modify, merge, publish,
38
+ distribute, sublicense, and/or sell copies of the Software, and to
39
+ permit persons to whom the Software is furnished to do so, subject to
40
+ the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be
43
+ included in all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
49
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
50
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
51
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52
+
53
+ The loop itself, one fresh agent session per step over a plan kept on
54
+ disk, is the "Ralph" technique described by Geoffrey Huntley
55
+ (https://ghuntley.com/ralph/). It is an idea and carries no licence;
56
+ it is named here because the project is named after it.
57
+
58
+ rafa drives Claude Code, a product of Anthropic, PBC. rafa is not
59
+ affiliated with or endorsed by Anthropic.
package/README.md ADDED
@@ -0,0 +1,362 @@
1
+ # rafa
2
+
3
+ Run a plan through the ralph loop: one Claude Code session per task, one
4
+ commit per task, then a pull request and a wait for CI, from one
5
+ terminal.
6
+
7
+ What guides it:
8
+
9
+ - **Tools before judgement.** Whatever code can decide, code decides: the
10
+ next task, the branch, the version, whether a pull request is green.
11
+ The agent is asked for the work itself and little else, which leaves
12
+ less to chance.
13
+ - **Repeatable wherever it can be.** The steps around the agent are
14
+ scripts with tests, each run once and in a fixed order, so everything
15
+ that is not the agent's own writing comes out the same on a second
16
+ run, on another machine and after a resume.
17
+ - **Your tools, not ours.** rafa drives what you already use (git, the
18
+ GitHub CLI, GitHub Issues) instead of rebuilding it, and keeps each of
19
+ those behind a small interface. Swapping one is meant to be an add-on,
20
+ not a migration: other issue trackers are on the way, starting with
21
+ Linear, and support for coding agents beyond Claude Code is being
22
+ specified.
23
+
24
+ > **Alpha.** rafa is built with rafa, in the open, and it is not
25
+ > finished: commands, files and defaults still change between versions,
26
+ > and the [Roadmap](#roadmap) below says what is and is not there yet.
27
+ > Feedback and bug reports are welcome at
28
+ > [github.com/open-tomato/rafa/issues](https://github.com/open-tomato/rafa/issues/new/choose);
29
+ > the order things are being built in is the pinned
30
+ > [Roadmap issue](https://github.com/open-tomato/rafa/issues/31).
31
+
32
+ ## Before you run it
33
+
34
+ Read this once; rafa also says it the first time you start a run.
35
+
36
+ - **Every Claude Code session rafa starts runs with
37
+ `--dangerously-skip-permissions`.** That is what lets a plan run
38
+ unattended, and it means a task can edit, delete and run anything your
39
+ user account can, without asking. There is no switch for it yet.
40
+ - **A run acts under your accounts.** It commits, pushes its branch,
41
+ opens a pull request with `gh`, waits for CI, and may file the
42
+ blockers and unrelated bugs it meets as issues on the project's
43
+ tracker.
44
+ - **It spends your Claude usage**, one session per task plus the plan
45
+ and the wrap-up. `budget=` on a task caps that task.
46
+ - So run it in a repository, on a branch and on a machine where all of
47
+ that is acceptable: a container or a disposable checkout is a good
48
+ first home. Nothing here is a sandbox.
49
+
50
+ On a terminal, `rafa loop start` and `rafa plan create` print these
51
+ notices and ask `Continue? [y] yes [d] yes, and do not show this again
52
+ [N] cancel`. Answering `d` records it in `~/.rafa/notices.json`
53
+ (`{"dismissed": ["alpha", "danger"]}`); delete the file to see them
54
+ again. Without a terminal they are printed as warnings and the run goes
55
+ on.
56
+
57
+ ## Install
58
+
59
+ The package is `@open-tomato/rafa` on npm (`publishConfig` names
60
+ `https://registry.npmjs.org/` for the scope as well as in general, so a
61
+ machine that maps `@open-tomato` to another registry still publishes
62
+ there, and `npm publish` builds first through `prepack`). It installs globally under either package manager:
63
+
64
+ ```bash
65
+ npm i -g @open-tomato/rafa
66
+ ```
67
+
68
+ ```bash
69
+ bun add -g @open-tomato/rafa
70
+ ```
71
+
72
+ Either one puts the `rafa` binary on `PATH`. The package declares no
73
+ runtime dependency — `dependencies`, `peerDependencies` and
74
+ `optionalDependencies` are all absent — so the install resolves nothing
75
+ beyond the package itself. The binary and every export run under bun,
76
+ which `engines` names: see [Runtime](#runtime) below.
77
+
78
+ ## How to use it
79
+
80
+ The cycle is always the same five steps, and most commands end by naming
81
+ the next one, so you rarely have to remember it.
82
+
83
+ 1. **Set the project up, once.** In the repository you want to work on:
84
+
85
+ ```bash
86
+ rafa init
87
+ rafa doctor
88
+ ```
89
+
90
+ `init` writes `.rafa/config.yaml`, keeps `.rafa/` out of git, and on a
91
+ GitHub repository offers to set up the board (labels, the spec issue
92
+ template, a pinned Roadmap issue). `doctor` runs every check
93
+ `loop start` runs before its first session, and starts nothing: the
94
+ prerequisites your config and the plan name, `gh` and its login when
95
+ the repository is on GitHub, and the install itself.
96
+
97
+ 2. **Write a spec.** A spec says what you get, where things stand, the
98
+ design, what can go wrong, the tasks the plan must carry, and how you
99
+ will know it is done. Either a file, `.rafa/specs/my-feature.md`, or
100
+ an issue opened from the "Spec" template and labelled `spec:ready`.
101
+ [docs/specs-and-roadmap.md](docs/specs-and-roadmap.md) has the
102
+ template and a prompt for drafting one.
103
+
104
+ 3. **Turn the spec into a plan.** One Claude Code session reads the spec
105
+ and the repository and writes a checklist the loop can parse:
106
+
107
+ ```bash
108
+ rafa plan create --spec=.rafa/specs/my-feature.md
109
+ rafa plan create --issue=42 # the spec is issue #42's body
110
+ rafa plan create --next # the first undone line of the Roadmap issue
111
+ rafa plan show my-feature # read it before you run it
112
+ ```
113
+
114
+ The plan lands in `.rafa/plans/PLAN-<stub>.md`, with a
115
+ `PREREQUISITES-<stub>.md` beside it when something has to be true
116
+ before the run. Read both. A plan is plain markdown: edit a task, drop
117
+ one, add one.
118
+
119
+ 4. **Run it.**
120
+
121
+ ```bash
122
+ rafa loop start --plan=.rafa/plans/PLAN-my-feature.md
123
+ ```
124
+
125
+ On `main` it offers to create `feat/<stub>` from the latest base and
126
+ run there. Then, per task: one Claude Code session, the task's report
127
+ stored, one commit. A task that reports `blocked` is marked and the
128
+ run stops with the reason; fix what it names and start again, and the
129
+ blocked task goes first. After the last task a wrap-up session syncs
130
+ with the base, bumps the version and the changelog when the project
131
+ has them, pushes, opens the pull request and waits for CI, spending
132
+ repair sessions on a red one.
133
+
134
+ From another terminal: `rafa loop status`, `rafa loop pause` (after the
135
+ running task), `rafa loop stop` (now).
136
+
137
+ 5. **Land it and look at what it cost.**
138
+
139
+ ```bash
140
+ rafa pr current # number, title, checks, URL
141
+ rafa pr triage # why is it red, and is the fix simple
142
+ rafa pr merge # asks y/N, merges, switches to the base, pulls, deletes both branches
143
+ rafa release tag # tag the merged version
144
+ rafa effort collect && rafa effort report
145
+ ```
146
+
147
+ Then step 2 again, or `rafa plan create --next`.
148
+
149
+ ### Which agents and skills are involved
150
+
151
+ A task line may end with a declaration, for example
152
+ `{agent=tdd-guide effort=medium}`. The planner writes it; you can change
153
+ it.
154
+
155
+ - `agent=` routes the task to a Claude Code subagent. The planner picks
156
+ by the task's SHAPE: implementation, tests, prose, a red build, a
157
+ review. This repository's own roster is in `.claude/agents/` and its
158
+ routing table in `context/workflow.md`; yours is whatever your project
159
+ holds.
160
+ - Sessions load the project's agents and skills only
161
+ (`--setting-sources project,local`), which keeps each turn smaller and
162
+ makes a run behave the same on every machine. So an agent that exists
163
+ only in `~/.claude/agents` is invisible to a run: `rafa agent list`
164
+ shows what a run sees, `rafa agent vendor <name>` copies one in, and
165
+ `loop start` refuses a plan that names an agent it cannot resolve,
166
+ before any session is paid for.
167
+ - The plan format itself is a skill, `dev-planner`, shipped inside the
168
+ package and used when the project has none of its own.
169
+ - `rafa skill check .claude/skills --project=.` refuses a skill an agent
170
+ could not follow (a path that does not resolve, a missing field)
171
+ before it costs a task.
172
+ - `model=`, `effort=`, `tools=` and `budget=` on a task line set the
173
+ session's model, reasoning effort, tool list and spending cap when no
174
+ agent decides them.
175
+
176
+ Every command has help at three levels (`rafa --help`,
177
+ `rafa loop --help`, `rafa loop start --help`), and
178
+ `rafa describe --output=json` is the same roster for a tool or an agent.
179
+
180
+ ## Specs, issues and the roadmap
181
+
182
+ You can plan from a local file and never touch a board. When you want
183
+ the queue, the specs and their history in one shared place, rafa works
184
+ from GitHub Issues:
185
+
186
+ - **A spec is an issue**, opened from a template with six headings (what
187
+ you get, starting position, design, what can go wrong, tasks,
188
+ definition of done). `rafa init --board` sets up the template, the
189
+ labels and a pinned "Roadmap" issue.
190
+ - **The roadmap is one ordered task list** in that pinned issue.
191
+ `rafa plan create --next` takes the first line that is neither done
192
+ nor already being worked on, and stops rather than skipping ahead when
193
+ that issue is not ready. `rafa plan create --issue=<n>` plans from one
194
+ issue directly.
195
+ - **A few labels carry the state**: `type:spec`, `spec:ready` (a person
196
+ says a plan may be made from it), `spec:needs-work` (details pending,
197
+ or the planner's review found gaps and listed them), and `type:bug`
198
+ with `needs-triage` for what a run files on its own.
199
+ - **Safety, in short.** An issue's text ends up in an agent's prompt, so
200
+ rafa plans only from an issue whose author can write to the
201
+ repository, that a maintainer has labelled `spec:ready`, that is
202
+ complete, and that holds no local path or token. Comments are never
203
+ read into a plan, rafa never applies `spec:ready` by itself, and
204
+ machine-specific failures a run meets stay off your public tracker.
205
+ - **Other trackers.** GitHub Issues is what works today. Linear support
206
+ is being ported from the project rafa grew out of, as an optional
207
+ add-on in a later version. For anything else, open or upvote a request
208
+ in [the issues](https://github.com/open-tomato/rafa/issues).
209
+
210
+ The full guide, with the spec template explained, a prompt for drafting
211
+ a spec and every gate in order, is
212
+ [docs/specs-and-roadmap.md](docs/specs-and-roadmap.md).
213
+
214
+ ## From a checkout
215
+
216
+ To install dependencies:
217
+
218
+ ```bash
219
+ bun install
220
+ ```
221
+
222
+ To run the loop from a checkout (no arguments prints the help):
223
+
224
+ ```bash
225
+ bun src/rafa.ts loop start --plan=<file>
226
+ ```
227
+
228
+ Every command but `init`, the help and `describe` runs inside a rafa
229
+ project: the nearest directory at or above the working directory holding
230
+ `.rafa/config.yaml`. Outside one it prints the `rafa init` hint and exits
231
+ 1; `bun src/rafa.ts init --yes` sets up the git toplevel as one.
232
+
233
+ `bun run build` writes `dist/`, which the `rafa` bin and the package's
234
+ `exports` point at.
235
+
236
+ This project was created using `bun init` in bun v1.3.14. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
237
+
238
+ ## Running rafa from a snapshot
239
+
240
+ Run the global `rafa` from a copy of the build, never from this
241
+ checkout's `dist/`: `bun run build` opens with `rm -rf dist`, so a loop
242
+ running from `dist/` has its runner replaced by the first task that
243
+ builds. `bun run snapshot` in this checkout, or `rafa self-update` run
244
+ inside it, builds, copies `dist/` into `~/.rafa/runtime/<version>/` with
245
+ the version from `package.json`, points `~/.rafa/bin/rafa` at the copied
246
+ `cli.js`, and prints the path the link resolves to, exiting 0. Both
247
+ install the same way (`src/runtime/install.ts`). The bin is not in
248
+ `~/.bun/bin`, where `bun link` in this checkout re-points `rafa` at the
249
+ checkout's `dist/` with no message, so put `~/.rafa/bin` on `PATH` ahead
250
+ of `~/.bun/bin`; both warn when it is not, and `rafa doctor` checks it.
251
+ Both exit 1 before building anything while a plan tracker in `plan.dir`
252
+ (`.rafa/plans` unless `.rafa/config.yaml` names another) still holds an
253
+ open or blocked task, and name every such tracker. `rafa self-update`
254
+ runs only inside a project, so `rafa init` the checkout first. They exit
255
+ 2 when they could not run: a `package.json` that is not rafa's or cannot
256
+ be read, a config or tracker they could not read, or a build, copy or
257
+ link that failed.
258
+
259
+ A version is installed once. Both also exit 1, before building, when
260
+ `~/.rafa/runtime/<version>/` is already there, naming that directory and
261
+ the version `package.json` gave: a loop may be running from it, and a
262
+ second build under the same version would swap its runner. Raise the
263
+ version to install beside it. `bun run snapshot --force` and
264
+ `rafa self-update --force` install over it anyway, replacing the
265
+ directory whole, so nothing the old build left is kept: the replacement
266
+ is copied beside the directory and renamed into its place, and only then
267
+ is the old one removed, so no reader meets a half-replaced runtime. The
268
+ link lands by a rename too, so a shell meets the old link or the new one
269
+ and never none.
270
+
271
+ ## Runtime
272
+
273
+ The build targets bun, and `engines` names `bun` alone: there is no
274
+ `engines.node`, because no node version runs the binary. The package
275
+ root, `./cli` and `./store` import `bun:sqlite`, which node's ESM loader
276
+ refuses before any module code runs, so only `./plan` and `./ports` load
277
+ under node at all. `module` points at `./dist/index.js`, the same build
278
+ the root of `exports` names. The package ships no type declarations:
279
+ `exports` names no `types`, and a TypeScript consumer gets TS7016 under
280
+ `strict`.
281
+
282
+ ## Roadmap
283
+
284
+ What rafa does today and what is planned, in the order it is being
285
+ built. A box is ticked by the change that finishes the feature.
286
+
287
+ - [x] Run a plan task by task: one Claude Code session per task, one
288
+ commit per task, then a pull request and a wait for CI
289
+ - [x] Plans that carry their own background, so each task reads only the
290
+ part of the plan it needs
291
+ - [x] Every task reports back what it did, what it found and what
292
+ blocked it, and rafa keeps the record
293
+ - [x] See what each plan cost: sessions, tokens and commits per plan
294
+ - [x] Install once, set up any project with `rafa init`
295
+ - [x] Checks before a run: a missing tool or key stops the run with its
296
+ name, before any session is paid for
297
+ - [x] A spending cap per task
298
+ - [x] One consistent command line, with help at every level that people
299
+ and agents can both read
300
+ - [x] Stop, pause, resume and check on a running plan
301
+ - [x] Blockers and unrelated bugs found along the way are filed as
302
+ issues, once each
303
+ - [x] rafa can safely work on its own code and update itself
304
+ - [x] Usable as a library inside other services, not only as a command
305
+ - [x] A health check for skills: one format, and a checker that refuses
306
+ a broken skill before an agent can follow it
307
+ - [x] The agents a plan needs are checked before the run, and copied
308
+ into the project with one command
309
+ - [x] Plan straight from the issue board, or from whatever is next on the roadmap
310
+ - [x] Review, merge and clean up pull requests from the command line
311
+ - [x] A failing pull request is diagnosed, and fixed when the fix is simple
312
+ - [x] A version bump and a changelog entry with every pull request
313
+ - [x] Start a plan from the main branch and rafa makes the branch for you
314
+ - [ ] The right skills reach the right task, chosen when the plan is
315
+ written
316
+ - [ ] Know which skills earn their place and which are ignored
317
+ - [ ] rafa learns from its own runs: what one task works out is handed
318
+ to the tasks that need it later
319
+ - [ ] Skills and lessons shared across projects and machines
320
+ - [ ] Work on several issues or specs at the same time
321
+ - [ ] Add-ons: install a tracker, an output or a set of skills (Linear,
322
+ Obsidian and others) without changing rafa
323
+ - [ ] A live terminal dashboard
324
+
325
+ ## Attribution
326
+
327
+ rafa stands on other people's work and on earlier work of ours.
328
+ [NOTICE](NOTICE) carries the licences; this is the story.
329
+
330
+ - **The Ralph technique.** Running an agent in a plain loop, one fresh
331
+ session per step over a plan kept on disk, is the "Ralph" technique
332
+ described by Geoffrey Huntley in
333
+ [Ralph Wiggum as a "software engineer"](https://ghuntley.com/ralph/).
334
+ The name "ralph loop" in this project is a nod to it. What rafa adds
335
+ around the loop (plans with declared routing, structured task reports,
336
+ preflight, effort records, the pull request and CI stage) is ours; the
337
+ idea of the loop is not.
338
+ - **Open Tomato.** rafa's first loop, its issue-tracker port, its CLI
339
+ event format and the learning design below come from projects in the
340
+ [open-tomato](https://github.com/open-tomato) organisation. Most of
341
+ them are not public yet; this section will link the specific
342
+ repositories as they are published.
343
+ - **Loop implementation.** The code rafa started from was imported from
344
+ [`marcostomatti/template-agentic-research`](https://github.com/marcostomatti/template-agentic-research)
345
+ (Apache-2.0), where the loop had grown its plan and report parsers,
346
+ effort collection and tracker.
347
+ - **Instinct model.** The instinct record (trigger, action, confidence,
348
+ evidence, scope) is adapted from the `continuous-learning-v2` skill of
349
+ [`affaan-m/everything-claude-code`](https://github.com/affaan-m/everything-claude-code)
350
+ by Affaan Mustafa (MIT).
351
+ - **Shared learning (coming).** The design for merging what separate
352
+ runs learn (one record per lesson, a rule for conflicting lessons,
353
+ promotion on recurrence) follows Open Tomato's hive-learning design.
354
+ In rafa it is partly built: lessons are recorded per project today, and
355
+ sharing them across runs, projects and machines is on the
356
+ [Roadmap](#roadmap) and not available yet.
357
+
358
+ ## License
359
+
360
+ Apache-2.0; see [LICENSE](LICENSE). [NOTICE](NOTICE) names the works
361
+ rafa builds on and their licences. rafa drives Claude Code and is not
362
+ affiliated with or endorsed by Anthropic.
package/dist/PROMPT.md ADDED
@@ -0,0 +1,28 @@
1
+ We shared as much of the plan as this run is configured to share — the whole plan, your task's stage, or your task line with the plan's context — so you know the context of the overall project and how your scoped task fits into it. Deliver the scoped task at the scope its text states: don't quietly narrow, widen or transform it. Nobody can answer a question while this session runs, so finish the whole task before you write `status: done`; if part of it genuinely cannot be done, do the rest, write `status: blocked`, and name what is missing and why under `blockers`.
2
+
3
+ Do not stage or commit anything: the loop owns staging and committing, and once this session exits cleanly it runs `git add -A` and commits your work under a subject derived from the task text. Leave your changes in the working tree, and leave them in a state the pre-commit hooks accept — a refused hook blocks the task and stops the loop.
4
+
5
+ End your final message with exactly one `rafa:report` block shaped like the example below, and write nothing after it: the loop stores what it reads there, and a message without the block stores none of your findings. Write all seven fields, `status`, `feedback`, `findings`, `skills_used`, `blockers`, `out_of_scope_bugs` and `changes`, and write a list with nothing in it as `[]` rather than leaving its field out. `status` is `done` or `blocked`. `feedback` says what was done and how it went. `findings` is a list with one entry per distinct observation, never several merged into one; a finding's `kind` is one of `gotcha`, `pattern`, `location` or `skill-suggestion`, its `signal` is `loud` when it surfaced as a failure or `silent` when something passed while wrong, and its `artifact`, when there is one, is the exact string a recurrence would match on, such as an error message. `skills_used` names each skill you invoked. `blockers` lists what stopped the task, each entry a `what` and, when there is one, an `artifact`, `out_of_scope_bugs` the bugs you saw outside it, each bug with `security` set to `true` or `false`, and `changes` is the changelog for your diff, each entry holding the required fields `level` (one of patch, minor, major, none) and `summary` (a quoted line the user would understand), plus optional `area` (the changelog section). Write those closed-set words and `security` bare, as the example does, and double-quote every other value on one line: an unquoted value that opens with a backtick, `@`, `%` or `[` makes the whole block unreadable, and a `#` after a space silently cuts a value short.
6
+
7
+ ```rafa:report
8
+ status: done
9
+ feedback: |
10
+ <what was done and how it went, one block>
11
+ findings:
12
+ - trigger: "when running bun test under a fresh worktree"
13
+ kind: gotcha
14
+ what: "node_modules is absent after fork"
15
+ cause: "worktree creation does not run bun install"
16
+ resolution: "run bun install before the first test"
17
+ artifact: "Cannot find package"
18
+ signal: loud
19
+ skills_used: ["git-workflow"]
20
+ blockers: []
21
+ out_of_scope_bugs:
22
+ - what: "..."
23
+ artifact: "..."
24
+ security: false
25
+ changes:
26
+ - level: patch
27
+ summary: "the loop waits for the running task's commit"
28
+ ```