@todoforai/cli 0.1.7 → 0.1.8

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 (2) hide show
  1. package/dist/todoai.js +83 -20
  2. package/package.json +1 -1
package/dist/todoai.js CHANGED
@@ -41805,15 +41805,15 @@ var require_route = __commonJS((exports, module) => {
41805
41805
  };
41806
41806
  }
41807
41807
  function wrapConversion(toModel, graph) {
41808
- const path2 = [graph[toModel].parent, toModel];
41808
+ const path3 = [graph[toModel].parent, toModel];
41809
41809
  let fn = conversions[graph[toModel].parent][toModel];
41810
41810
  let cur = graph[toModel].parent;
41811
41811
  while (graph[cur].parent) {
41812
- path2.unshift(graph[cur].parent);
41812
+ path3.unshift(graph[cur].parent);
41813
41813
  fn = link(conversions[graph[cur].parent][cur], fn);
41814
41814
  cur = graph[cur].parent;
41815
41815
  }
41816
- fn.conversion = path2;
41816
+ fn.conversion = path3;
41817
41817
  return fn;
41818
41818
  }
41819
41819
  module.exports = function(fromModel) {
@@ -42039,7 +42039,7 @@ var require_has_flag = __commonJS((exports, module) => {
42039
42039
 
42040
42040
  // node_modules/supports-color/index.js
42041
42041
  var require_supports_color = __commonJS((exports, module) => {
42042
- var os2 = __require("os");
42042
+ var os3 = __require("os");
42043
42043
  var tty = __require("tty");
42044
42044
  var hasFlag = require_has_flag();
42045
42045
  var { env } = process;
@@ -42087,7 +42087,7 @@ var require_supports_color = __commonJS((exports, module) => {
42087
42087
  return min;
42088
42088
  }
42089
42089
  if (process.platform === "win32") {
42090
- const osRelease = os2.release().split(".");
42090
+ const osRelease = os3.release().split(".");
42091
42091
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
42092
42092
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
42093
42093
  }
@@ -42661,9 +42661,55 @@ var require_dist = __commonJS((exports) => {
42661
42661
  });
42662
42662
 
42663
42663
  // src/index.ts
42664
- import { realpathSync } from "fs";
42664
+ import { realpathSync, readFileSync as readFileSync3 } from "fs";
42665
42665
  import { resolve as resolve3 } from "path";
42666
+ import { fileURLToPath } from "url";
42666
42667
  import { homedir as homedir3 } from "os";
42668
+ import path4 from "path";
42669
+
42670
+ // src/update-notifier.ts
42671
+ import fs from "fs";
42672
+ import path from "path";
42673
+ import os from "os";
42674
+ var TTL_MS = 24 * 60 * 60 * 1000;
42675
+ var CACHE_DIR = path.join(os.homedir(), ".config", "todoforai");
42676
+ function cmpVer(a, b) {
42677
+ const pa = a.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
42678
+ const pb = b.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
42679
+ for (let i = 0;i < Math.max(pa.length, pb.length); i++) {
42680
+ const d = (pa[i] ?? 0) - (pb[i] ?? 0);
42681
+ if (d)
42682
+ return d;
42683
+ }
42684
+ return 0;
42685
+ }
42686
+ function checkForUpdates(pkg) {
42687
+ if (!process.stderr.isTTY || process.env.CI || process.env.NO_UPDATE_NOTIFIER)
42688
+ return;
42689
+ const cacheFile = path.join(CACHE_DIR, `notifier-${encodeURIComponent(pkg.name)}.json`);
42690
+ let cache = {};
42691
+ try {
42692
+ cache = JSON.parse(fs.readFileSync(cacheFile, "utf8"));
42693
+ } catch {}
42694
+ if (cache.latest && cmpVer(cache.latest, pkg.version) > 0) {
42695
+ process.stderr.write(`
42696
+ \x1B[33m Update available: \x1B[2m${pkg.version}\x1B[22m \u2192 \x1B[1m${cache.latest}\x1B[0m
42697
+ ` + `\x1B[33m Run:\x1B[0m npm i -g ${pkg.name}
42698
+
42699
+ `);
42700
+ }
42701
+ if (Date.now() - (cache.ts ?? 0) > TTL_MS) {
42702
+ try {
42703
+ fs.mkdirSync(CACHE_DIR, { recursive: true });
42704
+ fs.writeFileSync(cacheFile, JSON.stringify({ ...cache, ts: Date.now() }));
42705
+ } catch {}
42706
+ fetch(`https://registry.npmjs.org/${pkg.name}/latest`, { signal: AbortSignal.timeout(3000) }).then((r) => r.ok ? r.json() : null).then((j) => {
42707
+ if (!j?.version)
42708
+ return;
42709
+ fs.writeFileSync(cacheFile, JSON.stringify({ ts: Date.now(), latest: j.version }));
42710
+ }).catch(() => {});
42711
+ }
42712
+ }
42667
42713
 
42668
42714
  // src/tips.ts
42669
42715
  var TIPS = [
@@ -42830,8 +42876,8 @@ class ApiClient {
42830
42876
  import WebSocket from "ws";
42831
42877
 
42832
42878
  // ../edge/bun/src/config.ts
42833
- import path from "path";
42834
- import os from "os";
42879
+ import path2 from "path";
42880
+ import os2 from "os";
42835
42881
  function normalizeApiUrl(url) {
42836
42882
  if (url.startsWith("localhost"))
42837
42883
  return `http://${url}`;
@@ -42840,7 +42886,19 @@ function normalizeApiUrl(url) {
42840
42886
  return url;
42841
42887
  }
42842
42888
  var SUBCOMMANDS = new Set(["login", "logout"]);
42843
- var CREDENTIALS_PATH = path.join(os.homedir(), ".todoforai", "credentials.json");
42889
+ function credentialsPath() {
42890
+ const sys = os2.platform();
42891
+ if (sys === "win32") {
42892
+ return path2.join(os2.homedir(), "AppData", "Roaming", "todoforai", "credentials.json");
42893
+ }
42894
+ if (sys === "darwin") {
42895
+ return path2.join(os2.homedir(), "Library", "Application Support", "todoforai", "credentials.json");
42896
+ }
42897
+ const xdg = process.env.XDG_CONFIG_HOME || path2.join(os2.homedir(), ".config");
42898
+ return path2.join(xdg, "todoforai", "credentials.json");
42899
+ }
42900
+ var CREDENTIALS_PATH = credentialsPath();
42901
+ var LEGACY_CREDENTIALS_PATH = path2.join(os2.homedir(), ".todoforai", "credentials.json");
42844
42902
 
42845
42903
  // ../edge/bun/src/frontend-ws.ts
42846
42904
  var log = (level, ...args) => console.log(`[frontend-ws:${level}]`, ...args);
@@ -44942,9 +45000,9 @@ async function listAgentsCommand(api, opts) {
44942
45000
 
44943
45001
  // src/ensure-edge.ts
44944
45002
  import { spawn, spawnSync } from "child_process";
44945
- import fs from "fs";
44946
- import path2 from "path";
44947
- import os2 from "os";
45003
+ import fs2 from "fs";
45004
+ import path3 from "path";
45005
+ import os3 from "os";
44948
45006
  function hasBunx() {
44949
45007
  const probe = spawnSync(process.platform === "win32" ? "where" : "which", ["bunx"], { stdio: "ignore" });
44950
45008
  return probe.status === 0;
@@ -44954,10 +45012,10 @@ function ensureEdgeRunning(apiUrl, apiKey) {
44954
45012
  console.error("\x1B[2mEdge daemon not started: `bunx` is missing. Install Bun from https://bun.sh to enable it, or pass --no-edge to silence this.\x1B[0m");
44955
45013
  return;
44956
45014
  }
44957
- const logDir = path2.join(os2.homedir(), ".todoforai");
44958
- fs.mkdirSync(logDir, { recursive: true });
44959
- const logFile = path2.join(logDir, "edge.log");
44960
- const out = fs.openSync(logFile, "a");
45015
+ const logDir = path3.join(os3.homedir(), ".todoforai");
45016
+ fs2.mkdirSync(logDir, { recursive: true });
45017
+ const logFile = path3.join(logDir, "edge.log");
45018
+ const out = fs2.openSync(logFile, "a");
44961
45019
  const child = spawn("bunx", ["@todoforai/edge", "--api-url", apiUrl, "--api-key", apiKey], {
44962
45020
  detached: true,
44963
45021
  stdio: ["ignore", out, out]
@@ -44975,7 +45033,7 @@ function ensureEdgeRunning(apiUrl, apiKey) {
44975
45033
  const pid = child.pid;
44976
45034
  if (!pid)
44977
45035
  return;
44978
- const shortLog = logFile.replace(os2.homedir(), "~");
45036
+ const shortLog = logFile.replace(os3.homedir(), "~");
44979
45037
  setTimeout(() => {
44980
45038
  if (!exited) {
44981
45039
  console.error(`\x1B[2mStarted edge daemon (pid ${pid}), logs: ${shortLog}\x1B[0m`);
@@ -44990,9 +45048,13 @@ function ensureEdgeRunning(apiUrl, apiKey) {
44990
45048
  }
44991
45049
 
44992
45050
  // src/index.ts
44993
- function formatPathWithTilde(path3) {
45051
+ try {
45052
+ const pkgPath = path4.resolve(fileURLToPath(import.meta.url), "../../package.json");
45053
+ checkForUpdates(JSON.parse(readFileSync3(pkgPath, "utf-8")));
45054
+ } catch {}
45055
+ function formatPathWithTilde(path5) {
44994
45056
  const home = homedir3();
44995
- return path3.startsWith(home) ? path3.replace(home, "~") : path3;
45057
+ return path5.startsWith(home) ? path5.replace(home, "~") : path5;
44996
45058
  }
44997
45059
  function getFrontendUrl(apiUrl, projectId, todoId) {
44998
45060
  if (apiUrl.includes("localhost:4000") || apiUrl.includes("127.0.0.1:4000")) {
@@ -45104,12 +45166,13 @@ Cancelled by user (Ctrl+C)
45104
45166
  const loginApi = new ApiClient(apiUrl, "");
45105
45167
  const { code, url, expiresIn } = await loginApi.initDeviceLogin("cli");
45106
45168
  const userCode = new URL(url).searchParams.get("user_code") || code.slice(-8).toUpperCase();
45169
+ const formattedCode = userCode.length === 8 ? `${userCode.slice(0, 4)}-${userCode.slice(4)}` : userCode;
45107
45170
  process.stderr.write(`
45108
45171
  \uD83D\uDD11 Open this URL to authorize:
45109
45172
  `);
45110
45173
  process.stderr.write(`${CYAN}${url}${RESET}
45111
45174
  `);
45112
- process.stderr.write(`Verification code: ${BRIGHT_WHITE}${userCode}${RESET}
45175
+ process.stderr.write(`Verification code: ${BRIGHT_WHITE}${formattedCode}${RESET}
45113
45176
 
45114
45177
  `);
45115
45178
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "todoai": "dist/todoai.js"