feat: Added an --init-memory [global|workspace] flag to easily and quickly enable memory
This commit is contained in:
+4
-1
@@ -4,7 +4,7 @@ use crate::cli::completer::{
|
|||||||
ShellCompletion, agent_completer, macro_completer, model_completer, rag_completer,
|
ShellCompletion, agent_completer, macro_completer, model_completer, rag_completer,
|
||||||
role_completer, secrets_completer, session_completer,
|
role_completer, secrets_completer, session_completer,
|
||||||
};
|
};
|
||||||
use crate::config::{AssetCategory, InstallFilter};
|
use crate::config::{AssetCategory, InstallFilter, MemoryScope};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::ValueHint;
|
use clap::ValueHint;
|
||||||
use clap::{Parser, crate_authors, crate_description, crate_version};
|
use clap::{Parser, crate_authors, crate_description, crate_version};
|
||||||
@@ -78,6 +78,9 @@ pub struct Cli {
|
|||||||
/// Disable memory for this invocation
|
/// Disable memory for this invocation
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub no_memory: bool,
|
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
|
/// Display the message without sending it
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub dry_run: bool,
|
pub dry_run: bool,
|
||||||
|
|||||||
@@ -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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
|
||||||
pub enum InstallFilter {
|
pub enum InstallFilter {
|
||||||
Agents,
|
Agents,
|
||||||
|
|||||||
+29
-4
@@ -22,9 +22,9 @@ use crate::client::{
|
|||||||
};
|
};
|
||||||
use crate::config::paths;
|
use crate::config::paths;
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
Agent, AppConfig, AppState, CODE_ROLE, Config, EXPLAIN_SHELL_ROLE, Input, RequestContext,
|
Agent, AppConfig, AppState, CODE_ROLE, Config, EXPLAIN_SHELL_ROLE, Input, MemoryScope,
|
||||||
SHELL_ROLE, TEMP_SESSION_NAME, WorkingMode, ensure_parent_exists, install_builtins,
|
RequestContext, SHELL_ROLE, TEMP_SESSION_NAME, WorkingMode, ensure_parent_exists,
|
||||||
list_agents, load_env_file, macro_execute, sync_models,
|
install_builtins, list_agents, load_env_file, macro_execute, sync_models,
|
||||||
};
|
};
|
||||||
use crate::render::{prompt_theme, render_error};
|
use crate::render::{prompt_theme, render_error};
|
||||||
use crate::repl::Repl;
|
use crate::repl::Repl;
|
||||||
@@ -42,7 +42,7 @@ use log4rs::config::{Appender, Logger, Root};
|
|||||||
use log4rs::encode::pattern::PatternEncoder;
|
use log4rs::encode::pattern::PatternEncoder;
|
||||||
use oauth::OAuthProvider;
|
use oauth::OAuthProvider;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{env, process, sync::Arc};
|
use std::{env, fs, process, sync::Arc};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
@@ -301,6 +301,31 @@ async fn run(
|
|||||||
if cli.save_session {
|
if cli.save_session {
|
||||||
ctx.set_save_session_this_time()?;
|
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 {
|
if cli.info {
|
||||||
let app: Arc<AppConfig> = Arc::clone(&ctx.app.config);
|
let app: Arc<AppConfig> = Arc::clone(&ctx.app.config);
|
||||||
let info = ctx.info(app.as_ref())?;
|
let info = ctx.info(app.as_ref())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user