Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(cli): align write-page project resolution
AkitaOnRailsf37f21026ebe
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a9e17bbc..18e7e0f1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,7 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0missing, not when the disk source of truth is corrupt or unreadable ([#63]).- `openai-oauth` now speaks the current ChatGPT/Codex responses stream formatfor bootstrap/consolidation requests and avoids sending the unsupported- `max_output_tokens` field on that endpoint.+ `max_output_tokens` field on that endpoint ([#64]).+- `ai-memory write-page` now resolves an omitted `--project` through the same+ current-project heuristic as `read-page` and `search`, preventing writes from+ landing in `scratch` while the read-back targets the cwd-derived project+ ([#66]).## [0.8.1] - 2026-05-30diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rsindex a611ac09..beb9050c 100644--- a/crates/ai-memory-cli/src/cli.rs+++ b/crates/ai-memory-cli/src/cli.rs@@ -910,9 +910,10 @@ pub struct WritePageArgs {/// Workspace name (auto-created if absent).#[arg(long, default_value_t = crate::config::DEFAULT_WORKSPACE.to_string())]pub workspace: String,- /// Project name within the workspace (auto-created if absent).- #[arg(long, default_value_t = crate::config::DEFAULT_PROJECT.to_string())]- pub project: String,+ /// Project name within the workspace. When omitted, auto-detect from the+ /// current project using the same resolver as read-page/search.+ #[arg(long)]+ pub project: Option<String>,}#[cfg(test)]@@ -943,6 +944,41 @@ mod tests {}}+ #[test]+ fn write_page_project_is_optional_for_shared_resolution() {+ let cli = Cli::try_parse_from([+ "ai-memory",+ "write-page",+ "--path",+ "notes/x.md",+ "--body",+ "hello",+ ])+ .expect("write-page parses without --project");++ let Command::WritePage(args) = cli.command else {+ panic!("expected write-page command");+ };+ assert_eq!(args.project, None);++ let cli = Cli::try_parse_from([+ "ai-memory",+ "write-page",+ "--path",+ "notes/x.md",+ "--body",+ "hello",+ "--project",+ "explicit",+ ])+ .expect("write-page parses with --project");++ let Command::WritePage(args) = cli.command else {+ panic!("expected write-page command");+ };+ assert_eq!(args.project.as_deref(), Some("explicit"));+ }+#[test]fn pi_hook_agent_aliases_parse_to_same_variant() {for alias in ["omp", "pi", "oh-my-pi"] {diff --git a/crates/ai-memory-cli/src/commands/write_page.rs b/crates/ai-memory-cli/src/commands/write_page.rsindex 92ea7246..473f9c07 100644--- a/crates/ai-memory-cli/src/commands/write_page.rs+++ b/crates/ai-memory-cli/src/commands/write_page.rs@@ -50,10 +50,10 @@ pub async fn run(config: &Config, args: WritePageArgs) -> Result<()> {args.body};- // `project` has a non-empty default ("scratch"); pass it directly so the- // explicit --project flag always wins. The auto-detect path is only useful- // for commands whose project arg is truly optional (no default).- let project = args.project.clone();+ // Resolve the project the same way read-page/search do: explicit flag wins,+ // otherwise derive the current project from host cwd / repo root. This keeps+ // write + read-back pairs from silently targeting different projects.+ let project = super::resolve_project_name(config, args.project.as_deref())?;let endpoint = ServerEndpoint::from_config(config);let resp: WritePageResponseBody = post_json(