@ghostlytools/cli 1.7.4 → 1.8.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.
Files changed (84) hide show
  1. package/README.md +12 -6
  2. package/SKILL.md +1 -1
  3. package/dist/assets/{api-Chhvpwok.js → api-Dj1yn0px.js} +2 -2
  4. package/dist/assets/{api-D3i2hwy0.js → api-I_KbuXHa.js} +62 -16
  5. package/dist/assets/api-I_KbuXHa.js.map +1 -0
  6. package/dist/assets/{apiKit-BtsHrnoo.js → apiKit-C-_PWZvy.js} +17 -5
  7. package/dist/assets/{apiKit-BtsHrnoo.js.map → apiKit-C-_PWZvy.js.map} +1 -1
  8. package/dist/assets/{apps-BHl97rHs.js → apps-DKIe8VjF.js} +8 -7
  9. package/dist/assets/apps-DKIe8VjF.js.map +1 -0
  10. package/dist/assets/{apps-BFJTqvAt.js → apps-DbEfL_3b.js} +1 -1
  11. package/dist/assets/{arkade-BFE8KkEE.js → arkade-k1bdSm70.js} +2 -2
  12. package/dist/assets/{arkade-BFE8KkEE.js.map → arkade-k1bdSm70.js.map} +1 -1
  13. package/dist/assets/{backup-Bbsr6nDi.js → backup-Cdd6-HNu.js} +1 -1
  14. package/dist/assets/{backup-CxACdtQX.js → backup-beKfbfNk.js} +6 -6
  15. package/dist/assets/{backup-CxACdtQX.js.map → backup-beKfbfNk.js.map} +1 -1
  16. package/dist/assets/buttons-BO1_7V4L.js +2 -0
  17. package/dist/assets/{buttons-CieBtXEO.js → buttons-ClI13rdv.js} +7 -6
  18. package/dist/assets/buttons-ClI13rdv.js.map +1 -0
  19. package/dist/assets/{daemonProof-QmtwDj-N.js → daemonProof-DtrL5lE5.js} +2 -2
  20. package/dist/assets/{daemonProof-QmtwDj-N.js.map → daemonProof-DtrL5lE5.js.map} +1 -1
  21. package/dist/assets/{envelope-DYiGwzq_.js → envelope-B88yiCQj.js} +2 -2
  22. package/dist/assets/{envelope-DYiGwzq_.js.map → envelope-B88yiCQj.js.map} +1 -1
  23. package/dist/assets/{errors-QUGP-jIF.js → errors-R4S2SAEM.js} +7 -2
  24. package/dist/assets/errors-R4S2SAEM.js.map +1 -0
  25. package/dist/assets/{groupFiles-CBJIEvCE.js → groupFiles-DjQc5XXv.js} +135 -24
  26. package/dist/assets/groupFiles-DjQc5XXv.js.map +1 -0
  27. package/dist/assets/{host-Va-r_KJz.js → host-CNWGB3-j.js} +44 -20
  28. package/dist/assets/host-CNWGB3-j.js.map +1 -0
  29. package/dist/assets/{hyperdhtRelay-B2uK9tJv.js → hyperdhtRelay-g7eXzf5h.js} +2 -2
  30. package/dist/assets/{hyperdhtRelay-B2uK9tJv.js.map → hyperdhtRelay-g7eXzf5h.js.map} +1 -1
  31. package/dist/assets/{irohWeb-DxeEgQ-W.js → irohWeb-Bx8dI4be.js} +2 -2
  32. package/dist/assets/{irohWeb-DxeEgQ-W.js.map → irohWeb-Bx8dI4be.js.map} +1 -1
  33. package/dist/assets/{main-BX4oPWCJ.js → main-BRxhBctJ.js} +121 -37
  34. package/dist/assets/main-BRxhBctJ.js.map +1 -0
  35. package/dist/assets/{mainline-IfWQOB-J.js → mainline-CwuS6ngj.js} +2 -2
  36. package/dist/assets/{mainline-IfWQOB-J.js.map → mainline-CwuS6ngj.js.map} +1 -1
  37. package/dist/assets/mints-BaOmx517.js +2 -0
  38. package/dist/assets/{mints-BrlY773j.js → mints-j5XAOk4f.js} +15 -3
  39. package/dist/assets/mints-j5XAOk4f.js.map +1 -0
  40. package/dist/assets/{networkReason-N2vAaoth.js → networkReason-CIAMieQm.js} +2 -2
  41. package/dist/assets/{networkReason-N2vAaoth.js.map → networkReason-CIAMieQm.js.map} +1 -1
  42. package/dist/assets/{nwc-CzyCtNK2.js → nwc-C9JLJJkL.js} +3 -3
  43. package/dist/assets/{nwc-CzyCtNK2.js.map → nwc-C9JLJJkL.js.map} +1 -1
  44. package/dist/assets/{nwcProvider-DjWmEn3j.js → nwcProvider-pFMrsUJh.js} +2 -2
  45. package/dist/assets/{nwcProvider-DjWmEn3j.js.map → nwcProvider-pFMrsUJh.js.map} +1 -1
  46. package/dist/assets/{profiles-DcCeOi7J.js → profiles-MFtCmJwK.js} +3 -3
  47. package/dist/assets/{profiles-DcCeOi7J.js.map → profiles-MFtCmJwK.js.map} +1 -1
  48. package/dist/assets/{registry-CeW8XEQc.js → registry-Cks7FA_o.js} +3 -3
  49. package/dist/assets/{registry-CeW8XEQc.js.map → registry-Cks7FA_o.js.map} +1 -1
  50. package/dist/assets/{registry-BmS02J5h.js → registry-DY2ixQfU.js} +1 -1
  51. package/dist/assets/{resolve-BvHkAhDH.js → resolve-C4Y2HPqQ.js} +15 -3
  52. package/dist/assets/resolve-C4Y2HPqQ.js.map +1 -0
  53. package/dist/assets/{restoredRows-mTTp3XNs.js → restoredRows-BCRCjhdF.js} +26 -2
  54. package/dist/assets/{restoredRows-mTTp3XNs.js.map → restoredRows-BCRCjhdF.js.map} +1 -1
  55. package/dist/assets/{server-BUcJo4vz.js → server-D9RAmGdm.js} +650 -150
  56. package/dist/assets/server-D9RAmGdm.js.map +1 -0
  57. package/dist/assets/{src-BB5-5P3s.js → src-1RU4TilT.js} +878 -77
  58. package/dist/assets/src-1RU4TilT.js.map +1 -0
  59. package/dist/assets/{translate-2WyaRVCr.js → translate-od5GbpvR.js} +11 -7
  60. package/dist/assets/translate-od5GbpvR.js.map +1 -0
  61. package/dist/assets/{usdt-BLazHiaP.js → usdt-DldXV0MR.js} +3 -3
  62. package/dist/assets/{usdt-BLazHiaP.js.map → usdt-DldXV0MR.js.map} +1 -1
  63. package/dist/assets/waitNotice-Ck3el3_Z.js +45 -0
  64. package/dist/assets/waitNotice-Ck3el3_Z.js.map +1 -0
  65. package/dist/assets/{words-BaumxjXe.js → words-BS2qq_vV.js} +6 -3
  66. package/dist/assets/words-BS2qq_vV.js.map +1 -0
  67. package/dist/ghostly.mjs +1 -1
  68. package/examples/claude-code-agent.sh +1 -1
  69. package/package.json +1 -1
  70. package/dist/assets/api-D3i2hwy0.js.map +0 -1
  71. package/dist/assets/apps-BHl97rHs.js.map +0 -1
  72. package/dist/assets/buttons-CieBtXEO.js.map +0 -1
  73. package/dist/assets/buttons-YtAj3R_E.js +0 -2
  74. package/dist/assets/errors-QUGP-jIF.js.map +0 -1
  75. package/dist/assets/groupFiles-CBJIEvCE.js.map +0 -1
  76. package/dist/assets/host-Va-r_KJz.js.map +0 -1
  77. package/dist/assets/main-BX4oPWCJ.js.map +0 -1
  78. package/dist/assets/mints-BrlY773j.js.map +0 -1
  79. package/dist/assets/mints-CqTdA4Gk.js +0 -2
  80. package/dist/assets/resolve-BvHkAhDH.js.map +0 -1
  81. package/dist/assets/server-BUcJo4vz.js.map +0 -1
  82. package/dist/assets/src-BB5-5P3s.js.map +0 -1
  83. package/dist/assets/translate-2WyaRVCr.js.map +0 -1
  84. package/dist/assets/words-BaumxjXe.js.map +0 -1
