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
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project sends Claude Code and OpenCode session traces to Langfuse for obser
- `src/tags.rs` — gathers env tags (repo, org, branch, user, host, os, agent version)
- `src/state.rs` — persisted cursor state per session
- `src/log.rs` — logging to `~/.local/share/code-trace/`
- `plugin/opencode/` — opencode v2 plugin (server part `index.ts`, TUI part `tui.ts`); embedded into the binary by `src/setup.rs`
- `plugin/pi-agent/code-trace.ts` — pi extension

## State location
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ The install script does this automatically. If not, add to `~/.claude/settings.j

#### OpenCode

Copy `plugin/opencode/code-trace.ts` to your OpenCode plugins directory:
Copy the `plugin/opencode` plugin directory into your OpenCode plugins directory (opencode v2 auto-loads plugin directories; the server part is `index.ts` and the TUI part is `tui.ts`):

```bash
mkdir -p ~/.config/opencode/plugins/
cp plugin/opencode/code-trace.ts ~/.config/opencode/plugins/code-trace.ts
cp -r plugin/opencode ~/.config/opencode/plugins/code-trace
rm -f ~/.config/opencode/plugins/code-trace.ts # v1 single-file plugin, if present
```

Or use the install script with `--opencode` (see above).
Or use the install script with `--opencode` (see above), which installs the directory and removes the v1 file.

#### Pi

Expand Down Expand Up @@ -214,7 +215,7 @@ How each agent surfaces that reminder to the **user** (never to the model):
}
```

- **OpenCode** — the plugin hooks the `session.created` event (root sessions only) and spawns `code-trace --on-start` with an OpenCode-shaped payload. The binary replies with a structured JSON `{ "codeTrace": { "level", "message" } }`, and the plugin renders it as a TUI toast (`warning` when tracing is ENABLED, `info` otherwise). Subagent (Task tool) sessions are filtered out so a delegation doesn't pop a banner. In headless `opencode run` (no TUI) the toast is a no-op.
- **OpenCode** — the plugin (server part) hooks the `session.created` event (root sessions only) and spawns `code-trace --on-start` with an OpenCode-shaped payload, recording the session so the privacy CLI can act on it. The binary replies with a structured JSON `{ "codeTrace": { "level", "message" } }`; the plugin's TUI part renders it as a toast (`warning` when tracing is ENABLED, `info` otherwise). Subagent (Task tool) sessions are filtered out so a delegation doesn't pop a banner. In headless `opencode run` (no TUI) the toast is a no-op, but the session is still recorded.

### Purge

Expand All @@ -240,11 +241,11 @@ Caveats: deleting the transcript removes the session from Claude Code's `--resum

### OpenCode

1. The OpenCode plugin shows the tracing reminder as a TUI toast when a root session is created (`session.created`)
1. The OpenCode plugin's TUI part shows the tracing reminder as a toast when a root session is created (`session.created`); the server part also runs `--on-start` so the session is recorded even headless
2. The plugin hooks into the `session.idle` event after each assistant response
3. It fetches new messages since the last processed message (tracked per-session in `~/.local/share/code-trace/opencode_cursor.json`)
4. Messages are assembled into turns and piped to the `code-trace` binary over stdin
5. The binary forks — the parent returns immediately, while the child sends the batch to the Langfuse API via HTTP and logs the result
4. Messages (opencode's flat v2 shape) are piped to the `code-trace` binary over stdin
5. The binary normalizes them into turns and forks — the parent returns immediately, while the child sends the batch to the Langfuse API via HTTP and logs the result

### Pi

Expand Down
4 changes: 2 additions & 2 deletions harness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ NPMRC_FILE="$HOME/.npmrc" docker compose -f harness/docker-compose.yml up --buil
--exit-code-from runner --abort-on-container-exit
```

Leave `NPMRC_FILE` unset (the default) where the registry is directly reachable,
such as CI.
Leave `NPMRC_FILE` unset (the default, an empty committed file — `harness/npmrc.empty`)
where the registry is directly reachable, such as CI.

## Run scenarios without Docker

Expand Down
8 changes: 6 additions & 2 deletions harness/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ services:

# Optional npm credentials for the image build. NPMRC_FILE points at an ~/.npmrc
# to route `npm install` through a private registry on restricted networks;
# unset it (the default empty file) for environments with direct registry
# unset it (the default, an empty file) for environments with direct registry
# access, such as CI. Consumed as a BuildKit build secret — see harness/Dockerfile.
# The default is a committed empty file rather than /dev/null: compose's bake
# integration refuses to read /dev/null without an explicit fs.read allowance,
# which broke CI ("additional privileges requested: pass
# --allow=fs.read=/dev/null"). An empty .npmrc is equivalent for npm.
secrets:
npmrc:
file: ${NPMRC_FILE:-/dev/null}
file: ${NPMRC_FILE:-./npmrc.empty}
Empty file added harness/npmrc.empty
Empty file.
243 changes: 0 additions & 243 deletions plugin/opencode/code-trace.ts

This file was deleted.

Loading
Loading