@counterposition/skill-pi 0.2.0 → 0.65.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/README.md +3 -0
- package/package.json +1 -1
- package/skills/pi/README.md +24 -20
- package/skills/pi/SKILL.md +1 -0
- package/skills/pi/references/extensions.md +12 -3
- package/skills/pi/references/sdk.md +80 -4
- package/skills/pi/references/settings.md +2 -5
package/README.md
CHANGED
package/package.json
CHANGED
package/skills/pi/README.md
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
# Pi Skill
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Knowing others is intelligence; knowing yourself is true wisdom.
|
|
4
|
+
>
|
|
5
|
+
> — Lao Tzu, *Tao Te Ching*
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
7
|
+
A coding agent that cannot reason about its own architecture will invent APIs that don't exist, hallucinate configuration formats, and give confident wrong answers about its own internals. The failure mode is subtle: the answers *sound* right, because the agent knows how systems like it tend to work. But Pi is specific, and the details matter.
|
|
8
|
+
|
|
9
|
+
This skill gives Pi self-knowledge. It injects task-specific reference documentation into context so that Pi reasons from grounded facts — about its extensions, settings, providers, sessions, and SDK — rather than from plausible fictions.
|
|
10
|
+
|
|
11
|
+
Without this skill, Pi guesses about itself. With it, Pi *knows*.
|
|
8
12
|
|
|
9
13
|
## Install
|
|
10
14
|
|
|
11
15
|
```bash
|
|
12
|
-
#
|
|
16
|
+
# as a skill
|
|
13
17
|
npx skills add counterposition/pi --skill pi
|
|
14
18
|
|
|
15
|
-
#
|
|
19
|
+
# as a Pi package
|
|
16
20
|
pi install npm:@counterposition/skill-pi
|
|
17
21
|
```
|
|
18
22
|
|
|
19
|
-
Maintainer
|
|
23
|
+
### Maintainer Paths
|
|
20
24
|
|
|
21
25
|
```bash
|
|
22
|
-
#
|
|
26
|
+
# from a local checkout
|
|
23
27
|
npx skills add /absolute/path/to/pi --skill pi
|
|
24
28
|
|
|
25
|
-
# packaged
|
|
29
|
+
# packaged install from monorepo root
|
|
26
30
|
pi install ./packages/skill-pi
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
If you
|
|
33
|
+
If you develop inside this repo, Pi already loads the skill via `.pi/settings.json`.
|
|
34
|
+
|
|
35
|
+
## What this covers
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
Pi's architecture and package layout. Skill authoring, discovery, and routing. Extensions, tools, and UI hooks. Settings, models, providers, and packages. Sessions, forks, and compaction. The SDK and RPC interface.
|
|
32
38
|
|
|
33
|
-
-
|
|
34
|
-
- Skill authoring and discovery
|
|
35
|
-
- Extensions, tools, and UI hooks
|
|
36
|
-
- Settings, models, providers, and packages
|
|
37
|
-
- Sessions, forks, and compaction
|
|
39
|
+
The reference material lives in `references/` as task-specific documents — not a single monolith, but pieces sized for injection into a conversation when relevant.
|
|
38
40
|
|
|
39
41
|
## Files
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
| Path | Purpose |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `SKILL.md` | Trigger rules and routing description |
|
|
46
|
+
| `references/` | Task-specific Pi reference documents |
|
|
47
|
+
| `evals/evals.json` | Example evaluation cases |
|
|
48
|
+
| `LICENSE.md` | GPLv3 license text |
|
package/skills/pi/SKILL.md
CHANGED
|
@@ -105,6 +105,7 @@ Read `references/patterns.md` for copy-paste-ready examples.
|
|
|
105
105
|
Sessions are append-only JSONL files with a tree structure (entries linked by `id`/`parentId`). This allows branching without modifying history. Key operations:
|
|
106
106
|
|
|
107
107
|
- **`/tree`** — Navigate the session tree, jump to any point
|
|
108
|
+
- **`Shift+T` in `/tree`** — Toggle timestamps on tree entry labels
|
|
108
109
|
- **`/compact`** — Manually trigger context compaction
|
|
109
110
|
- **`/fork`** — Branch from a specific point
|
|
110
111
|
- **Auto-compaction** — Triggers when `contextTokens > contextWindow - reserveTokens`
|
|
@@ -65,12 +65,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
65
65
|
|
|
66
66
|
Useful session events:
|
|
67
67
|
|
|
68
|
-
- `session_directory`
|
|
69
68
|
- `session_start`
|
|
70
69
|
- `session_before_switch`
|
|
71
|
-
- `session_switch`
|
|
72
70
|
- `session_before_fork`
|
|
73
|
-
- `session_fork`
|
|
74
71
|
- `session_before_compact`
|
|
75
72
|
- `session_compact`
|
|
76
73
|
- `session_before_tree`
|
|
@@ -78,6 +75,18 @@ Useful session events:
|
|
|
78
75
|
- `session_shutdown`
|
|
79
76
|
- `resources_discover`
|
|
80
77
|
|
|
78
|
+
Pi 0.65.0 removed the post-transition `session_switch` and `session_fork` events. Handle startup, reload, new, resume, and fork in `session_start` instead:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
pi.on("session_start", async (event, ctx) => {
|
|
82
|
+
if (event.reason === "fork" && event.previousSessionFile && ctx.hasUI) {
|
|
83
|
+
ctx.ui.notify(`Forked from ${event.previousSessionFile}`, "info");
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Use `event.reason` to distinguish `"startup"`, `"reload"`, `"new"`, `"resume"`, and `"fork"`. For `"new"`, `"resume"`, and `"fork"`, `event.previousSessionFile` points at the session file being replaced.
|
|
89
|
+
|
|
81
90
|
Useful agent events:
|
|
82
91
|
|
|
83
92
|
- `input`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SDK
|
|
2
2
|
|
|
3
|
-
The SDK embeds Pi in Node.js applications via `createAgentSession()`.
|
|
3
|
+
The SDK embeds Pi in Node.js applications via `createAgentSession()`. Use `createAgentSessionRuntime()` when you need `/new`, `/resume`, `/fork`, or import-style session replacement.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -99,12 +99,62 @@ await session.followUp("Summarize the changes afterward");
|
|
|
99
99
|
|
|
100
100
|
`prompt()` expands file-based prompt templates. During active streaming, calling it without `streamingBehavior` throws.
|
|
101
101
|
|
|
102
|
+
## Session Runtime
|
|
103
|
+
|
|
104
|
+
Pi 0.65.0 moved session replacement off `AgentSession` and onto `AgentSessionRuntime`. Use the runtime when you need `newSession()`, `switchSession()`, `fork()`, or `importFromJsonl()`.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import {
|
|
108
|
+
type CreateAgentSessionRuntimeFactory,
|
|
109
|
+
createAgentSessionFromServices,
|
|
110
|
+
createAgentSessionRuntime,
|
|
111
|
+
createAgentSessionServices,
|
|
112
|
+
getAgentDir,
|
|
113
|
+
SessionManager,
|
|
114
|
+
} from "@mariozechner/pi-coding-agent";
|
|
115
|
+
|
|
116
|
+
const createRuntime: CreateAgentSessionRuntimeFactory = async ({
|
|
117
|
+
cwd,
|
|
118
|
+
sessionManager,
|
|
119
|
+
sessionStartEvent,
|
|
120
|
+
}) => {
|
|
121
|
+
const services = await createAgentSessionServices({ cwd });
|
|
122
|
+
return {
|
|
123
|
+
...(await createAgentSessionFromServices({
|
|
124
|
+
services,
|
|
125
|
+
sessionManager,
|
|
126
|
+
sessionStartEvent,
|
|
127
|
+
})),
|
|
128
|
+
services,
|
|
129
|
+
diagnostics: services.diagnostics,
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
134
|
+
cwd: process.cwd(),
|
|
135
|
+
agentDir: getAgentDir(),
|
|
136
|
+
sessionManager: SessionManager.create(process.cwd()),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
let session = runtime.session;
|
|
140
|
+
let unsubscribe = session.subscribe(() => {});
|
|
141
|
+
|
|
142
|
+
await runtime.newSession();
|
|
143
|
+
|
|
144
|
+
unsubscribe();
|
|
145
|
+
session = runtime.session;
|
|
146
|
+
unsubscribe = session.subscribe(() => {});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Notes:
|
|
150
|
+
|
|
151
|
+
- `runtime.session` changes after replacement. Re-subscribe to session-local events after `newSession()`, `switchSession()`, `fork()`, or `importFromJsonl()`.
|
|
152
|
+
- Cross-cwd replacement rebuilds cwd-bound services and session configuration.
|
|
153
|
+
- `runtime.diagnostics` carries startup and replacement diagnostics instead of printing or exiting directly.
|
|
154
|
+
|
|
102
155
|
## Session Surface
|
|
103
156
|
|
|
104
157
|
```typescript
|
|
105
|
-
await session.newSession();
|
|
106
|
-
await session.switchSession("/path/to/session.jsonl");
|
|
107
|
-
await session.fork("entry-id");
|
|
108
158
|
await session.navigateTree("entry-id", { summarize: true });
|
|
109
159
|
await session.compact("Summarize design decisions only");
|
|
110
160
|
|
|
@@ -113,6 +163,8 @@ await session.agent.waitForIdle();
|
|
|
113
163
|
session.dispose();
|
|
114
164
|
```
|
|
115
165
|
|
|
166
|
+
Use `runtime.newSession()`, `runtime.switchSession()`, and `runtime.fork()` for session replacement. Keep `navigateTree()` and `compact()` on the live `session`.
|
|
167
|
+
|
|
116
168
|
Useful state:
|
|
117
169
|
|
|
118
170
|
- `session.sessionFile` / `session.sessionId`
|
|
@@ -155,3 +207,27 @@ session.subscribe((event) => {
|
|
|
155
207
|
- Override `agentsFiles` to inject virtual `AGENTS.md` content
|
|
156
208
|
- Add custom skills or prompt templates without touching disk
|
|
157
209
|
- Share an event bus between the host app and loaded extensions
|
|
210
|
+
|
|
211
|
+
## Standalone Custom Tools
|
|
212
|
+
|
|
213
|
+
Use `defineTool()` when you want a reusable custom tool definition outside `pi.registerTool(...)`:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { defineTool } from "@mariozechner/pi-coding-agent";
|
|
217
|
+
import { Type } from "@sinclair/typebox";
|
|
218
|
+
|
|
219
|
+
const myTool = defineTool({
|
|
220
|
+
name: "my_tool",
|
|
221
|
+
label: "My Tool",
|
|
222
|
+
description: "Does something useful",
|
|
223
|
+
parameters: Type.Object({
|
|
224
|
+
input: Type.String({ description: "Input value" }),
|
|
225
|
+
}),
|
|
226
|
+
async execute(_toolCallId, params) {
|
|
227
|
+
return {
|
|
228
|
+
content: [{ type: "text", text: `Result: ${params.input}` }],
|
|
229
|
+
details: {},
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
```
|
|
@@ -46,6 +46,7 @@ Edit JSON directly or use `/settings` for common interactive options.
|
|
|
46
46
|
|
|
47
47
|
- `doubleEscapeAction`: `"tree"`, `"fork"`, or `"none"`
|
|
48
48
|
- `treeFilterMode`: `"default"`, `"no-tools"`, `"user-only"`, `"labeled-only"`, or `"all"`
|
|
49
|
+
- In `/tree`, `Shift+T` toggles timestamps on entry labels
|
|
49
50
|
|
|
50
51
|
## Compaction, Branch Summary, Retry
|
|
51
52
|
|
|
@@ -119,11 +120,7 @@ Notes:
|
|
|
119
120
|
}
|
|
120
121
|
```
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
1. `--session-dir`
|
|
125
|
-
2. `sessionDir` in settings
|
|
126
|
-
3. Extension `session_directory` hooks
|
|
123
|
+
When multiple sources specify a session directory, `--session-dir` takes precedence over `sessionDir` in settings. Pi 0.65.0 removed the old `session_directory` extension/settings hook.
|
|
127
124
|
|
|
128
125
|
## Resources
|
|
129
126
|
|