create-agit 0.0.1 → 0.1.1
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 +102 -4
- package/package.json +19 -4
package/bin.mjs
CHANGED
|
@@ -1,5 +1,103 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The `npx create-agit` half: a durable single-file install.
|
|
4
|
+
*
|
|
5
|
+
* The npx cache is wiped, and what the user gets has to be an `agit` that keeps working, so
|
|
6
|
+
* this copies the platform binary out of the dependency tree (an optional dep of
|
|
7
|
+
* @einsia/agent-git, already picked by npm for this os/cpu) to ~/.local/bin/agit, then runs
|
|
8
|
+
* `agit setup` once to install skills / hooks / MCP. Zero network — the real download already
|
|
9
|
+
* happened when npx fetched the package.
|
|
10
|
+
*
|
|
11
|
+
* An unsupported platform (no matching platform package) leaves nothing half-installed: print
|
|
12
|
+
* the build-from-source instructions and exit.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { createRequire } from 'node:module'
|
|
16
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync } from 'node:fs'
|
|
17
|
+
import { homedir, platform, arch, tmpdir } from 'node:os'
|
|
18
|
+
import { join } from 'node:path'
|
|
19
|
+
import { spawnSync } from 'node:child_process'
|
|
20
|
+
|
|
21
|
+
const require = createRequire(import.meta.url)
|
|
22
|
+
|
|
23
|
+
function say(m) { console.log(m) }
|
|
24
|
+
function dim(m) { console.log(`\x1b[2m${m}\x1b[0m`) }
|
|
25
|
+
function ok(m) { console.log(`\x1b[32m✓\x1b[0m ${m}`) }
|
|
26
|
+
function fail(m) { console.error(`\x1b[31m✗ ${m}\x1b[0m`) }
|
|
27
|
+
|
|
28
|
+
// node os/arch names → platform package suffix (one for one with the optionalDependencies of
|
|
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
|
+
}
|
|
45
|
+
|
|
46
|
+
function main() {
|
|
47
|
+
const t = packageKey()
|
|
48
|
+
if (!t) {
|
|
49
|
+
fail(`no prebuilt binary for ${platform()}/${arch()}.`)
|
|
50
|
+
say('Build from source instead:')
|
|
51
|
+
say(' git clone https://github.com/Einsia/agent-git && cd agent-git && ./setup.sh')
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let bin
|
|
56
|
+
try {
|
|
57
|
+
bin = require.resolve(`@einsia/agent-git-${t}/bin/agit`)
|
|
58
|
+
} catch {
|
|
59
|
+
fail(`platform package @einsia/agent-git-${t} is missing (npm skipped it as an optional dep?).`)
|
|
60
|
+
say('If you are on an unsupported platform, build from source:')
|
|
61
|
+
say(' git clone https://github.com/Einsia/agent-git && cd agent-git && ./setup.sh')
|
|
62
|
+
process.exit(1)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
say('agent-git installer')
|
|
66
|
+
|
|
67
|
+
const targetDir = join(homedir(), '.local', 'bin')
|
|
68
|
+
mkdirSync(targetDir, { recursive: true })
|
|
69
|
+
const target = join(targetDir, 'agit')
|
|
70
|
+
copyFileSync(bin, target)
|
|
71
|
+
chmodSync(target, 0o755)
|
|
72
|
+
|
|
73
|
+
const check = spawnSync(target, ['--version'], { encoding: 'utf8' })
|
|
74
|
+
if (check.error || check.status !== 0) {
|
|
75
|
+
fail(`the binary did not run: ${(check.stderr || check.error?.message || `exit ${check.status}`).trim()}`)
|
|
76
|
+
process.exit(1)
|
|
77
|
+
}
|
|
78
|
+
ok(`installed ${check.stdout.trim()} → ${target}`)
|
|
79
|
+
|
|
80
|
+
if (!process.env.PATH?.split(':').includes(targetDir)) {
|
|
81
|
+
dim(`note: ${targetDir} is not on your PATH — add it (e.g. in ~/.profile)`)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// "installed by default at download time": hooks + skill + MCP + AGENTS.md in one pass. A
|
|
85
|
+
// failure does not block the install itself — the binary is already there, and setup can be
|
|
86
|
+
// re-run by hand later.
|
|
87
|
+
const setup = spawnSync(target, ['setup'], { stdio: 'inherit' })
|
|
88
|
+
if (setup.status === 0) {
|
|
89
|
+
ok('integrations installed (skills · hooks · MCP · AGENTS.md)')
|
|
90
|
+
} else {
|
|
91
|
+
dim('`agit setup` did not fully succeed — re-run it later; the CLI itself is installed.')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
say('')
|
|
95
|
+
say('Next:')
|
|
96
|
+
say(' agit login # sign in to the hub')
|
|
97
|
+
say(' agit import <session-id> -n <name> -b <branch> # sessions live on their own line')
|
|
98
|
+
say(' agit push # publish')
|
|
99
|
+
say('')
|
|
100
|
+
dim('docs: https://agent-git.com/docs')
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
main()
|
package/package.json
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-agit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|
|
7
7
|
"bin": {
|
|
8
8
|
"create-agit": "./bin.mjs"
|
|
9
9
|
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@einsia/agent-git": "0.1.1"
|
|
12
|
+
},
|
|
10
13
|
"engines": {
|
|
11
14
|
"node": ">=20"
|
|
12
15
|
},
|
|
13
16
|
"homepage": "https://agent-git.com",
|
|
14
17
|
"repository": {
|
|
15
18
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/Einsia/agent-git"
|
|
17
|
-
|
|
19
|
+
"url": "https://github.com/Einsia/agent-git",
|
|
20
|
+
"directory": "npm/create-agit"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"agent",
|
|
24
|
+
"session",
|
|
25
|
+
"version-control",
|
|
26
|
+
"claude-code",
|
|
27
|
+
"codex",
|
|
28
|
+
"opencode",
|
|
29
|
+
"cursor",
|
|
30
|
+
"mcp",
|
|
31
|
+
"cli"
|
|
32
|
+
]
|
|
18
33
|
}
|