Import sesssions (#9474)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -559,9 +559,13 @@ enum SessionCommand {
|
||||
)]
|
||||
relays: Vec<String>,
|
||||
},
|
||||
#[command(about = "Import a session from JSON or an encrypted Nostr share link")]
|
||||
#[command(
|
||||
about = "Import a session from JSON, a Claude Code / Codex / Pi .jsonl, or an encrypted Nostr share link"
|
||||
)]
|
||||
Import {
|
||||
#[arg(help = "Path to a JSON session export, or a goose://sessions/nostr share link")]
|
||||
#[arg(
|
||||
help = "Path to a goose session export, a Claude Code, Codex, or Pi .jsonl transcript, or a goose://sessions/nostr share link"
|
||||
)]
|
||||
input: String,
|
||||
|
||||
#[arg(long = "nostr", help = "Treat input as an encrypted Nostr share link")]
|
||||
|
||||
@@ -300,6 +300,15 @@ pub async fn handle_session_import(input: String, nostr: bool) -> Result<()> {
|
||||
.with_context(|| format!("Failed to read session import file: {input}"))?
|
||||
};
|
||||
|
||||
let format = goose::session::import_formats::detect_format(&json);
|
||||
let label = match format {
|
||||
goose::session::import_formats::ImportFormat::Goose => "goose",
|
||||
goose::session::import_formats::ImportFormat::ClaudeCode => "Claude Code",
|
||||
goose::session::import_formats::ImportFormat::Codex => "Codex",
|
||||
goose::session::import_formats::ImportFormat::Pi => "Pi",
|
||||
};
|
||||
println!("Detected format: {}", label);
|
||||
|
||||
let session_manager = SessionManager::instance();
|
||||
let session = session_manager
|
||||
.import_session(&json, Some(SessionType::User))
|
||||
|
||||
Reference in New Issue
Block a user