Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
feat(cli): keep cross-checkout resume behind --all; split out the bare picker
AkitaOnRailsac14b704144f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 30428297..61b04258 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,10 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Added-- Added a default checkout-local workstream picker for commandless terminal- launches, including `ai-jail ai-memory`. The Linux/macOS shell wrapper now- routes a bare interactive launch to its native host client. Scripted CLI- calls still require a subcommand; help/version behavior is unchanged. (#1039)+- Added `ai-memory resume --search` with immediate type-to-filter name search,+ and `resume --all`, which keeps the previous cross-checkout picker: every+ linked checkout, the current one first, each listed with its own fully+ paginated query. (#1039)- Added `install-hooks --agent claude-code --scope project`, which writes thehook configuration to the checkout's gitignored `.claude/settings.local.json`(where Claude Code reads it: the git root, or the launch directory on@@ -186,11 +186,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0queued SessionEnd consolidation job completed. (#1038)### Changed-- Scoped `ai-memory resume` to the current checkout instead of every linked- project, removed its default result cutoff with bounded server pagination,- and added `--search` plus immediate type-to-filter name search while preserving- Left/Right harness selection. Explicit limits now apply after the initial- search; `continue` retained its cross-directory behavior. (#1039)+- Scoped `ai-memory resume` to the current checkout by default instead of every+ linked project (`--all` restores the old view) and removed its default result+ cutoff with bounded server pagination, preserving Left/Right harness+ selection. Explicit limits now apply after the initial search; against an+ older server that ignores paging, the picker warns and shows the first page.+ `continue` retained its cross-directory behavior. (#1039)- Documented FutureInfra as an endpoint for the existing `openai-compat`provider. (#1026)- `.github/workflows/nix.yml` builds the flake on `x86_64-linux` for path-@@ -214,8 +215,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed- Removed unnecessary working-tree scans from checkout-local workstream listing- and the resume picker, including `ai-jail ai-memory resume --yolo`; launching- a selected workstream still captured its full checkpoint. (#1039)+ and the resume picker; launching a selected workstream still captured its+ full checkpoint. (#1039)- Fixed completed retries and no-op session endings advancing`last_persisted_ms` without a durable write. Recovery still advances thetimestamp when it commits a new page or terminal effect. (#1015)diff --git a/README.md b/README.mdindex 0d8c396c..af43853e 100644--- a/README.md+++ b/README.md@@ -372,10 +372,7 @@ ai-memory continue # resume the newest managed checkoutai-memory run --force-unlock codexai-memory resume # pick from ALL workstreams in this checkout onlyai-memory resume --search auth # find a workstream by name (case-insensitive)-ai-memory # same picker, when run in a terminal-ai-jail ai-memory # picker + selected harness inside ai-jail-ai-jail ai-memory resume --yolo # explicit picker + harness's dangerous mode-ai-jail --ssh ai-memory # also share SSH access+ai-memory resume --all # pick across every linked checkout````--force-unlock` immediately expires the selected workstream's active lease;@@ -390,30 +387,12 @@ then cancels when the search is empty (Ctrl-C always cancels).The list scrolls and loads every checkout-local page;there is no default workstream cutoff. Use `--limit N` only when you want tocap the matching results. Workstreams from other repositories or worktrees-never appear; `continue` still resumes the newest linked checkout from anywhere.--Running `ai-memory` without a subcommand in a terminal opens the same picker.-`ai-jail ai-memory` keeps both the picker and the selected harness inside-ai-jail; add ai-jail options before `ai-memory`, such as `--ssh` above.-This works with native installs and the Linux/macOS shell wrapper. Scripts-still require an explicit CLI subcommand, and `ai-memory --help` shows help.-Workstream discovery reads Git identity only; it does not scan the working tree+are left out unless you pass `--all`, which lists every linked checkout (the+current one first); `continue` still resumes the newest linked checkout from+anywhere. Listing reads Git identity only; it does not scan the working treewith `git status` before showing the picker. Full checkpoints are still capturedwhen launching the selected workstream.-For an unreleased source build, install the native binary on your host `PATH`-before entering ai-jail. A temporary `/tmp` build is not a reliable executable-location inside the sandbox:--```bash-cargo build -p ai-memory-cli --bin ai-memory-mkdir -p "$HOME/.local/bin"-install -m755 target/debug/ai-memory "$HOME/.local/bin/ai-memory"-export PATH="$HOME/.local/bin:$PATH"-# Run from the checkout you want to resume:-ai-jail ai-memory resume --yolo-```-Auto-wiring is on by default; opt out with `ai-memory run --no-autowire` or`AI_MEMORY_RUN_AUTOWIRE=false`. You can still wire agents by hand with`install-hooks` / `install-mcp` (e.g. for a harness you never launch throughdiff --git a/bin/ai-memory b/bin/ai-memoryindex 17504f7d..df3f98eb 100755--- a/bin/ai-memory+++ b/bin/ai-memory@@ -561,11 +561,6 @@ native_host_binary() {# ---- intercept wrapper-only subcommands -----------------------------------if [ "$#" -eq 0 ] && [ -z "${AI_MEMORY_NO_TTY:-}" ] && [ -t 0 ] && [ -t 1 ]; then- # The picker must inspect the host checkout and launch host harnesses.- set -- resume-fi-case "${1:-}" inupgrade)shiftdiff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rsindex 5e30b08a..b8119eac 100644--- a/crates/ai-memory-cli/src/cli.rs+++ b/crates/ai-memory-cli/src/cli.rs@@ -1,7 +1,6 @@//! Command-line interface definition (clap derive).use std::ffi::OsString;-use std::io::IsTerminal as _;use std::path::PathBuf;use clap::{Args, Parser, Subcommand};@@ -17,40 +16,7 @@ use clap_complete::Shell;/// wrapper-after-harness recovery (`--yolo`, `--fresh`, etc.) explicit in the/// run command rather than dependent on clap's option-name knowledge.pub(crate) fn parse_process() -> Cli {- let mut args = std::env::args_os().collect::<Vec<_>>();- default_to_resume(- &mut args,- std::io::stdin().is_terminal() && std::io::stdout().is_terminal(),- );- try_parse_from(args).unwrap_or_else(|error| error.exit())-}--fn default_to_resume(args: &mut Vec<OsString>, interactive: bool) {- if !interactive || args.is_empty() {- return;- }- let mut index = 1;- while index < args.len() {- let Some(arg) = args[index].to_str() else {- return;- };- if matches!(arg, "--data-dir" | "--config") && index + 1 < args.len() {- if args[index + 1]- .to_str()- .is_some_and(|value| value.starts_with('-'))- {- return;- }- index += 2;- } else if arg.starts_with("--data-dir=") || arg.starts_with("--config=") {- index += 1;- } else {- // Explicit commands, help/version and invalid input keep clap's- // usual behavior. Only a commandless terminal launch gets a picker.- return;- }- }- args.push("resume".into());+ try_parse_from(std::env::args_os()).unwrap_or_else(|error| error.exit())}pub(crate) fn try_parse_from<I, T>(args: I) -> Result<Cli, clap::Error>@@ -124,10 +90,7 @@ fn delimit_run_native_args(args: &mut Vec<OsString>) {/// Top-level CLI for the `ai-memory` binary.#[derive(Debug, Parser)]-#[command(- name = "ai-memory", version, about, long_about = None,- after_help = "Run without a command in a terminal to pick a workstream in this checkout.\nTo run inside ai-jail: ai-jail ai-memory"-)]+#[command(name = "ai-memory", version, about, long_about = None)]pub struct Cli {/// Override the data directory.///@@ -650,12 +613,17 @@ pub struct ContinueArgs {////// The picker deliberately accepts only wrapper-owned flags. Harness selection/// happens interactively, then it delegates to `run --workstream NAME` in the-/// current checkout.+/// selected checkout (the current one unless `--all` is given).#[derive(Debug, Args)]pub struct ResumeArgs {- /// Require the current checkout to resolve to this workspace.+ /// Require the current checkout to resolve to this workspace; with+ /// `--all`, only consider checkouts resolving to it.#[arg(long)]pub workspace: Option<String>,+ /// List workstreams from every locally linked checkout instead of only+ /// the current one.+ #[arg(long)]+ pub all: bool,/// Maximum matching workstreams to show (defaults to all).#[arg(long, value_parser = clap::value_parser!(u32).range(1..))]pub limit: Option<u32>,@@ -3465,6 +3433,7 @@ mod tests {};assert!(defaults.limit.is_none());assert!(defaults.search.is_none());+ assert!(!defaults.all);let Command::Resume(wide) = Cli::try_parse_from(["ai-memory", "resume", "--limit", "500"]).unwrap().command@@ -3481,6 +3450,7 @@ mod tests {"50","--search","refactor",+ "--all","--yolo",]).expect("resume parses picker flags");@@ -3490,6 +3460,7 @@ mod tests {assert_eq!(args.workspace.as_deref(), Some("work"));assert_eq!(args.limit, Some(50));assert_eq!(args.search.as_deref(), Some("refactor"));+ assert!(args.all);assert!(args.yolo);assert!(!args.fresh);@@ -3506,51 +3477,6 @@ mod tests {}}- #[test]- fn commandless_terminal_launch_opens_the_checkout_picker() {- for input in [- vec!["ai-memory"],- vec![- "ai-memory",- "--data-dir",- "data with spaces",- "--config=resume",- ],- vec!["ai-memory", "--config", "resume", "--data-dir=data"],- ] {- let mut args = input.into_iter().map(OsString::from).collect();- default_to_resume(&mut args, true);- let parsed = try_parse_from(args).unwrap();- let Command::Resume(picker) = parsed.command else {- panic!("expected checkout picker");- };- assert!(picker.limit.is_none() && picker.search.is_none());- assert!(!picker.yolo && !picker.true_yolo && !picker.fresh);- }- }-- #[test]- fn default_picker_preserves_explicit_commands_help_errors_and_scripts() {- for (input, interactive) in [- (vec!["ai-memory"], false),- (vec!["ai-memory", "--config", "config.toml"], false),- (vec!["ai-memory", "--help"], true),- (vec!["ai-memory", "--version"], true),- (vec!["ai-memory", "status"], true),- (vec!["ai-memory", "run", "codex"], true),- (vec!["ai-memory", "user"], true),- (vec!["ai-memory", "resumee"], true),- (vec!["ai-memory", "--config"], true),- (vec!["ai-memory", "--config", "--help"], true),- (vec!["ai-memory", "--unknown"], true),- ] {- let expected = input.into_iter().map(OsString::from).collect::<Vec<_>>();- let mut args = expected.clone();- default_to_resume(&mut args, interactive);- assert_eq!(args, expected);- }- }-#[test]fn show_parses_listing_and_launch_flags_without_consuming_native_args() {let listing = Cli::try_parse_from(["ai-memory", "show", "--json", "--no-scan"])diff --git a/crates/ai-memory-cli/src/commands/resume.rs b/crates/ai-memory-cli/src/commands/resume.rsindex d160bae0..8b79dba7 100644--- a/crates/ai-memory-cli/src/commands/resume.rs+++ b/crates/ai-memory-cli/src/commands/resume.rs@@ -1,10 +1,12 @@-//! `ai-memory resume` — pick a managed workstream in the current checkout.+//! `ai-memory resume` — pick a managed workstream in the current checkout,+//! or with `--all` across every locally linked checkout.//!//! The server deliberately cannot list client filesystem paths. This command-//! uses only the current checkout's privacy-preserving workstream listing,-//! revalidates the path before use, and delegates the-//! selected launch to `run --workstream`.+//! joins the current checkout (and, with `--all`, the checkout-local registry)+//! to each checkout's privacy-preserving workstream listing, revalidates the+//! selected path before use, and delegates the launch to `run --workstream`.+use std::collections::HashSet;use std::io::IsTerminal as _;use std::path::{Path, PathBuf};@@ -12,7 +14,7 @@ use ai_memory_core::ManagedWorkstreamSummary;use anyhow::{Context as _, Result, bail};use crate::cli::{ResumeArgs, RunArgs, RunHarnessChoice};-use crate::commands::project_registry::ProjectLink;+use crate::commands::project_registry::{self, ProjectLink};use crate::commands::show::{Choice, HorizontalDirection, available_harnesses, harness_name, select_with_horizontal,terminal_text,@@ -28,7 +30,8 @@ struct Candidate {summary: ManagedWorkstreamSummary,}-/// Interactively select a workstream in the current checkout only.+/// Interactively select a workstream in the current checkout, or in every+/// locally linked checkout with `--all`.pub async fn run(config: &Config, args: ResumeArgs) -> Result<i32> {if !std::io::stdin().is_terminal() || !std::io::stdout().is_terminal() {bail!(@@ -38,7 +41,11 @@ pub async fn run(config: &Config, args: ResumeArgs) -> Result<i32> {let endpoint = ServerEndpoint::from_config_resolving_auth(config).await;let cwd = std::env::current_dir().context("reading the current checkout")?;- let candidates = candidates_for_checkout(config, &endpoint, &args, &cwd).await?;+ let candidates = if args.all {+ candidates_across_checkouts(config, &endpoint, &args, &cwd).await?+ } else {+ candidates_for_checkout(config, &endpoint, &args, &cwd).await?+ };let harnesses = available_harnesses();let mut harness_indices = vec![0usize; candidates.len()];@@ -134,22 +141,120 @@ async fn candidates_for_checkout(}).collect::<Vec<_>>();order_candidates(&mut candidates);- // A requested limit applies after search, so an older matching row is- // never hidden behind newer non-matching workstreams.- if let Some(limit) = args.limit {- let search = args.search.as_deref().unwrap_or_default().to_lowercase();- candidates.retain(|candidate| candidate.summary.name.to_lowercase().contains(&search));- candidates.truncate(limit as usize);- if candidates.is_empty() {- bail!(- "no workstreams match '{}' in the current checkout",- terminal_text(&search)- );+ apply_limit(&mut candidates, args, "the current checkout")?;+ Ok(candidates)+}++/// `--all`: every checkout linked for this server, the current one first.+/// Each checkout is listed through its own fingerprint-scoped query, and one+/// that cannot be resolved or queried is skipped with a note.+async fn candidates_across_checkouts(+ config: &Config,+ endpoint: &ServerEndpoint,+ args: &ResumeArgs,+ cwd: &Path,+) -> Result<Vec<Candidate>> {+ let mut links = project_registry::links_for_server(config, endpoint)?;+ match current_checkout_link(config, endpoint, cwd) {+ Ok(current) => {+ if !links.iter().any(|link| {+ link.workspace == current.workspace+ && link.project == current.project+ && link.path == current.path+ }) {+ links.insert(0, current);+ }+ }+ Err(error) => eprintln!(+ "skipping current checkout: {}",+ terminal_text(&format!("{error:#}"))+ ),+ }+ let mut candidates = Vec::new();+ let mut seen = HashSet::new();+ let mut skipped = 0usize;+ for link in links.into_iter().filter(|link| {+ args.workspace+ .as_deref()+ .is_none_or(|workspace| link.workspace == workspace)+ }) {+ let target = match continue_session::resolve_target(config, &link) {+ Ok(target) => target,+ Err(error) => {+ eprintln!(+ "skipping {}: {}",+ scope_label(&link),+ terminal_text(&error.to_string())+ );+ skipped += 1;+ continue;+ }+ };+ let summaries = match workstreams::list_all_for_checkout(+ endpoint,+ &link.workspace,+ &link.project,+ &target,+ )+ .await+ {+ Ok(summaries) => summaries,+ Err(error) => {+ eprintln!(+ "skipping {}: could not list managed workstreams ({})",+ scope_label(&link),+ terminal_text(&format!("{error:#}"))+ );+ skipped += 1;+ continue;+ }+ };+ for summary in summaries {+ if seen.insert(summary.workstream_id) {+ candidates.push(Candidate {+ link: link.clone(),+ target: target.clone(),+ summary,+ });+ }}}+ if candidates.is_empty() {+ let detail = if skipped == 0 {+ "no local managed checkout has a saved workstream yet".to_owned()+ } else {+ format!(+ "{skipped} local checkout{} could not be queried",+ if skipped == 1 { "" } else { "s" }+ )+ };+ bail!(+ "no managed workstreams are available ({detail}); launch one with `ai-memory run <harness>` first"+ );+ }+ order_candidates(&mut candidates);+ apply_limit(&mut candidates, args, "any local checkout")?;Ok(candidates)}+/// A requested limit applies after search, so an older matching row is never+/// hidden behind newer non-matching workstreams.+fn apply_limit(candidates: &mut Vec<Candidate>, args: &ResumeArgs, scope: &str) -> Result<()> {+ let Some(limit) = args.limit else {+ return Ok(());+ };+ let search = args.search.as_deref().unwrap_or_default().to_lowercase();+ candidates.retain(|candidate| candidate.summary.name.to_lowercase().contains(&search));+ candidates.truncate(limit as usize);+ if candidates.is_empty() {+ bail!(+ "no workstreams match '{}' in {scope}",+ terminal_text(&search)+ );+ }+ Ok(())+}+fn current_checkout_link(config: &Config,endpoint: &ServerEndpoint,@@ -267,6 +372,7 @@ mod tests {fn args() -> ResumeArgs {ResumeArgs {workspace: None,+ all: false,limit: None,search: None,yolo: false,@@ -445,18 +551,78 @@ mod tests {}#[tokio::test]- async fn a_server_ignoring_pagination_fails_instead_of_silently_truncating() {+ async fn a_server_ignoring_pagination_still_shows_its_first_page() {let tmp = tempfile::TempDir::new().unwrap();let local = checkout(&tmp.path().join("local"));- let rows = (0..100)+ let rows = (0..150).map(|index| candidate(&format!("local-{index}"), false, "invalid").summary).collect();let (endpoint, requests, server) = listing_server(&local, rows, false).await;- let error = candidates_for_checkout(&Config::default(), &endpoint, &args(), &local)+ let candidates = candidates_for_checkout(&Config::default(), &endpoint, &args(), &local)+ .await+ .unwrap();+ // The repeated first page ends the walk instead of looping or failing.+ assert_eq!(candidates.len(), 100);+ assert_eq!(requests.lock().unwrap().len(), 2);+ server.abort();+ }++ #[tokio::test]+ async fn resume_all_walks_every_linked_checkout_and_honours_the_workspace_filter() {+ let tmp = tempfile::TempDir::new().unwrap();+ let local = checkout(&tmp.path().join("local"));+ let foreign = checkout(&tmp.path().join("foreign"));+ let config = Config {+ data_dir: tmp.path().join("data"),+ ..Config::default()+ };+ let rows = vec![candidate("local-only", true, "2026-09-02T00:00:00Z").summary];+ let (endpoint, requests, server) = listing_server(&local, rows, true).await;+ project_registry::record_prepared_checkout(&config, &endpoint, "work", "app", &foreign)+ .unwrap();+ // The registry keeps one checkout per project, so the stale link+ // belongs to a sibling project.+ let gone = checkout(&tmp.path().join("gone"));+ project_registry::record_prepared_checkout(&config, &endpoint, "work", "old", &gone)+ .unwrap();+ std::fs::remove_dir_all(&gone).unwrap();++ let mut all = args();+ all.all = true;+ let candidates = candidates_across_checkouts(&config, &endpoint, &all, &local)+ .await+ .unwrap();+ let rows = candidates+ .iter()+ .map(|row| (row.summary.name.as_str(), row.target.clone()))+ .collect::<Vec<_>>();+ // The current checkout's row leads; the other linked checkout's row+ // follows with its own target, and the deleted checkout is skipped.+ assert_eq!(+ rows,+ [+ ("local-only", local.clone()),+ ("foreign-workstream", foreign.clone())+ ]+ );+ assert_eq!(requests.lock().unwrap().len(), 2);++ all.workspace = Some("elsewhere".into());+ let error = candidates_across_checkouts(&config, &endpoint, &all, &local).await.unwrap_err();- assert!(error.to_string().contains("upgrade the ai-memory server"));+ assert!(+ error+ .to_string()+ .contains("no managed workstreams are available")+ );assert_eq!(requests.lock().unwrap().len(), 2);++ // Without `--all` the same registry contributes nothing.+ let local_only = candidates_for_checkout(&config, &endpoint, &args(), &local)+ .await+ .unwrap();+ assert_eq!(local_only.len(), 1);server.abort();}diff --git a/crates/ai-memory-cli/src/commands/workstreams.rs b/crates/ai-memory-cli/src/commands/workstreams.rsindex e6bee1f5..58fb6f77 100644--- a/crates/ai-memory-cli/src/commands/workstreams.rs+++ b/crates/ai-memory-cli/src/commands/workstreams.rs@@ -94,12 +94,20 @@ pub(super) async fn list_all_for_checkout(if count < request.limit {break;}- // Older servers ignore offset. Do not loop forever or silently show- // only their first page when the user requested all workstreams.- anyhow::ensure!(- summaries.len() > before,- "server did not advance workstream pagination; upgrade the ai-memory server and retry"- );+ // Older servers ignore offset and repeat their first page. Stop+ // instead of looping, and say the list is partial rather than fail:+ // the CLI and server may be upgraded on different machines.+ if summaries.len() == before {+ eprintln!(+ "warning: the ai-memory server ignored workstream pagination; showing its first {} workstreams. Upgrade the server to list them all.",+ summaries.len()+ );+ break;+ }+ // Pages are ordered by recency, so a workstream that becomes active+ // between two requests can move ahead of the offset and be skipped+ // until the next listing; `seen` keeps the reverse move from+ // duplicating a row. A picker tolerates that.request.offset = request.offset.checked_add(count)diff --git a/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rs b/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rsindex aad2283f..3bde87fb 100644--- a/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rs+++ b/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rs@@ -708,69 +708,6 @@ async fn yolo_offer_skips_the_checklist_for_a_project_ai_jail() {handle.abort();}-/// Exercise direct external wrapping, including the installed shell wrapper.-/// The forwarding stub preserves the terminal just like ai-jail's PTY proxy;-/// no nested real jail is needed, so this also runs inside ai-jail.-#[cfg(any(target_os = "linux", target_os = "macos"))]-#[tokio::test(flavor = "multi_thread", worker_threads = 2)]-async fn bare_ai_memory_opens_the_picker_directly_and_through_ai_jail() {- for mode in ["native", "jail-native", "jail-wrapper"] {- for launch in [false, true] {- let fixture = Fixture::new(HELP_2_4_1, true, None);- let entry = if mode == "jail-wrapper" {- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../bin/ai-memory")- } else {- PathBuf::from(BIN)- };- std::os::unix::fs::symlink(entry, fixture.bin.join("ai-memory")).unwrap();- std::os::unix::fs::symlink(host_tool("bash"), fixture.bin.join("bash")).unwrap();- write_script(- &fixture.bin.join("ai-jail"),- &format!(- "if [ \"$1\" = --dry-run ]; then exit 0; fi\n\- if [ \"$1\" = --help ]; then exit 0; fi\n\- printf '%s\\n' \"$@\" > '{}'\nexec \"$@\"\n",- fixture.jail_argv.display(),- ),- );- let (server, requests, handle) = mock_server().await;- let jailed = mode != "native";- let output = terminal_run_program(- &fixture,- &server,- &fixture- .bin- .join(if jailed { "ai-jail" } else { "ai-memory" }),- if jailed { "ai-memory" } else { "" },- if launch { "\x1b[C\r" } else { "\x1b" },- Some("Resume workstream"),- )- .await;- assert!(output.contains("Resume workstream"), "{mode}: {output}");- if jailed {- assert_eq!(fixture.jail_argv().unwrap(), ["ai-memory"]);- } else {- assert!(fixture.jail_argv().is_none());- }- let requests = requests.lock().unwrap();- assert_eq!(- requests.first().map(String::as_str),- Some("/workstream/recent")- );- if launch {- assert!(fixture.claude_ran.exists(), "{mode}: {output}");- assert!(output.contains("with harness 'claude'"), "{output}");- assert!(requests.iter().any(|path| path == "/workstream/runs"));- assert!(requests.iter().any(|path| path.ends_with("/finish")));- } else {- assert_eq!(requests.as_slice(), ["/workstream/recent"]);- assert!(!fixture.claude_ran.exists(), "Escape cancels before launch");- }- handle.abort();- }- }-}-#[tokio::test]async fn bare_nonterminal_command_help_version_and_typos_do_not_launch_a_picker() {let fixture = Fixture::new(HELP_2_4_1, true, None);diff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rsindex 7e842195..6a11686f 100644--- a/crates/ai-memory-cli/tests/suite/packaging.rs+++ b/crates/ai-memory-cli/tests/suite/packaging.rs@@ -442,11 +442,6 @@ fn run_wrapper_with_piped_stdin(args: &[&str], stdin_payload: &str) -> String {let mut child = shell_script_command(&repo_root().join("bin/ai-memory")).args(args).env("AI_MEMORY_DOCKER", shell_path(&docker))- .env(- "AI_MEMORY_NATIVE_BIN",- tmp.path().join("must-not-launch-native"),- )- .env("AI_MEMORY_IMAGE", "docker.io/akitaonrails/ai-memory:latest").env("AI_MEMORY_NO_VERSION_CHECK", "1").env("AI_MEMORY_DATA_VOLUME", "test-ai-memory-data").env("HOME", shell_path(tmp.path()))@@ -2392,20 +2387,6 @@ mod slow {);}- #[cfg(unix)]- #[test]- fn bare_wrapper_with_piped_stdin_does_not_open_the_host_picker() {- let args = run_wrapper_with_piped_stdin(&[], "");- let flags = args.lines().collect::<Vec<_>>();- assert!(flags.contains(&"-i"));- assert!(!flags.contains(&"-t"));- assert!(!flags.contains(&"resume"), "{args}");- assert_eq!(- flags.last().copied(),- Some("docker.io/akitaonrails/ai-memory:latest")- );- }-#[cfg(unix)]#[test]fn wrapper_self_upgrade_rejects_a_checksum_mismatch() {diff --git a/docs/cookbook.md b/docs/cookbook.mdindex 83b1ad59..7136578d 100644--- a/docs/cookbook.md+++ b/docs/cookbook.md@@ -333,6 +333,7 @@ Your agent runs most of these for you; `run` and `continue` are how you start itai-memory run <harness> # launch a harness, hooks + MCP auto-wiredai-memory continue # resume the newest managed checkoutai-memory resume --search auth # pick a matching workstream in this checkout only+ai-memory resume --all # pick from every linked checkout on this machineai-memory workstreams # list this checkout's managed workstreamsai-memory status # counts, paths, healthai-memory list-projects # every workspace/project the server knows aboutdiff --git a/docs/install.md b/docs/install.mdindex d2d690f5..ab508891 100644--- a/docs/install.md+++ b/docs/install.md@@ -2311,7 +2311,7 @@ docker run --rm akitaonrails/ai-memory:latest --help # full subcommand tree| `run [harness] [args...]` | host wrapper or native binary | Opt into one managed cross-harness workstream; omit the harness to resume the newest usable local session, or name Claude Code, Codex, OpenCode, Pi, Crush, Kimi Code, Command Code, Kiro CLI v2/v3, OMP, Grok Build CLI, or Antigravity CLI explicitly; exact `--yolo` and `--fresh` flags are wrapper-owned and other native arguments pass through || `show [--json]` | host wrapper or native binary | Choose a client-local checkout and installed managed harness, or return structured discovery data without launching; remote servers never provide checkout paths || `continue [--workspace NAME]` | host wrapper or native binary | From any directory, revalidate and resume the newest client-local managed checkout; accepts `--yolo` and `--fresh` but no harness-native arguments |-| `resume [--workspace NAME] [--search TERM] [--limit N]` | host wrapper or native binary | Interactively choose from all workstreams in the current checkout only (no default cutoff); type to search names, Up/Down selects, Left/Right cycles `auto` plus installed harnesses, Enter launches, and Escape clears the search or cancels; an explicit limit caps initial search results; accepts `--yolo` and `--fresh` |+| `resume [--all] [--workspace NAME] [--search TERM] [--limit N]` | host wrapper or native binary | Interactively choose from all workstreams in the current checkout (no default cutoff), or with `--all` from every valid client-local linked checkout; type to search names, Up/Down selects, Left/Right cycles `auto` plus installed harnesses, Enter launches, and Escape clears the search or cancels; an explicit limit caps initial search results; accepts `--yolo` and `--fresh` || `workstreams [--workspace NAME] [--project NAME] [--limit N] [--json]` | host wrapper or native binary | List recent workstreams selectable from the current checkout, including current selection and linked harnesses, without exposing paths or native session ids || `rename-workstream (--from NAME \| --workstream-id ID) --to NAME [--workspace NAME] [--project NAME] [--json]` | host wrapper or native binary | Retitle one workstream selectable from the current checkout; metadata only, so the stable id, the ledger, the listing order, and the current selection are unaffected || `workstream-search [query]` | managed child or thin HTTP client | Search the complete visible managed-workstream ledger; the managed child receives its workstream id automatically |diff --git a/docs/managed-workstreams.md b/docs/managed-workstreams.mdindex c81a4784..eb0a1922 100644--- a/docs/managed-workstreams.md+++ b/docs/managed-workstreams.md@@ -272,17 +272,14 @@ linked checkout from any directory, use `ai-memory continue` instead.ai-memory resumeai-memory resume --search authai-memory resume --workspace work --limit 50-ai-memory # no subcommand needed in a terminal-ai-jail ai-memory # picker and harness inside the jail-ai-jail ai-memory resume --yolo # explicit picker with dangerous-mode launch-ai-jail --ssh ai-memory # optional SSH access+ai-memory resume --all # every linked checkout, current one first```-A commandless terminal launch opens the same checkout-local picker. Wrap it-directly with `ai-jail ai-memory` to keep the selected harness in that jail.-There is no extra ai-memory jail flag or nested sandbox. The Linux/macOS shell-wrapper routes this interactive launch to its native host client. Non-terminal-CLI calls still require a subcommand, and explicit help/version remain available.+`--all` restores the cross-checkout view: it walks every checkout linked to+this server in the client-local registry (one per project), current checkout+first, with each checkout's own fingerprint-scoped, fully paginated query;+`--workspace` filters the registry before any request, and a checkout that can+no longer be resolved or queried is skipped with a note.Listing reads the stable repository/worktree fingerprints without running`git status`, so a working-tree scan or filesystem-monitor hook cannot hold upthe picker. The selected launch still captures its normal Git checkpoint.diff --git a/docs/security-boundaries.md b/docs/security-boundaries.mdindex a8b30109..b4281386 100644--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@ -26,7 +26,7 @@ boundary not yet built.| 1b | Reserved `_global` scope union never leaks a foreign project (#930) | `ai-memory-mcp/src/server.rs` `memory_query` — the union runs for single-project queries (`scopes` empty) and searches **only** `lookup_global_scope`'s reserved `(workspace_id, project_id)`, never an arbitrary project; the double-search guard resolves the *queried* project (named or active) so it can't be tricked into skipping | `server.rs` `global_union_never_leaks_a_foreign_projects_pages` (a third real project's page must not surface via the union; reserved page must), `single_project_query_unions_global_scope_and_multi_scope_skips_it` | STRONG || 1c | Reserved `_global` scope is read-open, write-gated (GHSA-7qj3-7wqw-m5w6) | `ai-memory-store/src/project_authz.rs` `ProjectAuthz::authorize` (a write to `default/_global` needs root or a `write` grant in either access mode; creator ignored) fed by `resolve_project_authz`/`read_project_row` (`reserved_global`, grant read for the global scope regardless of mode); `ai-memory-mcp/src/server.rs` `memory_write_page` resolves `scope: "global"` through `write_target_ids_with_actor` like an explicit `default/_global` | `project_authz.rs` `the_global_scope_admits_writes_only_from_root_or_a_write_grant`; `server.rs` `a_user_without_a_global_grant_cannot_change_the_global_scope` (both spellings and delete refused for an ungranted user and for `_global`'s creator; page survives; reads stay open), `a_global_write_grant_admits_writes_and_the_union_stays_readable` (legitimate control: write grant admits both spellings, another user's restricted-project query still unions the page); bite-checked with the authz rule removed and with the raw `create_global_scope` path restored | STRONG || 2 | Workspace isolation | same as #1; same-named project → distinct ids per workspace | `scope.rs` cross-workspace resolution rows; `multi_scope` dedup/validate | STRONG |-| 2b | Managed-workstream discovery stays checkout-local, including pagination | `ai-memory-workstream/src/repository.rs` `inspect_repository_fingerprints` shares the launch identity derivation without checkpoint scans; `ai-memory-cli/src/commands/resume.rs` `candidates_for_checkout` queries only the cwd, never registry links; `ai-memory-hooks/src/workstream.rs` `list_recent_workstreams` resolves an authorized explicit scope on every page; `ai-memory-store/src/workstream.rs` `list_recent` applies workspace/project/repository/worktree predicates before `LIMIT`/`OFFSET` | `resume.rs` `resume_lists_all_current_checkout_rows_not_registered_foreign_checkouts` (same scope/remote foreign checkout refused, 125 local rows visible), `empty_current_checkout_does_not_fall_back_to_the_registry`; `workstream.rs` `recent_workstream_pages_reach_older_rows_without_crossing_checkout_or_scope` (foreign repo, worktree, project and workspace excluded on every page; 105 legitimate rows reach the client, huge offsets return nothing); store `recent_workstreams_are_checkout_local_and_include_linked_harnesses` (page two keeps native harness links); `repository.rs` `reports_origin_push_url_and_linked_worktree` verifies lightweight/full fingerprint parity and distinct worktree keys; CLI `resume_yolo_displays_picker_without_scanning_git_status` verifies listing skips status scans | STRONG |+| 2b | Managed-workstream discovery stays checkout-local, including pagination | `ai-memory-workstream/src/repository.rs` `inspect_repository_fingerprints` shares the launch identity derivation without checkpoint scans; `ai-memory-cli/src/commands/resume.rs` `candidates_for_checkout` queries only the cwd, never registry links; the explicit `--all` walk (`candidates_across_checkouts`) lists each linked checkout through its own fingerprint-scoped request and applies `--workspace` before any request; `ai-memory-hooks/src/workstream.rs` `list_recent_workstreams` resolves an authorized explicit scope on every page; `ai-memory-store/src/workstream.rs` `list_recent` applies workspace/project/repository/worktree predicates before `LIMIT`/`OFFSET` | `resume.rs` `resume_lists_all_current_checkout_rows_not_registered_foreign_checkouts` (same scope/remote foreign checkout refused, 125 local rows visible), `empty_current_checkout_does_not_fall_back_to_the_registry`, `resume_all_walks_every_linked_checkout_and_honours_the_workspace_filter` (a foreign workspace filter sends no request; the default picker still ignores the registry); `workstream.rs` `recent_workstream_pages_reach_older_rows_without_crossing_checkout_or_scope` (foreign repo, worktree, project and workspace excluded on every page; 105 legitimate rows reach the client, huge offsets return nothing); store `recent_workstreams_are_checkout_local_and_include_linked_harnesses` (page two keeps native harness links); `repository.rs` `reports_origin_push_url_and_linked_worktree` verifies lightweight/full fingerprint parity and distinct worktree keys; CLI `resume_yolo_displays_picker_without_scanning_git_status` verifies listing skips status scans | STRONG || 3 | Multi-user auth ladder | `ai-memory-core/src/actor.rs` `AuthLevel::authorize`; `ai-memory-mcp/src/auth.rs` middleware; `admin.rs` `require_root_for_multiuser_admin` / `require_root`; `identity.rs` authorizes `NormalRead` behind the same machine bearer middleware as MCP; `serve.rs` mounts API-only and web+API protected routers behind `require_dual_auth` | `admin.rs` `multiuser_admin_routes_reject_db_user_tier` / `…reject_anonymous` / `create_user_as_user_tier_returns_403`; `auth.rs` unknown-bearer 401; `actor.rs` `skip_admission_chain_rejects_db_users`; `identity.rs` `identity_real_auth_isolates_users_root_and_revoked_keys`, `identity_anonymous_ignores_forged_headers_and_proxy_qualifies_oidc` (distinct users and root, invalid/revoked keys, forged headers, anonymous control); `serve.rs` `api_only_mode_keeps_data_authenticated_and_web_absent` (anonymous API read refused, authenticated control admitted, browser route absent; #986) | STRONG || 3b | Browser triage of pending writes (#855) | `ai-memory-web/src/routes/pending.rs` `require_admin` (`AuthLevel::authorize(Capability::Admin, distinguishes_operators)`, trusted-proxy flag from `WebMountSpec`) gates `GET {web_slug}/pending`; `html_auth.rs` `AdminRequired` keeps a non-root 403 off the change-password redirect; decisions post to the existing `/admin/pending-writes/{id}/approve\|reject` behind `require_dual_auth` (session + CSRF) and `require_root_for_multiuser_admin`. `ai-memory-web` has no write route | `ai-memory-web` `tests/suite/pending.rs` — anonymous refused (401, login redirect), DB user refused (403, no proposal text, no redirect), trusted-proxy flag reaches the gate, single-operator control admits, POSTs to `/pending*` refused, project filter keys do not collide on `/` in names, projects past the 500-row read cap stay counted and reachable; `ai-memory-mcp` `tests/suite/admin_pending_writes_session.rs` — anonymous and DB-user sessions refused, root session without a matching CSRF header refused (each leaves the proposal pending and no file), root approval keeps `auto_improve_proposal_id`/`auto_improve_run_id` and records the approver, root reject writes no file (each proven to fail with its guard removed) | STRONG || 4 | Handoff single-claim / no-steal | `ai-memory-store/src/ops.rs` `accept_handoff_in_transaction` (metadata `state='open'` guard + atomic CAS) | `multi_session.rs` `a_second_accept_cannot_steal_an_accepted_handoff`; `handoff_ownership.rs` `another_operator_cannot_claim_the_handoff` | STRONG |