@gitintel-cli/gitintel 0.1.0

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.
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('child_process');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ const binName = process.platform === 'win32' ? 'gitintel.exe' : 'gitintel';
9
+ const binPath = path.join(__dirname, binName);
10
+
11
+ if (!fs.existsSync(binPath)) {
12
+ console.error('gitintel binary not found.');
13
+ console.error('Try reinstalling: npm install -g @gitintel-cli/gitintel');
14
+ console.error('Or build from source: https://github.com/gitintel-ai/GitIntelAI');
15
+ process.exit(1);
16
+ }
17
+
18
+ const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
19
+
20
+ if (result.error) {
21
+ console.error(`Failed to run gitintel: ${result.error.message}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ process.exit(result.status ?? 0);
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@gitintel-cli/gitintel",
3
+ "version": "0.1.0",
4
+ "description": "GitIntel AI — git-native AI adoption tracking, cost intelligence, and context optimization",
5
+ "keywords": [
6
+ "ai",
7
+ "git",
8
+ "attribution",
9
+ "claude-code",
10
+ "cursor",
11
+ "copilot",
12
+ "ai-adoption",
13
+ "cost-tracking",
14
+ "context-optimization"
15
+ ],
16
+ "homepage": "https://gitintel.com",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/gitintel-ai/GitIntelAI.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/gitintel-ai/GitIntelAI/issues"
23
+ },
24
+ "license": "MIT",
25
+ "bin": {
26
+ "gitintel": "./bin/gitintel.js"
27
+ },
28
+ "scripts": {
29
+ "postinstall": "node postinstall.js"
30
+ },
31
+ "files": [
32
+ "bin/",
33
+ "postinstall.js",
34
+ "README.md"
35
+ ],
36
+ "engines": {
37
+ "node": ">=18"
38
+ }
39
+ }
package/postinstall.js ADDED
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const https = require('https');
6
+ const path = require('path');
7
+
8
+ const VERSION = require('./package.json').version;
9
+ const REPO = 'gitintel-ai/GitIntelAI';
10
+ const BIN_DIR = path.join(__dirname, 'bin');
11
+
12
+ // ── Platform detection ────────────────────────────────────────────────────────
13
+
14
+ const PLATFORM_MAP = { linux: 'linux', darwin: 'macos', win32: 'windows' };
15
+ const ARCH_MAP = { x64: 'amd64', arm64: 'arm64' };
16
+
17
+ const platform = PLATFORM_MAP[process.platform];
18
+ const arch = ARCH_MAP[process.arch];
19
+
20
+ if (!platform) {
21
+ warn(`Unsupported platform: ${process.platform}`);
22
+ process.exit(0); // soft exit — don't block npm install
23
+ }
24
+ if (!arch) {
25
+ warn(`Unsupported architecture: ${process.arch}`);
26
+ process.exit(0);
27
+ }
28
+
29
+ const isWindows = process.platform === 'win32';
30
+ const artifactName = isWindows
31
+ ? `gitintel-${platform}-${arch}.exe`
32
+ : `gitintel-${platform}-${arch}`;
33
+ const binName = isWindows ? 'gitintel.exe' : 'gitintel';
34
+ const binPath = path.join(BIN_DIR, binName);
35
+ const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${artifactName}`;
36
+
37
+ // ── Download helper (follows redirects) ──────────────────────────────────────
38
+
39
+ function download(url, dest, hops = 0) {
40
+ return new Promise((resolve, reject) => {
41
+ if (hops > 5) return reject(new Error('Too many redirects'));
42
+
43
+ const tmp = dest + '.tmp';
44
+ const file = fs.createWriteStream(tmp);
45
+
46
+ https
47
+ .get(url, { headers: { 'User-Agent': 'gitintel-npm-installer' } }, (res) => {
48
+ if (res.statusCode === 301 || res.statusCode === 302) {
49
+ file.destroy();
50
+ fs.rmSync(tmp, { force: true });
51
+ return download(res.headers.location, dest, hops + 1).then(resolve).catch(reject);
52
+ }
53
+
54
+ if (res.statusCode !== 200) {
55
+ file.destroy();
56
+ fs.rmSync(tmp, { force: true });
57
+ return reject(new Error(`HTTP ${res.statusCode} downloading ${url}`));
58
+ }
59
+
60
+ res.pipe(file);
61
+ file.on('finish', () => {
62
+ file.close(() => {
63
+ fs.renameSync(tmp, dest);
64
+ resolve();
65
+ });
66
+ });
67
+ file.on('error', (err) => {
68
+ fs.rmSync(tmp, { force: true });
69
+ reject(err);
70
+ });
71
+ })
72
+ .on('error', (err) => {
73
+ fs.rmSync(tmp, { force: true });
74
+ reject(err);
75
+ });
76
+ });
77
+ }
78
+
79
+ // ── Main ──────────────────────────────────────────────────────────────────────
80
+
81
+ async function main() {
82
+ // Skip if binary already present (reinstall / ci cache)
83
+ if (fs.existsSync(binPath)) {
84
+ console.log(` gitintel v${VERSION} already installed, skipping download.`);
85
+ return;
86
+ }
87
+
88
+ console.log(`\n Downloading gitintel v${VERSION} (${platform}/${arch})...`);
89
+
90
+ fs.mkdirSync(BIN_DIR, { recursive: true });
91
+
92
+ try {
93
+ await download(downloadUrl, binPath);
94
+ if (!isWindows) fs.chmodSync(binPath, 0o755);
95
+ console.log(` ✓ gitintel v${VERSION} ready`);
96
+ console.log(` Run 'gitintel --version' to verify.`);
97
+ console.log(` Run 'gitintel init' in a git repo to get started.\n`);
98
+ } catch (err) {
99
+ warn(`Could not download gitintel binary: ${err.message}`);
100
+ warn(`Download manually: https://github.com/${REPO}/releases/tag/v${VERSION}`);
101
+ warn(`Or build from source: https://github.com/${REPO}`);
102
+ // Soft exit — don't block the npm install of the caller
103
+ }
104
+ }
105
+
106
+ function warn(msg) {
107
+ console.warn(` ⚠ ${msg}`);
108
+ }
109
+
110
+ main().catch((err) => {
111
+ warn(err.message);
112
+ });