decorated-pi 0.6.0 → 0.7.0
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/README.md +19 -10
- package/commands/dp-settings.ts +6 -1
- package/hooks/mcp.ts +52 -0
- package/hooks/session-title.ts +25 -1
- package/index.ts +33 -22
- package/package.json +4 -3
- package/settings.ts +170 -31
- package/tools/ask/index.ts +93 -0
- package/tools/mcp/builtin/codegraph.ts +10 -34
- package/tools/mcp/builtin/index.ts +2 -2
- package/tools/mcp/config.ts +93 -21
- package/ui/ask.ts +443 -0
- package/ui/module-settings.ts +131 -26
- package/ui/usage.ts +4 -4
- package/.codegraph/daemon.pid +0 -6
- package/AGENTS.md +0 -92
package/AGENTS.md
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# decorated-pi — pi extension
|
|
2
|
-
|
|
3
|
-
## Architecture
|
|
4
|
-
|
|
5
|
-
### Three top-level categories
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
decorated-pi/
|
|
9
|
-
├── AGENTS.md
|
|
10
|
-
├── package.json
|
|
11
|
-
├── settings.ts # ~/.pi/agent/decorated-pi.json read/write
|
|
12
|
-
├── tools/ # LLM-callable tools
|
|
13
|
-
├── hooks/ # agent-loop event handlers
|
|
14
|
-
├── commands/ # slash commands
|
|
15
|
-
├── providers/ # LLM providers
|
|
16
|
-
└── test/ # vitest specs
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
| Category | Role | Knows about |
|
|
20
|
-
|----------|------|-------------|
|
|
21
|
-
| `tools/` | Endpoints the LLM calls | other modules via import only |
|
|
22
|
-
| `hooks/` | Reacts to agent-loop events | primitives, other hooks via skeleton |
|
|
23
|
-
| `commands/` | User-typed `/...` commands | `settings.ts` only |
|
|
24
|
-
|
|
25
|
-
**Hard rules**:
|
|
26
|
-
- A tool never registers a hook (no `pi.on(...)` in `tools/*.ts`).
|
|
27
|
-
- A hook does not care whether the triggering tool was registered by us or by pi core.
|
|
28
|
-
- A command does not participate in the agent loop. Its only shared state with tools is `settings.ts`.
|
|
29
|
-
- The skeleton (`hooks/skeleton.ts`) is the only place that calls `pi.on(...)` for hooks.
|
|
30
|
-
|
|
31
|
-
### Skeleton — `hooks/skeleton.ts`
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
pi core
|
|
35
|
-
│
|
|
36
|
-
│ events
|
|
37
|
-
▼
|
|
38
|
-
┌──────────────┐
|
|
39
|
-
│ skeleton │ ← only place that calls pi.on(...)
|
|
40
|
-
│ │
|
|
41
|
-
│ · collect │
|
|
42
|
-
│ · order │
|
|
43
|
-
│ · dispatch │
|
|
44
|
-
│ · owns: │
|
|
45
|
-
│ - deps │
|
|
46
|
-
│ - prompt │
|
|
47
|
-
└──────┬───────┘
|
|
48
|
-
│
|
|
49
|
-
▼
|
|
50
|
-
registered hooks
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Rules**:
|
|
54
|
-
- Registration order = execution order.
|
|
55
|
-
- Two handler modes: **parallel** (return values ignored) for lifecycle events; **compose** (next handler sees previous return) for transformation chains (`before_agent_start` mutates `systemPrompt`, `tool_call` mutates `input.command`, `tool_result` mutates `content`).
|
|
56
|
-
- The skeleton also owns dependency checking and system-prompt guideline injection — hooks declare them, skeleton enforces them at the right event.
|
|
57
|
-
|
|
58
|
-
### `dp-settings`
|
|
59
|
-
|
|
60
|
-
The only shared state is `settings.ts`. Commands write; `index.ts` reads on `/reload` to decide which tools to register. Neither side imports the other.
|
|
61
|
-
|
|
62
|
-
### Adding a new feature
|
|
63
|
-
|
|
64
|
-
**New tool**:
|
|
65
|
-
1. `tools/<name>.ts` exporting `register<Name>Tool(pi)`.
|
|
66
|
-
2. In `index.ts`: `if (isModuleEnabled("<name>")) register<Name>Tool(pi);`
|
|
67
|
-
3. *(Optional)* In `commands/dp-settings.ts`: add the module label so users can toggle it via `/dp-settings`. Without this the tool is always on; users would have to edit `settings.json` directly to disable.
|
|
68
|
-
|
|
69
|
-
If the tool has its own state, protocol client, or dynamic sub-tools, organize it as a directory instead of a single file: `tools/<name>/{client,manager,...}.ts` plus `tools/<name>/index.ts` exporting `register<Name>Tools(pi)`. See `tools/mcp/` and `tools/lsp/` for examples.
|
|
70
|
-
|
|
71
|
-
**New hook**:
|
|
72
|
-
1. `hooks/<name>.ts` exporting `<name>Module` and optionally `setup<X>(sk)`.
|
|
73
|
-
2. In `hooks/index.ts`: export the setup wrapper.
|
|
74
|
-
3. In `index.ts`: call `setup<X>(sk)` in the right slot (order = execution order).
|
|
75
|
-
4. Inside the setup, call `sk.declareDependency` / `sk.declareGuideline` if needed.
|
|
76
|
-
|
|
77
|
-
**New command**:
|
|
78
|
-
1. `commands/<name>.ts` exporting `register<Name>Command(pi)`.
|
|
79
|
-
2. In `index.ts`: call `register<Name>Command(pi)`.
|
|
80
|
-
|
|
81
|
-
## Test
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
npm test
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Organization rules:
|
|
88
|
-
|
|
89
|
-
- Tests mirror the source layout one-to-one: `extensions/<area>/<name>.ts` → `test/<name>.test.ts`.
|
|
90
|
-
- All spec files live flat in `test/` (no nested folders). For a tool that is a directory (e.g. `tools/mcp/`), the spec is `test/mcp.test.ts` covering the whole module.
|
|
91
|
-
- Sub-features of the same module may get their own file: `test/mcp-externalize.test.ts` for a specific concern of MCP, `test/patch.test.ts` for the patch tool.
|
|
92
|
-
- Every new feature or bug fix ships with a test — run `npm test` before considering the change done.
|