@mycompbox/compbox-cli 1.20.0 → 1.21.1
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/.tsbuildinfo +1 -1
- package/commands/configure.d.ts +2 -0
- package/commands/configure.d.ts.map +1 -1
- package/commands/configure.js +34 -55
- package/commands/configure.js.map +1 -1
- package/commands/deploy.d.ts +22 -0
- package/commands/deploy.d.ts.map +1 -0
- package/commands/deploy.js +96 -0
- package/commands/deploy.js.map +1 -0
- package/commands/doctor.d.ts +14 -12
- package/commands/doctor.d.ts.map +1 -1
- package/commands/doctor.js +35 -19
- package/commands/doctor.js.map +1 -1
- package/commands/repo.d.ts +24 -0
- package/commands/repo.d.ts.map +1 -0
- package/commands/repo.js +81 -0
- package/commands/repo.js.map +1 -0
- package/commands/run.d.ts +0 -15
- package/commands/run.d.ts.map +1 -1
- package/commands/run.js +45 -28
- package/commands/run.js.map +1 -1
- package/commands/workspace.d.ts +56 -0
- package/commands/workspace.d.ts.map +1 -0
- package/commands/workspace.js +177 -0
- package/commands/workspace.js.map +1 -0
- package/index.js +654 -132
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/utils/agent-invoker.d.ts +33 -1
- package/utils/agent-invoker.d.ts.map +1 -1
- package/utils/agent-invoker.js +94 -13
- package/utils/agent-invoker.js.map +1 -1
- package/utils/config-store.d.ts +30 -58
- package/utils/config-store.d.ts.map +1 -1
- package/utils/config-store.js +27 -47
- package/utils/config-store.js.map +1 -1
- package/utils/mailbox-client.d.ts +23 -0
- package/utils/mailbox-client.d.ts.map +1 -1
- package/utils/mailbox-client.js +20 -0
- package/utils/mailbox-client.js.map +1 -1
- package/utils/run-workspace.d.ts +38 -4
- package/utils/run-workspace.d.ts.map +1 -1
- package/utils/run-workspace.js +126 -22
- package/utils/run-workspace.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/utils/config-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAC;AAEvD,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB
|
|
1
|
+
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/utils/config-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAC;AAEvD,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC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AAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC5C;;;;GAIG;GACD;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAE5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CAAE,GAC3C,gBAAgB,CAOlB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,GAAG,SAAS,EACrD,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMjD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAE9D,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASzD;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,IAAI,eAAe,EAAE,CAEnD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,kBAAqC,GAChD,eAAe,CAsBjB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAa9D"}
|
package/utils/config-store.js
CHANGED
|
@@ -124,66 +124,46 @@ export function applyPxpipeEnv(config, env = process.env) {
|
|
|
124
124
|
// undefined: promote nothing, so the resolver's default governs.
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
|
-
* Resolve the project
|
|
128
|
-
*
|
|
127
|
+
* Resolve the project directory for ONE dispatched job by its git-remote
|
|
128
|
+
* identity — the daemon's per-job routing decision.
|
|
129
129
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
130
|
+
* - `projectRemote` present and registered in `config.projectDirs` →
|
|
131
|
+
* `{ status: 'registered', path }`.
|
|
132
|
+
* - present but not registered → `{ status: 'unregistered', remote }`.
|
|
133
|
+
* - absent / normalizes to empty → `{ status: 'no-remote' }`.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
135
|
+
* `config.projectDir` (the old single default folder), `--project-dir` and
|
|
136
|
+
* `COMPBOX_PROJECT_DIR` are NEVER consulted: routing a job to a folder that
|
|
137
|
+
* isn't registered for its repository is the exact failure this prevents.
|
|
138
|
+
*
|
|
139
|
+
* Security invariant: the returned path is ALWAYS one already present in the
|
|
140
|
+
* local allowlist — never a server-supplied path.
|
|
139
141
|
*/
|
|
140
|
-
export function
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (typeof candidate === 'string' && candidate.trim().length > 0) {
|
|
145
|
-
return candidate.trim();
|
|
146
|
-
}
|
|
142
|
+
export function resolveProjectDirForJob(projectRemote, opts) {
|
|
143
|
+
const remote = normalizeGitRemote(projectRemote ?? '');
|
|
144
|
+
if (remote.length === 0) {
|
|
145
|
+
return { status: 'no-remote' };
|
|
147
146
|
}
|
|
148
|
-
|
|
147
|
+
const entry = (opts.config?.projectDirs ?? []).find((e) => e.remote === remote);
|
|
148
|
+
return entry ? { status: 'registered', path: entry.path } : { status: 'unregistered', remote };
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* Precedence:
|
|
155
|
-
* 1. When the job carries a `projectRemote` (ENG-176 sets it for repo-scoped
|
|
156
|
-
* teams): normalize it and look it up in the machine's allowlist
|
|
157
|
-
* (`config.projectDirs`, ENG-177). A match → `{ status: 'registered', path }`;
|
|
158
|
-
* NO match → `{ status: 'unregistered', remote }`. This branch NEVER falls
|
|
159
|
-
* back to the single-repo `config.projectDir` — routing a job to the wrong
|
|
160
|
-
* checkout is the exact failure this feature prevents.
|
|
161
|
-
* 2. When `projectRemote` is absent (or normalizes to empty — legacy/single-repo
|
|
162
|
-
* dispatch): defer to {@link resolveProjectDir}'s flag→env→config precedence,
|
|
163
|
-
* returning `{ status: 'fallback', path }` when set or `{ status: 'unresolved' }`
|
|
164
|
-
* when nothing is configured.
|
|
165
|
-
*
|
|
166
|
-
* Security invariant: the returned path is ALWAYS one already present in the local
|
|
167
|
-
* allowlist or the machine's own configuration — never a server-supplied path.
|
|
151
|
+
* The old single default folder this machine still has configured but no
|
|
152
|
+
* longer uses (from `config.projectDir` or `COMPBOX_PROJECT_DIR`), for doctor
|
|
153
|
+
* and startup warnings. Undefined when none is set.
|
|
168
154
|
*/
|
|
169
|
-
export function
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (entry) {
|
|
174
|
-
return { status: 'registered', path: entry.path };
|
|
155
|
+
export function unusedLegacyProjectDir(config, env = process.env) {
|
|
156
|
+
for (const candidate of [config?.projectDir, env[PROJECT_DIR_ENV]]) {
|
|
157
|
+
if (typeof candidate === 'string' && candidate.trim().length > 0) {
|
|
158
|
+
return candidate.trim();
|
|
175
159
|
}
|
|
176
|
-
return { status: 'unregistered', remote };
|
|
177
160
|
}
|
|
178
|
-
|
|
179
|
-
return fallback !== undefined
|
|
180
|
-
? { status: 'fallback', path: fallback }
|
|
181
|
-
: { status: 'unresolved' };
|
|
161
|
+
return undefined;
|
|
182
162
|
}
|
|
183
163
|
/**
|
|
184
164
|
* True when `dir` looks like a git repository — a `.git` entry (directory for a
|
|
185
165
|
* normal checkout, or a file for a worktree/submodule) exists inside it. Used to
|
|
186
|
-
* validate
|
|
166
|
+
* validate a registered folder before spawning the planner so a
|
|
187
167
|
* misconfigured path fails fast with an actionable message rather than letting
|
|
188
168
|
* `claude` start in a non-repo (where `.mcp.json`/`CLAUDE.md` would be absent).
|
|
189
169
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/utils/config-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/utils/config-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AA8EvD,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAE5C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAErD,+EAA+E;AAC/E,MAAM,UAAU,YAAY;IAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7C,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,QAAQ,CAAC;IA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kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,gBAAgB,CACjF,CAAC;IACF,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,YAAY,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -91,6 +91,14 @@ export interface MailboxJob {
|
|
|
91
91
|
createdAt: string;
|
|
92
92
|
updatedAt: string;
|
|
93
93
|
turns: MailboxJobTurn[];
|
|
94
|
+
/** Progress of the job's linked epic (from payload.epicId), when the server sends it. */
|
|
95
|
+
progress?: {
|
|
96
|
+
epicId: string;
|
|
97
|
+
totalFeatures: number;
|
|
98
|
+
completedFeatures: number;
|
|
99
|
+
totalTasks: number;
|
|
100
|
+
completedTasks: number;
|
|
101
|
+
} | null;
|
|
94
102
|
}
|
|
95
103
|
/** Normalized error for mailbox request failures with a stable HTTP-ish status. */
|
|
96
104
|
export declare class MailboxClientError extends Error {
|
|
@@ -165,6 +173,21 @@ export declare class MailboxClient {
|
|
|
165
173
|
* conversation stays open; this only links the job to the request.
|
|
166
174
|
*/
|
|
167
175
|
markRequestSaved(machineToken: string, jobId: string, epicRequestId: string): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Asks CompBox to open the run's pull request through the CompBox GitHub
|
|
178
|
+
* app. Throws when the project isn't connected through the app (409), so
|
|
179
|
+
* the caller can open it another way.
|
|
180
|
+
*/
|
|
181
|
+
openPullRequest(machineToken: string, jobId: string, input: {
|
|
182
|
+
branch: string;
|
|
183
|
+
base: string;
|
|
184
|
+
title: string;
|
|
185
|
+
body: string;
|
|
186
|
+
draft: boolean;
|
|
187
|
+
}): Promise<{
|
|
188
|
+
url: string;
|
|
189
|
+
number: number;
|
|
190
|
+
}>;
|
|
168
191
|
/** Reports what a run on the person's API key spent. */
|
|
169
192
|
reportAiUsage(machineToken: string, jobId: string, usage: KeyRunUsage): Promise<void>;
|
|
170
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox-client.d.ts","sourceRoot":"","sources":["../../src/utils/mailbox-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC;;;;;OAKG;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AAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,GACnF,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAe3C,wDAAwD;IAClD,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAa5F;AAED,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB"}
|
package/utils/mailbox-client.js
CHANGED
|
@@ -304,6 +304,26 @@ export class MailboxClient {
|
|
|
304
304
|
throw errorFromResponse(res, 'saved failed');
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Asks CompBox to open the run's pull request through the CompBox GitHub
|
|
309
|
+
* app. Throws when the project isn't connected through the app (409), so
|
|
310
|
+
* the caller can open it another way.
|
|
311
|
+
*/
|
|
312
|
+
async openPullRequest(machineToken, jobId, input) {
|
|
313
|
+
let res;
|
|
314
|
+
try {
|
|
315
|
+
res = await this.http.post(`/api/v1/jobs/${jobId}/pull-request`, input, {
|
|
316
|
+
headers: { Authorization: `Bearer ${machineToken}` },
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
throw toMailboxError(error, 'pull-request request failed');
|
|
321
|
+
}
|
|
322
|
+
if (res.status < 200 || res.status >= 300) {
|
|
323
|
+
throw errorFromResponse(res, 'pull-request failed');
|
|
324
|
+
}
|
|
325
|
+
return res.data.data;
|
|
326
|
+
}
|
|
307
327
|
/** Reports what a run on the person's API key spent. */
|
|
308
328
|
async reportAiUsage(machineToken, jobId, usage) {
|
|
309
329
|
let res;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox-client.js","sourceRoot":"","sources":["../../src/utils/mailbox-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,EAAsB,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mailbox-client.js","sourceRoot":"","sources":["../../src/utils/mailbox-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,EAAsB,YAAY,EAAE,MAAM,OAAO,CAAC;AAsGhE,mFAAmF;AACnF,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,2EAA2E;IAC3D,MAAM,CAAS;IAE/B,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,mFAAmF;AACnF,SAAS,oBAAoB,CAAC,IAAa;IACzC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAChE,MAAM,MAAM,GAAG,IAA0D,CAAC;IAC1E,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC;AACjD,CAAC;AAED,kFAAkF;AAClF,SAAS,cAAc,CAAC,KAAc,EAAE,QAAgB;IACtD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,oBAAoB,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC;QAC5E,OAAO,IAAI,kBAAkB,CAAC,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gBACtE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,YAAY,EAAE,EAAE;aACrD,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,cAAc,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YAC1C,MAAM,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;QACtD,CAAC;QACD,OAAQ,GAAG,CAAC,IAAkD,CAAC,IAAI,CAAC;IACtE,CAAC;IAED,wDAAwD;IACxD,KAAK,CAAC,aAAa,CAAC,YAAoB,EAAE,KAAa,EAAE,KAAkB;QACzE,IAAI,GAAG,CAAC;QACR,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,KAAK,WAAW,EAAE,KAAK,EAAE;gBAClE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,YAAY,EAAE,EAAE;aACrD,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,cAAc,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YAC1C,MAAM,iBAAiB,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF"}
|
package/utils/run-workspace.d.ts
CHANGED
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
* prepare: fetch → new branch `compbox/epic-<id>-<stamp>` from the remote's
|
|
13
13
|
* default branch → `git worktree add` under ~/.compbox/runs →
|
|
14
14
|
* copy local-only config (.mcp.json, .env files, …) → install deps.
|
|
15
|
-
* finish: commit anything left uncommitted → if the branch
|
|
16
|
-
* push it and open a pull request (draft when the run
|
|
17
|
-
* early) with `gh`, or report a compare link when `gh` is
|
|
18
|
-
* remove the worktree (the branch stays).
|
|
15
|
+
* finish: commit anything left uncommitted (`--no-verify`) → if the branch
|
|
16
|
+
* has commits, push it and open a pull request (draft when the run
|
|
17
|
+
* stopped early) with `gh`, or report a compare link when `gh` is
|
|
18
|
+
* missing → remove the worktree (the branch stays). Removal is its
|
|
19
|
+
* own step and runs only on a verified-clean worktree: if a commit
|
|
20
|
+
* fails or changes remain, the worktree is KEPT and the run is
|
|
21
|
+
* flagged `needsAttention`.
|
|
19
22
|
*
|
|
20
23
|
* The person's own checkout is never switched, committed to or pushed.
|
|
21
24
|
* Every git/gh/install call goes through an injectable runner so tests never
|
|
@@ -48,6 +51,8 @@ export interface RunWorkspace {
|
|
|
48
51
|
baseBranch: string;
|
|
49
52
|
/** The remote to push to, or null when the repo has none. */
|
|
50
53
|
remote: string | null;
|
|
54
|
+
/** True when the run continues an earlier unfinished run's branch instead of starting a new one. */
|
|
55
|
+
continued?: boolean;
|
|
51
56
|
}
|
|
52
57
|
export type PrepareResult = {
|
|
53
58
|
ok: true;
|
|
@@ -76,6 +81,12 @@ export interface FinishResult {
|
|
|
76
81
|
compareUrl?: string;
|
|
77
82
|
/** Set when the worktree was kept (so nothing is lost). */
|
|
78
83
|
keptWorktree?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The run's work isn't safely on a branch (a commit failed, or changes are
|
|
86
|
+
* still uncommitted in {@link keptWorktree}). The job must not be reported
|
|
87
|
+
* as done.
|
|
88
|
+
*/
|
|
89
|
+
needsAttention?: boolean;
|
|
79
90
|
/** Plain-language notes on anything that didn't go as planned. */
|
|
80
91
|
notes: string[];
|
|
81
92
|
}
|
|
@@ -92,7 +103,19 @@ export declare function installCommand(dir: string, exists?: (path: string) => b
|
|
|
92
103
|
*/
|
|
93
104
|
export declare function githubCompareUrl(remoteUrl: string, baseBranch: string, branch: string): string | null;
|
|
94
105
|
export declare function withRepoLock<T>(projectDir: string, task: () => Promise<T>): Promise<T>;
|
|
106
|
+
/** Opens a pull request through CompBox's GitHub app; throws when it can't. */
|
|
107
|
+
export type OpenPullRequest = (input: {
|
|
108
|
+
branch: string;
|
|
109
|
+
base: string;
|
|
110
|
+
title: string;
|
|
111
|
+
body: string;
|
|
112
|
+
draft: boolean;
|
|
113
|
+
}) => Promise<{
|
|
114
|
+
url: string;
|
|
115
|
+
}>;
|
|
95
116
|
export interface RunWorkspaceDeps {
|
|
117
|
+
/** Tried first; `gh` on this computer is the fallback. */
|
|
118
|
+
openPullRequest?: OpenPullRequest;
|
|
96
119
|
run?: CommandRunner;
|
|
97
120
|
now?: () => Date;
|
|
98
121
|
/** Where worktrees go (defaults to `~/.compbox/runs`). */
|
|
@@ -108,13 +131,24 @@ export declare class RunWorkspaceManager {
|
|
|
108
131
|
private readonly exists;
|
|
109
132
|
private readonly copyFile;
|
|
110
133
|
private readonly env;
|
|
134
|
+
private readonly openPullRequest;
|
|
111
135
|
constructor(deps?: RunWorkspaceDeps);
|
|
112
136
|
private git;
|
|
113
137
|
/** Creates the branch + worktree for a run. Never touches the person's checkout. */
|
|
114
138
|
prepare(projectDir: string, epicId: string): Promise<PrepareResult>;
|
|
115
139
|
private createWorktree;
|
|
140
|
+
/** The newest pushed run branch for this epic that isn't merged into the base yet, if any. */
|
|
141
|
+
private unfinishedBranch;
|
|
116
142
|
/** Commits, pushes and opens the pull request; then cleans up the worktree. */
|
|
117
143
|
finish(input: FinishInput): Promise<FinishResult>;
|
|
118
144
|
private finishLocked;
|
|
145
|
+
/** True when the worktree has uncommitted (or unreadable) state. */
|
|
146
|
+
private isDirty;
|
|
147
|
+
/**
|
|
148
|
+
* Removes a run's worktree — a separate step, run only once the worktree is
|
|
149
|
+
* verified clean (everything is committed). Returns false, keeping the
|
|
150
|
+
* worktree and noting why, when it still has changes.
|
|
151
|
+
*/
|
|
152
|
+
private removeWorktree;
|
|
119
153
|
}
|
|
120
154
|
//# sourceMappingURL=run-workspace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-workspace.d.ts","sourceRoot":"","sources":["../../src/utils/run-workspace.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"run-workspace.d.ts","sourceRoot":"","sources":["../../src/utils/run-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAQH,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAErG,wEAAwE;AACxE,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAM/C,eAAO,MAAM,oBAAoB,EAAE,aAmC/B,CAAC;AAEL,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oGAAoG;IACpG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElH,MAAM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,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;YAInC,YAAY;IA6H1B,oEAAoE;YACtD,OAAO;IAMrB;;;;OAIG;YACW,cAAc;CAU7B"}
|
package/utils/run-workspace.js
CHANGED
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
* prepare: fetch → new branch `compbox/epic-<id>-<stamp>` from the remote's
|
|
13
13
|
* default branch → `git worktree add` under ~/.compbox/runs →
|
|
14
14
|
* copy local-only config (.mcp.json, .env files, …) → install deps.
|
|
15
|
-
* finish: commit anything left uncommitted → if the branch
|
|
16
|
-
* push it and open a pull request (draft when the run
|
|
17
|
-
* early) with `gh`, or report a compare link when `gh` is
|
|
18
|
-
* remove the worktree (the branch stays).
|
|
15
|
+
* finish: commit anything left uncommitted (`--no-verify`) → if the branch
|
|
16
|
+
* has commits, push it and open a pull request (draft when the run
|
|
17
|
+
* stopped early) with `gh`, or report a compare link when `gh` is
|
|
18
|
+
* missing → remove the worktree (the branch stays). Removal is its
|
|
19
|
+
* own step and runs only on a verified-clean worktree: if a commit
|
|
20
|
+
* fails or changes remain, the worktree is KEPT and the run is
|
|
21
|
+
* flagged `needsAttention`.
|
|
19
22
|
*
|
|
20
23
|
* The person's own checkout is never switched, committed to or pushed.
|
|
21
24
|
* Every git/gh/install call goes through an injectable runner so tests never
|
|
@@ -133,7 +136,9 @@ export class RunWorkspaceManager {
|
|
|
133
136
|
exists;
|
|
134
137
|
copyFile;
|
|
135
138
|
env;
|
|
139
|
+
openPullRequest;
|
|
136
140
|
constructor(deps = {}) {
|
|
141
|
+
this.openPullRequest = deps.openPullRequest;
|
|
137
142
|
this.run = deps.run ?? defaultCommandRunner;
|
|
138
143
|
this.now = deps.now ?? (() => new Date());
|
|
139
144
|
this.runsRoot = deps.runsRoot ?? join(getConfigDir(), 'runs');
|
|
@@ -206,11 +211,27 @@ export class RunWorkspaceManager {
|
|
|
206
211
|
baseRef = 'HEAD';
|
|
207
212
|
}
|
|
208
213
|
const when = stamp(this.now());
|
|
209
|
-
const branch = `compbox/epic-${slugForBranch(epicId)}-${when}`;
|
|
210
214
|
const dir = join(this.runsRoot, `${slugForBranch(basename(projectDir))}-${slugForBranch(epicId)}-${when}`);
|
|
211
215
|
mkdirSync(this.runsRoot, { recursive: true });
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
// A build that stopped early left its work on a pushed branch. Sending the
|
|
217
|
+
// build again continues on that branch (and its pull request) rather than
|
|
218
|
+
// starting over from the base branch.
|
|
219
|
+
let branch = `compbox/epic-${slugForBranch(epicId)}-${when}`;
|
|
220
|
+
let continued = false;
|
|
221
|
+
const previous = remote ? await this.unfinishedBranch(remote, slugForBranch(epicId), baseRef, projectDir) : null;
|
|
222
|
+
if (remote && previous) {
|
|
223
|
+
const resume = await this.git(['worktree', 'add', '-B', previous, dir, `${remote}/${previous}`], projectDir);
|
|
224
|
+
if (resume.status === 0) {
|
|
225
|
+
branch = previous;
|
|
226
|
+
continued = true;
|
|
227
|
+
notes.push(`Continuing the earlier unfinished work on ${previous}.`);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
notes.push(`Couldn't continue the earlier unfinished branch ${previous} (${firstLine(resume.stderr) || 'unknown error'}), so the run starts a new branch.`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const add = continued ? null : await this.git(['worktree', 'add', '-b', branch, dir, baseRef], projectDir);
|
|
234
|
+
if (add && add.status !== 0) {
|
|
214
235
|
return {
|
|
215
236
|
ok: false,
|
|
216
237
|
error: [
|
|
@@ -233,7 +254,17 @@ export class RunWorkspaceManager {
|
|
|
233
254
|
notes.push(`Couldn't copy ${path} into the run workspace.`);
|
|
234
255
|
}
|
|
235
256
|
}
|
|
236
|
-
return { ok: true, workspace: { dir, projectDir, branch, baseRef, baseBranch, remote }, notes };
|
|
257
|
+
return { ok: true, workspace: { dir, projectDir, branch, baseRef, baseBranch, remote, continued }, notes };
|
|
258
|
+
}
|
|
259
|
+
/** The newest pushed run branch for this epic that isn't merged into the base yet, if any. */
|
|
260
|
+
async unfinishedBranch(remote, epicSlug, baseRef, projectDir) {
|
|
261
|
+
const refs = await this.git(['for-each-ref', '--sort=-refname', '--format=%(refname:short)', `refs/remotes/${remote}/compbox/epic-${epicSlug}-*`], projectDir);
|
|
262
|
+
const latest = refs.stdout.split('\n').map((r) => r.trim()).find(Boolean);
|
|
263
|
+
if (!latest?.startsWith(`${remote}/`))
|
|
264
|
+
return null;
|
|
265
|
+
if ((await this.git(['merge-base', '--is-ancestor', latest, baseRef], projectDir)).status === 0)
|
|
266
|
+
return null;
|
|
267
|
+
return latest.slice(remote.length + 1);
|
|
237
268
|
}
|
|
238
269
|
/** Commits, pushes and opens the pull request; then cleans up the worktree. */
|
|
239
270
|
finish(input) {
|
|
@@ -242,23 +273,48 @@ export class RunWorkspaceManager {
|
|
|
242
273
|
async finishLocked(input) {
|
|
243
274
|
const { workspace: ws } = input;
|
|
244
275
|
const notes = [];
|
|
245
|
-
|
|
276
|
+
// Whether the run left anything uncommitted — read BEFORE committing, so
|
|
277
|
+
// "no code changes" is only ever reported for a truly clean worktree.
|
|
278
|
+
const dirtyBefore = await this.isDirty(ws.dir);
|
|
279
|
+
let commitFailed = false;
|
|
280
|
+
if (dirtyBefore) {
|
|
246
281
|
await this.git(['add', '-A'], ws.dir);
|
|
247
|
-
|
|
282
|
+
// --no-verify: these are the run's own commits, not the person's; review
|
|
283
|
+
// happens on the pull request. A repo pre-commit hook (e.g. one running
|
|
284
|
+
// the full test suite) once failed this commit and the work was lost.
|
|
285
|
+
const commit = await this.git(['commit', '--no-verify', '-m', `chore(compbox): save work left uncommitted by the orchestrator (epic ${input.epicId})`], ws.dir);
|
|
248
286
|
if (commit.status !== 0) {
|
|
249
|
-
|
|
287
|
+
commitFailed = true;
|
|
288
|
+
notes.push(`Couldn't commit the remaining changes: ${firstLine(commit.stderr) || firstLine(commit.stdout) || 'unknown error'}`);
|
|
250
289
|
}
|
|
251
290
|
}
|
|
252
291
|
const commits = Number.parseInt((await this.git(['rev-list', '--count', `${ws.baseRef}..HEAD`], ws.dir)).stdout.trim(), 10) || 0;
|
|
253
292
|
const base = { branch: ws.branch, commits, pushed: false, notes };
|
|
293
|
+
// Never remove a worktree that still holds uncommitted work: keep it, say
|
|
294
|
+
// where it is, and flag the run for attention.
|
|
295
|
+
if (commitFailed || (dirtyBefore && (await this.isDirty(ws.dir)))) {
|
|
296
|
+
notes.push(`The run's changes couldn't all be committed, so nothing was removed. They are safe in ${ws.dir} on branch ${ws.branch}.`);
|
|
297
|
+
return { ...base, keptWorktree: ws.dir, needsAttention: true };
|
|
298
|
+
}
|
|
254
299
|
if (commits === 0) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
300
|
+
if (!dirtyBefore) {
|
|
301
|
+
if (await this.removeWorktree(ws, notes)) {
|
|
302
|
+
await this.git(['branch', '-D', ws.branch], ws.projectDir);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
return { ...base, keptWorktree: ws.dir, needsAttention: true };
|
|
306
|
+
}
|
|
307
|
+
notes.push('The run made no code changes, so there is nothing to review.');
|
|
308
|
+
return base;
|
|
309
|
+
}
|
|
310
|
+
// Changes existed but no commit landed — keep everything.
|
|
311
|
+
notes.push(`The run's changes didn't end up in a commit, so nothing was removed. Check ${ws.dir} on branch ${ws.branch}.`);
|
|
312
|
+
return { ...base, keptWorktree: ws.dir, needsAttention: true };
|
|
259
313
|
}
|
|
260
314
|
if (!ws.remote || this.env[RUN_PUSH_ENV] === '0') {
|
|
261
|
-
await this.
|
|
315
|
+
if (!(await this.removeWorktree(ws, notes))) {
|
|
316
|
+
return { ...base, keptWorktree: ws.dir, needsAttention: true };
|
|
317
|
+
}
|
|
262
318
|
notes.push(ws.remote
|
|
263
319
|
? `Pushing is turned off (${RUN_PUSH_ENV}=0). The work is on the local branch ${ws.branch}.`
|
|
264
320
|
: `The repository has no remote, so the work is on the local branch ${ws.branch}.`);
|
|
@@ -279,11 +335,30 @@ export class RunWorkspaceManager {
|
|
|
279
335
|
'',
|
|
280
336
|
`${String(commits)} commit${commits === 1 ? '' : 's'} on \`${ws.branch}\`, based on \`${ws.baseBranch}\`.`,
|
|
281
337
|
].join('\n');
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
338
|
+
// CompBox's GitHub app first (no local GitHub CLI needed), then `gh`.
|
|
339
|
+
let prUrl;
|
|
340
|
+
if (this.openPullRequest) {
|
|
341
|
+
try {
|
|
342
|
+
prUrl = (await this.openPullRequest({ branch: ws.branch, base: ws.baseBranch, title, body, draft: !input.completed })).url;
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
prUrl = undefined;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
let pr = { status: 0, stdout: '', stderr: '' };
|
|
349
|
+
if (!prUrl) {
|
|
350
|
+
const prArgs = ['pr', 'create', '--base', ws.baseBranch, '--head', ws.branch, '--title', title, '--body', body];
|
|
351
|
+
if (!input.completed)
|
|
352
|
+
prArgs.push('--draft');
|
|
353
|
+
pr = await this.run('gh', prArgs, ws.dir);
|
|
354
|
+
prUrl = pr.status === 0 ? /https:\/\/\S+/.exec(pr.stdout)?.[0] : undefined;
|
|
355
|
+
if (!prUrl && ws.continued) {
|
|
356
|
+
// The continued branch usually has its pull request already.
|
|
357
|
+
const existing = await this.run('gh', ['pr', 'view', ws.branch, '--json', 'url', '--jq', '.url'], ws.dir);
|
|
358
|
+
if (existing.status === 0)
|
|
359
|
+
prUrl = /https:\/\/\S+/.exec(existing.stdout)?.[0];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
287
362
|
let compareUrl;
|
|
288
363
|
if (!prUrl) {
|
|
289
364
|
const remoteUrl = (await this.git(['remote', 'get-url', ws.remote], ws.dir)).stdout.trim();
|
|
@@ -291,8 +366,37 @@ export class RunWorkspaceManager {
|
|
|
291
366
|
notes.push(`The branch was pushed, but the pull request couldn't be opened automatically${firstLine(pr.stderr) ? ` (${firstLine(pr.stderr)})` : ''}.` +
|
|
292
367
|
(compareUrl ? ' Use the link to open it.' : ` Open a pull request for ${ws.branch} on your git host.`));
|
|
293
368
|
}
|
|
369
|
+
// The branch is pushed, so the worktree can go (removeWorktree still
|
|
370
|
+
// re-checks it is clean first).
|
|
371
|
+
const removed = await this.removeWorktree(ws, notes);
|
|
372
|
+
return {
|
|
373
|
+
...base,
|
|
374
|
+
pushed: true,
|
|
375
|
+
...(prUrl ? { prUrl } : {}),
|
|
376
|
+
...(compareUrl ? { compareUrl } : {}),
|
|
377
|
+
...(removed ? {} : { keptWorktree: ws.dir, needsAttention: true }),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/** True when the worktree has uncommitted (or unreadable) state. */
|
|
381
|
+
async isDirty(dir) {
|
|
382
|
+
const status = await this.git(['status', '--porcelain'], dir);
|
|
383
|
+
// A failed `git status` counts as dirty: never assume a worktree is clean.
|
|
384
|
+
return status.status !== 0 || status.stdout.trim().length > 0;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Removes a run's worktree — a separate step, run only once the worktree is
|
|
388
|
+
* verified clean (everything is committed). Returns false, keeping the
|
|
389
|
+
* worktree and noting why, when it still has changes.
|
|
390
|
+
*/
|
|
391
|
+
async removeWorktree(ws, notes) {
|
|
392
|
+
if (await this.isDirty(ws.dir)) {
|
|
393
|
+
notes.push(`The run's folder still has uncommitted changes, so it was kept: ${ws.dir} (branch ${ws.branch}).`);
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
// --force only skips git's own check for ignored/submodule state; this
|
|
397
|
+
// method already verified there is nothing uncommitted.
|
|
294
398
|
await this.git(['worktree', 'remove', '--force', ws.dir], ws.projectDir);
|
|
295
|
-
return
|
|
399
|
+
return true;
|
|
296
400
|
}
|
|
297
401
|
}
|
|
298
402
|
//# sourceMappingURL=run-workspace.js.map
|