gentle-agent-extensions 0.0.0-stage → 1.0.1
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/.manifest.json +15 -0
- package/README.md +419 -2
- package/agents/.gitkeep +0 -0
- package/assets/.gitkeep +0 -0
- package/docs/conventions.md +278 -0
- package/extensions/gentle-agent-extensions.ts +547 -0
- package/mcp/.gitkeep +31 -0
- package/overlays/.gitkeep +0 -0
- package/package.json +24 -4
- package/routing/.gitkeep +0 -0
- package/scripts/doctor.sh +509 -0
- package/scripts/install.sh +206 -0
- package/scripts/sync.sh +513 -0
- package/skills/gentle-agent-extension/SKILL.md +360 -0
- package/tests/gentle-extensions.test.ts +653 -0
package/.manifest.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0",
|
|
3
|
+
"description": "Manifest of files managed by gentle-agent-extensions. Used by sync.sh to verify ownership and prevent modification of external files.",
|
|
4
|
+
"managedPaths": {
|
|
5
|
+
"extensions": [],
|
|
6
|
+
"agents": [],
|
|
7
|
+
"routing": [],
|
|
8
|
+
"overlays": [],
|
|
9
|
+
"skills": [],
|
|
10
|
+
"mcp": [],
|
|
11
|
+
"scripts": [],
|
|
12
|
+
"assets": []
|
|
13
|
+
},
|
|
14
|
+
"installProfiles": {}
|
|
15
|
+
}
|
package/README.md
CHANGED
|
@@ -1,3 +1,420 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gentle-agent-extensions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Extend Gentle AI and Gentle Pi with custom agents, overlays, routing rules, and skills — declaratively, without modifying the official repositories.
|
|
4
|
+
|
|
5
|
+
## What This Project Does
|
|
6
|
+
|
|
7
|
+
- **Adds custom agents** to Gentle Pi via declarative Markdown definitions
|
|
8
|
+
- **Applies instruction overlays** to existing agents or the orchestrator without modifying their original definitions
|
|
9
|
+
- **Defines routing rules** so the orchestrator knows when to delegate to custom agents
|
|
10
|
+
- **Provides project skills** that teach future agents how to extend this system correctly
|
|
11
|
+
- **Installs as a Pi extension** using the official extension mechanism
|
|
12
|
+
- **Syncs idempotently** — repeated runs with the same configuration produce no changes
|
|
13
|
+
|
|
14
|
+
## What This Project Does NOT Do
|
|
15
|
+
|
|
16
|
+
- ❌ Modify Gentle AI or Gentle Pi official repositories
|
|
17
|
+
- ❌ Create parallel agent registries or skill indexes
|
|
18
|
+
- ❌ Require code changes for new agents/overlays
|
|
19
|
+
- ❌ Install demo agents or overlays by default
|
|
20
|
+
- ❌ Automatically update Gentle AI or Gentle Pi
|
|
21
|
+
|
|
22
|
+
## Architecture
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
gentle-agent-extensions/
|
|
26
|
+
├── agents/ # Custom agent definitions (Markdown + YAML frontmatter)
|
|
27
|
+
├── overlays/ # Instruction overlays for existing agents/orchestrator
|
|
28
|
+
├── routing/ # Delegation rules for custom agents
|
|
29
|
+
├── skills/ # Project skills (including gentle-agent-extension skill)
|
|
30
|
+
├── extensions/ # Pi extension (gentle-agent-extensions.ts)
|
|
31
|
+
├── scripts/ # install.sh, sync.sh, doctor.sh
|
|
32
|
+
├── tests/ # Automated tests
|
|
33
|
+
├── docs/ # Documentation (conventions.md)
|
|
34
|
+
├── .manifest.json # Tracks project-owned files
|
|
35
|
+
└── README.md # This file
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Extension (`extensions/gentle-agent-extensions.ts`)
|
|
39
|
+
|
|
40
|
+
A Pi extension that:
|
|
41
|
+
1. **Discovers** agents, overlays, and skills from project directories on `session_start`
|
|
42
|
+
2. **Injects** orchestrator context via `before_agent_start` using `appendSystemPromptOnce`
|
|
43
|
+
3. **Applies overlays** to target agents/orchestrator at runtime
|
|
44
|
+
4. **Registers commands**: `/gentle-extensions:sync`, `/gentle-extensions:doctor`, `/gentle-extensions:status`
|
|
45
|
+
|
|
46
|
+
### Declarative Conventions
|
|
47
|
+
|
|
48
|
+
See [docs/conventions.md](docs/conventions.md) for complete specification.
|
|
49
|
+
|
|
50
|
+
**Agents** (`agents/{name}.md`):
|
|
51
|
+
```markdown
|
|
52
|
+
---
|
|
53
|
+
name: my-agent
|
|
54
|
+
description: "When to use this agent"
|
|
55
|
+
model: anthropic/claude-opus-4
|
|
56
|
+
thinking: high
|
|
57
|
+
mode: task
|
|
58
|
+
tools: [read, write, bash]
|
|
59
|
+
---
|
|
60
|
+
# Agent Instructions
|
|
61
|
+
...
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Overlays** (`overlays/{target}.overlay.md`):
|
|
65
|
+
```markdown
|
|
66
|
+
---
|
|
67
|
+
target: orchestrator # or agent name
|
|
68
|
+
priority: 100
|
|
69
|
+
mode: append
|
|
70
|
+
---
|
|
71
|
+
# Additional instructions appended to target's prompt
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Routing** (`routing/{agent}.md`):
|
|
75
|
+
```markdown
|
|
76
|
+
---
|
|
77
|
+
agent: my-agent
|
|
78
|
+
triggers: ["trigger phrase"]
|
|
79
|
+
conditions: ["condition"]
|
|
80
|
+
delegation: subagent_run
|
|
81
|
+
---
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Skills** (`skills/{name}/SKILL.md`):
|
|
85
|
+
Follows [Gentle AI Skill Style Guide](https://github.com/Gentleman-Programming/gentle-pi/blob/main/docs/skill-style-guide.md)
|
|
86
|
+
|
|
87
|
+
## Installation
|
|
88
|
+
|
|
89
|
+
### Prerequisites
|
|
90
|
+
|
|
91
|
+
- Pi 1.2.0+
|
|
92
|
+
- Gentle Pi (`gentle-pi` package installed)
|
|
93
|
+
- Node.js 22+
|
|
94
|
+
|
|
95
|
+
### Quick Install
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Clone or navigate to the project
|
|
99
|
+
cd gentle-agent-extensions
|
|
100
|
+
|
|
101
|
+
# Make scripts executable
|
|
102
|
+
chmod +x scripts/*.sh
|
|
103
|
+
|
|
104
|
+
# Install for standard Pi (default profile)
|
|
105
|
+
./scripts/install.sh
|
|
106
|
+
|
|
107
|
+
# Or for Gentle Shell isolated
|
|
108
|
+
./scripts/install.sh --profile gentle-shell
|
|
109
|
+
|
|
110
|
+
# Or for Gentle Shell with --link
|
|
111
|
+
./scripts/install.sh --profile gentle-shell-linked
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Manual Installation Steps
|
|
115
|
+
|
|
116
|
+
1. **Register extension with Pi**:
|
|
117
|
+
```bash
|
|
118
|
+
pi install file:$(pwd)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
2. **Sync project agents/overlays**:
|
|
122
|
+
```bash
|
|
123
|
+
./scripts/sync.sh
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
3. **Verify installation**:
|
|
127
|
+
```bash
|
|
128
|
+
./scripts/doctor.sh
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
4. **Start Pi and check status**:
|
|
132
|
+
```
|
|
133
|
+
/gentle-extensions:status
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Installation Profiles
|
|
137
|
+
|
|
138
|
+
| Profile | Agent Home | Use Case |
|
|
139
|
+
|---------|------------|----------|
|
|
140
|
+
| `pi` | `~/.pi/agent` | Standard Pi installation |
|
|
141
|
+
| `gentle-shell` | `~/.local/share/gentle-shell/agent` | Isolated Gentle Shell |
|
|
142
|
+
| `gentle-shell-linked` | `~/.pi/agent` | Gentle Shell with `--link` |
|
|
143
|
+
|
|
144
|
+
Use `--agent-home PATH` to override the profile default.
|
|
145
|
+
|
|
146
|
+
### Dry Run
|
|
147
|
+
|
|
148
|
+
Preview changes without making them:
|
|
149
|
+
```bash
|
|
150
|
+
./scripts/install.sh --dry-run
|
|
151
|
+
./scripts/sync.sh --dry-run
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Usage
|
|
155
|
+
|
|
156
|
+
### Synchronization
|
|
157
|
+
|
|
158
|
+
After adding/modifying agents, overlays, routing, or skills:
|
|
159
|
+
```bash
|
|
160
|
+
./scripts/sync.sh
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Options:
|
|
164
|
+
- `--dry-run` — Preview changes
|
|
165
|
+
- `--check` — Validate only (exit 1 on issues)
|
|
166
|
+
- `--profile PROFILE` / `--agent-home PATH` — Target installation
|
|
167
|
+
|
|
168
|
+
### Doctor
|
|
169
|
+
|
|
170
|
+
Check installation health:
|
|
171
|
+
```bash
|
|
172
|
+
./scripts/doctor.sh
|
|
173
|
+
./scripts/doctor.sh --verbose # Detailed output
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Checks:
|
|
177
|
+
- Project structure completeness
|
|
178
|
+
- Manifest validity
|
|
179
|
+
- Extension installation
|
|
180
|
+
- Pi / Gentle Pi versions
|
|
181
|
+
- Agent/overlay/skill validation
|
|
182
|
+
- Conflict detection (shadowing, unknown targets)
|
|
183
|
+
- Skill registry status
|
|
184
|
+
- Script permissions
|
|
185
|
+
|
|
186
|
+
### Status Command
|
|
187
|
+
|
|
188
|
+
Inside Pi:
|
|
189
|
+
```
|
|
190
|
+
/gentle-extensions:status
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Shows discovered agents, overlays, skills directory status.
|
|
194
|
+
|
|
195
|
+
## Adding a New Agent
|
|
196
|
+
|
|
197
|
+
Follow **Procedure A** from the `gentle-agent-extension` skill:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# 1. Create agent definition
|
|
201
|
+
cat > agents/my-agent.md <<'EOF'
|
|
202
|
+
---
|
|
203
|
+
name: my-agent
|
|
204
|
+
description: "Reviews code for security issues"
|
|
205
|
+
model: anthropic/claude-opus-4
|
|
206
|
+
thinking: high
|
|
207
|
+
mode: task
|
|
208
|
+
tools: [read, grep, bash]
|
|
209
|
+
---
|
|
210
|
+
# My Agent
|
|
211
|
+
|
|
212
|
+
You are a security reviewer...
|
|
213
|
+
EOF
|
|
214
|
+
|
|
215
|
+
# 2. Create routing (if semantic delegation needed)
|
|
216
|
+
cat > routing/my-agent.md <<'EOF'
|
|
217
|
+
---
|
|
218
|
+
agent: my-agent
|
|
219
|
+
triggers:
|
|
220
|
+
- "security review"
|
|
221
|
+
- "check for vulnerabilities"
|
|
222
|
+
conditions:
|
|
223
|
+
- "User requests security review"
|
|
224
|
+
delegation: subagent_run
|
|
225
|
+
---
|
|
226
|
+
# Routing for my-agent
|
|
227
|
+
...
|
|
228
|
+
EOF
|
|
229
|
+
|
|
230
|
+
# 3. Create skill (for semantic activation)
|
|
231
|
+
mkdir -p skills/my-agent
|
|
232
|
+
cat > skills/my-agent/SKILL.md <<'EOF'
|
|
233
|
+
---
|
|
234
|
+
name: my-agent
|
|
235
|
+
description: "Trigger: security review, check vulnerabilities. Delegates to my-agent for security reviews."
|
|
236
|
+
license: Apache-2.0
|
|
237
|
+
metadata:
|
|
238
|
+
author: your-name
|
|
239
|
+
version: "1.0"
|
|
240
|
+
---
|
|
241
|
+
# My Agent Skill
|
|
242
|
+
## Activation Contract
|
|
243
|
+
Use when user requests security review.
|
|
244
|
+
## Hard Rules
|
|
245
|
+
Only delegate via subagent_run to my-agent.
|
|
246
|
+
## Decision Gates
|
|
247
|
+
| Situation | Action |
|
|
248
|
+
|-----------|--------|
|
|
249
|
+
| "security review" | Delegate to my-agent |
|
|
250
|
+
| General coding | Do NOT delegate |
|
|
251
|
+
## Execution Steps
|
|
252
|
+
1. Identify files to review
|
|
253
|
+
2. Call subagent_run with agent=my-agent
|
|
254
|
+
3. Return results
|
|
255
|
+
## Output Contract
|
|
256
|
+
Security findings with severity
|
|
257
|
+
## References
|
|
258
|
+
- agents/my-agent.md
|
|
259
|
+
- routing/my-agent.md
|
|
260
|
+
EOF
|
|
261
|
+
|
|
262
|
+
# 4. Sync and verify
|
|
263
|
+
./scripts/sync.sh
|
|
264
|
+
./scripts/doctor.sh
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Test in Pi:
|
|
268
|
+
```
|
|
269
|
+
"Please do a security review of my changes"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Adding an Overlay
|
|
273
|
+
|
|
274
|
+
Follow **Procedure B** from the skill:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# 1. Create overlay for existing agent or orchestrator
|
|
278
|
+
cat > overlays/gentle-ai-worker.overlay.md <<'EOF'
|
|
279
|
+
---
|
|
280
|
+
target: gentle-ai-worker
|
|
281
|
+
priority: 100
|
|
282
|
+
mode: append
|
|
283
|
+
---
|
|
284
|
+
# Overlay for gentle-ai-worker
|
|
285
|
+
|
|
286
|
+
## Additional Instructions
|
|
287
|
+
|
|
288
|
+
When writing tests, always use table-driven tests.
|
|
289
|
+
Prefer the project's test utilities.
|
|
290
|
+
EOF
|
|
291
|
+
|
|
292
|
+
# 2. Sync and verify
|
|
293
|
+
./scripts/sync.sh
|
|
294
|
+
./scripts/doctor.sh
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
The overlay instructions are appended to the target agent's prompt at runtime via `before_agent_start`.
|
|
298
|
+
|
|
299
|
+
## Verifying Routing and Activation
|
|
300
|
+
|
|
301
|
+
1. **Check status**: `/gentle-extensions:status`
|
|
302
|
+
2. **Trigger delegation**: Use trigger phrases from routing
|
|
303
|
+
3. **Check doctor**: `./scripts/doctor.sh` validates targets exist
|
|
304
|
+
4. **Inspect prompt**: Add temporary overlay with obvious marker to verify injection
|
|
305
|
+
|
|
306
|
+
## Troubleshooting
|
|
307
|
+
|
|
308
|
+
### Agent Not Discovered
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
./scripts/doctor.sh --verbose
|
|
312
|
+
# Check:
|
|
313
|
+
# - Agent file in agents/ with .md extension
|
|
314
|
+
# - Valid frontmatter with name field
|
|
315
|
+
# - sync.sh ran successfully
|
|
316
|
+
# - Extension loaded (check Pi startup logs)
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Overlay Not Applied
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
./scripts/doctor.sh
|
|
323
|
+
# Check:
|
|
324
|
+
# - Overlay file in overlays/ with .overlay.md extension
|
|
325
|
+
# - Target exists (global agent, project agent, or "orchestrator")
|
|
326
|
+
# - Extension's before_agent_start handler running
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Skill Not Indexed
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# Refresh skill registry
|
|
333
|
+
/skill-registry:refresh
|
|
334
|
+
|
|
335
|
+
# Verify
|
|
336
|
+
cat .atl/skill-registry.md | grep your-skill
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Extension Not Loading
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# Check Pi settings
|
|
343
|
+
cat ~/.pi/agent/settings.json
|
|
344
|
+
# Should include: { "packages": [{ "source": "file:/path/to/gentle-agent-extensions" }] }
|
|
345
|
+
|
|
346
|
+
# Reinstall
|
|
347
|
+
pi remove file:/path/to/gentle-agent-extensions
|
|
348
|
+
pi install file:/path/to/gentle-agent-extensions
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Conflicts Detected
|
|
352
|
+
|
|
353
|
+
Doctor reports:
|
|
354
|
+
- **Shadowing**: Project agent same name as global agent → rename or accept
|
|
355
|
+
- **Unknown overlay target**: Target agent doesn't exist → create agent or fix target name
|
|
356
|
+
|
|
357
|
+
## Limitations
|
|
358
|
+
|
|
359
|
+
| Limitation | Workaround |
|
|
360
|
+
|------------|------------|
|
|
361
|
+
| No agent removal via sync | Manually delete from `.pi/agents/` and manifest |
|
|
362
|
+
| Overlay priority only affects order | Use single overlay per target, or order by priority |
|
|
363
|
+
| Skills require manual registry refresh | Run `/skill-registry:refresh` after adding skills |
|
|
364
|
+
| No hot-reload of extension | Restart Pi or `reload` command |
|
|
365
|
+
| Profile detection is manual | Use `--profile` or `--agent-home` explicitly |
|
|
366
|
+
|
|
367
|
+
## Development
|
|
368
|
+
|
|
369
|
+
### Running Tests
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
node --test tests/gentle-extensions.test.ts
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Project Skill
|
|
376
|
+
|
|
377
|
+
The `gentle-agent-extension` skill teaches agents how to extend this system:
|
|
378
|
+
```
|
|
379
|
+
skills/gentle-agent-extension/SKILL.md
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Load it when working on this project:
|
|
383
|
+
```
|
|
384
|
+
/skill-registry:refresh
|
|
385
|
+
# Then in agent context, the skill will be available for relevant tasks
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Extending the Extension
|
|
389
|
+
|
|
390
|
+
Changes to `extensions/gentle-agent-extensions.ts` are exceptional. Before modifying:
|
|
391
|
+
1. Verify the declarative approach cannot achieve the goal
|
|
392
|
+
2. Document the architectural justification
|
|
393
|
+
3. Update tests and conventions.md
|
|
394
|
+
|
|
395
|
+
## Compatibility
|
|
396
|
+
|
|
397
|
+
Tested with:
|
|
398
|
+
- Pi 1.4.0+
|
|
399
|
+
- gentle-pi (bundled in Gentle Shell)
|
|
400
|
+
- gentle-ai (bundled)
|
|
401
|
+
|
|
402
|
+
Version detection via `doctor.sh`.
|
|
403
|
+
|
|
404
|
+
## License
|
|
405
|
+
|
|
406
|
+
Apache-2.0 — see LICENSE file.
|
|
407
|
+
|
|
408
|
+
## References
|
|
409
|
+
|
|
410
|
+
- [Gentle Pi Documentation](https://github.com/Gentleman-Programming/gentle-shell)
|
|
411
|
+
- [Gentle AI Skill Style Guide](https://github.com/Gentleman-Programming/gentle-pi/blob/main/docs/skill-style-guide.md)
|
|
412
|
+
- [Pi Extensions API](https://pi.dev/docs/latest/extensions)
|
|
413
|
+
- [Pi Packages](https://pi.dev/docs/latest/packages)
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
<div align="center">
|
|
417
|
+
|
|
418
|
+

|
|
419
|
+
|
|
420
|
+
</div>
|
package/agents/.gitkeep
ADDED
|
File without changes
|
package/assets/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Declarative Conventions for gentle-agent-extensions
|
|
2
|
+
|
|
3
|
+
This document defines the file structure and conventions for extending Gentle AI and Gentle Pi through this project.
|
|
4
|
+
|
|
5
|
+
## Directory Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
gentle-agent-extensions/
|
|
9
|
+
├── agents/ # Custom agent definitions (Markdown with YAML frontmatter)
|
|
10
|
+
├── routing/ # Routing instructions for custom agents
|
|
11
|
+
├── overlays/ # Instruction overlays for orchestrator and existing agents
|
|
12
|
+
├── skills/ # Project skills for agent programming
|
|
13
|
+
├── mcp/ # MCP server definitions (JSON)
|
|
14
|
+
├── scripts/ # Installation and synchronization scripts
|
|
15
|
+
├── tests/ # Automated tests
|
|
16
|
+
├── assets/ # Templates, schemas, examples
|
|
17
|
+
├── docs/ # Documentation
|
|
18
|
+
└── .manifest.json # Track project-owned files
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 1. Agent Definitions (`agents/`)
|
|
22
|
+
|
|
23
|
+
Custom agents follow Gentle Pi's native agent format: Markdown files with YAML frontmatter.
|
|
24
|
+
|
|
25
|
+
### File Naming
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
agents/{agent-name}.md
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Frontmatter Schema
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
---
|
|
35
|
+
name: {agent-name}
|
|
36
|
+
description: "One-line description of when this agent should be used"
|
|
37
|
+
model: {provider/model} # optional, e.g. "anthropic/claude-opus-4"
|
|
38
|
+
thinking: {minimal|low|medium|high} # optional
|
|
39
|
+
mode: {task|background} # optional, default: task
|
|
40
|
+
tools: [tool1, tool2, ...] # optional, defaults to Pi defaults
|
|
41
|
+
---
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Body
|
|
45
|
+
|
|
46
|
+
The body contains the agent's instructions/prompt. This follows the same format as Gentle AI's agent definitions.
|
|
47
|
+
|
|
48
|
+
### Discovery
|
|
49
|
+
|
|
50
|
+
Agents are discovered by Gentle Pi from:
|
|
51
|
+
- Global: `~/.pi/agent/agents/`, `~/.pi/agent/subagents/`
|
|
52
|
+
- Project: `<cwd>/.pi/agents/`, `<cwd>/.pi/subagents/`
|
|
53
|
+
|
|
54
|
+
This project's `sync.sh` will symlink or copy agents from `agents/` to the appropriate project directory.
|
|
55
|
+
|
|
56
|
+
## 2. Routing Instructions (`routing/`)
|
|
57
|
+
|
|
58
|
+
Routing instructions tell the orchestrator when to delegate to a custom agent.
|
|
59
|
+
|
|
60
|
+
### File Naming
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
routing/{agent-name}.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Format
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
---
|
|
70
|
+
agent: {agent-name}
|
|
71
|
+
triggers:
|
|
72
|
+
- "trigger phrase 1"
|
|
73
|
+
- "trigger phrase 2"
|
|
74
|
+
conditions:
|
|
75
|
+
- "condition description"
|
|
76
|
+
delegation: subagent_run
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
# Routing Instructions for {agent-name}
|
|
80
|
+
|
|
81
|
+
## When to Use
|
|
82
|
+
|
|
83
|
+
[Description of when this agent should be delegated to]
|
|
84
|
+
|
|
85
|
+
## How to Delegate
|
|
86
|
+
|
|
87
|
+
Use the `subagent_run` tool with:
|
|
88
|
+
- `agent`: "{agent-name}"
|
|
89
|
+
- `task`: "[specific task description]"
|
|
90
|
+
- `label`: "[3-6 word label]"
|
|
91
|
+
- `mode`: "task" | "background"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Skill Integration
|
|
95
|
+
|
|
96
|
+
Each agent that needs semantic routing should have an associated skill in `skills/` with an explicit Activation Contract.
|
|
97
|
+
|
|
98
|
+
## 3. Overlays (`overlays/`)
|
|
99
|
+
|
|
100
|
+
Overlays add instructions to existing agents or the orchestrator without modifying their original definitions.
|
|
101
|
+
|
|
102
|
+
### File Naming
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
overlays/{target-name}.overlay.md
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Where `{target-name}` is either:
|
|
109
|
+
- An agent name (e.g., `gentle-ai-worker.overlay.md`)
|
|
110
|
+
- `orchestrator` for orchestrator-level overlays
|
|
111
|
+
|
|
112
|
+
### Format
|
|
113
|
+
|
|
114
|
+
```markdown
|
|
115
|
+
---
|
|
116
|
+
target: {agent-name|orchestrator}
|
|
117
|
+
priority: 100 # optional, higher = applied later
|
|
118
|
+
mode: append # currently only 'append' is supported
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
# Overlay for {target-name}
|
|
122
|
+
|
|
123
|
+
## Additional Instructions
|
|
124
|
+
|
|
125
|
+
[Instructions to append to the target's prompt]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Application Mechanism
|
|
129
|
+
|
|
130
|
+
Overlays are applied via the `before_agent_start` event by mutating `systemPromptOptions.appendSystemPrompt`. This follows Gentle Pi's established pattern (see `lib/append-system-prompt.ts`).
|
|
131
|
+
|
|
132
|
+
## 4. Skills (`skills/`)
|
|
133
|
+
|
|
134
|
+
Skills follow the Gentle AI skill format with required sections:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
skills/{skill-name}/
|
|
138
|
+
├── SKILL.md
|
|
139
|
+
├── assets/ # optional
|
|
140
|
+
└── references/ # optional
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Required SKILL.md Sections
|
|
144
|
+
|
|
145
|
+
1. **Activation Contract** - When to use this skill
|
|
146
|
+
2. **Hard Rules** - Constraints and restrictions
|
|
147
|
+
3. **Decision Gates** - Decision tables for choices
|
|
148
|
+
4. **Execution Steps** - Step-by-step procedures
|
|
149
|
+
5. **Output Contract** - What the agent should produce
|
|
150
|
+
6. **References** - Local file paths
|
|
151
|
+
|
|
152
|
+
## 5. Installation Profiles
|
|
153
|
+
|
|
154
|
+
The project supports multiple installation targets:
|
|
155
|
+
|
|
156
|
+
| Profile | Agent Home | Use Case |
|
|
157
|
+
|---------|------------|----------|
|
|
158
|
+
| `pi` | `~/.pi/agent` | Standard Pi installation |
|
|
159
|
+
| `gentle-shell` | `~/.local/share/gentle-shell/agent` | Isolated Gentle Shell |
|
|
160
|
+
| `gentle-shell-linked` | `~/.pi/agent` | Gentle Shell with `--link` |
|
|
161
|
+
|
|
162
|
+
## 6. Sync Behavior
|
|
163
|
+
|
|
164
|
+
`sync.sh` performs:
|
|
165
|
+
1. Detect declared features (agents, routing, overlays, skills, mcp)
|
|
166
|
+
2. Validate metadata and files
|
|
167
|
+
3. Resolve native agent/skill paths for the target profile
|
|
168
|
+
4. Install/update only project-owned files
|
|
169
|
+
5. Update skill registry via official mechanism
|
|
170
|
+
6. Prepare orchestrator routing context
|
|
171
|
+
7. Validate overlays, detect conflicts
|
|
172
|
+
8. Update manifest
|
|
173
|
+
9. Report issues requiring intervention
|
|
174
|
+
|
|
175
|
+
Idempotent: repeated runs with same config produce no changes.
|
|
176
|
+
|
|
177
|
+
## 7. MCP Server Definitions (`mcp/`)
|
|
178
|
+
|
|
179
|
+
MCP servers are defined as JSON files in the `mcp/` directory. Each file defines one server.
|
|
180
|
+
|
|
181
|
+
### File Naming
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
mcp/{server-name}.mcp.json
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Schema
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"name": "server-name",
|
|
192
|
+
"description": "What this server provides",
|
|
193
|
+
"transport": "stdio|http",
|
|
194
|
+
"command": "npx",
|
|
195
|
+
"args": ["-y", "@pkg/server"],
|
|
196
|
+
"url": "https://example.com/mcp",
|
|
197
|
+
"env": {"KEY": "${ENV_VAR}"},
|
|
198
|
+
"exposure": "codemode",
|
|
199
|
+
"toolExposure": {},
|
|
200
|
+
"enabled": true,
|
|
201
|
+
"timeout": 60,
|
|
202
|
+
"install": {
|
|
203
|
+
"package": "@pkg/server",
|
|
204
|
+
"version": "1.0.0",
|
|
205
|
+
"manager": "npx"
|
|
206
|
+
},
|
|
207
|
+
"auth": {
|
|
208
|
+
"type": "oauth|bearer|none",
|
|
209
|
+
"envVar": "TOKEN_ENV_VAR",
|
|
210
|
+
"description": "OAuth flow or bearer token"
|
|
211
|
+
},
|
|
212
|
+
"capabilities": ["tools", "resources"],
|
|
213
|
+
"agentDependencies": ["agent-name"]
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Field Descriptions
|
|
218
|
+
|
|
219
|
+
| Field | Required | Description |
|
|
220
|
+
|-------|----------|-------------|
|
|
221
|
+
| `name` | Yes | Unique identifier (letters, digits, `_`, `-` only) |
|
|
222
|
+
| `description` | Yes | One-line description for system prompt |
|
|
223
|
+
| `transport` | Yes | `stdio` or `http` (streamable HTTP) |
|
|
224
|
+
| `command` | stdio only | Executable (not shell command) |
|
|
225
|
+
| `args` | stdio only | Array of arguments |
|
|
226
|
+
| `url` | http only | Server URL |
|
|
227
|
+
| `env` | No | Environment variables; use `${VAR}` for substitution |
|
|
228
|
+
| `exposure` | No | Tool exposure: `codemode` (default), `direct`, `deferred`, `hidden` |
|
|
229
|
+
| `toolExposure` | No | Per-tool exposure overrides |
|
|
230
|
+
| `enabled` | No | Default `true`; `false` keeps entry without connecting |
|
|
231
|
+
| `timeout` | No | Per-request timeout in seconds (default 60) |
|
|
232
|
+
| `install` | No | Installation metadata for optional auto-install |
|
|
233
|
+
| `auth` | No | Authentication requirements (no secrets in repo) |
|
|
234
|
+
| `capabilities` | No | Declared: `tools`, `resources` |
|
|
235
|
+
| `agentDependencies` | No | List of agent names that need this server |
|
|
236
|
+
|
|
237
|
+
### Discovery
|
|
238
|
+
|
|
239
|
+
The extension discovers `*.mcp.json` files in `mcp/` on `session_start` and registers them via `pi.registerMcpServer()`.
|
|
240
|
+
|
|
241
|
+
### Agent MCP Dependencies
|
|
242
|
+
|
|
243
|
+
Agents can declare MCP dependencies in their routing files:
|
|
244
|
+
|
|
245
|
+
```markdown
|
|
246
|
+
---
|
|
247
|
+
agent: my-agent
|
|
248
|
+
mcpDependencies:
|
|
249
|
+
- github
|
|
250
|
+
- filesystem
|
|
251
|
+
---
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
The orchestrator overlay includes available MCP servers and their capabilities.
|
|
255
|
+
|
|
256
|
+
## 8. Manifest Format
|
|
257
|
+
|
|
258
|
+
`.manifest.json` tracks project-owned files:
|
|
259
|
+
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"version": "1.0",
|
|
263
|
+
"managedPaths": {
|
|
264
|
+
"extensions": [".pi/extensions/gentle-agent-extensions.ts"],
|
|
265
|
+
"agents": [".pi/agents/custom-agent.md"],
|
|
266
|
+
"routing": [".pi/routing/custom-agent.md"],
|
|
267
|
+
"overlays": [".pi/overlays/orchestrator.overlay.md"],
|
|
268
|
+
"skills": ["skills/custom-skill/SKILL.md"],
|
|
269
|
+
"mcp": ["mcp/server.mcp.json"],
|
|
270
|
+
"scripts": ["scripts/sync.sh"],
|
|
271
|
+
"assets": []
|
|
272
|
+
},
|
|
273
|
+
"installProfiles": {
|
|
274
|
+
"pi": { "agentHome": "~/.pi/agent" },
|
|
275
|
+
"gentle-shell": { "agentHome": "~/.local/share/gentle-shell/agent" }
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|