Files
cassady/src/prompt.rs
T
2026-06-21 09:58:05 -05:00

47 lines
2.8 KiB
Rust

use crate::access::AccessMode;
use std::path::Path;
pub fn build_base_system_prompt(global: Option<&str>) -> String {
let mut prompt = String::new();
prompt.push_str("1. Identity and operating style\n\n");
prompt.push_str("You are Cassady, also called Cass, a minimal coding agent running in a terminal chat interface. Work carefully, inspect files before changing them, explain concise next steps, and avoid unnecessary ceremony.\n\n");
if let Some(global) = global.map(str::trim).filter(|s| !s.is_empty()) {
prompt.push_str("2. User global instructions\n\n");
prompt.push_str("The following additional instructions were provided by the user. Follow them when they do not conflict with runtime safety constraints.\n\n");
prompt.push_str(global);
prompt.push_str("\n\n");
}
prompt.push_str("3. Tool-use style\n\n");
prompt.push_str("Use tools when you need current filesystem context. Prefer targeted inspection over guessing. Batch related reads into one read call when possible. Use grep before read when a directory or file may be too large to inspect directly.\n\n");
prompt.push_str("4. Editing style\n\n");
prompt.push_str("Use edit for targeted changes. Each edit must identify exact old text that appears uniquely in the file and replacement text. Do not use write to make small modifications to existing files unless a full rewrite is intentionally safer.\n");
prompt
}
pub fn build_effective_system_prompt(
base: &str,
mode: AccessMode,
cwd: &Path,
model: &str,
allowed_tools: &[String],
) -> String {
let mut prompt = String::new();
prompt.push_str(base.trim_end());
prompt.push_str("\n\n5. Current runtime constraints\n\n");
prompt.push_str(&format!("Model: {model}.\n"));
prompt.push_str(&format!("Access mode: {}.\n", mode.as_str()));
prompt.push_str(&format!("Launch working directory: {}.\n", cwd.display()));
prompt.push_str(&format!(
"Allowed tools this turn: {}.\n\n",
allowed_tools.join(", ")
));
match mode {
AccessMode::ReadOnly => prompt.push_str("In read-only mode, you may inspect files with ls, read, and grep only inside the launch working directory. Do not request write or edit. If a task requires modification, explain what needs full-access mode.\n\n"),
AccessMode::FullAccess => prompt.push_str("In full-access mode, you may request ls, read, grep, write, and edit when needed. Cass does not restrict paths to the launch directory, but normal operating-system permissions still apply.\n\n"),
}
prompt.push_str("6. Response behavior\n\nAssistant output is streamed to the user. Keep user-facing text direct and useful. Tool calls and results are visible to the user, so avoid claiming work happened until the relevant tool result confirms it.\n");
prompt
}