borgmcp 0.9.0 → 0.9.2
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/assimilate-cmd.d.ts +83 -0
- package/dist/assimilate-cmd.d.ts.map +1 -0
- package/dist/assimilate-cmd.js +232 -0
- package/dist/assimilate-cmd.js.map +1 -0
- package/dist/assimilate-deps.d.ts +12 -0
- package/dist/assimilate-deps.d.ts.map +1 -0
- package/dist/assimilate-deps.js +104 -0
- package/dist/assimilate-deps.js.map +1 -0
- package/dist/claude.js +14 -5
- package/dist/claude.js.map +1 -1
- package/dist/cube-name.d.ts +26 -0
- package/dist/cube-name.d.ts.map +1 -0
- package/dist/cube-name.js +67 -0
- package/dist/cube-name.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/name-validator.d.ts +7 -0
- package/dist/name-validator.d.ts.map +1 -0
- package/dist/name-validator.js +22 -0
- package/dist/name-validator.js.map +1 -0
- package/dist/parse-assimilate-args.d.ts +17 -0
- package/dist/parse-assimilate-args.d.ts.map +1 -0
- package/dist/parse-assimilate-args.js +67 -0
- package/dist/parse-assimilate-args.js.map +1 -0
- package/dist/remote-client.d.ts +36 -5
- package/dist/remote-client.d.ts.map +1 -1
- package/dist/remote-client.js +55 -7
- package/dist/remote-client.js.map +1 -1
- package/dist/role-resolver.d.ts +32 -0
- package/dist/role-resolver.d.ts.map +1 -0
- package/dist/role-resolver.js +36 -0
- package/dist/role-resolver.js.map +1 -0
- package/dist/spawn.d.ts +14 -113
- package/dist/spawn.d.ts.map +1 -1
- package/dist/spawn.js +25 -269
- package/dist/spawn.js.map +1 -1
- package/package.json +1 -1
package/dist/spawn.d.ts
CHANGED
|
@@ -1,116 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `borg spawn` —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `borg spawn builder` call creates `/path/to/borg-mcp-builder` as
|
|
15
|
-
* a sibling directory and runs `git worktree add` to register it.
|
|
16
|
-
* Default checkout is detached HEAD at the current HEAD so the new
|
|
17
|
-
* drone starts on a clean reference point without competing with
|
|
18
|
-
* the source worktree's branch state.
|
|
19
|
-
*
|
|
20
|
-
* Flags:
|
|
21
|
-
* --no-launch Create the worktree but don't run `borg` inside.
|
|
22
|
-
* Useful for setting up a tree to come back to later.
|
|
23
|
-
* --branch <ref> Check out a specific branch instead of detached
|
|
24
|
-
* HEAD. If <ref> is already checked out in another
|
|
25
|
-
* worktree, git refuses and we surface that error.
|
|
26
|
-
*
|
|
27
|
-
* Edge cases:
|
|
28
|
-
* - Not inside a git repo → friendly error, exit 1
|
|
29
|
-
* - Target path already exists → friendly error, exit 1
|
|
30
|
-
* - Empty name / name with slashes → format-hint error, exit 1
|
|
31
|
-
* - git worktree add fails → surface git's stderr verbatim, exit 1
|
|
32
|
-
*/
|
|
33
|
-
export interface SpawnArgs {
|
|
34
|
-
name: string;
|
|
35
|
-
noLaunch: boolean;
|
|
36
|
-
branch: string | null;
|
|
37
|
-
}
|
|
38
|
-
export type ParseResult = {
|
|
39
|
-
ok: true;
|
|
40
|
-
args: SpawnArgs;
|
|
41
|
-
} | {
|
|
42
|
-
ok: false;
|
|
43
|
-
error: string;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Parse `argv.slice(2)` (i.e. arguments to `borg`, with `spawn` already
|
|
47
|
-
* stripped) into a structured SpawnArgs or a friendly error.
|
|
48
|
-
*
|
|
49
|
-
* Supported shapes:
|
|
50
|
-
* borg spawn <name>
|
|
51
|
-
* borg spawn <name> --no-launch
|
|
52
|
-
* borg spawn <name> --branch <ref>
|
|
53
|
-
* borg spawn <name> --branch <ref> --no-launch
|
|
54
|
-
* (flag order doesn't matter; positional `<name>` may appear before
|
|
55
|
-
* or after the flags)
|
|
56
|
-
*
|
|
57
|
-
* Unknown flags and missing/duplicate positional name are caller-
|
|
58
|
-
* friendly errors with format hints.
|
|
59
|
-
*/
|
|
60
|
-
export declare function parseSpawnArgs(rawArgs: string[]): ParseResult;
|
|
61
|
-
export declare function validateName(name: string): {
|
|
62
|
-
ok: true;
|
|
63
|
-
} | {
|
|
64
|
-
ok: false;
|
|
65
|
-
error: string;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Given the absolute path to the primary worktree and a validated
|
|
69
|
-
* spawn name, return the absolute path of the new sibling worktree.
|
|
70
|
-
*
|
|
71
|
-
* Naming convention: `<sibling-parent>/<primary-basename>-<name>`.
|
|
72
|
-
* Example: primary `/home/x/borg-mcp` + name `builder` →
|
|
73
|
-
* `/home/x/borg-mcp-builder`. Keeps related worktrees alphabetically
|
|
74
|
-
* adjacent in `ls`, which matters when a drone-operator has a dozen
|
|
75
|
-
* sibling trees.
|
|
76
|
-
*
|
|
77
|
-
* Pure. Tested directly.
|
|
78
|
-
*/
|
|
79
|
-
export declare function computeWorktreePath(primaryWorktreeAbs: string, name: string): string;
|
|
80
|
-
export interface SpawnDeps {
|
|
81
|
-
/** Synchronous spawn — used for `git ...` invocations. */
|
|
82
|
-
runSync?: (cmd: string, args: string[], cwd?: string) => SpawnSyncResult;
|
|
83
|
-
/** Path existence — used to bail on collisions. */
|
|
84
|
-
pathExists?: (p: string) => boolean;
|
|
85
|
-
/** Async spawn — used to launch the in-worktree `borg`. */
|
|
86
|
-
runDetached?: (cmd: string, args: string[], cwd: string) => Promise<number>;
|
|
87
|
-
/** Inject for tests; defaults to `process.cwd()`. */
|
|
88
|
-
cwd?: () => string;
|
|
89
|
-
/** stderr sink — overridable for tests. */
|
|
90
|
-
stderr?: (line: string) => void;
|
|
91
|
-
}
|
|
92
|
-
export interface SpawnSyncResult {
|
|
93
|
-
status: number | null;
|
|
94
|
-
stdout: string;
|
|
95
|
-
stderr: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Run the `borg spawn` flow against the given args. Returns the
|
|
99
|
-
* desired process exit code. Pure side-effects flow through `deps`
|
|
100
|
-
* so tests can inject mocks for every external interaction.
|
|
101
|
-
*
|
|
102
|
-
* Flow:
|
|
103
|
-
* 1. Validate name
|
|
104
|
-
* 2. Resolve primary worktree path via `git rev-parse --show-toplevel`
|
|
105
|
-
* (run from the operator's cwd — handles nested worktrees by
|
|
106
|
-
* asking git to find the top, which always points at the current
|
|
107
|
-
* worktree's root; for our naming convention we want the
|
|
108
|
-
* `--git-common-dir` parent which IS the primary worktree's
|
|
109
|
-
* filesystem dir, NOT the current worktree's. Resolve below.)
|
|
110
|
-
* 3. Compute target path; abort if exists
|
|
111
|
-
* 4. Run `git worktree add <target> [<ref>|--detach HEAD]`
|
|
112
|
-
* 5. Print stderr nudge
|
|
113
|
-
* 6. If !noLaunch, exec `borg` inside the new worktree
|
|
2
|
+
* `borg spawn` — deprecation stub.
|
|
3
|
+
*
|
|
4
|
+
* Replaced by `borg assimilate [role] --worktree <name>` (see
|
|
5
|
+
* `assimilate-cmd.ts`). The new command folds worktree creation,
|
|
6
|
+
* OAuth bootstrap, cube creation, template application, and drone
|
|
7
|
+
* assimilation into one shell call. This file remains so existing
|
|
8
|
+
* scripts and tab-completion entries fail loudly with an actionable
|
|
9
|
+
* migration message rather than silently mis-routing.
|
|
10
|
+
*
|
|
11
|
+
* `validateName` continues to be re-exported from here for callers
|
|
12
|
+
* that still depend on the symbol (it lives in `name-validator.ts`
|
|
13
|
+
* now — single source of truth).
|
|
114
14
|
*/
|
|
115
|
-
export
|
|
15
|
+
export { validateName } from './name-validator.js';
|
|
16
|
+
export declare function runSpawn(): Promise<number>;
|
|
116
17
|
//# sourceMappingURL=spawn.d.ts.map
|
package/dist/spawn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAahD"}
|
package/dist/spawn.js
CHANGED
|
@@ -1,273 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `borg spawn` —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `borg spawn builder` call creates `/path/to/borg-mcp-builder` as
|
|
15
|
-
* a sibling directory and runs `git worktree add` to register it.
|
|
16
|
-
* Default checkout is detached HEAD at the current HEAD so the new
|
|
17
|
-
* drone starts on a clean reference point without competing with
|
|
18
|
-
* the source worktree's branch state.
|
|
19
|
-
*
|
|
20
|
-
* Flags:
|
|
21
|
-
* --no-launch Create the worktree but don't run `borg` inside.
|
|
22
|
-
* Useful for setting up a tree to come back to later.
|
|
23
|
-
* --branch <ref> Check out a specific branch instead of detached
|
|
24
|
-
* HEAD. If <ref> is already checked out in another
|
|
25
|
-
* worktree, git refuses and we surface that error.
|
|
26
|
-
*
|
|
27
|
-
* Edge cases:
|
|
28
|
-
* - Not inside a git repo → friendly error, exit 1
|
|
29
|
-
* - Target path already exists → friendly error, exit 1
|
|
30
|
-
* - Empty name / name with slashes → format-hint error, exit 1
|
|
31
|
-
* - git worktree add fails → surface git's stderr verbatim, exit 1
|
|
32
|
-
*/
|
|
33
|
-
import { spawnSync, spawn } from 'node:child_process';
|
|
34
|
-
import { existsSync } from 'node:fs';
|
|
35
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
36
|
-
import chalk from 'chalk';
|
|
37
|
-
/**
|
|
38
|
-
* Parse `argv.slice(2)` (i.e. arguments to `borg`, with `spawn` already
|
|
39
|
-
* stripped) into a structured SpawnArgs or a friendly error.
|
|
40
|
-
*
|
|
41
|
-
* Supported shapes:
|
|
42
|
-
* borg spawn <name>
|
|
43
|
-
* borg spawn <name> --no-launch
|
|
44
|
-
* borg spawn <name> --branch <ref>
|
|
45
|
-
* borg spawn <name> --branch <ref> --no-launch
|
|
46
|
-
* (flag order doesn't matter; positional `<name>` may appear before
|
|
47
|
-
* or after the flags)
|
|
48
|
-
*
|
|
49
|
-
* Unknown flags and missing/duplicate positional name are caller-
|
|
50
|
-
* friendly errors with format hints.
|
|
51
|
-
*/
|
|
52
|
-
export function parseSpawnArgs(rawArgs) {
|
|
53
|
-
let name = null;
|
|
54
|
-
let noLaunch = false;
|
|
55
|
-
let branch = null;
|
|
56
|
-
for (let i = 0; i < rawArgs.length; i += 1) {
|
|
57
|
-
const arg = rawArgs[i];
|
|
58
|
-
if (arg === '--no-launch') {
|
|
59
|
-
noLaunch = true;
|
|
60
|
-
}
|
|
61
|
-
else if (arg === '--branch') {
|
|
62
|
-
const next = rawArgs[i + 1];
|
|
63
|
-
if (typeof next !== 'string' || next.length === 0) {
|
|
64
|
-
return {
|
|
65
|
-
ok: false,
|
|
66
|
-
error: `--branch requires a ref argument (e.g. \`--branch main\`)`,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
branch = next;
|
|
70
|
-
i += 1;
|
|
71
|
-
}
|
|
72
|
-
else if (arg.startsWith('--')) {
|
|
73
|
-
return {
|
|
74
|
-
ok: false,
|
|
75
|
-
error: `unknown flag: ${arg}. Supported: --no-launch, --branch <ref>`,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
if (name !== null) {
|
|
80
|
-
return {
|
|
81
|
-
ok: false,
|
|
82
|
-
error: `unexpected extra argument: ${arg} (already have name "${name}")`,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
name = arg;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (name === null) {
|
|
89
|
-
return {
|
|
90
|
-
ok: false,
|
|
91
|
-
error: `missing required argument <name>. Usage: borg spawn <name> [--branch <ref>] [--no-launch]`,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return { ok: true, args: { name, noLaunch, branch } };
|
|
95
|
-
}
|
|
96
|
-
// ------------------------------------------------------------------
|
|
97
|
-
// Name validation
|
|
98
|
-
// ------------------------------------------------------------------
|
|
99
|
-
/**
|
|
100
|
-
* Worktree names get tacked onto the parent directory's path. They
|
|
101
|
-
* must therefore be filesystem-safe AND short enough that the
|
|
102
|
-
* resulting path doesn't make `ls` unreadable. Reject anything with
|
|
103
|
-
* slashes, parent-directory tokens, leading dashes (would parse as
|
|
104
|
-
* a flag), or shell-metacharacter punctuation.
|
|
105
|
-
*
|
|
106
|
-
* Allowed: lowercase ASCII letters, digits, hyphens, underscores.
|
|
107
|
-
* Length 1–48. Anchored. No leading hyphen.
|
|
108
|
-
*/
|
|
109
|
-
const NAME_RE = /^[a-z0-9_][a-z0-9_-]{0,47}$/;
|
|
110
|
-
export function validateName(name) {
|
|
111
|
-
if (name.length === 0) {
|
|
112
|
-
return { ok: false, error: `name must not be empty` };
|
|
113
|
-
}
|
|
114
|
-
if (!NAME_RE.test(name)) {
|
|
115
|
-
return {
|
|
116
|
-
ok: false,
|
|
117
|
-
error: `invalid name "${name}". Use lowercase letters, digits, hyphens, or ` +
|
|
118
|
-
`underscores; max 48 chars; must not start with a hyphen.`,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
return { ok: true };
|
|
122
|
-
}
|
|
123
|
-
// ------------------------------------------------------------------
|
|
124
|
-
// Path computation (pure)
|
|
125
|
-
// ------------------------------------------------------------------
|
|
126
|
-
/**
|
|
127
|
-
* Given the absolute path to the primary worktree and a validated
|
|
128
|
-
* spawn name, return the absolute path of the new sibling worktree.
|
|
129
|
-
*
|
|
130
|
-
* Naming convention: `<sibling-parent>/<primary-basename>-<name>`.
|
|
131
|
-
* Example: primary `/home/x/borg-mcp` + name `builder` →
|
|
132
|
-
* `/home/x/borg-mcp-builder`. Keeps related worktrees alphabetically
|
|
133
|
-
* adjacent in `ls`, which matters when a drone-operator has a dozen
|
|
134
|
-
* sibling trees.
|
|
135
|
-
*
|
|
136
|
-
* Pure. Tested directly.
|
|
137
|
-
*/
|
|
138
|
-
export function computeWorktreePath(primaryWorktreeAbs, name) {
|
|
139
|
-
const parent = dirname(primaryWorktreeAbs);
|
|
140
|
-
const base = basename(primaryWorktreeAbs);
|
|
141
|
-
return join(parent, `${base}-${name}`);
|
|
142
|
-
}
|
|
143
|
-
const defaultDeps = {
|
|
144
|
-
runSync: (cmd, args, cwd) => {
|
|
145
|
-
const r = spawnSync(cmd, args, { cwd, encoding: 'utf-8' });
|
|
146
|
-
return {
|
|
147
|
-
status: r.status,
|
|
148
|
-
stdout: r.stdout ?? '',
|
|
149
|
-
stderr: r.stderr ?? '',
|
|
150
|
-
};
|
|
151
|
-
},
|
|
152
|
-
pathExists: (p) => existsSync(p),
|
|
153
|
-
runDetached: (cmd, args, cwd) => new Promise((resolveExit, rejectExit) => {
|
|
154
|
-
const child = spawn(cmd, args, { cwd, stdio: 'inherit', shell: false });
|
|
155
|
-
child.on('error', rejectExit);
|
|
156
|
-
child.on('exit', (code) => resolveExit(code ?? 0));
|
|
157
|
-
}),
|
|
158
|
-
cwd: () => process.cwd(),
|
|
159
|
-
stderr: (line) => process.stderr.write(line),
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Run the `borg spawn` flow against the given args. Returns the
|
|
163
|
-
* desired process exit code. Pure side-effects flow through `deps`
|
|
164
|
-
* so tests can inject mocks for every external interaction.
|
|
165
|
-
*
|
|
166
|
-
* Flow:
|
|
167
|
-
* 1. Validate name
|
|
168
|
-
* 2. Resolve primary worktree path via `git rev-parse --show-toplevel`
|
|
169
|
-
* (run from the operator's cwd — handles nested worktrees by
|
|
170
|
-
* asking git to find the top, which always points at the current
|
|
171
|
-
* worktree's root; for our naming convention we want the
|
|
172
|
-
* `--git-common-dir` parent which IS the primary worktree's
|
|
173
|
-
* filesystem dir, NOT the current worktree's. Resolve below.)
|
|
174
|
-
* 3. Compute target path; abort if exists
|
|
175
|
-
* 4. Run `git worktree add <target> [<ref>|--detach HEAD]`
|
|
176
|
-
* 5. Print stderr nudge
|
|
177
|
-
* 6. If !noLaunch, exec `borg` inside the new worktree
|
|
178
|
-
*/
|
|
179
|
-
export async function runSpawn(args, deps = {}) {
|
|
180
|
-
const { runSync, pathExists, runDetached, cwd, stderr } = {
|
|
181
|
-
...defaultDeps,
|
|
182
|
-
...deps,
|
|
183
|
-
};
|
|
184
|
-
// (1) Name validation
|
|
185
|
-
const nameCheck = validateName(args.name);
|
|
186
|
-
if (!nameCheck.ok) {
|
|
187
|
-
stderr(chalk.red(`◼ borg spawn: ${nameCheck.error}\n`));
|
|
188
|
-
return 1;
|
|
189
|
-
}
|
|
190
|
-
// (2) Primary worktree resolution.
|
|
191
|
-
//
|
|
192
|
-
// `git rev-parse --git-common-dir` returns the path to the SHARED
|
|
193
|
-
// `.git` directory (the primary worktree's `.git`). The PRIMARY
|
|
194
|
-
// WORKTREE itself is that directory's parent — which is what we
|
|
195
|
-
// want to use as the basis for the sibling worktree's path. This
|
|
196
|
-
// resolution works correctly even when `borg spawn` is invoked
|
|
197
|
-
// from inside a non-primary worktree (e.g. the operator already
|
|
198
|
-
// cd'd into a sibling drone tree and wants to spin up another).
|
|
199
|
-
const cwdValue = cwd();
|
|
200
|
-
const gitCommonDir = runSync('git', ['rev-parse', '--git-common-dir'], cwdValue);
|
|
201
|
-
if (gitCommonDir.status !== 0) {
|
|
202
|
-
stderr(chalk.red(`◼ borg spawn: not in a git repository (cwd: ${cwdValue})\n`));
|
|
203
|
-
return 1;
|
|
204
|
-
}
|
|
205
|
-
const commonDirRaw = gitCommonDir.stdout.trim();
|
|
206
|
-
// `--git-common-dir` may print a relative path (e.g. `.git`); resolve
|
|
207
|
-
// against cwd to get an absolute reference.
|
|
208
|
-
const commonDirAbs = resolve(cwdValue, commonDirRaw);
|
|
209
|
-
// Strip the trailing `.git` segment to get the primary worktree root.
|
|
210
|
-
// commonDirAbs ends in `/.git` for a regular checkout, or in
|
|
211
|
-
// `/.git/worktrees/<name>` for a non-primary worktree's perspective
|
|
212
|
-
// (but `--common-dir` always returns the SHARED `.git`, so the suffix
|
|
213
|
-
// is just `/.git`). dirname() peels the `.git` segment off.
|
|
214
|
-
const primaryWorktree = basename(commonDirAbs) === '.git' ? dirname(commonDirAbs) : commonDirAbs;
|
|
215
|
-
// (3) Compute + collision-check target path
|
|
216
|
-
const targetPath = computeWorktreePath(primaryWorktree, args.name);
|
|
217
|
-
if (pathExists(targetPath)) {
|
|
218
|
-
stderr(chalk.red(`◼ borg spawn: target path already exists: ${targetPath}\n`));
|
|
219
|
-
return 1;
|
|
220
|
-
}
|
|
221
|
-
// (4) Create the worktree
|
|
222
|
-
const worktreeArgs = args.branch
|
|
223
|
-
? ['worktree', 'add', targetPath, args.branch]
|
|
224
|
-
: ['worktree', 'add', '--detach', targetPath, 'HEAD'];
|
|
225
|
-
const createResult = runSync('git', worktreeArgs, primaryWorktree);
|
|
226
|
-
if (createResult.status !== 0) {
|
|
227
|
-
const gitErr = createResult.stderr.trim() || createResult.stdout.trim();
|
|
228
|
-
stderr(chalk.red(`◼ borg spawn: git worktree add failed:\n${gitErr}\n`));
|
|
229
|
-
return 1;
|
|
230
|
-
}
|
|
231
|
-
// (5) Stderr nudge.
|
|
232
|
-
//
|
|
233
|
-
// Even though `git worktree add` already prints its own confirmation
|
|
234
|
-
// line, we add a short summary that names the next steps the operator
|
|
235
|
-
// typically wants — particularly the "checkout a branch and pull"
|
|
236
|
-
// reminder for the default detached case, which catches users who
|
|
237
|
-
// would otherwise start work on a stale HEAD without realising.
|
|
238
|
-
stderr(chalk.blue(`◼ Spawned worktree at ${targetPath}\n`));
|
|
239
|
-
if (!args.branch) {
|
|
240
|
-
const shortSha = readShortSha(runSync, targetPath);
|
|
241
|
-
stderr(chalk.gray(`◼ Detached HEAD at ${shortSha}\n`));
|
|
242
|
-
stderr(chalk.gray(`◼ Run \`git checkout main && git pull\` (or your repo's default branch) before starting work\n`));
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
stderr(chalk.gray(`◼ Checked out ${args.branch}\n`));
|
|
246
|
-
}
|
|
247
|
-
// (6) Optional drone launch.
|
|
248
|
-
if (args.noLaunch) {
|
|
249
|
-
stderr(chalk.gray(`◼ --no-launch: skipping borg launch\n`));
|
|
250
|
-
stderr(chalk.gray(` cd ${targetPath} && borg\n`));
|
|
251
|
-
return 0;
|
|
252
|
-
}
|
|
253
|
-
stderr(chalk.blue(`◼ Launching Claude Code in ${targetPath}…\n`));
|
|
254
|
-
try {
|
|
255
|
-
const code = await runDetached('borg', [], targetPath);
|
|
256
|
-
return code;
|
|
257
|
-
}
|
|
258
|
-
catch (err) {
|
|
259
|
-
stderr(chalk.red(`◼ borg spawn: failed to launch borg in new worktree: ${err?.message ?? err}\n`));
|
|
260
|
-
return 1;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Best-effort short SHA of the new worktree's HEAD. Used only for the
|
|
265
|
-
* cosmetic "Detached HEAD at <sha>" line; failure here is non-fatal.
|
|
2
|
+
* `borg spawn` — deprecation stub.
|
|
3
|
+
*
|
|
4
|
+
* Replaced by `borg assimilate [role] --worktree <name>` (see
|
|
5
|
+
* `assimilate-cmd.ts`). The new command folds worktree creation,
|
|
6
|
+
* OAuth bootstrap, cube creation, template application, and drone
|
|
7
|
+
* assimilation into one shell call. This file remains so existing
|
|
8
|
+
* scripts and tab-completion entries fail loudly with an actionable
|
|
9
|
+
* migration message rather than silently mis-routing.
|
|
10
|
+
*
|
|
11
|
+
* `validateName` continues to be re-exported from here for callers
|
|
12
|
+
* that still depend on the symbol (it lives in `name-validator.ts`
|
|
13
|
+
* now — single source of truth).
|
|
266
14
|
*/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
15
|
+
export { validateName } from './name-validator.js';
|
|
16
|
+
export async function runSpawn() {
|
|
17
|
+
const msg = 'borg spawn is removed. Use:\n' +
|
|
18
|
+
' borg assimilate [role] --worktree <name>\n' +
|
|
19
|
+
'\n' +
|
|
20
|
+
'Example: if you previously ran `borg spawn drone-2`, the equivalent is\n' +
|
|
21
|
+
' borg assimilate --worktree drone-2\n' +
|
|
22
|
+
'(role is optional; defaults per first-drone rules)\n' +
|
|
23
|
+
'\n' +
|
|
24
|
+
'If you want a specific role:\n' +
|
|
25
|
+
' borg assimilate builder --worktree drone-2\n';
|
|
26
|
+
process.stderr.write(msg);
|
|
27
|
+
return 2;
|
|
272
28
|
}
|
|
273
29
|
//# sourceMappingURL=spawn.js.map
|
package/dist/spawn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,GAAG,GACP,+BAA+B;QAC/B,8CAA8C;QAC9C,IAAI;QACJ,0EAA0E;QAC1E,wCAAwC;QACxC,sDAAsD;QACtD,IAAI;QACJ,gCAAgC;QAChC,gDAAgD,CAAC;IACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,CAAC;AACX,CAAC"}
|