Documentation
¶
Overview ¶
Package sessions finds the conversations agents saved for a directory, so conch can list and resume them. Each agent keeps its own store; this package only reads them:
- Claude Code: ~/.claude/projects/<encoded dir>/<session id>.jsonl
- Codex: ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl (session_meta first)
- Gemini CLI: ~/.gemini/tmp/<project>/chats/session-*.json
- OpenCode: ~/.local/share/opencode/opencode.db (sqlite), or the older storage/session/*/*.json files
Index ¶
- func AgentName(agent string) string
- func Delete(ctx context.Context, e Env, s Session, trashDir string) error
- func Handoff(s Session, turns []Turn) string
- func Key(s Session) string
- func Match(ctx context.Context, e Env, list []Session, query string) map[string]string
- type ChatTurn
- type ChatUpdate
- type Env
- type Session
- type Turn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete removes a saved session: files move to trashDir (so a mistake can be undone), OpenCode's database entries are deleted through its CLI.
func Handoff ¶
Handoff renders a conversation as a Markdown document another agent can read to continue the work. Very long messages are cut, and when the whole conversation is too long the oldest messages are left out (the first request is always kept).
Types ¶
type ChatTurn ¶ added in v0.2.0
type ChatTurn struct {
Seq int // its place in the whole conversation, from 0; stable as turns are added
Role string // "user", "assistant", "tool" or "note"
Text string // for a tool, its name
Detail string // for a tool, what it was used on, on one line: a file, a command
Input string // for a tool, what it was given, as a chat shows it
InputKind string // "diff" (lines marked - and +), "code", or "" for text
Output string // for a tool, what came back
Error bool // the tool failed
Done bool // the tool's result has come
Time time.Time
// contains filtered or unexported fields
}
ChatTurn is one entry of a conversation as a chat draws it: something the user typed, something the agent said, a tool it used — with what it was given and what came back — or a note (an interruption).
type ChatUpdate ¶ added in v0.2.0
ChatUpdate is what a chat is sent: the turns that are new or changed since the version it has, or — Reset — the newest turns to start again from, when it has none, or another log's (a new conversation, a file rewritten, a server restarted).
type Session ¶
type Session struct {
Agent string
ID string
Dir string // where it ran
Branch string // when the agent recorded it
Title string
Started time.Time
Updated time.Time
// Path is the agent's session file, or its database (OpenCode).
Path string
// Cost is what the agent said the conversation cost, and Output the
// tokens it generated; both 0 when the store doesn't say. Read from
// the tail of the store, so listing stays cheap.
Cost float64
Output int
}
Session is one saved agent conversation.
func List ¶
List returns the sessions that ran in any of dirs (or below them), newest first, at most limit. It asks every store itself and waits for the answer: callers of this one — search, sharing, usage — want what is there now, not what a store said a moment ago.
func ListStatus ¶ added in v0.1.3
ListStatus is List, and whether every store answered. complete is false when an agent that keeps its sessions behind another program (see slow.go) was too slow: that agent's sessions are missing from the list, which is worth asking for again in a moment.