bamboo-agents 0.1.5-dev.15 → 0.1.5-dev.16

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5-dev.15
1
+ 0.1.5-dev.16
package/dist/index.js CHANGED
@@ -3037,7 +3037,7 @@ var VERSION;
3037
3037
  var init_version = __esm({
3038
3038
  "src/version.ts"() {
3039
3039
  "use strict";
3040
- VERSION = "0.1.5-dev.15";
3040
+ VERSION = "0.1.5-dev.16";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -11885,6 +11885,27 @@ async function checkGitCredentialForGitHub() {
11885
11885
  proc.stdin?.end();
11886
11886
  });
11887
11887
  }
11888
+ async function getRepoRemoteUrl(repoPath, remoteName = "origin") {
11889
+ try {
11890
+ const { stdout } = await execFileP(
11891
+ "git",
11892
+ ["-C", repoPath, "remote", "get-url", remoteName],
11893
+ { encoding: "utf8" }
11894
+ );
11895
+ return stdout.trim() || null;
11896
+ } catch {
11897
+ return null;
11898
+ }
11899
+ }
11900
+ function remoteUrlMatchesRepo(remoteUrl, repoFullName) {
11901
+ const expected = repoFullName.replace(/\.git$/i, "").toLowerCase();
11902
+ const url = remoteUrl.trim().replace(/\.git$/i, "");
11903
+ const httpsMatch = url.match(/^https?:\/\/[^/]*github\.com\/(.+)$/i);
11904
+ if (httpsMatch && httpsMatch[1].toLowerCase() === expected) return true;
11905
+ const sshMatch = url.match(/^[^@]+@github\.com:(.+)$/i);
11906
+ if (sshMatch && sshMatch[1].toLowerCase() === expected) return true;
11907
+ return false;
11908
+ }
11888
11909
  async function getGitConfig(key) {
11889
11910
  try {
11890
11911
  const { stdout } = await execFileP("git", ["config", "--global", "--get", key], {
@@ -12131,16 +12152,33 @@ async function runInit() {
12131
12152
  } catch {
12132
12153
  }
12133
12154
  if (dirExists) {
12155
+ const existingRemote = await getRepoRemoteUrl(repoPath);
12156
+ const matches = existingRemote != null && remoteUrlMatchesRepo(existingRemote, membership.org.workspace_repo);
12157
+ if (matches) {
12158
+ await writeConfig({
12159
+ org_id: membership.org.id,
12160
+ org_name: membership.org.name,
12161
+ workspace_repo: membership.org.workspace_repo,
12162
+ repo_path: repoPath,
12163
+ installed_at: (/* @__PURE__ */ new Date()).toISOString()
12164
+ });
12165
+ console.log("");
12166
+ console.log(` \u2713 Workspace already at ${repoPath}`);
12167
+ console.log(" (skipped clone \u2014 origin matches your workspace repo)");
12168
+ console.log(" Next: `bamboo-agents open` to launch Claude Code there.");
12169
+ console.log("");
12170
+ return;
12171
+ }
12134
12172
  console.error(
12135
12173
  `
12136
- ${repoPath} already exists.
12174
+ ${repoPath} already exists and is NOT the right repo.
12175
+
12176
+ ` + (existingRemote ? ` Found origin: ${existingRemote}
12177
+ Expected: github.com/${membership.org.workspace_repo}
12137
12178
 
12138
- If you've already initialized here, you can:
12139
- cd ${repoPath} && git pull origin main
12179
+ ` : ` It's not a git repo (no origin remote).
12140
12180
 
12141
- Or remove it and re-run init:
12142
- rm -rf ${repoPath} && bamboo-agents init
12143
- `
12181
+ `) + " Move or rename it, then re-run `bamboo-agents init`.\n"
12144
12182
  );
12145
12183
  process.exit(2);
12146
12184
  }