aicp-tracker 1.0.4 → 1.0.5

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/bin/setup.js +35 -5
  2. package/package.json +1 -1
package/bin/setup.js CHANGED
@@ -4,6 +4,8 @@
4
4
  // Runs on `npm install` (postinstall). Skipped in CI environments.
5
5
  if (process.env.CI || process.env.npm_config_yes) process.exit(0);
6
6
 
7
+ const path = require('path');
8
+
7
9
  // Skip if already fully configured (upgrade path — no prompts needed)
8
10
  const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
9
11
  if (isPostinstall) {
@@ -11,10 +13,39 @@ if (isPostinstall) {
11
13
  try { existing = require('../src/config').load(); } catch {}
12
14
  if (existing?.apiKey && existing?.vcsUrl) process.exit(0);
13
15
 
14
- // Interactive prompts are unreliable in the postinstall context across npm
15
- // versions and platforms. The wizard runs on first `aicp-tracker start` instead.
16
- console.log('\n\x1b[1m AI Code Pulse Tracker installed.\x1b[0m');
17
- console.log(' Run \x1b[1maicp-tracker start\x1b[0m to activate tracking.\n');
16
+ // Spawn a new terminal window with the wizard gives a guaranteed TTY
17
+ // regardless of how npm pipes its own stdout during postinstall.
18
+ const { spawn } = require('child_process');
19
+ const wizardPath = path.resolve(__dirname, 'aicp-tracker.js');
20
+ const nodePath = process.execPath;
21
+
22
+ try {
23
+ if (process.platform === 'win32') {
24
+ // cmd /k keeps the window open after the wizard finishes so the user can read output
25
+ spawn('cmd.exe', ['/c', 'start', 'cmd', '/k', `"${nodePath}" "${wizardPath}" setup`], { stdio: 'ignore', detached: true }).unref();
26
+ } else if (process.platform === 'darwin') {
27
+ spawn('osascript', ['-e', `tell app "Terminal" to do script "${nodePath} '${wizardPath}' setup"`], { stdio: 'ignore', detached: true }).unref();
28
+ } else {
29
+ // Try common Linux terminal emulators in order
30
+ const terms = ['x-terminal-emulator', 'gnome-terminal', 'xterm', 'konsole'];
31
+ let launched = false;
32
+ for (const term of terms) {
33
+ try {
34
+ spawn(term, ['-e', `${nodePath} "${wizardPath}" setup`], { stdio: 'ignore', detached: true }).unref();
35
+ launched = true;
36
+ break;
37
+ } catch {}
38
+ }
39
+ if (!launched) {
40
+ console.log('\n\x1b[1m AI Code Pulse Tracker installed.\x1b[0m');
41
+ console.log(' Run \x1b[1maicp-tracker setup\x1b[0m to activate tracking.\n');
42
+ }
43
+ }
44
+ } catch {
45
+ console.log('\n\x1b[1m AI Code Pulse Tracker installed.\x1b[0m');
46
+ console.log(' Run \x1b[1maicp-tracker setup\x1b[0m to activate tracking.\n');
47
+ }
48
+
18
49
  process.exit(0);
19
50
  }
20
51
 
@@ -24,7 +55,6 @@ const { prompt } = require('enquirer');
24
55
  const { execSync } = require('child_process');
25
56
  const fs = require('fs');
26
57
  const os = require('os');
27
- const path = require('path');
28
58
  const config = require('../src/config');
29
59
  const daemon = require('../src/daemon');
30
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicp-tracker",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "AI Code Pulse — Claude Code usage tracker for JIRA cost attribution",
5
5
  "main": "src/daemon.js",
6
6
  "bin": {