@detergent-software/conductor 1.3.0-dev.5 → 1.3.0-dev.7
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/CHANGELOG.md +21 -0
- package/README.md +28 -2
- package/build/checkout.js +139 -0
- package/build/checkout.js.map +1 -0
- package/build/cli.js +103 -27
- package/build/cli.js.map +1 -1
- package/build/code-host-cli.js +417 -0
- package/build/code-host-cli.js.map +1 -0
- package/build/code-host-service.js +74 -0
- package/build/code-host-service.js.map +1 -0
- package/build/code-host.js +143 -0
- package/build/code-host.js.map +1 -0
- package/build/conditions.js +9 -6
- package/build/conditions.js.map +1 -1
- package/build/credentials.js +29 -12
- package/build/credentials.js.map +1 -1
- package/build/daemon.js +3 -0
- package/build/daemon.js.map +1 -1
- package/build/help.js +76 -2
- package/build/help.js.map +1 -1
- package/build/landing.js +142 -0
- package/build/landing.js.map +1 -0
- package/build/lib/providers/ado/writes.js +8 -10
- package/build/lib/providers/ado/writes.js.map +1 -1
- package/build/ownership.js +57 -0
- package/build/ownership.js.map +1 -0
- package/build/server.js +74 -6
- package/build/server.js.map +1 -1
- package/build/store.js +8 -0
- package/build/store.js.map +1 -1
- package/build/watchers/ado.js +43 -6
- package/build/watchers/ado.js.map +1 -1
- package/build/watchers/github.js +9 -3
- package/build/watchers/github.js.map +1 -1
- package/build/watchers/index.js +26 -3
- package/build/watchers/index.js.map +1 -1
- package/build/watchers/source.js +17 -0
- package/build/watchers/source.js.map +1 -1
- package/build/worktrees.js +26 -36
- package/build/worktrees.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, isAbsolute, join, sep } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { aheadBehind, branchOf, checkoutBase, commitlint, needsPush, otherCheckouts, push, realDirty, REPOS_DIR, runGit, } from "./checkout.js";
|
|
5
|
+
import { callApi, NotRunningError } from "./client.js";
|
|
6
|
+
import { baseOf, checkoutDir, openPr, prChecks, projectHosts, prTarget, prThreads, replyOnPr, repoKey, repoOf, } from "./code-host.js";
|
|
7
|
+
import { loadConfig } from "./config.js";
|
|
8
|
+
import { LoginNeeded, providerCredentials, PROVIDERS } from "./credentials.js";
|
|
9
|
+
import { ConductorError, LOGIN_NEEDED_EXIT } from "./errors.js";
|
|
10
|
+
import { landPr } from "./landing.js";
|
|
11
|
+
import { githubRepoRef } from "./lib/providers/index.js";
|
|
12
|
+
import { branchName, itemKey } from "./ownership.js";
|
|
13
|
+
import { PROFILE_FILE, readProfile, trackerKey } from "./profile.js";
|
|
14
|
+
import { outputOf } from "./run.js";
|
|
15
|
+
import { daemonWorker, gitToplevel } from "./wait.js";
|
|
16
|
+
// A lost login the daemon met while writing for this worker: the verb exits 5 as for one met here.
|
|
17
|
+
class DaemonLoginNeeded extends ConductorError {
|
|
18
|
+
provider;
|
|
19
|
+
constructor(message, provider) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'DaemonLoginNeeded';
|
|
22
|
+
this.provider = provider;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// A write the daemon makes for the worker, 2 minutes: it reads the PR and writes a few times.
|
|
26
|
+
const WRITE_TIMEOUT_MS = 120_000;
|
|
27
|
+
const refusedBody = z.object({
|
|
28
|
+
details: z.array(z.string()).optional(),
|
|
29
|
+
error: z.string(),
|
|
30
|
+
login: z.object({ command: z.string(), provider: z.enum(PROVIDERS) }).optional(),
|
|
31
|
+
});
|
|
32
|
+
const landedBody = z.looseObject({
|
|
33
|
+
armed: z.boolean(),
|
|
34
|
+
mode: z.string(),
|
|
35
|
+
pr: z.number(),
|
|
36
|
+
verdict: z.looseObject({ outcome: z.string() }),
|
|
37
|
+
});
|
|
38
|
+
const repliedBody = z.looseObject({ posted: z.looseObject({ id: z.number() }), pr: z.number() });
|
|
39
|
+
const openedBody = z.looseObject({
|
|
40
|
+
base: z.string(),
|
|
41
|
+
head: z.string(),
|
|
42
|
+
pr: z.looseObject({ number: z.number(), url: z.string() }),
|
|
43
|
+
repo: z.string(),
|
|
44
|
+
});
|
|
45
|
+
// `conduct branch <type> <slug> [--item KEY-n]`: worktree-KEY-n becomes <type>/key-n-<slug>.
|
|
46
|
+
export async function branchCommand(type, slug, { item }, io) {
|
|
47
|
+
return verb(io, async () => {
|
|
48
|
+
const { checkout, git, profile } = await here(io);
|
|
49
|
+
const from = await branchOf(git, checkout);
|
|
50
|
+
const key = await itemFor(checkout, profile, git, item);
|
|
51
|
+
const next = branchName(type, slug, key);
|
|
52
|
+
if (next === null)
|
|
53
|
+
throw new ConductorError(`usage: conduct branch <type> <slug>, with a conventional type such as feat or fix`);
|
|
54
|
+
if (from === next)
|
|
55
|
+
return { branch: next, renamed: false };
|
|
56
|
+
// Only the item's own branch is renamed: never the base, main, or another item's branch.
|
|
57
|
+
if (from === null)
|
|
58
|
+
throw new ConductorError('the checkout is on no branch (a detached HEAD)');
|
|
59
|
+
if (from === profile.baseBranch || from === 'main')
|
|
60
|
+
throw new ConductorError(`refused: ${from} is a base branch`);
|
|
61
|
+
const owner = itemKey(from, trackerKey(profile));
|
|
62
|
+
if (owner !== null && owner !== key)
|
|
63
|
+
throw new ConductorError(`refused: ${from} is ${owner}'s branch, not ${key}'s`);
|
|
64
|
+
const renamed = await git(['branch', '-m', next], checkout);
|
|
65
|
+
if (renamed.code !== 0)
|
|
66
|
+
throw new ConductorError(`git branch -m ${next} failed`, [outputOf(renamed, 300)]);
|
|
67
|
+
return { branch: next, from, renamed: true };
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// `conduct checkout <owner>/<repo> <type> <slug> [--item KEY-n]`: another GitHub repo cloned into
|
|
71
|
+
// .scratch/repos/<repo> on <type>/key-n-<slug> from its default branch, with no upstream until the
|
|
72
|
+
// first push. Again on an existing checkout, it says where it is and changes nothing.
|
|
73
|
+
export async function checkoutCommand(name, type, slug, { item }, io) {
|
|
74
|
+
return verb(io, async () => {
|
|
75
|
+
const { checkout, git, profile } = await here(io);
|
|
76
|
+
const repo = githubRepoRef(name.replace(/^github:/, ''));
|
|
77
|
+
if (!repo)
|
|
78
|
+
throw new ConductorError(`conduct checkout takes a GitHub repo as <owner>/<repo>, not "${name}"`);
|
|
79
|
+
const key = await itemFor(checkout, profile, git, item);
|
|
80
|
+
const branch = branchName(type, slug, key);
|
|
81
|
+
if (branch === null)
|
|
82
|
+
throw new ConductorError('usage: conduct checkout <owner>/<repo> <type> <slug>');
|
|
83
|
+
const dir = checkoutDir(checkout, profile, repo);
|
|
84
|
+
if (existsSync(join(dir, '.git'))) {
|
|
85
|
+
const origin = (await git(['remote', 'get-url', 'origin'], dir)).stdout.trim();
|
|
86
|
+
const found = githubRepoRef(origin);
|
|
87
|
+
if (!found || repoKey(found) !== repoKey(repo)) {
|
|
88
|
+
throw new ConductorError(`${dir} is a checkout of ${origin || 'something else'}, not ${repoKey(repo)}`);
|
|
89
|
+
}
|
|
90
|
+
const current = await branchOf(git, dir);
|
|
91
|
+
return {
|
|
92
|
+
base: await checkoutBase(git, dir),
|
|
93
|
+
branch: current,
|
|
94
|
+
checkout: dir,
|
|
95
|
+
created: false,
|
|
96
|
+
repo: repoKey(repo),
|
|
97
|
+
...(current === branch
|
|
98
|
+
? {}
|
|
99
|
+
: { note: `on ${current ?? 'no branch'}, not ${branch}: switch it yourself if that's wrong` }),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
await excludeScratch(git, checkout);
|
|
103
|
+
mkdirSync(dirname(dir), { recursive: true });
|
|
104
|
+
// A checkout inside a worktree has long paths; core.longpaths lets Windows git write them.
|
|
105
|
+
const url = `https://github.com/${repo.owner}/${repo.repo}.git`;
|
|
106
|
+
const cloned = await git(['clone', '--quiet', '--filter=blob:none', '-c', 'core.longpaths=true', url, dir], checkout);
|
|
107
|
+
if (cloned.code !== 0)
|
|
108
|
+
throw new ConductorError(`git clone ${url} failed`, [outputOf(cloned, 300)]);
|
|
109
|
+
const base = await checkoutBase(git, dir);
|
|
110
|
+
const switched = await git(['switch', '--quiet', '--no-track', '-c', branch, `origin/${base}`], dir);
|
|
111
|
+
if (switched.code !== 0)
|
|
112
|
+
throw new ConductorError(`git switch -c ${branch} failed`, [outputOf(switched, 300)]);
|
|
113
|
+
return { base, branch, checkout: dir, created: true, repo: repoKey(repo) };
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// `conduct land <pr> [--mode auto|review] --reason … [--repo …] [--rearm] [--tier S|M|L]`: the PR set
|
|
117
|
+
// up to land and its first verdict (landing.ts): by the daemon for the worker that owns the
|
|
118
|
+
// checkout, which takes the plan's tier from the item's Plan note and records the landing so the
|
|
119
|
+
// watchers keep it armed; else here, with --tier for the landing rules.
|
|
120
|
+
export async function landCommand(paths, options, io) {
|
|
121
|
+
return verb(io, async () => {
|
|
122
|
+
const { checkout, git, profile } = await here(io);
|
|
123
|
+
const item = await itemFor(checkout, profile, git, options.item);
|
|
124
|
+
const request = {
|
|
125
|
+
pr: options.pr,
|
|
126
|
+
reason: options.reason,
|
|
127
|
+
...(options.mode === undefined ? {} : { mode: options.mode }),
|
|
128
|
+
...(options.rearm ? { rearm: true } : {}),
|
|
129
|
+
...repoOption(options.repo),
|
|
130
|
+
};
|
|
131
|
+
const daemon = await viaDaemon(paths, checkout, {
|
|
132
|
+
body: request,
|
|
133
|
+
lost: 'the landing may be armed already, so run conduct land again (it is safe to repeat)',
|
|
134
|
+
route: 'landings',
|
|
135
|
+
schema: landedBody,
|
|
136
|
+
});
|
|
137
|
+
if (daemon !== null)
|
|
138
|
+
return daemon;
|
|
139
|
+
const ctx = {
|
|
140
|
+
git,
|
|
141
|
+
hosts: hostsHere(paths, profile, io),
|
|
142
|
+
item,
|
|
143
|
+
profile,
|
|
144
|
+
tier: options.tier ?? null,
|
|
145
|
+
worktree: checkout,
|
|
146
|
+
};
|
|
147
|
+
return { ...(await landPr(ctx, request)), via: 'local' };
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// `conduct pr create --title … --body-file … [--repo …] [--dry-run]`: the checks here (the title's
|
|
151
|
+
// keys, the branch, the description's length, a clean tree, commits ahead, commitlint), the push from
|
|
152
|
+
// this checkout, then the PR: by the daemon for the worker that owns the checkout, which checks the
|
|
153
|
+
// ownership again and records the PR on the worker, else here.
|
|
154
|
+
export async function prCreateCommand(paths, options, io) {
|
|
155
|
+
return verb(io, async () => {
|
|
156
|
+
const { checkout, git, profile } = await here(io);
|
|
157
|
+
const item = await itemFor(checkout, profile, git, options.item);
|
|
158
|
+
const body = readBody(options.bodyFile);
|
|
159
|
+
const target = { git, item, profile, worktree: checkout };
|
|
160
|
+
const { base, dir, head, repo } = await prTarget(target, { title: options.title, ...repoOption(options.repo) });
|
|
161
|
+
const hosts = hostsHere(paths, profile, io);
|
|
162
|
+
await prChecks(hosts(repo), head, body);
|
|
163
|
+
const { dirty, lineEndingOnly } = await realDirty(git, dir);
|
|
164
|
+
if (dirty.length > 0)
|
|
165
|
+
throw new ConductorError(`uncommitted changes in ${dir}: commit or discard them first`, dirty);
|
|
166
|
+
const { ahead } = await aheadBehind(git, dir, base);
|
|
167
|
+
if (ahead === 0)
|
|
168
|
+
throw new ConductorError(`no commits ahead of origin/${base}`);
|
|
169
|
+
const linted = await commitlint(dir, base);
|
|
170
|
+
const wouldPush = await needsPush(git, dir);
|
|
171
|
+
const checked = {
|
|
172
|
+
ahead,
|
|
173
|
+
base,
|
|
174
|
+
commitlint: linted,
|
|
175
|
+
descriptionChars: body.length,
|
|
176
|
+
head,
|
|
177
|
+
repo: repoKey(repo),
|
|
178
|
+
...(lineEndingOnly.length > 0 ? { lineEndingOnly } : {}),
|
|
179
|
+
};
|
|
180
|
+
if (options.dryRun)
|
|
181
|
+
return { ...checked, dryRun: true, title: options.title, wouldPush };
|
|
182
|
+
const pushed = wouldPush ? await push(git, dir, head) : null;
|
|
183
|
+
const request = { body, title: options.title, ...repoOption(options.repo) };
|
|
184
|
+
const result = (await viaDaemon(paths, checkout, {
|
|
185
|
+
body: request,
|
|
186
|
+
lost: 'the PR may be open already, so run conduct state before trying again',
|
|
187
|
+
route: 'prs',
|
|
188
|
+
schema: openedBody,
|
|
189
|
+
})) ?? { ...(await openPr({ ...target, hosts }, request)), via: 'local' };
|
|
190
|
+
return {
|
|
191
|
+
...checked,
|
|
192
|
+
...result,
|
|
193
|
+
...(pushed?.attempts === 2 ? { pushRetried: pushed.firstError } : {}),
|
|
194
|
+
pushed: pushed !== null,
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// `conduct pr threads <pr> [--repo …]`: the PR's threads (on GitHub each comment and review), each
|
|
199
|
+
// with `needsAnswer`: a person's, open, with no note after it, and asking for something. A read, so
|
|
200
|
+
// it runs here.
|
|
201
|
+
export async function prThreadsCommand(paths, options, io) {
|
|
202
|
+
return verb(io, async () => {
|
|
203
|
+
const { profile } = await here(io);
|
|
204
|
+
const threads = await prThreads(hostsHere(paths, profile, io), profile, {
|
|
205
|
+
pr: options.pr,
|
|
206
|
+
...repoOption(options.repo),
|
|
207
|
+
});
|
|
208
|
+
return { pr: options.pr, repo: repoKey(repoOf(profile, options.repo)), threads, via: 'local' };
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// `conduct reply <pr> [<thread>] --body-file … [--repo …]`: an answer on the worker's PR, in an ADO
|
|
212
|
+
// thread or as a note on the PR, headed as a note (`## <skill> · Reply`) unless it is one.
|
|
213
|
+
export async function replyCommand(paths, options, io) {
|
|
214
|
+
return verb(io, async () => {
|
|
215
|
+
const { checkout, git, profile } = await here(io);
|
|
216
|
+
const item = await itemFor(checkout, profile, git, options.item);
|
|
217
|
+
const request = {
|
|
218
|
+
body: readBody(options.bodyFile),
|
|
219
|
+
pr: options.pr,
|
|
220
|
+
thread: options.thread,
|
|
221
|
+
...repoOption(options.repo),
|
|
222
|
+
};
|
|
223
|
+
const daemon = await viaDaemon(paths, checkout, {
|
|
224
|
+
body: request,
|
|
225
|
+
lost: 'the reply may be posted already, so read the PR before answering again',
|
|
226
|
+
route: 'replies',
|
|
227
|
+
schema: repliedBody,
|
|
228
|
+
});
|
|
229
|
+
if (daemon !== null)
|
|
230
|
+
return daemon;
|
|
231
|
+
const ctx = { git, hosts: hostsHere(paths, profile, io), item, profile, worktree: checkout };
|
|
232
|
+
return { ...(await replyOnPr(ctx, request)), via: 'local' };
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// `conduct state [--repo …]`: the checkout's branch, how far it is from its base, its uncommitted
|
|
236
|
+
// files and its branch's PR, and the same for each other repo checked out under .scratch/repos.
|
|
237
|
+
export async function stateCommand(paths, options, io) {
|
|
238
|
+
return verb(io, async () => {
|
|
239
|
+
const { checkout, git, profile } = await here(io);
|
|
240
|
+
const hosts = hostsHere(paths, profile, io);
|
|
241
|
+
if (options.repo !== undefined) {
|
|
242
|
+
const repo = repoOf(profile, options.repo);
|
|
243
|
+
return {
|
|
244
|
+
...(await stateOf(git, hosts, repo, checkout, checkoutDir(checkout, profile, repo), profile)),
|
|
245
|
+
via: 'local',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const own = await stateOf(git, hosts, repoOf(profile), checkout, checkout, profile);
|
|
249
|
+
const others = (await otherCheckouts(git, checkout)).flatMap((o) => (o.repo ? [{ dir: o.dir, repo: o.repo }] : []));
|
|
250
|
+
const repos = await Promise.all(others.map(async ({ dir, repo }) => {
|
|
251
|
+
try {
|
|
252
|
+
return await stateOf(git, hosts, repo, checkout, dir, profile);
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
if (error instanceof LoginNeeded)
|
|
256
|
+
throw error;
|
|
257
|
+
// One checkout that can't be read doesn't hide the item's own state.
|
|
258
|
+
return { checkout: dir, error: messageOf(error), repo: repoKey(repo) };
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
const worktree = basename(dirname(checkout)) === 'worktrees' ? basename(checkout) : null;
|
|
262
|
+
return {
|
|
263
|
+
...own,
|
|
264
|
+
branchIsDefault: own.branch === `worktree-${basename(checkout)}`,
|
|
265
|
+
item: await itemFor(checkout, profile, git).catch(() => null),
|
|
266
|
+
repos,
|
|
267
|
+
via: 'local',
|
|
268
|
+
worktree,
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
// Keeps .scratch/repos out of the project's own git status, so retire's clean check sees the
|
|
273
|
+
// worktree's work alone (and checks the clones on their own).
|
|
274
|
+
async function excludeScratch(git, checkout) {
|
|
275
|
+
const relative = REPOS_DIR.split(sep).join('/');
|
|
276
|
+
if ((await git(['check-ignore', '-q', `${relative}/x`], checkout)).code === 0)
|
|
277
|
+
return;
|
|
278
|
+
const common = (await git(['rev-parse', '--git-common-dir'], checkout)).stdout.trim();
|
|
279
|
+
const info = join(isAbsolute(common) ? common : join(checkout, common), 'info');
|
|
280
|
+
mkdirSync(info, { recursive: true });
|
|
281
|
+
appendFileSync(join(info, 'exclude'), `\n/${relative}/\n`);
|
|
282
|
+
}
|
|
283
|
+
// The project checkout around the working directory and its profile. Refused inside another repo's
|
|
284
|
+
// clone (.scratch/repos/<repo>), whose branch would read as the item's.
|
|
285
|
+
async function here(io) {
|
|
286
|
+
const checkout = await gitToplevel(io.cwd);
|
|
287
|
+
if (checkout === null)
|
|
288
|
+
throw new ConductorError("not in a git checkout: run it in the item's worktree");
|
|
289
|
+
if (checkout.includes(`${sep}${REPOS_DIR}${sep}`)) {
|
|
290
|
+
throw new ConductorError(`run it from the item's worktree, not inside ${checkout}`, [
|
|
291
|
+
"that is another repo's checkout, which --repo reaches from the worktree",
|
|
292
|
+
]);
|
|
293
|
+
}
|
|
294
|
+
if (!existsSync(join(checkout, PROFILE_FILE)))
|
|
295
|
+
throw new ConductorError(`no ${PROFILE_FILE} in ${checkout}`);
|
|
296
|
+
return { checkout, git: io.git ?? runGit, profile: readProfile(checkout).profile };
|
|
297
|
+
}
|
|
298
|
+
function hostsHere(paths, profile, io) {
|
|
299
|
+
return io.hosts ?? projectHosts(providerCredentials({ projects: loadConfig(paths.config).projects }), profile.name);
|
|
300
|
+
}
|
|
301
|
+
// The item this checkout works: --item, else the key in the worktree's name, else in its branch.
|
|
302
|
+
async function itemFor(checkout, profile, git, item) {
|
|
303
|
+
const prefix = trackerKey(profile);
|
|
304
|
+
if (item !== undefined) {
|
|
305
|
+
const key = itemKey(item, prefix);
|
|
306
|
+
if (key === null)
|
|
307
|
+
throw new ConductorError(`--item takes a ${prefix}-<n> key, not "${item}"`);
|
|
308
|
+
return key;
|
|
309
|
+
}
|
|
310
|
+
const found = itemKey(basename(checkout), prefix) ?? itemKey((await branchOf(git, checkout)) ?? '', prefix);
|
|
311
|
+
if (found === null)
|
|
312
|
+
throw new ConductorError(`no ${prefix}-<n> in the worktree's name or its branch: pass --item`);
|
|
313
|
+
return found;
|
|
314
|
+
}
|
|
315
|
+
function messageOf(error) {
|
|
316
|
+
return error instanceof Error ? error.message : String(error);
|
|
317
|
+
}
|
|
318
|
+
function readBody(file) {
|
|
319
|
+
try {
|
|
320
|
+
return readFileSync(file, 'utf8');
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
throw new ConductorError(`can't read ${file}`, [messageOf(error)]);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// --repo as a request's optional field.
|
|
327
|
+
function repoOption(repo) {
|
|
328
|
+
return repo === undefined ? {} : { repo };
|
|
329
|
+
}
|
|
330
|
+
async function stateOf(git, hosts, repo, worktree, dir, profile) {
|
|
331
|
+
if (!existsSync(join(dir, '.git')))
|
|
332
|
+
throw new ConductorError(`no checkout of ${repoKey(repo)} at ${dir}`);
|
|
333
|
+
const branch = await branchOf(git, dir);
|
|
334
|
+
const base = await baseOf(git, worktree, profile, dir);
|
|
335
|
+
const { ahead, behind } = await aheadBehind(git, dir, base);
|
|
336
|
+
const { dirty, lineEndingOnly } = await realDirty(git, dir);
|
|
337
|
+
let pr = null;
|
|
338
|
+
let prError;
|
|
339
|
+
// The base branch and main are the source of release and sync PRs, never of an item's PR.
|
|
340
|
+
if (branch && branch !== base && branch !== 'main') {
|
|
341
|
+
try {
|
|
342
|
+
pr = await hosts(repo).prForBranch(branch);
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (error instanceof LoginNeeded)
|
|
346
|
+
throw error;
|
|
347
|
+
prError = messageOf(error);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
ahead,
|
|
352
|
+
base,
|
|
353
|
+
behind,
|
|
354
|
+
branch,
|
|
355
|
+
checkout: dir,
|
|
356
|
+
dirty,
|
|
357
|
+
...(lineEndingOnly.length > 0 ? { lineEndingOnly } : {}),
|
|
358
|
+
pr,
|
|
359
|
+
...(prError === undefined ? {} : { prError }),
|
|
360
|
+
repo: repoKey(repo),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
// Runs a verb: its result as one JSON object on stdout, and its exit code. A lost login exits 5
|
|
364
|
+
// with the command that signs in again.
|
|
365
|
+
async function verb(io, run) {
|
|
366
|
+
try {
|
|
367
|
+
io.out(JSON.stringify(await run(), null, 2));
|
|
368
|
+
return 0;
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
if (error instanceof LoginNeeded) {
|
|
372
|
+
io.err(`conduct: ${error.line}`);
|
|
373
|
+
io.err(`then: conduct wait login ${error.account.provider}`);
|
|
374
|
+
return LOGIN_NEEDED_EXIT;
|
|
375
|
+
}
|
|
376
|
+
if (error instanceof DaemonLoginNeeded) {
|
|
377
|
+
io.err(`conduct: ${error.message}`);
|
|
378
|
+
io.err(`then: conduct wait login ${error.provider}`);
|
|
379
|
+
return LOGIN_NEEDED_EXIT;
|
|
380
|
+
}
|
|
381
|
+
throw error;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// The PR opened by the daemon for the worker that owns this checkout, or null when no daemon (or an
|
|
385
|
+
// older one, without the route) can: the caller opens it here.
|
|
386
|
+
async function viaDaemon(paths, checkout, write) {
|
|
387
|
+
const worker = await daemonWorker(paths, checkout, undefined);
|
|
388
|
+
if (worker === 'no-daemon' || worker === 'unreachable' || worker === null)
|
|
389
|
+
return null;
|
|
390
|
+
let answer;
|
|
391
|
+
try {
|
|
392
|
+
answer = await callApi(paths, {
|
|
393
|
+
body: write.body,
|
|
394
|
+
method: 'POST',
|
|
395
|
+
path: `/workers/${worker.id}/${write.route}`,
|
|
396
|
+
timeoutMs: WRITE_TIMEOUT_MS,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
if (error instanceof NotRunningError)
|
|
401
|
+
return null;
|
|
402
|
+
// The daemon may have written before the answer was lost.
|
|
403
|
+
throw new ConductorError(`the conductor didn't answer; ${write.lost}`, [messageOf(error)]);
|
|
404
|
+
}
|
|
405
|
+
if (answer.status === 200 || answer.status === 201)
|
|
406
|
+
return { ...write.schema.parse(answer.body), via: 'daemon' };
|
|
407
|
+
// A daemon from before protocol 2's verbs has no such route: the worker was just found, so a 404
|
|
408
|
+
// is the route.
|
|
409
|
+
if (answer.status === 404)
|
|
410
|
+
return null;
|
|
411
|
+
const refused = refusedBody.safeParse(answer.body).data;
|
|
412
|
+
if (answer.status === 503 && refused?.login) {
|
|
413
|
+
throw new DaemonLoginNeeded(`${refused.error}; to sign in: ${refused.login.command}`, refused.login.provider);
|
|
414
|
+
}
|
|
415
|
+
throw new ConductorError(refused?.error ?? `the conductor answered ${answer.status}`, refused?.details ?? []);
|
|
416
|
+
}
|
|
417
|
+
//# sourceMappingURL=code-host-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-host-cli.js","sourceRoot":"","sources":["../src/code-host-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAA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B;SAC5B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,eAAe;YAAE,OAAO,IAAI,CAAC;QAClD,0DAA0D;QAC1D,MAAM,IAAI,cAAc,CAAC,gCAAgC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;IACjH,iGAAiG;IACjG,gBAAgB;IAChB,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IACxD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5C,MAAM,IAAI,iBAAiB,CAAC,GAAG,OAAO,CAAC,KAAK,iBAAiB,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChH,CAAC;IACD,MAAM,IAAI,cAAc,CAAC,OAAO,EAAE,KAAK,IAAI,0BAA0B,MAAM,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { runGit } from "./checkout.js";
|
|
2
|
+
import { openPr, projectHosts, replyOnPr, repoKey, repoOf, } from "./code-host.js";
|
|
3
|
+
import { ConductorError } from "./errors.js";
|
|
4
|
+
import { landPr } from "./landing.js";
|
|
5
|
+
import {} from "./ownership.js";
|
|
6
|
+
import { ACTIVE_STATUSES } from "./store.js";
|
|
7
|
+
const isTier = (tier) => tier === 'L' || tier === 'M' || tier === 'S';
|
|
8
|
+
export function codeHostService({ credentials, git = runGit, hosts, store, }) {
|
|
9
|
+
const hostsOf = hosts ?? ((project) => projectHosts(credentials, project));
|
|
10
|
+
// The live worker and its project's profile, or a refusal that says why.
|
|
11
|
+
const owner = (id) => {
|
|
12
|
+
const worker = store.getWorker(id);
|
|
13
|
+
if (!worker || !ACTIVE_STATUSES.includes(worker.status)) {
|
|
14
|
+
throw new ConductorError(`worker ${id} isn't a live worker`, [
|
|
15
|
+
'only a worker in flight asks for code-host writes',
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
const project = store.listProjects().find((p) => p.name === worker.project);
|
|
19
|
+
if (!project?.profile)
|
|
20
|
+
throw new ConductorError(`worker ${worker.name}'s project ${worker.project} has no profile`);
|
|
21
|
+
if (!worker.worktree)
|
|
22
|
+
throw new ConductorError(`worker ${worker.name} has no worktree yet`);
|
|
23
|
+
return { profile: project.profile, worker, worktree: worker.worktree };
|
|
24
|
+
};
|
|
25
|
+
const context = (id) => {
|
|
26
|
+
const { profile, worker, worktree } = owner(id);
|
|
27
|
+
return { ctx: { git, hosts: hostsOf(profile.name), item: worker.item, profile, worktree }, worker };
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
land: async (id, request) => {
|
|
31
|
+
const { ctx, worker } = context(id);
|
|
32
|
+
const tier = store.latestTier(ctx.profile.name, worker.item);
|
|
33
|
+
const landed = await landPr({ ...ctx, tier: isTier(tier) ? tier : null }, request);
|
|
34
|
+
if (landed.armed) {
|
|
35
|
+
store.appendEvent({
|
|
36
|
+
data: { did: landed.did, mode: landed.mode, pr: `${landed.repo}#${landed.pr}`, worker: worker.id },
|
|
37
|
+
kind: 'code-host.landing-armed',
|
|
38
|
+
project: ctx.profile.name,
|
|
39
|
+
subject: worker.item,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return landed;
|
|
43
|
+
},
|
|
44
|
+
openPr: async (id, request) => {
|
|
45
|
+
const { profile, worker, worktree } = owner(id);
|
|
46
|
+
const opened = await openPr({ git, hosts: hostsOf(profile.name), item: worker.item, profile, worktree }, request);
|
|
47
|
+
// The worker's PR is its project's: another repo's (a registry PR) is recorded only while it
|
|
48
|
+
// has none.
|
|
49
|
+
const own = opened.repo === repoKey(repoOf(profile));
|
|
50
|
+
const updated = own || worker.pr === null
|
|
51
|
+
? store.updateWorker(worker.id, { pr: `${opened.repo}#${opened.pr.number}` })
|
|
52
|
+
: worker;
|
|
53
|
+
store.appendEvent({
|
|
54
|
+
data: { head: opened.head, pr: opened.pr.number, repo: opened.repo, url: opened.pr.url, worker: worker.id },
|
|
55
|
+
kind: 'code-host.pr-created',
|
|
56
|
+
project: profile.name,
|
|
57
|
+
subject: worker.item,
|
|
58
|
+
});
|
|
59
|
+
return { ...opened, worker: updated };
|
|
60
|
+
},
|
|
61
|
+
reply: async (id, request) => {
|
|
62
|
+
const { ctx, worker } = context(id);
|
|
63
|
+
const replied = await replyOnPr(ctx, request);
|
|
64
|
+
store.appendEvent({
|
|
65
|
+
data: { pr: `${replied.repo}#${replied.pr}`, thread: replied.thread, worker: worker.id },
|
|
66
|
+
kind: 'code-host.replied',
|
|
67
|
+
project: ctx.profile.name,
|
|
68
|
+
subject: worker.item,
|
|
69
|
+
});
|
|
70
|
+
return replied;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=code-host-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-host-service.js","sourceRoot":"","sources":["../src/code-host-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAGL,MAAM,EACN,YAAY,EAEZ,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,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