diff --git a/analysis/memory.md b/analysis/memory.md index 2a5cd77..14f3166 100644 --- a/analysis/memory.md +++ b/analysis/memory.md @@ -1,5 +1,5 @@ # Project Memory -> Updated: 2026-01-12T09:14:13Z | Size: 10.5k chars +> Updated: 2026-01-13T16:15:37Z | Size: 11.8k chars ### Remember Tool Wiring - `crates/g3-core/src/tools/memory.rs` [0..5000] - `execute_remember()`, `get_memory_path()`, `merge_memory()` @@ -172,10 +172,24 @@ if s.chars().count() <= max_len { ... } ### Project Memory Location - Memory is now stored at `analysis/memory.md` (version controlled, shared across worktrees) -- Previously was at `.g3/memory.md` (gitignored, ephemeral) - `crates/g3-core/src/tools/memory.rs` - `get_memory_path()` returns `analysis/memory.md` - `crates/g3-cli/src/project_files.rs` - `read_project_memory()` reads from `analysis/memory.md` ### Compact Tool Output - `crates/g3-cli/src/ui_writer_impl.rs` - `print_tool_compact()` handles compact display for file ops and other tools -- `crates/g3-core/src/streaming.rs` - `format_*_summary()` functions for each tool type \ No newline at end of file +- `crates/g3-core/src/streaming.rs` - `format_*_summary()` functions for each tool type + +### Racket Code Search Support +Tree-sitter based syntax-aware search for Racket `.rkt` files. + +- `crates/g3-core/src/code_search/searcher.rs` + - Racket parser init [~line 45] - `tree_sitter_racket::LANGUAGE` + - Extension mapping [~line 90] - `.rkt`, `.rktl`, `.rktd` → "racket" + +### Auto-Memory Reminder Format +Rich few-shot prompting for higher quality memory entries with per-symbol char ranges. + +- `crates/g3-core/src/lib.rs` + - `send_auto_memory_reminder()` [47800..48800] - MEMORY CHECKPOINT prompt with few-shot examples +- `crates/g3-core/src/prompts.rs` + - Memory Format section [3800..4500] - system prompt template and examples \ No newline at end of file diff --git a/crates/g3-core/src/lib.rs b/crates/g3-core/src/lib.rs index e2bb90b..8afc703 100644 --- a/crates/g3-core/src/lib.rs +++ b/crates/g3-core/src/lib.rs @@ -1416,7 +1416,37 @@ impl Agent { debug!("Auto-memory: Sending reminder to LLM ({} tools called this turn: {:?})", tools_called.len(), tools_called); self.ui_writer.print_context_status("\nMemory checkpoint: "); - let reminder = "SYSTEM REMINDER: You used tools during this turn. If you discovered any key code locations, patterns, or entry points that aren't already in Project Memory, please call the `remember` tool now to save them. If you didn't discover anything new worth remembering, you can skip this. Respond briefly after deciding."; + let reminder = r#"MEMORY CHECKPOINT: If you discovered code locations worth remembering, call `remember` now. + +Use this rich format: + +### Feature Name +Brief description of what this feature/subsystem does. + +- `path/to/file.rs` + - `FunctionName()` [1200..1450] - what it does, key params/return + - `StructName` [500..650] - purpose, key fields + - `related_function()` - how it connects + +### Pattern Name +When to use this pattern and why. + +1. First step +2. Second step +3. Key gotcha or tip + +Example of a good entry: + +### Session Continuation +Save/restore session state across g3 invocations using symlink-based approach. + +- `crates/g3-core/src/session_continuation.rs` + - `SessionContinuation` [850..2100] - artifact struct with session state, TODO snapshot, context % + - `save_continuation()` [5765..7200] - saves to `.g3/sessions//latest.json`, updates symlink + - `load_continuation()` [7250..8900] - follows `.g3/session` symlink to restore + - `find_incomplete_agent_session()` [10500..13200] - finds sessions with incomplete TODOs for agent resume + +Skip if nothing new. Be brief."#; // Add the reminder as a user message and get a response self.context_window.add_message(Message::new( diff --git a/crates/g3-core/src/prompts.rs b/crates/g3-core/src/prompts.rs index 03d9f2b..775be85 100644 --- a/crates/g3-core/src/prompts.rs +++ b/crates/g3-core/src/prompts.rs @@ -109,17 +109,25 @@ Use this format when calling `remember`: ``` ### -- `` [..] - `()`, `` +Brief description of what this feature/subsystem does. + +- `` + - `FunctionName()` [1200..1450] - what it does, key params/return + - `StructName` [500..650] - purpose, key fields + - `related_function()` - how it connects ### +When to use this pattern and why. + 1. Step one 2. Step two +3. Key gotcha or tip ``` ## When to Remember **ALWAYS** call `remember` at the END of your turn when you discovered: -- A feature's location (file + char range + function/struct names) +- A feature's location with purpose and key entry points - A useful pattern or workflow - An entry point for a subsystem @@ -129,9 +137,13 @@ Do NOT save duplicates - check the Project Memory section (loaded at startup) to ## Example -After discovering where WebDriver tools live: +After discovering how session continuation works: -{\"tool\": \"remember\", \"args\": {\"notes\": \"## Features\\n\\n### WebDriver Browser Automation\\n- crates/g3-core/src/tools/webdriver.rs [0..21750] - execute_webdriver_start(), execute_webdriver_navigate(), WebDriverSession\"}} +{\"tool\": \"remember\", \"args\": {\"notes\": \"### Session Continuation\\nSave/restore session state across g3 invocations using symlink-based approach.\\n\\n- `crates/g3-core/src/session_continuation.rs`\\n - `SessionContinuation` [850..2100] - artifact struct with session state, TODO snapshot, context %\\n - `save_continuation()` [5765..7200] - saves to `.g3/sessions//latest.json`, updates symlink\\n - `load_continuation()` [7250..8900] - follows `.g3/session` symlink to restore\\n - `find_incomplete_agent_session()` [10500..13200] - finds sessions with incomplete TODOs for agent resume\"}} + +After discovering a useful pattern: + +{\"tool\": \"remember\", \"args\": {\"notes\": \"### UTF-8 Safe String Slicing\\nRust string slices use byte indices. Multi-byte chars (emoji, CJK) cause panics if sliced mid-character.\\n\\n1. Use `s.char_indices().nth(n)` to get byte index of Nth character\\n2. Use `s.chars().count()` for length, not `s.len()`\\n3. Danger zones: display truncation, user input, any non-ASCII text\"}} # Response Guidelines