Documentation
¶
Overview ¶
Package amp provides an adapter for Amp Code that reads thread JSON files from ~/.local/share/amp/threads/.
Index ¶
- func NewWatcher(threadsDir string) (<-chan adapter.Event, io.Closer, error)
- type Adapter
- func (a *Adapter) Capabilities() adapter.CapabilitySet
- func (a *Adapter) Detect(projectRoot string) (bool, error)
- func (a *Adapter) ID() string
- func (a *Adapter) Icon() string
- func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)
- func (a *Adapter) Name() string
- func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)
- func (a *Adapter) SessionByID(sessionID string) (*adapter.Session, error)
- func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)
- func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)
- func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)
- func (a *Adapter) WatchScope() adapter.WatchScope
- type ContentBlock
- type Env
- type EnvInitial
- type Message
- type MessageMeta
- type MessageState
- type Platform
- type Repository
- type SubBlock
- type Thread
- type ToolResult
- type ToolRun
- type Tree
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements the adapter.Adapter interface for Amp Code threads.
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() adapter.CapabilitySet
Capabilities returns the supported features.
func (*Adapter) SearchMessages ¶
func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)
SearchMessages searches message content within a session. Implements adapter.MessageSearcher interface.
func (*Adapter) SessionByID ¶
SessionByID returns a single session by ID without scanning the directory. Implements adapter.TargetedRefresher.
func (*Adapter) Sessions ¶
Sessions returns all sessions for the given project, sorted by update time.
func (*Adapter) Usage ¶
func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)
Usage returns aggregate usage stats for the given session.
func (*Adapter) WatchScope ¶
func (a *Adapter) WatchScope() adapter.WatchScope
WatchScope returns Global because amp watches a global threads directory.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"` // "text", "thinking", "tool_use", "tool_result"
// Text block fields
Text string `json:"text,omitempty"`
// Thinking block fields
Thinking string `json:"thinking,omitempty"`
Signature string `json:"signature,omitempty"`
Provider string `json:"provider,omitempty"`
// Tool use fields
Complete bool `json:"complete,omitempty"`
BlockID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
// Tool result fields
ToolUseID string `json:"toolUseID,omitempty"`
Run *ToolRun `json:"run,omitempty"`
Content_ []SubBlock `json:"content,omitempty"` // Nested content for tool results
}
ContentBlock represents a content block in an Amp message.
type Env ¶
type Env struct {
Initial *EnvInitial `json:"initial,omitempty"`
}
Env holds environment information for the thread.
type EnvInitial ¶
type EnvInitial struct {
Trees []Tree `json:"trees,omitempty"`
Platform *Platform `json:"platform,omitempty"`
}
EnvInitial holds initial environment info including workspace trees.
type Message ¶
type Message struct {
Role string `json:"role"` // "user" or "assistant"
MessageID int `json:"messageId"`
Content []ContentBlock `json:"content"`
State *MessageState `json:"state,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Meta *MessageMeta `json:"meta,omitempty"`
}
Message represents a message in an Amp thread.
type MessageMeta ¶
type MessageMeta struct {
SentAt int64 `json:"sentAt,omitempty"` // Unix millis
}
MessageMeta holds metadata for user messages.
func (*MessageMeta) SentAtTime ¶
func (m *MessageMeta) SentAtTime() time.Time
SentAtTime returns the sentAt time.
type MessageState ¶
type MessageState struct {
Type string `json:"type,omitempty"`
StopReason string `json:"stopReason,omitempty"`
}
MessageState indicates the completion state of an assistant message.
type Platform ¶
type Platform struct {
OS string `json:"os,omitempty"`
Client string `json:"client,omitempty"`
ClientVersion string `json:"clientVersion,omitempty"`
}
Platform holds platform information.
type Repository ¶
type Repository struct {
URL string `json:"url,omitempty"`
Ref string `json:"ref,omitempty"`
SHA string `json:"sha,omitempty"`
}
Repository holds git repository info for a tree.
type Thread ¶
type Thread struct {
V int `json:"v"`
ID string `json:"id"`
Created int64 `json:"created"` // Unix millis
Messages []Message `json:"messages"`
Env *Env `json:"env,omitempty"`
}
Thread represents a top-level Amp thread from threads/T-{uuid}.json.
func (*Thread) CreatedTime ¶
CreatedTime returns the thread creation time.
type ToolResult ¶
type ToolResult struct {
Output string `json:"output,omitempty"`
ExitCode int `json:"exitCode,omitempty"`
}
ToolResult holds the output of a tool execution (dict form).
type ToolRun ¶
type ToolRun struct {
Status string `json:"status,omitempty"`
Result json.RawMessage `json:"result,omitempty"` // Can be {output,exitCode}, []string, or string
}
ToolRun holds the result of a tool execution.
func (*ToolRun) ParseResult ¶
ParseResult tries to extract output text and exit code from the polymorphic result field.
type Tree ¶
type Tree struct {
DisplayName string `json:"displayName,omitempty"`
URI string `json:"uri,omitempty"` // file:// URI
Repository *Repository `json:"repository,omitempty"`
}
Tree represents a workspace tree (project) in the Amp environment.
type Usage ¶
type Usage struct {
Model string `json:"model,omitempty"`
InputTokens int `json:"inputTokens,omitempty"`
OutputTokens int `json:"outputTokens,omitempty"`
CacheCreationInputTokens int `json:"cacheCreationInputTokens,omitempty"`
CacheReadInputTokens int `json:"cacheReadInputTokens,omitempty"`
TotalInputTokens int `json:"totalInputTokens,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
}
Usage holds per-message token usage information.