Skip to content

Commit 82dae0b

Browse files
Add runner: fake runner, session store, skeleton
0 parents  commit 82dae0b

26 files changed

Lines changed: 1790 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: ci
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
# Both repos side by side, so file:../codehands-contracts resolves.
8+
- uses: actions/checkout@v4
9+
with: { path: codehands-runner }
10+
- uses: actions/checkout@v4
11+
with: { repository: imtahirabatool/codehands-contracts, path: codehands-contracts }
12+
- uses: pnpm/action-setup@v4
13+
with: { version: 10.17.1 }
14+
- uses: actions/setup-node@v4
15+
with: { node-version: 22 }
16+
- run: pnpm install && pnpm build
17+
working-directory: codehands-contracts
18+
- run: pnpm install && pnpm build && pnpm test
19+
working-directory: codehands-runner

‎runner/.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

‎runner/.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.env
5+
.env.*
6+
*.log

‎runner/.nvmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

‎runner/README.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# codehands-runner
2+
3+
Given a repo and a prompt, the runner makes a private copy of the repo (a git worktree on a new branch). It runs Claude Code or Codex there with no screen and turns their output into events. Someone can then stop, resume, approve or reject the change.
4+
5+
Owner: Tahira · Consumed by: the daemon in `codehands-cli` (Midhat) · Contract: [`codehands-contracts`](../codehands-contracts)
6+
7+
## Layout
8+
9+
| Path | What | When |
10+
| --- | --- | --- |
11+
| `src/fake-runner.ts` | Stand-in that emits 12 events, 300 ms apart. Midhat plugs it in today. Also the demo backup | Mon, done |
12+
| `src/session-store.ts` | Session records and the legal state moves | Mon, done |
13+
| `src/events.ts` | `seq` 1, 2, 3 … per session | Mon, done |
14+
| `src/agents/claude-code.ts` | `claude -p` arguments, done. Stream-json line → events, to do | Tue |
15+
| `src/git/worktree.ts` | Branch names, done. Worktree add, remove and prune, to do | Tue, Wed |
16+
| `src/runner.ts` | `start`, then `diff`, `approve`, `reject`, `stop`, then `resume` | Tue to Thu |
17+
| `src/git/diff.ts` | `git add -A`, `diff --cached --binary`, commit | Wed |
18+
| `src/process/kill-tree.ts` | Stop politely, then kill the whole process tree | Wed |
19+
| `src/agents/codex.ts` | `codex exec --json` → events | Thu pm, Fri |
20+
| `src/memory/notes.ts` | Per-repo notes in, a summary appended after each run | Fri |
21+
| `scripts/spike.sh` | Monday's hand spike, saves `test/fixtures/spike-1.jsonl` | Mon |
22+
| `scripts/reset-fixture.sh` | Puts the fixture repo back to its starting state before a rehearsal | Wed night |
23+
24+
## Run it
25+
26+
Clone `codehands-contracts` next to this repo and build it first:
27+
28+
```bash
29+
cd ../codehands-contracts && pnpm install && pnpm build
30+
cd ../codehands-runner && pnpm install
31+
pnpm test # parser tests replay recorded JSONL, no API cost
32+
pnpm fake # print the fake runner's events
33+
```
34+
35+
Add the runtime dependencies when you start on Tuesday: `pnpm add execa tree-kill`.
36+
37+
## Rules this week
38+
39+
- Only run on our own repos. There is no sandbox until week 2.
40+
- `acceptEdits` plus a short `--allowedTools` list. Never use `--dangerously-skip-permissions`. Always pass `--max-budget-usd`.
41+
- API keys never go into events, logs or the diff.
42+
43+
The full week is in `codehands-docs/weeks/week-1/tahira.md`.

‎runner/package.json‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@codehands/runner",
3+
"version": "0.1.0",
4+
"description": "Runs Claude Code or Codex in a git worktree per task and turns its output into events",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"files": [
9+
"dist"
10+
],
11+
"packageManager": "pnpm@10.17.1",
12+
"engines": {
13+
"node": ">=22"
14+
},
15+
"scripts": {
16+
"build": "tsc",
17+
"prepare": "tsc",
18+
"typecheck": "tsc --noEmit",
19+
"test": "vitest run",
20+
"fake": "tsx scripts/fake.ts"
21+
},
22+
"dependencies": {
23+
"@codehands/contracts": "file:../../codehands-contracts"
24+
},
25+
"devDependencies": {
26+
"@types/node": "^26.6.5",
27+
"tsx": "^4.23.15",
28+
"typescript": "^7.0.2",
29+
"vitest": "^3.2.4"
30+
}
31+
}

0 commit comments

Comments
 (0)