mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 08:03:39 +00:00
Add ./hooks subpath export for cleaner imports
This commit is contained in:
parent
7c553acd1e
commit
1abc635044
4 changed files with 18 additions and 11 deletions
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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<number, string>();
|
||||
|
|
@ -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/"];
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@
|
|||
{
|
||||
"name": "pi-mono",
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../../.pi/hooks"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue