@staff0rd/assist 0.1092.0 → 0.1092.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.1092.0",
9
+ version: "0.1092.2",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -934,6 +934,7 @@ var assistConfigShape = {
934
934
  keyId: z6.string().optional(),
935
935
  issuerId: z6.string().optional(),
936
936
  keyRef: z6.string().optional(),
937
+ account: z6.string().optional(),
937
938
  bundleId: z6.string().optional(),
938
939
  externalGroup: z6.string().optional(),
939
940
  internalGroup: z6.string().optional()
@@ -1898,9 +1899,6 @@ function isExtensionOrigin(origin) {
1898
1899
  return !!origin && EXTENSION_ORIGIN.test(origin);
1899
1900
  }
1900
1901
 
1901
- // src/commands/sessions/web/handleSocket.ts
1902
- import { createInterface } from "readline";
1903
-
1904
1902
  // src/commands/sessions/daemon/links/isLinkCreate.ts
1905
1903
  var CREATE_TYPES = /* @__PURE__ */ new Set([
1906
1904
  "create",
@@ -1954,6 +1952,46 @@ function resolveNodeName() {
1954
1952
  return loadConfig().sessions?.nodeName?.trim() || defaultNodeName();
1955
1953
  }
1956
1954
 
1955
+ // src/commands/sessions/web/forEachCompleteLine.ts
1956
+ import { StringDecoder } from "string_decoder";
1957
+ function forEachCompleteLine(input, onLine, onTruncated) {
1958
+ const decoder = new StringDecoder("utf8");
1959
+ let buffered = "";
1960
+ input.on("data", (chunk2) => {
1961
+ const searchFrom = buffered.length;
1962
+ buffered += typeof chunk2 === "string" ? chunk2 : decoder.write(chunk2);
1963
+ let lineStart = 0;
1964
+ let newline = buffered.indexOf("\n", searchFrom);
1965
+ while (newline !== -1) {
1966
+ const line = buffered.slice(lineStart, newline);
1967
+ onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
1968
+ lineStart = newline + 1;
1969
+ newline = buffered.indexOf("\n", lineStart);
1970
+ }
1971
+ buffered = buffered.slice(lineStart);
1972
+ });
1973
+ const flushTruncated = () => {
1974
+ const partial = buffered + decoder.end();
1975
+ buffered = "";
1976
+ if (partial) onTruncated(partial);
1977
+ };
1978
+ input.on("end", flushTruncated);
1979
+ input.on("close", flushTruncated);
1980
+ }
1981
+
1982
+ // src/commands/sessions/web/withRepoCwd.ts
1983
+ function withRepoCwd(line, repoCwd) {
1984
+ if (!repoCwd) return line;
1985
+ try {
1986
+ const data = JSON.parse(line);
1987
+ if (data.type !== "sessions" || data.cwd) return line;
1988
+ data.cwd = repoCwd;
1989
+ return JSON.stringify(data);
1990
+ } catch {
1991
+ return line;
1992
+ }
1993
+ }
1994
+
1957
1995
  // src/commands/sessions/web/handleSocket.ts
1958
1996
  var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
1959
1997
  function handleSocket(ws, ctx) {
@@ -1982,12 +2020,15 @@ async function openDaemonConnection(ws, ctx) {
1982
2020
  }
1983
2021
  }
1984
2022
  function relayDaemonLines(conn, ws, repoCwd) {
1985
- const lines = createInterface({ input: conn });
1986
- lines.on("error", () => {
1987
- });
1988
- lines.on("line", (line) => {
1989
- if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
1990
- });
2023
+ forEachCompleteLine(
2024
+ conn,
2025
+ (line) => {
2026
+ if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
2027
+ },
2028
+ (partial) => console.log(
2029
+ `ws relay: dropped truncated daemon message (${partial.length} chars) after the daemon connection closed`
2030
+ )
2031
+ );
1991
2032
  conn.on("error", () => {
1992
2033
  });
1993
2034
  conn.on("close", () => ws.close());
@@ -2016,17 +2057,6 @@ function withDefaultCwd(raw, serverCwd) {
2016
2057
  function targetsLinkedNode(data) {
2017
2058
  return resolveLinkTarget(data, resolveNodeName(), () => true).kind !== "local";
2018
2059
  }
2019
- function withRepoCwd(line, repoCwd) {
2020
- if (!repoCwd) return line;
2021
- try {
2022
- const data = JSON.parse(line);
2023
- if (data.type !== "sessions" || data.cwd) return line;
2024
- data.cwd = repoCwd;
2025
- return JSON.stringify(data);
2026
- } catch {
2027
- return line;
2028
- }
2029
- }
2030
2060
 
2031
2061
  // src/commands/sessions/web/isAppOrigin.ts
2032
2062
  var APP_ORIGIN = "capacitor://localhost";
@@ -4679,15 +4709,15 @@ var KIND_LABELS = {
4679
4709
  rejection: "unhandled rejection",
4680
4710
  caught: "caught error"
4681
4711
  };
4682
- function formatClientFailure(failure) {
4683
- if (failure.kind)
4684
- return `client: ${KIND_LABELS[failure.kind]} on ${failure.path}: ${failure.error ?? "unknown error"} at ${failure.at}`;
4685
- const target = failure.node ? `node=${failure.node} via ${failure.base}` : failure.base;
4712
+ function formatClientFailure(failure2) {
4713
+ if (failure2.kind)
4714
+ return `client: ${KIND_LABELS[failure2.kind]} on ${failure2.path}: ${failure2.error ?? "unknown error"} at ${failure2.at}`;
4715
+ const target = failure2.node ? `node=${failure2.node} via ${failure2.base}` : failure2.base;
4686
4716
  const outcome = [
4687
- failure.status === void 0 ? void 0 : `HTTP ${failure.status}`,
4688
- failure.error
4717
+ failure2.status === void 0 ? void 0 : `HTTP ${failure2.status}`,
4718
+ failure2.error
4689
4719
  ].filter(Boolean).join(" ");
4690
- return `client: ${failure.method} ${failure.path} -> ${target} failed: ${outcome || "unknown error"} (${failure.durationMs}ms) at ${failure.at}`;
4720
+ return `client: ${failure2.method} ${failure2.path} -> ${target} failed: ${outcome || "unknown error"} (${failure2.durationMs}ms) at ${failure2.at}`;
4691
4721
  }
4692
4722
  async function clientErrors(req, res) {
4693
4723
  const parsed = clientErrorsSchema.safeParse(
@@ -4697,8 +4727,8 @@ async function clientErrors(req, res) {
4697
4727
  respondJson(res, 400, { error: "Invalid client errors body" });
4698
4728
  return;
4699
4729
  }
4700
- for (const failure of parsed.data.failures)
4701
- console.log(formatClientFailure(failure));
4730
+ for (const failure2 of parsed.data.failures)
4731
+ console.log(formatClientFailure(failure2));
4702
4732
  respondJson(res, 200, { received: parsed.data.failures.length });
4703
4733
  }
4704
4734
 
@@ -5307,7 +5337,7 @@ function recordPromptJournal(entry) {
5307
5337
  }
5308
5338
 
5309
5339
  // src/commands/sessions/daemon/requestDaemonReply.ts
5310
- import { createInterface as createInterface2 } from "readline";
5340
+ import { createInterface } from "readline";
5311
5341
  var QUERY_TIMEOUT_MS = 3e3;
5312
5342
  async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_MS) {
5313
5343
  let socket;
@@ -5323,7 +5353,7 @@ async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_
5323
5353
  resolve34(result);
5324
5354
  };
5325
5355
  const timer = setTimeout(() => finish2(void 0), timeoutMs);
5326
- const lines = createInterface2({ input: socket });
5356
+ const lines = createInterface({ input: socket });
5327
5357
  lines.on("error", () => {
5328
5358
  });
5329
5359
  lines.on("line", (line) => {
@@ -7015,6 +7045,11 @@ var testflightConfigHelp = [
7015
7045
  setter: "assist config set testflight.keyRef op://<vault>/<item>/<field>",
7016
7046
  note: "1Password reference to the API key .p8 (read via op, never stored)"
7017
7047
  },
7048
+ {
7049
+ key: "testflight.account",
7050
+ setter: "assist config set testflight.account my.1password.com",
7051
+ note: "1Password account holding keyRef (default: searches every signed-in account)"
7052
+ },
7018
7053
  {
7019
7054
  key: "testflight.bundleId",
7020
7055
  setter: "assist config set testflight.bundleId com.staff0rd.assist",
@@ -10991,8 +11026,8 @@ function createInboxScanParser(listener = {}) {
10991
11026
  onUsage(usage.current());
10992
11027
  }
10993
11028
  },
10994
- finish(failure) {
10995
- if (!resultLine) throw new Error(`Inbox scan failed: ${failure}`);
11029
+ finish(failure2) {
11030
+ if (!resultLine) throw new Error(`Inbox scan failed: ${failure2}`);
10996
11031
  return {
10997
11032
  messages: parseInboxScanOutput(resultLine),
10998
11033
  usage: usage.current(),
@@ -12748,29 +12783,83 @@ async function findAppId(client, bundleId) {
12748
12783
  return app.id;
12749
12784
  }
12750
12785
 
12751
- // src/commands/testflight/readAscKey.ts
12786
+ // src/commands/testflight/runOp.ts
12752
12787
  import { execFile as execFile9 } from "child_process";
12753
12788
  import { promisify as promisify10 } from "util";
12789
+
12790
+ // src/commands/testflight/cleanOpStderr.ts
12791
+ var wslWrapperNoise = [
12792
+ /^'\\\\wsl[.$]/i,
12793
+ /^CMD\.EXE was started with the above path/i,
12794
+ /^UNC paths are not supported/i
12795
+ ];
12796
+ function cleanOpStderr(stderr) {
12797
+ return stderr.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !wslWrapperNoise.some((re) => re.test(line))).join("\n");
12798
+ }
12799
+
12800
+ // src/commands/testflight/runOp.ts
12754
12801
  var run = promisify10(execFile9);
12755
- async function readAscKey(reference) {
12756
- if (!reference.startsWith("op://"))
12757
- throw new TestflightError(
12758
- "testflight.keyRef must be a 1Password reference starting with op://"
12759
- );
12802
+ var runOp = async (args) => {
12760
12803
  try {
12761
- const { stdout } = await run("op", ["read", reference]);
12762
- return stdout.trim();
12804
+ const { stdout } = await run("op", args, { maxBuffer: 10 * 1024 * 1024 });
12805
+ return { ok: true, stdout };
12763
12806
  } catch (error) {
12764
- const reason4 = error.stderr?.trim() || (error instanceof Error ? error.message : String(error));
12807
+ const { code, stderr } = error;
12808
+ if (code === "ENOENT")
12809
+ return {
12810
+ ok: false,
12811
+ error: "the 1Password CLI (op) is not installed or not on PATH",
12812
+ missing: false
12813
+ };
12814
+ const reason4 = cleanOpStderr(stderr ?? "") || (error instanceof Error ? error.message : String(error));
12815
+ return {
12816
+ ok: false,
12817
+ error: reason4,
12818
+ missing: /isn't an item|isn't a vault/i.test(reason4)
12819
+ };
12820
+ }
12821
+ };
12822
+
12823
+ // src/commands/testflight/readAscKey.ts
12824
+ async function listAccounts(op) {
12825
+ const result = await op(["account", "list", "--format", "json"]);
12826
+ if (!result.ok) return [];
12827
+ const accounts = JSON.parse(result.stdout);
12828
+ return accounts.map((account) => account.url);
12829
+ }
12830
+ function failure(reason4) {
12831
+ return new TestflightError(
12832
+ `Failed to read testflight.keyRef from 1Password: ${reason4}`
12833
+ );
12834
+ }
12835
+ async function readAscKey(reference, account, op = runOp) {
12836
+ if (!reference.startsWith("op://"))
12765
12837
  throw new TestflightError(
12766
- `Failed to read testflight.keyRef from 1Password (is op installed and signed in?): ${reason4}`
12838
+ "testflight.keyRef must be a 1Password reference starting with op://"
12767
12839
  );
12840
+ const accountArgs = account ? ["--account", account] : [];
12841
+ const first = await op(["read", ...accountArgs, reference]);
12842
+ if (first.ok) return first.stdout.trim();
12843
+ if (account || !first.missing) throw failure(first.error);
12844
+ const accounts = await listAccounts(op);
12845
+ for (const url of accounts) {
12846
+ const result = await op(["read", "--account", url, reference]);
12847
+ if (result.ok) return result.stdout.trim();
12848
+ if (!result.missing) throw failure(`${url}: ${result.error}`);
12768
12849
  }
12850
+ const searched = accounts.length ? ` (searched ${accounts.join(", ")})` : "";
12851
+ throw failure(
12852
+ `${first.error}
12853
+ The item was not found in any signed-in 1Password account${searched}. Set the account holding it with: assist config set testflight.account <account>`
12854
+ );
12769
12855
  }
12770
12856
 
12771
12857
  // src/commands/testflight/connectAsc.ts
12772
12858
  async function connectAsc(config, options2 = {}) {
12773
- const privateKey = await (options2.readKey ?? readAscKey)(config.keyRef);
12859
+ const privateKey = await (options2.readKey ?? readAscKey)(
12860
+ config.keyRef,
12861
+ config.account
12862
+ );
12774
12863
  const token = createAscToken({
12775
12864
  keyId: config.keyId,
12776
12865
  issuerId: config.issuerId,
@@ -14698,7 +14787,7 @@ function installRestartMenu(options2 = {}) {
14698
14787
  }
14699
14788
 
14700
14789
  // src/commands/sessions/web/streamDaemonLogs.ts
14701
- import { createInterface as createInterface4 } from "readline";
14790
+ import { createInterface as createInterface3 } from "readline";
14702
14791
  var RECONNECT_MS = 3e3;
14703
14792
  function streamDaemonLogs() {
14704
14793
  void connect2();
@@ -14717,7 +14806,7 @@ async function connect2() {
14717
14806
  }
14718
14807
  }
14719
14808
  function wire(socket) {
14720
- const lines = createInterface4({ input: socket });
14809
+ const lines = createInterface3({ input: socket });
14721
14810
  lines.on("error", () => {
14722
14811
  });
14723
14812
  lines.on("line", emit);
@@ -18943,8 +19032,8 @@ function validateDump({ header, sections }) {
18943
19032
  [tables.length > 0, "Dump header lists no tables; cannot restore."],
18944
19033
  [!missing, `Invalid dump: missing data section for "${missing}".`]
18945
19034
  ];
18946
- const failure = checks2.find(([ok]) => !ok);
18947
- if (failure) throw new Error(failure[1]);
19035
+ const failure2 = checks2.find(([ok]) => !ok);
19036
+ if (failure2) throw new Error(failure2[1]);
18948
19037
  }
18949
19038
 
18950
19039
  // src/commands/backlog/import/confirmReplace.ts
@@ -37952,8 +38041,8 @@ function printPrsStatus(report) {
37952
38041
  }
37953
38042
  if (report.errors.length === 0) return;
37954
38043
  console.log(chalk212.bold("Errors"));
37955
- for (const failure of report.errors) {
37956
- console.log(` ${chalk212.red(failure.repo)}: ${failure.error}`);
38044
+ for (const failure2 of report.errors) {
38045
+ console.log(` ${chalk212.red(failure2.repo)}: ${failure2.error}`);
37957
38046
  }
37958
38047
  console.log();
37959
38048
  }
@@ -50730,7 +50819,7 @@ function listDaemonPids() {
50730
50819
  }
50731
50820
 
50732
50821
  // src/commands/sessions/daemon/queryDaemon.ts
50733
- import { createInterface as createInterface8 } from "readline";
50822
+ import { createInterface as createInterface7 } from "readline";
50734
50823
  var STATUS_TIMEOUT_MS2 = 5e3;
50735
50824
  function queryDaemon(socket) {
50736
50825
  socket.write(`${JSON.stringify({ type: "ping" })}
@@ -50739,7 +50828,7 @@ function queryDaemon(socket) {
50739
50828
  const result = { sessions: [] };
50740
50829
  const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
50741
50830
  const timer = setTimeout(() => resolve34(result), STATUS_TIMEOUT_MS2);
50742
- const lines = createInterface8({ input: socket });
50831
+ const lines = createInterface7({ input: socket });
50743
50832
  lines.on("error", () => {
50744
50833
  });
50745
50834
  lines.on("line", (line) => {
@@ -50833,7 +50922,7 @@ function reportStrays(pids) {
50833
50922
  }
50834
50923
 
50835
50924
  // src/commands/sessions/daemon/drainDaemon.ts
50836
- import { createInterface as createInterface9 } from "readline";
50925
+ import { createInterface as createInterface8 } from "readline";
50837
50926
 
50838
50927
  // src/commands/sessions/daemon/clearPersistedSessionsOnDrain.ts
50839
50928
  function clearPersistedSessionsOnDrain() {
@@ -50875,7 +50964,7 @@ async function drainDaemon(options2 = {}) {
50875
50964
  clearPersistedSessionsOnDrain();
50876
50965
  return;
50877
50966
  }
50878
- const lines = createInterface9({ input: socket });
50967
+ const lines = createInterface8({ input: socket });
50879
50968
  lines.on("error", () => {
50880
50969
  });
50881
50970
  const live = await liveSessions(lines);
@@ -53032,11 +53121,11 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
53032
53121
  retryDelay: 200
53033
53122
  });
53034
53123
  } catch (error) {
53035
- const failure = deleteFailure(worktreePath, error);
53124
+ const failure2 = deleteFailure(worktreePath, error);
53036
53125
  daemonLog(
53037
- `worktree ${worktreePath} directory delete failed, left in place for the next reconcile: ${failure}`
53126
+ `worktree ${worktreePath} directory delete failed, left in place for the next reconcile: ${failure2}`
53038
53127
  );
53039
- return { removed: false, reason: failure };
53128
+ return { removed: false, reason: failure2 };
53040
53129
  }
53041
53130
  daemonLog(`worktree ${worktreePath} directory deleted directly`);
53042
53131
  await pruneBookkeeping(clone, worktreePath);
@@ -58547,7 +58636,7 @@ function exitAfterFlush(code) {
58547
58636
  }
58548
58637
 
58549
58638
  // src/commands/sessions/daemon/handleConnection.ts
58550
- import { createInterface as createInterface11 } from "readline";
58639
+ import { createInterface as createInterface10 } from "readline";
58551
58640
 
58552
58641
  // src/commands/sessions/daemon/routed.ts
58553
58642
  function routed(local) {
@@ -59811,7 +59900,7 @@ function handleConnection(socket, manager) {
59811
59900
  };
59812
59901
  manager.addClient(client);
59813
59902
  manager.clients.greet(client);
59814
- const lines = createInterface11({ input: socket });
59903
+ const lines = createInterface10({ input: socket });
59815
59904
  lines.on("error", () => {
59816
59905
  });
59817
59906
  lines.on("line", (line) => {
@@ -60462,14 +60551,14 @@ function registerNodes(sessions) {
60462
60551
  }
60463
60552
 
60464
60553
  // src/commands/sessions/daemon/requestSessionOutput.ts
60465
- import { createInterface as createInterface12 } from "readline";
60554
+ import { createInterface as createInterface11 } from "readline";
60466
60555
  var OUTPUT_TIMEOUT_MS = 5e3;
60467
60556
  async function requestSessionOutput(target) {
60468
60557
  const socket = await connectToDaemon().catch(() => {
60469
60558
  throw new Error("No sessions daemon is running");
60470
60559
  });
60471
60560
  try {
60472
- const lines = createInterface12({ input: socket });
60561
+ const lines = createInterface11({ input: socket });
60473
60562
  lines.on("error", () => {
60474
60563
  });
60475
60564
  const reply2 = readDaemonMessage(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1092.0",
3
+ "version": "0.1092.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {