0101-agents 0.1.0 → 0.1.2
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/cli.js +65 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// 0101-agents list
|
|
11
11
|
// 0101-agents help
|
|
12
12
|
|
|
13
|
-
import { execSync } from 'node:child_process'
|
|
13
|
+
import { execSync, spawn } from 'node:child_process'
|
|
14
14
|
import {
|
|
15
15
|
existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync,
|
|
16
16
|
rmSync, statSync, createWriteStream,
|
|
@@ -135,9 +135,11 @@ function unzipInto(zipPath, destDir, { skipPrefix } = {}) {
|
|
|
135
135
|
// Use the system unzip binary. Available everywhere except bare Windows.
|
|
136
136
|
mkdirSync(destDir, { recursive: true })
|
|
137
137
|
if (skipPrefix) {
|
|
138
|
-
// unzip
|
|
138
|
+
// unzip's -x excludes paths matching glob patterns. `<prefix>/*` catches
|
|
139
|
+
// every file under the directory; the bare directory entry (e.g. `data/`)
|
|
140
|
+
// is harmless to re-extract because it just re-creates the dir shell.
|
|
139
141
|
execSync(
|
|
140
|
-
`unzip -q -o "${zipPath}" -d "${destDir}" -x "${skipPrefix}/*"
|
|
142
|
+
`unzip -q -o "${zipPath}" -d "${destDir}" -x "${skipPrefix}/*"`,
|
|
141
143
|
{ stdio: 'inherit' },
|
|
142
144
|
)
|
|
143
145
|
} else {
|
|
@@ -169,10 +171,11 @@ async function prompt(question) {
|
|
|
169
171
|
async function cmdLogin(args) {
|
|
170
172
|
let key = args[0]
|
|
171
173
|
if (!key) {
|
|
174
|
+
console.log(dim('Get your license key at https://0101.fyi/account'))
|
|
172
175
|
key = await prompt('Paste your license key: ')
|
|
173
176
|
}
|
|
174
177
|
key = key.trim()
|
|
175
|
-
if (!key) die('No key provided.')
|
|
178
|
+
if (!key) die('No key provided. Get one at https://0101.fyi/account')
|
|
176
179
|
writeConfig({ ...readConfig(), license_key: key })
|
|
177
180
|
ok(`Saved license to ${CONFIG_PATH}`)
|
|
178
181
|
}
|
|
@@ -222,7 +225,8 @@ async function cmdInstall(args) {
|
|
|
222
225
|
|
|
223
226
|
console.log('')
|
|
224
227
|
ok(`Installed ${bold(agent)} ${manifest.latest} → ${installDir}`)
|
|
225
|
-
info(`Start:
|
|
228
|
+
info(`Start: 0101-agents start ${agent}`)
|
|
229
|
+
info(` or: cd ${installDir} && claude`)
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
async function cmdUpdate(args) {
|
|
@@ -245,6 +249,7 @@ async function cmdUpdate(args) {
|
|
|
245
249
|
return
|
|
246
250
|
}
|
|
247
251
|
|
|
252
|
+
console.log(dim('Your data/ folder is preserved (memory, projects, custom files).'))
|
|
248
253
|
const ans = await prompt(`Update ${agent} ${current ?? '?'} → ${manifest.latest}? [Y/n] `)
|
|
249
254
|
if (ans && !/^y(es)?$/i.test(ans)) {
|
|
250
255
|
info('Cancelled.')
|
|
@@ -281,17 +286,64 @@ function cmdList() {
|
|
|
281
286
|
}
|
|
282
287
|
}
|
|
283
288
|
|
|
289
|
+
async function cmdStart(args) {
|
|
290
|
+
const agent = args[0]
|
|
291
|
+
if (!agent) die('Usage: 0101-agents start <agent> [-- <claude-args>]')
|
|
292
|
+
const dir = agentInstallDir(agent)
|
|
293
|
+
if (!existsSync(dir)) {
|
|
294
|
+
die(`${agent} is not installed. Try: 0101-agents install ${agent}`)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Best-effort update check. Silently skipped if offline or the server
|
|
298
|
+
// misbehaves — never blocks the launch.
|
|
299
|
+
try {
|
|
300
|
+
const manifest = await fetchManifest(agent)
|
|
301
|
+
const current = installedVersion(agent)
|
|
302
|
+
if (current && manifest.latest !== current) {
|
|
303
|
+
console.log(
|
|
304
|
+
dim(`⚠ ${agent} ${manifest.latest} available (run: 0101-agents update ${agent})`),
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
} catch {
|
|
308
|
+
// ignore
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Everything after the agent name passes through to `claude`. Supports both:
|
|
312
|
+
// 0101-agents start marketer --resume
|
|
313
|
+
// 0101-agents start marketer -- --resume (explicit separator)
|
|
314
|
+
// The `--` is optional; if present, we drop it.
|
|
315
|
+
let claudeArgs = args.slice(1)
|
|
316
|
+
if (claudeArgs[0] === '--') claudeArgs = claudeArgs.slice(1)
|
|
317
|
+
|
|
318
|
+
// Hand the terminal over to `claude` with cwd set to the agent dir. When
|
|
319
|
+
// claude exits, the user returns to their original shell location.
|
|
320
|
+
const child = spawn('claude', claudeArgs, { cwd: dir, stdio: 'inherit' })
|
|
321
|
+
child.on('error', (e) => {
|
|
322
|
+
if (e.code === 'ENOENT') {
|
|
323
|
+
die('`claude` not found in PATH. Install Claude Code first: https://claude.com/code')
|
|
324
|
+
}
|
|
325
|
+
die(`Failed to start claude: ${e.message}`)
|
|
326
|
+
})
|
|
327
|
+
child.on('exit', (code) => process.exit(code ?? 0))
|
|
328
|
+
}
|
|
329
|
+
|
|
284
330
|
function cmdHelp() {
|
|
285
331
|
console.log(`0101-agents — install and update Claude Code agents.
|
|
286
332
|
|
|
287
333
|
Commands:
|
|
288
|
-
${bold('login')} [<key>]
|
|
289
|
-
${bold('logout')}
|
|
290
|
-
${bold('whoami')}
|
|
291
|
-
${bold('install')} <agent> [--force]
|
|
292
|
-
${bold('update')} <agent>
|
|
293
|
-
${bold('
|
|
294
|
-
${bold('
|
|
334
|
+
${bold('login')} [<key>] Save your license key
|
|
335
|
+
${bold('logout')} Forget your license key
|
|
336
|
+
${bold('whoami')} Show current license
|
|
337
|
+
${bold('install')} <agent> [--force] Install an agent
|
|
338
|
+
${bold('update')} <agent> Update an installed agent (preserves data/)
|
|
339
|
+
${bold('start')} <agent> [-- args] Open the agent (runs claude inside its dir)
|
|
340
|
+
${bold('list')} List installed agents
|
|
341
|
+
${bold('help')} Show this message
|
|
342
|
+
|
|
343
|
+
Examples:
|
|
344
|
+
0101-agents start marketer
|
|
345
|
+
0101-agents start marketer --resume
|
|
346
|
+
0101-agents start marketer -- -p "audit https://example.com"
|
|
295
347
|
|
|
296
348
|
Install dir: ${INSTALL_ROOT}
|
|
297
349
|
Config: ${CONFIG_PATH}`)
|
|
@@ -308,6 +360,7 @@ try {
|
|
|
308
360
|
case 'whoami': await cmdWhoami(); break
|
|
309
361
|
case 'install': await cmdInstall(rest); break
|
|
310
362
|
case 'update': await cmdUpdate(rest); break
|
|
363
|
+
case 'start': await cmdStart(rest); break
|
|
311
364
|
case 'list': cmdList(); break
|
|
312
365
|
case 'help':
|
|
313
366
|
case '-h':
|