@ghostystudio/cli 0.3.0 → 0.5.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/dist/index.js +20 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -275,7 +275,7 @@ async function request(path, opts = {}, retried = false) {
|
|
|
275
275
|
method: opts.method ?? (opts.body !== void 0 || opts.raw !== void 0 ? "POST" : "GET"),
|
|
276
276
|
headers: {
|
|
277
277
|
authorization: `Bearer ${token}`,
|
|
278
|
-
"user-agent": `ghosty-cli/${"0.
|
|
278
|
+
"user-agent": `ghosty-cli/${"0.5.0"}`,
|
|
279
279
|
...opts.body !== void 0 ? { "content-type": "application/json" } : {},
|
|
280
280
|
...opts.headers
|
|
281
281
|
},
|
|
@@ -300,8 +300,8 @@ async function toError(res) {
|
|
|
300
300
|
if (res.status === 401) return new CliError("Your session is not valid anymore.", EXIT.AUTH, "Run: ghosty login");
|
|
301
301
|
if (res.status === 403) return new CliError(`Not allowed: ${detail}`, EXIT.API, "Run: ghosty login (to refresh your permissions)");
|
|
302
302
|
if (res.status === 404) return new CliError("Not found.", EXIT.API, "Check the agent id (ghosty agents ls) or that your token belongs to that agent.");
|
|
303
|
-
if (body.error === "agente_sin_maquina") {
|
|
304
|
-
return new CliError("This agent'
|
|
303
|
+
if (body.error === "restart_no_aplica" || body.error === "agente_sin_maquina") {
|
|
304
|
+
return new CliError("This agent doesn't need a restart: new files, skills and MCP load on its next turn.", EXIT.API);
|
|
305
305
|
}
|
|
306
306
|
return new CliError(`${res.status} ${detail}`, EXIT.API);
|
|
307
307
|
}
|
|
@@ -358,15 +358,20 @@ async function agentsSet(id, v) {
|
|
|
358
358
|
id = need(id, "agent id", "ghosty agents set <agent-id> --prompt-file PROMPT.md");
|
|
359
359
|
const body = {};
|
|
360
360
|
if (v.name) body.name = v.name;
|
|
361
|
+
if (v.engine) body.engine = v.engine;
|
|
361
362
|
if (v.model) body.model = v.model;
|
|
362
363
|
if (v.prompt) body.prompt = v.prompt;
|
|
363
364
|
if (v["prompt-file"]) body.prompt = await readFile2(v["prompt-file"], "utf8");
|
|
364
365
|
const env = parseEnv(v.env);
|
|
365
366
|
if (env) body.env = env;
|
|
366
|
-
if (!Object.keys(body).length) throw usage("Nothing to change.", "Use --name, --model, --prompt, --prompt-file or --env.");
|
|
367
|
+
if (!Object.keys(body).length) throw usage("Nothing to change.", "Use --name, --engine, --model, --prompt, --prompt-file or --env.");
|
|
367
368
|
const r = await api(agentPath(id), { method: "PATCH", body });
|
|
368
369
|
out(r, () => `${lavender("\u2713")} Updated ${Object.keys(body).join(", ")}.`);
|
|
369
370
|
}
|
|
371
|
+
async function agentsRm(id) {
|
|
372
|
+
id = need(id, "agent id", "ghosty agents rm <agent-id>");
|
|
373
|
+
out(await api(agentPath(id), { method: "DELETE" }), () => `${lavender("\u2713")} Deleted ${id}.`);
|
|
374
|
+
}
|
|
370
375
|
async function agentsRestart(id) {
|
|
371
376
|
id = need(id, "agent id", "ghosty agents restart <agent-id>");
|
|
372
377
|
out(await api(agentPath(id, "/restart"), { method: "POST", body: {} }), () => `${lavender("\u2713")} Restarting \u2014 the next turn uses the new config.`);
|
|
@@ -408,7 +413,7 @@ ${table(r.files ?? [], cols)}`);
|
|
|
408
413
|
need(path, "path", ex);
|
|
409
414
|
const data = v.file ? await readFile2(v.file) : await readStdin();
|
|
410
415
|
const r = await api(agentPath(id, `/files/${p}`), { method: "PUT", raw: new Uint8Array(data), headers: { "content-type": "application/octet-stream" } });
|
|
411
|
-
out(r ?? { path: p, bytes: data.length }, () => `${lavender("\u2713")} Wrote ${p} (${data.length} bytes)
|
|
416
|
+
out(r ?? { path: p, bytes: data.length }, () => `${lavender("\u2713")} Wrote ${p} (${data.length} bytes).`);
|
|
412
417
|
return;
|
|
413
418
|
}
|
|
414
419
|
case "rm": {
|
|
@@ -436,7 +441,8 @@ async function skillsCmd(sub, id, slug, v) {
|
|
|
436
441
|
case "add": {
|
|
437
442
|
slug = need(slug, "skill slug", ex);
|
|
438
443
|
const body = v.file ? { markdown: await readFile2(v.file, "utf8") } : { fromCatalog: true };
|
|
439
|
-
|
|
444
|
+
const r = await api(agentPath(id, `/skills/${enc(slug)}`), { method: "PUT", body });
|
|
445
|
+
out(r, () => `${lavender("\u2713")} Skill ${slug} installed.${r?.nota ? dim(` (${r.nota})`) : ""}`);
|
|
440
446
|
return;
|
|
441
447
|
}
|
|
442
448
|
case "rm":
|
|
@@ -455,7 +461,8 @@ async function mcpCmd(sub, id, v) {
|
|
|
455
461
|
const file = need(v.file, "--file", ex);
|
|
456
462
|
const parsed = JSON.parse(await readFile2(file, "utf8"));
|
|
457
463
|
const body = { servers: Array.isArray(parsed) ? parsed : parsed.servers ?? [] };
|
|
458
|
-
|
|
464
|
+
const r = await api(agentPath(id, "/mcp"), { method: "PUT", body });
|
|
465
|
+
return out(r, () => `${lavender("\u2713")} MCP servers replaced \u2014 ${r?.reiniciado ? "the agent restarted with them." : "they load on the next turn."}`);
|
|
459
466
|
}
|
|
460
467
|
throw usage(`Unknown mcp subcommand: ${sub ?? "(none)"}.`, ex);
|
|
461
468
|
}
|
|
@@ -726,8 +733,9 @@ ${bold("Agents")}
|
|
|
726
733
|
agents ls List your agents
|
|
727
734
|
agents create Create an agent --name [--engine] [--model] [--prompt | --prompt-file FILE] [--env K=V,\u2026]
|
|
728
735
|
agents get <id> Show an agent's config [--fields name,model,prompt]
|
|
729
|
-
agents set <id> Change identity
|
|
730
|
-
agents
|
|
736
|
+
agents set <id> Change identity or engine [--name] [--engine] [--model] [--prompt | --prompt-file FILE] [--env K=V,\u2026]
|
|
737
|
+
agents rm <id> Delete an agent (owner only)
|
|
738
|
+
agents restart <id> Restart an ACP agent (needsRestart) so it loads new skills
|
|
731
739
|
|
|
732
740
|
${bold("Configure an agent")}
|
|
733
741
|
files ls|get|put|rm <id> [path] Files in the agent's machine [--file LOCAL] [--out LOCAL]
|
|
@@ -793,7 +801,7 @@ async function main() {
|
|
|
793
801
|
});
|
|
794
802
|
globals.json = Boolean(v.json);
|
|
795
803
|
globals.token = v.token;
|
|
796
|
-
if (v.version) return out({ version: "0.
|
|
804
|
+
if (v.version) return out({ version: "0.5.0" }, () => "0.5.0");
|
|
797
805
|
const [cmd, sub, a1, a2] = pos;
|
|
798
806
|
if (!cmd || v.help || cmd === "help") return showHelp();
|
|
799
807
|
switch (cmd) {
|
|
@@ -820,8 +828,9 @@ async function main() {
|
|
|
820
828
|
if (sub === "create" || sub === "new") return agentsCreate(v);
|
|
821
829
|
if (sub === "get") return agentsGet(a1, v.fields);
|
|
822
830
|
if (sub === "set") return agentsSet(a1, v);
|
|
831
|
+
if (sub === "rm" || sub === "delete") return agentsRm(a1);
|
|
823
832
|
if (sub === "restart") return agentsRestart(a1);
|
|
824
|
-
throw usage(`Unknown agents subcommand: ${sub}.`, "Try: ghosty agents ls | create | get | set | restart");
|
|
833
|
+
throw usage(`Unknown agents subcommand: ${sub}.`, "Try: ghosty agents ls | create | get | set | rm | restart");
|
|
825
834
|
case "files":
|
|
826
835
|
return filesCmd(sub, a1, a2, v);
|
|
827
836
|
case "skills":
|
package/package.json
CHANGED