mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 08:00:59 +00:00
Fix navigateTree API: add missing type updates, handler passthrough, and docs
- Update ExtensionCommandContext.navigateTree type signature - Pass new options through in print-mode and rpc-mode handlers - Update docs/extensions.md, docs/sdk.md, docs/tree.md - Add changelog entry
This commit is contained in:
parent
6b6707f30c
commit
572ec64dbd
7 changed files with 47 additions and 6 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
- Bash tool now displays the timeout value in the UI when a timeout is set ([#780](https://github.com/badlogic/pi-mono/pull/780) by [@dannote](https://github.com/dannote))
|
- Bash tool now displays the timeout value in the UI when a timeout is set ([#780](https://github.com/badlogic/pi-mono/pull/780) by [@dannote](https://github.com/dannote))
|
||||||
- Export `getShellConfig` for extensions to detect user's shell environment ([#766](https://github.com/badlogic/pi-mono/pull/766) by [@dannote](https://github.com/dannote))
|
- Export `getShellConfig` for extensions to detect user's shell environment ([#766](https://github.com/badlogic/pi-mono/pull/766) by [@dannote](https://github.com/dannote))
|
||||||
- Added `thinkingText` and `selectedBg` to theme schema ([#763](https://github.com/badlogic/pi-mono/pull/763) by [@scutifer](https://github.com/scutifer))
|
- Added `thinkingText` and `selectedBg` to theme schema ([#763](https://github.com/badlogic/pi-mono/pull/763) by [@scutifer](https://github.com/scutifer))
|
||||||
|
- `navigateTree()` now supports `replaceInstructions` option to replace the default summarization prompt entirely, and `label` option to attach a label to the branch summary entry ([#787](https://github.com/badlogic/pi-mono/pull/787) by [@mitsuhiko](https://github.com/mitsuhiko))
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -733,9 +733,18 @@ Navigate to a different point in the session tree:
|
||||||
```typescript
|
```typescript
|
||||||
const result = await ctx.navigateTree("entry-id-456", {
|
const result = await ctx.navigateTree("entry-id-456", {
|
||||||
summarize: true,
|
summarize: true,
|
||||||
|
customInstructions: "Focus on error handling changes",
|
||||||
|
replaceInstructions: false, // true = replace default prompt entirely
|
||||||
|
label: "review-checkpoint",
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Options:
|
||||||
|
- `summarize`: Whether to generate a summary of the abandoned branch
|
||||||
|
- `customInstructions`: Custom instructions for the summarizer
|
||||||
|
- `replaceInstructions`: If true, `customInstructions` replaces the default prompt instead of being appended
|
||||||
|
- `label`: Label to attach to the branch summary entry (or target entry if not summarizing)
|
||||||
|
|
||||||
## ExtensionAPI Methods
|
## ExtensionAPI Methods
|
||||||
|
|
||||||
### pi.on(event, handler)
|
### pi.on(event, handler)
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ interface AgentSession {
|
||||||
|
|
||||||
// Forking
|
// Forking
|
||||||
fork(entryId: string): Promise<{ selectedText: string; cancelled: boolean }>; // Creates new session file
|
fork(entryId: string): Promise<{ selectedText: string; cancelled: boolean }>; // Creates new session file
|
||||||
navigateTree(targetId: string, options?: { summarize?: boolean }): Promise<{ editorText?: string; cancelled: boolean }>; // In-place navigation
|
navigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean }>; // In-place navigation
|
||||||
|
|
||||||
// Hook message injection
|
// Hook message injection
|
||||||
sendHookMessage(message: HookMessage, triggerTurn?: boolean): Promise<void>;
|
sendHookMessage(message: HookMessage, triggerTurn?: boolean): Promise<void>;
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,21 @@ interface BranchSummaryEntry {
|
||||||
```typescript
|
```typescript
|
||||||
async navigateTree(
|
async navigateTree(
|
||||||
targetId: string,
|
targetId: string,
|
||||||
options?: { summarize?: boolean; customInstructions?: string }
|
options?: {
|
||||||
|
summarize?: boolean;
|
||||||
|
customInstructions?: string;
|
||||||
|
replaceInstructions?: boolean;
|
||||||
|
label?: string;
|
||||||
|
}
|
||||||
): Promise<{ editorText?: string; cancelled: boolean }>
|
): Promise<{ editorText?: string; cancelled: boolean }>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Options:
|
||||||
|
- `summarize`: Whether to generate a summary of the abandoned branch
|
||||||
|
- `customInstructions`: Custom instructions for the summarizer
|
||||||
|
- `replaceInstructions`: If true, `customInstructions` replaces the default prompt instead of being appended
|
||||||
|
- `label`: Label to attach to the branch summary entry (or target entry if not summarizing)
|
||||||
|
|
||||||
Flow:
|
Flow:
|
||||||
1. Validate target, check no-op (target === current leaf)
|
1. Validate target, check no-op (target === current leaf)
|
||||||
2. Find common ancestor between old leaf and target
|
2. Find common ancestor between old leaf and target
|
||||||
|
|
@ -153,21 +164,28 @@ interface TreePreparation {
|
||||||
commonAncestorId: string | null;
|
commonAncestorId: string | null;
|
||||||
entriesToSummarize: SessionEntry[];
|
entriesToSummarize: SessionEntry[];
|
||||||
userWantsSummary: boolean;
|
userWantsSummary: boolean;
|
||||||
|
customInstructions?: string;
|
||||||
|
replaceInstructions?: boolean;
|
||||||
|
label?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SessionBeforeTreeEvent {
|
interface SessionBeforeTreeEvent {
|
||||||
type: "session_before_tree";
|
type: "session_before_tree";
|
||||||
preparation: TreePreparation;
|
preparation: TreePreparation;
|
||||||
model: Model;
|
|
||||||
signal: AbortSignal;
|
signal: AbortSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SessionBeforeTreeResult {
|
interface SessionBeforeTreeResult {
|
||||||
cancel?: boolean;
|
cancel?: boolean;
|
||||||
summary?: { summary: string; details?: unknown };
|
summary?: { summary: string; details?: unknown };
|
||||||
|
customInstructions?: string; // Override custom instructions
|
||||||
|
replaceInstructions?: boolean; // Override replace mode
|
||||||
|
label?: string; // Override label
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Extensions can override `customInstructions`, `replaceInstructions`, and `label` by returning them from the `session_before_tree` handler.
|
||||||
|
|
||||||
### `session_tree`
|
### `session_tree`
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,10 @@ export interface ExtensionCommandContext extends ExtensionContext {
|
||||||
fork(entryId: string): Promise<{ cancelled: boolean }>;
|
fork(entryId: string): Promise<{ cancelled: boolean }>;
|
||||||
|
|
||||||
/** Navigate to a different point in the session tree. */
|
/** Navigate to a different point in the session tree. */
|
||||||
navigateTree(targetId: string, options?: { summarize?: boolean }): Promise<{ cancelled: boolean }>;
|
navigateTree(
|
||||||
|
targetId: string,
|
||||||
|
options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },
|
||||||
|
): Promise<{ cancelled: boolean }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,12 @@ export async function runPrintMode(session: AgentSession, options: PrintModeOpti
|
||||||
return { cancelled: result.cancelled };
|
return { cancelled: result.cancelled };
|
||||||
},
|
},
|
||||||
navigateTree: async (targetId, options) => {
|
navigateTree: async (targetId, options) => {
|
||||||
const result = await session.navigateTree(targetId, { summarize: options?.summarize });
|
const result = await session.navigateTree(targetId, {
|
||||||
|
summarize: options?.summarize,
|
||||||
|
customInstructions: options?.customInstructions,
|
||||||
|
replaceInstructions: options?.replaceInstructions,
|
||||||
|
label: options?.label,
|
||||||
|
});
|
||||||
return { cancelled: result.cancelled };
|
return { cancelled: result.cancelled };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,12 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
||||||
return { cancelled: result.cancelled };
|
return { cancelled: result.cancelled };
|
||||||
},
|
},
|
||||||
navigateTree: async (targetId, options) => {
|
navigateTree: async (targetId, options) => {
|
||||||
const result = await session.navigateTree(targetId, { summarize: options?.summarize });
|
const result = await session.navigateTree(targetId, {
|
||||||
|
summarize: options?.summarize,
|
||||||
|
customInstructions: options?.customInstructions,
|
||||||
|
replaceInstructions: options?.replaceInstructions,
|
||||||
|
label: options?.label,
|
||||||
|
});
|
||||||
return { cancelled: result.cancelled };
|
return { cancelled: result.cancelled };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue