ax-agents 0.0.1-alpha.3 → 0.0.1-alpha.4

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 +10 -22
  2. package/package.json +1 -1
package/ax.js CHANGED
@@ -2516,7 +2516,7 @@ Review changed files for bugs, type errors, and edge cases.
2516
2516
  }
2517
2517
 
2518
2518
  // Version of the hook script template - bump when making changes
2519
- const HOOK_SCRIPT_VERSION = "2";
2519
+ const HOOK_SCRIPT_VERSION = "3";
2520
2520
 
2521
2521
  function ensureMailboxHookScript() {
2522
2522
  const hooksDir = HOOKS_DIR;
@@ -2534,26 +2534,21 @@ function ensureMailboxHookScript() {
2534
2534
  mkdirSync(hooksDir, { recursive: true });
2535
2535
  }
2536
2536
 
2537
- // Inject absolute paths into the generated script
2538
- const mailboxPath = path.join(AI_DIR, "mailbox.jsonl");
2539
- const lastSeenPath = path.join(AI_DIR, "mailbox-last-seen");
2540
-
2541
2537
  const hookCode = `#!/usr/bin/env node
2542
2538
  ${versionMarker}
2543
- // Auto-generated hook script - do not edit manually
2544
-
2545
2539
  import { readFileSync, writeFileSync, existsSync } from "node:fs";
2540
+ import { dirname, join } from "node:path";
2541
+ import { fileURLToPath } from "node:url";
2546
2542
 
2543
+ const __dirname = dirname(fileURLToPath(import.meta.url));
2544
+ const AI_DIR = join(__dirname, "..");
2547
2545
  const DEBUG = process.env.AX_DEBUG === "1";
2548
- const MAILBOX = "${mailboxPath}";
2549
- const LAST_SEEN = "${lastSeenPath}";
2550
- const MAX_AGE_MS = 60 * 60 * 1000; // 1 hour (matches MAILBOX_MAX_AGE_MS)
2546
+ const MAILBOX = join(AI_DIR, "mailbox.jsonl");
2547
+ const LAST_SEEN = join(AI_DIR, "mailbox-last-seen");
2548
+ const MAX_AGE_MS = 60 * 60 * 1000;
2551
2549
 
2552
2550
  if (!existsSync(MAILBOX)) process.exit(0);
2553
2551
 
2554
- // Note: commit filtering removed - age + lastSeen is sufficient
2555
-
2556
- // Read last seen timestamp
2557
2552
  let lastSeen = 0;
2558
2553
  try {
2559
2554
  if (existsSync(LAST_SEEN)) {
@@ -2572,11 +2567,7 @@ for (const line of lines) {
2572
2567
  const entry = JSON.parse(line);
2573
2568
  const ts = new Date(entry.timestamp).getTime();
2574
2569
  const age = now - ts;
2575
-
2576
- // Only show observations within max age and not yet seen
2577
- // (removed commit filter - too strict when HEAD moves during a session)
2578
2570
  if (age < MAX_AGE_MS && ts > lastSeen) {
2579
- // Extract session prefix (without UUID) for shorter log command
2580
2571
  const session = entry.payload.session || "";
2581
2572
  const sessionPrefix = session.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "");
2582
2573
  relevant.push({ agent: entry.payload.agent, sessionPrefix, message: entry.payload.message });
@@ -2601,7 +2592,6 @@ if (relevant.length > 0) {
2601
2592
  }
2602
2593
  const sessionList = [...sessionPrefixes].map(s => "\\\`./ax.js log " + s + "\\\`").join(" or ");
2603
2594
  console.log("> For more context: \\\`./ax.js mailbox\\\`" + (sessionList ? " or " + sessionList : ""));
2604
- // Update last seen timestamp
2605
2595
  writeFileSync(LAST_SEEN, now.toString());
2606
2596
  }
2607
2597
 
@@ -2614,7 +2604,6 @@ process.exit(0);
2614
2604
  // Configure the hook in .claude/settings.json at the same time
2615
2605
  const configuredHook = ensureClaudeHookConfig();
2616
2606
  if (!configuredHook) {
2617
- const hookScriptPath = path.join(HOOKS_DIR, "mailbox-inject.js");
2618
2607
  console.log(`\nTo enable manually, add to .claude/settings.json:\n`);
2619
2608
  console.log(`{
2620
2609
  "hooks": {
@@ -2624,7 +2613,7 @@ process.exit(0);
2624
2613
  "hooks": [
2625
2614
  {
2626
2615
  "type": "command",
2627
- "command": "node ${hookScriptPath}",
2616
+ "command": "node .ai/hooks/mailbox-inject.js",
2628
2617
  "timeout": 5
2629
2618
  }
2630
2619
  ]
@@ -2638,8 +2627,7 @@ process.exit(0);
2638
2627
  function ensureClaudeHookConfig() {
2639
2628
  const settingsDir = ".claude";
2640
2629
  const settingsPath = path.join(settingsDir, "settings.json");
2641
- const hookScriptPath = path.join(HOOKS_DIR, "mailbox-inject.js");
2642
- const hookCommand = `node ${hookScriptPath}`;
2630
+ const hookCommand = "node .ai/hooks/mailbox-inject.js";
2643
2631
 
2644
2632
  try {
2645
2633
  /** @type {ClaudeSettings} */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ax-agents",
3
- "version": "0.0.1-alpha.3",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "A CLI for orchestrating AI coding agents via tmux",
5
5
  "bin": {
6
6
  "ax": "ax.js",