@mariozechner/pi-coding-agent 0.63.2 → 0.65.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/CHANGELOG.md +120 -0
- package/README.md +11 -5
- package/dist/cli/args.d.ts +7 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +37 -15
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +83 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +232 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +86 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +116 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +10 -42
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +58 -237
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts +2 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +2 -2
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +20 -28
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +10 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +5 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +70 -8
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +14 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +13 -14
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +7 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/package-manager.d.ts +20 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +32 -0
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +21 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +5 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +3 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +13 -6
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +2 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +15 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +205 -427
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +20 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +14 -3
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +4 -2
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +48 -15
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +12 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +146 -96
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -11
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts +2 -2
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +41 -36
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +95 -64
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +234 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/docs/compaction.md +4 -2
- package/docs/extensions.md +133 -40
- package/docs/json.md +5 -2
- package/docs/keybindings.md +2 -0
- package/docs/rpc.md +21 -7
- package/docs/sdk.md +239 -83
- package/docs/settings.md +1 -1
- package/docs/tree.md +6 -3
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
- package/examples/extensions/hello.ts +18 -17
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/rpc-demo.ts +3 -9
- package/examples/extensions/sandbox/index.ts +4 -0
- package/examples/extensions/status-line.ts +0 -8
- package/examples/extensions/todo.ts +0 -2
- package/examples/extensions/tools.ts +0 -5
- package/examples/extensions/widget-placement.ts +4 -12
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +3 -3
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +7 -4
- package/package.json +4 -4
package/docs/extensions.md
CHANGED
|
@@ -37,6 +37,7 @@ See [examples/extensions/](../examples/extensions/) for working implementations.
|
|
|
37
37
|
- [Extension Styles](#extension-styles)
|
|
38
38
|
- [Events](#events)
|
|
39
39
|
- [Lifecycle Overview](#lifecycle-overview)
|
|
40
|
+
- [Resource Events](#resource-events)
|
|
40
41
|
- [Session Events](#session-events)
|
|
41
42
|
- [Agent Events](#agent-events)
|
|
42
43
|
- [Tool Events](#tool-events)
|
|
@@ -225,10 +226,10 @@ Run `npm install` in the extension directory, then imports from `node_modules/`
|
|
|
225
226
|
### Lifecycle Overview
|
|
226
227
|
|
|
227
228
|
```
|
|
228
|
-
pi starts
|
|
229
|
+
pi starts
|
|
229
230
|
│
|
|
230
|
-
├─►
|
|
231
|
-
└─►
|
|
231
|
+
├─► session_start { reason: "startup" }
|
|
232
|
+
└─► resources_discover { reason: "startup" }
|
|
232
233
|
│
|
|
233
234
|
▼
|
|
234
235
|
user sends prompt ─────────────────────────────────────────┐
|
|
@@ -261,11 +262,15 @@ user sends another prompt ◄─────────────────
|
|
|
261
262
|
|
|
262
263
|
/new (new session) or /resume (switch session)
|
|
263
264
|
├─► session_before_switch (can cancel)
|
|
264
|
-
|
|
265
|
+
├─► session_shutdown
|
|
266
|
+
├─► session_start { reason: "new" | "resume", previousSessionFile? }
|
|
267
|
+
└─► resources_discover { reason: "startup" }
|
|
265
268
|
|
|
266
269
|
/fork
|
|
267
270
|
├─► session_before_fork (can cancel)
|
|
268
|
-
|
|
271
|
+
├─► session_shutdown
|
|
272
|
+
├─► session_start { reason: "fork", previousSessionFile }
|
|
273
|
+
└─► resources_discover { reason: "startup" }
|
|
269
274
|
|
|
270
275
|
/compact or auto-compaction
|
|
271
276
|
├─► session_before_compact (can cancel or customize)
|
|
@@ -282,44 +287,44 @@ exit (Ctrl+C, Ctrl+D)
|
|
|
282
287
|
└─► session_shutdown
|
|
283
288
|
```
|
|
284
289
|
|
|
285
|
-
###
|
|
286
|
-
|
|
287
|
-
See [session.md](session.md) for session storage internals and the SessionManager API.
|
|
288
|
-
|
|
289
|
-
#### session_directory
|
|
290
|
+
### Resource Events
|
|
290
291
|
|
|
291
|
-
|
|
292
|
+
#### resources_discover
|
|
292
293
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
- Startup-only. It is not emitted for later interactive `/new` or `/resume` actions.
|
|
296
|
-
- Lower priority than `--session-dir` and `sessionDir` in `settings.json`.
|
|
297
|
-
- Special-cased to receive no `ctx` argument.
|
|
298
|
-
|
|
299
|
-
If multiple extensions return `sessionDir`, the last one wins.
|
|
300
|
-
Combined precedence is: `--session-dir` CLI flag, then `sessionDir` in settings, then extension `session_directory` hooks.
|
|
294
|
+
Fired after `session_start` so extensions can contribute additional skill, prompt, and theme paths.
|
|
295
|
+
The startup path uses `reason: "startup"`. Reload uses `reason: "reload"`.
|
|
301
296
|
|
|
302
297
|
```typescript
|
|
303
|
-
pi.on("
|
|
298
|
+
pi.on("resources_discover", async (event, _ctx) => {
|
|
299
|
+
// event.cwd - current working directory
|
|
300
|
+
// event.reason - "startup" | "reload"
|
|
304
301
|
return {
|
|
305
|
-
|
|
302
|
+
skillPaths: ["/path/to/skills"],
|
|
303
|
+
promptPaths: ["/path/to/prompts"],
|
|
304
|
+
themePaths: ["/path/to/themes"],
|
|
306
305
|
};
|
|
307
306
|
});
|
|
308
307
|
```
|
|
309
308
|
|
|
309
|
+
### Session Events
|
|
310
|
+
|
|
311
|
+
See [session.md](session.md) for session storage internals and the SessionManager API.
|
|
312
|
+
|
|
310
313
|
#### session_start
|
|
311
314
|
|
|
312
|
-
Fired
|
|
315
|
+
Fired when a session is started, loaded, or reloaded.
|
|
313
316
|
|
|
314
317
|
```typescript
|
|
315
|
-
pi.on("session_start", async (
|
|
318
|
+
pi.on("session_start", async (event, ctx) => {
|
|
319
|
+
// event.reason - "startup" | "reload" | "new" | "resume" | "fork"
|
|
320
|
+
// event.previousSessionFile - present for "new", "resume", and "fork"
|
|
316
321
|
ctx.ui.notify(`Session: ${ctx.sessionManager.getSessionFile() ?? "ephemeral"}`, "info");
|
|
317
322
|
});
|
|
318
323
|
```
|
|
319
324
|
|
|
320
|
-
#### session_before_switch
|
|
325
|
+
#### session_before_switch
|
|
321
326
|
|
|
322
|
-
Fired
|
|
327
|
+
Fired before starting a new session (`/new`) or switching sessions (`/resume`).
|
|
323
328
|
|
|
324
329
|
```typescript
|
|
325
330
|
pi.on("session_before_switch", async (event, ctx) => {
|
|
@@ -331,14 +336,12 @@ pi.on("session_before_switch", async (event, ctx) => {
|
|
|
331
336
|
if (!ok) return { cancel: true };
|
|
332
337
|
}
|
|
333
338
|
});
|
|
334
|
-
|
|
335
|
-
pi.on("session_switch", async (event, ctx) => {
|
|
336
|
-
// event.reason - "new" or "resume"
|
|
337
|
-
// event.previousSessionFile - session we came from
|
|
338
|
-
});
|
|
339
339
|
```
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
After a successful switch or new-session action, pi emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "new" | "resume"` and `previousSessionFile`.
|
|
342
|
+
Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
|
|
343
|
+
|
|
344
|
+
#### session_before_fork
|
|
342
345
|
|
|
343
346
|
Fired when forking via `/fork`.
|
|
344
347
|
|
|
@@ -349,12 +352,11 @@ pi.on("session_before_fork", async (event, ctx) => {
|
|
|
349
352
|
// OR
|
|
350
353
|
return { skipConversationRestore: true }; // Fork but don't rewind messages
|
|
351
354
|
});
|
|
352
|
-
|
|
353
|
-
pi.on("session_fork", async (event, ctx) => {
|
|
354
|
-
// event.previousSessionFile - previous session file
|
|
355
|
-
});
|
|
356
355
|
```
|
|
357
356
|
|
|
357
|
+
After a successful fork, pi emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "fork"` and `previousSessionFile`.
|
|
358
|
+
Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
|
|
359
|
+
|
|
358
360
|
#### session_before_compact / session_compact
|
|
359
361
|
|
|
360
362
|
Fired on compaction. See [compaction.md](compaction.md) for details.
|
|
@@ -735,9 +737,7 @@ Transforms chain across handlers. See [input-transform.ts](../examples/extension
|
|
|
735
737
|
|
|
736
738
|
## ExtensionContext
|
|
737
739
|
|
|
738
|
-
All handlers
|
|
739
|
-
|
|
740
|
-
`session_directory` is a CLI startup hook and receives only the event.
|
|
740
|
+
All handlers receive `ctx: ExtensionContext`.
|
|
741
741
|
|
|
742
742
|
### ctx.ui
|
|
743
743
|
|
|
@@ -920,6 +920,38 @@ Options:
|
|
|
920
920
|
- `replaceInstructions`: If true, `customInstructions` replaces the default prompt instead of being appended
|
|
921
921
|
- `label`: Label to attach to the branch summary entry (or target entry if not summarizing)
|
|
922
922
|
|
|
923
|
+
### ctx.switchSession(sessionPath)
|
|
924
|
+
|
|
925
|
+
Switch to a different session file:
|
|
926
|
+
|
|
927
|
+
```typescript
|
|
928
|
+
const result = await ctx.switchSession("/path/to/session.jsonl");
|
|
929
|
+
if (result.cancelled) {
|
|
930
|
+
// An extension cancelled the switch via session_before_switch
|
|
931
|
+
}
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
To discover available sessions, use the static `SessionManager.list()` or `SessionManager.listAll()` methods:
|
|
935
|
+
|
|
936
|
+
```typescript
|
|
937
|
+
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
|
938
|
+
|
|
939
|
+
pi.registerCommand("switch", {
|
|
940
|
+
description: "Switch to another session",
|
|
941
|
+
handler: async (args, ctx) => {
|
|
942
|
+
const sessions = await SessionManager.list(ctx.cwd);
|
|
943
|
+
if (sessions.length === 0) return;
|
|
944
|
+
const choice = await ctx.ui.select(
|
|
945
|
+
"Pick session:",
|
|
946
|
+
sessions.map(s => s.file),
|
|
947
|
+
);
|
|
948
|
+
if (choice) {
|
|
949
|
+
await ctx.switchSession(choice);
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
});
|
|
953
|
+
```
|
|
954
|
+
|
|
923
955
|
### ctx.reload()
|
|
924
956
|
|
|
925
957
|
Run the same reload flow as `/reload`.
|
|
@@ -936,7 +968,7 @@ pi.registerCommand("reload-runtime", {
|
|
|
936
968
|
|
|
937
969
|
Important behavior:
|
|
938
970
|
- `await ctx.reload()` emits `session_shutdown` for the current extension runtime
|
|
939
|
-
- It then reloads resources and emits `session_start`
|
|
971
|
+
- It then reloads resources and emits `session_start` with `reason: "reload"` and `resources_discover` with reason `"reload"`
|
|
940
972
|
- The currently running command handler still continues in the old call frame
|
|
941
973
|
- Code after `await ctx.reload()` still runs from the pre-reload version
|
|
942
974
|
- Code after `await ctx.reload()` must not assume old in-memory extension state is still valid
|
|
@@ -1008,6 +1040,12 @@ pi.registerTool({
|
|
|
1008
1040
|
action: StringEnum(["list", "add"] as const),
|
|
1009
1041
|
text: Type.Optional(Type.String()),
|
|
1010
1042
|
}),
|
|
1043
|
+
prepareArguments(args) {
|
|
1044
|
+
// Optional compatibility shim. Runs before schema validation.
|
|
1045
|
+
// Return the current schema shape, for example to fold legacy fields
|
|
1046
|
+
// into the modern parameter object.
|
|
1047
|
+
return args;
|
|
1048
|
+
},
|
|
1011
1049
|
|
|
1012
1050
|
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
1013
1051
|
// Stream progress
|
|
@@ -1472,6 +1510,14 @@ pi.registerTool({
|
|
|
1472
1510
|
action: StringEnum(["list", "add"] as const), // Use StringEnum for Google compatibility
|
|
1473
1511
|
text: Type.Optional(Type.String()),
|
|
1474
1512
|
}),
|
|
1513
|
+
prepareArguments(args) {
|
|
1514
|
+
if (!args || typeof args !== "object") return args;
|
|
1515
|
+
const input = args as { action?: string; oldAction?: string };
|
|
1516
|
+
if (typeof input.oldAction === "string" && input.action === undefined) {
|
|
1517
|
+
return { ...input, action: input.oldAction };
|
|
1518
|
+
}
|
|
1519
|
+
return args;
|
|
1520
|
+
},
|
|
1475
1521
|
|
|
1476
1522
|
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
1477
1523
|
// Check for cancellation
|
|
@@ -1515,6 +1561,53 @@ async execute(toolCallId, params) {
|
|
|
1515
1561
|
|
|
1516
1562
|
**Important:** Use `StringEnum` from `@mariozechner/pi-ai` for string enums. `Type.Union`/`Type.Literal` doesn't work with Google's API.
|
|
1517
1563
|
|
|
1564
|
+
**Argument preparation:** `prepareArguments(args)` is optional. If defined, it runs before schema validation and before `execute()`. Use it to mimic an older accepted input shape when pi resumes an older session whose stored tool call arguments no longer match the current schema. Return the object you want validated against `parameters`. Keep the public schema strict. Do not add deprecated compatibility fields to `parameters` just to keep old resumed sessions working.
|
|
1565
|
+
|
|
1566
|
+
Example: an older session may contain an `edit` tool call with top-level `oldText` and `newText`, while the current schema only accepts `edits: [{ oldText, newText }]`.
|
|
1567
|
+
|
|
1568
|
+
```typescript
|
|
1569
|
+
pi.registerTool({
|
|
1570
|
+
name: "edit",
|
|
1571
|
+
label: "Edit",
|
|
1572
|
+
description: "Edit a single file using exact text replacement",
|
|
1573
|
+
parameters: Type.Object({
|
|
1574
|
+
path: Type.String(),
|
|
1575
|
+
edits: Type.Array(
|
|
1576
|
+
Type.Object({
|
|
1577
|
+
oldText: Type.String(),
|
|
1578
|
+
newText: Type.String(),
|
|
1579
|
+
}),
|
|
1580
|
+
),
|
|
1581
|
+
}),
|
|
1582
|
+
prepareArguments(args) {
|
|
1583
|
+
if (!args || typeof args !== "object") return args;
|
|
1584
|
+
|
|
1585
|
+
const input = args as {
|
|
1586
|
+
path?: string;
|
|
1587
|
+
edits?: Array<{ oldText: string; newText: string }>;
|
|
1588
|
+
oldText?: unknown;
|
|
1589
|
+
newText?: unknown;
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
if (typeof input.oldText !== "string" || typeof input.newText !== "string") {
|
|
1593
|
+
return args;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
return {
|
|
1597
|
+
...input,
|
|
1598
|
+
edits: [...(input.edits ?? []), { oldText: input.oldText, newText: input.newText }],
|
|
1599
|
+
};
|
|
1600
|
+
},
|
|
1601
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
1602
|
+
// params now matches the current schema
|
|
1603
|
+
return {
|
|
1604
|
+
content: [{ type: "text", text: `Applying ${params.edits.length} edit block(s)` }],
|
|
1605
|
+
details: {},
|
|
1606
|
+
};
|
|
1607
|
+
},
|
|
1608
|
+
});
|
|
1609
|
+
```
|
|
1610
|
+
|
|
1518
1611
|
### Overriding Built-in Tools
|
|
1519
1612
|
|
|
1520
1613
|
Extensions can override built-in tools (`read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`) by registering a tool with the same name. Interactive mode displays a warning when this happens.
|
|
@@ -2126,7 +2219,7 @@ All examples in [examples/extensions/](../examples/extensions/).
|
|
|
2126
2219
|
| **Compaction & Sessions** |||
|
|
2127
2220
|
| `custom-compaction.ts` | Custom compaction summary | `on("session_before_compact")` |
|
|
2128
2221
|
| `trigger-compact.ts` | Trigger compaction manually | `compact()` |
|
|
2129
|
-
| `git-checkpoint.ts` | Git stash on turns | `on("
|
|
2222
|
+
| `git-checkpoint.ts` | Git stash on turns | `on("turn_start")`, `on("session_before_fork")`, `exec` |
|
|
2130
2223
|
| `auto-commit-on-exit.ts` | Commit on shutdown | `on("session_shutdown")`, `exec` |
|
|
2131
2224
|
| **UI Components** |||
|
|
2132
2225
|
| `status-line.ts` | Footer status indicator | `setStatus`, session events |
|
package/docs/json.md
CHANGED
|
@@ -13,12 +13,15 @@ Events are defined in [`AgentSessionEvent`](https://github.com/badlogic/pi-mono/
|
|
|
13
13
|
```typescript
|
|
14
14
|
type AgentSessionEvent =
|
|
15
15
|
| AgentEvent
|
|
16
|
-
| { type: "
|
|
17
|
-
| { type: "
|
|
16
|
+
| { type: "queue_update"; steering: readonly string[]; followUp: readonly string[] }
|
|
17
|
+
| { type: "compaction_start"; reason: "manual" | "threshold" | "overflow" }
|
|
18
|
+
| { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string }
|
|
18
19
|
| { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }
|
|
19
20
|
| { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string };
|
|
20
21
|
```
|
|
21
22
|
|
|
23
|
+
`queue_update` emits the full pending steering and follow-up queues whenever they change. `compaction_start` and `compaction_end` cover both manual and automatic compaction.
|
|
24
|
+
|
|
22
25
|
Base events from [`AgentEvent`](https://github.com/badlogic/pi-mono/blob/main/packages/agent/src/types.ts#L179):
|
|
23
26
|
|
|
24
27
|
```typescript
|
package/docs/keybindings.md
CHANGED
|
@@ -128,6 +128,8 @@ Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+1
|
|
|
128
128
|
|--------|---------|-------------|
|
|
129
129
|
| `app.tree.foldOrUp` | `ctrl+left`, `alt+left` | Fold current branch segment, or jump to the previous segment start |
|
|
130
130
|
| `app.tree.unfoldOrDown` | `ctrl+right`, `alt+right` | Unfold current branch segment, or jump to the next segment start or branch end |
|
|
131
|
+
| `app.tree.editLabel` | `shift+l` | Edit the label on the selected tree node |
|
|
132
|
+
| `app.tree.toggleLabelTimestamp` | `shift+t` | Toggle label timestamps in the tree |
|
|
131
133
|
|
|
132
134
|
## Custom Configuration
|
|
133
135
|
|
package/docs/rpc.md
CHANGED
|
@@ -725,8 +725,9 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
|
|
|
725
725
|
| `tool_execution_start` | Tool begins execution |
|
|
726
726
|
| `tool_execution_update` | Tool execution progress (streaming output) |
|
|
727
727
|
| `tool_execution_end` | Tool completes |
|
|
728
|
-
| `
|
|
729
|
-
| `
|
|
728
|
+
| `queue_update` | Pending steering/follow-up queue changed |
|
|
729
|
+
| `compaction_start` | Compaction begins |
|
|
730
|
+
| `compaction_end` | Compaction completes |
|
|
730
731
|
| `auto_retry_start` | Auto-retry begins (after transient error) |
|
|
731
732
|
| `auto_retry_end` | Auto-retry completes (success or final failure) |
|
|
732
733
|
| `extension_error` | Extension threw an error |
|
|
@@ -862,19 +863,32 @@ When complete:
|
|
|
862
863
|
|
|
863
864
|
Use `toolCallId` to correlate events. The `partialResult` in `tool_execution_update` contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update.
|
|
864
865
|
|
|
865
|
-
###
|
|
866
|
+
### queue_update
|
|
866
867
|
|
|
867
|
-
Emitted
|
|
868
|
+
Emitted whenever the pending steering or follow-up queue changes.
|
|
868
869
|
|
|
869
870
|
```json
|
|
870
|
-
{
|
|
871
|
+
{
|
|
872
|
+
"type": "queue_update",
|
|
873
|
+
"steering": ["Focus on error handling"],
|
|
874
|
+
"followUp": ["After that, summarize the result"]
|
|
875
|
+
}
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
### compaction_start / compaction_end
|
|
879
|
+
|
|
880
|
+
Emitted when compaction runs, whether manual or automatic.
|
|
881
|
+
|
|
882
|
+
```json
|
|
883
|
+
{"type": "compaction_start", "reason": "threshold"}
|
|
871
884
|
```
|
|
872
885
|
|
|
873
|
-
The `reason` field is `"threshold"
|
|
886
|
+
The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
|
|
874
887
|
|
|
875
888
|
```json
|
|
876
889
|
{
|
|
877
|
-
"type": "
|
|
890
|
+
"type": "compaction_end",
|
|
891
|
+
"reason": "threshold",
|
|
878
892
|
"result": {
|
|
879
893
|
"summary": "Summary of conversation...",
|
|
880
894
|
"firstKeptEntryId": "abc123",
|