diff --git a/AGENTS.md b/AGENTS.md index 55d24f57850c90388bacbde91bbcbb5bf9efd788..451891bb8e9be2db43ef49a514243d94cb0c3185 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,7 +23,7 @@ CLI entry (src/cli/index.ts) ### Control Flow 1. **CLI** parses args with custom parser (no library), dispatches to command handlers -2. **Command handlers** (`src/cli/commands/`) load config, create workspace, configure tools, invoke `runAgent()` +2. **Command handlers** (`src/cli/commands/`) load config, create workspace, build context-aware system prompt, configure tools, invoke `runAgent()` 3. **Agent runner** (`src/agent/runner.ts`) wraps `@mariozechner/pi-agent` - creates `Agent`, subscribes to events, prompts, extracts final message 4. **Tools** are created via factory functions that close over workspace path for sandboxing 5. **Workspace** (`src/workspace/manager.ts`) is a temp directory (cleaned up unless `--no-cleanup`) @@ -73,6 +73,15 @@ API key resolution for custom models uses `resolveConfigValue()` from `src/util/ Custom error classes in `src/util/errors.ts` extend `RumiloError` with error codes: - `ConfigError`, `FetchError`, `CloneError`, `WorkspaceError`, `ToolInputError` +### System Prompts + +Prompts in `src/agent/prompts/` are builder functions, not static strings. Each takes a context object and returns a templated prompt with XML-style sections (``, ``, ``). + +- **Repo prompt** (`buildRepoPrompt`): receives `{ currentTime, hasHistory }`. Git history guidance is only included when `hasHistory` is true (i.e. `--full` clone). Instructs the agent to check for agent instruction files (AGENTS.md, CLAUDE.md, .cursorrules, etc.) before README when orienting. +- **Web prompt** (`buildWebPrompt`): receives `{ currentTime }`. Provider-agnostic — does not assume a specific search-then-fetch workflow. + +Custom `system_prompt_path` in config replaces the built prompt entirely. + ### Output Truncation `src/util/truncate.ts` handles large content: @@ -85,7 +94,7 @@ Custom error classes in `src/util/errors.ts` extend `RumiloError` with error cod 1. **Grep requires ripgrep** - `createGrepTool` checks for `rg` at tool creation time and throws if missing 2. **Web tools require credentials** - `KAGI_SESSION_TOKEN` and `TABSTACK_API_KEY` via env or config 3. **Shallow clones by default** - repo mode uses `--depth 1 --filter=blob:limit=5m` unless `--full` -4. **Pre-fetch injection threshold** - web command with `-u URL` injects content directly if ≤50KB, otherwise stores in workspace +4. **Pre-fetch injection** - web command with `-u URL` wraps content in `` XML tags; content ≤50KB is inlined, larger content is stored in workspace 5. **No `.js` extension in imports** - source uses `.js` extensions for ESM compatibility even though files are `.ts` ## Adding a New Tool