Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@

**/flake.lock
.nvim/
/.pi/agent/extensions/agents/config.json
9 changes: 6 additions & 3 deletions .pi/agent/extensions/COMPOSITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ Use a unique provider ID and stable row IDs within that provider. Return only
rows that belong in the live roster, in display order. Update state before
notifying subscribers. A `parentId` refers to another row from the same
provider. An optional `inspect(rowId, ctx)` opens the provider's detail view;
if it opens an overlay, await dismissal so the dock can restore focus. Call
the function returned by `publishDockProvider` if you need to withdraw the
provider. RPC clients get the collapsed counts only.
if it opens an overlay, await dismissal so the dock can restore focus.
An optional `kill(rowId, ctx)` runs the provider's stop action. Return
`false` if the row does not support it, return normally on success, and
throw on failure. The dock shows a toast for unsupported actions and failures.
Call the function returned by `publishDockProvider` to withdraw the provider.
RPC clients get the collapsed counts only.

## Quiet Transcript: publish presentation hints

Expand Down
41 changes: 20 additions & 21 deletions .pi/agent/extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Local extensions for Pi. Stow links `.pi/agent` to `~/.pi/agent`, so these load
| [codemode-view](#codemode-view) | Transcript | Formatted, highlighted codemode scripts under quiet-transcript rows |
| [code-blocks](#code-blocks) | Transcript | Fenced code block style and table header color |
| [image-chips](#image-chips) | Transcript | Pasted image paths become `[Image N]` chips and attachments |
| [transcript-timestamps](#transcript-timestamps) | Transcript | Clock time and response latency beside messages; `/stamp` |
| [trim-output](#trim-output) | Transcript | Drops invisible trailing spaces from rendered lines |
| [toast](#toast) | Transcript | Transient bottom-right notices; `/toast` |
| [composer](#composer-helper-not-an-extension) | Composer | Helper only: decorator host and focus helpers |
Expand All @@ -30,7 +29,7 @@ Local extensions for Pi. Stow links `.pi/agent` to `~/.pi/agent`, so these load
| [clear](#clear) | Composer | `/clear` as an alias for `/new` |
| [cursor-footer](#cursor-footer) | Footer & status | Footer: model, context %, statuses, cwd, branch, MCP health |
| [dashboard](#dashboard) | Footer & status | Boxed startup header |
| [turn-usage](#turn-usage) | Footer & status | Per-turn token, cache, time summary above the composer |
| [turn-usage](#turn-usage) | Footer & status | Per-turn token, cache, time summary and CPU / RAM readout above the composer |
| [stock](#stock) | Footer & status | `/stock` intraday chart widget |
| [work-dock](#work-dock) | Dock & agents | Shared roster of live agents and processes below the composer |
| [work-dock-processes](#work-dock-processes) | Dock & agents | Publishes `pi-processes` processes to the dock |
Expand All @@ -46,7 +45,7 @@ Local extensions for Pi. Stow links `.pi/agent` to `~/.pi/agent`, so these load
| [shell-guard](#shell-guard) | Misc | Approval prompt for destructive shell commands |
| [no-update-nag](#no-update-nag) | Misc | Silences startup update checks |

Helper-only directories (no default export, imported by the extensions that own them): `composer/`, `composer-layout/`, `native-transcript/`, `toast/`, `transcript-stamp/`, and the non-`index.ts` files inside each extension directory. `processes.json` is data, covered under [work-dock-processes](#work-dock-processes).
Helper-only directories (no default export, imported by the extensions that own them): `composer/`, `composer-layout/`, `native-transcript/`, `toast/`, and the non-`index.ts` files inside each extension directory. `processes.json` is data, covered under [work-dock-processes](#work-dock-processes).

Two names to keep apart: `dashboard.ts` is the startup header; the `/dashboard` command comes from [review](#review).

Expand Down Expand Up @@ -85,6 +84,7 @@ Leaving Expanded through Pi's own toggle lands on Collapsed.
| `lead` | `icon`, `dot`, `icon+dot`, `bar` | `icon` | – |
| `levels` | `{ [tool]: level }`, see below | see below | see below |
| `skillReads` | `true` labels `SKILL.md` reads as `skill` (display only; uses the `read` level) | `false` | `true` |
| `inlineKeep` | number of recent `inline-until-done` tool calls to keep open during a run (at least 1) | `3` | – |
| `diffLines` | preview cap for edit blocks | `20` | `8` |
| `writeLines` | preview cap for write blocks | `8` | – |

Expand All @@ -96,7 +96,7 @@ Invalid values fall back to the default.
| --- | --- |
| `persistent` | The call keeps its own block after the run and separates the summaries on either side |
| `inline` | Block stays open until the run settles, then folds into the summary |
| `inline-until-done` | Open while running and until the next call appears or the run settles, then folds |
| `inline-until-done` | Running calls and the `inlineKeep` most recent calls at this level stay open during the run. New calls at this level fold older finished calls into the summary. All calls fold when the run settles |
| `minimal` | Folded into the shared summary |
| `hidden` | Not shown |
| `native` | Pi's own renderer for that tool |
Expand All @@ -105,17 +105,19 @@ Invalid values fall back to the default.

Default levels: `edit`, `write`, `ask_user_question` → `inline`; `thinking` → `inline-until-done`.

Set here: `edit` and `write` `persistent`; `todo` `hidden`; `thinking`, `web_search`, `bash` `inline-until-done`; `ask_user_question`, `codemode` `inline`.
Set here: `edit`, `write`, and `ask_user_question` `persistent`; `todo` `hidden`; `thinking`, `web_search`, `bash`, and `codemode` `inline-until-done`.

Bash blocks wrap the command under their header: up to 2 rows and the last 5 output rows, or in Expanded the whole command and the last 12 output rows.

Related Pi settings in use: `hideThinkingBlock: true` (Pi's own thinking block is hidden; `levels.thinking` draws thinking inline instead).

### codemode-view

`codemode-view/index.ts`. Publishes a Quiet Transcript presentation for the `codemode` tool: the script (formatted with prettier once its call is complete, syntax highlighted) and the nested tool calls under the row header. Highlights previews successful scripts; Expanded shows the whole script, every nested call, and the full output.
`codemode-view/index.ts`. Publishes a Quiet Transcript presentation for the `codemode` tool: the script (formatted with prettier once its call is complete, syntax highlighted) and the nested tool calls under the row header. Live blocks show the last five output rows, like Bash. Highlights previews successful scripts; Expanded shows the whole script, every nested call, and the full output.

- Setup: `npm install` in `codemode-view/` (prettier). Without it, scripts are shown unformatted.
- Disable: delete `codemode-view/`; codemode rows revert to header plus output.
- Uses the `levels.codemode` setting from quiet-transcript (set here: `inline`).
- Uses the `levels.codemode` setting from quiet-transcript (set here: `inline-until-done`).

### code-blocks

Expand All @@ -139,14 +141,6 @@ Related Pi settings in use: `hideThinkingBlock: true` (Pi's own thinking block i
- Transcript previews are drawn only when Pi's `terminal.showImages` is on (set here: `false`, so only chip labels show); `terminal.imageWidthCells` (set here: `60`) sets preview width.
- Disable: delete `image-chips/`.

### transcript-timestamps

`transcript-timestamps.ts` + `transcript-stamp/layout.ts` (helper) + `native-transcript/insertion.ts` (shared helper). Clock time on user and assistant messages, optionally with the time to the first assistant text. Latency is saved in the session as `local-transcript-timestamp` entries.

- Commands: `/stamp [timestamps|latency] [on|off]`; with no valid argument it reports the current state.
- Settings: stored in `~/.pi/agent/transcript-timestamps.json` (not in dotfiles), not `settings.json`. Keys `showTimestamps` (default `true`) and `showLatency` (default `false`). Currently both `false`.
- Disable: delete the file, or `/stamp timestamps off`.

### trim-output

`trim-output.ts`. Removes trailing plain spaces (that show nothing) from every rendered line, to cut terminal output on full redraws. Leaves lines with backgrounds, inverse, underline, strike, or images alone. Patches `tui.render`. No settings.
Expand All @@ -169,7 +163,7 @@ Several of these attach through the shared decorator host in `composer/api.ts`;

### composer-layout

`composer-layout.ts` + `composer-layout/` (`roles.ts`, `dock-spacing.ts`, helpers). Lays out widgets above the composer in shared slots (`dockFill`, `dockActivity`, `dockTurnSummary`, `dockQueue`) and moves Pi's live working line into that dock. TUI only. Patches sibling render functions; a zero-row widget under the editor is how it finds them. Used by md-viewer, agents, work-dock-processes, turn-usage, steer-queue.
`composer-layout.ts` + `composer-layout/` (`roles.ts`, `dock-spacing.ts`, helpers). Lays out widgets above the composer in shared slots (`dockFill`, `dockActivity`, `dockTurnSummary`, `dockQueue`; `dockTrailing` text joins the turn summary row when it fits) and moves Pi's live working line into that dock. TUI only. Patches sibling render functions; a zero-row widget under the editor is how it finds them. Used by md-viewer, agents, work-dock-processes, turn-usage, steer-queue.

- Disable: delete `composer-layout.ts` (widgets then stack in Pi's default order). Delete `composer-layout/` only if you also remove everything that imports `roles.ts`.

Expand Down Expand Up @@ -243,7 +237,11 @@ Context % turns yellow at 70% and red at 90%. When a router model answers with a

### turn-usage

`turn-usage.ts`. After each run, a dim line above the composer: `12K in · 1.2K out · cache 80% · 4.2s · 3m ago`, shortened to fit. Clears when the next run starts; after an abort or on resume it shows only the age of the last user message. No settings.
`turn-usage.ts`. After each run, a dim line above the composer: `12K in · 1.2K out · cache 80% · 4.2s · 3m ago`, shortened to fit. Clears when the next run starts; after an abort or on resume it shows only the age of the last user message.

A dim, right-aligned `cpu 12% · ram 34% (42/124G)` readout shares the turn summary row when both fit, and takes its own row otherwise. It is hidden while a turn is running. It turns the warning colour at 90% CPU or RAM. Reads `/proc` on Linux (RAM counts reclaimable cache as free) and Node's `os` counters elsewhere.

- Settings (`turnUsage.systemStats`): `false` hides the readout (default on). An object sets `intervalSeconds` (default `2`, minimum `1`) and `show`, which picks and orders readouts from `"cpu"`, `"ram"`, `"load"` (default `["cpu", "ram"]`).

### stock

Expand All @@ -257,7 +255,7 @@ Work Dock has two states: a collapsed one-line count below the composer, and an

`work-dock/index.ts` (+ `api.ts`, `inspector.ts`, `process-activity.ts`). Collects rows from published providers and shows counts like `2 agents · 1 process` below the composer. RPC clients get the collapsed counts only.

- Keys: with the composer empty, **↓** or **←** opens the roster. `↑`/`↓` select, **Enter** inspects the row (if the provider supports it), **Esc** goes back, `Ctrl+C`/`Ctrl+D` close.
- With the composer empty, **↓** or **←** opens the roster. Use **↑**/**↓** to select, **Enter** to inspect, and **x** to stop the selected item. You’ll see a toast if the item doesn’t support stopping. **Esc**, `Ctrl+C`, and `Ctrl+D` close the roster.
- Inspector keys: `Tab` (or `←`/`→`) switches Output / Details, `↑`/`↓`, `PageUp`/`PageDown`, `Ctrl+U`/`Ctrl+D`, `Home`/`End` scroll (scrolling up pauses following; `End` resumes), `Ctrl+O` toggles the provider's view when offered, `Esc` goes back.
- No settings. Delete the directory and `agents` / `work-dock-processes` lose their dock (both import `work-dock/api.ts`; delete or edit them too).

Expand All @@ -275,10 +273,11 @@ Work Dock has two states: a collapsed one-line count below the composer, and an
- Tools registered: `agent`, `agent_message`, `agent_status`, `agent_stop`, `agent_reply`, `contact_supervisor`. Children get a subset (`contact_supervisor` for asking the parent; `agent` only while below `maxDepth`). Children have built-in `bash` but do not load or share `pi-processes`.
- Commands: `/agents` browses runs and definitions (`←`/`→`/`Tab` switch tab, `↑`/`↓` select, `Enter` opens a run, `Esc` closes).
- Definitions: Markdown files with front matter (`name`, `description`, optional `model`, `thinking`, `deny`) in `~/.pi/agent/agents/` and, in trusted projects, `<repo>/.pi/agents/`. A built-in `delegate` agent always exists. Duplicate names within one scope are dropped with a warning.
- Settings: `~/.pi/agent/extensions/agents/config.json` (not `settings.json`; absent by default):
- Settings: `~/.pi/agent/agents.json` (not `settings.json`; absent by default):

| Key | Default |
| --- | --- |
| `defaultModel` | unset (children use the parent's model); `provider/model` or a unique model ID. Precedence: the call's `model`, the definition's `model`, then this |
| `maxLiveRuns` | `4`, across the session including waiting and nested runs |
| `maxDepth` | `2` (main session is depth `0`) |
| `activityWidget.outputLayout` | `off`; `stacked` shows a preview under each run, `inline` one line at the row end |
Expand All @@ -300,7 +299,7 @@ Work Dock has two states: a collapsed one-line count below the composer, and an

### review

`review/index.ts` + modules (server, web UI, tests). Starts a loopback web dashboard for the current session: context-window usage and composition, and code (unstaged, commit ref, GitHub PR) and Markdown review with draft comments sent back to Pi. Footer status `dashboard · <state> · Open ↗` links to it. Full usage in [review/README.md](review/README.md).
`review/index.ts` + modules (server, web UI, tests). Starts a loopback web dashboard for the current session: context-window usage and composition, and code (unstaged, commit ref, GitHub PR) and Markdown review with draft comments sent back to Pi. Footer status `dashboard · <state> · Open ↗` links to Markdown (`review.page` = `context`, `code` or `markdown` picks the page). Full usage in [review/README.md](review/README.md).

- Commands: `/dashboard` and `/review` start (or show) the server; `url` prints the full URL (keep it private; it grants access); `stop` closes it.
- Settings (`review`, optional; not set here): `theme` (`mocha` default, `graphite`, `paper`, `system`), `markdownTheme` (`cursor` default, `inherit`, `graphite`, `mocha`, `paper`).
Expand All @@ -324,7 +323,7 @@ Work Dock has two states: a collapsed one-line count below the composer, and an

### session-prs

`session-prs/index.ts` + `events.ts`, `view.ts`. Registers a `pr` tool (`track`, `untrack`, `refresh`) that the agent calls with a PR URL or `owner/repo#N`, and shows tracked PRs as quiet rows, e.g. `PR · owner/repo#42 ↗ · open · CI passed · Title`. Open PRs are polled once a minute; a merged/closed PR, newly failing CI, or requested changes queues a `session-prs.status.v1` message for the next turn. A successful bash `gh pr create` is tracked automatically. Details in [session-prs/README.md](session-prs/README.md).
`session-prs/index.ts` + `events.ts`, `view.ts`, `status-notice.ts`. Registers a `pr` tool (`track`, `untrack`, `refresh`) that the agent calls with a PR URL or `owner/repo#N`, and shows tracked PRs as quiet rows, e.g. `PR · owner/repo#42 ↗ · open · CI passed · approved · Title`. Open PRs are polled once a minute; a merged or closed PR queues a `session-prs.status.v1` message for the next turn, shown as `▸ pr · merged · owner/repo#42 · Title`. A successful bash `gh pr create` is tracked automatically. Details in [session-prs/README.md](session-prs/README.md).

- Commands: `/prs` or `/prs refresh` fetches status; `/prs clear` dismisses the widget on the current branch.
- Setup: `gh` authenticated for the PR's host. Tracking is stored in session entries.
Expand Down
9 changes: 8 additions & 1 deletion .pi/agent/extensions/agents/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type ActivitySettings = {
};

export type AgentSettings = {
/** Model for agents whose request and definition name none; the parent's model when absent. */
defaultModel?: string;
maxDepth: number;
maxLiveRuns: number;
activityWidget: ActivitySettings;
Expand Down Expand Up @@ -35,7 +37,12 @@ export const parseAgentSettings = (value: unknown): AgentSettings => {
if (layout !== "off" && layout !== "inline" && layout !== "stacked") {
throw new Error('activityWidget.outputLayout must be "off", "inline", or "stacked"');
}
const { defaultModel } = config;
if (defaultModel !== undefined && (typeof defaultModel !== "string" || !defaultModel.trim())) {
throw new Error("defaultModel must be a nonempty string");
}
return {
...(defaultModel === undefined ? {} : { defaultModel: defaultModel.trim() }),
maxDepth: integer(config.maxDepth, "maxDepth", 2, 1),
maxLiveRuns: integer(config.maxLiveRuns, "maxLiveRuns", 4, 1),
activityWidget: {
Expand All @@ -46,7 +53,7 @@ export const parseAgentSettings = (value: unknown): AgentSettings => {
};

export const loadAgentSettings = (agentDir: string): AgentSettings => {
const path = join(agentDir, "extensions", "agents", "config.json");
const path = join(agentDir, "agents.json");
try {
return parseAgentSettings(JSON.parse(readFileSync(path, "utf8")));
} catch (error) {
Expand Down
4 changes: 3 additions & 1 deletion .pi/agent/extensions/agents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default function agents(pi: ExtensionAPI) {
break;
}
},
spawn: (request) => createChild(request, agentDir, (deny): ExtensionFactory => (childPi) => {
spawn: (request) => createChild(
{ ...request, definition: { ...request.definition, model: request.definition.model ?? settings.defaultModel } }, agentDir, (deny): ExtensionFactory => (childPi) => {
registerAgentTools(childPi, {
runtime: () => instance, definitions: () => loaded.definitions, parentId: request.run.id,
deny, canLaunch: request.run.depth < settings.maxDepth, ask: request.ask,
Expand All @@ -85,6 +86,7 @@ export default function agents(pi: ExtensionAPI) {
})),
subscribe: instance.registry.subscribe,
inspect: (id, inspector) => inspectAgent(inspector, source, id),
kill(id) { instance.stop(id); },
});
current = { runtime: instance, async dispose() { dock(); activity(); await instance.shutdown(); } };
});
Expand Down
4 changes: 3 additions & 1 deletion .pi/agent/extensions/agents/test/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ test("runtime and preview settings have validated defaults and overrides", () =>
assert.deepEqual(parseAgentSettings({ maxLiveRuns: 7, maxDepth: 3, activityWidget: { outputLayout: "inline", stackedPreviewLines: 5 } }), {
maxDepth: 3, maxLiveRuns: 7, activityWidget: { outputLayout: "inline", stackedPreviewLines: 5 },
});
for (const invalid of [{ maxLiveRuns: 0 }, { maxDepth: 2.5 }, { activityWidget: { stackedPreviewLines: 6 } }, { activityWidget: { outputLayout: "hidden" } }, { activityWidget: null }]) {
assert.equal(parseAgentSettings({ defaultModel: " p/m " }).defaultModel, "p/m");
assert.equal("defaultModel" in parseAgentSettings({}), false);
for (const invalid of [{ defaultModel: "" }, { defaultModel: 3 }, { maxLiveRuns: 0 }, { maxDepth: 2.5 }, { activityWidget: { stackedPreviewLines: 6 } }, { activityWidget: { outputLayout: "hidden" } }, { activityWidget: null }]) {
assert.throws(() => parseAgentSettings(invalid));
}
});
Expand Down
2 changes: 1 addition & 1 deletion .pi/agent/extensions/composer-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function (pi: ExtensionAPI) {
const docked = isWorking();
const statusRows = renderStatus.call(status, width);
const parts = children.map((child) => child.render?.(width) ?? []);
const segments = layoutDock(children, parts, docked ? statusRows : [], !docked && isDockBlank(statusRows.at(-1)));
const segments = layoutDock(children, parts, docked ? statusRows : [], !docked && isDockBlank(statusRows.at(-1)), width);
// Use the same positions for paint and mouse dispatch.
above.mouseLayout = {
width,
Expand Down
Loading