{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.108.2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package opencode\n\n## Constants\n\n```go\nconst Name = \"opencode\"\n```\nName is the provider identifier emitted to evidence and used as the key in SessionRecord.Provider. Kept as an exported constant so CLI wiring can refer to it without instantiating the provider.\n\n## Types\n\n```go\ntype Provider struct{}\n```\nProvider implements trace.Provider for opencode sessions.\n\n```go\nfunc New() *Provider\n```\nNew creates a new opencode provider.\n\n```go\nfunc (p *Provider) CaptureFileSnapshot(store *state.Store, input *trace.HookInput) error\n```\nCaptureFileSnapshot reads the file at input.FilePath and stores its content under the store's snapshots/ directory so the post-tool-use handler can compute line-range diffs after the edit. A missing file (e.g. write creating a new file) is treated as a non-error.\n\n```go\nfunc (p *Provider) CleanupAfterEdit(store *state.Store, input *trace.HookInput)\n```\nCleanupAfterEdit removes the per-edit snapshot.\n\n```go\nfunc (p *Provider) CopySessionData(store *state.Store, _, sessionID string) error\n```\nCopySessionData runs \\`opencode export \\\u003csessionID\u003e\\` and streams the JSON output directly to the store's raw/\\\u003csanitized-id\u003e.jsonl so pre-push can parse it independently of opencode's own storage. stdout is redirected to the destination file rather than a pipe: opencode (Node.js) doesn't reliably flush stdout to pipes, causing truncation at pipe buffer boundaries, but a regular file destination is safe. Fails gracefully (returns nil) when the opencode binary is missing or the export fails — the session is skipped rather than blocking the push, and any partially-written file is removed.\n\n```go\nfunc (p *Provider) DiscoverSession(repoRoot string) (*trace.DiscoveredSession, error)\n```\nDiscoverSession finds the most recent opencode session for the given repo root. Returns nil, nil if no matching session is found or the opencode binary is unavailable.\n\n```go\nfunc (p *Provider) InstallHooks(repoRoot string) error\n```\nInstallHooks writes the opencode plugin file with all hooks including session.deleted.\n\n```go\nfunc (p *Provider) InstallHooksForTraceRun(repoRoot string) error\n```\nInstallHooksForTraceRun writes the plugin file without the session.deleted handler; trace run drives end-of-session itself.\n\n```go\nfunc (p *Provider) IsCommandTool(toolName string) bool\n```\nIsCommandTool returns true if the named tool runs a shell command.\n\n```go\nfunc (p *Provider) IsFileWritingTool(toolName string) bool\n```\nIsFileWritingTool returns true if the named tool modifies files on disk.\n\n```go\nfunc (p *Provider) Name() string\n```\nName returns the agent identifier.\n\n```go\nfunc (p *Provider) ParseSession(_ context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)\n```\nParseSession reads the copied export JSON for sessionID and returns structured evidence.\n\n```go\nfunc (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)\n```\nReadHookInput reads and parses the opencode hook JSON from the given reader. The plugin pipes JSON to stdin with fields: session\\_id, hook\\_event\\_name, tool\\_name, file\\_path.\n\n```go\nfunc (p *Provider) ResolveBeforeContent(store *state.Store, input *trace.HookInput, _ []byte) []byte\n```\nResolveBeforeContent returns the snapshot saved by CaptureFileSnapshot.\n\n```go\nfunc (p *Provider) SessionDirForRepo(_ string) string\n```\nSessionDirForRepo returns \"\" for opencode — sessions are stored in a SQLite database, not a per-repo directory. The method exists to satisfy the interface; callers use CopySessionData for the actual data extraction.\n\n```go\nfunc (p *Provider) SettingsFile(repoRoot string) string\n```\nSettingsFile returns the absolute path to the plugin file for the given repo.\n\n```go\nfunc (p *Provider) SystemMessage(_ string) error\n```\nSystemMessage is a no-op for opencode: the plugin system has no systemMessage channel comparable to Claude Code's SessionStart output.\n\n```go\nfunc (p *Provider) UninstallHooks(repoRoot string) error\n```\nUninstallHooks removes the plugin file. The plugin file is entirely chainloop-owned, so we remove it without preserving content.\n\n","path":"github.com/chainloop-dev/chainloop/app/cli/internal/trace/opencode","name":"opencode","synopsis":"","isRedistributable":true}
