aicp-tracker 1.1.6 → 1.1.7

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/bin/setup.js CHANGED
@@ -9,6 +9,14 @@ const path = require('path');
9
9
  // Skip if already fully configured (upgrade path — no prompts needed)
10
10
  const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
11
11
  if (isPostinstall) {
12
+ // Always record which project this package was installed into.
13
+ // process.cwd() during postinstall is the project root — the only reliable moment we know it.
14
+ try {
15
+ const config = require('../src/config');
16
+ const existing = config.load() || {};
17
+ config.save({ ...existing, projectPath: process.cwd() });
18
+ } catch {}
19
+
12
20
  let existing = null;
13
21
  try { existing = require('../src/config').load(); } catch {}
14
22
  if (existing?.apiKey && existing?.vcsUrl) process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicp-tracker",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "AI Code Pulse — Claude Code usage tracker for JIRA cost attribution",
5
5
  "main": "src/daemon.js",
6
6
  "bin": {
package/src/daemon.js CHANGED
@@ -11,17 +11,13 @@ const { CONFIG_DIR } = require('./config');
11
11
 
12
12
  const PID_FILE = path.join(CONFIG_DIR, 'daemon.pid');
13
13
 
14
- // When installed locally: __dirname = <project>/node_modules/aicp-tracker/src
15
- // Resolve three levels up to get the host project root, then verify it has a
16
- // package.json that isn't ours (guards against global/npx installs).
14
+ // projectPath is saved during `npm install` (postinstall) when process.cwd()
15
+ // is reliably the host project root. Falls back to cwd if config is missing.
17
16
  function detectProjectPath() {
18
- const candidate = path.resolve(__dirname, '..', '..', '..');
19
- const hostPkg = path.join(candidate, 'package.json');
20
17
  try {
21
- const pkg = JSON.parse(fs.readFileSync(hostPkg, 'utf8'));
22
- if (pkg.name !== 'aicp-tracker') return candidate;
18
+ const cfg = require('./config').load();
19
+ if (cfg?.projectPath) return cfg.projectPath;
23
20
  } catch {}
24
- // Global install or npx — fall back to cwd at start time
25
21
  return process.cwd();
26
22
  }
27
23