Documentation
¶
Index ¶
- Constants
- type Provider
- func (p *Provider) CaptureFileSnapshot(store *state.Store, input *trace.HookInput) error
- func (p *Provider) CleanupAfterEdit(store *state.Store, input *trace.HookInput)
- func (p *Provider) CopySessionData(store *state.Store, _, sessionID string) error
- func (p *Provider) DiscoverSession(repoRoot string) (*trace.DiscoveredSession, error)
- func (p *Provider) InstallHooks(repoRoot string) error
- func (p *Provider) InstallHooksForTraceRun(repoRoot string) error
- func (p *Provider) IsCommandTool(toolName string) bool
- func (p *Provider) IsFileWritingTool(toolName string) bool
- func (p *Provider) Name() string
- func (p *Provider) ParseSession(_ context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)
- func (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)
- func (p *Provider) ResolveBeforeContent(store *state.Store, input *trace.HookInput, _ []byte) []byte
- func (p *Provider) SessionDirForRepo(_ string) string
- func (p *Provider) SettingsFile(repoRoot string) string
- func (p *Provider) SystemMessage(_ string) error
- func (p *Provider) UninstallHooks(repoRoot string) error
Constants ¶
const Name = "opencode"
Name 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.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct{}
Provider implements trace.Provider for opencode sessions.
func (*Provider) CaptureFileSnapshot ¶
CaptureFileSnapshot 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.
func (*Provider) CleanupAfterEdit ¶
CleanupAfterEdit removes the per-edit snapshot.
func (*Provider) CopySessionData ¶
CopySessionData runs `opencode export <sessionID>` and streams the JSON output directly to the store's raw/<sanitized-id>.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.
func (*Provider) DiscoverSession ¶
func (p *Provider) DiscoverSession(repoRoot string) (*trace.DiscoveredSession, error)
DiscoverSession 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.
func (*Provider) InstallHooks ¶
InstallHooks writes the opencode plugin file with all hooks including session.deleted.
func (*Provider) InstallHooksForTraceRun ¶
InstallHooksForTraceRun writes the plugin file without the session.deleted handler; trace run drives end-of-session itself.
func (*Provider) IsCommandTool ¶
IsCommandTool returns true if the named tool runs a shell command.
func (*Provider) IsFileWritingTool ¶
IsFileWritingTool returns true if the named tool modifies files on disk.
func (*Provider) ParseSession ¶
func (p *Provider) ParseSession(_ context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)
ParseSession reads the copied export JSON for sessionID and returns structured evidence.
func (*Provider) ReadHookInput ¶
ReadHookInput 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.
func (*Provider) ResolveBeforeContent ¶
func (p *Provider) ResolveBeforeContent(store *state.Store, input *trace.HookInput, _ []byte) []byte
ResolveBeforeContent returns the snapshot saved by CaptureFileSnapshot.
func (*Provider) SessionDirForRepo ¶
SessionDirForRepo 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.
func (*Provider) SettingsFile ¶
SettingsFile returns the absolute path to the plugin file for the given repo.
func (*Provider) SystemMessage ¶
SystemMessage is a no-op for opencode: the plugin system has no systemMessage channel comparable to Claude Code's SessionStart output.
func (*Provider) UninstallHooks ¶
UninstallHooks removes the plugin file. The plugin file is entirely chainloop-owned, so we remove it without preserving content.