@staff0rd/assist 0.1092.1 → 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.1",
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()
@@ -4708,15 +4709,15 @@ var KIND_LABELS = {
4708
4709
  rejection: "unhandled rejection",
4709
4710
  caught: "caught error"
4710
4711
  };
4711
- function formatClientFailure(failure) {
4712
- if (failure.kind)
4713
- return `client: ${KIND_LABELS[failure.kind]} on ${failure.path}: ${failure.error ?? "unknown error"} at ${failure.at}`;
4714
- 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;
4715
4716
  const outcome = [
4716
- failure.status === void 0 ? void 0 : `HTTP ${failure.status}`,
4717
- failure.error
4717
+ failure2.status === void 0 ? void 0 : `HTTP ${failure2.status}`,
4718
+ failure2.error
4718
4719
  ].filter(Boolean).join(" ");
4719
- 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}`;
4720
4721
  }
4721
4722
  async function clientErrors(req, res) {
4722
4723
  const parsed = clientErrorsSchema.safeParse(
@@ -4726,8 +4727,8 @@ async function clientErrors(req, res) {
4726
4727
  respondJson(res, 400, { error: "Invalid client errors body" });
4727
4728
  return;
4728
4729
  }
4729
- for (const failure of parsed.data.failures)
4730
- console.log(formatClientFailure(failure));
4730
+ for (const failure2 of parsed.data.failures)
4731
+ console.log(formatClientFailure(failure2));
4731
4732
  respondJson(res, 200, { received: parsed.data.failures.length });
4732
4733
  }
4733
4734
 
@@ -7044,6 +7045,11 @@ var testflightConfigHelp = [
7044
7045
  setter: "assist config set testflight.keyRef op://<vault>/<item>/<field>",
7045
7046
  note: "1Password reference to the API key .p8 (read via op, never stored)"
7046
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
+ },
7047
7053
  {
7048
7054
  key: "testflight.bundleId",
7049
7055
  setter: "assist config set testflight.bundleId com.staff0rd.assist",
@@ -11020,8 +11026,8 @@ function createInboxScanParser(listener = {}) {
11020
11026
  onUsage(usage.current());
11021
11027
  }
11022
11028
  },
11023
- finish(failure) {
11024
- if (!resultLine) throw new Error(`Inbox scan failed: ${failure}`);
11029
+ finish(failure2) {
11030
+ if (!resultLine) throw new Error(`Inbox scan failed: ${failure2}`);
11025
11031
  return {
11026
11032
  messages: parseInboxScanOutput(resultLine),
11027
11033
  usage: usage.current(),
@@ -12777,29 +12783,83 @@ async function findAppId(client, bundleId) {
12777
12783
  return app.id;
12778
12784
  }
12779
12785
 
12780
- // src/commands/testflight/readAscKey.ts
12786
+ // src/commands/testflight/runOp.ts
12781
12787
  import { execFile as execFile9 } from "child_process";
12782
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
12783
12801
  var run = promisify10(execFile9);
12784
- async function readAscKey(reference) {
12785
- if (!reference.startsWith("op://"))
12786
- throw new TestflightError(
12787
- "testflight.keyRef must be a 1Password reference starting with op://"
12788
- );
12802
+ var runOp = async (args) => {
12789
12803
  try {
12790
- const { stdout } = await run("op", ["read", reference]);
12791
- return stdout.trim();
12804
+ const { stdout } = await run("op", args, { maxBuffer: 10 * 1024 * 1024 });
12805
+ return { ok: true, stdout };
12792
12806
  } catch (error) {
12793
- 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://"))
12794
12837
  throw new TestflightError(
12795
- `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://"
12796
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}`);
12797
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
+ );
12798
12855
  }
12799
12856
 
12800
12857
  // src/commands/testflight/connectAsc.ts
12801
12858
  async function connectAsc(config, options2 = {}) {
12802
- const privateKey = await (options2.readKey ?? readAscKey)(config.keyRef);
12859
+ const privateKey = await (options2.readKey ?? readAscKey)(
12860
+ config.keyRef,
12861
+ config.account
12862
+ );
12803
12863
  const token = createAscToken({
12804
12864
  keyId: config.keyId,
12805
12865
  issuerId: config.issuerId,
@@ -18972,8 +19032,8 @@ function validateDump({ header, sections }) {
18972
19032
  [tables.length > 0, "Dump header lists no tables; cannot restore."],
18973
19033
  [!missing, `Invalid dump: missing data section for "${missing}".`]
18974
19034
  ];
18975
- const failure = checks2.find(([ok]) => !ok);
18976
- if (failure) throw new Error(failure[1]);
19035
+ const failure2 = checks2.find(([ok]) => !ok);
19036
+ if (failure2) throw new Error(failure2[1]);
18977
19037
  }
18978
19038
 
18979
19039
  // src/commands/backlog/import/confirmReplace.ts
@@ -37981,8 +38041,8 @@ function printPrsStatus(report) {
37981
38041
  }
37982
38042
  if (report.errors.length === 0) return;
37983
38043
  console.log(chalk212.bold("Errors"));
37984
- for (const failure of report.errors) {
37985
- console.log(` ${chalk212.red(failure.repo)}: ${failure.error}`);
38044
+ for (const failure2 of report.errors) {
38045
+ console.log(` ${chalk212.red(failure2.repo)}: ${failure2.error}`);
37986
38046
  }
37987
38047
  console.log();
37988
38048
  }
@@ -53061,11 +53121,11 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
53061
53121
  retryDelay: 200
53062
53122
  });
53063
53123
  } catch (error) {
53064
- const failure = deleteFailure(worktreePath, error);
53124
+ const failure2 = deleteFailure(worktreePath, error);
53065
53125
  daemonLog(
53066
- `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}`
53067
53127
  );
53068
- return { removed: false, reason: failure };
53128
+ return { removed: false, reason: failure2 };
53069
53129
  }
53070
53130
  daemonLog(`worktree ${worktreePath} directory deleted directly`);
53071
53131
  await pruneBookkeeping(clone, worktreePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1092.1",
3
+ "version": "0.1092.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {