@voyager-crew/cli 0.5.0 → 0.5.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/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
 
@@ -147,6 +149,9 @@ reported it.
147
149
  end, also after a failure; pass `--keep-tab` to leave it open. If ChatGPT asks you to sign in
148
150
  or solve a challenge, Voyager CLI stops, leaves that tab open and says so (exit 3); it never
149
151
  works around it.
152
+ - The extension refuses jobs while its page data is missing or over 24 hours old (`policy-stale`).
153
+ Commands then refresh it once from voyager.nagi.fun and go on; if that fails, they stop before
154
+ sending anything and say why. `voyager call catalog.refresh` tries again.
150
155
  - `voyager update` updates everything it can: the CLI (when npm installed it globally),
151
156
  `voyager serve` (restarted unless a job is running) and the extension's page data, fetched now
152
157
  instead of at its next check. Your browser's store updates the extension itself.
package/README_ZH.md CHANGED
@@ -125,6 +125,7 @@ agent 可以同时提问,回复一起等;输入和点击仍会轮流进行
125
125
  - `ask`、`read` 和所有 `project` 命令都会自己打开一个 ChatGPT 标签页,结束时关掉,失败了也关;
126
126
  想留着就加 `--keep-tab`。如果 ChatGPT 要求登录或人机验证,Voyager CLI 会停下来、留着那个
127
127
  标签页并告诉你(退出码 3),不会绕过。
128
+ - 扩展的页面数据缺失或超过 24 小时未更新时,会拒绝新任务(`policy-stale`)。这时命令会先从 voyager.nagi.fun 刷新一次再继续;刷新失败就在发送前停下并说明原因,之后可以用 `voyager call catalog.refresh` 重试。
128
129
  - `voyager update` 把能更新的都更新一遍:命令行本身(用 npm 全局安装时)、`voyager serve`
129
130
  (没有任务在跑时重启)和扩展的页面数据(立即重新获取,不等下一次定时检查)。扩展本身由浏览器的
130
131
  扩展商店更新。
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.2",
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) {
@@ -4016,6 +4055,67 @@ function newId(prefix) {
4016
4055
  return `${prefix}${Date.now().toString(36)}${randomBytes5(5).toString("hex")}`;
4017
4056
  }
4018
4057
 
4058
+ // src/cli/policyRefresh.ts
4059
+ var REFRESH_ATTEMPTS = 2;
4060
+ var REFRESH_WAIT_MS = 30000;
4061
+ var POLICY_REPORT_WAIT_MS = POLL_HOLD_MS + 5000;
4062
+ var POLICY_POLL_MS = 200;
4063
+ async function refreshOnce(client) {
4064
+ const { jobId } = await client.request("POST", BRIDGE_PATHS.call, {
4065
+ op: "catalog.refresh",
4066
+ params: {}
4067
+ });
4068
+ const { kind, job } = await waitForJob(client, jobId, REFRESH_WAIT_MS);
4069
+ if (kind === "timeout")
4070
+ return "the extension did not answer";
4071
+ if (job.status !== "succeeded")
4072
+ return job.error?.message ?? job.status;
4073
+ const result = job.result?.result;
4074
+ if (!isRecord2(result))
4075
+ return "the extension sent no result";
4076
+ if (result.status === "updated" || result.status === "unchanged")
4077
+ return;
4078
+ return typeof result.reason === "string" ? result.reason : String(result.status);
4079
+ }
4080
+ async function policyReported(client) {
4081
+ const deadline = Date.now() + POLICY_REPORT_WAIT_MS;
4082
+ while (Date.now() < deadline) {
4083
+ const status = await client.request("GET", BRIDGE_PATHS.status);
4084
+ if (status.extension.policy?.state !== "stale")
4085
+ return true;
4086
+ await new Promise((resolve3) => setTimeout(resolve3, POLICY_POLL_MS));
4087
+ }
4088
+ return false;
4089
+ }
4090
+ async function refreshPolicy(client) {
4091
+ let reason;
4092
+ for (let attempt = 0;attempt < REFRESH_ATTEMPTS; attempt += 1) {
4093
+ try {
4094
+ reason = await refreshOnce(client);
4095
+ } catch (thrown) {
4096
+ return toBridgeError(thrown).message;
4097
+ }
4098
+ if (reason === undefined) {
4099
+ return await policyReported(client) ? undefined : "the extension still reports it stale";
4100
+ }
4101
+ }
4102
+ return reason;
4103
+ }
4104
+ async function submitWithFreshPolicy(client, submit) {
4105
+ try {
4106
+ return await submit();
4107
+ } catch (thrown) {
4108
+ if (!(thrown instanceof BridgeFailure) || thrown.error.code !== "policy-stale")
4109
+ throw thrown;
4110
+ note("the extension policy is out of date; refreshing it from voyager.nagi.fun");
4111
+ const reason = await refreshPolicy(client);
4112
+ if (reason !== undefined) {
4113
+ throw failure("policy-stale", `${thrown.message} (refreshing it failed: ${reason})`);
4114
+ }
4115
+ }
4116
+ return submit();
4117
+ }
4118
+
4019
4119
  // src/cli/commands/plugin.ts
4020
4120
  var STAGING_MAX_AGE_MS = 24 * 60 * 60000;
4021
4121
  async function sweepStaging(root) {
@@ -4080,15 +4180,15 @@ async function pluginCommand(paths, registry, found, argv) {
4080
4180
  json: args.options.json === true,
4081
4181
  noWait: args.options["no-wait"] === true,
4082
4182
  timeoutMs: waitTimeout(args)
4083
- }, () => client.request("POST", BRIDGE_PATHS.jobs, {
4183
+ }, () => submitWithFreshPolicy(client, () => client.request("POST", BRIDGE_PATHS.jobs, {
4084
4184
  plugin: found.plugin.name,
4085
4185
  command: found.command,
4086
4186
  input
4087
- }));
4187
+ })));
4088
4188
  }
