@agimon-ai/doompi-hook 0.0.1-alpha.3 → 0.0.1-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -10
- package/dist/adapters/pi/extension.cjs +1 -1
- package/dist/adapters/pi/extension.cjs.map +1 -1
- package/dist/adapters/pi/extension.d.cts.map +1 -1
- package/dist/adapters/pi/extension.d.mts.map +1 -1
- package/dist/adapters/pi/extension.mjs +1 -1
- package/dist/adapters/pi/extension.mjs.map +1 -1
- package/dist/types/hooks.d.cts +5 -5
- package/dist/types/hooks.d.cts.map +1 -1
- package/dist/types/hooks.d.mts +5 -5
- package/dist/types/hooks.d.mts.map +1 -1
- package/dist/types/telemetry.d.cts +2 -2
- package/dist/types/telemetry.d.cts.map +1 -1
- package/dist/types/telemetry.d.mts +2 -2
- package/dist/types/telemetry.d.mts.map +1 -1
- package/llms.txt +6 -2
- package/package.json +20 -11
- package/src/prompts/doompi-author-hook/SKILL.md +51 -0
package/README.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# @agimon-ai/doompi-hook
|
|
2
2
|
|
|
3
|
-
Claude
|
|
3
|
+
Claude Code-compatible repository and plugin hooks for
|
|
4
4
|
[DoomPi](https://www.npmjs.com/package/@agimon-ai/doompi) sessions.
|
|
5
5
|
|
|
6
6
|
A **hook** is a shell command the repository runs at a point in the session: before a tool call,
|
|
7
7
|
after one, at session start, when the agent settles, and at session end. Commands are declared in
|
|
8
|
-
`.doom/hooks.yaml`, grouped so a mode can turn a whole family of them on or off
|
|
8
|
+
`.doom/hooks.yaml`, grouped so a mode can turn a whole family of them on or off.
|
|
9
|
+
|
|
10
|
+
> **Alpha:** hook configuration and runtime contracts may change between releases.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
- Node.js 22.19.0 or newer
|
|
15
|
+
- Pi 0.84.4
|
|
16
|
+
- `/bin/bash`
|
|
17
|
+
|
|
18
|
+
Configure hooks in `.doom/hooks.yaml`:
|
|
9
19
|
|
|
10
20
|
```yaml
|
|
11
21
|
# .doom/hooks.yaml
|
|
@@ -25,9 +35,9 @@ groups:
|
|
|
25
35
|
skipInSubagent: true
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
A group marked `core: true` always loads. Every other group loads only when the active mode
|
|
29
|
-
it. The same document is read from the global `.doom` directory and from the repository
|
|
30
|
-
repository group replaces the global group of the same
|
|
38
|
+
A group marked `core: true` always loads. Every other group loads only when the active mode selects
|
|
39
|
+
it. The same document is read from the global `.doom` directory and from the repository. A
|
|
40
|
+
repository group replaces the global group of the same ID outright.
|
|
31
41
|
|
|
32
42
|
## Activation
|
|
33
43
|
|
|
@@ -41,14 +51,16 @@ layers:
|
|
|
41
51
|
hookGroups: [safety, workflow]
|
|
42
52
|
```
|
|
43
53
|
|
|
44
|
-
A session with no selected `hookGroups` still runs groups marked `core: true`; other groups remain
|
|
54
|
+
A session with no selected `hookGroups` still runs groups marked `core: true`; other groups remain
|
|
55
|
+
inactive.
|
|
45
56
|
|
|
46
57
|
## What a hook sees and can say
|
|
47
58
|
|
|
48
59
|
Each command is run through `/bin/bash -c` in the repository root, with the Claude Code payload for
|
|
49
|
-
the event on stdin
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
the event on stdin. The environment includes `CLAUDE_PROJECT_DIR`, `CODEX_REPO_ROOT`, and
|
|
61
|
+
`ORIGINAL_REPO_PATH`. Every resolved hook also receives `CLAUDE_PLUGIN_ROOT`, set to the root that
|
|
62
|
+
declared its repository, personal, or plugin configuration. Tool names in the payload and in
|
|
63
|
+
`matcher` are Claude names (`Bash`, `Write`), not Pi's.
|
|
52
64
|
|
|
53
65
|
The last stdout line that starts with `{` is read as the hook's decision:
|
|
54
66
|
|
|
@@ -70,7 +82,13 @@ indistinguishable from one that passed.
|
|
|
70
82
|
expires, is sent `SIGTERM` and then `SIGKILL` two seconds later, so a stalled hook does not leave
|
|
71
83
|
the processes it started behind.
|
|
72
84
|
|
|
73
|
-
##
|
|
85
|
+
## Help guidance
|
|
86
|
+
|
|
87
|
+
While the Help minor mode is active, this package contributes `doompi-author-hook`. The prompt
|
|
88
|
+
covers `.doom/hooks.yaml`, group activation, commands, payloads, decisions, and verification, and
|
|
89
|
+
is withdrawn when the package or Help provider unloads.
|
|
90
|
+
|
|
91
|
+
## Install
|
|
74
92
|
|
|
75
93
|
DoomPi already includes this package. For standalone Pi installation:
|
|
76
94
|
|
|
@@ -78,6 +96,24 @@ DoomPi already includes this package. For standalone Pi installation:
|
|
|
78
96
|
pi install npm:@agimon-ai/doompi-hook
|
|
79
97
|
```
|
|
80
98
|
|
|
99
|
+
## Public API
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { createBashHookRunner, hookExtension } from '@agimon-ai/doompi-hook';
|
|
103
|
+
import type { HookDecision, HookEventName } from '@agimon-ai/doompi-hook';
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Development
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm build
|
|
110
|
+
pnpm typecheck
|
|
111
|
+
pnpm test
|
|
112
|
+
pnpm lint
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Maintained by [Agimon](https://agimon.ai/about).
|
|
116
|
+
|
|
81
117
|
## License
|
|
82
118
|
|
|
83
119
|
MIT
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../hookDocuments.cjs"),t=require("../hookRunner.cjs"),n=require("../telemetry/logSinkTelemetry.cjs"),r=require("./hookHandlers.cjs");let i=require("@agimon-ai/doompi-extension-contracts/readiness"),a=require("@agimon-ai/doompi-extension-contracts/cordis-host"),o=require("@agimon-ai/doompi-extension-contracts/config"),s=require("@agimon-ai/doompi-config/piContext");const
|
|
1
|
+
const e=require("../hookDocuments.cjs"),t=require("../hookRunner.cjs"),n=require("../telemetry/logSinkTelemetry.cjs"),r=require("./hookHandlers.cjs");let i=require("@agimon-ai/doompi-extension-contracts/readiness"),a=require("@agimon-ai/doompi-extension-contracts/cordis-host"),o=require("@agimon-ai/doompi-extension-contracts/config"),s=require("@agimon-ai/doompi-extension-contracts/help"),c=require("@agimon-ai/doompi-config/piContext");const l=`@agimon-ai/doompi-hook`;function u(r,i){let a=i.telemetry,o=()=>a??=n.createHookTelemetry();return{config:()=>(0,c.requireDoomConfigContext)(r),runner:i.runner??t.createBashHookRunner({telemetry:o()}),documents:i.documents??e.createHookDocumentReader({telemetry:o()})}}function d(e,t){let n=u(e,t),r=!0,a=0,o;return{session:n,readiness:{start(t,n){let s=++a,c=()=>r&&s===a,u=(0,i.readDoomReadinessCoordinator)(e);if(!u)return n(new AbortController().signal,c);let d=o,f=(async()=>{d?.coordinator===u&&await d.operation.catch(()=>void 0),c()&&await u.start(l,`${t.sessionManager.getSessionId()}:${s}`,async e=>(await n(e,c),{value:void 0})).wait()})();f.catch(()=>void 0),o={sessionManager:t.sessionManager,coordinator:u,operation:f}},async wait(e){let t=o;if(t){if(t.sessionManager!==e.sessionManager)throw Error(`Hook readiness belongs to a stale Pi session.`);if(await t.operation,!r||t!==o)throw Error(`Hook readiness belongs to a stale extension generation.`)}}},isCurrent:()=>r,dispose(){r=!1,a+=1,o=void 0}}}function f(e,{pi:t,options:n}){e.inject([s.DOOM_HELP_SERVICE],e=>{let t=(0,s.requireDoomHelpService)(e).register({source:l,moduleUrl:require("url").pathToFileURL(__filename).href,skills:[{name:`doompi-author-hook`,description:`Author DoomPi repository or plugin hooks. Use when creating or changing .doom/hooks.yaml, selecting hook groups from modes.yaml, writing hook commands, or adapting Claude Code hook payloads and decisions to DoomPi.`}]});return()=>t.dispose()});let i;e.inject([o.DOOM_CONFIG_SERVICE],e=>{let t=d(e,n);i=t,e.effect(()=>()=>{t.dispose(),i===t&&(i=void 0)},`${l}/config-runtime`)}),e.effect(function*(){for(let e of r.registerHookHandlers(t,()=>i))yield e;yield()=>{i=void 0}},l);let a;t.on(`session_shutdown`,(e,t)=>{let n=i;if(n?.isCurrent())return a??=r.runSessionEndHooks(n.session,t),a})}async function p(e,t={}){let n=await(0,a.connectDoomCordisHost)(e,l),r=n.root.plugin(f,{pi:e,options:t});try{await r}catch(e){try{await r.dispose()}finally{await n.dispose()}throw e}let i;e.on(`session_shutdown`,()=>i??=(async()=>{try{await r.dispose()}finally{await n.dispose()}})())}exports.default=p,exports.hookExtension=p;
|
|
2
2
|
//# sourceMappingURL=extension.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.cjs","names":["createHookTelemetry","requireDoomConfigContext","createBashHookRunner","createHookDocumentReader","readDoomReadinessCoordinator","DOOM_CONFIG_SERVICE","registerHookHandlers","runSessionEndHooks","connectDoomCordisHost"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type DoomReadinessCoordinator,\n readDoomReadinessCoordinator,\n} from '@agimon-ai/doompi-extension-contracts/readiness';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { requireDoomConfigContext } from '@agimon-ai/doompi-config/piContext';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { HookDocumentReader, HookRunner } from '../../types/hooks.ts';\nimport type { HookTelemetry } from '../../types/telemetry.ts';\nimport { createHookDocumentReader } from '../hookDocuments.ts';\nimport { createBashHookRunner } from '../hookRunner.ts';\nimport { createHookTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport {\n type HookReadinessGate,\n type HookRuntime,\n type HookSession,\n registerHookHandlers,\n runSessionEndHooks,\n} from './hookHandlers.ts';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-hook';\n\nexport interface HookExtensionOptions {\n telemetry?: HookTelemetry;\n runner?: HookRunner;\n documents?: HookDocumentReader;\n}\n\nfunction hookSession(cordis: Context, options: HookExtensionOptions): HookSession {\n // The log sink is only built if something actually reports to it, so a fully\n // stubbed session never touches the telemetry backend.\n let telemetry = options.telemetry;\n const requireTelemetry = (): HookTelemetry => (telemetry ??= createHookTelemetry());\n return {\n config: () => requireDoomConfigContext(cordis),\n runner: options.runner ?? createBashHookRunner({ telemetry: requireTelemetry() }),\n documents: options.documents ?? createHookDocumentReader({ telemetry: requireTelemetry() }),\n };\n}\n\ninterface HookPluginConfig {\n readonly pi: ExtensionAPI;\n readonly options: HookExtensionOptions;\n}\n\ninterface HookRuntimeBinding extends HookRuntime {\n dispose(): void;\n}\n\nfunction createHookRuntime(cordis: Context, options: HookExtensionOptions): HookRuntimeBinding {\n const session = hookSession(cordis, options);\n let active = true;\n let generation = 0;\n let readiness:\n | {\n readonly sessionManager: object;\n readonly coordinator: DoomReadinessCoordinator;\n readonly operation: Promise<void>;\n }\n | undefined;\n const readinessGate: HookReadinessGate = {\n start(context, operation) {\n const ownGeneration = ++generation;\n const isCurrent = (): boolean => active && ownGeneration === generation;\n const coordinator = readDoomReadinessCoordinator(cordis);\n if (!coordinator) return operation(new AbortController().signal, isCurrent);\n\n const previous = readiness;\n const readinessOperation = (async (): Promise<void> => {\n if (previous?.coordinator === coordinator) await previous.operation.catch(() => undefined);\n if (!isCurrent()) return;\n const handle = coordinator.start(\n PACKAGE_SOURCE,\n `${context.sessionManager.getSessionId()}:${ownGeneration}`,\n async (signal) => {\n await operation(signal, isCurrent);\n return { value: undefined };\n },\n );\n await handle.wait();\n })();\n // Config's coordinator owns the single user-facing failure notification.\n void readinessOperation.catch(() => undefined);\n readiness = {\n sessionManager: context.sessionManager,\n coordinator,\n operation: readinessOperation,\n };\n return undefined;\n },\n async wait(context: ExtensionContext): Promise<void> {\n const current = readiness;\n if (!current) return;\n if (current.sessionManager !== context.sessionManager) {\n throw new Error('Hook readiness belongs to a stale Pi session.');\n }\n await current.operation;\n if (!active || current !== readiness) {\n throw new Error('Hook readiness belongs to a stale extension generation.');\n }\n },\n };\n return {\n session,\n readiness: readinessGate,\n isCurrent: () => active,\n dispose() {\n active = false;\n generation += 1;\n readiness = undefined;\n },\n };\n}\n\nfunction hookPlugin(cordis: Context, { pi, options }: HookPluginConfig): void {\n let runtime: HookRuntimeBinding | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE], (configContext) => {\n const binding = createHookRuntime(configContext, options);\n runtime = binding;\n configContext.effect(\n () => () => {\n binding.dispose();\n if (runtime === binding) runtime = undefined;\n },\n `${PACKAGE_SOURCE}/config-runtime`,\n );\n });\n\n cordis.effect(function* () {\n for (const disposeRegistration of registerHookHandlers(pi, () => runtime)) yield disposeRegistration;\n yield () => {\n runtime = undefined;\n };\n }, PACKAGE_SOURCE);\n\n let shutdown: Promise<void> | undefined;\n pi.on('session_shutdown', (_event, ctx) => {\n const current = runtime;\n if (!current?.isCurrent()) return undefined;\n shutdown ??= runSessionEndHooks(current.session, ctx);\n return shutdown;\n });\n}\n\n/** The package's single standard Pi factory. */\nexport async function hookExtension(pi: ExtensionAPI, options: HookExtensionOptions = {}): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(hookPlugin, { pi, options });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default hookExtension;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension.cjs","names":["createHookTelemetry","requireDoomConfigContext","createBashHookRunner","createHookDocumentReader","readDoomReadinessCoordinator","DOOM_HELP_SERVICE","requireDoomHelpService","DOOM_CONFIG_SERVICE","registerHookHandlers","runSessionEndHooks","connectDoomCordisHost"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type DoomReadinessCoordinator,\n readDoomReadinessCoordinator,\n} from '@agimon-ai/doompi-extension-contracts/readiness';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { DOOM_HELP_SERVICE, requireDoomHelpService } from '@agimon-ai/doompi-extension-contracts/help';\nimport { requireDoomConfigContext } from '@agimon-ai/doompi-config/piContext';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { HookDocumentReader, HookRunner } from '../../types/hooks.ts';\nimport type { HookTelemetry } from '../../types/telemetry.ts';\nimport { createHookDocumentReader } from '../hookDocuments.ts';\nimport { createBashHookRunner } from '../hookRunner.ts';\nimport { createHookTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport {\n type HookReadinessGate,\n type HookRuntime,\n type HookSession,\n registerHookHandlers,\n runSessionEndHooks,\n} from './hookHandlers.ts';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-hook';\n\nexport interface HookExtensionOptions {\n telemetry?: HookTelemetry;\n runner?: HookRunner;\n documents?: HookDocumentReader;\n}\n\nfunction hookSession(cordis: Context, options: HookExtensionOptions): HookSession {\n // The log sink is only built if something actually reports to it, so a fully\n // stubbed session never touches the telemetry backend.\n let telemetry = options.telemetry;\n const requireTelemetry = (): HookTelemetry => (telemetry ??= createHookTelemetry());\n return {\n config: () => requireDoomConfigContext(cordis),\n runner: options.runner ?? createBashHookRunner({ telemetry: requireTelemetry() }),\n documents: options.documents ?? createHookDocumentReader({ telemetry: requireTelemetry() }),\n };\n}\n\ninterface HookPluginConfig {\n readonly pi: ExtensionAPI;\n readonly options: HookExtensionOptions;\n}\n\ninterface HookRuntimeBinding extends HookRuntime {\n dispose(): void;\n}\n\nfunction createHookRuntime(cordis: Context, options: HookExtensionOptions): HookRuntimeBinding {\n const session = hookSession(cordis, options);\n let active = true;\n let generation = 0;\n let readiness:\n | {\n readonly sessionManager: object;\n readonly coordinator: DoomReadinessCoordinator;\n readonly operation: Promise<void>;\n }\n | undefined;\n const readinessGate: HookReadinessGate = {\n start(context, operation) {\n const ownGeneration = ++generation;\n const isCurrent = (): boolean => active && ownGeneration === generation;\n const coordinator = readDoomReadinessCoordinator(cordis);\n if (!coordinator) return operation(new AbortController().signal, isCurrent);\n\n const previous = readiness;\n const readinessOperation = (async (): Promise<void> => {\n if (previous?.coordinator === coordinator) await previous.operation.catch(() => undefined);\n if (!isCurrent()) return;\n const handle = coordinator.start(\n PACKAGE_SOURCE,\n `${context.sessionManager.getSessionId()}:${ownGeneration}`,\n async (signal) => {\n await operation(signal, isCurrent);\n return { value: undefined };\n },\n );\n await handle.wait();\n })();\n // Config's coordinator owns the single user-facing failure notification.\n void readinessOperation.catch(() => undefined);\n readiness = {\n sessionManager: context.sessionManager,\n coordinator,\n operation: readinessOperation,\n };\n return undefined;\n },\n async wait(context: ExtensionContext): Promise<void> {\n const current = readiness;\n if (!current) return;\n if (current.sessionManager !== context.sessionManager) {\n throw new Error('Hook readiness belongs to a stale Pi session.');\n }\n await current.operation;\n if (!active || current !== readiness) {\n throw new Error('Hook readiness belongs to a stale extension generation.');\n }\n },\n };\n return {\n session,\n readiness: readinessGate,\n isCurrent: () => active,\n dispose() {\n active = false;\n generation += 1;\n readiness = undefined;\n },\n };\n}\n\nfunction hookPlugin(cordis: Context, { pi, options }: HookPluginConfig): void {\n cordis.inject([DOOM_HELP_SERVICE], (helpContext) => {\n const contribution = requireDoomHelpService(helpContext).register({\n source: PACKAGE_SOURCE,\n moduleUrl: import.meta.url,\n skills: [\n {\n name: 'doompi-author-hook',\n description:\n 'Author DoomPi repository or plugin hooks. Use when creating or changing .doom/hooks.yaml, selecting hook groups from modes.yaml, writing hook commands, or adapting Claude Code hook payloads and decisions to DoomPi.',\n },\n ],\n });\n return () => contribution.dispose();\n });\n\n let runtime: HookRuntimeBinding | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE], (configContext) => {\n const binding = createHookRuntime(configContext, options);\n runtime = binding;\n configContext.effect(\n () => () => {\n binding.dispose();\n if (runtime === binding) runtime = undefined;\n },\n `${PACKAGE_SOURCE}/config-runtime`,\n );\n });\n\n cordis.effect(function* () {\n for (const disposeRegistration of registerHookHandlers(pi, () => runtime)) yield disposeRegistration;\n yield () => {\n runtime = undefined;\n };\n }, PACKAGE_SOURCE);\n\n let shutdown: Promise<void> | undefined;\n pi.on('session_shutdown', (_event, ctx) => {\n const current = runtime;\n if (!current?.isCurrent()) return undefined;\n shutdown ??= runSessionEndHooks(current.session, ctx);\n return shutdown;\n });\n}\n\n/** The package's single standard Pi factory. */\nexport async function hookExtension(pi: ExtensionAPI, options: HookExtensionOptions = {}): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(hookPlugin, { pi, options });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default hookExtension;\n"],"mappings":"wbAuBA,MAAM,EAAiB,yBAQvB,SAAS,EAAY,EAAiB,EAA4C,CAGhF,IAAI,EAAY,EAAQ,UAClB,MAAyC,IAAcA,EAAAA,oBAAoB,EACjF,MAAO,CACL,YAAA,EAAcC,EAAAA,yBAAAA,CAAyB,CAAM,EAC7C,OAAQ,EAAQ,QAAUC,EAAAA,qBAAqB,CAAE,UAAW,EAAiB,CAAE,CAAC,EAChF,UAAW,EAAQ,WAAaC,EAAAA,yBAAyB,CAAE,UAAW,EAAiB,CAAE,CAAC,CAC5F,CACF,CAWA,SAAS,EAAkB,EAAiB,EAAmD,CAC7F,IAAM,EAAU,EAAY,EAAQ,CAAO,EACvC,EAAS,GACT,EAAa,EACb,EAiDJ,MAAO,CACL,UACA,UAAW,CA3CX,MAAM,EAAS,EAAW,CACxB,IAAM,EAAgB,EAAE,E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AAU,EAAkB,EAAe,CAAO,EACxD,EAAU,EACV,EAAc,eACA,CACV,EAAQ,QAAQ,EACZ,IAAY,IAAS,EAAU,IAAA,GACrC,EACA,GAAG,EAAe,gBACpB,CACF,CAAC,EAED,EAAO,OAAO,WAAa,CACzB,IAAK,IAAM,KAAuBC,EAAAA,qBAAqB,MAAU,CAAO,EAAG,MAAM,EACjF,SAAY,CACV,EAAU,IAAA,EACZ,CACF,EAAG,CAAc,EAEjB,IAAI,EACJ,EAAG,GAAG,oBAAqB,EAAQ,IAAQ,CACzC,IAAM,EAAU,EACX,MAAS,UAAU,EAExB,MADA,KAAaC,EAAAA,mBAAmB,EAAQ,QAAS,CAAG,EAC7C,CACT,CAAC,CACH,CAGA,eAAsB,EAAc,EAAkB,EAAgC,CAAC,EAAkB,CACvG,IAAM,EAAa,MAAA,EAAMC,EAAAA,sBAAAA,CAAsB,EAAI,CAAc,EAC3D,EAAQ,EAAW,KAAK,OAAO,EAAY,CAAE,KAAI,SAAQ,CAAC,EAChE,GAAI,CACF,MAAM,CACR,OAAS,EAAO,CACd,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACA,MAAM,CACR,CACA,IAAI,EACJ,EAAG,GACD,uBAEG,KAAc,SAAY,CACzB,GAAI,CACF,MAAM,EAAM,QAAQ,CACtB,QAAU,CACR,MAAM,EAAW,QAAQ,CAC3B,CACF,EAAA,CAAG,CACP,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;UAyBiB;EACf,YAAY;EACZ,SAAS;EACT,YAAY;;;iBAuIQ,cAAc,IAAI,cAAc,UAAS,uBAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;UAyBiB;EACf,YAAY;EACZ,SAAS;EACT,YAAY;;;iBAuIQ,cAAc,IAAI,cAAc,UAAS,uBAA4B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createHookDocumentReader as e}from"../hookDocuments.mjs";import{createBashHookRunner as t}from"../hookRunner.mjs";import{createHookTelemetry as n}from"../telemetry/logSinkTelemetry.mjs";import{registerHookHandlers as r,runSessionEndHooks as i}from"./hookHandlers.mjs";import{readDoomReadinessCoordinator as a}from"@agimon-ai/doompi-extension-contracts/readiness";import{connectDoomCordisHost as o}from"@agimon-ai/doompi-extension-contracts/cordis-host";import{DOOM_CONFIG_SERVICE as s}from"@agimon-ai/doompi-extension-contracts/config";import{
|
|
1
|
+
import{createHookDocumentReader as e}from"../hookDocuments.mjs";import{createBashHookRunner as t}from"../hookRunner.mjs";import{createHookTelemetry as n}from"../telemetry/logSinkTelemetry.mjs";import{registerHookHandlers as r,runSessionEndHooks as i}from"./hookHandlers.mjs";import{readDoomReadinessCoordinator as a}from"@agimon-ai/doompi-extension-contracts/readiness";import{connectDoomCordisHost as o}from"@agimon-ai/doompi-extension-contracts/cordis-host";import{DOOM_CONFIG_SERVICE as s}from"@agimon-ai/doompi-extension-contracts/config";import{DOOM_HELP_SERVICE as c,requireDoomHelpService as l}from"@agimon-ai/doompi-extension-contracts/help";import{requireDoomConfigContext as u}from"@agimon-ai/doompi-config/piContext";const d=`@agimon-ai/doompi-hook`;function f(r,i){let a=i.telemetry,o=()=>a??=n();return{config:()=>u(r),runner:i.runner??t({telemetry:o()}),documents:i.documents??e({telemetry:o()})}}function p(e,t){let n=f(e,t),r=!0,i=0,o;return{session:n,readiness:{start(t,n){let s=++i,c=()=>r&&s===i,l=a(e);if(!l)return n(new AbortController().signal,c);let u=o,f=(async()=>{u?.coordinator===l&&await u.operation.catch(()=>void 0),c()&&await l.start(d,`${t.sessionManager.getSessionId()}:${s}`,async e=>(await n(e,c),{value:void 0})).wait()})();f.catch(()=>void 0),o={sessionManager:t.sessionManager,coordinator:l,operation:f}},async wait(e){let t=o;if(t){if(t.sessionManager!==e.sessionManager)throw Error(`Hook readiness belongs to a stale Pi session.`);if(await t.operation,!r||t!==o)throw Error(`Hook readiness belongs to a stale extension generation.`)}}},isCurrent:()=>r,dispose(){r=!1,i+=1,o=void 0}}}function m(e,{pi:t,options:n}){e.inject([c],e=>{let t=l(e).register({source:d,moduleUrl:import.meta.url,skills:[{name:`doompi-author-hook`,description:`Author DoomPi repository or plugin hooks. Use when creating or changing .doom/hooks.yaml, selecting hook groups from modes.yaml, writing hook commands, or adapting Claude Code hook payloads and decisions to DoomPi.`}]});return()=>t.dispose()});let a;e.inject([s],e=>{let t=p(e,n);a=t,e.effect(()=>()=>{t.dispose(),a===t&&(a=void 0)},`${d}/config-runtime`)}),e.effect(function*(){for(let e of r(t,()=>a))yield e;yield()=>{a=void 0}},d);let o;t.on(`session_shutdown`,(e,t)=>{let n=a;if(n?.isCurrent())return o??=i(n.session,t),o})}async function h(e,t={}){let n=await o(e,d),r=n.root.plugin(m,{pi:e,options:t});try{await r}catch(e){try{await r.dispose()}finally{await n.dispose()}throw e}let i;e.on(`session_shutdown`,()=>i??=(async()=>{try{await r.dispose()}finally{await n.dispose()}})())}export{h as default,h as hookExtension};
|
|
2
2
|
//# sourceMappingURL=extension.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type DoomReadinessCoordinator,\n readDoomReadinessCoordinator,\n} from '@agimon-ai/doompi-extension-contracts/readiness';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { requireDoomConfigContext } from '@agimon-ai/doompi-config/piContext';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { HookDocumentReader, HookRunner } from '../../types/hooks.ts';\nimport type { HookTelemetry } from '../../types/telemetry.ts';\nimport { createHookDocumentReader } from '../hookDocuments.ts';\nimport { createBashHookRunner } from '../hookRunner.ts';\nimport { createHookTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport {\n type HookReadinessGate,\n type HookRuntime,\n type HookSession,\n registerHookHandlers,\n runSessionEndHooks,\n} from './hookHandlers.ts';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-hook';\n\nexport interface HookExtensionOptions {\n telemetry?: HookTelemetry;\n runner?: HookRunner;\n documents?: HookDocumentReader;\n}\n\nfunction hookSession(cordis: Context, options: HookExtensionOptions): HookSession {\n // The log sink is only built if something actually reports to it, so a fully\n // stubbed session never touches the telemetry backend.\n let telemetry = options.telemetry;\n const requireTelemetry = (): HookTelemetry => (telemetry ??= createHookTelemetry());\n return {\n config: () => requireDoomConfigContext(cordis),\n runner: options.runner ?? createBashHookRunner({ telemetry: requireTelemetry() }),\n documents: options.documents ?? createHookDocumentReader({ telemetry: requireTelemetry() }),\n };\n}\n\ninterface HookPluginConfig {\n readonly pi: ExtensionAPI;\n readonly options: HookExtensionOptions;\n}\n\ninterface HookRuntimeBinding extends HookRuntime {\n dispose(): void;\n}\n\nfunction createHookRuntime(cordis: Context, options: HookExtensionOptions): HookRuntimeBinding {\n const session = hookSession(cordis, options);\n let active = true;\n let generation = 0;\n let readiness:\n | {\n readonly sessionManager: object;\n readonly coordinator: DoomReadinessCoordinator;\n readonly operation: Promise<void>;\n }\n | undefined;\n const readinessGate: HookReadinessGate = {\n start(context, operation) {\n const ownGeneration = ++generation;\n const isCurrent = (): boolean => active && ownGeneration === generation;\n const coordinator = readDoomReadinessCoordinator(cordis);\n if (!coordinator) return operation(new AbortController().signal, isCurrent);\n\n const previous = readiness;\n const readinessOperation = (async (): Promise<void> => {\n if (previous?.coordinator === coordinator) await previous.operation.catch(() => undefined);\n if (!isCurrent()) return;\n const handle = coordinator.start(\n PACKAGE_SOURCE,\n `${context.sessionManager.getSessionId()}:${ownGeneration}`,\n async (signal) => {\n await operation(signal, isCurrent);\n return { value: undefined };\n },\n );\n await handle.wait();\n })();\n // Config's coordinator owns the single user-facing failure notification.\n void readinessOperation.catch(() => undefined);\n readiness = {\n sessionManager: context.sessionManager,\n coordinator,\n operation: readinessOperation,\n };\n return undefined;\n },\n async wait(context: ExtensionContext): Promise<void> {\n const current = readiness;\n if (!current) return;\n if (current.sessionManager !== context.sessionManager) {\n throw new Error('Hook readiness belongs to a stale Pi session.');\n }\n await current.operation;\n if (!active || current !== readiness) {\n throw new Error('Hook readiness belongs to a stale extension generation.');\n }\n },\n };\n return {\n session,\n readiness: readinessGate,\n isCurrent: () => active,\n dispose() {\n active = false;\n generation += 1;\n readiness = undefined;\n },\n };\n}\n\nfunction hookPlugin(cordis: Context, { pi, options }: HookPluginConfig): void {\n let runtime: HookRuntimeBinding | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE], (configContext) => {\n const binding = createHookRuntime(configContext, options);\n runtime = binding;\n configContext.effect(\n () => () => {\n binding.dispose();\n if (runtime === binding) runtime = undefined;\n },\n `${PACKAGE_SOURCE}/config-runtime`,\n );\n });\n\n cordis.effect(function* () {\n for (const disposeRegistration of registerHookHandlers(pi, () => runtime)) yield disposeRegistration;\n yield () => {\n runtime = undefined;\n };\n }, PACKAGE_SOURCE);\n\n let shutdown: Promise<void> | undefined;\n pi.on('session_shutdown', (_event, ctx) => {\n const current = runtime;\n if (!current?.isCurrent()) return undefined;\n shutdown ??= runSessionEndHooks(current.session, ctx);\n return shutdown;\n });\n}\n\n/** The package's single standard Pi factory. */\nexport async function hookExtension(pi: ExtensionAPI, options: HookExtensionOptions = {}): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(hookPlugin, { pi, options });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default hookExtension;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type DoomReadinessCoordinator,\n readDoomReadinessCoordinator,\n} from '@agimon-ai/doompi-extension-contracts/readiness';\nimport { connectDoomCordisHost } from '@agimon-ai/doompi-extension-contracts/cordis-host';\nimport { DOOM_CONFIG_SERVICE } from '@agimon-ai/doompi-extension-contracts/config';\nimport { DOOM_HELP_SERVICE, requireDoomHelpService } from '@agimon-ai/doompi-extension-contracts/help';\nimport { requireDoomConfigContext } from '@agimon-ai/doompi-config/piContext';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { HookDocumentReader, HookRunner } from '../../types/hooks.ts';\nimport type { HookTelemetry } from '../../types/telemetry.ts';\nimport { createHookDocumentReader } from '../hookDocuments.ts';\nimport { createBashHookRunner } from '../hookRunner.ts';\nimport { createHookTelemetry } from '../telemetry/logSinkTelemetry.ts';\nimport {\n type HookReadinessGate,\n type HookRuntime,\n type HookSession,\n registerHookHandlers,\n runSessionEndHooks,\n} from './hookHandlers.ts';\n\nconst PACKAGE_SOURCE = '@agimon-ai/doompi-hook';\n\nexport interface HookExtensionOptions {\n telemetry?: HookTelemetry;\n runner?: HookRunner;\n documents?: HookDocumentReader;\n}\n\nfunction hookSession(cordis: Context, options: HookExtensionOptions): HookSession {\n // The log sink is only built if something actually reports to it, so a fully\n // stubbed session never touches the telemetry backend.\n let telemetry = options.telemetry;\n const requireTelemetry = (): HookTelemetry => (telemetry ??= createHookTelemetry());\n return {\n config: () => requireDoomConfigContext(cordis),\n runner: options.runner ?? createBashHookRunner({ telemetry: requireTelemetry() }),\n documents: options.documents ?? createHookDocumentReader({ telemetry: requireTelemetry() }),\n };\n}\n\ninterface HookPluginConfig {\n readonly pi: ExtensionAPI;\n readonly options: HookExtensionOptions;\n}\n\ninterface HookRuntimeBinding extends HookRuntime {\n dispose(): void;\n}\n\nfunction createHookRuntime(cordis: Context, options: HookExtensionOptions): HookRuntimeBinding {\n const session = hookSession(cordis, options);\n let active = true;\n let generation = 0;\n let readiness:\n | {\n readonly sessionManager: object;\n readonly coordinator: DoomReadinessCoordinator;\n readonly operation: Promise<void>;\n }\n | undefined;\n const readinessGate: HookReadinessGate = {\n start(context, operation) {\n const ownGeneration = ++generation;\n const isCurrent = (): boolean => active && ownGeneration === generation;\n const coordinator = readDoomReadinessCoordinator(cordis);\n if (!coordinator) return operation(new AbortController().signal, isCurrent);\n\n const previous = readiness;\n const readinessOperation = (async (): Promise<void> => {\n if (previous?.coordinator === coordinator) await previous.operation.catch(() => undefined);\n if (!isCurrent()) return;\n const handle = coordinator.start(\n PACKAGE_SOURCE,\n `${context.sessionManager.getSessionId()}:${ownGeneration}`,\n async (signal) => {\n await operation(signal, isCurrent);\n return { value: undefined };\n },\n );\n await handle.wait();\n })();\n // Config's coordinator owns the single user-facing failure notification.\n void readinessOperation.catch(() => undefined);\n readiness = {\n sessionManager: context.sessionManager,\n coordinator,\n operation: readinessOperation,\n };\n return undefined;\n },\n async wait(context: ExtensionContext): Promise<void> {\n const current = readiness;\n if (!current) return;\n if (current.sessionManager !== context.sessionManager) {\n throw new Error('Hook readiness belongs to a stale Pi session.');\n }\n await current.operation;\n if (!active || current !== readiness) {\n throw new Error('Hook readiness belongs to a stale extension generation.');\n }\n },\n };\n return {\n session,\n readiness: readinessGate,\n isCurrent: () => active,\n dispose() {\n active = false;\n generation += 1;\n readiness = undefined;\n },\n };\n}\n\nfunction hookPlugin(cordis: Context, { pi, options }: HookPluginConfig): void {\n cordis.inject([DOOM_HELP_SERVICE], (helpContext) => {\n const contribution = requireDoomHelpService(helpContext).register({\n source: PACKAGE_SOURCE,\n moduleUrl: import.meta.url,\n skills: [\n {\n name: 'doompi-author-hook',\n description:\n 'Author DoomPi repository or plugin hooks. Use when creating or changing .doom/hooks.yaml, selecting hook groups from modes.yaml, writing hook commands, or adapting Claude Code hook payloads and decisions to DoomPi.',\n },\n ],\n });\n return () => contribution.dispose();\n });\n\n let runtime: HookRuntimeBinding | undefined;\n cordis.inject([DOOM_CONFIG_SERVICE], (configContext) => {\n const binding = createHookRuntime(configContext, options);\n runtime = binding;\n configContext.effect(\n () => () => {\n binding.dispose();\n if (runtime === binding) runtime = undefined;\n },\n `${PACKAGE_SOURCE}/config-runtime`,\n );\n });\n\n cordis.effect(function* () {\n for (const disposeRegistration of registerHookHandlers(pi, () => runtime)) yield disposeRegistration;\n yield () => {\n runtime = undefined;\n };\n }, PACKAGE_SOURCE);\n\n let shutdown: Promise<void> | undefined;\n pi.on('session_shutdown', (_event, ctx) => {\n const current = runtime;\n if (!current?.isCurrent()) return undefined;\n shutdown ??= runSessionEndHooks(current.session, ctx);\n return shutdown;\n });\n}\n\n/** The package's single standard Pi factory. */\nexport async function hookExtension(pi: ExtensionAPI, options: HookExtensionOptions = {}): Promise<void> {\n const connection = await connectDoomCordisHost(pi, PACKAGE_SOURCE);\n const fiber = connection.root.plugin(hookPlugin, { pi, options });\n try {\n await fiber;\n } catch (error) {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n throw error;\n }\n let disposal: Promise<void> | undefined;\n pi.on(\n 'session_shutdown',\n () =>\n (disposal ??= (async () => {\n try {\n await fiber.dispose();\n } finally {\n await connection.dispose();\n }\n })()),\n );\n}\n\nexport default hookExtension;\n"],"mappings":"wtBAuBA,MAAM,EAAiB,yBAQvB,SAAS,EAAY,EAAiB,EAA4C,CAGhF,IAAI,EAAY,EAAQ,UAClB,MAAyC,IAAc,EAAoB,EAC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ift would be silent. */
|
|
10
10
|
declare const HOOK_EVENT: {
|
|
11
|
-
readonly sessionStart:
|
|
12
|
-
readonly preToolUse:
|
|
13
|
-
readonly postToolUse:
|
|
14
|
-
readonly stop:
|
|
15
|
-
readonly sessionEnd:
|
|
11
|
+
readonly sessionStart: 'SessionStart';
|
|
12
|
+
readonly preToolUse: 'PreToolUse';
|
|
13
|
+
readonly postToolUse: 'PostToolUse';
|
|
14
|
+
readonly stop: 'Stop';
|
|
15
|
+
readonly sessionEnd: 'SessionEnd';
|
|
16
16
|
};
|
|
17
17
|
type HookEventName = (typeof HOOK_EVENT)[keyof typeof HOOK_EVENT];
|
|
18
18
|
interface HookCommand {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.cts","names":[],"sources":["../../src/types/hooks.ts"],"mappings":";;;;;;;;;cASa
|
|
1
|
+
{"version":3,"file":"hooks.d.cts","names":[],"sources":["../../src/types/hooks.ts"],"mappings":";;;;;;;;;cASa;WACX;WACA;WACA;WACA;WACA;;KAGU,wBAAwB,yBAAyB;UAE5C;EACf;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;;;UAIe,sBAAsB;EACrC;EACA;;EAEA;EACA;EACA;;EAEA;;UAGe;EACf;EACA,QAAQ;IAAQ;IAAe,KAAK;;;UAGrB;EACf,SAAS,eAAe;;;UAIT;EACf;EACA;;;UAIe;EACf;EACA,UAAU;;UAGK;EACf;EACA,QAAQ;;UAGO;EACf,QAAQ,eAAe;;;UAIR;EACf;EACA,QAAQ;;;UAIO;EACf,MAAM;EACN;;;UAIe;EACf;EACA;EACA;IACE;IACA;IACA;;;KAIQ;UAQK;EACf;EACA;EACA,QAAQ;;UAGO;EACf,WAAW;EACX,UAAU;;;;;;;;UASK;WACN;WACA;WACA;WACA;WACA;;;KAIC,cAAc;UAET;EACf;;EAEA;;;UAIe;EACf,IAAI,MAAM,aAAa,SAAS,aAAa,SAAS,iBAAiB,QAAQ;;;UAIhE;EACf,SAAS;EACT,UAAU;;;UAIK;EACf,WAAW;EACX,UAAU;;;UAIK;WACN;WACA;;;UAIM;EACf,SAAS,mBAAmB,QAAQ;EACpC,QAAQ,kBAAkB,wBAAwB,QAAQ"}
|
package/dist/types/hooks.d.mts
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/** Registry event names. Each is used twice per dispatch, so drift would be silent. */
|
|
10
10
|
declare const HOOK_EVENT: {
|
|
11
|
-
readonly sessionStart:
|
|
12
|
-
readonly preToolUse:
|
|
13
|
-
readonly postToolUse:
|
|
14
|
-
readonly stop:
|
|
15
|
-
readonly sessionEnd:
|
|
11
|
+
readonly sessionStart: 'SessionStart';
|
|
12
|
+
readonly preToolUse: 'PreToolUse';
|
|
13
|
+
readonly postToolUse: 'PostToolUse';
|
|
14
|
+
readonly stop: 'Stop';
|
|
15
|
+
readonly sessionEnd: 'SessionEnd';
|
|
16
16
|
};
|
|
17
17
|
type HookEventName = (typeof HOOK_EVENT)[keyof typeof HOOK_EVENT];
|
|
18
18
|
interface HookCommand {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.mts","names":[],"sources":["../../src/types/hooks.ts"],"mappings":";;;;;;;;;cASa
|
|
1
|
+
{"version":3,"file":"hooks.d.mts","names":[],"sources":["../../src/types/hooks.ts"],"mappings":";;;;;;;;;cASa;WACX;WACA;WACA;WACA;WACA;;KAGU,wBAAwB,yBAAyB;UAE5C;EACf;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;;;UAIe,sBAAsB;EACrC;EACA;;EAEA;EACA;EACA;;EAEA;;UAGe;EACf;EACA,QAAQ;IAAQ;IAAe,KAAK;;;UAGrB;EACf,SAAS,eAAe;;;UAIT;EACf;EACA;;;UAIe;EACf;EACA,UAAU;;UAGK;EACf;EACA,QAAQ;;UAGO;EACf,QAAQ,eAAe;;;UAIR;EACf;EACA,QAAQ;;;UAIO;EACf,MAAM;EACN;;;UAIe;EACf;EACA;EACA;IACE;IACA;IACA;;;KAIQ;UAQK;EACf;EACA;EACA,QAAQ;;UAGO;EACf,WAAW;EACX,UAAU;;;;;;;;UASK;WACN;WACA;WACA;WACA;WACA;;;KAIC,cAAc;UAET;EACf;;EAEA;;;UAIe;EACf,IAAI,MAAM,aAAa,SAAS,aAAa,SAAS,iBAAiB,QAAQ;;;UAIhE;EACf,SAAS;EACT,UAAU;;;UAIK;EACf,WAAW;EACX,UAAU;;;UAIK;WACN;WACA;;;UAIM;EACf,SAAS,mBAAmB,QAAQ;EACpC,QAAQ,kBAAkB,wBAAwB,QAAQ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/types/telemetry.d.ts
|
|
2
2
|
/** Telemetry events this package reports, and the port that records them. */
|
|
3
3
|
declare const HOOK_TELEMETRY_EVENT: {
|
|
4
|
-
readonly hookFailed:
|
|
5
|
-
readonly hookRegistryReadFailed:
|
|
4
|
+
readonly hookFailed: 'doom_pi_hook.failed';
|
|
5
|
+
readonly hookRegistryReadFailed: 'doom_pi_hook.registry_read_failed';
|
|
6
6
|
};
|
|
7
7
|
type HookTelemetryEventName = (typeof HOOK_TELEMETRY_EVENT)[keyof typeof HOOK_TELEMETRY_EVENT];
|
|
8
8
|
type HookTelemetryAttributes = Record<string, string | number | boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.cts","names":[],"sources":["../../src/types/telemetry.ts"],"mappings":";;cACa;
|
|
1
|
+
{"version":3,"file":"telemetry.d.cts","names":[],"sources":["../../src/types/telemetry.ts"],"mappings":";;cACa;WACX;WACA;;KAGU,iCAAiC,mCAAmC;KACpE,0BAA0B;;;;;;UAOrB;EACf,YAAY,OAAO,wBAAwB,gBAAgB,aAAa,0BAA0B;EAClG,cAAc,OAAO,wBAAwB,gBAAgB,aAAa,0BAA0B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/types/telemetry.d.ts
|
|
2
2
|
/** Telemetry events this package reports, and the port that records them. */
|
|
3
3
|
declare const HOOK_TELEMETRY_EVENT: {
|
|
4
|
-
readonly hookFailed:
|
|
5
|
-
readonly hookRegistryReadFailed:
|
|
4
|
+
readonly hookFailed: 'doom_pi_hook.failed';
|
|
5
|
+
readonly hookRegistryReadFailed: 'doom_pi_hook.registry_read_failed';
|
|
6
6
|
};
|
|
7
7
|
type HookTelemetryEventName = (typeof HOOK_TELEMETRY_EVENT)[keyof typeof HOOK_TELEMETRY_EVENT];
|
|
8
8
|
type HookTelemetryAttributes = Record<string, string | number | boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/types/telemetry.ts"],"mappings":";;cACa;
|
|
1
|
+
{"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/types/telemetry.ts"],"mappings":";;cACa;WACX;WACA;;KAGU,iCAAiC,mCAAmC;KACpE,0BAA0B;;;;;;UAOrB;EACf,YAAY,OAAO,wBAAwB,gBAAgB,aAAa,0BAA0B;EAClG,cAAc,OAAO,wBAAwB,gBAAgB,aAAa,0BAA0B"}
|
package/llms.txt
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Claude-Code-compatible repository and plugin hooks for Doom Pi sessions.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## How to author
|
|
6
6
|
|
|
7
|
-
- [
|
|
7
|
+
- [Author DoomPi hooks](./src/prompts/doompi-author-hook/SKILL.md): Create `.doom/hooks.yaml` groups and Claude-compatible hook commands.
|
|
8
|
+
|
|
9
|
+
## Package reference
|
|
10
|
+
|
|
11
|
+
- [Package README](./README.md): The hook registry, group selection, event mapping, decisions, and failure handling.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-hook",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.31",
|
|
4
4
|
"description": "Claude-Code-compatible repository and plugin hook runner for DoomPi sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -16,12 +16,21 @@
|
|
|
16
16
|
"repository-hooks"
|
|
17
17
|
],
|
|
18
18
|
"homepage": "https://agimon.ai",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/AgiFlow/doompi/issues"
|
|
21
|
+
},
|
|
19
22
|
"license": "MIT",
|
|
20
23
|
"author": "Vuong Ngo",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/AgiFlow/doompi.git",
|
|
27
|
+
"directory": "packages/default/doompi-hook"
|
|
28
|
+
},
|
|
21
29
|
"files": [
|
|
22
30
|
"dist",
|
|
23
31
|
"llms.txt",
|
|
24
32
|
"README.md",
|
|
33
|
+
"src/prompts",
|
|
25
34
|
"LICENSE",
|
|
26
35
|
"package.json"
|
|
27
36
|
],
|
|
@@ -48,21 +57,21 @@
|
|
|
48
57
|
"dependencies": {
|
|
49
58
|
"@deepseek-ai/cordis": "4.0.1",
|
|
50
59
|
"yaml": "2.9.0",
|
|
51
|
-
"@agimon-ai/doompi-config": "0.0.1-alpha.
|
|
52
|
-
"@agimon-ai/doompi-
|
|
53
|
-
"@agimon-ai/doompi-
|
|
60
|
+
"@agimon-ai/doompi-config": "0.0.1-alpha.53",
|
|
61
|
+
"@agimon-ai/doompi-telemetry": "0.0.1-alpha.53",
|
|
62
|
+
"@agimon-ai/doompi-extension-contracts": "0.0.1-alpha.53"
|
|
54
63
|
},
|
|
55
64
|
"devDependencies": {
|
|
56
|
-
"@earendil-works/pi-coding-agent": "0.84.
|
|
57
|
-
"@types/node": "26.
|
|
58
|
-
"@vitest/coverage-v8": "4.1.
|
|
65
|
+
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
66
|
+
"@types/node": "26.4.0",
|
|
67
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
59
68
|
"tsdown": "0.22.14",
|
|
60
|
-
"typescript": "
|
|
61
|
-
"vitest": "4.1.
|
|
62
|
-
"@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.
|
|
69
|
+
"typescript": "7.0.2",
|
|
70
|
+
"vitest": "4.1.11",
|
|
71
|
+
"@agimon-ai/vibe-lint-plugin-doom-extension": "0.0.1-alpha.51"
|
|
63
72
|
},
|
|
64
73
|
"peerDependencies": {
|
|
65
|
-
"@earendil-works/pi-coding-agent": "0.84.
|
|
74
|
+
"@earendil-works/pi-coding-agent": "0.84.4"
|
|
66
75
|
},
|
|
67
76
|
"peerDependenciesMeta": {
|
|
68
77
|
"@earendil-works/pi-coding-agent": {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: doompi-author-hook
|
|
3
|
+
description: Author DoomPi repository or plugin hooks. Use when creating or changing .doom/hooks.yaml, selecting hook groups from modes.yaml, writing hook commands, or adapting Claude Code hook payloads and decisions to DoomPi.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Author DoomPi hooks
|
|
7
|
+
|
|
8
|
+
Write the smallest hook that enforces the requested policy, and treat every hook command as executable repository code.
|
|
9
|
+
|
|
10
|
+
## Repository registry
|
|
11
|
+
|
|
12
|
+
Define repository and personal hooks in `.doom/hooks.yaml`:
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
groups:
|
|
16
|
+
safety:
|
|
17
|
+
core: true
|
|
18
|
+
hooks:
|
|
19
|
+
- event: PreToolUse
|
|
20
|
+
pi:
|
|
21
|
+
matcher: Bash
|
|
22
|
+
command: .doom/hooks/guard-destructive-commands.sh
|
|
23
|
+
timeout: 10
|
|
24
|
+
skipInSubagent: true
|
|
25
|
+
order: 0
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Personal configuration comes from `~/.pi/.doom/hooks.yaml`; repository configuration comes from `<repo>/.doom/hooks.yaml`.
|
|
29
|
+
- A repository group replaces a personal group with the same ID as one complete value.
|
|
30
|
+
- `core: true` runs regardless of the selected groups. Otherwise, add the group ID to a layer's `hookGroups` in `modes.yaml`.
|
|
31
|
+
- `matcher` is a regular expression over Claude tool names such as `Bash` and `Write`, even though Pi uses lowercase tool names internally.
|
|
32
|
+
- Use `skipInSubagent: true` when running the hook in a child could duplicate or close parent-owned work. Lower `order` values run first, with declaration order as the tiebreaker.
|
|
33
|
+
|
|
34
|
+
Supported repository events are `SessionStart`, `PreToolUse`, `PostToolUse`, and `Stop`. `SessionEnd` is resolved only from plugin `hooks.json` documents.
|
|
35
|
+
|
|
36
|
+
## Command contract
|
|
37
|
+
|
|
38
|
+
DoomPi runs each command through `/bin/bash -c` from the repository root and writes the Claude-compatible event payload to stdin. The environment includes `CLAUDE_PROJECT_DIR`, `CODEX_REPO_ROOT`, `ORIGINAL_REPO_PATH`, and `CLAUDE_PLUGIN_ROOT`. For `.doom/hooks.yaml`, `CLAUDE_PLUGIN_ROOT` is the root that declared the personal or repository document.
|
|
39
|
+
|
|
40
|
+
The final stdout line beginning with `{` is parsed as the hook decision. Use Claude Code decision fields only when the event supports them. `PreToolUse` may deny a tool or add context, `PostToolUse` may append context or mark a result as denied, and `SessionStart` may add context. `Stop` and `SessionEnd` run for side effects.
|
|
41
|
+
|
|
42
|
+
Hook failures are advisory: nonzero exits, invalid JSON, spawn failures, and timeouts are reported to the agent instead of crashing the turn. Set `timeout` in seconds only when the 10-second default is unsuitable. A timeout terminates the command's process group.
|
|
43
|
+
|
|
44
|
+
## Verification
|
|
45
|
+
|
|
46
|
+
Before enabling a new hook broadly:
|
|
47
|
+
|
|
48
|
+
1. Run the command directly with a representative JSON payload on stdin.
|
|
49
|
+
2. Start DoomPi with the intended major mode and confirm the group appears in `doompi --explain` output.
|
|
50
|
+
3. Exercise the exact lifecycle event in a disposable session, including a child session when `skipInSubagent` matters.
|
|
51
|
+
4. Confirm failure output reaches the agent and that repeated shutdown does not repeat external side effects unexpectedly.
|