raggiecode 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. Agent/__init__.py +0 -0
  2. Agent/agent.py +891 -0
  3. Agent/chat_history_db.py +1500 -0
  4. Agent/command.py +49 -0
  5. Agent/config.py +46 -0
  6. Agent/effort_levels.py +33 -0
  7. Agent/git_manager.py +727 -0
  8. Agent/tools.py +35 -0
  9. Commands/__init__.py +18 -0
  10. Commands/effort.py +42 -0
  11. Commands/global_todo.py +23 -0
  12. Commands/help.py +22 -0
  13. Commands/reasoning.py +24 -0
  14. Commands/redo.py +11 -0
  15. Commands/reindex.py +27 -0
  16. Commands/shell.py +28 -0
  17. Commands/stream.py +24 -0
  18. Commands/undo.py +13 -0
  19. Commands/unlimited_effort.py +8 -0
  20. Commands/window_size.py +29 -0
  21. RAG/__init__.py +0 -0
  22. RAG/document.py +119 -0
  23. RAG/find.py +408 -0
  24. RAG/graph.py +231 -0
  25. Tools/GetFileCodeStructure.py +43 -0
  26. Tools/GetSymbolSourceCode.py +27 -0
  27. Tools/__init__.py +39 -0
  28. Tools/ask_user.py +102 -0
  29. Tools/dispatch_subagent.py +215 -0
  30. Tools/document.py +35 -0
  31. Tools/edit_symbol.py +250 -0
  32. Tools/fuzzy_search.py +119 -0
  33. Tools/list_dir.py +51 -0
  34. Tools/read.py +49 -0
  35. Tools/read_image.py +75 -0
  36. Tools/remove.py +75 -0
  37. Tools/replace.py +305 -0
  38. Tools/search.py +41 -0
  39. Tools/shell.py +149 -0
  40. Tools/shell_kill.py +87 -0
  41. Tools/temp_background_service.py +113 -0
  42. Tools/todo_list.py +481 -0
  43. Tools/utils.py +116 -0
  44. Tools/view_changes.py +179 -0
  45. Tools/walk_call_tree.py +30 -0
  46. Tools/web_fetch.py +175 -0
  47. Tools/web_search.py +69 -0
  48. Tools/write.py +48 -0
  49. cli.py +111 -0
  50. config/__init__.py +0 -0
  51. config/coder_system_prompt.md +119 -0
  52. config/roles.json +43 -0
  53. config/tools.json +709 -0
  54. indexing/__init__.py +0 -0
  55. indexing/cli.py +128 -0
  56. indexing/code_index_sdk.py +832 -0
  57. indexing/code_indexer.py +1763 -0
  58. indexing/db_schema.py +396 -0
  59. indexing/export_to_json.py +346 -0
  60. indexing/extractors.py +189 -0
  61. indexing/file_utils.py +97 -0
  62. indexing/frontend/__init__.py +0 -0
  63. indexing/frontend/css_extractor.py +195 -0
  64. indexing/frontend/css_parser.py +387 -0
  65. indexing/frontend/css_selector_utils.py +226 -0
  66. indexing/frontend/edit_safety.py +573 -0
  67. indexing/frontend/graph.py +838 -0
  68. indexing/frontend/html_extractor.py +496 -0
  69. indexing/frontend/html_parser.py +314 -0
  70. indexing/frontend/jsx_extractor.py +1204 -0
  71. indexing/frontend/location_lookup.py +247 -0
  72. indexing/frontend/resolver.py +485 -0
  73. indexing/frontend/runtime_resolver.py +862 -0
  74. indexing/frontend/semantic_output.py +705 -0
  75. indexing/frontend/source_location.py +69 -0
  76. indexing/frontend_config.py +72 -0
  77. indexing/frontend_models.py +347 -0
  78. indexing/language_config.py +360 -0
  79. indexing/models.py +284 -0
  80. indexing/node_utils.py +1112 -0
  81. indexing/parse_worker.py +1082 -0
  82. indexing/queries.py +1542 -0
  83. indexing/sdk_examples.py +426 -0
  84. interactive.py +248 -0
  85. raggie.py +673 -0
  86. raggiecode-0.2.1.dist-info/METADATA +944 -0
  87. raggiecode-0.2.1.dist-info/RECORD +93 -0
  88. raggiecode-0.2.1.dist-info/WHEEL +5 -0
  89. raggiecode-0.2.1.dist-info/entry_points.txt +2 -0
  90. raggiecode-0.2.1.dist-info/top_level.txt +10 -0
  91. skills/__init__.py +3 -0
  92. skills/manager.py +114 -0
  93. skills/tool.py +121 -0
@@ -0,0 +1,944 @@
1
+ Metadata-Version: 2.4
2
+ Name: raggiecode
3
+ Version: 0.2.1
4
+ Summary: AI Coding Agent
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: tree-sitter==0.25.2
8
+ Requires-Dist: tree-sitter-python==0.25.0
9
+ Requires-Dist: tree-sitter-go==0.25.0
10
+ Requires-Dist: tree-sitter-c-sharp==0.21.0
11
+ Requires-Dist: tree-sitter-javascript==0.21.0
12
+ Requires-Dist: tree-sitter-typescript==0.21.0
13
+ Requires-Dist: tree-sitter-rust==0.24.2
14
+ Requires-Dist: tree-sitter-zig==1.1.2
15
+ Requires-Dist: tree-sitter-elixir==0.3.5
16
+ Requires-Dist: tree-sitter-cpp==0.23.4
17
+ Requires-Dist: tree-sitter-c==0.23.4
18
+ Requires-Dist: tree-sitter-php==0.24.1
19
+ Requires-Dist: tree-sitter-language-pack==1.8.1
20
+ Requires-Dist: rich>=13.7.1
21
+ Requires-Dist: pathspec==0.12.1
22
+ Requires-Dist: openai==2.43.0
23
+ Requires-Dist: prompt_toolkit
24
+ Requires-Dist: xxhash
25
+ Requires-Dist: ddgs
26
+ Requires-Dist: dulwich
27
+ Requires-Dist: ripgrep_rs
28
+
29
+ # Raggie Code
30
+
31
+ > *Raggie Code v0.2.1 (beta)*
32
+
33
+ <p style="padding:30px 50px;">
34
+ <img src="Raggie.png" alt="Raggie" width="312">
35
+ </p>
36
+
37
+ **Raggie** is an autonomous AI coding agent that doesn't just read your codebase. it *understands* it.
38
+
39
+ Most AI coding assistants dump file contents into a prompt and hope for the best. Raggie is different. It builds a **code semantic index** of your entire codebase, navigates **call graphs**, traces **dependency chains**, and uses that structural understanding to make surgical, context-aware changes. not blind edits.
40
+
41
+ It plans multi-step tasks with **todo lists**, delegates subtasks to **subagents**, fetches **skills on demand**, and tracks every change in a **built-in git repo** with one-click `/undo` and `/redo`. When the context window fills up, it performs an **automatic handover** to a fresh session. summarizing everything it's done so the next iteration picks up exactly where it left off. All while respecting your `.gitignore`, asking for your approval on big decisions, and working with **any OpenAI-compatible LLM**. local or cloud.
42
+
43
+ It runs locally. Your code index, chat history, and git repo never leave your machine.
44
+
45
+ ---
46
+
47
+ ## Why Raggie?
48
+
49
+ ### It actually understands your code
50
+
51
+ Raggie doesn't grep for strings and guess. It parses your codebase with **tree-sitter**. the same parser engine used by Neovim, GitHub code search, and tree-sitter's own language grammars. It tracks all dependencies and all dependents (something tree-sitter alone cannot do), letting the agent analyze the blast radius of each change by knowing what calls what, what imports what, and where every symbol lives. When you ask it to "refactor the auth middleware," it traces the call tree, finds every caller, and updates them all.
52
+
53
+ **15 languages supported:** Python, Go, C#, JavaScript, TypeScript, TSX, Rust, Zig, Elixir, C, C++, PHP, Dart, Java, and Kotlin.
54
+
55
+ ### It can plan before it acts
56
+
57
+ Give Raggie a complex task like "migrate the database from SQLite to PostgreSQL" and it won't just start editing files blindly. It can create a **todo list**, breaks the work into ordered steps, shows you the plan, and waits for your y/n approval before touching anything. Then it executes each step sequentially via **isolated subagents**. one task at a time, never in parallel, with full context carried forward.
58
+
59
+ ### Almost never loses context
60
+
61
+ When the LLM's context window fills up mid-task, Raggie doesn't just truncate and hope. It performs an **automatic session handover**: the agent generates a detailed handover document covering the original goal, current state, decisions made, changes applied, test results, errors encountered, and the exact next step. then spins up a fresh session that picks up the work seamlessly. You can also resume interrupted todo lists and converations across sessions.
62
+
63
+ ### It's safe by design
64
+
65
+ - **Built-in git repo**: Every change is committed to `.raggie/git/`. Type `/undo` to undo instantly, `/redo` to re-apply.
66
+ - **`.gitignore` / `.aiignore` respected**: The agent can't read, write, or modify ignored files. If a `.aiignore` file exists, it's used instead of `.gitignore` for both file access and code indexing.
67
+ - **Human-in-the-loop**: The `AskUser` tool lets the agent ask you questions mid-task. Todo list plans require your approval before execution.
68
+ - **Crash recovery**: Undo/redo operations use marker files for crash safety. Interrupted todo lists are detected and offered for resumption on next startup.
69
+
70
+ ### It gets smarter over time
71
+
72
+ Raggie's **skills system** lets it learn and persist knowledge across sessions. Skills are named instruction sets (like `code/testing` or `code/git-workflow`) stored in the database. At startup, only brief summaries go into the system prompt. the full content is fetched on demand via `GetSkill`, saving tokens. The agent can even create its own skills with `SetSkill` (with your consent). Skills survive across sessions, can be imported/exported as Markdown files, and stack with project-specific `AGENTS.md` overrides.
73
+
74
+ ### It works with your stack
75
+
76
+ - **Any OpenAI-compatible LLM**: OpenAI, DeepSeek, OpenRouter, Ollama, vLLM, LocalAI. if it speaks the OpenAI API, Raggie works with it.
77
+ - **31 tools**: Code exploration, file operations, shell execution (including background processes), web search, web fetch, and more.
78
+ - **Project-specific customization**: Drop an `AGENTS.md` in your project root and the agent picks up your conventions automatically.
79
+ - **Role-based configuration**: Define multiple agent roles with different models, tools, and system prompts.
80
+
81
+ ### It's transparent
82
+
83
+ Every tool call is displayed in real time with its arguments. Debug mode (`--debug`) shows full tool outputs. The `ViewChanges` tool lets the agent introspect its own git history. status, diffs, and commit log. You always know what the agent is doing, what it changed, and why.
84
+
85
+ ---
86
+
87
+ ## Feature Overview
88
+
89
+ | Feature | What it means |
90
+ |---|---|
91
+ | **code semantic indexing** | Full codebase parsing into symbols, functions, classes, imports, and dependency graphs (blast radius analysis). not just text search |
92
+ | **Call graph traversal** | BFS traversal from any entry point with cycle detection (depth 5). Trace execution flow across your entire codebase |
93
+ | **Fuzzy symbol search** | Find functions/classes/variables by name even when you don't know the exact spelling |
94
+ | **Multi-step task planning** | Todo list system with user approval gates, sequential subagent execution, and crash recovery |
95
+ | **Subagent delegation** | Spawn child agents for subtasks with depth controlled by effort levels and optional timeouts |
96
+ | **Automatic context handover** | When the context window fills up, the agent generates a handover document and continues in a fresh session |
97
+ | **Skills system** | Persistent, on-demand instruction sets that the agent advertises and fetches as needed |
98
+ | **Built-in git versioning** | Every change committed automatically. `/undo` to undo, `/redo` to redo. Full diff and log introspection |
99
+ | **Human-in-the-loop** | `AskUser` tool for mid-task questions. Todo list approval gates. `SetSkill` requires user consent |
100
+ | **31 tools** | Code exploration, file I/O, shell (foreground + background), web search/fetch, and more |
101
+ | **`.gitignore` / `.aiignore` enforcement** | Ignored files are invisible to the agent. can't read, write, modify, or index them. Use `.aiignore` to control this independently of git |
102
+ | **15 languages** | Python, Go, C#, JavaScript, TypeScript, TSX, Rust, Zig, Elixir, C, C++, PHP, Dart, Java, Kotlin |
103
+ | **Any OpenAI-compatible LLM** | Works with OpenAI, DeepSeek, OpenRouter, Ollama, vLLM, LocalAI, and anything else that speaks the OpenAI API |
104
+ | **Persistent chat history** | SQLite-backed sessions, messages, skills, and todo lists. all survive across restarts |
105
+ | **Project customization** | `AGENTS.md` for project conventions, `roles.json` for model/tool configuration, skills for persistent instructions |
106
+ | **Effort levels** | Control how deep the agent can nest subagents. 5 levels: Zen (depth 1), Serious (2), Extreme (4), Feral (8), Insane (16). Change mid-session with `/effort` |
107
+ | **Background shell execution** | Run long-running commands (dev servers, watchers) non-blocking with PID tracking and kill support |
108
+ | **Web search & fetch** | Search the web via DuckDuckGo and fetch URL content. the agent can look up docs and APIs |
109
+ | **Multiprocessing indexing** | Tree-sitter parsing uses multiprocessing for fast indexing of large codebases |
110
+
111
+ ---
112
+
113
+ ## Table of Contents
114
+
115
+ - [Installation](#installation)
116
+ - [Quick Start](#quick-start)
117
+ - [Commands Reference](#commands-reference)
118
+ - [In-Chat Commands](#in-chat-commands)
119
+ - [Effort Levels](#effort-levels)
120
+ - [Architecture](#architecture)
121
+ - [Configuration](#configuration)
122
+ - [Using Local AI](#using-local-ai)
123
+ - [Tools Reference](#tools-reference)
124
+ - [Skills System](#skills-system)
125
+ - [Todo List System](#todo-list-system)
126
+ - [Code Indexing](#code-indexing)
127
+ - [Git Integration](#git-integration)
128
+ - [FAQ](#faq)
129
+
130
+ ---
131
+
132
+ ## Installation
133
+
134
+ ### From pip (GitHub)
135
+
136
+ ```bash
137
+ pip install git+https://github.com/Hussein-L-AlMadhachi/RaggieCode.git
138
+ ```
139
+
140
+ ### From source
141
+
142
+ ```bash
143
+ git clone https://github.com/Hussein-L-AlMadhachi/RaggieCode.git
144
+ cd raggie
145
+ pip install .
146
+ ```
147
+
148
+ ### Requirements
149
+
150
+ - Python 3.10+
151
+ - An API key for an OpenAI-compatible LLM provider (OpenAI, DeepSeek, OpenRouter, etc.)
152
+
153
+ ### First-time setup
154
+
155
+ ```bash
156
+ raggie setup
157
+ ```
158
+
159
+ This guided wizard walks you through:
160
+ 1. Adding your API keys
161
+ 2. Reviewing agent roles (model, base URL)
162
+
163
+ ### Start the agent
164
+
165
+ ```bash
166
+ raggie code myproject
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Quick Start
172
+
173
+ ### 1. Run the setup wizard
174
+
175
+ ```bash
176
+ raggie setup
177
+ ```
178
+
179
+ You'll be prompted to add API keys and review your agent roles in one seamless flow.
180
+
181
+ ### 2. Run the agent
182
+
183
+ ```bash
184
+ # Single prompt mode (in a new project)
185
+ raggie code myproject --prompt "Write a hello world function in Python"
186
+
187
+ # Single prompt mode (in a specific project)
188
+ raggie code /path/to/project --prompt "Write a hello world function in Python"
189
+
190
+ # Interactive mode (chat loop)
191
+ raggie code /path/to/project
192
+
193
+ ```
194
+
195
+ In interactive mode:
196
+ - **Enter** to send your message
197
+ - **Esc then Enter** for multi-line input
198
+ - **`exit`** or **`quit`** to leave
199
+ - **`!command`** to run a shell command directly (e.g. `!ls -la`)
200
+
201
+ ### 3. Undo if something goes wrong
202
+
203
+ After the agent makes changes, type `/undo` as your next prompt to undo the last commit. Type `/redo` to re-apply it.
204
+
205
+ ### See it in action
206
+
207
+ ```bash
208
+ $ raggie code .
209
+
210
+ Raggie Agent (code) v1.0.0 - Interactive Mode
211
+ Press Esc followed by Enter to send message, or type 'exit' to quit
212
+ --------------------------------------------------
213
+ Indexing codebase...
214
+
215
+ Effort: Zen - to change it use /effort
216
+
217
+ You:
218
+ > Add input validation to the login endpoint and update all callers
219
+
220
+ Agent (deepseek-v4-flash:0):
221
+ I'll start by finding the login endpoint and tracing its callers.
222
+
223
+ [tool] GetSymbolSourceCode(name="login")
224
+ [tool] WalkCallTree(entry_point="login", depth=3)
225
+ [tool] GetFileCodeSemantics(file_path="src/auth/views.py")
226
+
227
+ I found the login endpoint at `src/auth/views.py:42` and 3 callers across
228
+ the codebase. I'll add validation for the email and password fields,
229
+ then update each caller to handle the new validation errors.
230
+
231
+ [tool] ReplaceText(file_path="src/auth/views.py", ...)
232
+ [tool] ReplaceText(file_path="src/api/routes.py", ...)
233
+ [tool] ReplaceText(file_path="tests/test_auth.py", ...)
234
+ [tool] Shell(command="python -m pytest tests/test_auth.py")
235
+
236
+ All 3 callers updated and tests pass. Changes committed.
237
+ type /undo to undo the last code changes
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Effort Levels
243
+
244
+ Effort levels control how deep the agent can nest subagents. Higher effort means the agent can break down complex tasks into more layers of subtasks.
245
+
246
+ | Level | Name | Max Depth | Description |
247
+ |---|---|---|---|
248
+ | 1 | **Zen** | 1 | Minimal. One level of subagents only. Fast and cheap. Default for new sessions |
249
+ | 2 | **Serious** | 2 | Moderate. Up to 2 levels of nested subagents |
250
+ | 3 | **Extreme** | 4 | Deep. Up to 4 levels of nested subagents for complex multi-step tasks |
251
+ | 4 | **Feral** | 8 | Very deep. Up to 8 levels. For highly complex tasks requiring extensive decomposition |
252
+ | 5 | **Insane** | 16 | Deepest. Up to 16 levels. For the most complex tasks. Use with caution |
253
+
254
+ ### Changing effort
255
+
256
+ - **In interactive mode**: The current effort level is displayed before each prompt. Use `/effort` to change it:
257
+ ```
258
+ /effort 3 # set by number
259
+ /effort extreme # set by name (case-insensitive)
260
+ /effort # interactive prompt to pick a level
261
+ ```
262
+ - **In non-interactive mode**: Pass `--effort <num>` on the command line:
263
+ ```bash
264
+ raggie code myproject --prompt "Refactor everything" --effort 5
265
+ ```
266
+ - New sessions default to **Zen** (level 1). The effort level persists per session in the database.
267
+
268
+ ### How depth works
269
+
270
+ When the agent dispatches a subagent, the child session's depth increments. If the depth reaches the effort level's `max_depth`, further subagent dispatch and todo list creation are blocked. This prevents runaway recursion and keeps costs predictable.
271
+
272
+ ---
273
+
274
+ ## Commands Reference
275
+
276
+ ### `raggie <role> <project-dir>`
277
+
278
+ Run the AI agent with a specific role in a project directory.
279
+
280
+ | Argument | Description |
281
+ |---|---|
282
+ | `role` | (Required) Agent role, defined in `roles.json`. Default: `"code"` |
283
+ | `project-dir` | (Optional) Path to the project directory. Use `.` for current directory. Created if it doesn't exist. Default: `.` |
284
+ | `--prompt` | (Optional) Single prompt. Omit for interactive mode |
285
+ | `--effort` | (Optional) Effort level 1-5 (zen, serious, extreme, feral, insane). Controls max subagent depth |
286
+ | `--debug` | Show raw tool call outputs for debugging |
287
+
288
+ **Examples:**
289
+ ```bash
290
+ raggie code /path/to/project --prompt "Refactor the API router to use dependency injection"
291
+ raggie code /path/to/project
292
+ raggie code . --debug
293
+ ```
294
+
295
+ ### `raggie setup`
296
+
297
+ First-time setup wizard. Guides you through configuring API keys and reviewing agent roles. everything needed to get started.
298
+
299
+ ### `raggie keys`
300
+
301
+ Manage API keys via an interactive menu. Keys are stored in `~/.config/raggie/keys.json`.
302
+
303
+ Options: Add key, Remove key, Exit (press `q`).
304
+
305
+ ### `raggie roles`
306
+
307
+ List and edit agent roles via an interactive menu. Roles are stored in `~/.config/raggie/roles.json`.
308
+
309
+ Options: Edit role's base URL / model, Exit (press `q`).
310
+
311
+ ### `raggie skill [role]`
312
+
313
+ Manage named skills stored in the database. A role can have multiple skills, each identified by a unique name.
314
+
315
+ Running `raggie skill` or `raggie skill <role>` without flags opens an interactive menu (like `raggie keys` and `raggie roles`):
316
+
317
+ ```
318
+ Skills for role 'code'
319
+ ------------------------------------------------------------
320
+ 1. testing: Always write tests after implementing. Use pytest.
321
+ 2. refactoring: When refactoring, preserve behavior.
322
+ ------------------------------------------------------------
323
+ q. Exit
324
+ 1. View skill content
325
+ 2. Delete skill
326
+ 3. Export skill to file
327
+ 4. Import skill from file
328
+ 5. List all skills (all roles)
329
+ ```
330
+
331
+ For scripting, flags are also available:
332
+
333
+ | Flag | Description |
334
+ |---|---|
335
+ | `--show` | Display all skills for the role (or a specific skill with `--name`) |
336
+ | `--name <name>` | Specify the skill name (required for import/export/delete) |
337
+ | `--import-skill <file>` | Import a skill from a Markdown file into the database (requires `--name`) |
338
+ | `--export-skill <file>` | Export a skill from the database to a Markdown file (requires `--name`) |
339
+ | `--delete` | Delete a skill (requires `--name`) |
340
+ | `--list-all` | List all skills across all roles (role arg not required) |
341
+
342
+ **Examples:**
343
+ ```bash
344
+ raggie skill code # interactive menu for role 'code'
345
+ raggie skill # interactive menu (all roles)
346
+ raggie skill code --show --name testing # show full content of a specific skill
347
+ raggie skill code --import-skill my-skills.md --name testing # import from file
348
+ raggie skill code --export-skill backup.md --name testing # export to file
349
+ raggie skill code --delete --name testing # delete a skill
350
+ raggie skill --list-all # list all skills across all roles
351
+ ```
352
+
353
+ ---
354
+
355
+ ## In-Chat Commands
356
+
357
+ These commands are available inside the interactive chat loop. They are intercepted before reaching the LLM and handled locally.
358
+
359
+ | Command | Description |
360
+ |---|---|
361
+ | `/undo` | Undo the last agent commit (restore previous file state) |
362
+ | `/redo` | Re-apply the last undone commit |
363
+ | `/streaming on\|off` | Toggle streaming mode mid-conversation. Persists to `roles.json` |
364
+ | `/reasoning on\|off` | Toggle reasoning output mid-conversation. Persists to `roles.json` |
365
+ | `/windowSize <number>` | Set the context window size (in tokens) for handover logic. Persists to `roles.json` |
366
+ | `/globalTodo on\|off` | Toggle shared todo lists across subagents. Persists to `roles.json` |
367
+ | `/effort <num\|name>` | Set effort level (1-5 or zen, serious, extreme, feral, insane). Controls max subagent depth |
368
+ | `/reindex [--force]` | Re-index the codebase. Use `--force` to re-index all files from scratch |
369
+ | `/help` | Show available in-chat commands |
370
+ | `!<command>` | Run a shell command directly (e.g. `!ls -la`, `!pytest tests/`) |
371
+
372
+ **Notes:**
373
+ - `/streaming`, `/reasoning`, and `/windowSize` take effect on the next message and persist to `~/.config/raggie/roles.json` so they survive across sessions.
374
+ - Calling `/streaming` or `/reasoning` without arguments shows the current status.
375
+ - Calling `/windowSize` without arguments shows the current context window size.
376
+ - Calling `/effort` without arguments prompts you to pick a level interactively.
377
+ - Calling `/globalTodo` without arguments shows the current status.
378
+ - Shell commands run via `!` are executed in the project directory and their output is printed directly. They do not go through the LLM.
379
+
380
+ ---
381
+
382
+ ## Architecture
383
+
384
+ ```
385
+ raggie/
386
+ ├── raggie.py # Entry point. parses args (role + project-dir), runs agent loop
387
+ ├── src/
388
+ │ ├── cli.py # Argument parser (argparse)
389
+ │ ├── chat.py # Watermelon-themed status messages (flavor)
390
+ │ ├── config/ # Default configuration files
391
+ │ │ ├── roles.json # Agent role definitions
392
+ │ │ ├── tools.json # Tool definitions for LLM function calling
393
+ │ │ └── coder_system_prompt.md # System prompt for the code role
394
+ │ ├── Agent/
395
+ │ │ ├── agent.py # Core Agent class. prompt loop, tool execution, commit
396
+ │ │ ├── config.py # Config loader. reads from ~/.config/raggie/
397
+ │ │ ├── tools.py # ToolRegistry. maps tool names to handler functions
398
+ │ │ ├── chat_history_db.py # SQLite DB. sessions, messages, skills, todo lists
399
+ │ │ └── git_manager.py # Local git repo in .raggie/git/ for versioning
400
+ │ ├── Tools/
401
+ │ │ ├── __init__.py # Registers all tool handlers with the registry
402
+ │ │ ├── read.py # WholeFileContentDump
403
+ │ │ ├── write.py # WriteFile
404
+ │ │ ├── replace.py # ReplaceText
405
+ │ │ ├── remove.py # RemoveFile
406
+ │ │ ├── shell.py # Shell command execution
407
+ │ │ ├── temp_background_service.py # TempBackgroundService. temporary background services
408
+ │ │ ├── shell_kill.py # ShellKill. kill background processes
409
+ │ │ ├── search.py # SearchAllFilesContent (grep)
410
+ │ │ ├── list_dir.py # ListDir
411
+ │ │ ├── web_fetch.py # WebFetch
412
+ │ │ ├── web_search.py # WebSearch
413
+ │ │ ├── view_changes.py # ViewChanges (git status/diff/log)
414
+ │ │ ├── dispatch_subagent.py # DispatchSubagent. spawns child agents
415
+ │ │ ├── todo_list.py # Todo list CRUD + execution
416
+ │ │ ├── GetSymbolSourceCode.py # GetSymbolSourceCode
417
+ │ │ ├── GetFileCodeStructure.py # GetFileCodeSemantics
418
+ │ │ ├── walk_call_tree.py # WalkCallTree
419
+ │ │ ├── fuzzy_search.py # FileNameSearch (fuzzy file name matching)
420
+ │ │ └── utils.py # Colors, is_within_cwd, is_ignored_by_gitignore
421
+ │ ├── indexing/
422
+ │ │ ├── code_indexer.py # Tree-sitter based code indexer
423
+ │ │ ├── code_index_sdk.py # SDK for querying the code index
424
+ │ │ ├── file_utils.py # File walking utilities
425
+ │ │ ├── extracts.py # Symbol extraction per language
426
+ │ │ ├── language_config.py # Language parser configurations
427
+ │ │ ├── models.py # Data models (Symbol, Function, Class, etc.)
428
+ │ │ ├── db_schema.py # SQLite schema for the code index
429
+ │ │ ├── node_utils.py # Tree-sitter node helpers
430
+ │ │ ├── queries.py # Tree-sitter query patterns
431
+ │ │ ├── parse_worker.py # Multiprocessing parse worker
432
+ │ │ └── export_to_json.py # Export index to JSON
433
+ │ ├── RAG/
434
+ │ │ ├── find.py # Find symbols in the index
435
+ │ │ └── graph.py # Dependency graph traversal
436
+ │ └── skills/
437
+ │ ├── __init__.py # Exports SkillManager
438
+ │ ├── manager.py # SkillManager. CRUD for named skills (role + name)
439
+ │ └── tool.py # SetSkill + GetSkill tool handlers
440
+ ├── AGENTS.md # Project-specific overrides (auto-loaded)
441
+ ├── pyproject.toml # Package metadata + dependencies
442
+ ├── .raggie/
443
+ │ ├── .raggie.chat # SQLite DB: sessions, messages, skills, todo lists
444
+ │ ├── .code_index.raggie # SQLite DB: tree-sitter code index
445
+ │ └── git/ # Local git repo for change tracking
446
+ └── requirements.txt # pip dependencies
447
+ ```
448
+
449
+ ### How the Agent Works
450
+
451
+ 1. **Startup**: The agent loads its role config, connects to the LLM API, checks for project markers in the working directory, indexes your codebase (tree-sitter, multiprocessing) if it looks like a project, and initialises its local git repo.
452
+ 2. **Prompt loop**: User sends a message → agent calls the LLM with full chat history + tool definitions → LLM responds with text and/or tool calls.
453
+ 3. **Tool execution**: Each tool call is dispatched to a registered handler. Results are fed back to the LLM as tool responses.
454
+ 4. **Re-indexing**: After each tool call, the code index is updated so the agent always has fresh context.
455
+ 5. **Context handover**: When the context window is nearly full, the agent generates a detailed handover document and seamlessly continues in a new session. no lost progress.
456
+ 6. **Commit**: When the agent finishes responding (no more tool calls), all files changed during the session are committed to `.raggie/git/`.
457
+ 7. **Undo/Redo**: Type `/undo` to undo the last commit and restore the previous state. Type `/redo` to re-apply an undone commit.
458
+
459
+ ---
460
+
461
+ ## Configuration
462
+
463
+ ### User Config Directory
464
+
465
+ All user-specific config lives in `~/.config/raggie/`:
466
+
467
+ ```
468
+ ~/.config/raggie/
469
+ ├── keys.json # API keys (base_url -> key mappings)
470
+ ├── roles.json # Role definitions (copied from src/config/ on first run)
471
+ └── tools.json # Tool definitions (copied from src/config/ on first run)
472
+ ```
473
+
474
+ ### `roles.json`
475
+
476
+ Defines agent roles. Each role has a model, base URL, tools list, and system prompt.
477
+
478
+ ```json
479
+ {
480
+ "code": {
481
+ "tools": ["WholeFileContentDump", "Shell", "WriteFile", ...],
482
+ "model": "deepseek-v4-flash",
483
+ "base_url": "https://api.deepseek.com",
484
+ "system_prompt_file": "coder_system_prompt.md"
485
+ }
486
+ }
487
+ ```
488
+
489
+ ### `AGENTS.md`
490
+
491
+ Place a file called `AGENTS.md` in the project root. Its contents are automatically appended to the agent's system prompt every time it starts. Useful for project-specific conventions:
492
+
493
+ ```markdown
494
+ # Project Conventions
495
+ - Use TypeScript for all new files
496
+ - Tests go in a __tests__/ directory
497
+ - Follow the existing ESLint config
498
+ ```
499
+
500
+ ### `.gitignore` and `.aiignore`
501
+
502
+ Raggie uses ignore patterns to determine which files are off-limits. If a `.aiignore` file exists in the project root, it is used **instead of** `.gitignore` for both code indexing and agent file access enforcement. If no `.aiignore` exists, `.gitignore` is used as a fallback.
503
+
504
+ When `.aiignore` is active, files matched by its patterns cannot be read, written, modified, or indexed by the agent. This gives you a single file to control what the agent sees and touches, independently of your git configuration.
505
+
506
+ `.aiignore` uses the same pattern syntax as `.gitignore`.
507
+
508
+ ---
509
+
510
+ ## Using Local AI
511
+
512
+ Raggie works with any OpenAI-compatible local LLM server. Below are setup guides for the most popular options.
513
+
514
+ ### Ollama
515
+
516
+ [Ollama](https://ollama.com) runs models locally with a built-in OpenAI-compatible endpoint.
517
+
518
+ 1. **Install Ollama**: Follow the instructions at [ollama.com](https://ollama.com)
519
+ 2. **Pull a model that supports tool calling** (not all models do):
520
+ ```bash
521
+ ollama pull qwen2.5:14b
522
+ # or
523
+ ollama pull llama3.1:8b
524
+ ```
525
+ 3. **Start the Ollama server** (it usually starts automatically):
526
+ ```bash
527
+ ollama serve
528
+ ```
529
+ 4. **Configure Raggie** — edit `~/.config/raggie/roles.json`:
530
+ ```json
531
+ {
532
+ "code": {
533
+ "model": "qwen2.5:14b",
534
+ "base_url": "http://localhost:11434/v1/",
535
+ "tools": ["..."],
536
+ "system_prompt_file": "coder_system_prompt.md",
537
+ "context_window": 32768,
538
+ "reasoning": false,
539
+ "stream": false
540
+ }
541
+ }
542
+ ```
543
+ 5. **Set the API key to `nokey`** — edit `~/.config/raggie/keys.json`:
544
+ ```json
545
+ {
546
+ "http://localhost:11434/v1/": "nokey"
547
+ }
548
+ ```
549
+ Raggie sees `nokey` and passes an empty API key to the client, which Ollama ignores.
550
+ 6. **Run Raggie**:
551
+ ```bash
552
+ raggie code myproject
553
+ ```
554
+
555
+ > **Note:** `context_window` should match the model's actual context length. For example, `qwen2.5:14b` supports 32768 tokens. Set this too high and the handover logic won't trigger when it should.
556
+
557
+ ### vLLM
558
+
559
+ [vLLM](https://github.com/vllm-project/vllm) is a high-throughput inference engine with an OpenAI-compatible server.
560
+
561
+ 1. **Install vLLM**:
562
+ ```bash
563
+ pip install vllm
564
+ ```
565
+ 2. **Start the server** with a tool-calling model:
566
+ ```bash
567
+ vllm serve Qwen/Qwen2.5-14B-Instruct --enable-auto-tool-choice --tool-call-parser hermes
568
+ ```
569
+ 3. **Configure Raggie** — edit `~/.config/raggie/roles.json`:
570
+ ```json
571
+ {
572
+ "code": {
573
+ "model": "Qwen/Qwen2.5-14B-Instruct",
574
+ "base_url": "http://localhost:8000/v1/",
575
+ "tools": ["..."],
576
+ "system_prompt_file": "coder_system_prompt.md",
577
+ "context_window": 32768,
578
+ "reasoning": false,
579
+ "stream": false
580
+ }
581
+ }
582
+ ```
583
+ 4. **Set the API key to `nokey`** — edit `~/.config/raggie/keys.json`:
584
+ ```json
585
+ {
586
+ "http://localhost:8000/v1/": "nokey"
587
+ }
588
+ ```
589
+ 5. **Run Raggie**:
590
+ ```bash
591
+ raggie code myproject
592
+ ```
593
+
594
+ ### LM Studio
595
+
596
+ [LM Studio](https://lmstudio.ai) provides a desktop GUI for running local models with an OpenAI-compatible server.
597
+
598
+ 1. **Install LM Studio** from [lmstudio.ai](https://lmstudio.ai)
599
+ 2. **Download a model** that supports tool calling (e.g. Qwen2.5, Llama 3.1)
600
+ 3. **Start the local server**: In LM Studio, go to the "Local Server" tab, load your model, and click "Start Server". The default endpoint is `http://localhost:1234/v1/`
601
+ 4. **Configure Raggie** — edit `~/.config/raggie/roles.json`:
602
+ ```json
603
+ {
604
+ "code": {
605
+ "model": "qwen2.5-14b-instruct",
606
+ "base_url": "http://localhost:1234/v1/",
607
+ "tools": ["..."],
608
+ "system_prompt_file": "coder_system_prompt.md",
609
+ "context_window": 32768,
610
+ "reasoning": false,
611
+ "stream": false
612
+ }
613
+ }
614
+ ```
615
+ > The `model` name must match what LM Studio shows as the loaded model identifier.
616
+ 5. **Set the API key to `nokey`** — edit `~/.config/raggie/keys.json`:
617
+ ```json
618
+ {
619
+ "http://localhost:1234/v1/": "nokey"
620
+ }
621
+ ```
622
+ 6. **Run Raggie**:
623
+ ```bash
624
+ raggie code myproject
625
+ ```
626
+
627
+ ### General Notes for Local AI
628
+
629
+ - **Tool calling is required**: Raggie relies on function/tool calling. Not all models support this. Known good options include Qwen2.5 (7B+), Llama 3.1 (8B+), and Mistral (7B+). If the model doesn't support tool calls, Raggie won't be able to use its tools.
630
+ - **Context window**: Set `context_window` in `roles.json` to match the model's actual context length. This controls when the automatic handover kicks in. Too high = handover never triggers (API errors). Too low = handover triggers too often (wasted tokens).
631
+ - **Streaming**: Set `"stream": false` for local models. Streaming with tool calling can be unreliable with some local servers.
632
+ - **The `nokey` convention**: Any `base_url` in `keys.json` with the value `"nokey"` tells Raggie to skip authentication and pass an empty key to the OpenAI client.
633
+
634
+ ---
635
+
636
+ ## Tools Reference
637
+
638
+ Raggie provides 31 tools to the LLM. Here they are grouped by category:
639
+
640
+ ### Code Exploration
641
+
642
+ this part is powered by the code indexer (code analysis and dependency tracking engine )
643
+
644
+ | Tool | What it does |
645
+ |---|---|
646
+ | `GetFileCodeSemantics` | Show a file's structure: functions, classes, imports, dependencies, with optional full source bodies |
647
+ | `GetSymbolSourceCode` | Get full source of a function/class/variable by name with fuzzy search fallback |
648
+ | `WalkCallTree` | BFS traversal of the call graph from any entry point (up to depth 5, cycle detection) |
649
+ | `WholeFileContentDump` | Read raw file contents (throttled. prefer semantic tools first) |
650
+ | `ListDir` | List directory contents with type and size |
651
+ | `SearchAllFilesContent` | Regex grep across files/directories |
652
+ | `FileNameSearch` | Fuzzy search for file names by partial or approximate match (top 5 results) |
653
+
654
+ ### File Operations
655
+
656
+ | Tool | What it does |
657
+ |---|---|
658
+ | `WriteFile` | Create or overwrite a file (auto-creates dirs, respects .gitignore) |
659
+ | `ReplaceText` | Find-and-replace in an existing file (literal or regex, supports replace_all) |
660
+ | `RemoveFile` | Delete a file or directory (refuses gitignored paths) |
661
+ | `Shell` | Execute a shell command (for build, test, etc.) |
662
+ | `TempBackgroundService` | Start a temporary background service (non-blocking, returns PID) |
663
+ | `ShellKill` | Kill a background shell process by PID |
664
+
665
+ ### Information Gathering
666
+
667
+ | Tool | What it does |
668
+ |---|---|
669
+ | `WebFetch` | Fetch a URL and return readable text (HTML stripped, configurable max chars) |
670
+ | `WebSearch` | Search the web via DuckDuckGo (up to 20 results, optional region) |
671
+
672
+ ### Agent Management & Communication
673
+
674
+ | Tool | What it does |
675
+ |---|---|
676
+ | `DispatchSubagent` | Spawn a child agent to handle a subtask (max 3 levels deep, optional timeout) |
677
+ | `SetSkill` | Create/update a named skill for the agent's own role (requires user consent) |
678
+ | `GetSkill` | Fetch the full content of a skill by role and name |
679
+ | `ViewChanges` | Show git status, diff, or log from `.raggie/git/` |
680
+ | `AskUser` | Ask the user a question mid-task, optionally with predefined options (single or multiple choice, or free-form) |
681
+
682
+ ### Todo Lists
683
+
684
+ | Tool | What it does |
685
+ |---|---|
686
+ | `CreateTodoList` | Create a new todo list |
687
+ | `AddTask` | Add a task with goal, requirements, notes, and order |
688
+ | `GetTodoList` | View the plan with all tasks and their status |
689
+ | `ApproveTodoList` | Present the plan to the user for y/n approval |
690
+ | `ExecuteNextTask` | Dispatch a subagent to execute the next pending task |
691
+ | `MarkTaskComplete` | Manually mark a task as done (auto-deletes todo list if all done) |
692
+ | `MarkTaskFailed` | Mark a task as failed |
693
+ | `MarkTaskCancelled` | Mark a task as cancelled (skipped intentionally) |
694
+ | `GetActiveTodoList` | Check for an incomplete todo list to resume |
695
+
696
+ ---
697
+
698
+ ## Skills System
699
+
700
+ Skills are named instruction sets stored in the database and advertised to the agent at startup. A role can have multiple skills, each identified by a unique name.
701
+
702
+ ### How it works
703
+
704
+ 1. **At startup**, all skills are listed as brief summaries in the system prompt (e.g. `code/testing: Always write tests after implementing...`)
705
+ 2. **The LLM picks** the skill it needs and calls `GetSkill(role, name)` to fetch the full content
706
+ 3. **The full skill content** is returned as a tool response, giving the agent detailed instructions for the task at hand
707
+
708
+ ### Key characteristics
709
+
710
+ - **Persistent**: Skills survive across sessions
711
+ - **Multiple per role**: Each role can have many named skills (e.g. `code/testing`, `code/refactoring`, `code/git-workflow`)
712
+ - **On-demand loading**: Only summaries go into the system prompt. full content is fetched when needed, saving tokens
713
+ - **User-controlled**: The `SetSkill` tool always asks for user consent before applying changes
714
+ - **Override with AGENTS.md**: Project-specific instructions in `AGENTS.md` are appended after skills
715
+
716
+ ### Managing skills
717
+
718
+ ```bash
719
+ # List all skills for a role
720
+ raggie skill code
721
+
722
+ # Show a specific skill
723
+ raggie skill code --show --name testing
724
+
725
+ # Import from a file
726
+ raggie skill code --import-skill my-skills.md --name testing
727
+
728
+ # Export to a file (backup)
729
+ raggie skill code --export-skill backup.md --name testing
730
+
731
+ # Delete a skill
732
+ raggie skill code --delete --name testing
733
+
734
+ # List all skills across all roles
735
+ raggie skill --list-all
736
+ ```
737
+
738
+ ### How skills stack
739
+
740
+ At startup, the agent builds its system prompt in this order:
741
+
742
+ 1. Role system prompt file (e.g. `coder_system_prompt.md`)
743
+ 2. Current date, working directory, host system info
744
+ 3. All skill summaries from database (role/name: one-line summary)
745
+ 4. `AGENTS.md` from project root (if it exists)
746
+
747
+ ---
748
+
749
+ ## Todo List System
750
+
751
+ The todo list system lets the agent plan and execute complex multi-step tasks with user oversight.
752
+
753
+ ### Workflow
754
+
755
+ ```
756
+ 1. GetActiveTodoList → check for existing incomplete todo list
757
+ 2. CreateTodoList → create a new list
758
+ 3. AddTask (x N) → add tasks with goals and requirements
759
+ 4. GetTodoList → review the plan
760
+ 5. ApproveTodoList → present to user for y/n approval
761
+ 6. ExecuteNextTask → execute tasks one by one via subagents
762
+ ```
763
+
764
+ ### Key behaviors
765
+
766
+ - **Sequential execution**: Tasks run one at a time, never in parallel
767
+ - **Subagent isolation**: Each task is handled by a fresh subagent that receives context from completed tasks
768
+ - **Auto-deletion**: When all tasks are done, the todo list is automatically removed from the database
769
+ - **Crash recovery**: If the session is interrupted, `GetActiveTodoList` returns the incomplete list and the user is offered to resume it
770
+ - **Nested todo lists**: Subagents can create their own todo lists for complex subtasks (up to 3 levels deep)
771
+
772
+ ---
773
+
774
+ ## Code Indexing
775
+
776
+ At startup and after every tool call, Raggie indexes your codebase using tree-sitter. This gives the agent:
777
+
778
+ - **Symbol definitions**: Functions, classes, methods, and their locations
779
+ - **Dependency graphs**: What calls what, what imports what
780
+ - **Call trees**: Full execution flow from any entry point
781
+ - **Fuzzy search**: Find symbols even if you don't know the exact name
782
+
783
+ ### Supported languages
784
+
785
+ The code indexer supports 15 programming languages via tree-sitter grammars:
786
+
787
+ | Language | Extensions | What gets indexed |
788
+ |---|---|---|
789
+ | **Python** | `.py` | Functions, classes, methods, imports, variables, type aliases, docstrings, branches |
790
+ | **Go** | `.go` | Functions, methods (with receivers), structs, interfaces, type aliases, imports |
791
+ | **C#** | `.cs` | Methods, constructors, classes, records, interfaces, structs, enums, namespaces, properties, using directives |
792
+ | **JavaScript** | `.js`, `.jsx` | Functions, generator functions, classes, methods, imports, variables (var/let/const) |
793
+ | **TypeScript** | `.ts` | Functions, classes (incl. abstract), interfaces, type aliases, enums, public fields, imports |
794
+ | **TSX** | `.tsx` | Same as TypeScript, with JSX support |
795
+ | **Rust** | `.rs` | Functions, structs, enums, traits, impl blocks, constants, statics, type aliases, use declarations |
796
+ | **Zig** | `.zig` | Functions, variable declarations (const/var), `@import` calls |
797
+ | **Elixir** | `.ex`, `.exs` | `def`/`defp`/`defmacro` functions, `defmodule` modules, alias imports, assignments |
798
+ | **C** | `.c`, `.h` | Functions, structs, enums, typedefs, `#include` directives, macros |
799
+ | **C++** | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.h`, `.hxx` | Functions, classes, structs, enums, type aliases, `#include` directives, macros |
800
+ | **PHP** | `.php` | Functions, methods, classes, interfaces, `use`/`include`/`require` imports |
801
+ | **Dart** | `.dart` | Function signatures, getters/setters, constructors, classes, mixins, extensions, imports |
802
+ | **Java** | `.java` | Methods, constructors, classes, records, annotation types, interfaces, enums, imports |
803
+ | **Kotlin** | `.kt`, `.kts` | Functions, classes, objects, interfaces, enums, type aliases, imports |
804
+
805
+ Languages are gracefully skipped if their tree-sitter grammar is not installed.
806
+
807
+ ### Project directory detection
808
+
809
+ Before indexing, Raggie checks whether the current directory looks like a code project by looking for project marker files (`.git`, `pyproject.toml`, `package.json`, `go.mod`, `Cargo.toml`, `Makefile`, `pom.xml`, `build.gradle`, `composer.json`, `Gemfile`, `mix.exs`, `build.zig`, `pubspec.yaml`, `.raggie`, `.vscode`, `.idea`, `.editorconfig`, and many more).
810
+
811
+ - **If project markers are found**: indexing proceeds automatically as normal.
812
+ - **If no project markers are found**: Raggie warns that the directory doesn't look like a project and asks whether to index anyway. This prevents accidentally scanning unrelated files (e.g. if you run `raggie code .` in your home directory). If you decline, Raggie exits and suggests you `cd` into your project directory or start a new one with `raggie code <project-name>`.
813
+ - **Subagent sessions**: indexing is skipped silently (subagents can't prompt interactively).
814
+
815
+ You can manually trigger re-indexing at any time with the `/reindex` command.
816
+
817
+ ### Data location
818
+
819
+ The index is stored in `.raggie/.code_index.raggie` (SQLite).
820
+
821
+ ### `.aiignore`
822
+
823
+ The code indexer and agent file tools respect a `.aiignore` file in the project root. If present, it is used **instead of** `.gitignore` to determine which files are off-limits — for both indexing and file read/write/modify enforcement. If no `.aiignore` exists, `.gitignore` is used as a fallback.
824
+
825
+ This lets you control what the agent sees and touches independently of your git configuration. `.aiignore` uses the same pattern syntax as `.gitignore`.
826
+
827
+ ### Indexing Performance
828
+
829
+ The indexer uses multiprocessing (tree-sitter parsing in parallel workers) with a sliding-window scheduler and a dedicated writer thread to keep both CPU and I/O saturated. Batch `executemany` inserts and a post-indexing dependency resolution pass minimize SQLite round-trips.
830
+
831
+ **Benchmark: Linux Kernel 7.1.1** (27844648 lines of code across 62,875 files)
832
+
833
+ | Phase | Time |
834
+ |---|---|
835
+ | File collection | ~4s |
836
+ | Changed-file detection | ~1.5s |
837
+ | Parse + insert (parallel) | ~521s |
838
+ | Dependency resolution | ~66s |
839
+ | **Total** | **~10m37s** |
840
+
841
+ Symbols indexed: 750K functions, 5.9M macros, 367K classes, 909K structs, 84K enums, 266K variables.
842
+
843
+ **Benchmark: Typical project** (a few hundred files)
844
+
845
+ Indexing completes in seconds. Re-indexing after a tool call is incremental — only changed files are re-parsed.
846
+
847
+ ---
848
+
849
+ ## Git Integration
850
+
851
+ Raggie maintains a local git repository at `.raggie/git/` for change tracking and rollback.
852
+
853
+ ### How it works
854
+
855
+ 1. **After every response**: The agent commits all current project files to `.raggie/git/`
856
+ 2. **Commit messages**: Include the user prompt, tool call count, and agent response summary
857
+ 3. **Proper nested trees**: Subdirectories are stored as proper git tree objects (standard git compatible)
858
+ 4. **Undo/Redo**: Type `/undo` to undo the last commit and restore files. Type `/redo` to re-apply an undone commit.
859
+
860
+ ### Commands
861
+
862
+ ```
863
+ /undo → Undo the last commit (restore previous state)
864
+ /redo → Redo the last undone commit (re-apply)
865
+ ```
866
+
867
+ ### The `ViewChanges` tool
868
+
869
+ The agent can introspect the git repo itself:
870
+
871
+ | view_type | What it shows |
872
+ |---|---|
873
+ | `status` | Files added/modified/deleted/unchanged since last commit |
874
+ | `diff` | Actual line-by-line diffs (with optional path filter and line limit) |
875
+ | `log` | Commit history (with configurable max count) |
876
+
877
+ ### Ignore file support
878
+
879
+ - Files matched by `.aiignore` (or `.gitignore` as fallback) are excluded from commits and status checks
880
+ - Common exclusions are hardcoded as fallback: `.raggie`, `.git`, `.venv`, `__pycache__`, `build`, `dist`, `.egg-info`, and binary extensions
881
+
882
+ ### Crash safety
883
+
884
+ The undo and redo operations write marker files (`.raggie/.undoing` and `.raggie/.redoing`) before deleting files, and remove them after successful restoration. If the process crashes mid-operation, the marker is detected on next startup and a warning is displayed. The redo stack (`.raggie/.redo_stack`) tracks undone commits so they can be re-applied; it is cleared when a new commit is made.
885
+
886
+ ---
887
+
888
+ ## FAQ
889
+
890
+ ### Does my code get sent to an external API?
891
+
892
+ Yes. your prompts and the agent's responses are sent to the LLM provider you configure (OpenAI, OpenRouter, DeepSeek, etc.). The code index and git repo stay local.
893
+
894
+ ### Can I use it with a local model?
895
+
896
+ Yes. Point `base_url` to any OpenAI-compatible local server (e.g. Ollama, vLLM, LocalAI) in your `~/.config/raggie/roles.json`.
897
+
898
+ ### Where is my data stored?
899
+
900
+ ```
901
+ .raggie/
902
+ ├── .raggie.chat # Chat sessions and messages
903
+ ├── .code_index.raggie # Tree-sitter code index
904
+ └── git/ # Local git repository for changes
905
+ ```
906
+
907
+ All of this is in your project directory and is gitignored by default.
908
+
909
+ ### How do I stop the agent from making changes?
910
+
911
+ The agent only writes files when you explicitly ask it to. You can review changes before accepting them. The `/undo` command undoes the last set of changes, and `/redo` re-applies them.
912
+
913
+ ### Can I customise the agent's behavior?
914
+
915
+ Yes. Create a `AGENTS.md` file in your project root with custom instructions. Edit `roles.json` to change models or tools per role. Use `raggie skill code --import-skill ... --name <name>` to add persistent named skills.
916
+
917
+ ### What happens if I interrupt the agent mid-task?
918
+
919
+ Todo lists are persisted in the database. When you restart, the agent checks for incomplete todo lists and offers to resume them. The git repo also has the last committed state for recovery.
920
+
921
+ ### What happens when the context window fills up?
922
+
923
+ Raggie performs an **automatic session handover**. The agent generates a detailed handover document (original goal, current state, decisions made, changes applied, test results, errors, next step) and continues in a fresh session. so it can work on large tasks that exceed a single context window without losing progress.
924
+
925
+ ### Can the agent ask me questions?
926
+
927
+ Yes. The `AskUser` tool lets the agent ask you questions mid-task, optionally with predefined options (single-choice, multiple-choice, or free-form). This means the agent can clarify requirements, confirm design decisions, or ask for preferences without guessing.
928
+
929
+ ### License
930
+ ```
931
+ Copyright 2026 Hussein Layth Al-Madhachi
932
+
933
+ Licensed under the Apache License, Version 2.0 (the "License");
934
+ you may not use this file except in compliance with the License.
935
+ You may obtain a copy of the License at
936
+
937
+ http://www.apache.org/licenses/LICENSE-2.0
938
+
939
+ Unless required by applicable law or agreed to in writing, software
940
+ distributed under the License is distributed on an "AS IS" BASIS,
941
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
942
+ See the License for the specific language governing permissions and
943
+ limitations under the License.
944
+ ```