@beremaran/ralphie 0.0.0-stage → 0.2.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +832 -0
  2. package/LICENSE +21 -0
  3. package/README.md +53 -2
  4. package/dist/ralphie.js +33691 -0
  5. package/docs/README.md +71 -0
  6. package/docs/architecture.md +159 -0
  7. package/docs/cli-reference.md +126 -0
  8. package/docs/configuration.md +269 -0
  9. package/docs/development.md +248 -0
  10. package/docs/getting-started.md +134 -0
  11. package/docs/operations-and-recovery.md +328 -0
  12. package/docs/safety.md +189 -0
  13. package/docs/workflows.md +411 -0
  14. package/package.json +83 -3
  15. package/vendor/mattpocock-skills/LICENSE +21 -0
  16. package/vendor/mattpocock-skills/code-review/SKILL.md +87 -0
  17. package/vendor/mattpocock-skills/code-review/agents/openai.yaml +3 -0
  18. package/vendor/mattpocock-skills/codebase-design/DEEPENING.md +37 -0
  19. package/vendor/mattpocock-skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  20. package/vendor/mattpocock-skills/codebase-design/SKILL.md +114 -0
  21. package/vendor/mattpocock-skills/codebase-design/agents/openai.yaml +3 -0
  22. package/vendor/mattpocock-skills/diagnosing-bugs/SKILL.md +138 -0
  23. package/vendor/mattpocock-skills/diagnosing-bugs/agents/openai.yaml +3 -0
  24. package/vendor/mattpocock-skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  25. package/vendor/mattpocock-skills/implement/SKILL.md +15 -0
  26. package/vendor/mattpocock-skills/implement/agents/openai.yaml +5 -0
  27. package/vendor/mattpocock-skills/lock.json +37 -0
  28. package/vendor/mattpocock-skills/tdd/SKILL.md +38 -0
  29. package/vendor/mattpocock-skills/tdd/agents/openai.yaml +3 -0
  30. package/vendor/mattpocock-skills/tdd/mocking.md +59 -0
  31. package/vendor/mattpocock-skills/tdd/tests.md +77 -0
  32. package/vendor/mattpocock-skills/to-tickets/SKILL.md +105 -0
  33. package/vendor/mattpocock-skills/to-tickets/agents/openai.yaml +5 -0
  34. package/vendor/mattpocock-skills/triage/AGENT-BRIEF.md +207 -0
  35. package/vendor/mattpocock-skills/triage/OUT-OF-SCOPE.md +105 -0
  36. package/vendor/mattpocock-skills/triage/SKILL.md +112 -0
  37. package/vendor/mattpocock-skills/triage/agents/openai.yaml +5 -0
