summaryrefslogtreecommitdiff
path: root/makima/daemon/src/process/claude_protocol.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-11 05:52:14 +0000
committersoryu <soryu@soryu.co>2026-01-15 00:21:16 +0000
commit87044a747b47bd83249d61a45842c7f7b2eae56d (patch)
treeef2000ce79ffcc2723ef841acef5aa1deb1d5378 /makima/daemon/src/process/claude_protocol.rs
parent077820c4167c168072d217a1b01df840463a12a8 (diff)
downloadsoryu-87044a747b47bd83249d61a45842c7f7b2eae56d.tar.gz
soryu-87044a747b47bd83249d61a45842c7f7b2eae56d.zip
Contract system
Diffstat (limited to 'makima/daemon/src/process/claude_protocol.rs')
-rw-r--r--makima/daemon/src/process/claude_protocol.rs59
1 files changed, 0 insertions, 59 deletions
diff --git a/makima/daemon/src/process/claude_protocol.rs b/makima/daemon/src/process/claude_protocol.rs
deleted file mode 100644
index 930152b..0000000
--- a/makima/daemon/src/process/claude_protocol.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-//! Claude Code JSON protocol types for stdin communication.
-//!
-//! When using `--input-format=stream-json`, Claude Code expects
-//! newline-delimited JSON messages on stdin.
-
-use serde::Serialize;
-
-/// Message sent to Claude Code via stdin.
-///
-/// Format based on Claude Code's stream-json input protocol.
-#[derive(Debug, Clone, Serialize)]
-#[serde(tag = "type", rename_all = "snake_case")]
-pub enum ClaudeInputMessage {
- /// A user message to send to Claude.
- User { message: UserMessage },
-}
-
-/// The inner user message structure.
-#[derive(Debug, Clone, Serialize)]
-pub struct UserMessage {
- /// Always "user" for user messages.
- pub role: String,
- /// The message content.
- pub content: String,
-}
-
-impl ClaudeInputMessage {
- /// Create a new user message.
- pub fn user(content: impl Into<String>) -> Self {
- Self::User {
- message: UserMessage {
- role: "user".to_string(),
- content: content.into(),
- },
- }
- }
-
- /// Serialize to a JSON string with trailing newline (NDJSON format).
- pub fn to_json_line(&self) -> Result<String, serde_json::Error> {
- let mut json = serde_json::to_string(self)?;
- json.push('\n');
- Ok(json)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn test_user_message_serialization() {
- let msg = ClaudeInputMessage::user("Hello, Claude!");
- let json = msg.to_json_line().unwrap();
-
- // Should produce: {"type":"user","message":{"role":"user","content":"Hello, Claude!"}}\n
- assert!(json.starts_with(r#"{"type":"user","message":{"role":"user","content":"Hello, Claude!"}}"#));
- assert!(json.ends_with('\n'));
- }
-}