1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! `path p incept` — file/stdin-shaped sibling of `export claude`.
//!
//! `incept --input X --project Y` writes a toolpath document into a
//! Claude session layout under `<project>`. `--input` defaults to
//! stdin so `path p import claude … --no-cache | path p incept
//! --project /tmp/sandbox` composes cleanly; `--project` defaults to
//! the current directory. It's the older surface kept for shell
//! pipelines that prefer that ergonomic over `export claude --input X
//! --project Y`.
use anyhow::Result;
use clap::Args;
use std::path::PathBuf;
#[derive(Args, Debug)]
pub struct InceptArgs {
/// Input toolpath document (JSON path, or cache id). Reads stdin when omitted.
#[arg(short, long)]
input: Option<String>,
/// Target project directory. Defaults to the current directory.
#[arg(short, long)]
project: Option<PathBuf>,
}
pub fn run(args: InceptArgs) -> Result<()> {
let input = match args.input {
Some(s) => s,
None => {
use std::io::Read;
let mut buf = String::new();
std::io::stdin()
.read_to_string(&mut buf)
.map_err(|e| anyhow::anyhow!("Failed to read stdin: {}", e))?;
let mut f = tempfile::NamedTempFile::new()?;
std::io::Write::write_all(&mut f, buf.as_bytes())?;
let (_file, path) = f.keep()?;
path.to_string_lossy().to_string()
}
};
let project = args
.project
.unwrap_or_else(|| std::env::current_dir().expect("cwd"));
crate::cmd_export::run(crate::cmd_export::ExportTarget::Claude {
input,
project: Some(project),
output: None,
})
}