@@ -0,0 +1,248 @@
1
+ # Development
2
+
3
+ This page is for contributors and maintainers working on the Ralphie checkout.
4
+ It is the authoritative home for local setup, validation commands, optional
5
+ registry checks, and contribution expectations. Return to the [documentation
6
+ index](README.md) for the other documentation paths.
7
+
8
+ ## Local setup and checks
9
+
10
+ Install dependencies and run the complete local gate:
11
+
12
+ ```bash
13
+ bun install --frozen-lockfile
14
+ bun run check
15
+ ```
16
+
17
+ `bun run check` runs, in this order: `format:check`, `lint`, `typecheck`, the
18
+ source-reachability audit, `test`, and `build`. CI runs the same steps except
19
+ the source-reachability audit, which only `bun run check` runs, so run it
20
+ locally.
21
+
22
+ Useful individual commands:
23
+
24
+ | Command | Purpose |
25
+ | --- | --- |
26
+ | `bun run test` | Run the full Bun test suite, including offline unit tests, local integration/PTY coverage, and in-memory GitHub clients and stubs. The suite does not require live GitHub, model-provider, or registry credentials; some tests use temporary checkouts and local subprocesses. |
27
+ | `bun run typecheck` | Type-check without emitting JavaScript. |
28
+ | `bun run format` | Format the repository with Biome. |
29
+ | `bun run format:check` | Verify formatting without modifying files. |
30
+ | `bun run lint` | Check TypeScript cognitive complexity (maximum 12). |
31
+ | `bun run build` | Build the publishable package bundle at `dist/ralphie.js` (local builds use the `local` commit sentinel). |
32
+ | `bun run build -- --commit-sha <sha> [--version <version>]` | Build with explicit release metadata. |
33
+ | `bun run build:package` | Same as `bun run build`; the package bundle at `dist/ralphie.js`. |
34
+ | `bun run package:check` | Pack, inspect, install, and run the local package in isolated temporary directories. |
35
+ | `bun run package:inspect` | Inspect the local package-manager pack file list without installing it. |
36
+ | `bun run source:audit` | Run the deterministic, offline source/module/export reachability audit as sorted JSON. |
37
+ | `bun run skills:sync [ref]` | Replace the vendored copy of mattpocock/skills with the given upstream ref (default: the upstream default branch) and rewrite its lock file. Needs network access to GitHub; see [Vendored skills](#vendored-skills). |
38
+
39
+ The package check builds an actual tarball, verifies its allowlist, installs it
40
+ with `npm install --omit=dev` in a fresh project, and invokes the installed bin
41
+ with Bun. Its isolated install does not use the checkout's lockfile or `node_modules`;
42
+ all temporary pack, install, cache, and home directories are created outside the
43
+ checkout.
44
+ For an explicitly opt-in registry check, pass a package spec:
45
+
46
+ ```bash
47
+ bun run package:check -- \
48
+ --registry --package-spec @beremaran/ralphie@<release-version>
49
+ ```
50
+
51
+ The project is a Bun + TypeScript CLI in strict mode. The entry point is
52
+ `index.ts`; services are assembled as an explicit dependency object in
53
+ `src/runtime.ts`, and `src/workflow/workflow.ts` orchestrates them. Formatting is Biome
54
+ with four-space indentation, double quotes, and semicolons. Keep functions
55
+ small: the configured cognitive-complexity limit is the meaningful lint
56
+ constraint.
57
+
58
+ ## Live smoke script
59
+
60
+ `bun run smoke:live` (`scripts/live-smoke.ts`) runs the real CLI against a
61
+ scratch GitHub repository with each installed harness (`claude`, `codex`,
62
+ `pi`, `opencode`; missing executables are skipped). For each harness it files
63
+ three issues labelled `ready-for-agent` and `smoke-<harness>` (an
64
+ implementation task that goes through review, an ambiguous task that must end
65
+ in a hand-off, and an oversized task that must be decomposed), runs Ralphie
66
+ with every role on that harness in `yolo` approval, checks the outcomes, and
67
+ closes the issues afterwards as not planned (`--keep-issues` leaves them).
68
+ The script waits until GitHub lists the new issues before starting Ralphie, runs
69
+ it with `--output json`, and prints the path of the saved JSON Lines log with
70
+ the final `Run completed` line. The implementation scenario passes only when
71
+ the log shows Ralphie closing the issue as completed and a new commit on the
72
+ default branch added `greeting.txt` containing `hello`; a closed issue alone is
73
+ not evidence. Each harness ends as PASS, FAIL or INCONCLUSIVE. The decomposition scenario
74
+ passes only when a child issue was then worked to a genuine terminal outcome:
75
+ closed as completed by Ralphie, or handed off for a real reason rather than a
76
+ failed session. When Ralphie exits `75` because a usage limit, outage or
77
+ expired login halted the run, the harness is INCONCLUSIVE, not a pass or a
78
+ failure; rerun it once the limit clears.
79
+
80
+ It is never run by `bun run test`, `bun run check`, or CI: it needs live
81
+ harness logins, model spend, and GitHub credentials. Run it by hand before a
82
+ release or after changing an adapter, prompt, or hand-off path:
83
+
84
+ ```bash
85
+ RALPHIE_SMOKE_SCRATCH_REPO=you/ralphie-scratch \
86
+ bun run smoke:live -- --scratch-repo you/ralphie-scratch --harness claude,codex
87
+ ```
88
+
89
+ The scratch repository must be named both by flag and by the
90
+ `RALPHIE_SMOKE_SCRATCH_REPO` environment variable, and the project repository
91
+ is refused. Use a throwaway repository: Ralphie commits and pushes to its
92
+ default branch. Outcomes depend on model judgement, so one failed scenario is
93
+ a prompt to inspect the run, not necessarily a regression. The script was
94
+ run live on 2026-10-06 against `claude`, `codex` and `pi`. Those runs found and
95
+ fixed real defects (the Codex output schema, a parallel skill-preparation race,
96
+ and the exit status of a halted run), and not every scenario passed on every
97
+ harness, so expect to inspect a run rather than trust a single result.
98
+
99
+ ## Source reachability boundary
100
+
101
+ The supported runtime boundary is the bundled `dist/ralphie.js` CLI reached
102
+ from `index.ts` through `src/cli.ts`, `src/command.ts`, and the runtime
103
+ assembly. Tests and helper probes are verification-only consumers: they do not
104
+ establish a supported production path, and a type-only import does not
105
+ establish runtime bundle reachability.
106
+
107
+ `bun run source:audit` follows value imports, type-only imports, relative
108
+ re-exports, and missing paths from the production root `index.ts`. It also
109
+ follows the explicit build root `scripts/build.ts`, reports every `src/**/*.ts`
110
+ module and export in stable JSON, and fails on unresolved relative paths. Run
111
+ `bun run scripts/source-reachability.ts` when a human-readable classification
112
+ listing is more useful. The audit is part of `bun run check` and is fully
113
+ offline.
114
+
115
+ The completed audit has one intentional build-time exception set:
116
+
117
+ | Source path | Root | Import kind | Purpose |
118
+ | --- | --- | --- | --- |
119
+ | `scripts/build.ts` → `src/build-info.ts` | `scripts/build.ts` | value: `LOCAL_BUILD_COMMIT_SHA` | Supplies the `local` commit sentinel when a release build does not provide an explicit commit SHA. |
120
+ | `scripts/build.ts` → `src/build-info.ts` | `scripts/build.ts` | type: `BuildInfo` | Checks the shape of the version/commit metadata injected into the bundle. |
121
+ | `src/command.ts` → `src/build-info.ts` | `index.ts` production path | value: `BUILD_INFO` | Supplies the version and commit SHA reported by the CLI's plain and JSON `--version` output. |
122
+ | `src/build-info.ts` → `package.json` | `index.ts` production path and build output | value: package metadata | Provides the package version fallback used before release metadata is injected. |
123
+
124
+ Keep these roots and exceptions synchronized with the audit when changing the
125
+ source map or build metadata relationship. A source-only helper should not be
126
+ made part of the package boundary merely to satisfy a test import; add focused
127
+ verification at the canonical production seam instead.
128
+
129
+ ## Publishing
130
+
131
+ The package builds with `bun run build` to `dist/ralphie.js`; `bun run
132
+ package:check` packs, installs, and runs it in an isolated directory, and
133
+ `bun run package:inspect` lists the packed files. Release flow: bump
134
+ `package.json` `version` and `CHANGELOG.md`, push a `v<major>.<minor>.<patch>`
135
+ tag, and the tag-triggered publish workflow validates the tag/package version
136
+ (`scripts/validate-npm-context.ts`), builds, smoke-checks, and runs
137
+ `bun publish`. No other distribution channel exists.
138
+
139
+ The `bun run test` suite is deliberately offline: it combines fast in-memory
140
+ unit tests with local integration, PTY, and temporary-checkout coverage. It does
141
+ not contact GitHub, model providers, npm, or a container registry.
142
+ The former distribution-channel and live network smoke suites (standalone
143
+ installer, Docker image, Homebrew reconciliation, and release publication)
144
+ were removed from the default gate; the package registry check remains an
145
+ explicit opt-in using `--registry` with an exact `--package-spec`.
146
+
147
+ ## Vendored skills
148
+
149
+ Ralphie runs Matt Pocock's skills from a pinned copy in this repository, not
150
+ from whatever a user has installed ([ADR-0002](adr/0002-vendored-skills-with-overlays.md)).
151
+ The copy lives in `vendor/mattpocock-skills/`:
152
+
153
+ - one directory per skill (`triage`, `to-tickets`, `implement`, `tdd`,
154
+ `code-review`, `codebase-design`, `diagnosing-bugs`), flattened from
155
+ upstream's `skills/<bucket>/<name>/`, so the directory is itself a skills
156
+ directory and each skill keeps its references and `agents/` metadata;
157
+ - `LICENSE`, the upstream MIT license; and
158
+ - `lock.json`, which records the upstream repository, the full commit id, where
159
+ each skill lives upstream, and the git blob id of every vendored file.
160
+
161
+ The copy is published: `package.json` `files` includes `vendor/mattpocock-skills`,
162
+ and `bun run package:check` fails if a locked file is missing from the tarball
163
+ or the installed package. The bundled `dist/ralphie.js` finds the copy at
164
+ `../vendor/mattpocock-skills` relative to its own directory.
165
+
166
+ **Never hand-edit anything under `vendor/mattpocock-skills/`.** Where Ralphie's
167
+ contract departs from a skill's text, the difference belongs in a Ralphie skill
168
+ overlay. `tests/skills-sync.test.ts` verifies that the checked-in files are
169
+ exactly the blobs named in `lock.json`, so an edit, a stray file, or a hand-built
170
+ lock fails `bun run test`. The directory is excluded from Biome, and
171
+ `.gitattributes` marks it `-text` so line endings are never rewritten.
172
+
173
+ ### Syncing
174
+
175
+ `bun run skills:sync [ref]` fetches `ref` (a branch, tag, or commit of
176
+ `https://github.com/mattpocock/skills`; default `HEAD`) with a shallow, read-only
177
+ `git fetch` into a scratch repository, rebuilds the copy beside the vendored
178
+ directory, and swaps it in. Nothing in the output depends on the ref spelling, the
179
+ clock, or the machine, so syncing the same commit twice produces byte-identical
180
+ files, and the script prints the previous and new commit and the vendored files
181
+ that changed. It fails without touching the existing copy when the ref does not
182
+ resolve, upstream no longer has one of the driven skills (or has it in two
183
+ places), the license is missing, or a driven skill contains something that is not a
184
+ regular file. Adding a driven skill means adding its name to `VENDORED_SKILLS` in
185
+ `scripts/skills-sync.ts` and syncing.
186
+
187
+ To compare a lock with upstream by hand, `git ls-tree -r <commit>` in a clone of
188
+ upstream lists the same blob ids as `lock.json`.
189
+
190
+ ### Scheduled sync and review
191
+
192
+ `.github/workflows/skills-sync.yml` runs weekly and on demand (`workflow_dispatch`
193
+ accepts an optional `ref`). It runs `bun run skills:sync`, and opens or updates
194
+ one pull request on the `skills-sync` branch only when the vendored files or skill
195
+ locations differ from the lock. An upstream commit that changes none of the driven
196
+ skills does not open a pull request. The pull request body links the upstream
197
+ compare view between the locked and new commits.
198
+ The repository setting "Allow GitHub Actions to create and approve pull requests"
199
+ must be enabled for the workflow to open the pull request.
200
+
201
+ Reviewing a sync pull request:
202
+
203
+ 1. Read the upstream diff in the pull request (or its compare link) for each
204
+ driven skill, not only the vendored paths.
205
+ 2. Check whether the new skill text still fits Ralphie's contract: schema-validated
206
+ tool results, no agent commits or pushes, direct delivery. Where it does not,
207
+ change the Ralphie skill overlay in the same pull request, never the vendored
208
+ files.
209
+ 3. Pull requests opened with the workflow's token do not trigger CI. Close and
210
+ reopen the pull request, or run `bun run check` on its branch, before merging.
211
+
212
+ ## Contribution expectations
213
+
214
+ Contributions are welcome. For substantial behavior or workflow changes, open
215
+ an issue first so the safety and recovery implications can be discussed before
216
+ implementation.
217
+
218
+ Before submitting a change:
219
+
220
+ 1. Add or update tests for the behavior.
221
+ 2. Run `bun run check`.
222
+ 3. Keep Git and GitHub mutations inside their deterministic domain services.
223
+ 4. Update the authoritative page under [`docs/`](README.md) when documentation
224
+ changes. Update [`CHANGELOG.md`](../CHANGELOG.md) when the command surface, the
225
+ output shape, the run-state version, or the recovery contract changes.
226
+
227
+ Add in-memory unit tests for new behavior, following the patterns in the
228
+ remaining files under `tests/`. Do not
229
+ run the mutating CLI against an uncontrolled repository while developing; use a
230
+ repository you control when a command-level check is needed. The workspace is deleted by the CLI; see
231
+ [Workspace risk](safety.md#workspace-risk).
232
+
233
+ ## Where future documentation belongs
234
+
235
+ Do not append detailed contracts to the root README. Keep the root page as the
236
+ landing page, and place changes in the page that owns the fact:
237
+
238
+ - configuration keys and removed flags: [Configuration](configuration.md);
239
+ - CLI options and recipes: [CLI reference](cli-reference.md);
240
+ - routing and delivery behavior: [Workflows](workflows.md);
241
+ - mutation boundaries: [Safety](safety.md);
242
+ - output, state, and recovery: [Operations and recovery](operations-and-recovery.md);
243
+ - components and source locations: [Architecture](architecture.md); and
244
+ - versioning, publishing, the live smoke script and vendored-skill syncing:
245
+ [Development](development.md#publishing).
246
+
247
+ Update the [documentation index](README.md)
248
+ when pages or reading paths change.
@@ -0,0 +1,134 @@
1
+ # Getting started
2
+
3
+ This page is for a new operator setting up Ralphie and performing the first
4
+ safe validation. It is the authoritative guide to prerequisites, installation,
5
+ credential setup, verification, and the first run. Return to the
6
+ [documentation index](README.md) for other task paths.
7
+
8
+ > [!CAUTION]
9
+ > Ralphie commits approved work and pushes directly to the selected branch.
10
+ > Ralphie is pre-1.0. Validate against a repository you control and read the
11
+ > [safety model](safety.md) before enabling mutations.
12
+
13
+ ## Prerequisites and authentication
14
+
15
+ Ralphie is distributed as a single npm package. Running it needs:
16
+
17
+ - [Bun](https://bun.sh/) (also needed to build from source);
18
+ - [Git](https://git-scm.com/) and the
19
+ [GitHub CLI](https://cli.github.com/) (`gh`);
20
+ - a POSIX shell;
21
+ - at least one supported coding-agent command-line program, signed in: Claude
22
+ Code (`claude`, the default), Codex (`codex`), pi (`pi`), or OpenCode
23
+ (`opencode`).
24
+
25
+ Agent sessions run through that program, headless, in the repository
26
+ checkout. It brings its own login, so Ralphie asks for no model credentials
27
+ and stores none. Pick the harness, model and effort per role with the
28
+ `harnesses` and `roles` keys in the
29
+ [configuration file](configuration.md#harnesses-and-roles); without them every
30
+ role uses Claude Code with its own defaults. Sessions never commit, push, or
31
+ mutate GitHub; Ralphie's deterministic services do (see the
32
+ [safety model](safety.md#agent-and-mutation-boundaries)).
33
+
34
+ For interactive GitHub authentication, run `gh auth login` and verify the
35
+ selected account with `gh auth status`. For unattended runs, supply a token
36
+ through the environment as described under
37
+ [Environment variables](cli-reference.md#environment-variables).
38
+
39
+ Ralphie only works on open issues labelled `ready-for-agent` (the label name
40
+ is configurable). Label at least one issue before the first run, or enable
41
+ [AFK triage](workflows.md#afk-triage).
42
+
43
+ Permission needs depend on the run. The issue workflow needs
44
+ read access to the target repository and its issues, permission to push to the
45
+ selected branch, and permission to create, update, and close issues.
46
+
47
+ ## Create the config file
48
+
49
+ Run `ralphie init` once. It looks for the supported harnesses (`claude`,
50
+ `codex`, `pi`, `opencode`) on PATH and writes a commented config file at the
51
+ default location (or at `--config <path>`), assigning the first harness it
52
+ finds to every role. The defaults pass the startup checks for the harnesses it
53
+ found. It refuses to overwrite an existing file and fails when no harness is
54
+ installed. Running Ralphie without a config file points you back to `init`.
55
+
56
+ ## Installation
57
+
58
+ ### Published package
59
+
60
+ Use Bun's package runner to run the latest published version without a global
61
+ installation:
62
+
63
+ ```bash
64
+ bunx @beremaran/ralphie --version
65
+ ```
66
+
67
+ For a global install, `bun add -g @beremaran/ralphie` provides the `ralphie`
68
+ command. The `@beremaran` scope is intentional. Do not substitute the unrelated
69
+ unscoped npm package named `ralphie`; use `@beremaran/ralphie` for this CLI.
70
+
71
+ ### Source checkout
72
+
73
+ For development or to run the current checkout:
74
+
75
+ ```bash
76
+ git clone https://github.com/beremaran/ralphie.git
77
+ cd ralphie
78
+ bun install --frozen-lockfile
79
+ bun run index.ts --version
80
+ ```
81
+
82
+ ## Verify the installation
83
+
84
+ For the published package (Bun required):
85
+
86
+ ```bash
87
+ bunx @beremaran/ralphie --version
88
+ git --version
89
+ gh --version
90
+ gh auth status
91
+ ```
92
+
93
+ For a source checkout, use the source entry point instead (Bun required):
94
+
95
+ ```bash
96
+ bun run index.ts --version
97
+ ```
98
+
99
+ The output forms are described under
100
+ [Version and help](cli-reference.md#version-and-help).
101
+
102
+ ## Target-repository verification dependencies
103
+
104
+ Deterministic verification is opt-in. List one or more
105
+ commands under `repos."owner/repo".verify` in the
106
+ [configuration file](configuration.md) to run the target's checks in the checkout through
107
+ `/bin/sh` after changes are staged; when omitted, the gate is skipped and
108
+ review proceeds on the staged diff alone. The tools used by a supplied command
109
+ belong to the target repository's contract, not Ralphie's runtime: a command
110
+ that uses Bun, Node.js, or a project compiler needs those tools present in the
111
+ environment you run Ralphie in.
112
+
113
+ ## First run
114
+
115
+ Run against the `ready-for-agent` issues of a repository you control:
116
+
117
+ ```bash
118
+ bunx @beremaran/ralphie owner/repository
119
+ ```
120
+
121
+ When running from source, use the source entry point instead:
122
+
123
+ ```bash
124
+ bun run index.ts owner/repository
125
+ ```
126
+
127
+ This performs authentication and Git preflight, prepares a clean checkout,
128
+ discovers issues, and asks the configured harness to pre-flight, implement, review, and commit the
129
+ work. Successful delivery pushes directly to the selected branch and closes the
130
+ issue. See [Workflows](workflows.md) for what the selected route means and
131
+ [Operations and recovery](operations-and-recovery.md)
132
+ for the artifacts it leaves behind.
133
+
134
+ For all available options, continue to the [CLI reference](cli-reference.md).