@@ -1,18 +1,19 @@
1
- import { $a as RUN_RESULTS, Gn as GROUP_FILE_LIMITS, Ja as CRON_LINE, Qa as ROUTINE_STATES, Xa as PR_CHECKS, Ya as ITEM_STATES, Za as PR_STATES, ao as cardUrl, co as statusCardBytes, eo as STATUS_CARD_LIMITS, fa as VOICE_LIMITS, io as cardLine, to as TASK_STATUSES } from "./src-BB5-5P3s.js";
2
- import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-BaumxjXe.js";
3
- import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-QUGP-jIF.js";
4
- import { m as namedByThem, t as CONTACT_KEY } from "./apiKit-BtsHrnoo.js";
5
- import { _ as userPath, a as checkShownName, c as ghostlyHome, f as profileExists, h as startingDaemon, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner, y as ownSocket } from "./profiles-DcCeOi7J.js";
6
- import { _ as isCallRate, a as newNonce, c as provesGreeting, d as CALL_RATES, l as readDaemonSecret, n as daemonOfThisRelease, s as provesDaemon, t as HELLO } from "./daemonProof-QmtwDj-N.js";
1
+ import { $a as ROUTINE_STATES, Gn as GROUP_FILE_LIMITS, Qa as PR_STATES, Xa as ITEM_STATES, Ya as CRON_LINE, Za as PR_CHECKS, ao as cardLine, eo as RUN_RESULTS, lo as statusCardBytes, no as TASK_STATUSES, oo as cardUrl, pa as VOICE_LIMITS, to as STATUS_CARD_LIMITS } from "./src-1RU4TilT.js";
2
+ import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-BS2qq_vV.js";
3
+ import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-R4S2SAEM.js";
4
+ import { m as namedByThem, t as CONTACT_KEY } from "./apiKit-C-_PWZvy.js";
5
+ import { _ as userPath, a as checkShownName, c as ghostlyHome, f as profileExists, h as startingDaemon, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner, y as ownSocket } from "./profiles-MFtCmJwK.js";
6
+ import { n as waitNotice, r as waitsFor } from "./waitNotice-Ck3el3_Z.js";
7
+ import { _ as isCallRate, a as newNonce, c as provesGreeting, d as CALL_RATES, l as readDaemonSecret, n as daemonOfThisRelease, s as provesDaemon, t as HELLO } from "./daemonProof-DtrL5lE5.js";
8
+ import { spawn } from "node:child_process";
7
9
  import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
