ax-agents 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/ax.js +13 -5
  2. package/package.json +1 -1
package/ax.js CHANGED
@@ -131,7 +131,7 @@ const VERSION = packageJson.version;
131
131
  /**
132
132
  * @typedef {{matcher: string, hooks: Array<{type: string, command: string, timeout?: number}>}} ClaudeHookEntry
133
133
  * @typedef {Object} ClaudeSettings
134
- * @property {{UserPromptSubmit?: ClaudeHookEntry[], PostToolUse?: ClaudeHookEntry[], Stop?: ClaudeHookEntry[], [key: string]: ClaudeHookEntry[] | undefined}} [hooks]
134
+ * @property {{UserPromptSubmit?: ClaudeHookEntry[], PreToolUse?: ClaudeHookEntry[], Stop?: ClaudeHookEntry[], [key: string]: ClaudeHookEntry[] | undefined}} [hooks]
135
135
  */
136
136
 
137
137
  const DEBUG = process.env.AX_DEBUG === "1";
@@ -3420,7 +3420,7 @@ async function cmdRecall(name = null) {
3420
3420
  }
3421
3421
 
3422
3422
  // Version of the hook script template - bump when making changes
3423
- const HOOK_SCRIPT_VERSION = "4";
3423
+ const HOOK_SCRIPT_VERSION = "5";
3424
3424
 
3425
3425
  function ensureMailboxHookScript() {
3426
3426
  const hooksDir = HOOKS_DIR;
@@ -3539,8 +3539,16 @@ if (relevant.length > 0) {
3539
3539
  // For Stop hook, return blocking JSON to force acknowledgment
3540
3540
  if (hookEvent === "Stop") {
3541
3541
  console.log(JSON.stringify({ decision: "block", reason: formattedMessage }));
3542
+ } else if (hookEvent === "PreToolUse") {
3543
+ // For PreToolUse, use JSON with hookSpecificOutput to inject into Claude's context
3544
+ console.log(JSON.stringify({
3545
+ hookSpecificOutput: {
3546
+ hookEventName: "PreToolUse",
3547
+ additionalContext: formattedMessage
3548
+ }
3549
+ }));
3542
3550
  } else {
3543
- // For other hooks, just output the context
3551
+ // For UserPromptSubmit, plain text stdout is automatically added to context
3544
3552
  console.log(formattedMessage);
3545
3553
  }
3546
3554
 
@@ -3566,7 +3574,7 @@ process.exit(0);
3566
3574
  console.log(`{
3567
3575
  "hooks": {
3568
3576
  "UserPromptSubmit": [{ "matcher": "", "hooks": [{ "type": "command", "command": "node .ai/hooks/mailbox-inject.js", "timeout": 5 }] }],
3569
- "PostToolUse": [{ "matcher": "", "hooks": [{ "type": "command", "command": "node .ai/hooks/mailbox-inject.js", "timeout": 5 }] }],
3577
+ "PreToolUse": [{ "matcher": "", "hooks": [{ "type": "command", "command": "node .ai/hooks/mailbox-inject.js", "timeout": 5 }] }],
3570
3578
  "Stop": [{ "matcher": "", "hooks": [{ "type": "command", "command": "node .ai/hooks/mailbox-inject.js", "timeout": 5 }] }]
3571
3579
  }
3572
3580
  }`);
@@ -3577,7 +3585,7 @@ function ensureClaudeHookConfig() {
3577
3585
  const settingsDir = ".claude";
3578
3586
  const settingsPath = path.join(settingsDir, "settings.json");
3579
3587
  const hookCommand = "node .ai/hooks/mailbox-inject.js";
3580
- const hookEvents = ["UserPromptSubmit", "PostToolUse", "Stop"];
3588
+ const hookEvents = ["UserPromptSubmit", "PreToolUse", "Stop"];
3581
3589
 
3582
3590
  try {
3583
3591
  /** @type {ClaudeSettings} */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ax-agents",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A CLI for orchestrating AI coding agents via tmux",
5
5
  "bin": {
6
6
  "ax": "ax.js",