@code-yeongyu/senpi 2026.5.15 → 2026.5.16
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.
- package/CHANGELOG.md +1113 -1177
- package/README.md +1 -2
- package/dist/core/agent-session.d.ts +9 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +114 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/dynamic-prompt/verification.d.ts +31 -0
- package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/verification.js +41 -0
- package/dist/core/dynamic-prompt/verification.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-reduction.d.ts +97 -0
- package/dist/core/extensions/builtin/compaction/context-reduction.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/context-reduction.js +420 -0
- package/dist/core/extensions/builtin/compaction/context-reduction.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +168 -31
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +197 -0
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote.js +690 -0
- package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/prompts.d.ts +3 -3
- package/dist/core/extensions/builtin/compaction/prompts.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/prompts.js +0 -22
- package/dist/core/extensions/builtin/compaction/prompts.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts +4 -0
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js +48 -0
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative.d.ts +3 -1
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +80 -33
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts +8 -0
- package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/todo-bridge.js +12 -6
- package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
- package/dist/core/extensions/builtin/diff.d.ts.map +1 -1
- package/dist/core/extensions/builtin/diff.js +1 -1
- package/dist/core/extensions/builtin/diff.js.map +1 -1
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +0 -2
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/openai-web-search/index.d.ts +6 -2
- package/dist/core/extensions/builtin/openai-web-search/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/openai-web-search/index.js +82 -10
- package/dist/core/extensions/builtin/openai-web-search/index.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/prompt.js +0 -5
- package/dist/core/extensions/builtin/permission-system/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/system-messages.d.ts +1 -1
- package/dist/core/extensions/builtin/system-messages.d.ts.map +1 -1
- package/dist/core/extensions/builtin/system-messages.js.map +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/index.js +8 -4
- package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.d.ts +3 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.js +89 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.js.map +1 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.d.ts +3 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.js +122 -0
- package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +2 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +18 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +22 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/messages.d.ts +3 -3
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +5 -10
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -22
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +0 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/thinking-levels.d.ts +6 -0
- package/dist/core/thinking-levels.d.ts.map +1 -0
- package/dist/core/thinking-levels.js +36 -0
- package/dist/core/thinking-levels.js.map +1 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +15 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +20 -2
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +3 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +8 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +137 -49
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/working-status.d.ts +15 -0
- package/dist/modes/interactive/working-status.d.ts.map +1 -0
- package/dist/modes/interactive/working-status.js +60 -0
- package/dist/modes/interactive/working-status.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/docs/extensions.md +0 -1
- package/docs/index.md +0 -1
- package/docs/models.md +9 -0
- package/docs/sdk.md +0 -1
- package/docs/settings.md +1 -29
- package/docs/termux.md +2 -2
- package/docs/usage.md +1 -1
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/overlay-qa-tests.ts +1 -1
- package/package.json +4 -4
- package/dist/core/extensions/builtin/background-task/cancel-tool.d.ts +0 -10
- package/dist/core/extensions/builtin/background-task/cancel-tool.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/cancel-tool.js +0 -109
- package/dist/core/extensions/builtin/background-task/cancel-tool.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/index.d.ts +0 -3
- package/dist/core/extensions/builtin/background-task/index.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/index.js +0 -207
- package/dist/core/extensions/builtin/background-task/index.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/manager.d.ts +0 -17
- package/dist/core/extensions/builtin/background-task/manager.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/manager.js +0 -114
- package/dist/core/extensions/builtin/background-task/manager.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/notification.d.ts +0 -22
- package/dist/core/extensions/builtin/background-task/notification.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/notification.js +0 -105
- package/dist/core/extensions/builtin/background-task/notification.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/output-tool.d.ts +0 -11
- package/dist/core/extensions/builtin/background-task/output-tool.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/output-tool.js +0 -127
- package/dist/core/extensions/builtin/background-task/output-tool.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/spawner.d.ts +0 -8
- package/dist/core/extensions/builtin/background-task/spawner.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/spawner.js +0 -207
- package/dist/core/extensions/builtin/background-task/spawner.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/task-tool.d.ts +0 -20
- package/dist/core/extensions/builtin/background-task/task-tool.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/task-tool.js +0 -302
- package/dist/core/extensions/builtin/background-task/task-tool.js.map +0 -1
- package/dist/core/extensions/builtin/background-task/types.d.ts +0 -72
- package/dist/core/extensions/builtin/background-task/types.d.ts.map +0 -1
- package/dist/core/extensions/builtin/background-task/types.js +0 -32
- package/dist/core/extensions/builtin/background-task/types.js.map +0 -1
- package/docs/agents.md +0 -348
- package/examples/extensions/subagent/README.md +0 -172
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -126
- package/examples/extensions/subagent/index.ts +0 -987
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
package/docs/agents.md
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
> pi can create custom agents. Ask it to build one for your use case.
|
|
2
|
-
|
|
3
|
-
# Agents
|
|
4
|
-
|
|
5
|
-
Agents are typed subagent profiles that control which tools a spawned task can use and what system prompt it receives. Use agents to enforce read-only exploration, restrict dangerous operations, or create specialized task runners.
|
|
6
|
-
|
|
7
|
-
## Table of Contents
|
|
8
|
-
|
|
9
|
-
- [Built-in Agents](#built-in-agents)
|
|
10
|
-
- [Using Agents](#using-agents)
|
|
11
|
-
- [Custom Agents](#custom-agents)
|
|
12
|
-
- [Locations](#locations)
|
|
13
|
-
- [Frontmatter](#frontmatter)
|
|
14
|
-
- [Example](#example)
|
|
15
|
-
- [Permissions](#permissions)
|
|
16
|
-
- [Permission Actions](#permission-actions)
|
|
17
|
-
- [Permission Config](#permission-config)
|
|
18
|
-
- [Evaluation Order](#evaluation-order)
|
|
19
|
-
- [Ask Mode](#ask-mode)
|
|
20
|
-
- [Configuration](#configuration)
|
|
21
|
-
- [Directory Setup](#directory-setup)
|
|
22
|
-
- [Writing an Agent File](#writing-an-agent-file)
|
|
23
|
-
- [Settings](#settings)
|
|
24
|
-
- [Priority Order](#priority-order)
|
|
25
|
-
- [Quick Start Recipes](#quick-start-recipes)
|
|
26
|
-
- [How It Works](#how-it-works)
|
|
27
|
-
- [Known Limitations](#known-limitations)
|
|
28
|
-
|
|
29
|
-
## Built-in Agents
|
|
30
|
-
|
|
31
|
-
| Agent | Tools | System Prompt | Description |
|
|
32
|
-
|-------|-------|---------------|-------------|
|
|
33
|
-
| `general` | All except `task`, `todowrite` | Default pi prompt | General-purpose agent for parallel work |
|
|
34
|
-
| `explore` | `read`, `grep`, `find`, `ls`, `bash` | File search specialist | Read-only codebase exploration |
|
|
35
|
-
|
|
36
|
-
### general
|
|
37
|
-
|
|
38
|
-
The default agent for complex multi-step tasks. It can use all tools except `task` and `todowrite` (to prevent nested subagent spawning and todo list conflicts).
|
|
39
|
-
|
|
40
|
-
Permission config:
|
|
41
|
-
|
|
42
|
-
```json
|
|
43
|
-
{
|
|
44
|
-
"*": "allow",
|
|
45
|
-
"task": "deny",
|
|
46
|
-
"todowrite": "deny"
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### explore
|
|
51
|
-
|
|
52
|
-
A read-only agent optimized for fast codebase exploration. It can search, read, and list files but cannot modify anything.
|
|
53
|
-
|
|
54
|
-
Permission config:
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
{
|
|
58
|
-
"read": "allow",
|
|
59
|
-
"grep": "allow",
|
|
60
|
-
"find": "allow",
|
|
61
|
-
"ls": "allow",
|
|
62
|
-
"bash": "allow"
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
System prompt appended:
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
|
|
70
|
-
Guidelines:
|
|
71
|
-
- Search file contents by regex or literal pattern when you need to locate usages or definitions
|
|
72
|
-
- Read files directly when you already know the path
|
|
73
|
-
- List directory contents to build a map of unfamiliar areas
|
|
74
|
-
- Return file paths as absolute paths
|
|
75
|
-
- Do not create any files or modify the system state
|
|
76
|
-
Complete the search request efficiently and report findings clearly.
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Using Agents
|
|
80
|
-
|
|
81
|
-
Pass `agent_type` when spawning a task:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
task(agent_type="explore", prompt="Find all files importing React", run_in_background=true)
|
|
85
|
-
task(agent_type="general", prompt="Refactor the auth module", run_in_background=false)
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Without `agent_type`, the task tool works exactly as before (no restrictions, full backward compat).
|
|
89
|
-
|
|
90
|
-
## Custom Agents
|
|
91
|
-
|
|
92
|
-
### Locations
|
|
93
|
-
|
|
94
|
-
Pi loads custom agents from Markdown files in:
|
|
95
|
-
|
|
96
|
-
- Global: `~/.senpi/agent/**/*.md` and `~/.senpi/agents/**/*.md`
|
|
97
|
-
- Project: `.senpi/agent/**/*.md` and `.senpi/agents/**/*.md` (in current working directory)
|
|
98
|
-
|
|
99
|
-
Both `agent/` and `agents/` directories are scanned recursively. The agent name is derived from the filename: `my-agent.md` becomes `my-agent`.
|
|
100
|
-
|
|
101
|
-
**Name collision resolution:** Project-local agents override global agents with the same name.
|
|
102
|
-
|
|
103
|
-
### Frontmatter
|
|
104
|
-
|
|
105
|
-
Custom agents use YAML frontmatter (same format as skills):
|
|
106
|
-
|
|
107
|
-
| Field | Type | Required | Description |
|
|
108
|
-
|-------|------|----------|-------------|
|
|
109
|
-
| `description` | string | No | What this agent does and when to use it |
|
|
110
|
-
| `mode` | string | No | `"subagent"`, `"primary"`, or `"all"` (default: `"all"`) |
|
|
111
|
-
| `model` | string | No | Model ID for this agent (e.g., `"anthropic/claude-haiku-4-5"`) |
|
|
112
|
-
| `temperature` | number | No | Sampling temperature 0-2 |
|
|
113
|
-
| `tools` | object | No | Permission config (see below) |
|
|
114
|
-
| `disable` | boolean | No | When `true`, agent is not loaded |
|
|
115
|
-
|
|
116
|
-
**Mode values:**
|
|
117
|
-
- `"subagent"` - Only runs as a task subagent (spawned via `task()`)
|
|
118
|
-
- `"primary"` - Only runs in the main session (not as a subagent)
|
|
119
|
-
- `"all"` - Can run in both contexts
|
|
120
|
-
|
|
121
|
-
### Example
|
|
122
|
-
|
|
123
|
-
Create `.senpi/agents/readonly.md`:
|
|
124
|
-
|
|
125
|
-
```markdown
|
|
126
|
-
---
|
|
127
|
-
description: Read-only agent for safe codebase exploration
|
|
128
|
-
mode: subagent
|
|
129
|
-
tools:
|
|
130
|
-
read: allow
|
|
131
|
-
grep: allow
|
|
132
|
-
find: allow
|
|
133
|
-
ls: allow
|
|
134
|
-
bash: deny
|
|
135
|
-
write: deny
|
|
136
|
-
edit: deny
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
You are a read-only exploration agent. You can search and read files but cannot modify anything.
|
|
140
|
-
|
|
141
|
-
Guidelines:
|
|
142
|
-
- Use grep to search for code patterns
|
|
143
|
-
- Use read to examine file contents
|
|
144
|
-
- Use find and ls to navigate the filesystem
|
|
145
|
-
- Never suggest file modifications
|
|
146
|
-
- Report findings clearly and concisely
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Use it:
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
task(agent_type="readonly", prompt="Find all TODO comments in the codebase", run_in_background=true)
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Permissions
|
|
156
|
-
|
|
157
|
-
### Permission Actions
|
|
158
|
-
|
|
159
|
-
Three actions control tool access:
|
|
160
|
-
|
|
161
|
-
- `allow` - Tool executes normally
|
|
162
|
-
- `deny` - Tool blocked, LLM receives error message explaining the restriction
|
|
163
|
-
- `ask` - In interactive mode, user is prompted to allow/deny. In non-interactive mode (json/print), auto-denied.
|
|
164
|
-
|
|
165
|
-
### Permission Config
|
|
166
|
-
|
|
167
|
-
The `tools` frontmatter field accepts two formats.
|
|
168
|
-
|
|
169
|
-
**Simple format** - single action for all patterns:
|
|
170
|
-
|
|
171
|
-
```yaml
|
|
172
|
-
tools:
|
|
173
|
-
read: allow
|
|
174
|
-
bash: deny
|
|
175
|
-
edit: ask
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
**Nested format** - pattern-specific rules (for future extensibility):
|
|
179
|
-
|
|
180
|
-
```yaml
|
|
181
|
-
tools:
|
|
182
|
-
read:
|
|
183
|
-
"*": allow
|
|
184
|
-
"*.env": ask
|
|
185
|
-
bash: deny
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
Currently, pattern matching is not implemented for specific paths. The `"*"` pattern applies to all uses of that tool.
|
|
189
|
-
|
|
190
|
-
### Evaluation Order
|
|
191
|
-
|
|
192
|
-
Permissions are evaluated using `findLast` semantics: **later rules override earlier ones**.
|
|
193
|
-
|
|
194
|
-
Merge order (later wins):
|
|
195
|
-
|
|
196
|
-
1. Global defaults from `settings.json` (`agentDefaults.permission`)
|
|
197
|
-
2. Built-in agent permissions (for built-in agents)
|
|
198
|
-
3. Custom agent permissions (from frontmatter `tools`)
|
|
199
|
-
|
|
200
|
-
Example: If global defaults set `"bash": "ask"` but a custom agent sets `"bash": "allow"`, the agent's explicit permission wins.
|
|
201
|
-
|
|
202
|
-
### Ask Mode
|
|
203
|
-
|
|
204
|
-
In **interactive mode**, when a tool with `"ask"` permission is called:
|
|
205
|
-
|
|
206
|
-
1. TUI displays a select prompt: "Allow once / Allow always / Deny"
|
|
207
|
-
2. "Allow once" permits this single call
|
|
208
|
-
3. "Allow always" persists a matching approval rule to `.senpi/permissions-approved.jsonl`, so matching calls are auto-allowed after reload too
|
|
209
|
-
4. "Deny" blocks with an error message
|
|
210
|
-
|
|
211
|
-
In **non-interactive mode** (json or print output), `ask` permissions are auto-denied with an explanatory message.
|
|
212
|
-
|
|
213
|
-
## Configuration
|
|
214
|
-
|
|
215
|
-
### Directory Setup
|
|
216
|
-
|
|
217
|
-
Create your agent directory structure:
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
# Project-local agents (recommended)
|
|
221
|
-
.senpi/
|
|
222
|
-
agents/
|
|
223
|
-
my-agent.md
|
|
224
|
-
code-reviewer.md
|
|
225
|
-
|
|
226
|
-
# Global agents (shared across projects)
|
|
227
|
-
~/.senpi/
|
|
228
|
-
agents/
|
|
229
|
-
my-global-agent.md
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
Both `agent/` and `agents/` subdirectories are scanned recursively.
|
|
233
|
-
|
|
234
|
-
### Writing an Agent File
|
|
235
|
-
|
|
236
|
-
Agent files are Markdown with YAML frontmatter. The body (after `---`) becomes the agent's system prompt.
|
|
237
|
-
|
|
238
|
-
```markdown
|
|
239
|
-
---
|
|
240
|
-
description: Strict code reviewer that only reads and analyzes
|
|
241
|
-
mode: subagent
|
|
242
|
-
model: anthropic/claude-sonnet-4-20250514
|
|
243
|
-
temperature: 0.3
|
|
244
|
-
tools:
|
|
245
|
-
read: allow
|
|
246
|
-
grep: allow
|
|
247
|
-
find: allow
|
|
248
|
-
ls: allow
|
|
249
|
-
bash: allow
|
|
250
|
-
edit: deny
|
|
251
|
-
write: deny
|
|
252
|
-
task: deny
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
You are a code review specialist. Analyze code for bugs, security issues, and style violations.
|
|
256
|
-
|
|
257
|
-
Rules:
|
|
258
|
-
- Never suggest modifying files directly
|
|
259
|
-
- Always reference specific line numbers
|
|
260
|
-
- Categorize issues as: critical, warning, or suggestion
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Settings
|
|
264
|
-
|
|
265
|
-
Configure default permissions and model for all agents in `settings.json`.
|
|
266
|
-
|
|
267
|
-
| Location | Scope |
|
|
268
|
-
|----------|-------|
|
|
269
|
-
| `~/.senpi/agent/settings.json` | Global (all projects) |
|
|
270
|
-
| `.senpi/settings.json` | Project (overrides global) |
|
|
271
|
-
|
|
272
|
-
Add the `agentDefaults` key:
|
|
273
|
-
|
|
274
|
-
```json
|
|
275
|
-
{
|
|
276
|
-
"agentDefaults": {
|
|
277
|
-
"permission": {
|
|
278
|
-
"write": "ask",
|
|
279
|
-
"edit": "ask",
|
|
280
|
-
"bash": "allow",
|
|
281
|
-
"read": "allow"
|
|
282
|
-
},
|
|
283
|
-
"model": "anthropic/claude-haiku-4-5"
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
| Setting | Type | Default | Description |
|
|
289
|
-
|---------|------|---------|-------------|
|
|
290
|
-
| `agentDefaults.permission` | object | `{}` | Default tool permissions for all agents (see [Permission Actions](#permission-actions)) |
|
|
291
|
-
| `agentDefaults.model` | string | - | Default model ID for spawned agents |
|
|
292
|
-
|
|
293
|
-
These defaults are the **lowest priority** layer. Agent-specific permissions (from frontmatter `tools`) override them.
|
|
294
|
-
|
|
295
|
-
### Priority Order
|
|
296
|
-
|
|
297
|
-
Permissions are resolved in this order (later wins):
|
|
298
|
-
|
|
299
|
-
1. `settings.json` -> `agentDefaults.permission` (lowest priority)
|
|
300
|
-
2. Built-in agent permissions (`general`, `explore` configs)
|
|
301
|
-
3. Custom agent frontmatter `tools` (highest priority)
|
|
302
|
-
|
|
303
|
-
Example: Global settings set `bash: ask`, but your custom agent sets `bash: allow` -> bash is allowed for that agent.
|
|
304
|
-
|
|
305
|
-
### Quick Start Recipes
|
|
306
|
-
|
|
307
|
-
**Read-only explorer:**
|
|
308
|
-
```typescript
|
|
309
|
-
task(agent_type="explore", prompt="Find all error handling patterns", run_in_background=true)
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
**Custom strict reviewer:**
|
|
313
|
-
1. Create `.senpi/agents/reviewer.md` (see [Writing an Agent File](#writing-an-agent-file))
|
|
314
|
-
2. Use: `task(agent_type="reviewer", prompt="Review changes in src/auth/", run_in_background=false)`
|
|
315
|
-
|
|
316
|
-
**Restrict all agents by default:**
|
|
317
|
-
Add to `~/.senpi/agent/settings.json`:
|
|
318
|
-
```json
|
|
319
|
-
{
|
|
320
|
-
"agentDefaults": {
|
|
321
|
-
"permission": {
|
|
322
|
-
"write": "ask",
|
|
323
|
-
"edit": "ask"
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
```
|
|
328
|
-
Now every agent must get user confirmation before writing or editing files.
|
|
329
|
-
|
|
330
|
-
## How It Works
|
|
331
|
-
|
|
332
|
-
The agent system is implemented as a builtin extension that intercepts the task tool:
|
|
333
|
-
|
|
334
|
-
1. **Environment variable** - When `task(agent_type="...")` is called, the agent type is passed via `SENPI_AGENT_TYPE` environment variable to the subprocess
|
|
335
|
-
2. **Registry lookup** - On session start, the extension scans `~/.senpi/` and `.senpi/` for agent definitions, merges with built-in agents, and resolves by name
|
|
336
|
-
3. **Tool filtering** - `setActiveTools()` removes denied tools from the LLM's tool list entirely (they don't appear in the API call)
|
|
337
|
-
4. **Defense in depth** - A `tool_call` event handler acts as backup, catching any tools that slip through (e.g., added dynamically after session start)
|
|
338
|
-
5. **System prompt** - The `before_agent_start` event appends the agent's custom prompt to the existing system prompt (doesn't replace it)
|
|
339
|
-
6. **Permission evaluation** - Each tool call is checked against the merged permission rules (global defaults + agent config)
|
|
340
|
-
|
|
341
|
-
## Known Limitations
|
|
342
|
-
|
|
343
|
-
- `disable: true` in custom agents does not currently remove built-in agents (v1 limitation)
|
|
344
|
-
- Bash permission bypass: denying `edit` but allowing `bash` still permits `echo > file` via bash redirection
|
|
345
|
-
- No sub-pattern matching for bash commands (entire bash tool allow/deny only, no per-command filtering)
|
|
346
|
-
- `ask` mode in non-interactive (json/print) mode auto-denies without user input
|
|
347
|
-
- No dynamic permission changes at runtime (permissions are immutable after agent start)
|
|
348
|
-
- No agent permission inheritance chains (flat configs only, no "extends" mechanism)
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
# Subagent Example
|
|
2
|
-
|
|
3
|
-
Delegate tasks to specialized subagents with isolated context windows.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Isolated context**: Each subagent runs in a separate `pi` process
|
|
8
|
-
- **Streaming output**: See tool calls and progress as they happen
|
|
9
|
-
- **Parallel streaming**: All parallel tasks stream updates simultaneously
|
|
10
|
-
- **Markdown rendering**: Final output rendered with proper formatting (expanded view)
|
|
11
|
-
- **Usage tracking**: Shows turns, tokens, cost, and context usage per agent
|
|
12
|
-
- **Abort support**: Ctrl+C propagates to kill subagent processes
|
|
13
|
-
|
|
14
|
-
## Structure
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
subagent/
|
|
18
|
-
├── README.md # This file
|
|
19
|
-
├── index.ts # The extension (entry point)
|
|
20
|
-
├── agents.ts # Agent discovery logic
|
|
21
|
-
├── agents/ # Sample agent definitions
|
|
22
|
-
│ ├── scout.md # Fast recon, returns compressed context
|
|
23
|
-
│ ├── planner.md # Creates implementation plans
|
|
24
|
-
│ ├── reviewer.md # Code review
|
|
25
|
-
│ └── worker.md # General-purpose (full capabilities)
|
|
26
|
-
└── prompts/ # Workflow presets (prompt templates)
|
|
27
|
-
├── implement.md # scout -> planner -> worker
|
|
28
|
-
├── scout-and-plan.md # scout -> planner (no implementation)
|
|
29
|
-
└── implement-and-review.md # worker -> reviewer -> worker
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Installation
|
|
33
|
-
|
|
34
|
-
From the repository root, symlink the files:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Symlink the extension (must be in a subdirectory with index.ts)
|
|
38
|
-
mkdir -p ~/.senpi/agent/extensions/subagent
|
|
39
|
-
ln -sf "$(pwd)/packages/coding-agent/examples/extensions/subagent/index.ts" ~/.senpi/agent/extensions/subagent/index.ts
|
|
40
|
-
ln -sf "$(pwd)/packages/coding-agent/examples/extensions/subagent/agents.ts" ~/.senpi/agent/extensions/subagent/agents.ts
|
|
41
|
-
|
|
42
|
-
# Symlink agents
|
|
43
|
-
mkdir -p ~/.senpi/agent/agents
|
|
44
|
-
for f in packages/coding-agent/examples/extensions/subagent/agents/*.md; do
|
|
45
|
-
ln -sf "$(pwd)/$f" ~/.senpi/agent/agents/$(basename "$f")
|
|
46
|
-
done
|
|
47
|
-
|
|
48
|
-
# Symlink workflow prompts
|
|
49
|
-
mkdir -p ~/.senpi/agent/prompts
|
|
50
|
-
for f in packages/coding-agent/examples/extensions/subagent/prompts/*.md; do
|
|
51
|
-
ln -sf "$(pwd)/$f" ~/.senpi/agent/prompts/$(basename "$f")
|
|
52
|
-
done
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Security Model
|
|
56
|
-
|
|
57
|
-
This tool executes a separate `pi` subprocess with a delegated system prompt and tool/model configuration.
|
|
58
|
-
|
|
59
|
-
**Project-local agents** (`.senpi/agents/*.md`) are repo-controlled prompts that can instruct the model to read files, run bash commands, etc.
|
|
60
|
-
|
|
61
|
-
**Default behavior:** Only loads **user-level agents** from `~/.senpi/agent/agents`.
|
|
62
|
-
|
|
63
|
-
To enable project-local agents, pass `agentScope: "both"` (or `"project"`). Only do this for repositories you trust.
|
|
64
|
-
|
|
65
|
-
When running interactively, the tool prompts for confirmation before running project-local agents. Set `confirmProjectAgents: false` to disable.
|
|
66
|
-
|
|
67
|
-
## Usage
|
|
68
|
-
|
|
69
|
-
### Single agent
|
|
70
|
-
```
|
|
71
|
-
Use scout to find all authentication code
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Parallel execution
|
|
75
|
-
```
|
|
76
|
-
Run 2 scouts in parallel: one to find models, one to find providers
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Chained workflow
|
|
80
|
-
```
|
|
81
|
-
Use a chain: first have scout find the read tool, then have planner suggest improvements
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Workflow prompts
|
|
85
|
-
```
|
|
86
|
-
/implement add Redis caching to the session store
|
|
87
|
-
/scout-and-plan refactor auth to support OAuth
|
|
88
|
-
/implement-and-review add input validation to API endpoints
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Tool Modes
|
|
92
|
-
|
|
93
|
-
| Mode | Parameter | Description |
|
|
94
|
-
|------|-----------|-------------|
|
|
95
|
-
| Single | `{ agent, task }` | One agent, one task |
|
|
96
|
-
| Parallel | `{ tasks: [...] }` | Multiple agents run concurrently (max 8, 4 concurrent) |
|
|
97
|
-
| Chain | `{ chain: [...] }` | Sequential with `{previous}` placeholder |
|
|
98
|
-
|
|
99
|
-
## Output Display
|
|
100
|
-
|
|
101
|
-
**Collapsed view** (default):
|
|
102
|
-
- Status icon (✓/✗/⏳) and agent name
|
|
103
|
-
- Last 5-10 items (tool calls and text)
|
|
104
|
-
- Usage stats: `3 turns ↑input ↓output RcacheRead WcacheWrite $cost ctx:contextTokens model`
|
|
105
|
-
|
|
106
|
-
**Expanded view** (Ctrl+O):
|
|
107
|
-
- Full task text
|
|
108
|
-
- All tool calls with formatted arguments
|
|
109
|
-
- Final output rendered as Markdown
|
|
110
|
-
- Per-task usage (for chain/parallel)
|
|
111
|
-
|
|
112
|
-
**Parallel mode streaming**:
|
|
113
|
-
- Shows all tasks with live status (⏳ running, ✓ done, ✗ failed)
|
|
114
|
-
- Updates as each task makes progress
|
|
115
|
-
- Shows "2/3 done, 1 running" status
|
|
116
|
-
|
|
117
|
-
**Tool call formatting** (mimics built-in tools):
|
|
118
|
-
- `$ command` for bash
|
|
119
|
-
- `read ~/path:1-10` for read
|
|
120
|
-
- `grep /pattern/ in ~/path` for grep
|
|
121
|
-
- etc.
|
|
122
|
-
|
|
123
|
-
## Agent Definitions
|
|
124
|
-
|
|
125
|
-
Agents are markdown files with YAML frontmatter:
|
|
126
|
-
|
|
127
|
-
```markdown
|
|
128
|
-
---
|
|
129
|
-
name: my-agent
|
|
130
|
-
description: What this agent does
|
|
131
|
-
tools: read, grep, find, ls
|
|
132
|
-
model: claude-haiku-4-5
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
System prompt for the agent goes here.
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**Locations:**
|
|
139
|
-
- `~/.senpi/agent/agents/*.md` - User-level (always loaded)
|
|
140
|
-
- `.senpi/agents/*.md` - Project-level (only with `agentScope: "project"` or `"both"`)
|
|
141
|
-
|
|
142
|
-
Project agents override user agents with the same name when `agentScope: "both"`.
|
|
143
|
-
|
|
144
|
-
## Sample Agents
|
|
145
|
-
|
|
146
|
-
| Agent | Purpose | Model | Tools |
|
|
147
|
-
|-------|---------|-------|-------|
|
|
148
|
-
| `scout` | Fast codebase recon | Haiku | read, grep, find, ls, bash |
|
|
149
|
-
| `planner` | Implementation plans | Sonnet | read, grep, find, ls |
|
|
150
|
-
| `reviewer` | Code review | Sonnet | read, grep, find, ls, bash |
|
|
151
|
-
| `worker` | General-purpose | Sonnet | (all default) |
|
|
152
|
-
|
|
153
|
-
## Workflow Prompts
|
|
154
|
-
|
|
155
|
-
| Prompt | Flow |
|
|
156
|
-
|--------|------|
|
|
157
|
-
| `/implement <query>` | scout → planner → worker |
|
|
158
|
-
| `/scout-and-plan <query>` | scout → planner |
|
|
159
|
-
| `/implement-and-review <query>` | worker → reviewer → worker |
|
|
160
|
-
|
|
161
|
-
## Error Handling
|
|
162
|
-
|
|
163
|
-
- **Exit code != 0**: Tool returns error with stderr/output
|
|
164
|
-
- **stopReason "error"**: LLM error propagated with error message
|
|
165
|
-
- **stopReason "aborted"**: User abort (Ctrl+C) kills subprocess, throws error
|
|
166
|
-
- **Chain mode**: Stops at first failing step, reports which step failed
|
|
167
|
-
|
|
168
|
-
## Limitations
|
|
169
|
-
|
|
170
|
-
- Output truncated to last 10 items in collapsed view (expand to see all)
|
|
171
|
-
- Agents discovered fresh on each invocation (allows editing mid-session)
|
|
172
|
-
- Parallel mode limited to 8 tasks, 4 concurrent
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: planner
|
|
3
|
-
description: Creates implementation plans from context and requirements
|
|
4
|
-
tools: read, grep, find, ls
|
|
5
|
-
model: claude-sonnet-4-5
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a planning specialist. You receive context (from a scout) and requirements, then produce a clear implementation plan.
|
|
9
|
-
|
|
10
|
-
You must NOT make any changes. Only read, analyze, and plan.
|
|
11
|
-
|
|
12
|
-
Input format you'll receive:
|
|
13
|
-
- Context/findings from a scout agent
|
|
14
|
-
- Original query or requirements
|
|
15
|
-
|
|
16
|
-
Output format:
|
|
17
|
-
|
|
18
|
-
## Goal
|
|
19
|
-
One sentence summary of what needs to be done.
|
|
20
|
-
|
|
21
|
-
## Plan
|
|
22
|
-
Numbered steps, each small and actionable:
|
|
23
|
-
1. Step one - specific file/function to modify
|
|
24
|
-
2. Step two - what to add/change
|
|
25
|
-
3. ...
|
|
26
|
-
|
|
27
|
-
## Files to Modify
|
|
28
|
-
- `path/to/file.ts` - what changes
|
|
29
|
-
- `path/to/other.ts` - what changes
|
|
30
|
-
|
|
31
|
-
## New Files (if any)
|
|
32
|
-
- `path/to/new.ts` - purpose
|
|
33
|
-
|
|
34
|
-
## Risks
|
|
35
|
-
Anything to watch out for.
|
|
36
|
-
|
|
37
|
-
Keep the plan concrete. The worker agent will execute it verbatim.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: reviewer
|
|
3
|
-
description: Code review specialist for quality and security analysis
|
|
4
|
-
tools: read, grep, find, ls, bash
|
|
5
|
-
model: claude-sonnet-4-5
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a senior code reviewer. Analyze code for quality, security, and maintainability.
|
|
9
|
-
|
|
10
|
-
Bash is for read-only commands only: `git diff`, `git log`, `git show`. Do NOT modify files or run builds.
|
|
11
|
-
Assume tool permissions are not perfectly enforceable; keep all bash usage strictly read-only.
|
|
12
|
-
|
|
13
|
-
Strategy:
|
|
14
|
-
1. Run `git diff` to see recent changes (if applicable)
|
|
15
|
-
2. Read the modified files
|
|
16
|
-
3. Check for bugs, security issues, code smells
|
|
17
|
-
|
|
18
|
-
Output format:
|
|
19
|
-
|
|
20
|
-
## Files Reviewed
|
|
21
|
-
- `path/to/file.ts` (lines X-Y)
|
|
22
|
-
|
|
23
|
-
## Critical (must fix)
|
|
24
|
-
- `file.ts:42` - Issue description
|
|
25
|
-
|
|
26
|
-
## Warnings (should fix)
|
|
27
|
-
- `file.ts:100` - Issue description
|
|
28
|
-
|
|
29
|
-
## Suggestions (consider)
|
|
30
|
-
- `file.ts:150` - Improvement idea
|
|
31
|
-
|
|
32
|
-
## Summary
|
|
33
|
-
Overall assessment in 2-3 sentences.
|
|
34
|
-
|
|
35
|
-
Be specific with file paths and line numbers.
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: scout
|
|
3
|
-
description: Fast codebase recon that returns compressed context for handoff to other agents
|
|
4
|
-
tools: read, grep, find, ls, bash
|
|
5
|
-
model: claude-haiku-4-5
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a scout. Quickly investigate a codebase and return structured findings that another agent can use without re-reading everything.
|
|
9
|
-
|
|
10
|
-
Your output will be passed to an agent who has NOT seen the files you explored.
|
|
11
|
-
|
|
12
|
-
Thoroughness (infer from task, default medium):
|
|
13
|
-
- Quick: Targeted lookups, key files only
|
|
14
|
-
- Medium: Follow imports, read critical sections
|
|
15
|
-
- Thorough: Trace all dependencies, check tests/types
|
|
16
|
-
|
|
17
|
-
Strategy:
|
|
18
|
-
1. grep/find to locate relevant code
|
|
19
|
-
2. Read key sections (not entire files)
|
|
20
|
-
3. Identify types, interfaces, key functions
|
|
21
|
-
4. Note dependencies between files
|
|
22
|
-
|
|
23
|
-
Output format:
|
|
24
|
-
|
|
25
|
-
## Files Retrieved
|
|
26
|
-
List with exact line ranges:
|
|
27
|
-
1. `path/to/file.ts` (lines 10-50) - Description of what's here
|
|
28
|
-
2. `path/to/other.ts` (lines 100-150) - Description
|
|
29
|
-
3. ...
|
|
30
|
-
|
|
31
|
-
## Key Code
|
|
32
|
-
Critical types, interfaces, or functions:
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
interface Example {
|
|
36
|
-
// actual code from the files
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
function keyFunction() {
|
|
42
|
-
// actual implementation
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Architecture
|
|
47
|
-
Brief explanation of how the pieces connect.
|
|
48
|
-
|
|
49
|
-
## Start Here
|
|
50
|
-
Which file to look at first and why.
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: worker
|
|
3
|
-
description: General-purpose subagent with full capabilities, isolated context
|
|
4
|
-
model: claude-sonnet-4-5
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
You are a worker agent with full capabilities. You operate in an isolated context window to handle delegated tasks without polluting the main conversation.
|
|
8
|
-
|
|
9
|
-
Work autonomously to complete the assigned task. Use all available tools as needed.
|
|
10
|
-
|
|
11
|
-
Output format when finished:
|
|
12
|
-
|
|
13
|
-
## Completed
|
|
14
|
-
What was done.
|
|
15
|
-
|
|
16
|
-
## Files Changed
|
|
17
|
-
- `path/to/file.ts` - what changed
|
|
18
|
-
|
|
19
|
-
## Notes (if any)
|
|
20
|
-
Anything the main agent should know.
|
|
21
|
-
|
|
22
|
-
If handing off to another agent (e.g. reviewer), include:
|
|
23
|
-
- Exact file paths changed
|
|
24
|
-
- Key functions/types touched (short list)
|