8
10
  import { dirname, resolve } from "node:path";
9
- import { spawn } from "node:child_process";
10
11
  import { connect } from "node:net";
11
12
  import { createInterface } from "node:readline";
12
13
  import { format } from "node:util";
13
14
  var package_default = {
14
15
  name: "@ghostlytools/cli",
15
- version: "1.7.4",
16
+ version: "1.8.0",
16
17
  type: "module",
17
18
  description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
18
19
  license: "MIT",
@@ -220,6 +221,7 @@ function nearest(typed, words) {
220
221
  const most = Math.min(2, Math.floor(typed.length / 3));
221
222
  let best, bestDistance = most + 1;
222
223
  for (const word of words) {
224
+ if (Math.abs(typed.length - word.length) >= bestDistance) continue;
223
225
  const d = distance(typed, word);
224
226
  if (d < bestDistance) {
225
227
  best = word;
@@ -1209,7 +1211,7 @@ var commands$8 = {
1209
1211
  description: "Replace the three files when they are there"
1210
1212
  }
1211
1213
  },
1212
- run: async ({ options }, a) => (await import("./apps-BFJTqvAt.js")).initApp(a.dir, {
1214
+ run: async ({ options }, a) => (await import("./apps-DbEfL_3b.js")).initApp(a.dir, {
1213
1215
  name: options.name,
1214
1216
  title: options.title,
1215
1217
  force: options.force === true
@@ -1249,7 +1251,7 @@ var commands$8 = {
1249
1251
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1250
1252
  }
1251
1253
  },
1252
- run: async ({ options }, a) => (await import("./apps-BFJTqvAt.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1254
+ run: async ({ options }, a) => (await import("./apps-DbEfL_3b.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1253
1255
  },
1254
1256
  "app revoke": {
1255
1257
  method: "app.revoke",
@@ -1282,7 +1284,7 @@ var commands$8 = {
1282
1284
  description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
1283
1285
  }
1284
1286
  },
1285
- run: async ({ options }, a) => (await import("./apps-BFJTqvAt.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1287
+ run: async ({ options }, a) => (await import("./apps-DbEfL_3b.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1286
1288
  digests: options.digest,
1287
1289
  upTo: options["up-to"],
1288
1290
  reason: options.reason,
@@ -1343,7 +1345,7 @@ var commands$8 = {
1343
1345
  usage: "app verify <bundle|url>",
1344
1346
  summary: "Check a .ghostlyapp as a client would, from a file or an https URL: its manifest and digest, or refused (exit 1) with the reason, revoked when the ghostly-revoke.json beside it revokes this version",
1345
1347
  args: ["bundle"],
1346
- run: async (_, a) => (await import("./apps-BFJTqvAt.js")).verifyApp(a.bundle)
1348
+ run: async (_, a) => (await import("./apps-DbEfL_3b.js")).verifyApp(a.bundle)
1347
1349
  },
1348
1350
  "store sign": {
1349
1351
  method: "store.sign",
@@ -1360,7 +1362,7 @@ var commands$8 = {
1360
1362
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1361
1363
  }
1362
1364
  },
1363
- run: async ({ options }, a) => (await import("./apps-BFJTqvAt.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1365
+ run: async ({ options }, a) => (await import("./apps-DbEfL_3b.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1364
1366
  }
1365
1367
  };
1366
1368
  //#endregion
@@ -4091,15 +4093,15 @@ var VERSION = package_default.version;
4091
4093
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4092
4094
  * cost every command ~100 ms before its socket was opened.
4093
4095
  */
4094
- var engineApi = () => import("./api-Chhvpwok.js");
4095
- var engineHost = () => import("./host-Va-r_KJz.js");
4096
+ var engineApi = () => import("./api-Dj1yn0px.js");
4097
+ var engineHost = () => import("./host-CNWGB3-j.js");
4096
4098
  /**
4097
4099
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4098
4100
  * asked: the app's message parser it reads costs every other command nothing.
4099
4101
  */
4100
4102
  async function translatorFor(value, home) {
4101
4103
  if (value === void 0) return null;
4102
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-2WyaRVCr.js");
4104
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-od5GbpvR.js");
4103
4105
  return openTranslator({
4104
4106
  home,
4105
4107
  to: translateTarget(value),
@@ -4303,16 +4305,6 @@ function answerWithin(method, params) {
4303
4305
  if (waits !== void 0) return (waits + 10) * 1e3;
4304
4306
  if (readOnly(method, params)) return ANSWER_MS;
4305
4307
  }
4306
- /**
4307
- * The seconds a call without `--timeout` waits for the contact: the daemon's defaults (`num(params, "timeout", …)` in
4308
- * api.ts, files.ts, buttons.ts and statusCards.ts), so that a bot's `chat wait` or `send --wait sent` on a daemon that
4309
- * stopped answering ends when the wait would have. A call that does not wait is none.
4310
- */
4311
- function waitsFor(method, params) {
4312
- if (method === "chat.wait") return 60;
4313
- if (method === "file.wait" || method === "file.save" && params.wait === true) return 300;
4314
- if (typeof params.wait === "string" && params.wait !== "none") return 30;
4315
- }
4316
4308
  async function session(g, options) {
4317
4309
  requireProfile(g);
4318
4310
  const client = await connectDaemon(g.paths);
@@ -4323,7 +4315,8 @@ async function session(g, options) {
4323
4315
  return {
4324
4316
  mode: "one-shot",
4325
4317
  call: (m, p) => callApi(host.ctx, m, p ?? {}),
4326
- close: () => host.close()
4318
+ close: () => host.close(),
4319
+ abort: () => host.close()
4327
4320
  };
4328
4321
  }
4329
4322
  function throughDaemon(client) {
@@ -4342,6 +4335,9 @@ function throughDaemon(client) {
4342
4335
  close: async () => {
4343
4336
  await warned;
4344
4337
  client.close();
4338
+ },
4339
+ abort: async () => {
4340
+ client.destroy();
4345
4341
  }
4346
4342
  };
4347
4343
  }
@@ -4384,12 +4380,78 @@ async function openOneShot(g, options = {}, mode = "one-shot") {
4384
4380
  */
4385
4381
  async function withSession(g, work, options = {}) {
4386
4382
  const s = await session(g, options);
4383
+ const stops = interruptible(s);
4387
4384
  try {
4388
- return await work(s);
4385
+ return await stops.run(work);
4389
4386
  } finally {
4390
4387
  await s.close();
4388
+ stops.off();
4391
4389
  }
4392
4390
  }
4391
+ /** How long a wait goes on before a terminal is told what it waits for: a command done by then says nothing. */
4392
+ var WAIT_NOTICE_MS = 1e3;
4393
+ /** How long Ctrl-C gives the profile to close before the command leaves anyway (a second Ctrl-C leaves at once). */
4394
+ var INTERRUPT_CLOSE_MS = 1e4;
4395
+ /**
4396
+ * Ctrl-C while a session's command runs (agents#2354): the command stops where it is, a one-shot's profile closes (its
4397
+ * lock released, as `daemon` does in `stopper`), one line on stderr says what became of what it waited on, stdout has
4398
+ * the `interrupted` error, and the exit is 130. Killed by SIGINT, it said nothing, left `daemon.lock` behind, and the
4399
+ * person did not learn that the message still goes (and sent it again). Ctrl-C once the work is done (the profile
4400
+ * closing) only lets the answer out. A wait that goes on past WAIT_NOTICE_MS says what it waits for, on a terminal only:
4401
+ * stderr of a bot's pipe stays clean.
4402
+ */
4403
+ function interruptible(s) {
4404
+ let interrupted = false, done = false, left = false;
4405
+ const pending = /* @__PURE__ */ new Set();
4406
+ const onSignal = () => {
4407
+ if (interrupted) process.exit(EXIT.interrupted);
4408
+ interrupted = true;
4409
+ if (done) return;
4410
+ const [first] = pending, waiting = [...pending].find((call) => call.notice)?.notice;
4411
+ const words = waiting ? `stopped waiting (Ctrl-C): ${waiting.stopped}` : "stopped (Ctrl-C) before the command answered";
4412
+ const leave = () => {
4413
+ if (left) return;
4414
+ left = true;
4415
+ process.stderr.write(`ghostly: ${words}\n`);
4416
+ print({ error: new CliError("interrupted", words[0].toUpperCase() + words.slice(1), first ? { method: first.method } : void 0).toJSON() });
4417
+ exit(EXIT.interrupted);
4418
+ };
4419
+ setTimeout(leave, INTERRUPT_CLOSE_MS).unref();
4420
+ s.abort().catch(() => {}).then(leave);
4421
+ };
4422
+ process.on("SIGINT", onSignal);
4423
+ const held = (promise) => new Promise((resolve, reject) => {
4424
+ promise.then((value) => {
4425
+ if (!interrupted || done) resolve(value);
4426
+ }, (error) => {
4427
+ if (!interrupted || done) reject(error);
4428
+ });
4429
+ });
4430
+ const call = (method, params) => {
4431
+ const entry = {
4432
+ method,
4433
+ notice: waitNotice(method, params ?? {}, s.mode)
4434
+ };
4435
+ pending.add(entry);
4436
+ const notice = entry.notice;
4437
+ const timer = notice && process.stderr.isTTY ? setTimeout(() => process.stderr.write(`ghostly: ${notice.waiting}\n`), WAIT_NOTICE_MS) : void 0;
4438
+ return held(s.call(method, params).finally(() => {
4439
+ clearTimeout(timer);
4440
+ pending.delete(entry);
4441
+ }));
4442
+ };
4443
+ return {
4444
+ run: (work) => held(work({
4445
+ ...s,
4446
+ call
4447
+ }).finally(() => {
4448
+ if (!interrupted) done = true;
4449
+ })),
4450
+ off: () => {
4451
+ process.off("SIGINT", onSignal);
4452
+ }
4453
+ };
4454
+ }
4393
4455
  /**
4394
4456
  * A one-shot join waits up to 60 s for the inviter. Its answer says whether the chat paired and at what stage it is; one
4395
4457
  * not paired yet comes with the next step, since nothing pairs once the command has left.
@@ -4506,7 +4568,7 @@ var SPECIAL = [
4506
4568
  cursor: o("string", "A file that keeps the last seq handled (read at start, written after each event)"),
4507
4569
  type: o("list", "Only events of this type (message.received) or family (message, or group.typing.); repeat for more"),
4508
4570
  turns: o("boolean", "Only agent turns: each message received, and each group message that mentions you, as one agent.turn event"),
4509
- from: o("list", "Only this chat's events (id, prefix, name or the contact's key; again for more)"),
4571
+ from: o("list", "Only this chat's events (id, a label given here or the contact's key; again for more)"),
4510
4572
  group: o("list", "Only this group's events (again for more); with --from or --group, nobody else's event gets through"),
4511
4573
  exec: o("string", "Run this command per event, the event as JSON on stdin"),
4512
4574
  webhook: o("string", "POST each event to this URL"),
@@ -4640,7 +4702,7 @@ function help(firstSteps = false) {
4640
4702
  "Options for every command:",
4641
4703
  ...Object.entries(GLOBAL_OPTIONS).flatMap(([name, o]) => helpRow(` --${name}${o.short ? `, -${o.short}` : ""}`, o.description, 24, columns)),
4642
4704
  "",
4643
- ...paragraph(["A <chat> is its id, a unique prefix of it, or its name; a <group> the same. Exit codes: 0 done, 1 failed,", "2 usage, 3 not found, 4 timed out, 5 needs --force/--yes/--confirm-real."], columns),
4705
+ ...paragraph(["A <chat> is its id, a unique prefix of it, or its name; a <group> the same. Exit codes: 0 done, 1 failed,", "2 usage, 3 not found, 4 timed out, 5 needs --force/--yes/--confirm-real, 130 stopped with Ctrl-C."], columns),
4644
4706
  ...paragraph(["More: https://ghostly.tools/cli, or the README.md beside this CLI."], columns)
4645
4707
  ].join("\n");
4646
4708
  }
@@ -4862,7 +4924,7 @@ async function profileCommand(sub, argv) {
4862
4924
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
4863
4925
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
4864
4926
  const file = here(given);
4865
- const { backupFileProtection, restoreProfile } = await import("./backup-Bbsr6nDi.js");
4927
+ const { backupFileProtection, restoreProfile } = await import("./backup-Cdd6-HNu.js");
4866
4928
  const protection = await backupFileProtection(file);
4867
4929
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
4868
4930
  if (parsed.options.use) selectProfile(g.home, name);
@@ -5589,7 +5651,7 @@ async function textCommand(name, argv) {
5589
5651
  };
5590
5652
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
5591
5653
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
5592
- if (!spec.message) Object.assign(params, (await import("./buttons-YtAj3R_E.js")).buttonsOf(parsed.options));
5654
+ if (!spec.message) Object.assign(params, (await import("./buttons-BO1_7V4L.js")).buttonsOf(parsed.options));
5593
5655
  print(await withSession(g, (s) => {
5594
5656
  if (spec.target === "chat") {
5595
5657
  params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
@@ -5635,7 +5697,7 @@ async function identityAddCommand(argv) {
5635
5697
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
5636
5698
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
5637
5699
  const items = parsed.options.field ?? [];
5638
- const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-BmS02J5h.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5700
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-DY2ixQfU.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5639
5701
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
5640
5702
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
5641
5703
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
@@ -5745,7 +5807,7 @@ async function tableCommand(name, argv) {
5745
5807
  });
5746
5808
  if (translator) {
5747
5809
  try {
5748
- printAnswer(await (await import("./translate-2WyaRVCr.js")).translateAnswer(result, translator));
5810
+ printAnswer(await (await import("./translate-od5GbpvR.js")).translateAnswer(result, translator));
5749
5811
  } finally {
5750
5812
  translator.close();
5751
5813
  }
@@ -5784,7 +5846,9 @@ async function callPipeCommand(argv) {
5784
5846
  }
5785
5847
  /**
5786
5848
  * The command's words when the line asks for help (`help <words>`, or `--help`/`--help=true`/`-h` before any `--`), else
5787
- * null. `--help=false` asks for none: the command runs.
5849
+ * null. `--help=false` asks for none: the command runs. A `-h` or `--help` that is an option's value, as the parser
5850
+ * reads it (`profile set --name --help`, `edit … --text "$NEW"`), asks for none either: it printed the help with exit 0
5851
+ * and changed nothing.
5788
5852
  */
5789
5853
  function helpAsked(argv) {
5790
5854
  const end = argv.indexOf("--");
@@ -5798,9 +5862,29 @@ function helpAsked(argv) {
5798
5862
  return out;
5799
5863
  };
5800
5864
  if (head[0] === "help") return words(head.slice(1));
5801
- if (head.some((word) => word === "--help" || word === "--help=true" || word === "-h")) return words(head);
5865
+ const options = optionsOf(words(head));
5866
+ for (let i = 0; i < head.length; i++) {
5867
+ const word = head[i];
5868
+ if (word === "--help" || word === "--help=true" || word === "-h") return words(head);
5869
+ const option = word.startsWith("--") ? word.includes("=") ? void 0 : options[word.slice(2)] : word.length === 2 && word.startsWith("-") ? Object.values(options).find((o) => o.short === word.slice(1)) : void 0;
5870
+ if (!option || option.type === "boolean") continue;
5871
+ if (option.optionalValue && !(i + 1 < head.length && head[i + 1] !== "" && Number.isFinite(Number(head[i + 1])))) continue;
5872
+ i++;
5873
+ }
5802
5874
  return null;
5803
5875
  }
5876
+ /** The options of the command `words` name (its longest command), with the global ones: what takes a value on its line. */
5877
+ function optionsOf(words) {
5878
+ for (let n = words.length; n > 0; n--) {
5879
+ const asked = words.slice(0, n).join(" ");
5880
+ const row = helpRows().find((r) => commandWords(r.usage).join(" ") === asked);
5881
+ if (row) return {
5882
+ ...GLOBAL_OPTIONS,
5883
+ ...row.options
5884
+ };
5885
+ }
5886
+ return GLOBAL_OPTIONS;
5887
+ }
5804
5888
  /** No profile yet in the Ghostly folder these global options name: `ghostly`'s first run there. */
5805
5889
  function newHome(argv) {
5806
5890
  try {
@@ -5943,4 +6027,4 @@ async function run(argv) {
5943
6027
  //#endregion
5944
6028
  export { run };
5945
6029
 
5946
- //# sourceMappingURL=main-BX4oPWCJ.js.map
6030
+ //# sourceMappingURL=main-BRxhBctJ.js.map