feat: phase 2 — sessions export + rétention, init --template (closes #52 #53)

Axe 3 (#52) : templates embarqués dans le binaire (web, python, rust, cli)
- am init --template <stack> génère une config pré-remplie : groupe dev,
  profil par défaut, hooks projet (npm install / uv sync / cargo fetch)
- substitution {project} {dir} au rendu ; --template list pour lister
- fallback détection automatique de stack quand aucun template
- config générée validée (parse YAML + validate) par les tests

Axe 4 (#53) : am sessions export + rétention configurable
- am sessions --export <id> [--output <fichier>] : JSON complet et
  reproductible (métadonnées + commandes history/<id>.jsonl + extrait de
  log 4 Ko + rendu lisible 'readable'), compatible archivage manuel
- settings.sessions_retention_days (défaut 90) : purge au démarrage
  (silencieuse) et am sessions --retention <jours>
- purge limitée à l'index dérivé sessions.json — le journal d'événements
  primaire n'est jamais touché ; EventKind::Prune journalisé (visibilité
  am audit)
- sessions en cours (running) jamais purgées ; erreur claire si id inconnu

REPL : sessions --export/--retention/--output + init --template ; help
specs, tip cheat sheet, config.yaml, README, man pages régénérées.
Version 0.4.7, ROADMAP cochée, 276 tests verts.
This commit is contained in:
2026-08-18 10:08:20 -04:00
parent d9ffc34156
commit 6a6676fc5d
23 changed files with 561 additions and 71 deletions
+15 -7
View File
@@ -181,12 +181,16 @@ pub static HELP_SPECS: &[HelpSpec] = &[
name: "sessions",
category: "Commands",
usage: "sessions {flags} [agent]",
about: "List the sessions of every agent and of the interactive shell.",
search_terms: &["session", "history", "log"],
about: "List sessions; export one as JSON; enforce retention on old ones.",
search_terms: &["session", "history", "log", "export", "retention", "purge", "resume"],
flags: &[
HelpFlag { short: "", long: "--project", value: "PROJECT", desc: "Only sessions of this project" },
HelpFlag { short: "", long: "--status", value: "STATUS", desc: "Only sessions with this status (running, stopped, failed, interrupted)" },
HelpFlag { short: "", long: "--show", value: "ID", desc: "Show one session in detail (summary + log excerpt)" },
HelpFlag { short: "", long: "--export", value: "ID", desc: "Export a session (metadata + commands + log excerpt) to JSON" },
HelpFlag { short: "", long: "--output", value: "FILE", desc: "Export destination (default ./am-session-<ID>.json)" },
HelpFlag { short: "", long: "--retention", value: "DAYS", desc: "Purge sessions finished more than N days ago (settings default 90)" },
HelpFlag { short: "", long: "--resume", value: "ID", desc: "Relaunch a finished agent session with its recorded arguments" },
],
subcommands: &[],
parameters: &[
@@ -195,7 +199,9 @@ pub static HELP_SPECS: &[HelpSpec] = &[
io: None,
examples: &[
HelpExample { desc: "List recent sessions.", code: "sessions" },
HelpExample { desc: "Show one session with its log excerpt.", code: "sessions --show 20260815_143926_a1b2c3" },
HelpExample { desc: "Export one session.", code: "sessions --export 20260815_143926_a1b2c3" },
HelpExample { desc: "Purge sessions older than 30 days.", code: "sessions --retention 30" },
HelpExample { desc: "Resume a finished session.", code: "sessions --resume 20260815_143926_a1b2c3" },
],
},
HelpSpec {
@@ -557,17 +563,19 @@ pub static HELP_SPECS: &[HelpSpec] = &[
name: "init",
category: "Commands",
usage: "init {flags}",
about: "Generate a local agent-manager.yaml for the current directory, based on the detected stack.",
search_terms: &["project", "setup", "scaffold"],
about: "Generate a local agent-manager.yaml — stack detection or an embedded template.",
search_terms: &["project", "setup", "scaffold", "template"],
flags: &[
HelpFlag { short: "", long: "--force", value: "", desc: "Overwrite an existing agent-manager.yaml" },
HelpFlag { short: "", long: "--template", value: "NAME", desc: "web | python | rust | cli ('list' shows them)" },
],
subcommands: &[],
parameters: &[],
io: None,
examples: &[
HelpExample { desc: "Generate a project config.", code: "init" },
HelpExample { desc: "Regenerate over an existing one.", code: "init --force" },
HelpExample { desc: "Generate a project config (stack detection).", code: "init" },
HelpExample { desc: "Generate a web-stack config.", code: "init --template web" },
HelpExample { desc: "List the available templates.", code: "init --template list" },
],
},
HelpSpec {