diff --git a/packages/coding-agent/README.md b/packages/coding-agent/README.md index eb6091cb..9b569b28 100644 --- a/packages/coding-agent/README.md +++ b/packages/coding-agent/README.md @@ -480,7 +480,7 @@ Hooks are TypeScript modules that extend pi's behavior by subscribing to lifecyc **Quick example** (permission gate): ```typescript -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { pi.on("tool_call", async (event, ctx) => { @@ -499,7 +499,7 @@ Use `pi.send(text, attachments?)` to inject messages into the session. If the ag ```typescript import * as fs from "node:fs"; -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { pi.on("session_start", async () => { diff --git a/packages/coding-agent/docs/hooks.md b/packages/coding-agent/docs/hooks.md index fb0eebcc..a4530d33 100644 --- a/packages/coding-agent/docs/hooks.md +++ b/packages/coding-agent/docs/hooks.md @@ -32,7 +32,7 @@ You can also add explicit hook paths in `~/.pi/agent/settings.json`: A hook is a TypeScript file that exports a default function. The function receives a `HookAPI` object used to subscribe to events. ```typescript -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { pi.on("session_start", async (event, ctx) => { @@ -298,7 +298,7 @@ If the agent is currently streaming, the message is queued. Otherwise, a new age ```typescript import * as fs from "node:fs"; -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { pi.on("session_start", async (event, ctx) => { @@ -328,7 +328,7 @@ To trigger: `echo "Run the tests" > /tmp/agent-trigger.txt` ```typescript import * as http from "node:http"; -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { pi.on("session_start", async (event, ctx) => { @@ -358,7 +358,7 @@ To trigger: `curl -X POST http://localhost:3333 -d "CI build failed"` ### Shitty Permission Gate ```typescript -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { const dangerousPatterns = [ @@ -394,7 +394,7 @@ export default function (pi: HookAPI) { Stash code state at each turn so `/branch` can restore it. ```typescript -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { const checkpoints = new Map(); @@ -434,7 +434,7 @@ export default function (pi: HookAPI) { ### Block Writes to Certain Paths ```typescript -import type { HookAPI } from "@mariozechner/pi-coding-agent"; +import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks"; export default function (pi: HookAPI) { const protectedPaths = [".env", ".git/", "node_modules/"]; diff --git a/packages/coding-agent/package.json b/packages/coding-agent/package.json index ba8d7833..708b9a5f 100644 --- a/packages/coding-agent/package.json +++ b/packages/coding-agent/package.json @@ -12,6 +12,16 @@ }, "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./hooks": { + "types": "./dist/core/hooks/index.d.ts", + "import": "./dist/core/hooks/index.js" + } + }, "files": [ "dist", "docs", diff --git a/pi-mono.code-workspace b/pi-mono.code-workspace index f4900287..dc380bb7 100644 --- a/pi-mono.code-workspace +++ b/pi-mono.code-workspace @@ -3,9 +3,6 @@ { "name": "pi-mono", "path": "." - }, - { - "path": "../../.pi/hooks" } ], "settings": {}