diff --git a/crates/eureka-state/src/bin/huginn/main.rs b/crates/eureka-state/src/bin/huginn/main.rs index 252bd13..280ae96 100644 --- a/crates/eureka-state/src/bin/huginn/main.rs +++ b/crates/eureka-state/src/bin/huginn/main.rs @@ -219,7 +219,7 @@ enum Command { /// The mind's persona document (gamecult.persona_state.v0). Persona { #[command(subcommand)] - command: PersonaCommand, + command: Box, }, } @@ -374,7 +374,7 @@ fn run(settings: &Settings, command: Command) -> Result { let session = settings.session(session)?; import::run(settings, import::Flags { campaign, from, from_endpoint, faculty, agent, session }) } - Command::Persona { command } => persona::run(settings, command), + Command::Persona { command } => persona::run(settings, *command), Command::Recall { command: RecallCommand::Dispatch { top_k, max_anchors, budget, deadline_ms } } => Ok(recall::dispatch( settings, &recall::Flags { top_k: top_k as usize, max_anchors: max_anchors as usize, budget: budget as usize, deadline_ms }, diff --git a/crates/eureka-state/src/bin/huginn/persona.rs b/crates/eureka-state/src/bin/huginn/persona.rs index 7a07b23..e4416e8 100644 --- a/crates/eureka-state/src/bin/huginn/persona.rs +++ b/crates/eureka-state/src/bin/huginn/persona.rs @@ -5,7 +5,7 @@ use std::collections::BTreeSet; use std::fmt::Write as _; use chrono::{DateTime, Duration, Utc}; -use clap::{Subcommand, ValueEnum}; +use clap::{Args, Subcommand, ValueEnum}; use huginn_mind::eureka_pipeline::{Short, Slug}; use huginn_mind::persona::validate_document; use huginn_mind::{ @@ -63,55 +63,7 @@ const THOUGHT_STATUSES: [&str; 6] = [ #[derive(Subcommand, Debug)] pub enum MemoryCommand { /// Add an anchored thought to thoughtMemory.{shortTerm,memories,incubation}. - Add { - #[arg(long, value_parser = crate::faculty)] - faculty: Faculty, - /// The writing agent's name. - #[arg(long)] - agent: String, - /// The writing session; else HUGINN_SESSION. - #[arg(long)] - session: Option, - /// The thought's summary text. - #[arg(long)] - summary: String, - /// Which thoughtMemory pool to write into. - #[arg(long, value_enum, default_value_t = MemoryKind::ShortTerm)] - kind: MemoryKind, - /// Explicit id (default: generated m-... or w-...). - #[arg(long)] - id: Option, - /// Target kind (default: self). - #[arg(long)] - target_kind: Option, - /// Target id (default: current instance when target is self). - #[arg(long)] - target_id: Option, - /// Optional target label. - #[arg(long)] - target_label: Option, - /// Optional tension text. - #[arg(long)] - tension: Option, - /// Optional actionImplication text. - #[arg(long)] - action_implication: Option, - /// Optional claim text. - #[arg(long)] - claim: Option, - /// Optional question text. - #[arg(long)] - question: Option, - /// Importance / intensity in [0, 1]. - #[arg(long, allow_hyphen_values = true)] - importance: Option, - /// Valence in [-1, 1]. - #[arg(long, allow_hyphen_values = true)] - valence: Option, - /// Public tags (private and room:! tags are rejected). - #[arg(long = "tag")] - tags: Vec, - }, + Add(Box), /// Retire, resolve, or crystallize an existing thoughtMemory entry by id. Retire { #[arg(long, value_parser = crate::faculty)] @@ -130,6 +82,57 @@ pub enum MemoryCommand { }, } +#[derive(Args, Debug)] +pub struct MemoryAddCli { + #[arg(long, value_parser = crate::faculty)] + pub faculty: Faculty, + /// The writing agent's name. + #[arg(long)] + pub agent: String, + /// The writing session; else HUGINN_SESSION. + #[arg(long)] + pub session: Option, + /// The thought's summary text. + #[arg(long)] + pub summary: String, + /// Which thoughtMemory pool to write into. + #[arg(long, value_enum, default_value_t = MemoryKind::ShortTerm)] + pub kind: MemoryKind, + /// Explicit id (default: generated m-... or w-...). + #[arg(long)] + pub id: Option, + /// Target kind (default: self). + #[arg(long)] + pub target_kind: Option, + /// Target id (default: current instance when target is self). + #[arg(long)] + pub target_id: Option, + /// Optional target label. + #[arg(long)] + pub target_label: Option, + /// Optional tension text. + #[arg(long)] + pub tension: Option, + /// Optional actionImplication text. + #[arg(long)] + pub action_implication: Option, + /// Optional claim text. + #[arg(long)] + pub claim: Option, + /// Optional question text. + #[arg(long)] + pub question: Option, + /// Importance / intensity in [0, 1]. + #[arg(long, allow_hyphen_values = true)] + pub importance: Option, + /// Valence in [-1, 1]. + #[arg(long, allow_hyphen_values = true)] + pub valence: Option, + /// Public tags (private and room:! tags are rejected). + #[arg(long = "tag")] + pub tags: Vec, +} + #[derive(ValueEnum, Clone, Copy, Debug, PartialEq, Eq)] pub enum MemoryKind { #[value(name = "short-term")] @@ -311,42 +314,25 @@ pub fn run(settings: &Settings, command: PersonaCommand) -> Result persona_put(settings, faculty, agent, session, expected_updated_at, &file) } PersonaCommand::Seed => persona_seed(settings), - PersonaCommand::Memory { command: MemoryCommand::Add { - faculty, - agent, - session, - summary, - kind, - id, - target_kind, - target_id, - target_label, - tension, - action_implication, - claim, - question, - importance, - valence, - tags, - } } => memory_add( + PersonaCommand::Memory { command: MemoryCommand::Add(cli) } => memory_add( settings, - faculty, - agent, - session, + cli.faculty, + cli.agent, + cli.session, MemoryAddArgs { - summary, - kind, - id, - target_kind, - target_id, - target_label, - tension, - action_implication, - claim, - question, - importance, - valence, - tags, + summary: cli.summary, + kind: cli.kind, + id: cli.id, + target_kind: cli.target_kind, + target_id: cli.target_id, + target_label: cli.target_label, + tension: cli.tension, + action_implication: cli.action_implication, + claim: cli.claim, + question: cli.question, + importance: cli.importance, + valence: cli.valence, + tags: cli.tags, }, ), PersonaCommand::Memory { command: MemoryCommand::Retire { faculty, agent, session, status, id } } => {