@profullstack/qryptchat 0.6.2 → 0.6.4

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/bin/qc.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  // qc: qrypt.chat in the terminal. `qc` opens the chat client; `qc --help` lists the rest.
3
3
  import { readFileSync } from 'node:fs';
4
- import { errorLine, main } from '../dist/commands.js';
4
+ import { errorLine, exitWhenFlushed, main } from '../dist/commands.js';
5
5
 
6
6
  const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
7
7
 
8
8
  main(process.argv.slice(2), { version: pkg.version }).then(
9
- () => process.exit(0),
9
+ () => exitWhenFlushed(0),
10
10
  (err) => {
11
11
  process.stderr.write(`${errorLine(err)}\n`);
12
- process.exit(1);
12
+ exitWhenFlushed(1);
13
13
  },
14
14
  );
@@ -0,0 +1,71 @@
1
+ // src/cli/update.js
2
+ import { spawn } from "node:child_process";
3
+ import { realpathSync } from "node:fs";
4
+ var PACKAGE = "@profullstack/qryptchat";
5
+ function compareVersions(a, b) {
6
+ const parse = (v) => {
7
+ const [core, pre = ""] = String(v).replace(/^v/, "").split("-");
8
+ return { nums: core.split(".").map((n) => Number.parseInt(n, 10) || 0), pre };
9
+ };
10
+ const x = parse(a);
11
+ const y = parse(b);
12
+ for (let i = 0;i < 3; i++) {
13
+ const d = (x.nums[i] ?? 0) - (y.nums[i] ?? 0);
14
+ if (d)
15
+ return Math.sign(d);
16
+ }
17
+ if (x.pre === y.pre)
18
+ return 0;
19
+ if (!x.pre)
20
+ return 1;
21
+ if (!y.pre)
22
+ return -1;
23
+ return x.pre < y.pre ? -1 : 1;
24
+ }
25
+ function installCommand(binPath = "") {
26
+ const p = binPath.replaceAll("\\", "/");
27
+ const spec = `${PACKAGE}@latest`;
28
+ if (p.includes("/_npx/"))
29
+ return { npx: true };
30
+ if (p.includes("/.bun/"))
31
+ return { cmd: "bun", args: ["add", "-g", spec] };
32
+ if (p.includes("/pnpm/"))
33
+ return { cmd: "pnpm", args: ["add", "-g", spec] };
34
+ return { cmd: "npm", args: ["install", "-g", spec] };
35
+ }
36
+ async function latestVersion(fetchImpl = fetch) {
37
+ const res = await fetchImpl(`https://registry.npmjs.org/${PACKAGE}/latest`, { headers: { accept: "application/json" } });
38
+ if (!res.ok)
39
+ throw new Error(`Could not reach the npm registry (HTTP ${res.status}).`);
40
+ const { version } = await res.json();
41
+ if (!version)
42
+ throw new Error("The npm registry did not say which version is latest.");
43
+ return version;
44
+ }
45
+ function run(cmd, args) {
46
+ return new Promise((resolve, reject) => {
47
+ const child = spawn(cmd, args, { stdio: "inherit", shell: process.platform === "win32" });
48
+ child.on("error", (err) => reject(new Error(`Could not run ${cmd}: ${err.message}`)));
49
+ child.on("exit", (code) => code === 0 ? resolve() : reject(new Error(`${cmd} ${args.join(" ")} exited with ${code}.`)));
50
+ });
51
+ }
52
+ async function update({ current, check = false, binPath = process.argv[1], fetchImpl = fetch, runImpl = run }) {
53
+ const latest = await latestVersion(fetchImpl);
54
+ if (compareVersions(latest, current) <= 0)
55
+ return { updated: false, line: `qc ${current} is the latest.` };
56
+ let real = binPath || "";
57
+ try {
58
+ real = realpathSync(real);
59
+ } catch {}
60
+ const how = installCommand(real);
61
+ if (how.npx)
62
+ return { updated: false, line: `qc ${latest} is out (you have ${current}). Run: npx ${PACKAGE}@latest` };
63
+ const command = `${how.cmd} ${how.args.join(" ")}`;
64
+ if (check)
65
+ return { updated: false, line: `qc ${latest} is out (you have ${current}). Update with: qc update (runs ${command})` };
66
+ await runImpl(how.cmd, how.args);
67
+ return { updated: true, line: `qc ${current} -> ${latest}.` };
68
+ }
69
+ export {
70
+ update
71
+ };
@@ -1157,6 +1157,12 @@ function who(user, { agent = false } = {}) {
1157
1157
  return `${face}${name}${handle}${pronouns}`;
1158
1158
  }
