Help us shape the future of Go! Take the 2026 Go Developer Survey

codex

package
v1.127.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package codex captures sessions from the Codex CLI's native hooks and JSONL rollouts.

Index

Constants

View Source
const Name = "codex"

Name is the identifier stored in session records and evidence.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct{}

Provider connects Codex to Trace. It holds no session state.

func New

func New() *Provider

New creates a Codex provider.

func (*Provider) AnnouncePromptSubmit

func (p *Provider) AnnouncePromptSubmit(reminder string) error

AnnouncePromptSubmit adds the reminder to the model's context.

func (*Provider) AnnounceSessionStart

func (p *Provider) AnnounceSessionStart(msg trace.SessionStartMessage) error

AnnounceSessionStart sends the banner and instruction in one hook response.

func (*Provider) AnnounceToUser

func (p *Provider) AnnounceToUser(msg string) error

AnnounceToUser shows the session link and gives the model context to repeat it.

func (*Provider) CaptureFileSnapshot

func (p *Provider) CaptureFileSnapshot(store *state.Store, input *trace.HookInput) error

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 (a patch creating a new file) is treated as a non-error; other read errors (permission denied, I/O failures) are surfaced.

func (*Provider) CleanupAfterEdit

func (p *Provider) CleanupAfterEdit(store *state.Store, input *trace.HookInput)

CleanupAfterEdit removes the per-edit snapshot. Safe to call when no snapshot was ever taken.

func (*Provider) CopySessionData

func (p *Provider) CopySessionData(store *state.Store, loc trace.SessionLocation) error

CopySessionData refreshes a private transcript copy atomically. A missing transcript leaves the previous copy intact. Only Codex session storage is read.

func (*Provider) HooksInstalled

func (p *Provider) HooksInstalled(repoRoot string) (bool, error)

HooksInstalled reports whether .codex/hooks.json holds any Chainloop hook. User-authored hooks are ignored.

func (*Provider) InstallHooks

func (p *Provider) InstallHooks(repoRoot string) error

InstallHooks adds Chainloop hooks to .codex/hooks.json.

func (*Provider) InstallHooksForTraceRun

func (p *Provider) InstallHooksForTraceRun(repoRoot string) error

InstallHooksForTraceRun installs every hook except SessionEnd; trace run drives end-of-session itself.

func (*Provider) IsCommandTool

func (p *Provider) IsCommandTool(toolName string) bool

IsCommandTool returns true if the named tool runs a shell command.

func (*Provider) IsFileWritingTool

func (p *Provider) IsFileWritingTool(toolName string) bool

IsFileWritingTool returns true if the named tool modifies files on disk.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider identifier.

func (*Provider) NewSkillLoads

func (p *Provider) NewSkillLoads(store *state.Store, input *trace.HookInput) []string

NewSkillLoads recognizes newly completed loads in the live rollout. It validates storage and session identity before returning any skill folder. Pending tool calls are rescanned so a result in the next hook can pair with its original call. The offset counts completed uses, not pending calls.

func (*Provider) ParseSession

func (p *Provider) ParseSession(ctx context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)

ParseSession reads only the private rollout copy. Unknown record types stay in the raw transcript, because the Codex rollout format can evolve.

func (*Provider) PastedImages

func (p *Provider) PastedImages(raw map[string][]json.RawMessage) []trace.PastedImage

PastedImages extracts each distinct user image from native or normalized rollouts. The digest identifies the model-visible bytes, not a file path.

func (*Provider) ReadHookInput

func (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)

ReadHookInput reads and parses the Codex hook JSON from the given reader.

func (*Provider) ReplaceSpecCopies

func (p *Provider) ReplaceSpecCopies(raw map[string][]json.RawMessage, sources pointer.Sources) pointer.Report

ReplaceSpecCopies replaces exact source copies only after material storage. Results and native duplicates use the same digest mapping as viewer messages.

func (*Provider) ResolveBeforeContent

func (p *Provider) ResolveBeforeContent(store *state.Store, input *trace.HookInput, _ []byte) []byte

ResolveBeforeContent returns the snapshot saved by CaptureFileSnapshot. The "after" argument is unused for Codex — we always rely on the pre-edit snapshot — but is part of the interface for providers that reconstruct from edits instead of snapshots.

func (*Provider) SessionSkills

func (p *Provider) SessionSkills(opts *trace.ParseOpts) ([]trace.SkillUse, []string, error)

SessionSkills reads the private rollout copy, never the current agent file.

func (*Provider) SettingsFile

func (p *Provider) SettingsFile(repoRoot string) string

SettingsFile returns the absolute path to .codex/hooks.json for the given repo.

func (*Provider) SkillRoots

func (p *Provider) SkillRoots(repoRoot string) skill.Roots

SkillRoots classifies the filesystem-backed skill scopes known to Codex.

func (*Provider) SupportsPromptReminder

func (p *Provider) SupportsPromptReminder() bool

SupportsPromptReminder reports whether Codex accepts context at each prompt.

func (*Provider) SupportsSessionStartBanner

func (p *Provider) SupportsSessionStartBanner() bool

SupportsSessionStartBanner reports whether Codex shows systemMessage to the user.

func (*Provider) SupportsSessionStartInstruction

func (p *Provider) SupportsSessionStartInstruction() bool

SupportsSessionStartInstruction reports whether Codex accepts startup context.

func (*Provider) UninstallHooks

func (p *Provider) UninstallHooks(repoRoot string) error

UninstallHooks removes Chainloop hooks from .codex/hooks.json.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL