aicp-tracker 1.0.3 → 1.0.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.
- package/bin/aicp-tracker.js +17 -4
- package/bin/setup.js +20 -17
- package/package.json +2 -2
- package/LICENSE +0 -19
package/bin/aicp-tracker.js
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const [,, cmd
|
|
4
|
+
const [,, cmd] = process.argv;
|
|
5
|
+
|
|
6
|
+
async function ensureConfigured() {
|
|
7
|
+
const config = require('../src/config');
|
|
8
|
+
const existing = (() => { try { return config.load(); } catch { return null; } })();
|
|
9
|
+
if (existing?.apiKey && existing?.vcsUrl) return;
|
|
10
|
+
// No config — run the wizard first, then continue
|
|
11
|
+
await require('./setup').main();
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
switch (cmd) {
|
|
7
|
-
case 'start':
|
|
15
|
+
case 'start':
|
|
16
|
+
ensureConfigured().then(() => require('../src/daemon').start()).catch(e => {
|
|
17
|
+
console.error('[aicp-tracker] Setup failed:', e.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
});
|
|
20
|
+
break;
|
|
8
21
|
case 'stop': require('../src/daemon').stop(); break;
|
|
9
22
|
case 'status': require('../src/daemon').status(); break;
|
|
10
|
-
case 'setup': require('./setup');
|
|
23
|
+
case 'setup': require('./setup').main().catch(e => console.error('[aicp-tracker] Setup failed:', e.message)); break;
|
|
11
24
|
case 'flush': require('../src/wal').flush(); break;
|
|
12
25
|
default:
|
|
13
26
|
console.log(`
|
|
14
27
|
aicp-tracker <command>
|
|
15
28
|
|
|
16
29
|
Commands:
|
|
17
|
-
start Start the background tracker (
|
|
30
|
+
start Start the background tracker (runs setup wizard on first use)
|
|
18
31
|
stop Stop the background tracker
|
|
19
32
|
status Show tracker status and WAL queue depth
|
|
20
33
|
setup Re-run the configuration wizard
|
package/bin/setup.js
CHANGED
|
@@ -4,18 +4,22 @@
|
|
|
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
|
|
8
|
-
// The user can always re-run manually: aicp-tracker setup
|
|
7
|
+
// Skip if already fully configured (upgrade path — no prompts needed)
|
|
9
8
|
const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
|
|
10
9
|
if (isPostinstall) {
|
|
11
10
|
let existing = null;
|
|
12
11
|
try { existing = require('../src/config').load(); } catch {}
|
|
13
|
-
if (existing?.apiKey && existing?.vcsUrl)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (existing?.apiKey && existing?.vcsUrl) process.exit(0);
|
|
13
|
+
|
|
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');
|
|
18
|
+
process.exit(0);
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
// ── When called directly (aicp-tracker setup) ─────────────────────────────────
|
|
22
|
+
|
|
19
23
|
const { prompt } = require('enquirer');
|
|
20
24
|
const { execSync } = require('child_process');
|
|
21
25
|
const fs = require('fs');
|
|
@@ -44,14 +48,11 @@ function installAutoStart() {
|
|
|
44
48
|
|
|
45
49
|
try {
|
|
46
50
|
if (process.platform === 'win32') {
|
|
47
|
-
// Windows Task Scheduler: run at every login, current user only
|
|
48
51
|
execSync(
|
|
49
52
|
`schtasks /create /tn "${TASK_NAME}" /tr "\\"${nodePath}\\" \\"${scriptPath}\\" start" /sc ONLOGON /f`,
|
|
50
53
|
{ stdio: 'ignore' }
|
|
51
54
|
);
|
|
52
|
-
|
|
53
55
|
} else if (process.platform === 'darwin') {
|
|
54
|
-
// macOS launchd: load on login
|
|
55
56
|
const plistDir = path.join(os.homedir(), 'Library', 'LaunchAgents');
|
|
56
57
|
const plistPath = path.join(plistDir, 'com.aicp-tracker.plist');
|
|
57
58
|
fs.mkdirSync(plistDir, { recursive: true });
|
|
@@ -71,9 +72,7 @@ function installAutoStart() {
|
|
|
71
72
|
</dict>
|
|
72
73
|
</plist>`);
|
|
73
74
|
execSync(`launchctl load "${plistPath}"`, { stdio: 'ignore' });
|
|
74
|
-
|
|
75
75
|
} else {
|
|
76
|
-
// Linux: systemd user service
|
|
77
76
|
const unitDir = path.join(os.homedir(), '.config', 'systemd', 'user');
|
|
78
77
|
const unitPath = path.join(unitDir, 'aicp-tracker.service');
|
|
79
78
|
fs.mkdirSync(unitDir, { recursive: true });
|
|
@@ -90,7 +89,6 @@ WantedBy=default.target
|
|
|
90
89
|
`);
|
|
91
90
|
execSync('systemctl --user daemon-reload && systemctl --user enable --now aicp-tracker', { stdio: 'ignore' });
|
|
92
91
|
}
|
|
93
|
-
|
|
94
92
|
return true;
|
|
95
93
|
} catch {
|
|
96
94
|
return false;
|
|
@@ -115,12 +113,12 @@ async function register(email) {
|
|
|
115
113
|
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
116
114
|
|
|
117
115
|
async function main() {
|
|
118
|
-
console.log('\n\x1b[1m AI Code Pulse Tracker —
|
|
116
|
+
console.log('\n\x1b[1m AI Code Pulse Tracker — setup\x1b[0m\n');
|
|
119
117
|
|
|
120
118
|
let existing = null;
|
|
121
119
|
try { existing = config.load(); } catch {}
|
|
122
120
|
if (existing?.vcsUrl) {
|
|
123
|
-
console.log(` Already configured (${existing.vcsUrl}).
|
|
121
|
+
console.log(` Already configured (${existing.vcsUrl}). Answers below will overwrite it.\n`);
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
const answers = await prompt([
|
|
@@ -174,6 +172,11 @@ async function main() {
|
|
|
174
172
|
console.log(' \x1b[32m✔\x1b[0m Tracker running. Usage will be sent every 5 minutes.\n');
|
|
175
173
|
}
|
|
176
174
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
module.exports = { main };
|
|
176
|
+
|
|
177
|
+
// Auto-run when invoked directly (aicp-tracker setup) or required without await
|
|
178
|
+
if (require.main === module || process.env.npm_lifecycle_event === 'postinstall') {
|
|
179
|
+
main().catch(e => {
|
|
180
|
+
console.warn('\n [aicp-tracker] Setup error:', e.message, '\n Run `aicp-tracker setup` to try again.\n');
|
|
181
|
+
});
|
|
182
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicp-tracker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "AI Code Pulse — Claude Code usage tracker for JIRA cost attribution",
|
|
5
5
|
"main": "src/daemon.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=18"
|
|
17
17
|
},
|
|
18
|
-
"license": "
|
|
18
|
+
"license": "MIT",
|
|
19
19
|
"private": false
|
|
20
20
|
}
|
package/LICENSE
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2026 Alexey Pavlenko
|
|
2
|
-
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
This software is proprietary and confidential.
|
|
6
|
-
|
|
7
|
-
Permission is granted to install and use this software solely for the purpose
|
|
8
|
-
of interacting with the AICP Tracker service, and only with a valid and active subscription.
|
|
9
|
-
|
|
10
|
-
You may NOT:
|
|
11
|
-
- copy, modify, merge, publish, distribute, sublicense, or sell the software
|
|
12
|
-
- use the software in any competing product or service
|
|
13
|
-
- reverse engineer, decompile, or attempt to extract source code or algorithms
|
|
14
|
-
- remove or alter any proprietary notices
|
|
15
|
-
|
|
16
|
-
The software is provided "as is", without warranty of any kind.
|
|
17
|
-
|
|
18
|
-
Access to the source code (if provided) is for review purposes only and does
|
|
19
|
-
not grant any rights beyond what is explicitly stated in this license.
|