@miraland-labs/conduit-bridge 0.16.16 → 0.16.17

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/checkout.js +30 -25
  2. package/package.json +1 -1
package/dist/checkout.js CHANGED
@@ -35,16 +35,39 @@ async function gitOriginUrl(workspace, exec) {
35
35
  }
36
36
  }
37
37
  /** A control-plane repository fingerprint needs a transport before Git can clone it. */
38
- function cloneRepositoryUrl(repositoryUrl) {
38
+ function cloneRepositoryUrls(repositoryUrl) {
39
39
  const value = repositoryUrl.trim();
40
40
  const slash = value.indexOf("/");
41
41
  if (slash <= 0 || value.startsWith(".") || value.includes("\\") || /^[^/@\s]+@[^:]+:/.test(value))
42
- return value;
42
+ return [value];
43
43
  const host = value.slice(0, slash);
44
44
  const path = value.slice(slash + 1);
45
45
  if (!host.includes(".") || /\s/.test(value) || path.split("/").filter(Boolean).length < 2)
46
- return value;
47
- return `https://${value}`;
46
+ return [value];
47
+ return [`https://${value}`, `git@${host}:${path}${path.endsWith(".git") ? "" : ".git"}`];
48
+ }
49
+ async function cloneWorkspace(workspace, repositoryUrls, exec, accessFn, readdirFn) {
50
+ let lastError;
51
+ for (const [index, repositoryUrl] of repositoryUrls.entries()) {
52
+ try {
53
+ await exec("git", ["clone", "--", repositoryUrl, workspace], {
54
+ timeout: 300_000,
55
+ maxBuffer: 2_000_000,
56
+ });
57
+ return;
58
+ }
59
+ catch (error) {
60
+ lastError = error;
61
+ if (index === repositoryUrls.length - 1)
62
+ break;
63
+ const exists = await pathExists(workspace, accessFn);
64
+ const entries = exists ? await readdirFn(workspace).catch(() => null) : [];
65
+ if (entries === null || entries.length > 0)
66
+ break;
67
+ }
68
+ }
69
+ const detail = lastError instanceof Error ? lastError.message : "clone_failed";
70
+ throw new Error(`ensure_checkout_clone_failed:${detail}`);
48
71
  }
49
72
  /**
50
73
  * Ensure `workspace` is a checkout of `repositoryUrl`.
@@ -61,20 +84,11 @@ export async function ensureCheckout(workspace, repositoryUrl, deps = {}) {
61
84
  const wanted = normalizeRepositoryUrl(repositoryUrl);
62
85
  if (!wanted)
63
86
  throw new Error("ensure_checkout_invalid_url");
64
- const cloneUrl = cloneRepositoryUrl(repositoryUrl);
87
+ const cloneUrls = cloneRepositoryUrls(repositoryUrl);
65
88
  const exists = await pathExists(workspace, accessFn);
66
89
  if (!exists) {
67
90
  await mkdirFn(dirname(workspace), { recursive: true });
68
- try {
69
- await exec("git", ["clone", "--", cloneUrl, workspace], {
70
- timeout: 300_000,
71
- maxBuffer: 2_000_000,
72
- });
73
- }
74
- catch (error) {
75
- const detail = error instanceof Error ? error.message : "clone_failed";
76
- throw new Error(`ensure_checkout_clone_failed:${detail}`);
77
- }
91
+ await cloneWorkspace(workspace, cloneUrls, exec, accessFn, readdirFn);
78
92
  const origin = await gitOriginUrl(workspace, exec);
79
93
  if (!origin || normalizeRepositoryUrl(origin) !== wanted) {
80
94
  throw new Error("ensure_checkout_clone_mismatch");
@@ -85,16 +99,7 @@ export async function ensureCheckout(workspace, repositoryUrl, deps = {}) {
85
99
  if (entries === null)
86
100
  throw new Error("ensure_checkout_path_unreadable");
87
101
  if (entries.length === 0) {
88
- try {
89
- await exec("git", ["clone", "--", cloneUrl, workspace], {
90
- timeout: 300_000,
91
- maxBuffer: 2_000_000,
92
- });
93
- }
94
- catch (error) {
95
- const detail = error instanceof Error ? error.message : "clone_failed";
96
- throw new Error(`ensure_checkout_clone_failed:${detail}`);
97
- }
102
+ await cloneWorkspace(workspace, cloneUrls, exec, accessFn, readdirFn);
98
103
  return "cloned";
99
104
  }
100
105
  const origin = await gitOriginUrl(workspace, exec);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miraland-labs/conduit-bridge",
3
- "version": "0.16.16",
3
+ "version": "0.16.17",
4
4
  "description": "Conduit Bridge CLI — join, connect, disconnect, multi-driver lanes, and run Claude Code / Codex / Cursor / OpenCode / Pi / Kiro / Antigravity / Grok Build agents for a Conduit organization",
5
5
  "type": "module",
6
6
  "bin": {