Repository navigation
Add TUI palette, agent awareness, and evidence loop #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TerminallyLazy
merged 2 commits into
codex/rust-only-repo-v0.9
from
codex/install-onboarding-v0.10
Jul 5, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| use serde::Serialize; | ||
| use std::fs; | ||
| use std::path::{Path, PathBuf}; | ||
|
|
||
| const SKILL_TEMPLATE: &str = include_str!("../../../skills/tree-ring-memory/SKILL.md"); | ||
| const DOX_TEMPLATE: &str = include_str!("../../../templates/dox/AGENTS.md"); | ||
| const CLI_REFERENCE: &str = r#"# Tree Ring Memory CLI Quick Reference | ||
|
|
||
| Tree Ring Memory is a local-first memory lifecycle layer for AI agents. | ||
|
|
||
| Use memory deliberately: | ||
|
|
||
| - recall before substantial project work | ||
| - remember durable decisions, lessons, warnings, and user preferences | ||
| - use scars for failures that should not be repeated | ||
| - use seeds for future work and hypotheses | ||
| - forget, redact, or supersede stale or sensitive memory | ||
|
|
||
| Core commands: | ||
|
|
||
| ```bash | ||
| tree-ring init | ||
| tree-ring recall "project startup warnings" | ||
| tree-ring remember "Use project-scoped recall before risky changes." --event-type lesson --scope project | ||
| tree-ring evidence "Snapshot invalidation fixed stale unread chat state." --outcome promoted --evidence-ref evals/chat-state/run-042 --score 0.91 | ||
| tree-ring evidence "Aggressive caching caused stale multi-chat state." --outcome rejected --evidence-ref evals/cache-branch/run-013 | ||
| tree-ring forget mem_example --mode redact --reason "remove sensitive detail" | ||
| tree-ring consolidate --period-type manual --dry-run | ||
| tree-ring maintain | ||
| tree-ring tui | ||
| ``` | ||
|
|
||
| Safety rules: | ||
|
|
||
| - Do not store secrets, credentials, private keys, or raw chain-of-thought. | ||
| - Prefer concise, source-linked summaries over transcript capture. | ||
| - Treat local source files, tests, explicit user instructions, and root `AGENTS.md` files as authoritative. | ||
| - When memory and source docs disagree, re-read source docs and update or forget stale memory. | ||
| "#; | ||
|
|
||
| #[derive(Debug, Clone, Serialize, PartialEq, Eq)] | ||
| pub struct AgentAwarenessReport { | ||
| pub created: Vec<PathBuf>, | ||
| pub existing: Vec<PathBuf>, | ||
| } | ||
|
|
||
| pub fn ensure_agent_awareness(root: &Path) -> Result<AgentAwarenessReport, String> { | ||
| fs::create_dir_all(root).map_err(|err| err.to_string())?; | ||
| let mut report = AgentAwarenessReport { | ||
| created: Vec::new(), | ||
| existing: Vec::new(), | ||
| }; | ||
|
|
||
| write_if_missing(&root.join("AGENTS.md"), &agent_contract(root), &mut report)?; | ||
| write_if_missing(&root.join("SKILL.md"), SKILL_TEMPLATE, &mut report)?; | ||
| write_if_missing(&root.join("CLI.md"), CLI_REFERENCE, &mut report)?; | ||
|
|
||
| Ok(report) | ||
| } | ||
|
|
||
| fn write_if_missing( | ||
| path: &Path, | ||
| content: &str, | ||
| report: &mut AgentAwarenessReport, | ||
| ) -> Result<(), String> { | ||
| if path.exists() { | ||
| report.existing.push(path.to_path_buf()); | ||
| return Ok(()); | ||
| } | ||
| if let Some(parent) = path.parent() { | ||
| fs::create_dir_all(parent).map_err(|err| err.to_string())?; | ||
| } | ||
| fs::write(path, content).map_err(|err| err.to_string())?; | ||
| report.created.push(path.to_path_buf()); | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn agent_contract(root: &Path) -> String { | ||
| format!( | ||
| r#"# Tree Ring Memory Agent Instructions | ||
|
|
||
| This directory contains Tree Ring Memory's local project memory store. | ||
|
|
||
| Memory is a recall aid. It does not replace project source files, tests, root | ||
| `AGENTS.md` files, explicit user instructions, DOX contracts, or other local | ||
| project documentation. | ||
|
|
||
| ## Memory Root | ||
|
|
||
| ```text | ||
| {root} | ||
| ``` | ||
|
|
||
| Do not commit local memory databases or exports unless the project explicitly | ||
| requires sanitized fixtures. | ||
|
|
||
| ## Agent Skill | ||
|
|
||
| Read `SKILL.md` before using Tree Ring Memory. It explains when to recall, | ||
| remember, redact, forget, consolidate, and avoid memory capture. | ||
|
|
||
| ## CLI Reference | ||
|
|
||
| Read `CLI.md` for local commands. Common commands: | ||
|
|
||
| ```bash | ||
| tree-ring --root {root} recall "project startup warnings" | ||
| tree-ring --root {root} remember "Use project-scoped recall before risky changes." --event-type lesson --scope project | ||
| tree-ring --root {root} forget mem_example --mode redact --reason "remove sensitive detail" | ||
| tree-ring --root {root} tui | ||
| ``` | ||
|
|
||
| ## DOX Integration | ||
|
|
||
| If this project uses DOX-style `AGENTS.md` traversal, merge the relevant | ||
| sections from the template below into the project root `AGENTS.md`. Tree Ring | ||
| Memory does not overwrite root project contracts automatically. | ||
|
|
||
| --- | ||
|
|
||
| {DOX_TEMPLATE} | ||
| "#, | ||
| root = shell_path(root) | ||
| ) | ||
| } | ||
|
|
||
| fn shell_path(path: &Path) -> String { | ||
| path.display().to_string() | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use tempfile::tempdir; | ||
|
|
||
| #[test] | ||
| fn init_writes_agent_awareness_files_without_overwriting() { | ||
| let dir = tempdir().unwrap(); | ||
| let root = dir.path().join(".tree-ring"); | ||
|
|
||
| let first = ensure_agent_awareness(&root).unwrap(); | ||
| assert_eq!(first.created.len(), 3); | ||
| assert!(root.join("AGENTS.md").exists()); | ||
| assert!(root.join("SKILL.md").exists()); | ||
| assert!(root.join("CLI.md").exists()); | ||
|
|
||
| fs::write(root.join("CLI.md"), "custom").unwrap(); | ||
| let second = ensure_agent_awareness(&root).unwrap(); | ||
| assert!(second.existing.iter().any(|path| path.ends_with("CLI.md"))); | ||
| assert_eq!(fs::read_to_string(root.join("CLI.md")).unwrap(), "custom"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn generated_agents_file_mentions_skill_cli_and_dox() { | ||
| let dir = tempdir().unwrap(); | ||
| let root = dir.path().join(".tree-ring"); | ||
|
|
||
| ensure_agent_awareness(&root).unwrap(); | ||
| let agents = fs::read_to_string(root.join("AGENTS.md")).unwrap(); | ||
|
|
||
| assert!(agents.contains("SKILL.md")); | ||
| assert!(agents.contains("CLI.md")); | ||
| assert!(agents.contains("DOX Integration")); | ||
| assert!(agents.contains("Tree Ring Memory Project Contract")); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
shell_pathfunction inagent_awareness.rsdoes not handle paths containing spaces, unlike the implementation inwelcome.rs. If the project path contains spaces, the generated shell commands inAGENTS.mdwill be malformed and broken when copy-pasted or executed by an agent. Update this function to wrap paths containing spaces in single quotes.