feat: Added an --init-memory [global|workspace] flag to easily and quickly enable memory

This commit is contained in:
2026-06-10 20:26:17 -06:00
parent 0d2292bff6
commit 10de6025b5
3 changed files with 39 additions and 5 deletions
+4 -1
View File
@@ -4,7 +4,7 @@ use crate::cli::completer::{
ShellCompletion, agent_completer, macro_completer, model_completer, rag_completer,
role_completer, secrets_completer, session_completer,
};
use crate::config::{AssetCategory, InstallFilter};
use crate::config::{AssetCategory, InstallFilter, MemoryScope};
use anyhow::{Context, Result};
use clap::ValueHint;
use clap::{Parser, crate_authors, crate_description, crate_version};
@@ -78,6 +78,9 @@ pub struct Cli {
/// Disable memory for this invocation
#[arg(long)]
pub no_memory: bool,
/// Bootstrap a memory marker so coyote begins loading memory next run
#[arg(long, value_name = "SCOPE", value_enum)]
pub init_memory: Option<MemoryScope>,
/// Display the message without sending it
#[arg(long)]
pub dry_run: bool,
+6
View File
@@ -363,6 +363,12 @@ impl AssetCategory {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum MemoryScope {
Global,
Workspace,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum InstallFilter {
Agents,
+29 -4
View File
@@ -22,9 +22,9 @@ use crate::client::{
};
use crate::config::paths;
use crate::config::{
Agent, AppConfig, AppState, CODE_ROLE, Config, EXPLAIN_SHELL_ROLE, Input, RequestContext,
SHELL_ROLE, TEMP_SESSION_NAME, WorkingMode, ensure_parent_exists, install_builtins,
list_agents, load_env_file, macro_execute, sync_models,
Agent, AppConfig, AppState, CODE_ROLE, Config, EXPLAIN_SHELL_ROLE, Input, MemoryScope,
RequestContext, SHELL_ROLE, TEMP_SESSION_NAME, WorkingMode, ensure_parent_exists,
install_builtins, list_agents, load_env_file, macro_execute, sync_models,
};
use crate::render::{prompt_theme, render_error};
use crate::repl::Repl;
@@ -42,7 +42,7 @@ use log4rs::config::{Appender, Logger, Root};
use log4rs::encode::pattern::PatternEncoder;
use oauth::OAuthProvider;
use std::path::PathBuf;
use std::{env, process, sync::Arc};
use std::{env, fs, process, sync::Arc};
#[tokio::main]
async fn main() -> Result<()> {
@@ -301,6 +301,31 @@ async fn run(
if cli.save_session {
ctx.set_save_session_this_time()?;
}
if let Some(scope) = cli.init_memory {
let (path, content) = match scope {
MemoryScope::Global => (
paths::global_memory_index_path(),
"# Global Memory\n\n<!-- Universal facts about you go here. The LLM uses this as always-on context. -->\n<!-- Drill files (when created) are listed below. -->\n",
),
MemoryScope::Workspace => (
std::env::current_dir()?.join("COYOTE.md"),
"# Workspace Memory\n\n<!-- Facts about this project go here. The LLM uses this as always-on context. -->\n",
),
};
if path.exists() {
eprintln!("Memory marker already exists at '{}'.", path.display());
return Ok(());
}
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
fs::write(&path, content)?;
println!("✓ Created memory marker at '{}'.", path.display());
return Ok(());
}
if cli.info {
let app: Arc<AppConfig> = Arc::clone(&ctx.app.config);
let info = ctx.info(app.as_ref())?;