copilot

package
v1.135.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package copilot captures GitHub Copilot sessions, from Copilot CLI and from the Copilot agent in VS Code, through the Copilot hook files and the session event log that Copilot keeps on disk.

Index

Constants

View Source
const Name = "copilot"

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 {
	// contains filtered or unexported fields
}

Provider connects GitHub Copilot to Trace. It holds no session state.

func New

func New() *Provider

New creates a Copilot provider.

func (*Provider) AnnouncePromptSubmit

func (p *Provider) AnnouncePromptSubmit(string) error

AnnouncePromptSubmit does nothing: Copilot drops the output of the hook.

func (*Provider) AnnounceSessionStart

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

AnnounceSessionStart shows the banner to the user and gives the instruction to the model.

func (*Provider) AnnounceToUser

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

AnnounceToUser shows the message to the user as a progress line. The model gets no copy: it would show the message to the user a second time.

func (*Provider) CaptureFileSnapshot

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

CaptureFileSnapshot stores the content of input.FilePath before a file tool runs. A missing file (a new file) is not an error.

func (*Provider) CleanupAfterEdit

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

CleanupAfterEdit deletes the snapshot of the edit.

func (*Provider) CopySessionData

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

CopySessionData refreshes the private copy of the session event log. The copy is atomic, so a failed copy keeps the previous one. A missing log is not an error. Only files inside the Copilot session-state folder are read.

func (*Provider) HooksInstalled

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

HooksInstalled reports whether the hook file holds a Chainloop hook.

func (*Provider) InstallHooks

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

InstallHooks writes the Trace hook file.

func (*Provider) InstallHooksForTraceRun

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

InstallHooksForTraceRun writes the hook file without session end. trace run ends the session itself, and it restores the previous file after the run, so it can replace a file that Trace does not own.

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 writes one file.

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 returns the folders of the skills that the session loaded since the last call, from the live event log. It reads only a log inside the Copilot session-state folder, and never fails.

func (*Provider) ParseSession

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

ParseSession reads only the private copy of the event log. Unknown event types stay in the raw session, because the format can change.

func (*Provider) PastedImages

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

PastedImages returns each distinct image that the user attached to a message. An image that a tool gave the model, such as a view of an image file, is not a pasted image (spec issue-3800 R-009).

func (*Provider) ReadHookInput

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

ReadHookInput reads a Copilot hook payload in either form.

The pre-tool payload of a batch of calls cannot pair one call with its post-tool payload, so the input never carries a tool call ID, also when the post-tool payload has one. The pre and post hooks of a shell tool then share the snapshot key of the session (TRC-006).

func (*Provider) ReplaceSpecCopies

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

ReplaceSpecCopies replaces each exact copy of a stored source with a pointer to its material: the full view or shell read of a source file, the text of a create call or of a patch that adds one file, and the data of an image that the user attached. Partial reads, changed content, failed tool calls, and data that cannot be decoded stay inline (spec issue-3800 R-009).

func (*Provider) ResolveBeforeContent

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

ResolveBeforeContent returns the snapshot that CaptureFileSnapshot saved.

func (*Provider) SessionSkills

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

SessionSkills reads the skills from the private copy of the event log. Only a skill.invoked event counts as a use: Copilot writes it when it loads a skill into the session, not when it lists the skills (spec issue-3800 R-008).

func (*Provider) SettingsFile

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

SettingsFile returns the absolute path of the hook file that Trace owns.

func (*Provider) SkillRoots

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

SkillRoots returns the skill folders that Copilot reads, which tell where a skill came from. Copilot reads project skills in .github/skills, .agents/skills and .claude/skills, all under the repository.

func (*Provider) SupportsPromptReminder

func (p *Provider) SupportsPromptReminder() bool

SupportsPromptReminder is false: Copilot drops the output of a userPromptSubmitted command hook.

func (*Provider) SupportsSessionStartBanner

func (p *Provider) SupportsSessionStartBanner() bool

SupportsSessionStartBanner is true: Copilot shows the progress messages of a hook to the user.

func (*Provider) SupportsSessionStartInstruction

func (p *Provider) SupportsSessionStartInstruction() bool

SupportsSessionStartInstruction is true: Copilot adds the additionalContext of a sessionStart hook to the session.

func (*Provider) UninstallHooks

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

UninstallHooks deletes the hook file, but only when every hook in it is a Chainloop hook. Other hook files are never touched.

Jump to

Keyboard shortcuts

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