4089
4189
 
4090
4190
  // src/cli/commands/serve.ts
4091
- import { readFile as readFile8 } from "node:fs/promises";
4191
+ import { readFile as readFile9 } from "node:fs/promises";
4092
4192
 
4093
4193
  // src/server/http.ts
4094
4194
  import { createServer } from "node:http";
@@ -4368,7 +4468,7 @@ function policyFailure(state, op) {
4368
4468
  return failure("policy-denied", "the extension policy does not allow the bridge");
4369
4469
  }
4370
4470
  if (state === "stale") {
4371
- return failure("policy-stale", "the extension policy is out of date; turn on online plugin updates in Voyager");
4471
+ return failure("policy-stale", "the extension policy is out of date; run `voyager call catalog.refresh` while the browser can reach voyager.nagi.fun");
4372
4472
  }
4373
4473
  return;
4374
4474
  }
@@ -4457,7 +4557,7 @@ function admissionFailure(running, next, capacity) {
4457
4557
  }
4458
4558
 
4459
4559
  // src/jobs/jobStore.ts
4460
- import { appendFile, mkdir as mkdir7, readdir as readdir5, readFile as readFile6, rm as rm4 } from "node:fs/promises";
4560
+ import { appendFile, mkdir as mkdir7, readdir as readdir5, readFile as readFile7, rm as rm4 } from "node:fs/promises";
4461
4561
  import { join as join11 } from "node:path";
