{"_id":"@aaplugin/extension-hooks","_rev":"2-63fe56091c47a01b12ccd36d2d28d4f2","name":"@aaplugin/extension-hooks","dist-tags":{"latest":"1.0.0-beta.2"},"versions":{"1.0.0-beta.1":{"name":"@aaplugin/extension-hooks","version":"1.0.0-beta.1","author":{"url":"https://github.com/wh1teAlter","name":"wh1teAlter"},"license":"MIT","_id":"@aaplugin/extension-hooks@1.0.0-beta.1","maintainers":[{"name":"wh1t3alter","email":"2369332823@qq.com"}],"homepage":"https://github.com/wh1teAlter/aaplugin#readme","bugs":{"url":"https://github.com/wh1teAlter/aaplugin/issues"},"dist":{"shasum":"3b3b594a1a911877e89629d95e2728b0161b3c36","tarball":"https://registry.npmjs.org/@aaplugin/extension-hooks/-/extension-hooks-1.0.0-beta.1.tgz","fileCount":5,"integrity":"sha512-P036xUbXSCWuRu/gBhUNsAUXFtupeSfG42kqGajVp8wIkl6DttO0bdFCt2XRYb4if/bD7r1jh08WziIlO7wFgg==","signatures":[{"sig":"MEQCIBbfy61dDME8IRk5+BLrRkxc03xikMWdG5nS1ZzUZ9kAAiBnD7CKE86G1AZyABxfkuipjQRN+8JM8S/3GfN4wi3L6A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":89137},"type":"module","_from":"file:aaplugin-extension-hooks-1.0.0-beta.1.tgz","engines":{"node":"^20.19.0 || ^22.13.0 || >=23.5.0"},"exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"}},"scripts":{"test":"vitest run --passWithNoTests","build":"tsdown","pretest":"pnpm --filter @aaplugin/core run build && pnpm --filter @aaplugin/kit run build && pnpm --filter @aaplugin/platform-claude-code run build && pnpm --filter @aaplugin/platform-codex run build && pnpm run build","typecheck":"tsc -p tsconfig.json"},"_npmUser":{"name":"wh1t3alter","email":"2369332823@qq.com"},"_resolved":"/private/var/folders/07/ymy0fnqn20d7p_4hkrf8z97c0000gn/T/d6489d94625587ef47d14418a5433766/aaplugin-extension-hooks-1.0.0-beta.1.tgz","_integrity":"sha512-P036xUbXSCWuRu/gBhUNsAUXFtupeSfG42kqGajVp8wIkl6DttO0bdFCt2XRYb4if/bD7r1jh08WziIlO7wFgg==","repository":{"url":"git+https://github.com/wh1teAlter/aaplugin.git","type":"git","directory":"packages/extensions/hooks"},"_npmVersion":"10.9.4","description":"Portable hook authoring and Platform contributors for AAPlugin.","directories":{},"sideEffects":false,"_nodeVersion":"22.21.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsdown":"^0.22.14","vitest":"^4.1.10","typescript":"^6.0.3","@types/node":"^20.19.0","@aaplugin/kit":"^1.0.0-beta.1"},"peerDependencies":{"@aaplugin/kit":"^1.0.0-beta.1"},"_npmOperationalInternal":{"tmp":"tmp/extension-hooks_1.0.0-beta.1_1787753762817_0.06565263310394864","host":"s3://npm-registry-packages-npm-production"}},"1.0.0-beta.2":{"name":"@aaplugin/extension-hooks","version":"1.0.0-beta.2","description":"Portable hook authoring and Platform contributors for AAPlugin.","type":"module","license":"MIT","author":{"name":"wh1teAlter","url":"https://github.com/wh1teAlter"},"homepage":"https://github.com/wh1teAlter/aaplugin#readme","repository":{"type":"git","url":"git+https://github.com/wh1teAlter/aaplugin.git","directory":"packages/extensions/hooks"},"bugs":{"url":"https://github.com/wh1teAlter/aaplugin/issues"},"sideEffects":false,"engines":{"node":"^20.19.0 || ^22.13.0 || >=23.5.0"},"exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"}},"publishConfig":{"access":"public"},"peerDependencies":{"@aaplugin/kit":"^1.0.0-beta.2"},"devDependencies":{"@types/node":"^20.19.43","tsdown":"^0.22.14","typescript":"^6.0.3","vitest":"^4.1.11","@aaplugin/kit":"^1.0.0-beta.2"},"scripts":{"build":"tsdown","pretest":"pnpm --filter @aaplugin/core run build && pnpm --filter @aaplugin/kit run build && pnpm --filter @aaplugin/platform-claude-code run build && pnpm --filter @aaplugin/platform-codex run build && pnpm run build","test":"vitest run --passWithNoTests","typecheck":"tsc -p tsconfig.json"},"_id":"@aaplugin/extension-hooks@1.0.0-beta.2","_integrity":"sha512-FfIBteTCoRE70QAU6UHEDhlSv9WmffKoC6C1CVv6rqMU5Qx0XVCDU/6leggMsowCvyizlh5ktJQCplRf1O7CqA==","_resolved":"/private/var/folders/07/ymy0fnqn20d7p_4hkrf8z97c0000gn/T/01fdd853bb46a76572c3113f1e3e7725/aaplugin-extension-hooks-1.0.0-beta.2.tgz","_from":"file:aaplugin-extension-hooks-1.0.0-beta.2.tgz","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-FfIBteTCoRE70QAU6UHEDhlSv9WmffKoC6C1CVv6rqMU5Qx0XVCDU/6leggMsowCvyizlh5ktJQCplRf1O7CqA==","shasum":"75bf05f1f197d736c295a13917ae40343febd33b","tarball":"https://registry.npmjs.org/@aaplugin/extension-hooks/-/extension-hooks-1.0.0-beta.2.tgz","fileCount":5,"unpackedSize":88722,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGYpriGRgSJsaL2M/un1r17vEmVBcbU/triizuBuz2uuAiAyQhjdnrAcu/d8K0zg6Bqd+ih64oDytzBOb7RBds9KTA=="}]},"_npmUser":{"name":"wh1t3alter","email":"2369332823@qq.com"},"directories":{},"maintainers":[{"name":"wh1t3alter","email":"2369332823@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/extension-hooks_1.0.0-beta.2_1788859416764_0.6470997893036765"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-26T14:16:02.478Z","modified":"2026-09-08T09:23:37.061Z","1.0.0-beta.1":"2026-08-26T14:16:02.945Z","1.0.0-beta.2":"2026-09-08T09:23:36.896Z"},"bugs":{"url":"https://github.com/wh1teAlter/aaplugin/issues"},"author":{"name":"wh1teAlter","url":"https://github.com/wh1teAlter"},"license":"MIT","homepage":"https://github.com/wh1teAlter/aaplugin#readme","repository":{"type":"git","url":"git+https://github.com/wh1teAlter/aaplugin.git","directory":"packages/extensions/hooks"},"description":"Portable hook authoring and Platform contributors for AAPlugin.","maintainers":[{"name":"wh1t3alter","email":"2369332823@qq.com"}],"readme":"# @aaplugin/extension-hooks\n\nPortable Hook authoring plus six official Platform Contributors for `aaplugin`.\n\nRequires Node.js `^20.19.0 || ^22.13.0 || >=23.5.0`.\n\n`统一书写 Hook，通过 Core Compiler 只构建一次，再由官方 Contributor 交付为六个平台各自支持的静态或运行时能力。`\n\n```bash\npnpm add -D @aaplugin/kit \\\n  @aaplugin/platform-claude-code \\\n  @aaplugin/extension-hooks\n```\n\n```ts\n// aaplugin.config.ts\nimport { defineConfig } from '@aaplugin/kit';\nimport claudeCode from '@aaplugin/platform-claude-code';\nimport hooks from '@aaplugin/extension-hooks';\n\nexport default defineConfig({\n  name: 'my-plugin',\n  version: '1.0.0',\n  description: 'Reusable AI workflows.',\n  platforms: [claudeCode()],\n  extensions: [hooks()],\n});\n```\n\nEach Hook is a plain ESM default export at `src/hooks/<id>/hook.ts`:\n\n`每个 Hook 使用独立一级目录，并通过 satisfies 获得事件级输入和结果类型。`\n\n```ts\nimport type { Hook } from '@aaplugin/extension-hooks';\n\nexport default {\n  event: 'PreToolUse',\n  matcher: 'Bash|Write|Edit',\n  timeout: 10,\n  platforms: {\n    codex: { additionalContextLimit: 2_500 },\n  },\n  async run(input, context) {\n    return input.toolName === 'Bash'\n      ? { decision: 'allow' }\n      : { decision: 'deny', reason: `Denied on ${context.platform}.` };\n  },\n} satisfies Hook<'PreToolUse'>;\n```\n\nThe canonical events are `SessionStart`, `SessionEnd`, `UserPromptSubmit`, `PreToolUse`, `PermissionRequest`, `PostToolUse`, `PreCompact`, `PostCompact`, `SubagentStart`, `SubagentStop`, and `Stop`.\n\nPlatform-only events stay explicitly scoped and never expand that union:\n\n`平台专属事件必须显式限定；其他 Platform 不会获得产物或兼容性结论。`\n\n```ts\nimport type { Hook } from '@aaplugin/extension-hooks';\n\nexport default {\n  event: { platform: 'claude-code', name: 'Setup' },\n  matcher: 'init',\n  run() {},\n} satisfies Hook;\n```\n\nAAPlugin's Core `portable-node` Compiler bundles each implementation once as a self-contained, platform-neutral Node 20 ESM `hooks/<id>/handler.mjs`. Verified wire profiles are compiled into the same file and own native stdin schemas, camelCase conversion, runtime root/data environment mapping, and stdout mapping. The Handler validates event-specific results, keeps stdin/stdout within 1 MiB, emits only stable error codes, and requires no adjacent runtime JavaScript. Third-party code included in a Handler receives a deterministic `THIRD_PARTY_LICENSES.txt`.\n\n`作者不能声明原始 shell、绝对 executable、HTTP、prompt、agent 或 MCP-tool Handler；平台 wire 协议完全由对应 Contributor 管理。`\n\nClaude Code uses shell-free exec form (`command: \"node\"` plus `args`). Codex currently receives a fixed framework-generated command string because its public Hook schema does not expose `args`. A meaningful matcher is reported as `degraded` whenever the selected host silently ignores it, including Claude Code `UserPromptSubmit`/`Stop` and Codex `UserPromptSubmit`/`Stop`; empty Hooks produce no Assets.\n\nPortable event support:\n\n| Platform | Native | Transformed | Degraded | Unsupported |\n| --- | --- | --- | --- | --- |\n| Claude Code | all 11 portable events | — | matcher on selected events | — |\n| Codex | all 11 portable events | — | matcher on selected events | — |\n| Cursor | — | 9 events | field-level matcher/status loss | `PermissionRequest`, `PostCompact` |\n| Antigravity | `SessionStart`, `SessionEnd`, `PreToolUse`, `PostToolUse`, `PreCompact` | — | field-level matcher/status loss | remaining 6 events |\n| OpenCode | `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PostCompact` | — | `SessionEnd`, `Stop` | remaining 4 events |\n| Pi | `SessionStart`, `SessionEnd`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `PostCompact` | — | `Stop` | `PermissionRequest`, `SubagentStart`, `SubagentStop` |\n\nStrict mode rejects degraded or unsupported outcomes; relaxed mode emits only verified runtimes and preserves the full structured report. Empty Hooks produce no Asset.\n\nContracts were last rechecked on 2026-08-06 against [Claude Code Hooks](https://code.claude.com/docs/en/hooks), [Codex Hooks](https://learn.chatgpt.com/docs/hooks), [Cursor Hooks](https://cursor.com/docs/agent/hooks), [Antigravity Plugins](https://antigravity.google/docs/plugins?app=cli), [OpenCode Plugins](https://opencode.ai/docs/plugins/), and [Pi Extensions](https://pi.dev/docs/latest/extensions).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}