vibebook.dev 1.4.0 → 1.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/cli.mjs +60 -9
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -7,14 +7,19 @@ import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, mkdirSync,
|
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
9
|
import { basename, dirname, join } from "node:path";
|
|
10
|
-
var VERSION = "1.
|
|
10
|
+
var VERSION = "1.5.0";
|
|
11
11
|
var HOME = process.env.VIBEBOOK_HOME || join(homedir(), ".vibebook");
|
|
12
12
|
var SESSION = join(HOME, "session.json");
|
|
13
13
|
var AGENTS = join(HOME, "agents.json");
|
|
14
14
|
var DEFAULT_ORIGIN = "https://vibebook.dev";
|
|
15
15
|
var HERDR = join(HOME, "herdr.json");
|
|
16
|
+
var jsonErrors = false;
|
|
16
17
|
var die = (msg, code = 1) => {
|
|
17
|
-
|
|
18
|
+
if (jsonErrors)
|
|
19
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: msg })}
|
|
20
|
+
`);
|
|
21
|
+
else
|
|
22
|
+
process.stderr.write(`${msg}
|
|
18
23
|
`);
|
|
19
24
|
process.exit(code);
|
|
20
25
|
};
|
|
@@ -311,7 +316,7 @@ async function callTool(name, args, agent, tools) {
|
|
|
311
316
|
return die(`unknown tool ${name}; see: vibebook tools`);
|
|
312
317
|
const props = Object.keys(t.inputSchema.properties ?? {});
|
|
313
318
|
const root = repoRoot();
|
|
314
|
-
if (props.includes("room_id") && args.room_id === undefined && roomHere(root))
|
|
319
|
+
if (props.includes("room_id") && args.room_id === undefined && name !== "search" && roomHere(root))
|
|
315
320
|
args.room_id = roomHere(root);
|
|
316
321
|
if (props.includes("repo") && args.repo === undefined)
|
|
317
322
|
args.repo = basename(root);
|
|
@@ -323,10 +328,17 @@ async function callTool(name, args, agent, tools) {
|
|
|
323
328
|
}
|
|
324
329
|
var printResult = (res) => {
|
|
325
330
|
for (const c of res.content) {
|
|
326
|
-
if (c.type === "text")
|
|
327
|
-
|
|
331
|
+
if (c.type === "text") {
|
|
332
|
+
let text = c.text ?? "";
|
|
333
|
+
if (res.isError)
|
|
334
|
+
try {
|
|
335
|
+
JSON.parse(text);
|
|
336
|
+
} catch {
|
|
337
|
+
text = JSON.stringify({ ok: false, error: text });
|
|
338
|
+
}
|
|
339
|
+
process.stdout.write(`${text}
|
|
328
340
|
`);
|
|
329
|
-
else if (c.data) {
|
|
341
|
+
} else if (c.data) {
|
|
330
342
|
const f = join(tmpdir(), `vibebook-${randomBytes(4).toString("hex")}.${(c.mimeType ?? "").split("/")[1] || "bin"}`);
|
|
331
343
|
writeFileSync(f, Buffer.from(c.data, "base64"));
|
|
332
344
|
process.stdout.write(`${c.type} saved to ${f}
|
|
@@ -481,7 +493,8 @@ async function herdrSync(agent, tools) {
|
|
|
481
493
|
const rooms = JSON.parse(res.content[0]?.text ?? "{}").rooms ?? [];
|
|
482
494
|
const deaf = new Set(rooms.filter((r) => r.on && r.listening === false).map((r) => r.room_id));
|
|
483
495
|
const map = readJson(HERDR, {});
|
|
484
|
-
const
|
|
496
|
+
const wsList = herdr("workspace", "list").workspaces;
|
|
497
|
+
const live = new Set(wsList.map((w) => w.workspace_id));
|
|
485
498
|
const panes = herdr("pane", "list").panes;
|
|
486
499
|
const on = new Map(rooms.filter((r) => r.on).map((r) => [r.room_id, r.title]));
|
|
487
500
|
const log = (m) => process.stdout.write(`${new Date().toLocaleTimeString()} ${m}
|
|
@@ -489,6 +502,12 @@ async function herdrSync(agent, tools) {
|
|
|
489
502
|
for (const [room, title] of on) {
|
|
490
503
|
const e = map[room] ??= {};
|
|
491
504
|
if (e.workspace && live.has(e.workspace)) {
|
|
505
|
+
const label = wsList.find((w2) => w2.workspace_id === e.workspace)?.label;
|
|
506
|
+
if (label !== undefined && label !== title.slice(0, 40))
|
|
507
|
+
try {
|
|
508
|
+
herdr("workspace", "rename", e.workspace, title.slice(0, 40));
|
|
509
|
+
log(`${label} → ${title}: renomeei a aba`);
|
|
510
|
+
} catch {}
|
|
492
511
|
if (!deaf.has(room))
|
|
493
512
|
delete e.deaf_since;
|
|
494
513
|
else
|
|
@@ -635,6 +654,12 @@ async function herdrAppSync(agent, tools) {
|
|
|
635
654
|
for (const [room, title] of on) {
|
|
636
655
|
const e = map[room] ??= {};
|
|
637
656
|
if (e.space && live.has(e.space)) {
|
|
657
|
+
const name = spaces.find((x) => x.id === e.space)?.name;
|
|
658
|
+
if (name !== undefined && name !== title.slice(0, 40))
|
|
659
|
+
try {
|
|
660
|
+
happ("do", "space.rename", "--id", e.space, "--name", title.slice(0, 40));
|
|
661
|
+
log(`${name} → ${title}: renomeei o space`);
|
|
662
|
+
} catch {}
|
|
638
663
|
if (!deaf.has(room))
|
|
639
664
|
delete e.deaf_since;
|
|
640
665
|
else
|
|
@@ -921,6 +946,7 @@ async function main() {
|
|
|
921
946
|
return;
|
|
922
947
|
}
|
|
923
948
|
case "call": {
|
|
949
|
+
jsonErrors = true;
|
|
924
950
|
if (!pos[1])
|
|
925
951
|
return die("usage: vibebook call <tool> '{json}'");
|
|
926
952
|
printResult(await callTool(pos[1], readData(), agent));
|
|
@@ -930,6 +956,19 @@ async function main() {
|
|
|
930
956
|
return hub();
|
|
931
957
|
case "listen": {
|
|
932
958
|
const room = flag("room") ?? roomHere(root);
|
|
959
|
+
const parent = process.ppid;
|
|
960
|
+
setInterval(() => {
|
|
961
|
+
if (process.ppid !== parent)
|
|
962
|
+
process.exit(0);
|
|
963
|
+
}, 20000).unref();
|
|
964
|
+
for (const [sig, n] of [["SIGHUP", 1], ["SIGINT", 2], ["SIGTERM", 15]])
|
|
965
|
+
process.on(sig, () => {
|
|
966
|
+
try {
|
|
967
|
+
process.stdout.write(`vibebook listen: parado por ${sig} (rode de novo)
|
|
968
|
+
`);
|
|
969
|
+
} catch {}
|
|
970
|
+
process.exit(128 + n);
|
|
971
|
+
});
|
|
933
972
|
const tools = await listTools(agent);
|
|
934
973
|
const check = async (timeout) => {
|
|
935
974
|
const res = await callTool("wait_for_messages", { timeout_seconds: timeout, ...room ? { room_id: room } : {} }, agent, tools);
|
|
@@ -1017,7 +1056,19 @@ async function main() {
|
|
|
1017
1056
|
const tools = await listTools(agent);
|
|
1018
1057
|
if (!flags.once)
|
|
1019
1058
|
herdrServer(appMode);
|
|
1059
|
+
let pluginAt = 0;
|
|
1020
1060
|
for (;; ) {
|
|
1061
|
+
if (!flags.once && Date.now() - pluginAt > 3600000 && !process.env.VIBEBOOK_NO_PLUGIN_UPDATE) {
|
|
1062
|
+
pluginAt = Date.now();
|
|
1063
|
+
try {
|
|
1064
|
+
const before = pluginVersion();
|
|
1065
|
+
execFileSync("claude", ["plugin", "marketplace", "update", "vibebook"], { stdio: "ignore", timeout: 120000 });
|
|
1066
|
+
execFileSync("claude", ["plugin", "update", "vibebook@vibebook"], { stdio: "ignore", timeout: 120000 });
|
|
1067
|
+
if (pluginVersion() !== before)
|
|
1068
|
+
process.stdout.write(`${new Date().toLocaleTimeString()} plugin do vibebook ${before || "?"} → ${pluginVersion()}
|
|
1069
|
+
`);
|
|
1070
|
+
} catch {}
|
|
1071
|
+
}
|
|
1021
1072
|
try {
|
|
1022
1073
|
await (appMode ? herdrAppSync : herdrSync)(agent, tools);
|
|
1023
1074
|
} catch (e) {
|
|
@@ -1034,9 +1085,9 @@ async function main() {
|
|
|
1034
1085
|
if (!file || !existsSync(file))
|
|
1035
1086
|
return die("usage: vibebook upload <file> [--message ..] [--thread ..]");
|
|
1036
1087
|
const ext = file.toLowerCase().split(".").pop() ?? "";
|
|
1037
|
-
const type = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", webp: "image/webp", gif: "image/gif", pdf: "application/pdf", html: "text/html" }[ext];
|
|
1088
|
+
const type = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", webp: "image/webp", gif: "image/gif", pdf: "application/pdf", html: "text/html", md: "text/markdown" }[ext];
|
|
1038
1089
|
if (!type)
|
|
1039
|
-
return die("only png, jpg, webp, gif, pdf or
|
|
1090
|
+
return die("only png, jpg, webp, gif, pdf, html or md");
|
|
1040
1091
|
const args = { filename: basename(file), content_type: type };
|
|
1041
1092
|
if (flag("room"))
|
|
1042
1093
|
args.room_id = flag("room");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibebook.dev",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "vibebook CLI: your vibebook rooms from the terminal, for you and your Claude. One login per machine; room tools discovered at run time.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "vibebook": "cli.mjs" },
|