ax-agents 0.0.1-alpha.2 → 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 +21 -24
  2. package/package.json +1 -1
package/ax.js CHANGED
@@ -20,6 +20,11 @@ import { fileURLToPath } from "node:url";
20
20
  import path from "node:path";
21
21
  import os from "node:os";
22
22
 
23
+ const __filename = fileURLToPath(import.meta.url);
24
+ const __dirname = path.dirname(__filename);
25
+ const packageJson = JSON.parse(readFileSync(path.join(__dirname, "package.json"), "utf-8"));
26
+ const VERSION = packageJson.version;
27
+
23
28
  /**
24
29
  * @typedef {'claude' | 'codex'} ToolName
25
30
  */
@@ -2511,7 +2516,7 @@ Review changed files for bugs, type errors, and edge cases.
2511
2516
  }
2512
2517
 
2513
2518
  // Version of the hook script template - bump when making changes
2514
- const HOOK_SCRIPT_VERSION = "2";
2519
+ const HOOK_SCRIPT_VERSION = "3";
2515
2520
 
2516
2521
  function ensureMailboxHookScript() {
2517
2522
  const hooksDir = HOOKS_DIR;
@@ -2529,26 +2534,21 @@ function ensureMailboxHookScript() {
2529
2534
  mkdirSync(hooksDir, { recursive: true });
2530
2535
  }
2531
2536
 
2532
- // Inject absolute paths into the generated script
2533
- const mailboxPath = path.join(AI_DIR, "mailbox.jsonl");
2534
- const lastSeenPath = path.join(AI_DIR, "mailbox-last-seen");
2535
-
2536
2537
  const hookCode = `#!/usr/bin/env node
2537
2538
  ${versionMarker}
2538
- // Auto-generated hook script - do not edit manually
2539
-
2540
2539
  import { readFileSync, writeFileSync, existsSync } from "node:fs";
2540
+ import { dirname, join } from "node:path";
2541
+ import { fileURLToPath } from "node:url";
2541
2542
 
2543
+ const __dirname = dirname(fileURLToPath(import.meta.url));
2544
+ const AI_DIR = join(__dirname, "..");
2542
2545
  const DEBUG = process.env.AX_DEBUG === "1";
2543
- const MAILBOX = "${mailboxPath}";
2544
- const LAST_SEEN = "${lastSeenPath}";
2545
- 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;
2546
2549
 
2547
2550
  if (!existsSync(MAILBOX)) process.exit(0);
2548
2551
 
2549
- // Note: commit filtering removed - age + lastSeen is sufficient
2550
-
2551
- // Read last seen timestamp
2552
2552
  let lastSeen = 0;
2553
2553
  try {
2554
2554
  if (existsSync(LAST_SEEN)) {
@@ -2567,11 +2567,7 @@ for (const line of lines) {
2567
2567
  const entry = JSON.parse(line);
2568
2568
  const ts = new Date(entry.timestamp).getTime();
2569
2569
  const age = now - ts;
2570
-
2571
- // Only show observations within max age and not yet seen
2572
- // (removed commit filter - too strict when HEAD moves during a session)
2573
2570
  if (age < MAX_AGE_MS && ts > lastSeen) {
2574
- // Extract session prefix (without UUID) for shorter log command
2575
2571
  const session = entry.payload.session || "";
2576
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, "");
2577
2573
  relevant.push({ agent: entry.payload.agent, sessionPrefix, message: entry.payload.message });
@@ -2596,7 +2592,6 @@ if (relevant.length > 0) {
2596
2592
  }
2597
2593
  const sessionList = [...sessionPrefixes].map(s => "\\\`./ax.js log " + s + "\\\`").join(" or ");
2598
2594
  console.log("> For more context: \\\`./ax.js mailbox\\\`" + (sessionList ? " or " + sessionList : ""));
2599
- // Update last seen timestamp
2600
2595
  writeFileSync(LAST_SEEN, now.toString());
2601
2596
  }
2602
2597
 
@@ -2609,7 +2604,6 @@ process.exit(0);
2609
2604
  // Configure the hook in .claude/settings.json at the same time
2610
2605
  const configuredHook = ensureClaudeHookConfig();
2611
2606
  if (!configuredHook) {
2612
- const hookScriptPath = path.join(HOOKS_DIR, "mailbox-inject.js");
2613
2607
  console.log(`\nTo enable manually, add to .claude/settings.json:\n`);
2614
2608
  console.log(`{
2615
2609
  "hooks": {
@@ -2619,7 +2613,7 @@ process.exit(0);
2619
2613
  "hooks": [
2620
2614
  {
2621
2615
  "type": "command",
2622
- "command": "node ${hookScriptPath}",
2616
+ "command": "node .ai/hooks/mailbox-inject.js",
2623
2617
  "timeout": 5
2624
2618
  }
2625
2619
  ]
@@ -2633,8 +2627,7 @@ process.exit(0);
2633
2627
  function ensureClaudeHookConfig() {
2634
2628
  const settingsDir = ".claude";
2635
2629
  const settingsPath = path.join(settingsDir, "settings.json");
2636
- const hookScriptPath = path.join(HOOKS_DIR, "mailbox-inject.js");
2637
- const hookCommand = `node ${hookScriptPath}`;
2630
+ const hookCommand = "node .ai/hooks/mailbox-inject.js";
2638
2631
 
2639
2632
  try {
2640
2633
  /** @type {ClaudeSettings} */
@@ -3447,7 +3440,7 @@ function printHelp(agent, cliName) {
3447
3440
  const backendName = agent.name === "codex" ? "OpenAI Codex" : "Claude";
3448
3441
  const hasReview = !!agent.reviewOptions;
3449
3442
 
3450
- console.log(`${name}.js - agentic assistant CLI (${backendName})
3443
+ console.log(`${name} v${VERSION} - agentic assistant CLI (${backendName})
3451
3444
 
3452
3445
  Commands:
3453
3446
  agents List all running agents with state and log paths
@@ -3516,6 +3509,11 @@ async function main() {
3516
3509
  const args = process.argv.slice(2);
3517
3510
  const cliName = path.basename(process.argv[1], ".js");
3518
3511
 
3512
+ if (args.includes("--version") || args.includes("-V")) {
3513
+ console.log(VERSION);
3514
+ process.exit(0);
3515
+ }
3516
+
3519
3517
  // Parse flags
3520
3518
  const wait = args.includes("--wait");
3521
3519
  const noWait = args.includes("--no-wait");
@@ -3650,7 +3648,6 @@ async function main() {
3650
3648
 
3651
3649
  // Run main() only when executed directly (not when imported for testing)
3652
3650
  // Use realpathSync to handle symlinks (e.g., axclaude, axcodex bin entries)
3653
- const __filename = fileURLToPath(import.meta.url);
3654
3651
  const isDirectRun = process.argv[1] && (() => {
3655
3652
  try {
3656
3653
  return realpathSync(process.argv[1]) === __filename;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ax-agents",
3
- "version": "0.0.1-alpha.2",
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",