@ghostystudio/cli 0.3.0 → 0.4.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 +13 -10
- 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.4.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,12 +358,13 @@ 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
|
}
|
|
@@ -408,7 +409,7 @@ ${table(r.files ?? [], cols)}`);
|
|
|
408
409
|
need(path, "path", ex);
|
|
409
410
|
const data = v.file ? await readFile2(v.file) : await readStdin();
|
|
410
411
|
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)
|
|
412
|
+
out(r ?? { path: p, bytes: data.length }, () => `${lavender("\u2713")} Wrote ${p} (${data.length} bytes).`);
|
|
412
413
|
return;
|
|
413
414
|
}
|
|
414
415
|
case "rm": {
|
|
@@ -436,7 +437,8 @@ async function skillsCmd(sub, id, slug, v) {
|
|
|
436
437
|
case "add": {
|
|
437
438
|
slug = need(slug, "skill slug", ex);
|
|
438
439
|
const body = v.file ? { markdown: await readFile2(v.file, "utf8") } : { fromCatalog: true };
|
|
439
|
-
|
|
440
|
+
const r = await api(agentPath(id, `/skills/${enc(slug)}`), { method: "PUT", body });
|
|
441
|
+
out(r, () => `${lavender("\u2713")} Skill ${slug} installed.${r?.nota ? dim(` (${r.nota})`) : ""}`);
|
|
440
442
|
return;
|
|
441
443
|
}
|
|
442
444
|
case "rm":
|
|
@@ -455,7 +457,8 @@ async function mcpCmd(sub, id, v) {
|
|
|
455
457
|
const file = need(v.file, "--file", ex);
|
|
456
458
|
const parsed = JSON.parse(await readFile2(file, "utf8"));
|
|
457
459
|
const body = { servers: Array.isArray(parsed) ? parsed : parsed.servers ?? [] };
|
|
458
|
-
|
|
460
|
+
const r = await api(agentPath(id, "/mcp"), { method: "PUT", body });
|
|
461
|
+
return out(r, () => `${lavender("\u2713")} MCP servers replaced \u2014 ${r?.reiniciado ? "the agent restarted with them." : "they load on the next turn."}`);
|
|
459
462
|
}
|
|
460
463
|
throw usage(`Unknown mcp subcommand: ${sub ?? "(none)"}.`, ex);
|
|
461
464
|
}
|
|
@@ -726,8 +729,8 @@ ${bold("Agents")}
|
|
|
726
729
|
agents ls List your agents
|
|
727
730
|
agents create Create an agent --name [--engine] [--model] [--prompt | --prompt-file FILE] [--env K=V,\u2026]
|
|
728
731
|
agents get <id> Show an agent's config [--fields name,model,prompt]
|
|
729
|
-
agents set <id> Change identity
|
|
730
|
-
agents restart <id> Restart
|
|
732
|
+
agents set <id> Change identity or engine [--name] [--engine] [--model] [--prompt | --prompt-file FILE] [--env K=V,\u2026]
|
|
733
|
+
agents restart <id> Restart an ACP agent (needsRestart) so it loads new skills
|
|
731
734
|
|
|
732
735
|
${bold("Configure an agent")}
|
|
733
736
|
files ls|get|put|rm <id> [path] Files in the agent's machine [--file LOCAL] [--out LOCAL]
|
|
@@ -793,7 +796,7 @@ async function main() {
|
|
|
793
796
|
});
|
|
794
797
|
globals.json = Boolean(v.json);
|
|
795
798
|
globals.token = v.token;
|
|
796
|
-
if (v.version) return out({ version: "0.
|
|
799
|
+
if (v.version) return out({ version: "0.4.0" }, () => "0.4.0");
|
|
797
800
|
const [cmd, sub, a1, a2] = pos;
|
|
798
801
|
if (!cmd || v.help || cmd === "help") return showHelp();
|
|
799
802
|
switch (cmd) {
|
package/package.json
CHANGED