threadnote 1.1.3 → 1.1.5

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.
@@ -33081,7 +33081,6 @@ var StreamableHTTPClientTransport = class {
33081
33081
 
33082
33082
  // src/mcp_server.ts
33083
33083
  var import_promises5 = require("node:fs/promises");
33084
- var import_node_os3 = require("node:os");
33085
33084
  var import_node_path5 = require("node:path");
33086
33085
 
33087
33086
  // src/constants.ts
@@ -35724,6 +35723,7 @@ var jsYaml = {
35724
35723
  // src/utils.ts
35725
35724
  var import_node_child_process = require("node:child_process");
35726
35725
  var import_node_crypto = require("node:crypto");
35726
+ var import_node_fs = require("node:fs");
35727
35727
  var import_promises = require("node:fs/promises");
35728
35728
  var import_node_os = require("node:os");
35729
35729
  var import_node_path = require("node:path");
@@ -35778,18 +35778,57 @@ function redactText(content) {
35778
35778
  ).replace(/Bearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [REDACTED]").replace(/sk-[A-Za-z0-9_-]{16,}/g, "sk-[REDACTED]").replace(/gh[pousr]_[A-Za-z0-9_]{16,}/g, "gh_[REDACTED]");
35779
35779
  }
35780
35780
  async function requiredOpenVikingCli() {
35781
- const command2 = await findExecutable(["ov", "openviking"]);
35781
+ const command2 = await findOpenVikingCli();
35782
35782
  if (!command2) {
35783
- throw new Error("Neither ov nor openviking was found in PATH. Run threadnote install first.");
35783
+ throw new Error(
35784
+ "Neither ov nor openviking was found in PATH, uv tool bin dir, $UV_TOOL_BIN_DIR, or ~/.local/bin. Run threadnote install first."
35785
+ );
35784
35786
  }
35785
35787
  return command2;
35786
35788
  }
35787
35789
  async function openVikingCliForMode(dryRun) {
35788
35790
  if (dryRun) {
35789
- return await findExecutable(["ov", "openviking"]) ?? "ov";
35791
+ return await findOpenVikingCli() ?? "ov";
35790
35792
  }
35791
35793
  return requiredOpenVikingCli();
35792
35794
  }
35795
+ async function findOpenVikingCli() {
35796
+ const override = process.env.THREADNOTE_OV?.trim();
35797
+ if (override) {
35798
+ return override;
35799
+ }
35800
+ const onPath = await findExecutable(["ov", "openviking"]);
35801
+ if (onPath) {
35802
+ return onPath;
35803
+ }
35804
+ for (const candidateDir of await openVikingToolCandidateDirs()) {
35805
+ for (const command2 of ["ov", "openviking"]) {
35806
+ const candidate = (0, import_node_path.join)(candidateDir, command2);
35807
+ if (await isExecutable(candidate)) {
35808
+ return candidate;
35809
+ }
35810
+ }
35811
+ }
35812
+ return void 0;
35813
+ }
35814
+ async function openVikingToolCandidateDirs() {
35815
+ const dirs = [];
35816
+ const uv = await findExecutable(["uv"]);
35817
+ if (uv) {
35818
+ const result = await runCommand(uv, ["tool", "dir", "--bin"], { allowFailure: true });
35819
+ if (result.exitCode === 0) {
35820
+ const dir = result.stdout.trim();
35821
+ if (dir) {
35822
+ dirs.push(dir);
35823
+ }
35824
+ }
35825
+ }
35826
+ if (process.env.UV_TOOL_BIN_DIR) {
35827
+ dirs.push(process.env.UV_TOOL_BIN_DIR);
35828
+ }
35829
+ dirs.push((0, import_node_path.join)((0, import_node_os.homedir)(), ".local", "bin"));
35830
+ return Array.from(new Set(dirs));
35831
+ }
35793
35832
  async function requiredExecutable(command2) {
35794
35833
  const executable = await findExecutable([command2]);
35795
35834
  if (!executable) {
@@ -35946,6 +35985,14 @@ async function exists(path) {
35946
35985
  return false;
35947
35986
  }
35948
35987
  }
35988
+ async function isExecutable(path) {
35989
+ try {
35990
+ await (0, import_promises.access)(path, import_node_fs.constants.X_OK);
35991
+ return true;
35992
+ } catch (_err) {
35993
+ return false;
35994
+ }
35995
+ }
35949
35996
  async function isFile(path) {
35950
35997
  try {
35951
35998
  return (await (0, import_promises.stat)(path)).isFile();
@@ -40006,23 +40053,12 @@ function withIdentity2(config2, args) {
40006
40053
  return [...args, "--account", config2.account, "--user", config2.user, "--agent-id", config2.agentId];
40007
40054
  }
40008
40055
  async function requiredOpenVikingCli2() {
40009
- const command2 = process.env.THREADNOTE_OV ?? await findExecutable(["ov", "openviking"]) ?? await firstExistingPath([(0, import_node_path5.join)((0, import_node_os3.homedir)(), ".local", "bin", "ov"), (0, import_node_path5.join)((0, import_node_os3.homedir)(), ".local", "bin", "openviking")]);
40056
+ const command2 = await findOpenVikingCli();
40010
40057
  if (!command2) {
40011
40058
  throw new Error("Neither ov nor openviking was found. Run threadnote install first.");
40012
40059
  }
40013
40060
  return command2;
40014
40061
  }
40015
- async function firstExistingPath(paths) {
40016
- for (const path of paths) {
40017
- try {
40018
- await (0, import_promises5.access)(path);
40019
- return await (0, import_promises5.realpath)(path);
40020
- } catch (_err) {
40021
- continue;
40022
- }
40023
- }
40024
- return void 0;
40025
- }
40026
40062
  main().catch((err) => {
40027
40063
  process.stderr.write(`${errorMessage(err)}
40028
40064
  `);