@flumecode/runner 0.0.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/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @flumecode/runner
2
+
3
+ The FlumeCode **local runner**. It runs on your own machine, claims agent jobs
4
+ from the FlumeCode web app, and drives your **local Claude Code** against a real
5
+ checkout of the repo — editing files, running tests, and opening a pull request.
6
+
7
+ Because the work runs on your machine and through your own Claude Code login, the
8
+ FlumeCode service never stores an API key or runs your code itself.
9
+
10
+ ## Prerequisites
11
+
12
+ - Node 20+
13
+ - `git` on your PATH
14
+ - [Claude Code](https://code.claude.com) installed and logged in (subscription),
15
+ or an `ANTHROPIC_API_KEY` exported in the shell you run the runner from
16
+ - A runner token — create one in the web app on the **Runners** page
17
+
18
+ ## Install & run
19
+
20
+ The runner ships as a global CLI on npm. The Runners page in the web app shows
21
+ these exact commands with your token pre-filled:
22
+
23
+ ```bash
24
+ npm install -g @flumecode/runner
25
+
26
+ # Save the server URL + token (or run `flumecode login` for an interactive prompt)
27
+ flumecode login --server https://<your-app> --token flrun_…
28
+
29
+ # Start polling for jobs (keep it running)
30
+ flumecode start
31
+ ```
32
+
33
+ Config is written to `~/.flume/config.json` (mode 0600). The token lives only
34
+ there and is sent only as the `Authorization` header to your server. The default
35
+ server for a bare interactive `flumecode login` can be set via `FLUME_SERVER`.
36
+
37
+ ## Developing on the runner
38
+
39
+ From the monorepo, run it straight from source with `tsx` (no build step):
40
+
41
+ ```bash
42
+ pnpm install
43
+ pnpm --filter @flumecode/runner dev login # or: dev start
44
+ ```
45
+
46
+ `pnpm --filter @flumecode/runner build` produces the published single-file bundle
47
+ (`dist/cli.js`); it is published to npm by the `release-runner` GitHub workflow
48
+ when a `runner-v*` tag is pushed.
49
+
50
+ ## What a job does
51
+
52
+ 1. Claim the next queued job for your account (`POST /api/runner/jobs/claim`).
53
+ 2. Clone the repo with a short-lived GitHub token and check out the frozen commit
54
+ on the request's `checkoutBranch`.
55
+ 3. Run Claude Code (`permissionMode: acceptEdits`) over the working directory with
56
+ the request + thread as the prompt.
57
+ 4. If it was an edit-mode job that changed files, run a second pass with the
58
+ `flumecode:document` skill to reconcile the repo wiki (`.flumecode/wiki/`) with
59
+ the change — bootstrapping it on the first run. The wiki edits are committed in
60
+ the same PR. A failure here is logged and skipped; it never fails the job.
61
+ 5. If files changed: commit, push `checkoutBranch`, open a PR into `mergeBranch`.
62
+ 6. Report the summary back (`POST /api/runner/jobs/:id/complete`), which fills in
63
+ the pending agent comment in the thread.
64
+
65
+ Jobs come in two kinds. **chat** jobs answer a request thread (the flow above).
66
+ **init** jobs bootstrap a repository: they clone the default branch onto a fresh
67
+ `flumecode/init-*` branch, run the `flumecode:document` skill to create the
68
+ `.flumecode/` wiki, and open a PR. A repo must be initialized (from its dashboard
69
+ in the web app) before requests can be opened against it.
70
+
71
+ > ⚠️ The runner executes model-generated commands on your machine via
72
+ > `acceptEdits`. Run it only against repos and requests you trust.
73
+
74
+ ## Status reporting
75
+
76
+ On startup (and every few minutes after) the runner probes your local Claude
77
+ Code with one trivial turn and reports the result to the server
78
+ (`POST /api/runner/heartbeat`). The web **Runners** page shows two states per
79
+ machine: **Connected** (the runner is checking in) and **Claude Code ready**
80
+ (its login works, so the server can dispatch tasks to it). A failed probe shows
81
+ **Claude Code error** with the reason — usually "not logged in" or a missing
82
+ binary.
83
+
84
+ The runner also reports its own version (`x-flumecode-runner-version` header) on
85
+ every call, so the Runners page can show an **Update available** hint when your
86
+ machine is behind. To update: `npm install -g @flumecode/runner`, then restart
87
+ the runner.
88
+
89
+ ## Troubleshooting
90
+
91
+ - **"Runner token rejected (401)"** — the token is wrong or was removed. Create a
92
+ fresh one on the Runners page and re-run `flumecode login`.
93
+ - **Claude Code error on the Runners page** — open a shell and confirm Claude Code
94
+ works there (`claude` is on your PATH and you're logged in), or that
95
+ `ANTHROPIC_API_KEY` is exported. The runner uses whatever that shell has.
96
+ - **`flumecode: command not found`** — the global npm bin dir isn't on your PATH,
97
+ or use `npx @flumecode/runner …` instead of installing globally.
98
+ - **Update available hint** — `npm install -g @flumecode/runner` then restart.