aicp-tracker 1.2.5 → 1.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicp-tracker",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
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
@@ -81,15 +81,19 @@ function stop() {
81
81
  function status() {
82
82
  const pid = readPid();
83
83
  const running = pid ? (() => { try { process.kill(pid, 0); return true; } catch { return false; } })() : false;
84
- const { pathToProjectFolder } = require('./log-scanner');
84
+ const { pathToProjectFolder, findMatchingProjectFolder } = require('./log-scanner');
85
85
  const claudeFolder = pathToProjectFolder(PROJECT_PATH);
86
- const claudeDir = path.join(os.homedir(), '.claude', 'projects');
87
- const available = fs.existsSync(claudeDir) ? fs.readdirSync(claudeDir).filter(e => fs.statSync(path.join(claudeDir, e)).isDirectory()) : [];
88
- const matched = available.includes(claudeFolder);
86
+ const resolvedFolder = findMatchingProjectFolder(PROJECT_PATH);
87
+ const matched = resolvedFolder !== null;
88
+ const resolvedNote = matched && resolvedFolder !== claudeFolder ? ` (resolved to parent: ${resolvedFolder})` : '';
89
89
  console.log(`[daemon] Status: ${running ? `running (pid ${pid})` : 'stopped'}`);
90
90
  console.log(`[daemon] Project path: ${PROJECT_PATH}`);
91
- console.log(`[daemon] Claude folder: ${claudeFolder} ${matched ? '✔ found' : '✘ NOT FOUND in ~/.claude/projects'}`);
92
- if (!matched) console.log(`[daemon] Available: ${available.join(', ')}`);
91
+ console.log(`[daemon] Claude folder: ${claudeFolder} ${matched ? `✔ found${resolvedNote}` : '✘ NOT FOUND in ~/.claude/projects'}`);
92
+ if (!matched) {
93
+ const claudeDir = path.join(os.homedir(), '.claude', 'projects');
94
+ const available = fs.existsSync(claudeDir) ? fs.readdirSync(claudeDir).filter(e => fs.statSync(path.join(claudeDir, e)).isDirectory()) : [];
95
+ console.log(`[daemon] Available: ${available.join(', ')}`);
96
+ }
93
97
  console.log(`[daemon] WAL pending: ${wal.pendingCount()} records`);
94
98
  console.log(`[daemon] Log file: ${path.join(CONFIG_DIR, 'daemon.log')}`);
95
99
  }
@@ -23,11 +23,30 @@ function pathToProjectFolder(p) {
23
23
  return p.replace(/\//g, '-').replace(/_/g, '-');
24
24
  }
25
25
 
26
+ // Walk up from projectPath until a matching ~/.claude/projects/<folder> exists.
27
+ // This handles the case where Claude Code names the project by the workspace root
28
+ // rather than the sub-directory where the package was installed.
29
+ function findMatchingProjectFolder(projectPath) {
30
+ if (!projectPath || !fs.existsSync(CLAUDE_DIR)) return null;
31
+ let p = projectPath;
32
+ while (true) {
33
+ const candidate = pathToProjectFolder(p);
34
+ const candidateDir = path.join(CLAUDE_DIR, candidate);
35
+ if (fs.existsSync(candidateDir) && fs.statSync(candidateDir).isDirectory()) {
36
+ return candidate;
37
+ }
38
+ const parent = path.dirname(p);
39
+ if (parent === p) break; // reached filesystem root
40
+ p = parent;
41
+ }
42
+ return null;
43
+ }
44
+
26
45
  function findJsonlFiles(projectPath) {
27
46
  const results = [];
28
47
  if (!fs.existsSync(CLAUDE_DIR)) return results;
29
48
 
30
- const targetFolder = projectPath ? pathToProjectFolder(projectPath) : null;
49
+ const targetFolder = projectPath ? findMatchingProjectFolder(projectPath) : null;
31
50
 
32
51
  for (const entry of fs.readdirSync(CLAUDE_DIR)) {
33
52
  if (targetFolder && entry !== targetFolder) continue;
@@ -43,4 +62,4 @@ function findJsonlFiles(projectPath) {
43
62
  return results;
44
63
  }
45
64
 
46
- module.exports = { findJsonlFiles, pathToProjectFolder };
65
+ module.exports = { findJsonlFiles, pathToProjectFolder, findMatchingProjectFolder };