chore: update stale docs

This commit is contained in:
can1357
2026-08-03 16:37:05 +02:00
parent fc04aa6fa7
commit ebd5e3f86f
120 changed files with 5246 additions and 4691 deletions
+11 -10
View File
@@ -1,6 +1,6 @@
# Hooks
This document describes the **current hook subsystem code** in `src/extensibility/hooks/*`.
This document describes the **current hook subsystem code** in `packages/coding-agent/src/extensibility/hooks/*`.
## Current status in runtime
@@ -15,11 +15,11 @@ So this file documents the legacy hook subsystem implementation itself (types/lo
## Key files
- `src/extensibility/hooks/types.ts` — hook context, event types, and result contracts
- `src/extensibility/hooks/loader.ts` — module loading and hook discovery bridge
- `src/extensibility/hooks/runner.ts` — event dispatch, command lookup, error signaling
- `src/extensibility/hooks/tool-wrapper.ts` — pre/post tool interception wrapper
- `src/extensibility/hooks/index.ts` — exports/re-exports
- `packages/coding-agent/src/extensibility/hooks/types.ts` — hook context, event types, and result contracts
- `packages/coding-agent/src/extensibility/hooks/loader.ts` — module loading and hook discovery bridge
- `packages/coding-agent/src/extensibility/hooks/runner.ts` — event dispatch, command lookup, error signaling
- `packages/coding-agent/src/extensibility/hooks/tool-wrapper.ts` — pre/post tool interception wrapper
- `packages/coding-agent/src/extensibility/hooks/index.ts` — exports/re-exports
## What a hook module is
@@ -47,8 +47,8 @@ The factory can:
- persist non-LLM state with `pi.appendEntry(...)`
- register slash commands via `pi.registerCommand(...)`
- register custom message renderers via `pi.registerMessageRenderer(...)`
- run shell commands via `pi.exec(...)`
- author schemas/helpers with injected `pi.zod`, `pi.typebox`, and package exports via `pi.pi`
- run shell commands via `pi.exec(...)` and log through `pi.logger`
- author schemas/helpers with injected `pi.arktype`, `pi.zod`, legacy-compatible `pi.typebox`, and package exports via `pi.pi`
## Discovery and loading
@@ -165,13 +165,14 @@ On tool failure, wrapper emits `tool_result` with `isError: true` and error text
### What hooks can mutate
- LLM context for a single call via `context` (`messages` replacement chain)
- raw tool execution arguments by returning `input` from `tool_call` (except `computer` calls)
- tool output content/details on successful tool calls (`tool_result` path)
- pre-agent injected message via `before_agent_start`
- cancellation/custom compaction/tree behavior via `session_before_*` and `session.compacting`
### What hooks cannot mutate in this implementation
- raw tool input parameters in-place (only block/allow on `tool_call`)
- a `computer` tool call's raw parameters
- execution continuation after thrown tool errors (error path rethrows)
- final success/error status in wrapper behavior (returned `isError` is typed but not applied by `HookToolWrapper`)
@@ -338,7 +339,7 @@ export default function (pi: HookAPI): void {
## Export surface
`src/extensibility/hooks/index.ts` and the package subpath `@oh-my-pi/pi-coding-agent/extensibility/hooks` export:
`packages/coding-agent/src/extensibility/hooks/index.ts` and the package subpath `@oh-my-pi/pi-coding-agent/extensibility/hooks` export:
- loading APIs (`discoverAndLoadHooks`, `loadHooks`)
- runner and wrapper (`HookRunner`, `HookToolWrapper`)