move working_stack code to correct file

This commit is contained in:
Kent Overstreet 2026-04-04 17:00:01 -04:00
parent e9d803c4ea
commit 375a8d9738
5 changed files with 24 additions and 30 deletions

View file

@ -4,6 +4,15 @@
// internal tool — the agent uses it to maintain context across turns
// and compaction. The model should never mention it to the user.
// TODO: these should not be hardcoded absolute paths
pub fn instructions_path() -> std::path::PathBuf {
dirs::home_dir().unwrap_or_default().join(".consciousness/config/working-stack.md")
}
pub fn file_path() -> std::path::PathBuf {
dirs::home_dir().unwrap_or_default().join(".consciousness/working-stack.json")
}
pub fn tool() -> super::Tool {
super::Tool {
name: "working_stack",
@ -25,7 +34,7 @@ fn handle(args: &serde_json::Value, stack: &mut Vec<String>) -> String {
let content = args.get("content").and_then(|v| v.as_str()).unwrap_or("");
let index = args.get("index").and_then(|v| v.as_u64()).map(|v| v as usize);
match action {
let out = match action {
"push" => {
if content.is_empty() { return "Error: 'content' is required for push".into(); }
stack.push(content.to_string());
@ -56,7 +65,13 @@ fn handle(args: &serde_json::Value, stack: &mut Vec<String>) -> String {
format!("Switched to index {}.\n{}", idx, format_stack(stack))
}
_ => format!("Error: unknown action '{}'. Use push, pop, update, or switch.", action),
}
};
if let Ok(json) = serde_json::to_string(stack) {
let _ = std::fs::write(file_path(), json);
};
out
}
fn format_stack(stack: &[String]) -> String {