MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / agent_explain

Function agent_explain

atomic-cli/src/commands/rpc.rs:6169–6317  ·  view source on GitHub ↗

`atomic agent explain` over ExplainTurns — the session record resolves CLIENT-SIDE (the session store is a working-copy file read, not redb) and its fields ride the request; the handler loads the turns, extracts the transcripts, generates the reasoning via the Claude CLI, anchors the learnings, and performs the save-backs. The CLI renders the local body's exact lines from the wire-carried per-turn

(args: &super::agent::explain::Explain)

Source from the content-addressed store, hash-verified

6167/// the learnings, and performs the save-backs. The CLI renders the local
6168/// body's exact lines from the wire-carried per-turn results.
6169pub fn agent_explain(args: &super::agent::explain::Explain) -> CliResult<bool> {
6170 use atomic_agent::turn::session::SessionStore;
6171 let repo_root = crate::commands::find_repository_root()?;
6172 let session_store =
6173 SessionStore::for_repo(&repo_root).map_err(|e| CliError::InvalidRepository {
6174 reason: format!("Failed to open session store: {}", e),
6175 })?;
6176 let session = session_store
6177 .load(&args.session_id)
6178 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load session: {}", e)))?
6179 .ok_or_else(|| CliError::InvalidArgument {
6180 message: format!(
6181 "Session '{}' not found. Use 'atomic agent status' to see available sessions.",
6182 args.session_id
6183 ),
6184 })?;
6185 let Some(service_session) = Service::open()? else {
6186 return Ok(false);
6187 };
6188 let request = pb::ExplainTurnsRequest {
6189 repository: Some(service_session.reference.clone()),
6190 meta: request_meta(),
6191 session_id: args.session_id.clone(),
6192 turn: args.turn,
6193 all: args.all,
6194 save: args.save,
6195 model: args.model.clone(),
6196 view_name: session.view_name.clone(),
6197 transcript_path: session
6198 .transcript_path
6199 .as_ref()
6200 .map(|path| path.display().to_string()),
6201 files_touched: session.files_touched.clone(),
6202 agent_name: session.agent_name.clone(),
6203 };
6204 let response = service_session.explain_turns(request)?;
6205
6206 if response.session_has_no_turns {
6207 println!(
6208 "Session '{}' has no recorded turns on view '{}'.",
6209 args.session_id, session.view_name,
6210 );
6211 return Ok(true);
6212 }
6213
6214 // The Claude CLI availability check — the local body's exact early-out.
6215 let generator = atomic_agent::transcript::ClaudeCliGenerator::new().with_model(&args.model);
6216 use atomic_agent::transcript::ReasoningGenerator as _;
6217 if !generator.is_available() {
6218 crate::output::print_error(
6219 "Claude CLI not found. Install from https://docs.anthropic.com/en/docs/claude-code",
6220 );
6221 println!();
6222 println!("The 'explain' command uses Claude CLI to generate reasoning summaries.");
6223 println!("Make sure 'claude' is in your PATH and authenticated.");
6224 return Ok(true);
6225 }
6226

Callers 1

runMethod · 0.85

Calls 15

find_repository_rootFunction · 0.85
print_errorFunction · 0.85
print_warningFunction · 0.85
print_reasoningFunction · 0.85
full_hashFunction · 0.85
print_successFunction · 0.85
context_file_for_agentFunction · 0.85
as_refMethod · 0.80
displayMethod · 0.80
with_modelMethod · 0.80
is_noneMethod · 0.80
request_metaFunction · 0.70

Tested by

no test coverage detected