4462
4562
  var TERMINAL_STATUSES = new Set([
4463
4563
  "succeeded",
@@ -4553,13 +4653,13 @@ class JobStore {
4553
4653
  return ready;
4554
4654
  const set = this.waiters.get(jobId) ?? new Set;
4555
4655
  this.waiters.set(jobId, set);
4556
- return new Promise((resolve2) => {
4656
+ return new Promise((resolve3) => {
4557
4657
  const waiter = {
4558
4658
  after,
4559
4659
  wake: (events) => {
4560
4660
  clearTimeout(timer);
4561
4661
  set.delete(waiter);
4562
- resolve2(events);
4662
+ resolve3(events);
4563
4663
  }
4564
4664
  };
4565
4665
  const timer = setTimeout(() => waiter.wake([]), Math.min(waitMs, MAX_WAIT_MS));
@@ -4653,7 +4753,7 @@ class JobStore {
4653
4753
  return cached;
4654
4754
  let text = "";
4655
4755
  try {
4656
- text = await readFile6(join11(this.jobDir(jobId), "events.jsonl"), "utf8");
4756
+ text = await readFile7(join11(this.jobDir(jobId), "events.jsonl"), "utf8");
4657
4757
  } catch (error) {
4658
4758
  if (!isErrno(error, "ENOENT"))
4659
4759
  throw error;
@@ -4747,7 +4847,7 @@ class PageTurns {
4747
4847
  wait(jobId, signal, cleanup) {
4748
4848
  if (Date.now() >= this.holderDue)
4749
4849
  return Promise.reject(this.overdueFailure());
4750
- return new Promise((resolve2, reject) => {
4850
+ return new Promise((resolve3, reject) => {
4751
4851
  const leave = () => {
4752
4852
  clearTimeout(cleanupTimer);
4753
4853
  signal?.removeEventListener("abort", onAbort);
@@ -4761,7 +4861,7 @@ class PageTurns {
4761
4861
  jobId,
4762
4862
  grant: () => {
4763
4863
  leave();
4764
- resolve2();
4864
+ resolve3();
4765
4865
  },
4766
4866
  fail: (error) => {
4767
4867
  if (leave())
@@ -5174,7 +5274,7 @@ class TaskSlot {
5174
5274
  throw failure("cancelled", "job was cancelled");
5175
5275
  if (this.taskOf(input.jobId) !== undefined)
5176
5276
  return this.run(input);
5177
- return new Promise((resolve2, reject) => {
5277
+ return new Promise((resolve3, reject) => {
5178
5278
  const entry = {
5179
5279
  task: {
5180
5280
  taskId: newId("t"),
@@ -5191,7 +5291,7 @@ class TaskSlot {
5191
5291
  abortSentAt: 0,
5192
5292
  lastSeq: -1,
5193
5293
  settled: false,
5194
- resolve: resolve2,
5294
+ resolve: resolve3,
5195
5295
  reject,
5196
5296
  ...input.onProgress === undefined ? {} : { onProgress: input.onProgress }
5197
5297
  };
@@ -5996,7 +6096,7 @@ async function poll(core, ctx) {
5996
6096
  const immediate = core.slot.poll(view2);
5997
6097
  if (immediate !== undefined)
5998
6098
  return { status: 200, data: immediate };
5999
- const held = await new Promise((resolve2) => {
6099
+ const held = await new Promise((resolve3) => {
6000
6100
  let finished = false;
6001
6101
  const finish = (response) => {
6002
6102
  if (finished)
@@ -6006,7 +6106,7 @@ async function poll(core, ctx) {
6006
6106
  unsubscribe();
6007
6107
  if (core.heldPoll === end)
6008
6108
  core.heldPoll = undefined;
6009
- resolve2(response);
6109
+ resolve3(response);
6010
6110
  };
6011
6111
  const end = () => finish(undefined);
6012
6112
  const timer = setTimeout(end, core.pollHoldMs);
@@ -6256,11 +6356,11 @@ async function startBridgeServer(options) {
6256
6356
  throw thrown;
6257
6357
  }
6258
6358
  }
6259
- await new Promise((resolve2, reject) => {
6359
+ await new Promise((resolve3, reject) => {
6260
6360
  server.once("error", reject);
6261
6361
  server.listen(options.port, BRIDGE_HOST, () => {
6262
6362
  server.off("error", reject);
6263
- resolve2();
6363
+ resolve3();
6264
6364
  });
6265
6365
  });
6266
6366
  boundPort = server.address().port;
@@ -6272,8 +6372,8 @@ async function startBridgeServer(options) {
6272
6372
  core.heldPoll?.();
6273
6373
  store.releaseWaiters();
6274
6374
  slot.close();
6275
- await new Promise((resolve2) => {
6276
- server.close(() => resolve2());
6375
+ await new Promise((resolve3) => {
6376
+ server.close(() => resolve3());
6277
6377
  server.closeAllConnections();
6278
6378
  });
6279
6379
  await runner.settled();
@@ -6322,7 +6422,7 @@ function tooLarge(limit) {
6322
6422
  // src/state/singleInstance.ts
6323
6423
  import { randomBytes as randomBytes6 } from "node:crypto";
6324
6424
  import { constants as constants4 } from "node:fs";
6325
- import { link as link2, open as open4, readFile as readFile7 } from "node:fs/promises";
6425
+ import { link as link2, open as open4, readFile as readFile8 } from "node:fs/promises";
6326
6426
  function isAlive(pid) {
6327
6427
  if (!Number.isInteger(pid) || pid <= 0)
6328
6428
  return false;
@@ -6374,7 +6474,7 @@ async function linkLock(paths) {
6374
6474
  }
6375
6475
  async function readLockPid(paths) {
6376
6476
  try {
6377
- const pid = Number((await readFile7(paths.lock, "utf8")).trim());
6477
+ const pid = Number((await readFile8(paths.lock, "utf8")).trim());
6378
6478
  return Number.isInteger(pid) ? pid : undefined;
6379
6479
  } catch (error) {
6380
6480
  if (isErrno(error, "ENOENT"))
@@ -6452,9 +6552,9 @@ async function runServe(paths, daemon) {
6452
6552
  });
6453
6553
  if (!daemon)
6454
6554
  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);
6555
+ await new Promise((resolve3) => {
6556
+ process.once("SIGINT", resolve3);
6557
+ process.once("SIGTERM", resolve3);
6458
6558
  });
6459
6559
  log.info("serve stopping");
6460
6560
  await server.close();
@@ -6474,7 +6574,7 @@ async function stopServe(paths) {
6474
6574
  process.kill(pid, "SIGTERM");
6475
6575
  const deadline = Date.now() + 1e4;
6476
6576
  while (isAlive(pid) && Date.now() < deadline)
6477
- await new Promise((resolve2) => setTimeout(resolve2, 100));
6577
+ await new Promise((resolve3) => setTimeout(resolve3, 100));
6478
6578
  if (isAlive(pid)) {
6479
6579
  note(`voyager serve (pid ${pid}) did not stop`);
6480
6580
  return 1;
@@ -6484,7 +6584,7 @@ async function stopServe(paths) {
6484
6584
  }
6485
6585
  async function readLockPid2(paths) {
6486
6586
  try {
6487
- const pid = Number((await readFile8(paths.lock, "utf8")).trim());
6587
+ const pid = Number((await readFile9(paths.lock, "utf8")).trim());
6488
6588
  return Number.isInteger(pid) ? pid : undefined;
6489
6589
  } catch {
6490
6590
  return;
@@ -6517,7 +6617,7 @@ function defaultUpdateDeps(paths) {
6517
6617
  };
6518
6618
  }
6519
6619
  function runCommand(command, args, options) {
6520
- return new Promise((resolve2, reject) => {
6620
+ return new Promise((resolve3, reject) => {
6521
6621
  const child = spawn3(command, [...args], {
6522
6622
  stdio: options.capture ? ["ignore", "pipe", "ignore"] : ["ignore", 2, 2],
6523
6623
  shell: process.platform === "win32"
@@ -6527,7 +6627,7 @@ function runCommand(command, args, options) {
6527
6627
  stdout += chunk.toString();
6528
6628
  });
6529
6629
  child.once("error", reject);
6530
- child.once("close", (code) => resolve2({ code: code ?? 1, stdout }));
6630
+ child.once("close", (code) => resolve3({ code: code ?? 1, stdout }));
6531
6631
  });
6532
6632
  }
6533
6633
  function compareVersions(a, b) {
@@ -6819,6 +6919,8 @@ usage:
6819
6919
  voyager ask "<prompt>" [--json] new conversation, send, wait, save response.md
6820
6920
  and the files the reply offers under files/
6821
6921
  [--attach <file|folder>]... upload files; folders are zipped, credentials left out
6922
+ [--preset math] prepend the mathematical research opening
6923
+ [--preset <file>] prepend a UTF-8 text file, trimmed (up to 20,000 characters)
6822
6924
  [--dry-run] pack attachments and print the job input, send nothing
6823
6925
  [--chat <link|id> | --continue] ask in an existing conversation, or the last one used
6824
6926
  [--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.2",
4
4
  "description": "Ask ChatGPT from your terminal or your coding agent, through the Voyager browser extension",
5
5
  "keywords": [
6
6
  "chatgpt",
@@ -98,9 +98,12 @@ 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
 
105
+ `policy-stale` (exit 3) means voyager already tried to refresh the extension's page data and could not; nothing was sent, and `error.message` says why. It usually means the browser cannot reach voyager.nagi.fun. Once it can, run the same command again.
106
+
104
107
  | Code | Meaning | Next step |
105
108
  | ---- | -------------------------------------------------------------------------------------- | ------------------------------------------------------- |
106
109
  | 0 | succeeded (also when some `failedFiles` could not be downloaded) | read `responsePath` and `files`; report `failedFiles` |