@goodfoot/agent-hooks 1.0.11 → 1.0.12

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @goodfoot/agent-hooks npm package changelog
2
2
 
3
+ ## 1.0.12
4
+
5
+ Waits for stdout and stderr writes to complete before exiting, preventing truncated hook responses and error diagnostics when output is piped. Asynchronous stdout write failures now follow the existing unexpected-error policy without retrying the payload.
6
+
3
7
  ## 1.0.11
4
8
 
5
9
  Moves generated-file tracking out of `hooks.json` into a sibling `hooks.meta.json`, because Claude Code rejects a hooks manifest carrying any key besides `hooks`. The manifest is now a pure function of its inputs, so a rebuild that changes nothing writes identical bytes and leaves the host's hook-trust hash intact. A missing or unreadable sidecar is treated as "nothing tracked as generated", which preserves the entries already in the manifest rather than pruning them.
@@ -50,7 +50,7 @@ function packageJson(projectName, outputPath) {
50
50
  lint: "biome check .",
51
51
  typecheck: "tsc --noEmit",
52
52
  },
53
- dependencies: { [PACKAGE_NAME]: "^1.0.11" },
53
+ dependencies: { [PACKAGE_NAME]: "^1.0.12" },
54
54
  devDependencies: {
55
55
  "@biomejs/biome": "2.4.9",
56
56
  "@types/node": "^24.0.0",
@@ -55,7 +55,7 @@ function generatePackageJson(projectName, outputPath) {
55
55
  typecheck: "tsc --noEmit",
56
56
  },
57
57
  dependencies: {
58
- [PACKAGE_NAME]: "^1.0.11",
58
+ [PACKAGE_NAME]: "^1.0.12",
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.11";
29
+ const VERSION = "1.0.12";
30
30
  /** Filename of the tracking sidecar written beside hooks.json. */
31
31
  const HOOKS_META_FILENAME = "hooks.meta.json";
32
32
  const DEFAULT_ESBUILD_LOADERS = {
@@ -111,18 +111,29 @@ function classify(error, phase, policy, onUnexpectedError) {
111
111
  }
112
112
  return { kind: "handlerError", error, phase };
113
113
  }
114
+ // A successful write return value only describes buffering; its callback confirms delivery.
115
+ function writeStream(stream, content) {
116
+ return new Promise((resolve, reject) => {
117
+ stream.write(content, (error) => {
118
+ if (error)
119
+ reject(error);
120
+ else
121
+ resolve();
122
+ });
123
+ });
124
+ }
114
125
  /**
115
126
  * Writes an unexpected (non-handler, runtime-owned) error's stacktrace to
116
127
  * stderr. Used for cleanup/finalize failures under the default `"error"`
117
128
  * policy, which exit with code 1 — these are not the handler's own
118
129
  * intentional signal.
119
130
  */
120
- function writeUnexpectedErrorStderr(error) {
131
+ async function writeUnexpectedErrorStderr(error) {
121
132
  if (error instanceof Error) {
122
- process.stderr.write(`${error.stack ?? error.message}\n`);
133
+ await writeStream(process.stderr, `${error.stack ?? error.message}\n`);
123
134
  }
124
135
  else {
125
- process.stderr.write(`${String(error)}\n`);
136
+ await writeStream(process.stderr, `${String(error)}\n`);
126
137
  }
127
138
  }
128
139
  /**
@@ -198,7 +209,7 @@ export async function drive(transport, hookFn) {
198
209
  cleanupQuietly();
199
210
  process.exit(FALLBACK_EXIT_SUCCESS);
200
211
  }
201
- writeUnexpectedErrorStderr(error);
212
+ await writeUnexpectedErrorStderr(error);
202
213
  cleanupQuietly();
203
214
  process.exit(FALLBACK_EXIT_ERROR);
204
215
  }
@@ -206,15 +217,15 @@ export async function drive(transport, hookFn) {
206
217
  cleanup(policy, onUnexpectedError);
207
218
  }
208
219
  catch (error) {
209
- writeUnexpectedErrorStderr(error);
220
+ await writeUnexpectedErrorStderr(error);
210
221
  process.exit(FALLBACK_EXIT_ERROR);
211
222
  }
212
223
  if (finalized.stderr !== undefined) {
213
- process.stderr.write(finalized.stderr);
224
+ await writeStream(process.stderr, finalized.stderr);
214
225
  }
215
226
  if (finalized.stdout !== undefined) {
216
227
  try {
217
- process.stdout.write(finalized.stdout);
228
+ await writeStream(process.stdout, finalized.stdout);
218
229
  }
219
230
  catch (error) {
220
231
  if (policy === "continue") {
@@ -222,7 +233,7 @@ export async function drive(transport, hookFn) {
222
233
  cleanupQuietly();
223
234
  process.exit(FALLBACK_EXIT_SUCCESS);
224
235
  }
225
- writeUnexpectedErrorStderr(error);
236
+ await writeUnexpectedErrorStderr(error);
226
237
  cleanupQuietly();
227
238
  process.exit(FALLBACK_EXIT_ERROR);
228
239
  }
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.11",
134
+ "@goodfoot/agent-hooks": "^1.0.12",
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.11",
3
+ "version": "1.0.12",
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": {
@@ -22,7 +22,7 @@
22
22
  "scripts": {
23
23
  "typecheck": "tsc --noEmit",
24
24
  "build": "tsc --build tsconfig.build.json",
25
- "lint": "biome check --write --unsafe --max-diagnostics 500 ./src ./tests ./e2e ./scripts && node ./scripts/check-stale-imports.mjs",
25
+ "lint": "biome check --write --unsafe --max-diagnostics 500 ./src ./tests ./e2e ./scripts ./vitest.config.ts && node ./scripts/check-stale-imports.mjs",
26
26
  "test": "node ./scripts/check-stale-imports.mjs && node ./scripts/check-agent-duplication.mjs && vitest run",
27
27
  "release": "bash ../../scripts/release-package.sh agent-hooks",
28
28
  "release:dry-run": "bash ../../scripts/release-package.sh agent-hooks --dry-run"
@@ -56,7 +56,7 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "esbuild": "^0.24.0",
59
+ "esbuild": "^0.28.2",
60
60
  "glob": "^11.0.0",
61
61
  "typescript": "^5.9.3"
62
62
  },
@@ -70,10 +70,15 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@anthropic-ai/claude-agent-sdk": "^0.3.162",
73
+ "@anthropic-ai/sdk": "^0.133.0",
73
74
  "@biomejs/biome": "2.4.16",
75
+ "@goodfoot/vitest-cache": "workspace:*",
76
+ "@modelcontextprotocol/sdk": "^1.29.0",
74
77
  "@opencode-ai/plugin": "1.18.23",
75
- "@types/node": "^24",
78
+ "@types/node": "^26.6.5",
76
79
  "tsx": "^4.20.6",
77
- "vitest": "4.0.13"
80
+ "vite": "8.3.4",
81
+ "vitest": "patch:vitest@npm%3A5.0.4#~/.yarn/patches/vitest-npm-5.0.4-2ab4bceca5.patch",
82
+ "zod": "^4.6.7"
78
83
  }
79
84
  }