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

Function parse_user_prompt

atomic-agent/src/hooks/claude_code/parse.rs:201–224  ·  view source on GitHub ↗
(
    agent_name: &str,
    hook_type: HookType,
    raw_json: serde_json::Value,
)

Source from the content-addressed store, hash-verified

199}
200
201fn parse_user_prompt(
202 agent_name: &str,
203 hook_type: HookType,
204 raw_json: serde_json::Value,
205) -> AgentResult<TurnEvent> {
206 let parsed: UserPromptInput =
207 serde_json::from_value(raw_json.clone()).map_err(|e| AgentError::HookParseFailed {
208 agent: agent_name.to_string(),
209 hook_type: hook_type.as_str().to_string(),
210 reason: e.to_string(),
211 })?;
212
213 let mut event =
214 TurnEvent::new(extract_session_id(parsed.session_id), hook_type).with_raw_json(raw_json);
215
216 if let Some(path) = parsed.transcript_path {
217 event = event.with_transcript_path(path);
218 }
219 if let Some(prompt) = parsed.prompt {
220 event = event.with_prompt(prompt);
221 }
222
223 Ok(event)
224}
225
226fn parse_pre_tool(
227 agent_name: &str,

Callers 1

parse_hook_eventFunction · 0.85

Calls 6

extract_session_idFunction · 0.85
with_raw_jsonMethod · 0.80
with_transcript_pathMethod · 0.80
with_promptMethod · 0.80
cloneMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected