@driftless-sh/cli 0.1.37 → 0.1.38

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
@@ -214581,7 +214581,7 @@ async function installSkillCommand() {
214581
214581
  // src/commands/init.ts
214582
214582
  function getVersion() {
214583
214583
  try {
214584
- return "0.1.37";
214584
+ return "0.1.38";
214585
214585
  } catch {
214586
214586
  return "0.0.0";
214587
214587
  }
@@ -216045,31 +216045,45 @@ init_api_client();
216045
216045
  function notLinkedMessage(remote, workspaceSlug) {
216046
216046
  return `Repo '${remote.org}/${remote.repo}' is not registered in workspace '${workspaceSlug}'. Run \`driftless init\` to register it.`;
216047
216047
  }
216048
+ async function fetchRepos(slug) {
216049
+ try {
216050
+ const raw = await api.get(`/workspaces/${slug}/repos`);
216051
+ return Array.isArray(raw) ? raw : null;
216052
+ } catch {
216053
+ return null;
216054
+ }
216055
+ }
216048
216056
  async function resolveRepo() {
216049
216057
  const remote = getGitRemote();
216050
216058
  if (!remote) return { ok: false, reason: "no_remote" };
216051
- let workspaceSlug;
216059
+ let meSlug;
216052
216060
  try {
216053
216061
  const me = await api.get("/me");
216054
- workspaceSlug = me?.slug;
216062
+ meSlug = me?.slug;
216055
216063
  } catch {
216056
216064
  }
216057
- const slug = workspaceSlug ?? remote.org;
216058
- let repos = null;
216059
- try {
216060
- repos = await api.get(`/workspaces/${slug}/repos`);
216061
- } catch {
216065
+ const candidates = [...new Set([meSlug, remote.org].filter(Boolean))];
216066
+ let lastLinkedSlug;
216067
+ for (const slug of candidates) {
216068
+ const repos = await fetchRepos(slug);
216069
+ if (!repos) continue;
216070
+ const repo = repos.find((r) => r.github_org === remote.org && r.github_repo === remote.repo);
216071
+ if (repo) {
216072
+ return {
216073
+ ok: true,
216074
+ workspaceSlug: slug,
216075
+ repoId: repo.id,
216076
+ remote,
216077
+ hasScanBaseline: !!repo.scan_summary
216078
+ };
216079
+ }
216080
+ lastLinkedSlug = slug;
216062
216081
  }
216063
- if (!repos) return { ok: false, reason: "no_workspace", remote };
216064
- const repo = repos.find((r) => r.github_org === remote.org && r.github_repo === remote.repo);
216065
- if (!repo) return { ok: false, reason: "not_linked", workspaceSlug: slug, remote };
216066
- return {
216067
- ok: true,
216068
- workspaceSlug: slug,
216069
- repoId: repo.id,
216070
- remote,
216071
- hasScanBaseline: !!repo.scan_summary
216072
- };
216082
+ if (lastLinkedSlug) {
216083
+ return { ok: false, reason: "not_linked", workspaceSlug: lastLinkedSlug, remote };
216084
+ }
216085
+ const triedSlugs = candidates.join(", ");
216086
+ return { ok: false, reason: "no_workspace", remote, detail: `tried slugs: ${triedSlugs}` };
216073
216087
  }
216074
216088
 
216075
216089
  // src/commands/sync.ts
@@ -216099,7 +216113,9 @@ async function syncCommand(args) {
216099
216113
  const isJSON = !!flags["json"];
216100
216114
  const resolution = await resolveRepo();
216101
216115
  if (!resolution.ok) {
216102
- const msg = resolution.reason === "no_remote" ? "Error: no git remote configured." : resolution.reason === "no_workspace" ? "Error: could not resolve workspace. Run `driftless doctor` to diagnose." : notLinkedMessage(resolution.remote, resolution.workspaceSlug);
216116
+ const base = resolution.reason === "no_remote" ? "Error: no git remote configured." : resolution.reason === "no_workspace" ? "Error: could not resolve workspace." : notLinkedMessage(resolution.remote, resolution.workspaceSlug);
216117
+ const detail = resolution.reason === "no_workspace" && resolution.detail ? ` (${resolution.detail})` : "";
216118
+ const msg = base + detail;
216103
216119
  if (!isJSON) {
216104
216120
  console.log(`\u26A0 ${msg}`);
216105
216121
  if (resolution.reason !== "no_remote") console.log(" Run `driftless doctor` to diagnose.");
@@ -216389,7 +216405,7 @@ function pad2(s, n) {
216389
216405
  }
216390
216406
 
216391
216407
  // src/index.ts
216392
- var VERSION = "0.1.37";
216408
+ var VERSION = "0.1.38";
216393
216409
  var HELP_TEXT = `Driftless CLI v${VERSION} \u2014 Living repo context for humans and coding agents
216394
216410
 
216395
216411
  Install: npm install -g @driftless-sh/cli