@wayai/cli 0.3.51 → 0.3.52

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
@@ -8867,111 +8867,132 @@ var init_logout = __esm({
8867
8867
  }
8868
8868
  });
8869
8869
 
8870
- // src/lib/hub-lock.ts
8870
+ // src/lib/hub-binding.ts
8871
8871
  import { execFileSync as execFileSync2 } from "child_process";
8872
8872
  import * as fs7 from "fs";
8873
8873
  import * as path7 from "path";
8874
- function getLockPath() {
8874
+ function resolveGitDir() {
8875
8875
  const cwd = process.cwd();
8876
- if (_lockPathCache && _lockPathCache.cwd === cwd) return _lockPathCache.lockPath;
8876
+ if (_gitDirCache && _gitDirCache.cwd === cwd) return _gitDirCache.gitDir;
8877
8877
  let gitDir;
8878
8878
  try {
8879
- gitDir = execFileSync2("git", ["rev-parse", "--git-dir"], {
8879
+ const raw = execFileSync2("git", ["rev-parse", "--git-dir"], {
8880
8880
  cwd,
8881
8881
  encoding: "utf-8",
8882
8882
  stdio: ["pipe", "pipe", "pipe"]
8883
8883
  }).trim();
8884
+ gitDir = raw ? path7.resolve(cwd, raw) : null;
8884
8885
  } catch {
8885
- _lockPathCache = { cwd, lockPath: null };
8886
- return null;
8886
+ gitDir = null;
8887
8887
  }
8888
- const lockPath = gitDir ? path7.resolve(cwd, gitDir, LOCK_FILENAME) : null;
8889
- _lockPathCache = { cwd, lockPath };
8890
- return lockPath;
8888
+ _gitDirCache = { cwd, gitDir };
8889
+ return gitDir;
8891
8890
  }
8892
- function readLock() {
8893
- const lockPath = getLockPath();
8894
- if (!lockPath) return null;
8895
- let raw;
8896
- try {
8897
- raw = fs7.readFileSync(lockPath, "utf-8");
8898
- } catch (err) {
8899
- if (err.code === "ENOENT") return null;
8900
- throw err;
8891
+ function getBindingPath() {
8892
+ const gitDir = resolveGitDir();
8893
+ return gitDir ? path7.join(gitDir, BINDING_FILENAME) : null;
8894
+ }
8895
+ function getLegacyBindingPath() {
8896
+ const gitDir = resolveGitDir();
8897
+ return gitDir ? path7.join(gitDir, LEGACY_BINDING_FILENAME) : null;
8898
+ }
8899
+ function readBinding() {
8900
+ for (const bindingPath of [getBindingPath(), getLegacyBindingPath()]) {
8901
+ if (!bindingPath) continue;
8902
+ let raw;
8903
+ try {
8904
+ raw = fs7.readFileSync(bindingPath, "utf-8");
8905
+ } catch (err) {
8906
+ if (err.code === "ENOENT") continue;
8907
+ throw err;
8908
+ }
8909
+ const trimmed = raw.trim();
8910
+ return UUID_RE.test(trimmed) ? trimmed : null;
8901
8911
  }
8902
- const trimmed = raw.trim();
8903
- return UUID_RE.test(trimmed) ? trimmed : null;
8912
+ return null;
8904
8913
  }
8905
- function writeLock(hubId) {
8914
+ function writeBinding(hubId) {
8906
8915
  if (!UUID_RE.test(hubId)) {
8907
8916
  throw new Error(`Invalid hub_id (must be a UUID): ${hubId}`);
8908
8917
  }
8909
- const lockPath = getLockPath();
8910
- if (!lockPath) {
8911
- throw new Error("Not inside a git repository \u2014 cannot write hub lock.");
8918
+ const bindingPath = getBindingPath();
8919
+ if (!bindingPath) {
8920
+ throw new Error("Not inside a git repository \u2014 cannot write hub binding.");
8912
8921
  }
8913
- fs7.writeFileSync(lockPath, `${hubId}
8922
+ fs7.writeFileSync(bindingPath, `${hubId}
8914
8923
  `, "utf-8");
8924
+ removeLegacyBinding();
8915
8925
  }
8916
- function clearLock() {
8917
- const lockPath = getLockPath();
8918
- if (!lockPath) return false;
8926
+ function removeLegacyBinding() {
8927
+ const legacyPath = getLegacyBindingPath();
8928
+ if (!legacyPath) return;
8919
8929
  try {
8920
- fs7.unlinkSync(lockPath);
8921
- return true;
8922
- } catch (err) {
8923
- if (err.code === "ENOENT") return false;
8924
- throw err;
8930
+ fs7.unlinkSync(legacyPath);
8931
+ } catch {
8932
+ }
8933
+ }
8934
+ function clearBinding() {
8935
+ let removed = false;
8936
+ for (const bindingPath of [getBindingPath(), getLegacyBindingPath()]) {
8937
+ if (!bindingPath) continue;
8938
+ try {
8939
+ fs7.unlinkSync(bindingPath);
8940
+ removed = true;
8941
+ } catch (err) {
8942
+ if (err.code !== "ENOENT") throw err;
8943
+ }
8925
8944
  }
8945
+ return removed;
8926
8946
  }
8927
- function assertHubMatchesLock(resolvedHubId, hubLabel) {
8928
- const locked = readLock();
8929
- if (!locked) return;
8930
- if (locked === resolvedHubId) return;
8947
+ function assertHubMatchesBinding(resolvedHubId, hubLabel) {
8948
+ const bound = readBinding();
8949
+ if (!bound) return;
8950
+ if (bound === resolvedHubId) return;
8931
8951
  const target = hubLabel ? `${hubLabel} (${resolvedHubId})` : resolvedHubId;
8932
8952
  console.error(
8933
8953
  [
8934
- `This worktree is locked to hub ${locked}, but the command resolved to ${target}.`,
8954
+ `This worktree is bound to hub ${bound}, but the command resolved to ${target}.`,
8935
8955
  "",
8936
8956
  "This usually means a prompt was routed to the wrong worktree.",
8937
- "Confirm with the user before unlocking. To override:",
8938
- " wayai unlock # clear the lock for this worktree",
8957
+ "Confirm with the user before unbinding. To override:",
8958
+ " wayai unbind # clear the binding for this worktree",
8939
8959
  ` wayai use ${resolvedHubId} # rebind this worktree to the new hub`
8940
8960
  ].join("\n")
8941
8961
  );
8942
8962
  process.exit(1);
8943
8963
  }
8944
- function autoLockIfUnlocked(hubId) {
8964
+ function autoBindIfUnbound(hubId) {
8945
8965
  try {
8946
- if (readLock()) return false;
8947
- writeLock(hubId);
8948
- console.log(`Worktree locked to hub ${hubId} (run \`wayai unlock\` to clear).`);
8966
+ if (readBinding()) return false;
8967
+ writeBinding(hubId);
8968
+ console.log(`Worktree bound to hub ${hubId} (run \`wayai unbind\` to clear).`);
8949
8969
  return true;
8950
8970
  } catch (err) {
8951
- console.warn(` Warning: could not auto-lock worktree (${err instanceof Error ? err.message : String(err)})`);
8971
+ console.warn(` Warning: could not auto-bind worktree (${err instanceof Error ? err.message : String(err)})`);
8952
8972
  return false;
8953
8973
  }
8954
8974
  }
8955
- function assertNoLockBlocksHubCreation(newHubName) {
8956
- const locked = readLock();
8957
- if (!locked) return;
8975
+ function assertNoBindingBlocksHubCreation(newHubName) {
8976
+ const bound = readBinding();
8977
+ if (!bound) return;
8958
8978
  console.error(
8959
8979
  [
8960
- `This worktree is locked to hub ${locked}, but you're about to create a new hub "${newHubName}" here.`,
8980
+ `This worktree is bound to hub ${bound}, but you're about to create a new hub "${newHubName}" here.`,
8961
8981
  "",
8962
8982
  "This usually means a prompt was routed to the wrong worktree.",
8963
- "Confirm with the user before unlocking. To override:",
8964
- " wayai unlock # clear the lock for this worktree"
8983
+ "Confirm with the user before unbinding. To override:",
8984
+ " wayai unbind # clear the binding for this worktree"
8965
8985
  ].join("\n")
8966
8986
  );
8967
8987
  process.exit(1);
8968
8988
  }
8969
- var LOCK_FILENAME, _lockPathCache;
8970
- var init_hub_lock = __esm({
8971
- "src/lib/hub-lock.ts"() {
8989
+ var BINDING_FILENAME, LEGACY_BINDING_FILENAME, _gitDirCache;
8990
+ var init_hub_binding = __esm({
8991
+ "src/lib/hub-binding.ts"() {
8972
8992
  "use strict";
8973
8993
  init_utils();
8974
- LOCK_FILENAME = "wayai-lock";
8994
+ BINDING_FILENAME = "wayai-binding";
8995
+ LEGACY_BINDING_FILENAME = "wayai-lock";
8975
8996
  }
8976
8997
  });
8977
8998
 
@@ -9017,11 +9038,11 @@ async function statusCommand(args2, pkg2) {
9017
9038
  const cachedCliLatest = readCachedLatest(CLI_CACHE_FILE);
9018
9039
  const cliLatest = cachedCliLatest && isNewerVersion(cachedCliLatest, pkg2.version) ? cachedCliLatest : null;
9019
9040
  const skill = buildSkillState();
9020
- let lockedHubId = null;
9041
+ let boundHubId = null;
9021
9042
  try {
9022
- lockedHubId = readLock();
9043
+ boundHubId = readBinding();
9023
9044
  } catch {
9024
- lockedHubId = null;
9045
+ boundHubId = null;
9025
9046
  }
9026
9047
  if (!config) {
9027
9048
  const snapshot2 = {
@@ -9035,7 +9056,8 @@ async function statusCommand(args2, pkg2) {
9035
9056
  orgs: [],
9036
9057
  active_org: null,
9037
9058
  workspace,
9038
- worktree_lock: { hub_id: lockedHubId }
9059
+ worktree_binding: { hub_id: boundHubId },
9060
+ worktree_lock: { hub_id: boundHubId }
9039
9061
  };
9040
9062
  if (json) {
9041
9063
  console.log(JSON.stringify(snapshot2, null, 2));
@@ -9089,7 +9111,8 @@ async function statusCommand(args2, pkg2) {
9089
9111
  orgs,
9090
9112
  active_org: activeOrg,
9091
9113
  workspace,
9092
- worktree_lock: { hub_id: lockedHubId }
9114
+ worktree_binding: { hub_id: boundHubId },
9115
+ worktree_lock: { hub_id: boundHubId }
9093
9116
  };
9094
9117
  if (json) {
9095
9118
  console.log(JSON.stringify(snapshot, null, 2));
@@ -9119,8 +9142,8 @@ async function statusCommand(args2, pkg2) {
9119
9142
  } else {
9120
9143
  console.log("No .wayai.yaml found \u2014 run `wayai init` to scope this repo to an organization.");
9121
9144
  }
9122
- if (lockedHubId) {
9123
- console.log(`Worktree lock: ${lockedHubId} (run \`wayai unlock\` to clear)`);
9145
+ if (boundHubId) {
9146
+ console.log(`Worktree binding: ${boundHubId} (run \`wayai unbind\` to clear)`);
9124
9147
  }
9125
9148
  if (tokenValid === true && accessToken) {
9126
9149
  await nudgeReportActions(config.api_url, accessToken);
@@ -9133,7 +9156,7 @@ var init_status = __esm({
9133
9156
  init_auth();
9134
9157
  init_repo_config();
9135
9158
  init_workspace();
9136
- init_hub_lock();
9159
+ init_hub_binding();
9137
9160
  init_api_client();
9138
9161
  init_version_cache();
9139
9162
  init_skill_version();
@@ -10243,7 +10266,7 @@ async function pullCommand(args2) {
10243
10266
  }
10244
10267
  if (gitRoot) warnLayoutOnce(gitRoot);
10245
10268
  const { hubId, hubFolder: existingFolder } = resolveHubTarget(workspaceDir, hubSelector);
10246
- assertHubMatchesLock(hubId);
10269
+ assertHubMatchesBinding(hubId);
10247
10270
  console.log("Fetching hub configuration...");
10248
10271
  const payload = await client.pull(hubId, organizationId);
10249
10272
  if (payload.hub_environment === "production") {
@@ -10315,7 +10338,7 @@ async function pullCommand(args2) {
10315
10338
  }
10316
10339
  if (cancelled) return;
10317
10340
  }
10318
- if (wroteFiles) autoLockIfUnlocked(hubId);
10341
+ if (wroteFiles) autoBindIfUnbound(hubId);
10319
10342
  }
10320
10343
  async function downloadBinaryResourceFiles(hubFolder, payload) {
10321
10344
  const resources = payload.resources || [];
@@ -10355,7 +10378,7 @@ var init_pull = __esm({
10355
10378
  init_workspace();
10356
10379
  init_layout();
10357
10380
  init_repo_config();
10358
- init_hub_lock();
10381
+ init_hub_binding();
10359
10382
  }
10360
10383
  });
10361
10384
 
@@ -10602,7 +10625,7 @@ async function pushSingleHub(client, hubId, hubFolder, autoConfirm, organization
10602
10625
  } else {
10603
10626
  console.log("No changes to push; folder renamed.");
10604
10627
  }
10605
- autoLockIfUnlocked(hubId);
10628
+ autoBindIfUnbound(hubId);
10606
10629
  return true;
10607
10630
  }
10608
10631
  console.log("\nChanges to push:");
@@ -10618,7 +10641,7 @@ async function pushSingleHub(client, hubId, hubFolder, autoConfirm, organization
10618
10641
  const result = await client.push(hubId, localConfig, organizationId);
10619
10642
  printSyncResult(result);
10620
10643
  await syncAfterPush(client, hubId, hubFolder, organizationId);
10621
- autoLockIfUnlocked(hubId);
10644
+ autoBindIfUnbound(hubId);
10622
10645
  return true;
10623
10646
  }
10624
10647
  function resolveWorkspaceDir() {
@@ -10677,7 +10700,7 @@ async function pushCommand(args2) {
10677
10700
  const newHubs = scanNewHubs(workspaceDir);
10678
10701
  const existing = selectExistingHub(workspaceDir, existingHubs, hubSelector, wsLabel);
10679
10702
  if (existing) {
10680
- assertHubMatchesLock(existing.hubId, path14.basename(existing.hubFolder));
10703
+ assertHubMatchesBinding(existing.hubId, path14.basename(existing.hubFolder));
10681
10704
  await pushSingleHub(client, existing.hubId, existing.hubFolder, autoConfirm, organizationId);
10682
10705
  return;
10683
10706
  }
@@ -10696,7 +10719,7 @@ async function pushCommand(args2) {
10696
10719
  }
10697
10720
  process.exit(1);
10698
10721
  }
10699
- assertNoLockBlocksHubCreation(newHub.hubName);
10722
+ assertNoBindingBlocksHubCreation(newHub.hubName);
10700
10723
  const hubType = newHub.hubType || "chat";
10701
10724
  console.log(`
10702
10725
  New hub detected: "${newHub.hubName}" (${hubType})`);
@@ -10738,7 +10761,7 @@ hub_environment: preview
10738
10761
  ${content}`;
10739
10762
  }
10740
10763
  fs12.writeFileSync(hubYamlPath, updated, "utf-8");
10741
- autoLockIfUnlocked(hubId);
10764
+ autoBindIfUnbound(hubId);
10742
10765
  await pushSingleHub(client, hubId, newHub.hubFolder, autoConfirm, organizationId, { skipAgentRename: true });
10743
10766
  }
10744
10767
  var init_push = __esm({
@@ -10754,7 +10777,7 @@ var init_push = __esm({
10754
10777
  init_workspace();
10755
10778
  init_layout();
10756
10779
  init_repo_config();
10757
- init_hub_lock();
10780
+ init_hub_binding();
10758
10781
  }
10759
10782
  });
10760
10783
 
@@ -10792,13 +10815,13 @@ async function useCommand(args2) {
10792
10815
  }
10793
10816
  hubId = match.hubId;
10794
10817
  }
10795
- const previous = readLock();
10818
+ const previous = readBinding();
10796
10819
  if (previous === hubId) {
10797
- console.log(`Worktree already locked to ${hubId}.`);
10820
+ console.log(`Worktree already bound to ${hubId}.`);
10798
10821
  return;
10799
10822
  }
10800
10823
  try {
10801
- writeLock(hubId);
10824
+ writeBinding(hubId);
10802
10825
  } catch (err) {
10803
10826
  console.error(err instanceof Error ? err.message : String(err));
10804
10827
  process.exit(1);
@@ -10806,13 +10829,13 @@ async function useCommand(args2) {
10806
10829
  if (previous) {
10807
10830
  console.log(`Worktree rebound: ${previous} \u2192 ${hubId}`);
10808
10831
  } else {
10809
- console.log(`Worktree locked to hub ${hubId}.`);
10832
+ console.log(`Worktree bound to hub ${hubId}.`);
10810
10833
  }
10811
10834
  }
10812
10835
  var init_use = __esm({
10813
10836
  "src/commands/use.ts"() {
10814
10837
  "use strict";
10815
- init_hub_lock();
10838
+ init_hub_binding();
10816
10839
  init_workspace();
10817
10840
  init_layout();
10818
10841
  init_utils();
@@ -10912,24 +10935,24 @@ var init_migrate = __esm({
10912
10935
  }
10913
10936
  });
10914
10937
 
10915
- // src/commands/unlock.ts
10916
- var unlock_exports = {};
10917
- __export(unlock_exports, {
10918
- unlockCommand: () => unlockCommand
10938
+ // src/commands/unbind.ts
10939
+ var unbind_exports = {};
10940
+ __export(unbind_exports, {
10941
+ unbindCommand: () => unbindCommand
10919
10942
  });
10920
- async function unlockCommand(_args) {
10921
- const previous = readLock();
10943
+ async function unbindCommand(_args) {
10944
+ const previous = readBinding();
10922
10945
  if (!previous) {
10923
- console.log("No worktree lock to clear.");
10946
+ console.log("No worktree binding to clear.");
10924
10947
  return;
10925
10948
  }
10926
- clearLock();
10927
- console.log(`Worktree unlocked (was: ${previous}).`);
10949
+ clearBinding();
10950
+ console.log(`Worktree unbound (was: ${previous}).`);
10928
10951
  }
10929
- var init_unlock = __esm({
10930
- "src/commands/unlock.ts"() {
10952
+ var init_unbind = __esm({
10953
+ "src/commands/unbind.ts"() {
10931
10954
  "use strict";
10932
- init_hub_lock();
10955
+ init_hub_binding();
10933
10956
  }
10934
10957
  });
10935
10958
 
@@ -17027,11 +17050,11 @@ var init_admin = __esm({
17027
17050
 
17028
17051
  // src/commands/report-create.ts
17029
17052
  import { readFileSync as readFileSync14 } from "fs";
17030
- import { dirname as dirname7, join as join19 } from "path";
17053
+ import { dirname as dirname7, join as join20 } from "path";
17031
17054
  import { fileURLToPath as fileURLToPath2 } from "url";
17032
17055
  function getCliVersion() {
17033
17056
  try {
17034
- const pkg2 = JSON.parse(readFileSync14(join19(__dirname, "..", "..", "package.json"), "utf-8"));
17057
+ const pkg2 = JSON.parse(readFileSync14(join20(__dirname, "..", "..", "package.json"), "utf-8"));
17035
17058
  return `cli@${pkg2.version}`;
17036
17059
  } catch {
17037
17060
  return "cli@unknown";
@@ -17415,7 +17438,7 @@ var init_update = __esm({
17415
17438
  init_sentry();
17416
17439
  import { readFileSync as readFileSync15 } from "fs";
17417
17440
  import { fileURLToPath as fileURLToPath3 } from "url";
17418
- import { dirname as dirname8, join as join20 } from "path";
17441
+ import { dirname as dirname8, join as join21 } from "path";
17419
17442
 
17420
17443
  // src/lib/errors.ts
17421
17444
  init_api_client();
@@ -17544,7 +17567,7 @@ Run \`npx skills add wayai-pro/wayai-skill -y\` to update.`);
17544
17567
 
17545
17568
  // src/index.ts
17546
17569
  var __dirname2 = dirname8(fileURLToPath3(import.meta.url));
17547
- var pkg = JSON.parse(readFileSync15(join20(__dirname2, "..", "package.json"), "utf-8"));
17570
+ var pkg = JSON.parse(readFileSync15(join21(__dirname2, "..", "package.json"), "utf-8"));
17548
17571
  var [, , command, ...args] = process.argv;
17549
17572
  var isBackgroundRefresh = command === REFRESH_COMMAND;
17550
17573
  var OWN_HELP_COMMANDS = /* @__PURE__ */ new Set(["eval", "admin", "report"]);
@@ -17600,9 +17623,11 @@ async function main() {
17600
17623
  await migrateCommand2(args);
17601
17624
  break;
17602
17625
  }
17626
+ // `unlock` is the deprecated pre-rename alias for `unbind` (kept for back-compat).
17627
+ case "unbind":
17603
17628
  case "unlock": {
17604
- const { unlockCommand: unlockCommand2 } = await Promise.resolve().then(() => (init_unlock(), unlock_exports));
17605
- await unlockCommand2(args);
17629
+ const { unbindCommand: unbindCommand2 } = await Promise.resolve().then(() => (init_unbind(), unbind_exports));
17630
+ await unbindCommand2(args);
17606
17631
  break;
17607
17632
  }
17608
17633
  case "send-message": {
@@ -17726,9 +17751,9 @@ Commands:
17726
17751
  push Parse local files, show diff, sync to preview (creates hub if new)
17727
17752
  org create Create a new organization (you become its owner)
17728
17753
  org <pull|push|diff> Sync org-scoped resources as code (wayai-ws/org/)
17729
- use <hub> Lock this worktree to a specific hub (UUID or folder name)
17754
+ use <hub> Bind this worktree to a specific hub (UUID or folder name)
17730
17755
  migrate Move a legacy repo to the wayai-ws/{hubs,org} layout
17731
- unlock Clear the worktree hub lock
17756
+ unbind Clear the worktree hub binding
17732
17757
  send-message Send a test message to a preview hub
17733
17758
  conversations List or inspect conversations
17734
17759
  analytics Show analytics summary and metrics (use \`analytics query\` for structured ClickHouse queries)
@@ -17786,12 +17811,12 @@ Org-scoped mode:
17786
17811
  pull/push operate on the single hub in the workspace, or pass
17787
17812
  \`--hub <uuid|name>\` to disambiguate when multiple hubs exist.
17788
17813
 
17789
- Worktree hub lock:
17790
- Each git checkout (main or linked worktree) can be locked to a single hub.
17791
- push/pull refuse to run against a different hub once locked. The lock is
17792
- auto-set on first successful pull (or new-hub creation) into an unlocked
17793
- checkout. Use \`wayai use <hub>\` to bind manually and \`wayai unlock\` to clear.
17794
- The lock lives at \`<git-dir>/wayai-lock\` and is naturally per-checkout.
17814
+ Worktree hub binding:
17815
+ Each git checkout (main or linked worktree) can be bound to a single hub.
17816
+ push/pull refuse to run against a different hub once bound. The binding is
17817
+ auto-set on first successful pull (or new-hub creation) into an unbound
17818
+ checkout. Use \`wayai use <hub>\` to bind manually and \`wayai unbind\` to clear.
17819
+ The binding lives at \`<git-dir>/wayai-binding\` and is naturally per-checkout.
17795
17820
 
17796
17821
  Examples:
17797
17822
  wayai login