This is a plugin designed to capture the raw JSON requests sent to the LLM, and the raw JSON responses back after streaming-delta consolidation. It writes pure JSONL for FM-Agent trace collection.
- End users should install it as an npm plugin via
"plugin": ["@lucentia/opencode-trace"]in~/.config/opencode/opencode.json. - Runtime requires both
TRACE_DIRandTRACE_FILENAME.TRACE_DIRmust be an absolute path.TRACE_FILENAMEmust be a basename without path separators; the plugin writes${TRACE_FILENAME}.jsonlinsideTRACE_DIR. - Missing or invalid environment variables, directory creation failures, and write failures are silent. The plugin must not interrupt OpenCode.
- Existing trace files are overwritten when this plugin instance first writes to them, then subsequent rows are appended.
- For development:
npm installonce, and change the plugin line to["/path/to/opencode-trace/index.ts"]. Then each time you edit, runnpm run typecheckandnpm run lint, then exercise it with something likeTRACE_DIR=/tmp TRACE_FILENAME=opencode-trace-test opencode run --dangerously-skip-permissions "why is the sky blue?". It uses the existing OpenCode configuration to pick up already-configured auth. - To deploy, bump version,
npm login,npm publish --dry-run,npm publish. Verify withnpm view "@lucentia/opencode-trace", then test it by installing as above.