Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions atomic-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rust-version.workspace = true
# Internal crates
atomic-core = { workspace = true }
atomic-repository = { workspace = true }
atomic-canonical = { workspace = true }
atomic-identity = { workspace = true }

# Watchman file watching
Expand Down
58 changes: 58 additions & 0 deletions atomic-agent/src/hooks/sherpa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ struct SherpaHookInput {
/// Used as the atomic record commit message on `turn-end`.
#[serde(default)]
intent_title: Option<String>,

/// Absolute path to the turn's transcript file, when the harness
/// wrote one.
///
/// Sherpa writes Claude Code-shaped JSONL, which is what
/// `format_for_agent("sherpa")` selects. Without this the turn is
/// recorded with a message and a file list but no account of the
/// assistant's replies or its tool calls — the provenance Claude Code
/// and OpenCode turns both carry.
///
/// Aliased because the harness has always sent the field as
/// `trace_file`.
#[serde(default, alias = "trace_file")]
transcript_path: Option<String>,
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -205,6 +219,14 @@ impl AgentHook for SherpaHook {

let mut event = TurnEvent::new(parsed.session_id.clone(), hook_type).with_raw_json(raw);

// Same as Claude Code: whichever hook carries the transcript sets
// it, and the session keeps the first one it sees.
if let Some(path) = &parsed.transcript_path {
if !path.is_empty() {
event = event.with_transcript_path(path.clone());
}
}

// Stamp model and provider so the orchestrator can persist them on
// the AgentSession — same pattern as OpenCode.
if let Some(model) = &parsed.model {
Expand Down Expand Up @@ -342,6 +364,42 @@ mod tests {
assert_eq!(make_hook().display_name(), "Sherpa");
}

// --- transcript_path ---

#[test]
fn test_turn_end_carries_transcript_path() {
let input = br#"{"session_id":"s-1","turn_number":2,"transcript_path":"/w/.atomic/sessions/s-1/turn-1.jsonl"}"#;
let event = make_hook()
.parse_event(HookType::TurnEnd, input)
.expect("parse");
assert_eq!(
event.transcript_path.as_deref(),
Some(std::path::Path::new("/w/.atomic/sessions/s-1/turn-1.jsonl")),
);
}

#[test]
fn test_trace_file_is_accepted_as_an_alias() {
// The harness has always named the field `trace_file`.
let input = br#"{"session_id":"s-1","trace_file":"/w/turn-1.jsonl"}"#;
let event = make_hook()
.parse_event(HookType::TurnEnd, input)
.expect("parse");
assert_eq!(
event.transcript_path.as_deref(),
Some(std::path::Path::new("/w/turn-1.jsonl")),
);
}

#[test]
fn test_transcript_path_absent_stays_none() {
let input = br#"{"session_id":"s-1"}"#;
let event = make_hook()
.parse_event(HookType::TurnEnd, input)
.expect("parse");
assert!(event.transcript_path.is_none());
}

// --- supported_hooks ---

#[test]
Expand Down
Loading
Loading