@goodfoot/agent-hooks 1.0.5 → 1.0.6

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/CHANGELOG.md ADDED
@@ -0,0 +1,71 @@
1
+ # @goodfoot/agent-hooks npm package changelog
2
+
3
+ ## 1.0.6
4
+
5
+ Restructures the README's Install section to separate the npm package from the plugin, and documents verified plugin installation for Claude Code, Codex, Antigravity, and OpenCode. Adds `README.md` and `CHANGELOG.md` to the package's `files` list so both ship to npm; previously neither was published. No changes to the hook API, the compiler, or the CLI.
6
+
7
+ ## 1.0.5
8
+ - Fixed Codex hook scaffold's PreToolUse/PostToolUse examples to avoid accessing unknown tool_input fields
9
+
10
+ ## 1.0.4
11
+ - Fixed the Codex scaffold's generated `biome.json` to properly scope linting/formatting to project files and enable organized imports
12
+
13
+ ## 1.0.3
14
+ - Fixed the Codex scaffold generating hook imports that pointed at the package root instead of the correct path
15
+ - Fixed a type error in the OpenCode README example where the resumed-session branch didn't narrow correctly
16
+
17
+ ## 1.0.2
18
+ - Added OpenCode plugin support, including session guardrails and advisory/policy hooks
19
+ - Wired `--agent opencode` into the unified CLI for scaffolding OpenCode projects
20
+ - Fixed a type error in scaffolded Claude Code hook tests
21
+
22
+ ## 1.0.1
23
+ - Fixed hardcoded version references so displayed/reported versions stay in sync with the installed package
24
+ - Updated documentation
25
+
26
+ ## 1.0.0
27
+
28
+ Plugin and deprecation groundwork for the 1.0.0 release, plus the Antigravity descope from Step 0.
29
+
30
+ - **Antigravity:** typed factories, output builders, and a self-oracled conformance matrix ship under the Step 0 Outcome B descope — Antigravity is not a shipped agent this release (`agy` OAuth-walls every non-interactive run; CI provides no usable backend). No `@goodfoot/agent-hooks/antigravity` export or skill exists yet; that lands in a follow-up card once a runnable CLI path exists.
31
+ - **`plugins/agent-hooks`** added with `skills/claude-code` and `skills/codex` — mechanically ported and adapted from `plugins/claude-code-hooks/skills/sdk` and `plugins/codex-hooks/skills/sdk` (package names, import specifiers, CLI invocations, and the `AGENT_HOOKS_LOG_FILE`/`AGENT_HOOKS_LOG_ENV_VAR` env var rename). Each skill opens by checking for the deprecated package in the project's `package.json` and offering the repoint.
32
+ - **`@goodfoot/claude-code-hooks` and `@goodfoot/codex-hooks`** marked deprecated: README banners, CHANGELOG entries, and patch version bumps (1.9.0 → 1.9.1, 1.3.0 → 1.3.1) so the notice reaches the registry page on next publish; their plugin skills narrowed to trigger only on the old package names, with a deprecation pointer at the top of each. `npm deprecate` itself, the version-1.0.0 tag/publish, and the marketplace evidence-gated smoke-install remain a separate, explicitly authorized release step — not run as part of this entry.
33
+
34
+ ## 0.3.0
35
+
36
+ Codex parity: the full `@goodfoot/codex-hooks` 1.3.0 surface now ships behind `@goodfoot/agent-hooks/codex`.
37
+
38
+ - **All 10 hook factories** ported with their config shapes (`matcher`, `timeout`, `statusMessage`), result unions, output builders (reserved fields emitted only when passed), input types, constants, and the runtime `execute` entry point. Factory results carry both `.hookEventName` (source name) and `.eventName` (core).
39
+ - **`BlockError` preserved as a subclass of the core `HookBlockError`**, so the shared driver classifies it before consulting policy — carrying an ordering the source runtime already implemented. Public surface unchanged: `name`, `reason`, `instanceof BlockError`.
40
+ - **Wire semantics verbatim:** BlockError → reason on stderr + exit 2 regardless of policy, for every event including SubagentStart (no per-event table — Codex has no narrower native deny); every other unexpected failure → stacktrace + exit 1 under the default policy (Codex exits 1 where Claude Code exits 2), `{}` at exit 0 under `"continue"`; malformed stdin is policy-gated on Codex (NOT unconditionally fail-open — that is Claude Code's rule). Returned-string normalization for the three text-output events is unchanged; other events reject plain text through the same policy path.
41
+ - **Deliberate narrowing — advisory allow-list transcribed from codex-hooks README.md** (Fail-Open Execution): advisory = exactly {UserPromptSubmit, SessionStart, SubagentStart}; never = {PreToolUse, PermissionRequest, blocking PostToolUse/Stop/SubagentStop}; PreCompact/PostCompact are named nowhere in the README and are excluded by default, fail-closed, pending doc clarification. Enforced at factory-call time (runtime gate) and compile time (`MatcherHookConfigFor`/`NoMatcherHookConfigFor`). This intentionally breaks code passing `"continue"` to non-advisory Codex events; no shipped test exercised that gap.
42
+ - **CLI:** `--agent codex` un-stubbed — Codex AST analysis (statusMessage-aware), command-context detection (`.codex-plugin` marker / `--plugin-root` / `.codex` git-toplevel mode / absolute), plugin-mode stable-names default, timeout-in-seconds and statusMessage hooks.json entries; `--plugin-root` flag added to the unified CLI. Codex scaffold templates emit `@goodfoot/agent-hooks` dependencies and `--agent codex` build scripts.
43
+ - **Exports:** closed map grows by one explicit `./codex` subpath (still no wildcard).
44
+ - **Test estate:** all 9 codex unit test files + e2e/runtime-and-build.test.ts ported under tests/codex/ and e2e/codex/ with import-specifier adaptation; parity checker extended to map codex-hooks sources; new conformance matrix documents the three NON-uniform advisory rows (SessionStart/UserPromptSubmit halt vs SubagentStart ignored) from the host-behaviour notes; cross-agent duplication check wired into `test`.
45
+
46
+ ## 0.2.0
47
+
48
+ Claude Code parity: the full `@goodfoot/claude-code-hooks` 1.9.0 surface now ships behind `@goodfoot/agent-hooks/claude-code`, with one deliberate API narrowing.
49
+
50
+ - **All 30 hook factories** ported, including `postToolBatchHook`, which the source package defined but never re-exported from its barrel (pre-existing bug fixed here). Output builders, input/output types, tool-helper guards, env utilities, `Logger`, and `EXIT_CODES` are re-exported from the same entry point.
51
+ - **Deliberate narrowing — advisory fail-open allow-list (FMEA F2):** `unexpectedError: "continue"` is rejected for events not on the Claude Code advisory list (`HOOK_EVENT_NAMES` minus `PreToolUse`, `PermissionRequest`, blocking `Stop`/`SubagentStop`, `WorktreeCreate`/`WorktreeRemove`, transcribed verbatim from CARD.md:75). Enforcement is twice-folded: a runtime policy gate that throws at factory-call time, and compile-time config narrowing (`HookConfigFor`/`TypedHookConfigFor`) that makes `"continue"` unassignable on excluded events. This intentionally breaks code that passed `"continue"` to non-advisory events; no shipped test exercised that gap.
52
+ - **`HookBlockError` wire translation:** a thrown block signal survives fail-open under every policy value and translates per event — native tool-scoped deny shapes for `PreToolUse` (`permissionDecision: "deny"`) and `PermissionRequest` (`decision.behavior: "deny"`), `{ continue: false, stopReason }` elsewhere — via the exported `BLOCK_SHAPE_BY_EVENT` table.
53
+ - **Runtime renamed:** `execute()` now lives in `agents/claude-code/transport.ts` and drives through the shared core; wire semantics carried over exactly — JSON-on-stdout at exit 0 (`{}` when empty), stderr-carrying responses exit 2 with no stdout write, malformed stdin fails open unconditionally, worktree events keep their plain-text stdout protocol. Handler functions receive their context via factory-bound `createContext` (SessionStart gets `persistEnvVar`/`persistEnvVars`).
54
+ - **Metadata property renamed:** factory results expose `.eventName` (core's shape) instead of `.hookEventName`.
55
+ - **Log env vars renamed:** compiled hooks read/wire `AGENT_HOOKS_LOG_FILE` / `AGENT_HOOKS_LOG_ENV_VAR` instead of `CLAUDE_CODE_HOOKS_LOG_FILE` / `CLAUDE_CODE_HOOKS_LOG_ENV_VAR`.
56
+ - **CLI:** single `agent-hooks` binary with a NEW required `--agent <claude-code|codex|antigravity>` flag — exit non-zero without it, never inferred; bare invocations are no longer help requests. `codex`/`antigravity` values validate but fail closed until their parity steps land. All prior flags (`--stable-names`, `--log`, `--log-env-var`, `--loader`, `--no-sourcemap`, scaffold) keep their semantics; install-context inference unchanged. Scaffold templates emit `@goodfoot/agent-hooks/claude-code` imports and `--agent claude-code` build scripts.
57
+ - **Exports:** closed map gains the explicit `./claude-code` subpath (no wildcard, ever); `bin`/`publishConfig` name the `agent-hooks` binary.
58
+ - **Test surface:** unit tests, `tests/types/`, and all 21 e2e files + fixtures ported with import-specifier-only adaptation, guarded by a parity script (counterpart presence + per-file assertion counts) wired into `test`; conformance matrix runs compiled bundles in child processes against hand-written expected wire triples.
59
+
60
+ ## 0.1.0
61
+
62
+ Initial release: agent-neutral core only.
63
+
64
+ - `defineHook<TInput, TOutput, TContext>(eventName, config, handler, policyGate?)` factory primitive with `unexpectedError` policy plumbing (`"error" | "continue"`, `onUnexpectedError` diagnostic sink) and an injectable per-event policy-validation gate; core hardcodes no event list and fails closed when a gate rejects.
65
+ - `core/transport.ts`: `Transport` interface (`finalize(outcome)` pure mapping plus optional `rawStdout` predicate), shared `drive(transport, hookFn)` driver owning stdin read, JSON parse, handler invocation, buffered single-write emission, and process exit; `HookOutcome<TOutput>` discriminated union (`response`, `block`, `handlerError`, `rawStdout`).
66
+ - `HookBlockError` — policy-exempt block-signal channel: classified before `unexpectedError` policy, so an advisory event's intentional block survives fail-open under every policy value.
67
+ - `Logger` ported behavior-identically from `@goodfoot/claude-code-hooks` (silent by default, JSON Lines file output, event subscription).
68
+ - Env utilities ported from `@goodfoot/claude-code-hooks`.
69
+ - Stdin read + JSON parse helpers shared by both source runtimes.
70
+ - Root-export lint as tests: `src/index.ts` re-exports `./core*` only; package `exports` map is a closed list with no `./*` wildcard subpath, with a fail-case fixture proving the check rejects wildcards.
71
+ - Per-agent entry points (`claude-code`, `codex`, `antigravity`) intentionally absent; they land with their implementations.
package/README.md CHANGED
@@ -20,11 +20,86 @@ validate against.
20
20
 
21
21
  ## Install
22
22
 
23
+ Two things ship under the `agent-hooks` name. The **npm package** is the hook API and the
24
+ compiler CLI. The **plugin** carries the `agent-hooks` skill, which teaches a coding agent
25
+ how to write and compile hooks against this package — install it in whichever agent you
26
+ develop with.
27
+
28
+ ### The npm package
29
+
23
30
  ```bash
24
31
  yarn add @goodfoot/agent-hooks
25
32
  # or npm install, pnpm, etc.
26
33
  ```
27
34
 
35
+ ### The plugin, for development
36
+
37
+ All four hosts install from the published marketplace at
38
+ [`goodfoot-io/marketplace`](https://github.com/goodfoot-io/marketplace). Claude Code and
39
+ Codex resolve the repository directly; Antigravity and OpenCode need a local checkout
40
+ because neither exposes a remote marketplace for skills.
41
+
42
+ Note that the plugin and the npm package version independently — the plugin version you
43
+ install will not match the package version above.
44
+
45
+ #### Claude Code
46
+
47
+ ```bash
48
+ claude plugin marketplace add goodfoot-io/marketplace
49
+ claude plugin install agent-hooks@goodfoot
50
+ ```
51
+
52
+ Verify with `claude plugin list` — `agent-hooks@goodfoot` should be listed as enabled.
53
+
54
+ #### Codex
55
+
56
+ ```bash
57
+ codex plugin marketplace add goodfoot-io/marketplace
58
+ codex plugin add agent-hooks@goodfoot
59
+ ```
60
+
61
+ The marketplace source must be a repository, git URL, or directory; passing the manifest
62
+ path itself is rejected. `codex plugin add` requires the `<plugin>@<marketplace>` form.
63
+ Verify with `codex plugin list --json`; the skill tree lands under
64
+ `$CODEX_HOME/plugins/cache/goodfoot/agent-hooks/<version>/skills`.
65
+
66
+ #### Antigravity
67
+
68
+ `agy` has no marketplace command, so install from a checkout:
69
+
70
+ ```bash
71
+ git clone https://github.com/goodfoot-io/marketplace.git
72
+ agy plugin install ./marketplace/plugins-antigravity/agent-hooks
73
+ ```
74
+
75
+ A successful install reports `skills : N processed`; `agents`, `commands`, `mcpServers`,
76
+ and `hooks` report `skipped (not found)`, which is expected for a skills-only plugin.
77
+ Verify with `agy plugin list`.
78
+
79
+ This installs the authoring skill only. It is unrelated to `--agent antigravity`, which
80
+ the compiler CLI still rejects (see the status note above).
81
+
82
+ #### OpenCode
83
+
84
+ OpenCode plugins are hook-transport modules and cannot contribute skills — skills load
85
+ only from `skills.paths`. `opencode plugin` will not install this. Clone the repository
86
+ and register the skill directory in `opencode.json`:
87
+
88
+ ```bash
89
+ git clone https://github.com/goodfoot-io/marketplace.git
90
+ ```
91
+
92
+ ```json
93
+ {
94
+ "skills": {
95
+ "paths": ["./marketplace/plugins-opencode/agent-hooks/skills"]
96
+ }
97
+ }
98
+ ```
99
+
100
+ Verify with `opencode debug skill`, which lists every discovered skill. This is separate
101
+ from compiling hooks *for* OpenCode, covered in [OpenCode](#opencode) below.
102
+
28
103
  ## Quick Start
29
104
 
30
105
  ### 1. Write a hook
@@ -55,7 +55,7 @@ function generatePackageJson(projectName, outputPath) {
55
55
  typecheck: "tsc --noEmit",
56
56
  },
57
57
  dependencies: {
58
- [PACKAGE_NAME]: "^1.0.5",
58
+ [PACKAGE_NAME]: "^1.0.6",
59
59
  },
60
60
  devDependencies: {
61
61
  "@biomejs/biome": "2.4.9",
package/dist/cli.js CHANGED
@@ -26,7 +26,7 @@ import { scaffoldProject } from "./scaffold.js";
26
26
  // ============================================================================
27
27
  // Constants
28
28
  // ============================================================================
29
- const VERSION = "1.0.5";
29
+ const VERSION = "1.0.6";
30
30
  const DEFAULT_ESBUILD_LOADERS = {
31
31
  ".md": "text",
32
32
  };
package/dist/scaffold.js CHANGED
@@ -131,7 +131,7 @@ function generatePackageJson(projectName, outputPath) {
131
131
  typecheck: "tsc --noEmit",
132
132
  },
133
133
  dependencies: {
134
- "@goodfoot/agent-hooks": "^1.0.5",
134
+ "@goodfoot/agent-hooks": "^1.0.6",
135
135
  },
136
136
  devDependencies: {
137
137
  "@biomejs/biome": "2.4.16",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodfoot/agent-hooks",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Unified agent hooks library: shared core runtime with per-agent entry points for Claude Code, Codex, and Antigravity",
5
5
  "homepage": "https://github.com/goodfoot-io/marketplace/tree/main/packages/agent-hooks",
6
6
  "repository": {
@@ -15,14 +15,15 @@
15
15
  },
16
16
  "files": [
17
17
  "dist",
18
- "types"
18
+ "types",
19
+ "README.md",
20
+ "CHANGELOG.md"
19
21
  ],
20
22
  "scripts": {
21
23
  "typecheck": "tsc --noEmit",
22
24
  "build": "tsc --build tsconfig.build.json",
23
25
  "lint": "biome check --write --unsafe --max-diagnostics 500 ./src ./tests ./e2e ./scripts && node ./scripts/check-stale-imports.mjs",
24
- "test": "node ./scripts/check-e2e-parity.mjs && node ./scripts/check-stale-imports.mjs && node ./scripts/check-agent-duplication.mjs && vitest run",
25
- "check:e2e-parity": "node ./scripts/check-e2e-parity.mjs",
26
+ "test": "node ./scripts/check-stale-imports.mjs && node ./scripts/check-agent-duplication.mjs && vitest run",
26
27
  "release": "bash ../../scripts/release-package.sh agent-hooks",
27
28
  "release:dry-run": "bash ../../scripts/release-package.sh agent-hooks --dry-run"
28
29
  },