`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)
| 6127 | /// the learnings, and performs the save-backs. The CLI renders the local |
| 6128 | /// body's exact lines from the wire-carried per-turn results. |
| 6129 | pub fn agent_explain(args: &super::agent::explain::Explain) -> CliResult<bool> { |
| 6130 | use atomic_agent::turn::session::SessionStore; |
| 6131 | let repo_root = crate::commands::find_repository_root()?; |
| 6132 | let session_store = |
| 6133 | SessionStore::for_repo(&repo_root).map_err(|e| CliError::InvalidRepository { |
| 6134 | reason: format!("Failed to open session store: {}", e), |
| 6135 | })?; |
| 6136 | let session = session_store |
| 6137 | .load(&args.session_id) |
| 6138 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load session: {}", e)))? |
| 6139 | .ok_or_else(|| CliError::InvalidArgument { |
| 6140 | message: format!( |
| 6141 | "Session '{}' not found. Use 'atomic agent status' to see available sessions.", |
| 6142 | args.session_id |
| 6143 | ), |
| 6144 | })?; |
| 6145 | let Some(service_session) = Service::open()? else { |
| 6146 | return Ok(false); |
| 6147 | }; |
| 6148 | let request = pb::ExplainTurnsRequest { |
| 6149 | repository: Some(service_session.reference.clone()), |
| 6150 | meta: request_meta(), |
| 6151 | session_id: args.session_id.clone(), |
| 6152 | turn: args.turn, |
| 6153 | all: args.all, |
| 6154 | save: args.save, |
| 6155 | model: args.model.clone(), |
| 6156 | view_name: session.view_name.clone(), |
| 6157 | transcript_path: session |
| 6158 | .transcript_path |
| 6159 | .as_ref() |
| 6160 | .map(|path| path.display().to_string()), |
| 6161 | files_touched: session.files_touched.clone(), |
| 6162 | agent_name: session.agent_name.clone(), |
| 6163 | }; |
| 6164 | let response = service_session.explain_turns(request)?; |
| 6165 | |
| 6166 | if response.session_has_no_turns { |
| 6167 | println!( |
| 6168 | "Session '{}' has no recorded turns on view '{}'.", |
| 6169 | args.session_id, session.view_name, |
| 6170 | ); |
| 6171 | return Ok(true); |
| 6172 | } |
| 6173 | |
| 6174 | // The Claude CLI availability check — the local body's exact early-out. |
| 6175 | let generator = atomic_agent::transcript::ClaudeCliGenerator::new().with_model(&args.model); |
| 6176 | use atomic_agent::transcript::ReasoningGenerator as _; |
| 6177 | if !generator.is_available() { |
| 6178 | crate::output::print_error( |
| 6179 | "Claude CLI not found. Install from https://docs.anthropic.com/en/docs/claude-code", |
| 6180 | ); |
| 6181 | println!(); |
| 6182 | println!("The 'explain' command uses Claude CLI to generate reasoning summaries."); |
| 6183 | println!("Make sure 'claude' is in your PATH and authenticated."); |
| 6184 | return Ok(true); |
| 6185 | } |
| 6186 |
no test coverage detected