@usebitl/cli 0.1.5 → 0.1.6

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.
@@ -467,7 +467,7 @@ function readCloudConfig(home = bitlHome()) {
467
467
  }
468
468
  }
469
469
  function clientVersionHeader() {
470
- const v = "0.1.5";
470
+ const v = "0.1.6";
471
471
  return v ? { "x-bitl-client": v } : {};
472
472
  }
473
473
  function resolveTarget(home = bitlHome()) {
package/bin/bitl.mjs CHANGED
@@ -5,7 +5,7 @@
5
5
  // node bin/bitl.mjs __sync — copy only (npm postinstall). A failure does not block the install
6
6
  import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
7
7
  import { homedir } from 'node:os';
8
- import { join } from 'node:path';
8
+ import { join, sep } from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
10
 
11
11
  const syncOnly = process.argv[2] === '__sync';
@@ -28,6 +28,8 @@ try {
28
28
  if (syncOnly) process.exit(0);
29
29
 
30
30
  process.env.BITL_ADAPTER_DIR = dir;
31
+ // Run via npx (from the npm cache's _npx folder): the update notice suggests npx @usebitl/cli@latest instead of npm i -g
32
+ if (fileURLToPath(import.meta.url).includes(`${sep}_npx${sep}`)) process.env.BITL_INSTALL = 'npx';
31
33
  // Web UI that bitl start serves (built into the package)
32
34
  process.env.BITL_WEB_DIST ??= fileURLToPath(new URL('../web/', import.meta.url));
33
35
  await import('../dist/cli.mjs');
package/dist/cli.mjs CHANGED
@@ -20812,6 +20812,197 @@ var init_src = __esm({
20812
20812
  }
20813
20813
  });
20814
20814
 
20815
+ // ../../shared/src/node/antigravity.ts
20816
+ var MAX_TRANSCRIPT_BYTES;
20817
+ var init_antigravity = __esm({
20818
+ "../../shared/src/node/antigravity.ts"() {
20819
+ "use strict";
20820
+ MAX_TRANSCRIPT_BYTES = 20 * 1024 * 1024;
20821
+ }
20822
+ });
20823
+
20824
+ // ../../shared/src/node/keys.ts
20825
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
20826
+ import { homedir } from "node:os";
20827
+ import { dirname, join } from "node:path";
20828
+ function loadOrCreateMasterKey(home = bitlHome(), env2 = process.env.BITL_KEY) {
20829
+ if (env2?.trim()) return env2.trim();
20830
+ const file2 = keyPath(home);
20831
+ try {
20832
+ const existing = readFileSync(file2, "utf8").trim();
20833
+ if (existing) return existing;
20834
+ } catch {
20835
+ }
20836
+ const key = toBase64Url(generateMasterKey());
20837
+ mkdirSync(dirname(file2), { recursive: true });
20838
+ try {
20839
+ writeFileSync(file2, key + "\n", { encoding: "utf8", mode: 384, flag: "wx" });
20840
+ return key;
20841
+ } catch (err) {
20842
+ if (err.code === "EEXIST") return readFileSync(file2, "utf8").trim();
20843
+ throw err;
20844
+ }
20845
+ }
20846
+ var bitlHome, keyPath, loadKeys;
20847
+ var init_keys = __esm({
20848
+ "../../shared/src/node/keys.ts"() {
20849
+ "use strict";
20850
+ init_crypto();
20851
+ bitlHome = (env2 = process.env.BITL_HOME) => env2?.trim() ? env2.trim() : join(homedir(), ".bitl");
20852
+ keyPath = (home = bitlHome()) => join(home, "key");
20853
+ loadKeys = (home = bitlHome()) => keysFromBase64Url(loadOrCreateMasterKey(home));
20854
+ }
20855
+ });
20856
+
20857
+ // ../../shared/src/node/cloud.ts
20858
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
20859
+ import { dirname as dirname2, join as join2 } from "node:path";
20860
+ function writePrivate(file2, text) {
20861
+ mkdirSync2(dirname2(file2), { recursive: true });
20862
+ writeFileSync2(file2, text, { encoding: "utf8", mode: 384 });
20863
+ }
20864
+ function readCloudConfig(home = bitlHome()) {
20865
+ try {
20866
+ const c = JSON.parse(readFileSync2(cloudConfigPath(home), "utf8"));
20867
+ return c.url && c.deviceId && c.apiKey ? c : null;
20868
+ } catch {
20869
+ return null;
20870
+ }
20871
+ }
20872
+ function saveCloudLogin(cfg, masterB64, home = bitlHome()) {
20873
+ writePrivate(cloudKeyPath(home), masterB64 + "\n");
20874
+ writePrivate(cloudConfigPath(home), JSON.stringify(cfg, null, 2) + "\n");
20875
+ }
20876
+ function removeCloudLogin(home = bitlHome()) {
20877
+ rmSync(cloudConfigPath(home), { force: true });
20878
+ rmSync(cloudKeyPath(home), { force: true });
20879
+ }
20880
+ function clientVersionHeader() {
20881
+ const v = "0.1.6";
20882
+ return v ? { "x-bitl-client": v } : {};
20883
+ }
20884
+ function resolveTarget(home = bitlHome()) {
20885
+ const cloud = readCloudConfig(home);
20886
+ if (cloud) {
20887
+ return {
20888
+ kind: "cloud",
20889
+ url: cloud.url.replace(/\/+$/, ""),
20890
+ headers: { authorization: `Bearer ${cloud.apiKey}`, ...clientVersionHeader() },
20891
+ keys: () => keysFromBase64Url(readFileSync2(cloudKeyPath(home), "utf8"))
20892
+ };
20893
+ }
20894
+ return {
20895
+ kind: "local",
20896
+ url: (process.env.BITL_URL?.trim() || `http://127.0.0.1:${process.env.BITL_PORT ?? 7777}`).replace(/\/+$/, ""),
20897
+ headers: {},
20898
+ keys: () => loadKeys(home)
20899
+ };
20900
+ }
20901
+ var cloudConfigPath, cloudKeyPath;
20902
+ var init_cloud = __esm({
20903
+ "../../shared/src/node/cloud.ts"() {
20904
+ "use strict";
20905
+ init_crypto();
20906
+ init_keys();
20907
+ cloudConfigPath = (home = bitlHome()) => join2(home, "cloud.json");
20908
+ cloudKeyPath = (home = bitlHome()) => join2(home, "cloud-key");
20909
+ }
20910
+ });
20911
+
20912
+ // ../../shared/src/node/enrich.ts
20913
+ var MAX_TRANSCRIPT_BYTES2;
20914
+ var init_enrich = __esm({
20915
+ "../../shared/src/node/enrich.ts"() {
20916
+ "use strict";
20917
+ init_prepare();
20918
+ MAX_TRANSCRIPT_BYTES2 = 20 * 1024 * 1024;
20919
+ }
20920
+ });
20921
+
20922
+ // ../../shared/src/node/approve.ts
20923
+ var DEFAULT_APPROVAL_WAIT_MS;
20924
+ var init_approve = __esm({
20925
+ "../../shared/src/node/approve.ts"() {
20926
+ "use strict";
20927
+ init_approval();
20928
+ init_cloud();
20929
+ init_enrich();
20930
+ init_keys();
20931
+ DEFAULT_APPROVAL_WAIT_MS = 10 * 6e4;
20932
+ }
20933
+ });
20934
+
20935
+ // ../../shared/src/node/update-check.ts
20936
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
20937
+ import { join as join3 } from "node:path";
20938
+ function readCache(home) {
20939
+ try {
20940
+ return JSON.parse(readFileSync3(cachePath(home), "utf8"));
20941
+ } catch {
20942
+ return null;
20943
+ }
20944
+ }
20945
+ async function fetchLatest() {
20946
+ try {
20947
+ const res = await fetch(REGISTRY, { signal: AbortSignal.timeout(TIMEOUT_MS), headers: { accept: "application/json" } });
20948
+ if (!res.ok) return void 0;
20949
+ const v = (await res.json()).version;
20950
+ return typeof v === "string" && VERSION_PATTERN.test(v) ? v : void 0;
20951
+ } catch {
20952
+ return void 0;
20953
+ }
20954
+ }
20955
+ async function latestVersion(home, now3) {
20956
+ const cache = readCache(home);
20957
+ if (cache && now3 - Date.parse(cache.checkedAt) < DAY) return cache.latest;
20958
+ const latest = await fetchLatest() ?? cache?.latest;
20959
+ try {
20960
+ mkdirSync3(home, { recursive: true });
20961
+ writeFileSync3(cachePath(home), JSON.stringify({ checkedAt: new Date(now3).toISOString(), latest }) + "\n");
20962
+ } catch {
20963
+ }
20964
+ return latest;
20965
+ }
20966
+ async function checkCliUpdate(current = "0.1.6", opts = {}) {
20967
+ if (!current || process.env.BITL_NO_UPDATE_CHECK === "1") return void 0;
20968
+ const latest = await latestVersion(opts.home ?? bitlHome(), opts.now ?? Date.now());
20969
+ if (!latest || compareVersions(latest, current) <= 0) return void 0;
20970
+ return { current, latest, command: updateCommand() };
20971
+ }
20972
+ var REGISTRY, DAY, TIMEOUT_MS, cachePath, updateCommand;
20973
+ var init_update_check = __esm({
20974
+ "../../shared/src/node/update-check.ts"() {
20975
+ "use strict";
20976
+ init_release();
20977
+ init_keys();
20978
+ REGISTRY = "https://registry.npmjs.org/@usebitl/cli/latest";
20979
+ DAY = 864e5;
20980
+ TIMEOUT_MS = 1e3;
20981
+ cachePath = (home) => join3(home, "update-check.json");
20982
+ updateCommand = (install2 = process.env.BITL_INSTALL) => install2 === "npx" ? "npx @usebitl/cli@latest start" : "npm i -g @usebitl/cli";
20983
+ }
20984
+ });
20985
+
20986
+ // ../../shared/src/node/index.ts
20987
+ var init_node = __esm({
20988
+ "../../shared/src/node/index.ts"() {
20989
+ "use strict";
20990
+ init_crypto();
20991
+ init_normalize();
20992
+ init_prepare();
20993
+ init_antigravity();
20994
+ init_cloud();
20995
+ init_enrich();
20996
+ init_keys();
20997
+ init_antigravity();
20998
+ init_approve();
20999
+ init_cloud();
21000
+ init_enrich();
21001
+ init_keys();
21002
+ init_update_check();
21003
+ }
21004
+ });
21005
+
20815
21006
  // ../../../node_modules/.pnpm/@hono+node-server@2.1.1_hono@4.13.9/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
20816
21007
  var X_ALREADY_SENT;
20817
21008
  var init_constants_BLSFu_RU = __esm({
@@ -25015,7 +25206,7 @@ function compareKey(a, b) {
25015
25206
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
25016
25207
  }
25017
25208
  var LABEL_REG_EXP_STR, ONLY_WILDCARD_REG_EXP_STR, TAIL_WILDCARD_REG_EXP_STR, PATH_ERROR, regExpMetaChars, Node;
25018
- var init_node = __esm({
25209
+ var init_node2 = __esm({
25019
25210
  "../../../node_modules/.pnpm/hono@4.13.9/node_modules/hono/dist/router/reg-exp-router/node.js"() {
25020
25211
  init_utils();
25021
25212
  LABEL_REG_EXP_STR = "[^/]+";
@@ -25112,7 +25303,7 @@ var Trie;
25112
25303
  var init_trie = __esm({
25113
25304
  "../../../node_modules/.pnpm/hono@4.13.9/node_modules/hono/dist/router/reg-exp-router/trie.js"() {
25114
25305
  init_utils();
25115
- init_node();
25306
+ init_node2();
25116
25307
  Trie = class {
25117
25308
  #context = { varIndex: 0 };
25118
25309
  #root = new Node();
@@ -25202,7 +25393,7 @@ var init_router2 = __esm({
25202
25393
  init_url();
25203
25394
  init_utils();
25204
25395
  init_matcher();
25205
- init_node();
25396
+ init_node2();
25206
25397
  init_trie();
25207
25398
  wildcardRegExpCache = createNullObject();
25208
25399
  RegExpRouter = class {
@@ -25397,7 +25588,7 @@ var init_smart_router = __esm({
25397
25588
 
25398
25589
  // ../../../node_modules/.pnpm/hono@4.13.9/node_modules/hono/dist/router/trie-router/node.js
25399
25590
  var emptyParams, order, Node2;
25400
- var init_node2 = __esm({
25591
+ var init_node3 = __esm({
25401
25592
  "../../../node_modules/.pnpm/hono@4.13.9/node_modules/hono/dist/router/trie-router/node.js"() {
25402
25593
  init_router();
25403
25594
  init_url();
@@ -25568,7 +25759,7 @@ var TrieRouter;
25568
25759
  var init_router4 = __esm({
25569
25760
  "../../../node_modules/.pnpm/hono@4.13.9/node_modules/hono/dist/router/trie-router/router.js"() {
25570
25761
  init_url();
25571
- init_node2();
25762
+ init_node3();
25572
25763
  TrieRouter = class {
25573
25764
  name = "TrieRouter";
25574
25765
  #node = new Node2();
@@ -33634,19 +33825,32 @@ function runServer({ store, services, app, where, info: info2 = [], sweep, prune
33634
33825
  process.on("SIGINT", shutdown);
33635
33826
  process.on("SIGTERM", shutdown);
33636
33827
  }
33828
+ function watchCliUpdate() {
33829
+ let update;
33830
+ const refresh = () => checkCliUpdate().then(
33831
+ (u) => update = u,
33832
+ () => {
33833
+ }
33834
+ );
33835
+ void refresh();
33836
+ setInterval(refresh, UPDATE_CHECK_INTERVAL_MS).unref();
33837
+ return () => update;
33838
+ }
33637
33839
  async function startServer() {
33638
33840
  const file2 = join7(BITL_HOME, "bitl.db");
33639
33841
  const store = openSqliteStore(file2);
33640
33842
  const drained = await drainQueue(store);
33641
33843
  const services = coreServices(store);
33642
- const app = createApp({ store, webDist: WEB_DIST, ...services.app });
33844
+ const update = watchCliUpdate();
33845
+ const app = createApp({ store, webDist: WEB_DIST, ...services.app, extension: { me: () => ({ mode: "local", update: update() }) } });
33643
33846
  runServer({ store, services, app, where: file2, info: drained ? [`queue: processed ${drained} pending events`] : [] });
33644
33847
  }
33645
- var BITL_HOME, PORT, HOST, SWEEP_INTERVAL_MS, PRUNE_INTERVAL_MS, EVENT_RETENTION_DAYS, env, here2, WEB_DIST, errorLogger;
33848
+ var BITL_HOME, PORT, HOST, SWEEP_INTERVAL_MS, PRUNE_INTERVAL_MS, UPDATE_CHECK_INTERVAL_MS, EVENT_RETENTION_DAYS, env, here2, WEB_DIST, errorLogger;
33646
33849
  var init_src2 = __esm({
33647
33850
  "../../server/src/index.ts"() {
33648
33851
  "use strict";
33649
33852
  init_dist();
33853
+ init_node();
33650
33854
  init_access();
33651
33855
  init_approvals_api();
33652
33856
  init_app();
@@ -33657,6 +33861,7 @@ var init_src2 = __esm({
33657
33861
  HOST = process.env.BITL_HOST ?? "127.0.0.1";
33658
33862
  SWEEP_INTERVAL_MS = 3e4;
33659
33863
  PRUNE_INTERVAL_MS = 60 * 6e4;
33864
+ UPDATE_CHECK_INTERVAL_MS = 6 * 60 * 6e4;
33660
33865
  EVENT_RETENTION_DAYS = Number(process.env.BITL_EVENT_RETENTION_DAYS ?? 14);
33661
33866
  env = (name) => process.env[name]?.trim() || void 0;
33662
33867
  here2 = dirname5(fileURLToPath2(import.meta.url));
@@ -33673,115 +33878,21 @@ var init_src2 = __esm({
33673
33878
 
33674
33879
  // ../src/index.ts
33675
33880
  init_src();
33881
+ init_node();
33676
33882
  import { homedir as homedir4 } from "node:os";
33677
33883
  import { join as join8, resolve as resolve3 } from "node:path";
33678
-
33679
- // ../../shared/src/node/index.ts
33680
- init_crypto();
33681
- init_normalize();
33682
- init_prepare();
33683
-
33684
- // ../../shared/src/node/antigravity.ts
33685
- var MAX_TRANSCRIPT_BYTES = 20 * 1024 * 1024;
33686
-
33687
- // ../../shared/src/node/cloud.ts
33688
- init_crypto();
33689
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
33690
- import { dirname as dirname2, join as join2 } from "node:path";
33691
-
33692
- // ../../shared/src/node/keys.ts
33693
- init_crypto();
33694
- import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
33695
- import { homedir } from "node:os";
33696
- import { dirname, join } from "node:path";
33697
- var bitlHome = (env2 = process.env.BITL_HOME) => env2?.trim() ? env2.trim() : join(homedir(), ".bitl");
33698
- var keyPath = (home = bitlHome()) => join(home, "key");
33699
- function loadOrCreateMasterKey(home = bitlHome(), env2 = process.env.BITL_KEY) {
33700
- if (env2?.trim()) return env2.trim();
33701
- const file2 = keyPath(home);
33702
- try {
33703
- const existing = readFileSync(file2, "utf8").trim();
33704
- if (existing) return existing;
33705
- } catch {
33706
- }
33707
- const key = toBase64Url(generateMasterKey());
33708
- mkdirSync(dirname(file2), { recursive: true });
33709
- try {
33710
- writeFileSync(file2, key + "\n", { encoding: "utf8", mode: 384, flag: "wx" });
33711
- return key;
33712
- } catch (err) {
33713
- if (err.code === "EEXIST") return readFileSync(file2, "utf8").trim();
33714
- throw err;
33715
- }
33716
- }
33717
- var loadKeys = (home = bitlHome()) => keysFromBase64Url(loadOrCreateMasterKey(home));
33718
-
33719
- // ../../shared/src/node/cloud.ts
33720
- var cloudConfigPath = (home = bitlHome()) => join2(home, "cloud.json");
33721
- var cloudKeyPath = (home = bitlHome()) => join2(home, "cloud-key");
33722
- function writePrivate(file2, text) {
33723
- mkdirSync2(dirname2(file2), { recursive: true });
33724
- writeFileSync2(file2, text, { encoding: "utf8", mode: 384 });
33725
- }
33726
- function readCloudConfig(home = bitlHome()) {
33727
- try {
33728
- const c = JSON.parse(readFileSync2(cloudConfigPath(home), "utf8"));
33729
- return c.url && c.deviceId && c.apiKey ? c : null;
33730
- } catch {
33731
- return null;
33732
- }
33733
- }
33734
- function saveCloudLogin(cfg, masterB64, home = bitlHome()) {
33735
- writePrivate(cloudKeyPath(home), masterB64 + "\n");
33736
- writePrivate(cloudConfigPath(home), JSON.stringify(cfg, null, 2) + "\n");
33737
- }
33738
- function removeCloudLogin(home = bitlHome()) {
33739
- rmSync(cloudConfigPath(home), { force: true });
33740
- rmSync(cloudKeyPath(home), { force: true });
33741
- }
33742
- function clientVersionHeader() {
33743
- const v = "0.1.5";
33744
- return v ? { "x-bitl-client": v } : {};
33745
- }
33746
- function resolveTarget(home = bitlHome()) {
33747
- const cloud = readCloudConfig(home);
33748
- if (cloud) {
33749
- return {
33750
- kind: "cloud",
33751
- url: cloud.url.replace(/\/+$/, ""),
33752
- headers: { authorization: `Bearer ${cloud.apiKey}`, ...clientVersionHeader() },
33753
- keys: () => keysFromBase64Url(readFileSync2(cloudKeyPath(home), "utf8"))
33754
- };
33755
- }
33756
- return {
33757
- kind: "local",
33758
- url: (process.env.BITL_URL?.trim() || `http://127.0.0.1:${process.env.BITL_PORT ?? 7777}`).replace(/\/+$/, ""),
33759
- headers: {},
33760
- keys: () => loadKeys(home)
33761
- };
33762
- }
33763
-
33764
- // ../../shared/src/node/enrich.ts
33765
- init_prepare();
33766
- var MAX_TRANSCRIPT_BYTES2 = 20 * 1024 * 1024;
33767
-
33768
- // ../../shared/src/node/approve.ts
33769
- init_approval();
33770
- var DEFAULT_APPROVAL_WAIT_MS = 10 * 6e4;
33771
-
33772
- // ../src/index.ts
33773
33884
  import { readFileSync as readFileSync7 } from "node:fs";
33774
33885
 
33775
33886
  // ../src/install.ts
33776
- import { copyFileSync, existsSync, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
33887
+ import { copyFileSync, existsSync, mkdirSync as mkdirSync4, readdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
33777
33888
  import { homedir as homedir2 } from "node:os";
33778
- import { dirname as dirname3, join as join3, resolve } from "node:path";
33889
+ import { dirname as dirname3, join as join4, resolve } from "node:path";
33779
33890
  import { fileURLToPath } from "node:url";
33780
33891
 
33781
33892
  // ../src/i18n.ts
33782
33893
  var ko = {
33783
33894
  "usage.title": "bitl \u2014 AI \uC5D0\uC774\uC804\uD2B8 \uC791\uC5C5 \uD604\uD669\uD310 (https://usebitl.com)",
33784
- "update.available": "\u2191 bitl {latest} \uAC00 \uB098\uC654\uC2B5\uB2C8\uB2E4 (\uC9C0\uAE08 {current}) \u2014 npm i -g @usebitl/cli",
33895
+ "update.available": "\u2191 bitl {latest} \uAC00 \uB098\uC654\uC2B5\uB2C8\uB2E4 (\uC9C0\uAE08 {current}) \u2014 {command}",
33785
33896
  "update.changelog": " \uBC14\uB010 \uC810: https://usebitl.com/changelog",
33786
33897
  "usage.start": "\uC11C\uBC84 \uC2DC\uC791 (http://127.0.0.1:7777)",
33787
33898
  "usage.status": "\uD604\uC7AC \uC138\uC158 \uC694\uC57D (\uC774 PC \uC758 \uD0A4\uB85C \uBCF5\uD638\uD654)",
@@ -33853,7 +33964,7 @@ var ko = {
33853
33964
  };
33854
33965
  var en = {
33855
33966
  "usage.title": "bitl \u2014 all your AI coding agents in one place (https://usebitl.com)",
33856
- "update.available": "\u2191 bitl {latest} is available (you have {current}) \u2014 npm i -g @usebitl/cli",
33967
+ "update.available": "\u2191 bitl {latest} is available (you have {current}) \u2014 {command}",
33857
33968
  "update.changelog": " What changed: https://usebitl.com/changelog",
33858
33969
  "usage.start": "Start the server (http://127.0.0.1:7777)",
33859
33970
  "usage.status": "Summary of current sessions (decrypted with this PC\u2019s key)",
@@ -33990,7 +34101,7 @@ function addHooks(settings, command = hookCommand(), approve = approveCommand())
33990
34101
  return { ...base, hooks };
33991
34102
  }
33992
34103
  function updateTextFile(file2, change) {
33993
- const before = existsSync(file2) ? readFileSync3(file2, "utf8") : "";
34104
+ const before = existsSync(file2) ? readFileSync4(file2, "utf8") : "";
33994
34105
  const after = change(before);
33995
34106
  if (after === before) return { changed: false };
33996
34107
  let backup;
@@ -33998,8 +34109,8 @@ function updateTextFile(file2, change) {
33998
34109
  backup = `${file2}.bitl-backup-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
33999
34110
  copyFileSync(file2, backup);
34000
34111
  }
34001
- mkdirSync3(dirname3(file2), { recursive: true });
34002
- writeFileSync3(file2, after, "utf8");
34112
+ mkdirSync4(dirname3(file2), { recursive: true });
34113
+ writeFileSync4(file2, after, "utf8");
34003
34114
  return { changed: true, backup };
34004
34115
  }
34005
34116
  function updateSettingsFile(file2, change) {
@@ -34024,7 +34135,7 @@ var CODEX_EVENTS = [
34024
34135
  var CODEX_SHORT_EVENTS = /* @__PURE__ */ new Set(["SessionEnd", "Interrupt"]);
34025
34136
  var CODEX_BEGIN = "# >>> bitl (bitl install codex) >>>";
34026
34137
  var CODEX_END = "# <<< bitl <<<";
34027
- var codexConfigPath = () => join3(process.env.CODEX_HOME ?? join3(homedir2(), ".codex"), "config.toml");
34138
+ var codexConfigPath = () => join4(process.env.CODEX_HOME ?? join4(homedir2(), ".codex"), "config.toml");
34028
34139
  function removeCodexBlock(toml) {
34029
34140
  const sections = [[]];
34030
34141
  for (const line of toml.split("\n")) {
@@ -34058,7 +34169,7 @@ function addCodexBlock(toml, command = hookCommand("codex")) {
34058
34169
  var ANTIGRAVITY_EVENTS = ["PreInvocation", "PreToolUse", "PostToolUse", "Stop"];
34059
34170
  var ANTIGRAVITY_TOOL_EVENTS = /* @__PURE__ */ new Set(["PreToolUse", "PostToolUse"]);
34060
34171
  var ANTIGRAVITY_HOOK_NAME = "bitl";
34061
- var antigravityHooksPath = () => join3(homedir2(), ".gemini", "config", "hooks.json");
34172
+ var antigravityHooksPath = () => join4(homedir2(), ".gemini", "config", "hooks.json");
34062
34173
  function addAntigravityHooks(config2, adapter = ADAPTER_PATH) {
34063
34174
  if (/\s/.test(adapter)) throw new Error(t("err.agySpace", { path: adapter }));
34064
34175
  const group = { enabled: true };
@@ -34073,11 +34184,11 @@ function removeAntigravityHooks(config2) {
34073
34184
  return rest;
34074
34185
  }
34075
34186
  var MCP_PATH = resolve(ADAPTER_DIR, "bitl-mcp.mjs").replaceAll("\\", "/");
34076
- function msixClaudeDir(localAppData = process.env.LOCALAPPDATA ?? join3(homedir2(), "AppData", "Local")) {
34077
- const packages = join3(localAppData, "Packages");
34187
+ function msixClaudeDir(localAppData = process.env.LOCALAPPDATA ?? join4(homedir2(), "AppData", "Local")) {
34188
+ const packages = join4(localAppData, "Packages");
34078
34189
  try {
34079
34190
  for (const pkg of readdirSync(packages).filter((d) => /^Claude_/.test(d))) {
34080
- const dir = join3(packages, pkg, "LocalCache", "Roaming", "Claude");
34191
+ const dir = join4(packages, pkg, "LocalCache", "Roaming", "Claude");
34081
34192
  if (existsSync(dir)) return dir;
34082
34193
  }
34083
34194
  } catch {
@@ -34086,11 +34197,11 @@ function msixClaudeDir(localAppData = process.env.LOCALAPPDATA ?? join3(homedir2
34086
34197
  }
34087
34198
  function claudeDesktopConfigPath() {
34088
34199
  if (process.platform === "win32") {
34089
- const dir = msixClaudeDir() ?? join3(process.env.APPDATA ?? join3(homedir2(), "AppData", "Roaming"), "Claude");
34090
- return join3(dir, "claude_desktop_config.json");
34200
+ const dir = msixClaudeDir() ?? join4(process.env.APPDATA ?? join4(homedir2(), "AppData", "Roaming"), "Claude");
34201
+ return join4(dir, "claude_desktop_config.json");
34091
34202
  }
34092
- if (process.platform === "darwin") return join3(homedir2(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
34093
- return join3(homedir2(), ".config", "Claude", "claude_desktop_config.json");
34203
+ if (process.platform === "darwin") return join4(homedir2(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
34204
+ return join4(homedir2(), ".config", "Claude", "claude_desktop_config.json");
34094
34205
  }
34095
34206
  function addMcpServer(config2, mcpPath = MCP_PATH, source = "claude-desktop") {
34096
34207
  return { ...config2, mcpServers: { ...config2.mcpServers ?? {}, bitl: { command: "node", args: [mcpPath, "--source", source] } } };
@@ -34103,6 +34214,7 @@ function removeMcpServer(config2) {
34103
34214
 
34104
34215
  // ../src/login.ts
34105
34216
  init_src();
34217
+ init_node();
34106
34218
  import { spawn } from "node:child_process";
34107
34219
  import { hostname as hostname3 } from "node:os";
34108
34220
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -34196,46 +34308,10 @@ async function logout() {
34196
34308
  }
34197
34309
 
34198
34310
  // ../src/update.ts
34199
- init_src();
34200
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
34201
- import { join as join4 } from "node:path";
34202
- var REGISTRY = "https://registry.npmjs.org/@usebitl/cli/latest";
34203
- var DAY = 864e5;
34204
- var TIMEOUT_MS = 1e3;
34205
- var cachePath = () => join4(bitlHome(), "update-check.json");
34206
- function readCache() {
34207
- try {
34208
- return JSON.parse(readFileSync4(cachePath(), "utf8"));
34209
- } catch {
34210
- return null;
34211
- }
34212
- }
34213
- async function fetchLatest() {
34214
- try {
34215
- const res = await fetch(REGISTRY, { signal: AbortSignal.timeout(TIMEOUT_MS), headers: { accept: "application/json" } });
34216
- if (!res.ok) return void 0;
34217
- const v = (await res.json()).version;
34218
- return typeof v === "string" && VERSION_PATTERN.test(v) ? v : void 0;
34219
- } catch {
34220
- return void 0;
34221
- }
34222
- }
34223
- async function latestVersion(now3 = Date.now()) {
34224
- const cache = readCache();
34225
- if (cache && now3 - Date.parse(cache.checkedAt) < DAY) return cache.latest;
34226
- const latest = await fetchLatest() ?? cache?.latest;
34227
- try {
34228
- mkdirSync4(bitlHome(), { recursive: true });
34229
- writeFileSync4(cachePath(), JSON.stringify({ checkedAt: new Date(now3).toISOString(), latest }) + "\n");
34230
- } catch {
34231
- }
34232
- return latest;
34233
- }
34234
- async function updateNotice(current = "0.1.5") {
34235
- if (!current || process.env.BITL_NO_UPDATE_CHECK === "1") return void 0;
34236
- const latest = await latestVersion();
34237
- if (!latest || compareVersions(latest, current) <= 0) return void 0;
34238
- return `${t("update.available", { latest, current })}
34311
+ init_node();
34312
+ async function updateNotice(current = "0.1.6") {
34313
+ const u = await checkCliUpdate(current);
34314
+ return u && `${t("update.available", { ...u })}
34239
34315
  ${t("update.changelog")}`;
34240
34316
  }
34241
34317
 
@@ -34412,7 +34488,6 @@ main(process.argv.slice(2)).catch((err) => {
34412
34488
  console.error(err instanceof Error ? err.message : err);
34413
34489
  process.exitCode = 1;
34414
34490
  }).then(async () => {
34415
- if (process.argv[2] === "start") return;
34416
34491
  const notice = await updateNotice();
34417
34492
  if (notice) console.error(`
34418
34493
  ${notice}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usebitl/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "BITL — see which of your AI coding agents (Claude Code, Codex, Antigravity) are waiting for you. Local board or usebitl.com",
5
5
  "type": "module",
6
6
  "bin": {