mirror of
https://github.com/akitaonrails/ai-memory.git
synced 2026-10-02 03:24:46 +08:00
Add `ai-memory run kiro` (alias `kiro-cli`) for the AWS Kiro CLI (#356), deliberately scoped to the binary's default v2 agent engine. Cross-engine resume is prevented by construction, not detection: Kiro v3 sessions occupy a separate id space the v2 engine cannot resume (the resume hint printed after a v3 session silently starts a fresh v2 session unless --v3 is added), and the v3 persisted-session format is not publicly documented — so any `--v3`, `--mode`, or non-v2 `--agent-engine` selection turns the whole invocation into an unmanaged passthrough with argv byte-identical. Headless `--no-interactive` runs persist to Kiro's v1 SQLite store rather than the v2 session files this adapter reads, so they pass through too, as do the one-shot list/delete/model flags and every root utility subcommand except `chat` (list verified against kiro-cli 2.16.0 --help-all). Launch planning: session ids are server-assigned, so a fresh launch injects nothing and the session is linked by the session-start hook or discovered post-exit; a returning session appends `--resume-id <id>` after user arguments (accepted at the root and on `chat`, verified on the 2.16.0 binary). Explicit `-r/--resume`, `--resume-id`, `--resume-picker`/`--list` selections always win. Kiro's `-v` is verbose, not version, and stays managed. Discovery/import: the interactive store is flat — `$KIRO_HOME/sessions/cli/<uuid>.json` metadata + `<uuid>.jsonl` event stream — and the adapter matches checkouts on the metadata `cwd`, requiring the metadata session_id to agree with the file stem. The parser imports the versioned v1 envelope (Prompt / AssistantMessage with toolUse parts / ToolResults), ignores unknown record kinds for forward compatibility, and annotates unknown envelope versions and non-text parts as explicit losses. The stream is not verified append-only, so it shares Kimi's rewrite tolerance: a prefix-hash cursor that resets and replays on in-place rewrites, with stable line-hash record ids deduplicating server-side. `--yolo` maps to the official v2 flag `--trust-all-tools`, treats `-a`/`--trust-tools` as already-satisfying (an explicit narrower trust set is never widened), and maps nothing on non-v2 engines — v3 replaced the flag with permissions.yaml — with a stderr notice. Kiro joins the automatic bare-`run` pool (client and server side) and the deterministic phase of the acceptance script, including a byte-identical `--v3` passthrough check; the real-harness phase skips kiro with an explanation because scripted headless turns cannot write the store the adapter reads. Session-file shapes derive from public kiro-cli 1.29.x references and are documented as pending revalidation on a live logged-in install; the CLI argument contract was verified against kiro-cli 2.16.0 locally. Closes #356. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJvj7D7czyZzqk4pDXgLxY