aicp-tracker 1.0.0 → 1.0.3

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
@@ -4,6 +4,18 @@
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
+ // Skip interactive setup on upgrade if already fully configured.
8
+ // The user can always re-run manually: aicp-tracker setup
9
+ const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
10
+ if (isPostinstall) {
11
+ let existing = null;
12
+ try { existing = require('../src/config').load(); } catch {}
13
+ if (existing?.apiKey && existing?.vcsUrl) {
14
+ console.log('\n [aicp-tracker] Already configured — skipping setup. Run `aicp-tracker setup` to reconfigure.\n');
15
+ process.exit(0);
16
+ }
17
+ }
18
+
7
19
  const { prompt } = require('enquirer');
8
20
  const { execSync } = require('child_process');
9
21
  const fs = require('fs');
@@ -12,7 +24,7 @@ const path = require('path');
12
24
  const config = require('../src/config');
13
25
  const daemon = require('../src/daemon');
14
26
 
15
- const API_URL = 'http://147.5.102.208:3000';
27
+ const API_URL = 'https://aicp-tracker.duckdns.org';
16
28
  const TASK_NAME = 'AI Code Pulse Tracker';
17
29
 
18
30
  const PLANS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicp-tracker",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
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/log-parser.js CHANGED
@@ -6,6 +6,20 @@ const state = require('./state');
6
6
  // Tool names whose input.file_path / input.path we extract
7
7
  const FILE_TOOLS = new Set(['Read', 'Edit', 'Write', 'Glob', 'NotebookEdit', 'MultiEdit']);
8
8
 
9
+ /**
10
+ * Extracts all JIRA-style task keys from a git branch name.
11
+ * Handles all combinations per spec:
12
+ * "STORAGE-56: ASD", "STORAGE-56 ASD", "ASD STORAGE-56", "STORAGE-56",
13
+ * "storage-56 asd" (case-insensitive), "asd :storage-56",
14
+ * "STORAGE-56, STORAGE-57: ASD" (multiple tasks → returns both)
15
+ * Returns uppercase deduplicated keys: ["STORAGE-56", "STORAGE-57"]
16
+ */
17
+ function extractTasksFromBranch(branch) {
18
+ if (!branch || typeof branch !== 'string') return [];
19
+ const matches = branch.match(/[A-Za-z][A-Za-z0-9]*-\d+/g) || [];
20
+ return [...new Set(matches.map(m => m.toUpperCase()))];
21
+ }
22
+
9
23
  function parseNewLines(filePath) {
10
24
  const offset = state.getOffset(filePath);
11
25
  let stat;
@@ -49,12 +63,13 @@ function parseNewLines(filePath) {
49
63
  }
50
64
 
51
65
  records.push({
52
- sessionId: entry.sessionId || null,
53
- uuid: entry.uuid || null,
54
- parentUuid: entry.parentUuid || null,
55
- timestamp: entry.timestamp || new Date().toISOString(),
56
- gitBranch: entry.gitBranch || null,
57
- model: entry.message?.model || null,
66
+ sessionId: entry.sessionId || null,
67
+ uuid: entry.uuid || null,
68
+ parentUuid: entry.parentUuid || null,
69
+ timestamp: entry.timestamp || new Date().toISOString(),
70
+ gitBranch: entry.gitBranch || null,
71
+ task_from_git_branch: extractTasksFromBranch(entry.gitBranch),
72
+ model: entry.message?.model || null,
58
73
 
59
74
  input_tokens: usage.input_tokens || 0,
60
75
  cache_creation_input_tokens: usage.cache_creation_input_tokens || 0,
@@ -73,7 +88,7 @@ function parseNewLines(filePath) {
73
88
  enterprise_usd_per_token: null,
74
89
 
75
90
  service_tier: usage.service_tier || null,
76
- speed: usage.cache_creation_input_tokens > 0 ? 'fast' : 'normal',
91
+ speed: usage.speed || (usage.cache_creation_input_tokens > 0 ? 'fast' : 'normal'),
77
92
  });
78
93
  }
79
94
 
package/src/sender.js CHANGED
@@ -35,7 +35,9 @@ function buildPayload(cfg, records) {
35
35
  sessionId: rec.sessionId,
36
36
  uuid: rec.uuid,
37
37
  parentUuid: rec.parentUuid,
38
+ timestamp: rec.timestamp || null,
38
39
  gitBranch: rec.gitBranch,
40
+ task_from_git_branch: rec.task_from_git_branch || [],
39
41
  });
40
42
  }
41
43