create-agit 0.1.1 → 0.2.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.
- package/bin.mjs +42 -26
- package/package.json +2 -2
package/bin.mjs
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { createRequire } from 'node:module'
|
|
16
|
-
import { chmodSync, copyFileSync,
|
|
17
|
-
import { homedir, platform, arch
|
|
18
|
-
import { join } from 'node:path'
|
|
16
|
+
import { chmodSync, copyFileSync, mkdirSync } from 'node:fs'
|
|
17
|
+
import { homedir, platform, arch } from 'node:os'
|
|
18
|
+
import { join, delimiter } from 'node:path'
|
|
19
19
|
import { spawnSync } from 'node:child_process'
|
|
20
20
|
|
|
21
21
|
const require = createRequire(import.meta.url)
|
|
@@ -25,25 +25,26 @@ function dim(m) { console.log(`\x1b[2m${m}\x1b[0m`) }
|
|
|
25
25
|
function ok(m) { console.log(`\x1b[32m✓\x1b[0m ${m}`) }
|
|
26
26
|
function fail(m) { console.error(`\x1b[31m✗ ${m}\x1b[0m`) }
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
// @einsia/agent-git). Under Rosetta node reports x64, so probe the real hardware and install the
|
|
30
|
-
// arm64 package instead.
|
|
31
|
-
function packageKey() {
|
|
32
|
-
let a = arch()
|
|
33
|
-
if (platform() === 'darwin' && a === 'x64') {
|
|
34
|
-
const r = spawnSync('sysctl', ['-n', 'sysctl.proc_translated'], { encoding: 'utf8' })
|
|
35
|
-
if (!r.error && r.status === 0 && (r.stdout || '').trim() === '1') a = 'arm64'
|
|
36
|
-
}
|
|
37
|
-
const map = {
|
|
38
|
-
'linux/x64': 'linux-x64',
|
|
39
|
-
'linux/arm64': 'linux-arm64',
|
|
40
|
-
'darwin/x64': 'darwin-x64',
|
|
41
|
-
'darwin/arm64': 'darwin-arm64',
|
|
42
|
-
}
|
|
43
|
-
return map[`${platform()}/${a}`] || null
|
|
44
|
-
}
|
|
28
|
+
const { packageKey, binaryName } = require('@einsia/agent-git/npm/lib/platform.js')
|
|
45
29
|
|
|
46
30
|
function main() {
|
|
31
|
+
const args = process.argv.slice(2)
|
|
32
|
+
const attributionIndex = args.indexOf('--acquisition-id')
|
|
33
|
+
const acquisitionId = attributionIndex >= 0 ? args[attributionIndex + 1] : undefined
|
|
34
|
+
if (attributionIndex >= 0 && !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(acquisitionId ?? '')) {
|
|
35
|
+
fail('--acquisition-id requires a random UUID.')
|
|
36
|
+
process.exit(1)
|
|
37
|
+
}
|
|
38
|
+
const campaignIndex = args.indexOf('--campaign-url')
|
|
39
|
+
const campaignUrl = campaignIndex >= 0 ? args[campaignIndex + 1] : undefined
|
|
40
|
+
if (campaignIndex >= 0) {
|
|
41
|
+
try {
|
|
42
|
+
if (!campaignUrl || campaignUrl.length > 8192 || !['http:', 'https:'].includes(new URL(campaignUrl).protocol)) throw new Error()
|
|
43
|
+
} catch {
|
|
44
|
+
fail('--campaign-url requires an HTTP or HTTPS URL of at most 8192 characters.')
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
47
48
|
const t = packageKey()
|
|
48
49
|
if (!t) {
|
|
49
50
|
fail(`no prebuilt binary for ${platform()}/${arch()}.`)
|
|
@@ -54,7 +55,7 @@ function main() {
|
|
|
54
55
|
|
|
55
56
|
let bin
|
|
56
57
|
try {
|
|
57
|
-
bin = require.resolve(`@einsia/agent-git-${t}/bin
|
|
58
|
+
bin = require.resolve(`@einsia/agent-git-${t}/bin/${binaryName()}`)
|
|
58
59
|
} catch {
|
|
59
60
|
fail(`platform package @einsia/agent-git-${t} is missing (npm skipped it as an optional dep?).`)
|
|
60
61
|
say('If you are on an unsupported platform, build from source:')
|
|
@@ -66,25 +67,40 @@ function main() {
|
|
|
66
67
|
|
|
67
68
|
const targetDir = join(homedir(), '.local', 'bin')
|
|
68
69
|
mkdirSync(targetDir, { recursive: true })
|
|
69
|
-
const target = join(targetDir,
|
|
70
|
+
const target = join(targetDir, binaryName())
|
|
70
71
|
copyFileSync(bin, target)
|
|
71
72
|
chmodSync(target, 0o755)
|
|
72
73
|
|
|
73
|
-
const check = spawnSync(target, ['--version'], { encoding: 'utf8' })
|
|
74
|
+
const check = spawnSync(target, ['--version'], { encoding: 'utf8', env: { ...process.env, AGIT_TELEMETRY_DEFER: '1' } })
|
|
74
75
|
if (check.error || check.status !== 0) {
|
|
75
76
|
fail(`the binary did not run: ${(check.stderr || check.error?.message || `exit ${check.status}`).trim()}`)
|
|
76
77
|
process.exit(1)
|
|
77
78
|
}
|
|
78
79
|
ok(`installed ${check.stdout.trim()} → ${target}`)
|
|
79
80
|
|
|
80
|
-
if (!process.env.PATH?.split(
|
|
81
|
-
dim(`note: ${targetDir} is not on your PATH — add it (
|
|
81
|
+
if (!process.env.PATH?.split(delimiter).includes(targetDir)) {
|
|
82
|
+
dim(`note: ${targetDir} is not on your PATH — add it to your ${platform() === 'win32' ? 'user environment variables' : 'shell profile'}`)
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
// "installed by default at download time": hooks + skill + MCP + AGENTS.md in one pass. A
|
|
85
86
|
// failure does not block the install itself — the binary is already there, and setup can be
|
|
86
87
|
// re-run by hand later.
|
|
87
|
-
const
|
|
88
|
+
const yes = ['1', 'true'].includes(process.env.npm_config_yes?.toLowerCase()) || process.argv.slice(2).some(a => a === '--yes' || a === '-y')
|
|
89
|
+
spawnSync(target, ['--internal-install-completed'], {
|
|
90
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
91
|
+
env: { ...process.env, AGIT_INSTALL_CHANNEL: 'create_agit', AGIT_INSTALLER_YES: yes ? '1' : '0',
|
|
92
|
+
...(acquisitionId ? { AGIT_ACQUISITION_ID: acquisitionId } : {}),
|
|
93
|
+
...(campaignUrl ? { AGIT_CAMPAIGN_URL: campaignUrl } : {}) },
|
|
94
|
+
})
|
|
95
|
+
const skipSetup = process.env.AGIT_SKIP_SETUP && !['0', 'false'].includes(process.env.AGIT_SKIP_SETUP.toLowerCase())
|
|
96
|
+
if (skipSetup) {
|
|
97
|
+
dim('Setup skipped by AGIT_SKIP_SETUP. Run `agit setup` when ready.')
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
const setup = spawnSync(target, yes ? ['setup', '--yes'] : ['setup'], {
|
|
101
|
+
stdio: 'inherit',
|
|
102
|
+
env: { ...process.env, AGIT_INSTALL_CHANNEL: 'create_agit', AGIT_INSTALLER_YES: yes ? '1' : '0' },
|
|
103
|
+
})
|
|
88
104
|
if (setup.status === 0) {
|
|
89
105
|
ok('integrations installed (skills · hooks · MCP · AGENTS.md)')
|
|
90
106
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-agit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "One-line installer for agit (npx create-agit) — thin wrapper around @einsia/agent-git that lands the CLI at ~/.local/bin and wires skills/hooks/MCP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"create-agit": "./bin.mjs"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@einsia/agent-git": "0.
|
|
11
|
+
"@einsia/agent-git": "0.2.0"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20"
|