1159
1159
 
1160
+ // src/cli/exit.js
1161
+ function exitWhenFlushed2(code, { timeoutMs = 30000 } = {}) {
1162
+ setTimeout(() => process.exit(code), timeoutMs);
1163
+ process.stdout.end(() => process.stderr.end(() => process.exit(code)));
1164
+ }
1165
+
1160
1166
  // src/cli/commands.js
1161
1167
  var errorLine2 = (err) => `qc: ${fail(err?.message ?? String(err))}`;
1162
1168
  var HELP2 = `qc: qrypt.chat in your terminal (end-to-end encrypted, ML-KEM-1024)
@@ -1167,6 +1173,7 @@ Usage:
1167
1173
  qc agent join <link> join as an AI agent from an invite (makes its own keys) [--name --username]
1168
1174
  qc login [--oob] sign in through your browser; --oob to paste a code (SSH)
1169
1175
  qc logout forget this terminal's session and keys
1176
+ qc update [--check] update qc to the latest release (--check only says whether there is one)
1170
1177
  qc whoami who this terminal is signed in as
1171
1178
  qc profile [--emoji \uD83D\uDD2D] [--pronouns she/her] [--website URL] [--bio TEXT]
1172
1179
  show or set your public profile (an empty value clears it);
@@ -1433,6 +1440,12 @@ ${info("Set: qc profile --emoji :telescope: --pronouns she/her --website https:/
1433
1440
  `) });
1434
1441
  return;
1435
1442
  }
1443
+ case "update":
1444
+ case "upgrade": {
1445
+ const { update } = await import("./chunk-1499e56f.js");
1446
+ const r = await update({ current: version, check: Boolean(flags.check) });
1447
+ return out(r.updated ? ok(r.line) : info(r.line));
1448
+ }
1436
1449
  case "mcp": {
1437
1450
  const { serveMcp } = await import("./mcp.js");
1438
1451
  return serveMcp(await client(flags), { version });
@@ -1444,4 +1457,4 @@ ${HELP2}`);
1444
1457
  }
1445
1458
  }
1446
1459
 
1447
- export { errorLine2, HELP2, parseArgs2, findChat2, main2 };
1460
+ export { exitWhenFlushed2, errorLine2, HELP2, parseArgs2, findChat2, main2 };
package/dist/commands.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import {
2
+ exitWhenFlushed2,
2
3
  errorLine2,
3
4
  HELP2,
4
5
  parseArgs2,
5
6
  findChat2,
6
7
  main2
7
- } from "./chunk-s0qccr26.js";
8
+ } from "./chunk-7fw9y4pv.js";
8
9
  import"./chunk-g9xn5036.js";
9
10
  export {
10
11
  HELP2 as HELP,
11
12
  errorLine2 as errorLine,
13
+ exitWhenFlushed2 as exitWhenFlushed,
12
14
  findChat2 as findChat,
13
15
  main2 as main,
14
16
  parseArgs2 as parseArgs
package/dist/mcp.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import"./chunk-g9xn5036.js";
2
2
  import {
3
3
  findChat2
4
- } from "./chunk-s0qccr26.js";
4
+ } from "./chunk-7fw9y4pv.js";
5
5
 
6
6
  // src/cli/mcp.js
7
7
  import { createInterface } from "node:readline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/qryptchat",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "qc: qrypt.chat in your terminal. A full-screen end-to-end encrypted chat client (ML-KEM-1024), plus a scriptable CLI and an MCP server.",
5
5
  "type": "module",
6
6
  "bin": {