Skip to content
Closed
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
8 changes: 8 additions & 0 deletions packages/coding-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased]

### Added

- Exported `convertToPng` for extension authors.

### Changed

- Changed `pi.getAllTools()` to return full readonly tool definitions with source metadata.

## [0.76.0] - 2026-05-27

### New Features
Expand Down
10 changes: 7 additions & 3 deletions packages/coding-agent/docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ To share extensions via npm or git as pi packages, see [packages.md](packages.md

| Package | Purpose |
|---------|---------|
| `@earendil-works/pi-coding-agent` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) |
| `@earendil-works/pi-coding-agent` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) and utilities (`convertToPng`, `resizeImage`) |
| `typebox` | Schema definitions for tool parameters |
| `@earendil-works/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums) |
| `@earendil-works/pi-tui` | TUI components for custom rendering |
Expand Down Expand Up @@ -1489,8 +1489,12 @@ const active = pi.getActiveTools();
const all = pi.getAllTools();
// [{
// name: "read",
// label: "Read",
// description: "Read file contents...",
// parameters: ...,
// parameters: ...,
// execute: async (...),
// renderCall: (...),
// renderResult: (...),
// sourceInfo: { path: "<builtin:read>", source: "builtin", scope: "temporary", origin: "top-level" }
// }, ...]
const names = all.map(t => t.name);
Expand All @@ -1499,7 +1503,7 @@ const extensionTools = all.filter((t) => t.sourceInfo.source !== "builtin" && t.
pi.setActiveTools(["read", "bash"]); // Switch to read-only
```

`pi.getAllTools()` returns `name`, `description`, `parameters`, and `sourceInfo`.
`pi.getAllTools()` returns full tool definitions with `sourceInfo`. Tool items are readonly as a type-level hint; nested schemas are not frozen.

Typical `sourceInfo.source` values:
- `builtin` for built-in tools
Expand Down
6 changes: 2 additions & 4 deletions packages/coding-agent/src/core/agent-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,11 @@ export class AgentSession {
}

/**
* Get all configured tools with name, description, parameter schema, and source metadata.
* Get all configured tools with readonly definitions and source metadata.
*/
getAllTools(): ToolInfo[] {
return Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({
name: definition.name,
description: definition.description,
parameters: definition.parameters,
...definition,
sourceInfo,
}));
}
Expand Down
6 changes: 3 additions & 3 deletions packages/coding-agent/src/core/extensions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ export interface ExtensionAPI {
/** Get the list of currently active tool names. */
getActiveTools(): string[];

/** Get all configured tools with parameter schema and source metadata. */
/** Get all configured tools with readonly definitions and source metadata. */
getAllTools(): ToolInfo[];

/** Set the active tools by name. */
Expand Down Expand Up @@ -1422,8 +1422,8 @@ export type GetSessionNameHandler = () => string | undefined;

export type GetActiveToolsHandler = () => string[];

/** Tool info with name, description, parameter schema, and source metadata */
export type ToolInfo = Pick<ToolDefinition, "name" | "description" | "parameters"> & {
/** Tool definition with source metadata. Readonly is a type-level hint; nested schemas are not frozen. */
export type ToolInfo = Readonly<ToolDefinition> & {
sourceInfo: SourceInfo;
};

Expand Down
1 change: 1 addition & 0 deletions packages/coding-agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ export {
// Clipboard utilities
export { copyToClipboard } from "./utils/clipboard.ts";
export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.ts";
export { convertToPng } from "./utils/image-convert.ts";
export { formatDimensionNote, type ResizedImage, resizeImage } from "./utils/image-resize.ts";
// Shell utilities
export { getShellConfig } from "./utils/shell.ts";