Compare commits
1 Commits
rcc/runtim
...
rcc/doctor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b200198df7 |
@@ -133,7 +133,6 @@ Inside the REPL, useful commands include:
|
||||
/diff
|
||||
/version
|
||||
/export notes.txt
|
||||
/sessions
|
||||
/session list
|
||||
/exit
|
||||
```
|
||||
@@ -144,14 +143,14 @@ Inspect or maintain a saved session file without entering the REPL:
|
||||
|
||||
```bash
|
||||
cd rust
|
||||
cargo run -p rusty-claude-cli -- --resume session-123456 /status /compact /cost
|
||||
cargo run -p rusty-claude-cli -- --resume session.json /status /compact /cost
|
||||
```
|
||||
|
||||
You can also inspect memory/config state for a restored session:
|
||||
|
||||
```bash
|
||||
cd rust
|
||||
cargo run -p rusty-claude-cli -- --resume ~/.claude/sessions/session-123456.json /memory /config
|
||||
cargo run -p rusty-claude-cli -- --resume session.json /memory /config
|
||||
```
|
||||
|
||||
## Available commands
|
||||
@@ -159,7 +158,7 @@ cargo run -p rusty-claude-cli -- --resume ~/.claude/sessions/session-123456.json
|
||||
### Top-level CLI commands
|
||||
|
||||
- `prompt <text...>` — run one prompt non-interactively
|
||||
- `--resume <session-id-or-path> [/commands...]` — inspect or maintain a saved session stored under `~/.claude/sessions/`
|
||||
- `--resume <session.json> [/commands...]` — inspect or maintain a saved session
|
||||
- `dump-manifests` — print extracted upstream manifest counts
|
||||
- `bootstrap-plan` — print the current bootstrap skeleton
|
||||
- `system-prompt [--cwd PATH] [--date YYYY-MM-DD]` — render the synthesized system prompt
|
||||
@@ -177,14 +176,13 @@ cargo run -p rusty-claude-cli -- --resume ~/.claude/sessions/session-123456.json
|
||||
- `/permissions [read-only|workspace-write|danger-full-access]` — inspect or switch permissions
|
||||
- `/clear [--confirm]` — clear the current local session
|
||||
- `/cost` — show token usage totals
|
||||
- `/resume <session-id-or-path>` — load a saved session into the REPL
|
||||
- `/resume <session-path>` — load a saved session into the REPL
|
||||
- `/config [env|hooks|model]` — inspect discovered Claude config
|
||||
- `/memory` — inspect loaded instruction memory files
|
||||
- `/init` — create a starter `CLAUDE.md`
|
||||
- `/diff` — show the current git diff for the workspace
|
||||
- `/version` — print version and build metadata locally
|
||||
- `/export [file]` — export the current conversation transcript
|
||||
- `/sessions` — list recent managed local sessions from `~/.claude/sessions/`
|
||||
- `/session [list|switch <session-id>]` — inspect or switch managed local sessions
|
||||
- `/exit` — leave the REPL
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ const SLASH_COMMAND_SPECS: &[SlashCommandSpec] = &[
|
||||
SlashCommandSpec {
|
||||
name: "resume",
|
||||
summary: "Load a saved session into the REPL",
|
||||
argument_hint: Some("<session-id-or-path>"),
|
||||
argument_hint: Some("<session-path>"),
|
||||
resume_supported: false,
|
||||
},
|
||||
SlashCommandSpec {
|
||||
@@ -129,12 +129,6 @@ const SLASH_COMMAND_SPECS: &[SlashCommandSpec] = &[
|
||||
argument_hint: Some("[list|switch <session-id>]"),
|
||||
resume_supported: false,
|
||||
},
|
||||
SlashCommandSpec {
|
||||
name: "sessions",
|
||||
summary: "List recent managed local sessions",
|
||||
argument_hint: None,
|
||||
resume_supported: false,
|
||||
},
|
||||
];
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -169,7 +163,6 @@ pub enum SlashCommand {
|
||||
action: Option<String>,
|
||||
target: Option<String>,
|
||||
},
|
||||
Sessions,
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
@@ -214,7 +207,6 @@ impl SlashCommand {
|
||||
action: parts.next().map(ToOwned::to_owned),
|
||||
target: parts.next().map(ToOwned::to_owned),
|
||||
},
|
||||
"sessions" => Self::Sessions,
|
||||
other => Self::Unknown(other.to_string()),
|
||||
})
|
||||
}
|
||||
@@ -299,7 +291,6 @@ pub fn handle_slash_command(
|
||||
| SlashCommand::Version
|
||||
| SlashCommand::Export { .. }
|
||||
| SlashCommand::Session { .. }
|
||||
| SlashCommand::Sessions
|
||||
| SlashCommand::Unknown(_) => None,
|
||||
}
|
||||
}
|
||||
@@ -374,10 +365,6 @@ mod tests {
|
||||
target: Some("abc123".to_string())
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
SlashCommand::parse("/sessions"),
|
||||
Some(SlashCommand::Sessions)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -391,7 +378,7 @@ mod tests {
|
||||
assert!(help.contains("/permissions [read-only|workspace-write|danger-full-access]"));
|
||||
assert!(help.contains("/clear [--confirm]"));
|
||||
assert!(help.contains("/cost"));
|
||||
assert!(help.contains("/resume <session-id-or-path>"));
|
||||
assert!(help.contains("/resume <session-path>"));
|
||||
assert!(help.contains("/config [env|hooks|model]"));
|
||||
assert!(help.contains("/memory"));
|
||||
assert!(help.contains("/init"));
|
||||
@@ -399,8 +386,7 @@ mod tests {
|
||||
assert!(help.contains("/version"));
|
||||
assert!(help.contains("/export [file]"));
|
||||
assert!(help.contains("/session [list|switch <session-id>]"));
|
||||
assert!(help.contains("/sessions"));
|
||||
assert_eq!(slash_command_specs().len(), 16);
|
||||
assert_eq!(slash_command_specs().len(), 15);
|
||||
assert_eq!(resume_supported_slash_commands().len(), 11);
|
||||
}
|
||||
|
||||
@@ -418,7 +404,6 @@ mod tests {
|
||||
text: "recent".to_string(),
|
||||
}]),
|
||||
],
|
||||
metadata: None,
|
||||
};
|
||||
|
||||
let result = handle_slash_command(
|
||||
@@ -483,6 +468,5 @@ mod tests {
|
||||
assert!(
|
||||
handle_slash_command("/session list", &session, CompactionConfig::default()).is_none()
|
||||
);
|
||||
assert!(handle_slash_command("/sessions", &session, CompactionConfig::default()).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@ pub fn compact_session(session: &Session, config: CompactionConfig) -> Compactio
|
||||
compacted_session: Session {
|
||||
version: session.version,
|
||||
messages: compacted_messages,
|
||||
metadata: session.metadata.clone(),
|
||||
},
|
||||
removed_message_count: removed.len(),
|
||||
}
|
||||
@@ -394,7 +393,6 @@ mod tests {
|
||||
let session = Session {
|
||||
version: 1,
|
||||
messages: vec![ConversationMessage::user_text("hello")],
|
||||
metadata: None,
|
||||
};
|
||||
|
||||
let result = compact_session(&session, CompactionConfig::default());
|
||||
@@ -422,7 +420,6 @@ mod tests {
|
||||
usage: None,
|
||||
},
|
||||
],
|
||||
metadata: None,
|
||||
};
|
||||
|
||||
let result = compact_session(
|
||||
|
||||
@@ -73,9 +73,7 @@ pub use remote::{
|
||||
RemoteSessionContext, UpstreamProxyBootstrap, UpstreamProxyState, DEFAULT_REMOTE_BASE_URL,
|
||||
DEFAULT_SESSION_TOKEN_PATH, DEFAULT_SYSTEM_CA_BUNDLE, NO_PROXY_HOSTS, UPSTREAM_PROXY_ENV_KEYS,
|
||||
};
|
||||
pub use session::{
|
||||
ContentBlock, ConversationMessage, MessageRole, Session, SessionError, SessionMetadata,
|
||||
};
|
||||
pub use session::{ContentBlock, ConversationMessage, MessageRole, Session, SessionError};
|
||||
pub use usage::{
|
||||
format_usd, pricing_for_model, ModelPricing, TokenUsage, UsageCostEstimate, UsageTracker,
|
||||
};
|
||||
|
||||
@@ -39,19 +39,10 @@ pub struct ConversationMessage {
|
||||
pub usage: Option<TokenUsage>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SessionMetadata {
|
||||
pub started_at: String,
|
||||
pub model: String,
|
||||
pub message_count: u32,
|
||||
pub last_prompt: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Session {
|
||||
pub version: u32,
|
||||
pub messages: Vec<ConversationMessage>,
|
||||
pub metadata: Option<SessionMetadata>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -91,7 +82,6 @@ impl Session {
|
||||
Self {
|
||||
version: 1,
|
||||
messages: Vec::new(),
|
||||
metadata: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +111,6 @@ impl Session {
|
||||
.collect(),
|
||||
),
|
||||
);
|
||||
if let Some(metadata) = &self.metadata {
|
||||
object.insert("metadata".to_string(), metadata.to_json());
|
||||
}
|
||||
JsonValue::Object(object)
|
||||
}
|
||||
|
||||
@@ -144,15 +131,7 @@ impl Session {
|
||||
.iter()
|
||||
.map(ConversationMessage::from_json)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let metadata = object
|
||||
.get("metadata")
|
||||
.map(SessionMetadata::from_json)
|
||||
.transpose()?;
|
||||
Ok(Self {
|
||||
version,
|
||||
messages,
|
||||
metadata,
|
||||
})
|
||||
Ok(Self { version, messages })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,41 +141,6 @@ impl Default for Session {
|
||||
}
|
||||
}
|
||||
|
||||
impl SessionMetadata {
|
||||
#[must_use]
|
||||
pub fn to_json(&self) -> JsonValue {
|
||||
let mut object = BTreeMap::new();
|
||||
object.insert(
|
||||
"started_at".to_string(),
|
||||
JsonValue::String(self.started_at.clone()),
|
||||
);
|
||||
object.insert("model".to_string(), JsonValue::String(self.model.clone()));
|
||||
object.insert(
|
||||
"message_count".to_string(),
|
||||
JsonValue::Number(i64::from(self.message_count)),
|
||||
);
|
||||
if let Some(last_prompt) = &self.last_prompt {
|
||||
object.insert(
|
||||
"last_prompt".to_string(),
|
||||
JsonValue::String(last_prompt.clone()),
|
||||
);
|
||||
}
|
||||
JsonValue::Object(object)
|
||||
}
|
||||
|
||||
fn from_json(value: &JsonValue) -> Result<Self, SessionError> {
|
||||
let object = value.as_object().ok_or_else(|| {
|
||||
SessionError::Format("session metadata must be an object".to_string())
|
||||
})?;
|
||||
Ok(Self {
|
||||
started_at: required_string(object, "started_at")?,
|
||||
model: required_string(object, "model")?,
|
||||
message_count: required_u32(object, "message_count")?,
|
||||
last_prompt: optional_string(object, "last_prompt"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ConversationMessage {
|
||||
#[must_use]
|
||||
pub fn user_text(text: impl Into<String>) -> Self {
|
||||
@@ -424,13 +368,6 @@ fn required_string(
|
||||
.ok_or_else(|| SessionError::Format(format!("missing {key}")))
|
||||
}
|
||||
|
||||
fn optional_string(object: &BTreeMap<String, JsonValue>, key: &str) -> Option<String> {
|
||||
object
|
||||
.get(key)
|
||||
.and_then(JsonValue::as_str)
|
||||
.map(ToOwned::to_owned)
|
||||
}
|
||||
|
||||
fn required_u32(object: &BTreeMap<String, JsonValue>, key: &str) -> Result<u32, SessionError> {
|
||||
let value = object
|
||||
.get(key)
|
||||
@@ -441,8 +378,7 @@ fn required_u32(object: &BTreeMap<String, JsonValue>, key: &str) -> Result<u32,
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{ContentBlock, ConversationMessage, MessageRole, Session, SessionMetadata};
|
||||
use crate::json::JsonValue;
|
||||
use super::{ContentBlock, ConversationMessage, MessageRole, Session};
|
||||
use crate::usage::TokenUsage;
|
||||
use std::fs;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
@@ -450,12 +386,6 @@ mod tests {
|
||||
#[test]
|
||||
fn persists_and_restores_session_json() {
|
||||
let mut session = Session::new();
|
||||
session.metadata = Some(SessionMetadata {
|
||||
started_at: "2026-04-01T00:00:00Z".to_string(),
|
||||
model: "claude-sonnet".to_string(),
|
||||
message_count: 3,
|
||||
last_prompt: Some("hello".to_string()),
|
||||
});
|
||||
session
|
||||
.messages
|
||||
.push(ConversationMessage::user_text("hello"));
|
||||
@@ -498,23 +428,5 @@ mod tests {
|
||||
restored.messages[1].usage.expect("usage").total_tokens(),
|
||||
17
|
||||
);
|
||||
assert_eq!(restored.metadata, session.metadata);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loads_legacy_session_without_metadata() {
|
||||
let legacy = r#"{
|
||||
"version": 1,
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"blocks": [{"type": "text", "text": "hello"}]
|
||||
}
|
||||
]
|
||||
}"#;
|
||||
let restored = Session::from_json(&JsonValue::parse(legacy).expect("legacy json"))
|
||||
.expect("legacy session should parse");
|
||||
assert_eq!(restored.messages.len(), 1);
|
||||
assert!(restored.metadata.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,6 @@ mod tests {
|
||||
cache_read_input_tokens: 0,
|
||||
}),
|
||||
}],
|
||||
metadata: None,
|
||||
};
|
||||
|
||||
let tracker = UsageTracker::from_session(&session);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user