@voyager-crew/cli 0.5.0 → 0.5.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/README.md CHANGED
@@ -51,6 +51,8 @@ voyager ask "Explain this stack trace" --attach crash.log
51
51
  voyager ask "Look over the repo" --attach ./src # folders go up as a zip, secrets left out
52
52
  voyager ask --model high "Quick sanity check" # pro (default), extra-high, high, medium, instant
53
53
  voyager ask --chat <link|id> "And the edge cases?" # follow up in a conversation
54
+ voyager ask --preset math "Prove this claim" # prepend the mathematical research opening
55
+ voyager ask --preset <file> "Review this argument" # prepend a UTF-8 text file, trimmed (up to 20,000 characters)
54
56
  voyager read <link|id> # save a conversation's latest reply
55
57
  ```
56
58
 
package/dist/cli.mjs CHANGED
@@ -3,13 +3,9 @@
3
3
  // plugins/ask/index.ts
4
4
  import { basename as basename3 } from "node:path";
5
5
 
6
- // src/plugins/api.ts
7
- function conversationConflictKey(conversationId) {
8
- return `conversation ${conversationId}`;
9
- }
10
- function definePlugin(plugin) {
11
- return plugin;
12
- }
6
+ // src/cli/presets.ts
7
+ import { readFile as readFile2 } from "node:fs/promises";
8
+ import { resolve } from "node:path";
13
9
 
14
10
  // node_modules/@voyager-crew/bridge-protocol/src/read.ts
15
11
  var ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
@@ -1165,6 +1161,43 @@ function toBridgeError(thrown) {
1165
1161
  return bridgeError("bad-request", `internal error: ${message}`);
1166
1162
  }
1167
1163
 
1164
+ // src/cli/presets.ts
1165
+ var BUILT_IN_PRESETS = {
1166
+ math: "Mathematical research session. This question comes from a long-running mathematics project. Treat it as research: expect a long session and prepare for hours of real work; depth and rigor come before speed. Every conclusion is either derived from the material given, verified, or marked explicitly as a conjecture together with what evidence would settle it. Work from the exact statement below rather than a paraphrase of it."
1167
+ };
1168
+ async function resolvePreset(value, cwd) {
1169
+ if (value === undefined)
1170
+ return "";
1171
+ if (typeof value !== "string") {
1172
+ throw failure("bad-request", "--preset needs a built-in name or a UTF-8 text file");
1173
+ }
1174
+ if (Object.hasOwn(BUILT_IN_PRESETS, value))
1175
+ return BUILT_IN_PRESETS[value];
1176
+ const label = JSON.stringify(value);
1177
+ let text;
1178
+ try {
1179
+ text = await readFile2(resolve(cwd, value), "utf8");
1180
+ } catch {
1181
+ throw failure("bad-request", `--preset ${label}: use a built-in name (math) or a readable UTF-8 text file`);
1182
+ }
1183
+ if (Array.from(text).length > 20000) {
1184
+ throw failure("bad-request", `--preset ${label}: file exceeds 20,000 characters`);
1185
+ }
1186
+ const trimmed = text.trim();
1187
+ if (trimmed === "") {
1188
+ throw failure("bad-request", `--preset ${label}: file is empty after trimming whitespace`);
1189
+ }
1190
+ return trimmed;
1191
+ }
1192
+
1193
+ // src/plugins/api.ts
1194
+ function conversationConflictKey(conversationId) {
1195
+ return `conversation ${conversationId}`;
1196
+ }
1197
+ function definePlugin(plugin) {
1198
+ return plugin;
1199
+ }
1200
+
1168
1201
  // src/plugins/sendGuard.ts
1169
1202
  var SENDING_CHECKPOINT = "sending";
1170
1203
  var BEFORE_CLICK = new Set([
@@ -1202,8 +1235,8 @@ async function sendOnce(ctx, params) {
1202
1235
 
1203
1236
  // src/util/attach/stage.ts
1204
1237
  import { createHash as createHash2 } from "node:crypto";
1205
- import { copyFile, constants as constants2, readFile as readFile4, realpath, stat } from "node:fs/promises";
1206
- import { basename, join as join3, resolve } from "node:path";
1238
+ import { copyFile, constants as constants2, readFile as readFile5, realpath, stat } from "node:fs/promises";
1239
+ import { basename, join as join3, resolve as resolve2 } from "node:path";
1207
1240
 
1208
1241
  // src/util/mime.ts
1209
1242
  var TYPES = {
@@ -1728,17 +1761,17 @@ var Zip = /* @__PURE__ */ function() {
1728
1761
 
1729
1762
  // src/util/attach/zipFolder.ts
1730
1763
  import { createHash } from "node:crypto";
1731
- import { readFile as readFile3 } from "node:fs/promises";
1764
+ import { readFile as readFile4 } from "node:fs/promises";
1732
1765
  import { deflateRawSync } from "node:zlib";
1733
1766
 
1734
1767
  // src/util/files.ts
1735
1768
  import { randomBytes } from "node:crypto";
1736
1769
  import { constants } from "node:fs";
1737
- import { chmod, open, readFile as readFile2, rename, unlink } from "node:fs/promises";
1770
+ import { chmod, open, readFile as readFile3, rename, unlink } from "node:fs/promises";
1738
1771
  import { dirname, join as join2 } from "node:path";
1739
1772
  async function readJsonFile(path) {
1740
1773
  try {
1741
- return JSON.parse(await readFile2(path, "utf8"));
1774
+ return JSON.parse(await readFile3(path, "utf8"));
1742
1775
  } catch (error) {
1743
1776
  if (isErrno(error, "ENOENT"))
1744
1777
  return;
@@ -1846,7 +1879,7 @@ async function zipFiles(files, root, outPath, maxBytes) {
1846
1879
  const tooLarge = () => failure("bad-request", `the zip of ${root} is over ${formatBytes(maxBytes)}; the largest folders are ${largestFolders(files).map((entry) => `${entry.path} (${formatBytes(entry.bytes)})`).join(", ")}`, { limit: maxBytes, largest: largestFolders(files) });
1847
1880
  const sorted = [...files].sort((a, b) => a.relative < b.relative ? -1 : 1);
1848
1881
  for (const file of sorted) {
1849
- const data = await readFile3(file.absolute);
1882
+ const data = await readFile4(file.absolute);
1850
1883
  const entry = new DeflatedEntry(`${root}/${checkEntryPath(file.relative)}`, data.length, crc32(data), deflateRawSync(data, { level: LEVEL }));
1851
1884
  zip.add(entry);
1852
1885
  entry.emit();
@@ -1869,7 +1902,7 @@ async function zipFiles(files, root, outPath, maxBytes) {
1869
1902
  // src/util/attach/stage.ts
1870
1903
  var EXAMPLES = 5;
1871
1904
  async function sha256File(path) {
1872
- return createHash2("sha256").update(await readFile4(path)).digest("hex");
1905
+ return createHash2("sha256").update(await readFile5(path)).digest("hex");
1873
1906
  }
1874
1907
  async function stageFolder(source, taken, options, maxBytes) {
1875
1908
  const folder = await realpath(source);
@@ -1939,7 +1972,7 @@ async function stageAttachments(inputs, options) {
1939
1972
  const taken = new Set;
1940
1973
  const staged = [];
1941
1974
  for (const input of inputs) {
1942
- const source = resolve(options.cwd, input);
1975
+ const source = resolve2(options.cwd, input);
1943
1976
  let stats;
1944
1977
  try {
1945
1978
  stats = await stat(source);
@@ -2582,6 +2615,7 @@ async function prepare(fg, argv) {
2582
2615
  const asked = argv.positionals.join(" ").trim();
2583
2616
  if (asked === "")
2584
2617
  throw failure("bad-request", 'usage: voyager ask "<prompt>"');
2618
+ const preset = await resolvePreset(argv.options.preset, fg.cwd);
2585
2619
  const model = parseAskModel(argv.options.model);
2586
2620
  const project = typeof argv.options.project === "string" ? argv.options.project.trim() : undefined;
2587
2621
  if (project !== undefined) {
@@ -2604,6 +2638,7 @@ async function prepare(fg, argv) {
2604
2638
  fg.note(`repo: ChatGPT is asked to write only to ${repo.branch}`);
2605
2639
  const timebox = parseTimebox(argv.options.timebox);
2606
2640
  const prompt = [
2641
+ preset,
2607
2642
  asked,
2608
2643
  drive.block,
2609
2644
  repo === undefined ? "" : repoPromptBlock(repo),
@@ -2771,6 +2806,10 @@ var askPlugin = definePlugin({
2771
2806
  summary: "Ask ChatGPT (a new conversation, or --chat / --continue) and save the reply",
2772
2807
  args: [{ name: "prompt", summary: "the message to send", variadic: true }],
2773
2808
  options: {
2809
+ preset: {
2810
+ type: "string",
2811
+ summary: "prepend a built-in preset (math) or a UTF-8 text file to the prompt"
2812
+ },
2774
2813
  "keep-tab": { type: "boolean", summary: "leave the bridge tab open afterwards" },
2775
2814
  chat: {
2776
2815
  type: "string",
@@ -3233,7 +3272,7 @@ class PluginRegistry {
3233
3272
  // package.json
3234
3273
  var package_default = {
3235
3274
  name: "@voyager-crew/cli",
3236
- version: "0.5.0",
3275
+ version: "0.5.1",
3237
3276
  description: "Ask ChatGPT from your terminal or your coding agent, through the Voyager browser extension",
3238
3277
  keywords: [
3239
3278
  "chatgpt",
@@ -3330,13 +3369,13 @@ async function extensionPluginCommand(argv) {
3330
3369
  return argv.length === 0 ? 2 : 0;
3331
3370
  }
3332
3371
  const npx = process.platform === "win32" ? "npx.cmd" : "npx";
3333
- return new Promise((resolve2) => {
3372
+ return new Promise((resolve3) => {
3334
3373
  const child = spawn(npx, scaffoldArgs(argv), { stdio: "inherit" });
3335
3374
  child.on("error", (error) => {
3336
3375
  note(`voyager plugin: could not run npx (${error.message}); install Node.js 18 or later`);
3337
- resolve2(2);
3376
+ resolve3(2);
3338
3377
  });
3339
- child.on("exit", (code) => resolve2(code ?? 2));
3378
+ child.on("exit", (code) => resolve3(code ?? 2));
3340
3379
  });
3341
3380
  }
3342
3381
 
@@ -3345,7 +3384,7 @@ import { spawn as spawn2 } from "node:child_process";
3345
3384
  import { closeSync, openSync } from "node:fs";
3346
3385
 
3347
3386
  // src/state/tokens.ts
3348
- import { chmod as chmod3, readFile as readFile5 } from "node:fs/promises";
3387
+ import { chmod as chmod3, readFile as readFile6 } from "node:fs/promises";
3349
3388
  async function ensureCliToken(paths) {
3350
3389
  const existing = await readCliToken(paths);
3351
3390
  if (existing !== undefined) {
@@ -3368,7 +3407,7 @@ async function ensureCliToken(paths) {
3368
3407
  }
3369
3408
  async function readCliToken(paths) {
3370
3409
  try {
3371
- const token = (await readFile5(paths.cliToken, "utf8")).trim();
3410
+ const token = (await readFile6(paths.cliToken, "utf8")).trim();
3372
3411
  return token === "" ? undefined : token;
3373
3412
  } catch (error) {
3374
3413
  if (isErrno(error, "ENOENT"))
@@ -3482,7 +3521,7 @@ async function ensureServe(paths) {
3482
3521
  }
3483
3522
  const deadline = Date.now() + START_TIMEOUT_MS;
3484
3523
  while (Date.now() < deadline) {
3485
- await new Promise((resolve2) => setTimeout(resolve2, 100));
3524
+ await new Promise((resolve3) => setTimeout(resolve3, 100));
3486
3525
  const client = await connectServe(paths);
3487
3526
  if (client !== undefined)
3488
3527
  return client;
@@ -3957,7 +3996,7 @@ async function pairCommand(paths, argv) {
3957
3996
  note("The code works once and expires in 5 minutes. Waiting…");
3958
3997
  }
3959
3998
  for (;; ) {
3960
- await new Promise((resolve2) => setTimeout(resolve2, 500));
3999
+ await new Promise((resolve3) => setTimeout(resolve3, 500));
3961
4000
  const state = await client.request("GET", CLI_LOCAL_PATHS.pairingCode(code));
3962
4001
  if (state.state === "paired") {
3963
4002
  if (json) {
@@ -4088,7 +4127,7 @@ async function pluginCommand(paths, registry, found, argv) {
4088
4127
  }
4089
4128
 
4090
4129
  // src/cli/commands/serve.ts
4091
- import { readFile as readFile8 } from "node:fs/promises";
4130
+ import { readFile as readFile9 } from "node:fs/promises";
4092
4131
 
4093
4132
  // src/server/http.ts
4094
4133
  import { createServer } from "node:http";
@@ -4457,7 +4496,7 @@ function admissionFailure(running, next, capacity) {
4457
4496
  }
4458
4497
 
4459
4498
  // src/jobs/jobStore.ts
4460
- import { appendFile, mkdir as mkdir7, readdir as readdir5, readFile as readFile6, rm as rm4 } from "node:fs/promises";
4499
+ import { appendFile, mkdir as mkdir7, readdir as readdir5, readFile as readFile7, rm as rm4 } from "node:fs/promises";
4461
4500
  import { join as join11 } from "node:path";
4462
4501
  var TERMINAL_STATUSES = new Set([
4463
4502
  "succeeded",
@@ -4553,13 +4592,13 @@ class JobStore {
4553
4592
  return ready;
4554
4593
  const set = this.waiters.get(jobId) ?? new Set;
4555
4594
  this.waiters.set(jobId, set);
4556
- return new Promise((resolve2) => {
4595
+ return new Promise((resolve3) => {
4557
4596
  const waiter = {
4558
4597
  after,
4559
4598
  wake: (events) => {
4560
4599
  clearTimeout(timer);
4561
4600
  set.delete(waiter);
4562
- resolve2(events);
4601
+ resolve3(events);
4563
4602
  }
4564
4603
  };
4565
4604
  const timer = setTimeout(() => waiter.wake([]), Math.min(waitMs, MAX_WAIT_MS));
@@ -4653,7 +4692,7 @@ class JobStore {
4653
4692
  return cached;
4654
4693
  let text = "";
4655
4694
  try {
4656
- text = await readFile6(join11(this.jobDir(jobId), "events.jsonl"), "utf8");
4695
+ text = await readFile7(join11(this.jobDir(jobId), "events.jsonl"), "utf8");
4657
4696
  } catch (error) {
4658
4697
  if (!isErrno(error, "ENOENT"))
4659
4698
  throw error;
@@ -4747,7 +4786,7 @@ class PageTurns {
4747
4786
  wait(jobId, signal, cleanup) {
4748
4787
  if (Date.now() >= this.holderDue)
4749
4788
  return Promise.reject(this.overdueFailure());
4750
- return new Promise((resolve2, reject) => {
4789
+ return new Promise((resolve3, reject) => {
4751
4790
  const leave = () => {
4752
4791
  clearTimeout(cleanupTimer);
4753
4792
  signal?.removeEventListener("abort", onAbort);
@@ -4761,7 +4800,7 @@ class PageTurns {
4761
4800
  jobId,
4762
4801
  grant: () => {
4763
4802
  leave();
4764
- resolve2();
4803
+ resolve3();
4765
4804
  },
4766
4805
  fail: (error) => {
4767
4806
  if (leave())
@@ -5174,7 +5213,7 @@ class TaskSlot {
5174
5213
  throw failure("cancelled", "job was cancelled");
5175
5214
  if (this.taskOf(input.jobId) !== undefined)
5176
5215
  return this.run(input);
5177
- return new Promise((resolve2, reject) => {
5216
+ return new Promise((resolve3, reject) => {
5178
5217
  const entry = {
5179
5218
  task: {
5180
5219
  taskId: newId("t"),
@@ -5191,7 +5230,7 @@ class TaskSlot {
5191
5230
  abortSentAt: 0,
5192
5231
  lastSeq: -1,
5193
5232
  settled: false,
5194
- resolve: resolve2,
5233
+ resolve: resolve3,
5195
5234
  reject,
5196
5235
  ...input.onProgress === undefined ? {} : { onProgress: input.onProgress }
5197
5236
  };
@@ -5996,7 +6035,7 @@ async function poll(core, ctx) {
5996
6035
  const immediate = core.slot.poll(view2);
5997
6036
  if (immediate !== undefined)
5998
6037
  return { status: 200, data: immediate };
5999
- const held = await new Promise((resolve2) => {
6038
+ const held = await new Promise((resolve3) => {
6000
6039
  let finished = false;
6001
6040
  const finish = (response) => {
6002
6041
  if (finished)
@@ -6006,7 +6045,7 @@ async function poll(core, ctx) {
6006
6045
  unsubscribe();
6007
6046
  if (core.heldPoll === end)
6008
6047
  core.heldPoll = undefined;
6009
- resolve2(response);
6048
+ resolve3(response);
6010
6049
  };
6011
6050
  const end = () => finish(undefined);
6012
6051
  const timer = setTimeout(end, core.pollHoldMs);
@@ -6256,11 +6295,11 @@ async function startBridgeServer(options) {
6256
6295
  throw thrown;
6257
6296
  }
6258
6297
  }
6259
- await new Promise((resolve2, reject) => {
6298
+ await new Promise((resolve3, reject) => {
6260
6299
  server.once("error", reject);
6261
6300
  server.listen(options.port, BRIDGE_HOST, () => {
6262
6301
  server.off("error", reject);
6263
- resolve2();
6302
+ resolve3();
6264
6303
  });
6265
6304
  });
6266
6305
  boundPort = server.address().port;
@@ -6272,8 +6311,8 @@ async function startBridgeServer(options) {
6272
6311
  core.heldPoll?.();
6273
6312
  store.releaseWaiters();
6274
6313
  slot.close();
6275
- await new Promise((resolve2) => {
6276
- server.close(() => resolve2());
6314
+ await new Promise((resolve3) => {
6315
+ server.close(() => resolve3());
6277
6316
  server.closeAllConnections();
6278
6317
  });
6279
6318
  await runner.settled();
@@ -6322,7 +6361,7 @@ function tooLarge(limit) {
6322
6361
  // src/state/singleInstance.ts
6323
6362
  import { randomBytes as randomBytes6 } from "node:crypto";
6324
6363
  import { constants as constants4 } from "node:fs";
6325
- import { link as link2, open as open4, readFile as readFile7 } from "node:fs/promises";
6364
+ import { link as link2, open as open4, readFile as readFile8 } from "node:fs/promises";
6326
6365
  function isAlive(pid) {
6327
6366
  if (!Number.isInteger(pid) || pid <= 0)
6328
6367
  return false;
@@ -6374,7 +6413,7 @@ async function linkLock(paths) {
6374
6413
  }
6375
6414
  async function readLockPid(paths) {
6376
6415
  try {
6377
- const pid = Number((await readFile7(paths.lock, "utf8")).trim());
6416
+ const pid = Number((await readFile8(paths.lock, "utf8")).trim());
6378
6417
  return Number.isInteger(pid) ? pid : undefined;
6379
6418
  } catch (error) {
6380
6419
  if (isErrno(error, "ENOENT"))
@@ -6452,9 +6491,9 @@ async function runServe(paths, daemon) {
6452
6491
  });
6453
6492
  if (!daemon)
6454
6493
  note(`voyager serve listening on 127.0.0.1:${server.port} (Ctrl-C to stop)`);
6455
- await new Promise((resolve2) => {
6456
- process.once("SIGINT", resolve2);
6457
- process.once("SIGTERM", resolve2);
6494
+ await new Promise((resolve3) => {
6495
+ process.once("SIGINT", resolve3);
6496
+ process.once("SIGTERM", resolve3);
6458
6497
  });
6459
6498
  log.info("serve stopping");
6460
6499
  await server.close();
@@ -6474,7 +6513,7 @@ async function stopServe(paths) {
6474
6513
  process.kill(pid, "SIGTERM");
6475
6514
  const deadline = Date.now() + 1e4;
6476
6515
  while (isAlive(pid) && Date.now() < deadline)
6477
- await new Promise((resolve2) => setTimeout(resolve2, 100));
6516
+ await new Promise((resolve3) => setTimeout(resolve3, 100));
6478
6517
  if (isAlive(pid)) {
6479
6518
  note(`voyager serve (pid ${pid}) did not stop`);
6480
6519
  return 1;
@@ -6484,7 +6523,7 @@ async function stopServe(paths) {
6484
6523
  }
6485
6524
  async function readLockPid2(paths) {
6486
6525
  try {
6487
- const pid = Number((await readFile8(paths.lock, "utf8")).trim());
6526
+ const pid = Number((await readFile9(paths.lock, "utf8")).trim());
6488
6527
  return Number.isInteger(pid) ? pid : undefined;
6489
6528
  } catch {
6490
6529
  return;
@@ -6517,7 +6556,7 @@ function defaultUpdateDeps(paths) {
6517
6556
  };
6518
6557
  }
6519
6558
  function runCommand(command, args, options) {
6520
- return new Promise((resolve2, reject) => {
6559
+ return new Promise((resolve3, reject) => {
6521
6560
  const child = spawn3(command, [...args], {
6522
6561
  stdio: options.capture ? ["ignore", "pipe", "ignore"] : ["ignore", 2, 2],
6523
6562
  shell: process.platform === "win32"
@@ -6527,7 +6566,7 @@ function runCommand(command, args, options) {
6527
6566
  stdout += chunk.toString();
6528
6567
  });
6529
6568
  child.once("error", reject);
6530
- child.once("close", (code) => resolve2({ code: code ?? 1, stdout }));
6569
+ child.once("close", (code) => resolve3({ code: code ?? 1, stdout }));
6531
6570
  });
6532
6571
  }
6533
6572
  function compareVersions(a, b) {
@@ -6819,6 +6858,8 @@ usage:
6819
6858
  voyager ask "<prompt>" [--json] new conversation, send, wait, save response.md
6820
6859
  and the files the reply offers under files/
6821
6860
  [--attach <file|folder>]... upload files; folders are zipped, credentials left out
6861
+ [--preset math] prepend the mathematical research opening
6862
+ [--preset <file>] prepend a UTF-8 text file, trimmed (up to 20,000 characters)
6822
6863
  [--dry-run] pack attachments and print the job input, send nothing
6823
6864
  [--chat <link|id> | --continue] ask in an existing conversation, or the last one used
6824
6865
  [--project <name|id>] ask in a new chat of a ChatGPT project (its files are there)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyager-crew/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Ask ChatGPT from your terminal or your coding agent, through the Voyager browser extension",
5
5
  "keywords": [
6
6
  "chatgpt",
@@ -98,6 +98,7 @@ ChatGPT sees nothing of your conversation, so the prompt carries everything. Pro
98
98
  - Say what it cannot see: callers outside the material, and the real defaults (timeouts, limits), so it does not rate severity from settings nobody uses.
99
99
  - In ordinary debugging or review work, avoid words like bypass, exploit, attack, inject, payload or crack; a safety check can take such a prompt for intrusion work and stop the turn halfway. Say workaround, trigger condition, defect or stress test.
100
100
  - When files should come back, ask for one ZIP.
101
+ - For a mathematics question (a proof, a derivation, an algorithm's correctness or bound), add `--preset math`. It opens the prompt with a research framing: a long session, depth before speed, every conclusion derived, verified or marked as a conjecture. `--preset <file>` opens it with a text file instead, for an opening the person wrote; `--dry-run` shows the combined prompt.
101
102
 
102
103
  ## Exit codes
103
104