Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ jobs:
- run: npm ci
- run: npm run typecheck
- run: npm test
# The npm package ships only dist/, src/, LICENSE and package.json: no
# demo video, voiceover, benchmark data or examples.
- name: Check npm package contents
working-directory: packages/codemode-git
run: |
npm pack --dry-run --json | node -e '
const files = JSON.parse(require("fs").readFileSync(0, "utf8"))[0].files.map((f) => f.path);
const extra = files.filter((p) => !/^(dist|src)\//.test(p) && !["LICENSE", "package.json", "README.md"].includes(p));
if (extra.length) { console.error("Unexpected files in the npm package:\n" + extra.join("\n")); process.exit(1); }
console.log(files.length + " files, all expected");'
# Builds the example and checks the deploy without credentials.
- run: npx cf build --mode production
working-directory: examples/agent
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ permissions: {}

jobs:
verify:
# Only version releases (v1.2.3) publish; other releases, like the demo
# video's, skip every job.
if: startsWith(github.event.release.tag_name, 'v')
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
3 changes: 1 addition & 2 deletions DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ The video is code: [demo/video](demo/video). [transcript.md](demo/video/transcri
| 3 | **Every agent starts from zero** | A grid of agents, each writing code that dissolves | The problem |
| 4 | **Code Mode** | Before: model ⇄ tools ping-pong. After: one program in an isolate | Brief context; the code is the plan |
| 5 | **The gap** | The isolate collapses, and the code falls away | The plan is thrown away |
| 6 | **Phase 1: code memory** | Agents → their own Artifacts repos, with commits stacking up | 1 repo per agent, 1 writer per repo, 0 merges |
| 6 | **Phase 1: code memory** | Agents → their own Artifacts repos, with commits stacking up; then the measured swarm result | 1 repo per agent, 1 writer per repo, 0 merges; 1,000 agents committed at once in 27s with 0 errors |
| 7 | **Under the hood** | execution ends → Durable Object SQLite outbox → isomorphic-git → Artifacts | How the write path works |
| 8 | **Every attempt, in git** (≥30s) | `git log` of an agent: error, fix, answer | Slot for a VHS recording |
| 9 | **One repo per agent** (≥25s) | 1,000 squares lighting up | Slot for the swarm recording |
| 10 | **Phase 2: learning** | michelle's repo → Workers AI → Vectorize → matthew. A provenance arrow back | Retrieval and `Codemode-Examples` |
| 11 | **Lava lamp wall** (≥60s) | michelle and matthew lanes: runs ✓/✗ and token bars | Slot for the real `walkthrough.mjs` run |
| 12 | **Learning curve** | Median tokens by run position, baseline vs memory | Cold start, then about a third |
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/smithclay/codemode-git/tree/main/examples/agent)

[![Watch the 5-minute demo](docs/assets/demo-poster.jpg)](https://github.com/smithclay/codemode-git/releases/download/demo-video/codemode-git-demo.mp4)

**`codemode-git` gives Code Mode agents code memory on Cloudflare Artifacts.** Keep the code, and your Workers get smarter over time.

Every [Code Mode](https://www.npmjs.com/package/@cloudflare/codemode) execution becomes a git commit on that agent's own [Cloudflare Artifacts](https://developers.cloudflare.com/artifacts/) repo. Clone it with plain `git` and `git log -p run.js` is the agent's trajectory.
Expand Down Expand Up @@ -150,12 +152,12 @@ curl -X POST localhost:8787/agents/michelle/ask -d '{"question": "How many lava
# {"agent","question","answer","steps","executions","errors","tokens":{"input","output"},"examples":["agent-…@sha"],"commits":[{"sha","intent","status"}],"indexed"}
```

Pass `"useExamples": false` for a baseline without retrieval. `GET /agents/:name/examples?question=...` shows what `ask` would retrieve, without calling the chat model.
Pass `"useExamples": false` for a baseline without retrieval. Agents share the `lamps` examples scope; pass `"scope": "<name>"` to keep a group of runs separate. `GET /agents/:name/examples?question=...[&scope=...]` shows what `ask` would retrieve, without calling the chat model.

`scripts/walkthrough.mjs` runs the two-agent demo: `michelle` asks how many lamps are flowing, then `matthew` asks how many red lamps are flowing and is shown michelle's run. Between the two it polls until michelle's run is retrievable, because Vectorize metadata filters see new vectors only after ~1–2 minutes (`--wait` caps the wait in seconds, default 180). Agent names get a run-unique prefix, so each rerun uses fresh agents and repos. It prints both answers side by side with executions, steps, tokens, examples and commit shas.
`scripts/walkthrough.mjs` runs the two-agent demo: `michelle` asks how many lamps are flowing, then `matthew` asks how many red lamps are flowing and is shown michelle's run. Between the two it polls until michelle's run is retrievable, because Vectorize metadata filters see new vectors only after ~1–2 minutes (`--wait` caps the wait in seconds, default 180). Agent names and the examples scope are run-unique, so each rerun uses fresh agents and repos, and earlier runs can't crowd out this run's michelle (`--scope lamps` shares memory instead). It prints both answers side by side with executions, steps, tokens, examples and commit shas.

```bash
node examples/agent/scripts/walkthrough.mjs https://codemode-git-example.<subdomain>.workers.dev [--prefix demo] [--wait 180]
node examples/agent/scripts/walkthrough.mjs https://codemode-git-example.<subdomain>.workers.dev [--prefix demo] [--scope <name>] [--wait 180]
```

### Run many agents at once
Expand Down
4 changes: 3 additions & 1 deletion demo/video/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Demo video

The competition demo, built with [Remotion](https://www.remotion.dev/). The voiceover is generated on Workers AI with Deepgram Aura-2 (`@cf/deepgram/aura-2-en`), and Whisper (`@cf/openai/whisper`) supplies word timings for the captions. The narration is in [transcript.md](transcript.md), one `## <scene>` section per scene. Scene order, diagrams and recording slots are in [src/script.ts](src/script.ts). The run of show it follows is in [DEMO.md](../../DEMO.md).
The competition demo, built with [Remotion](https://www.remotion.dev/). The voiceover is generated on Workers AI with Deepgram Aura-2 (`@cf/deepgram/aura-2-en`, voice `arcas`, uncompressed WAV), and Whisper (`@cf/openai/whisper`) supplies word timings for the captions. The narration is in [transcript.md](transcript.md), one `## <scene>` section per scene. Scene order, diagrams and recording slots are in [src/script.ts](src/script.ts). The run of show it follows is in [DEMO.md](../../DEMO.md).

This package sits outside the repo's npm workspaces, so Remotion's headless Chrome doesn't affect CI or the library install.

Expand All @@ -23,3 +23,5 @@ To skip the local Worker, set `CLOUDFLARE_API_TOKEN` (with Workers AI access) an
**Recordings:** a scene shows `public/clips/<scene>.mp4` instead of its diagram when the scene id is listed in `public/clips/index.json`. Scenes with `minSeconds` in the script stretch to that length once their recording exists (the git log, the swarm, and the michelle → matthew run). Until then they last only as long as their narration, so there's no silent padding.

**Terminal recordings:** `npm run record` records [terminal/new-worker.tape](terminal/new-worker.tape) with [VHS](https://github.com/charmbracelet/vhs): `cf init`, installing Code Mode and codemode-git, the connector and bindings, and `cf deploy --dry-run` (nothing is deployed). [scripts/record.mjs](scripts/record.mjs) then encodes the clip to `public/clips/new-worker.mp4` and lists it in `public/clips/index.json`. VHS's own encoding fails silently with ffmpeg 9, so VHS writes frames and ffmpeg does the encoding. The recording turns off npm's minimum-release-age check for its own shell only, because the `cf init` template pins a `cf` beta that is less than a week old.

**Publishing:** `npm run publish-video` renders the video, uploads it as `codemode-git-demo.mp4` to the `demo-video` GitHub release (creating it if needed, never marked latest), and refreshes the README poster (`docs/assets/demo-poster.jpg`, from the `Poster` still). The repo README links the poster to that release asset. GitHub only plays videos inline when they're uploaded through its web editor, so the README uses a poster that links to the MP4.
3 changes: 2 additions & 1 deletion demo/video/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"studio": "remotion studio",
"render": "remotion render Demo out/demo.mp4",
"typecheck": "tsc -p . && tsc -p worker",
"record": "node scripts/record.mjs new-worker"
"record": "node scripts/record.mjs new-worker",
"publish-video": "node scripts/publish-video.mjs"
},
"dependencies": {
"@remotion/cli": "4.0.532",
Expand Down
8 changes: 5 additions & 3 deletions demo/video/public/clips/index.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[
"new-worker"
]
{
"new-worker": 39.2,
"repo": 34.5,
"provenance": 39.8
}
Binary file added demo/video/public/clips/provenance.mp4
Binary file not shown.
Binary file added demo/video/public/clips/repo.mp4
Binary file not shown.
Binary file removed demo/video/public/voiceover/accuracy.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/accuracy.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/close.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/close.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/code-memory.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/code-memory.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/code-mode.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/code-mode.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/contagion.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/contagion.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/credits.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/credits.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/curve.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/curve.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/gap.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/gap.wav
Binary file not shown.
Binary file removed demo/video/public/voiceover/hook.mp3
Binary file not shown.
Binary file added demo/video/public/voiceover/hook.wav
Binary file not shown.
Loading
Loading