mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 19:05:11 +00:00
WIP: Add hook API for dynamic tool control with plan-mode hook example
- Add pi.getTools() and pi.setTools(toolNames) to HookAPI - Hooks can now enable/disable tools dynamically - Changes take effect on next agent turn New example hook: plan-mode.ts - Claude Code-style read-only exploration mode - /plan command toggles plan mode on/off - Plan mode tools: read, bash, grep, find, ls - Edit/write tools disabled in plan mode - Injects context telling agent about restrictions - After each response, prompts to execute/stay/refine - State persists across sessions
This commit is contained in:
parent
5b95ccf830
commit
059292ead1
14 changed files with 304 additions and 8 deletions
|
|
@ -752,6 +752,29 @@ const result = await pi.exec("git", ["status"], {
|
|||
// result.stdout, result.stderr, result.code, result.killed
|
||||
```
|
||||
|
||||
### pi.getTools()
|
||||
|
||||
Get the names of currently active tools:
|
||||
|
||||
```typescript
|
||||
const toolNames = pi.getTools();
|
||||
// ["read", "bash", "edit", "write"]
|
||||
```
|
||||
|
||||
### pi.setTools(toolNames)
|
||||
|
||||
Set the active tools by name. Changes take effect on the next agent turn.
|
||||
|
||||
```typescript
|
||||
// Switch to read-only mode (plan mode)
|
||||
pi.setTools(["read", "bash", "grep", "find", "ls"]);
|
||||
|
||||
// Restore full access
|
||||
pi.setTools(["read", "bash", "edit", "write"]);
|
||||
```
|
||||
|
||||
Only built-in tools can be enabled/disabled. Custom tools are always active. Unknown tool names are ignored.
|
||||
|
||||
## Examples
|
||||
|
||||
### Permission Gate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue