@opencorelabs/lucidity 0.6.0 → 0.8.0
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/README.md +18 -3
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts.map +1 -1
- package/dist/automations/agent.js +2 -0
- package/dist/automations/designer.d.ts +1 -1
- package/dist/chat/server.d.ts +1 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +6 -1
- package/dist/coding/conduct.d.ts +1 -22
- package/dist/coding/conduct.d.ts.map +1 -1
- package/dist/coding/conduct.js +9 -94
- package/dist/coding/runCodeTurn.d.ts +3 -16
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +157 -165
- package/dist/coding/workspaceRegistry.d.ts +24 -0
- package/dist/coding/workspaceRegistry.d.ts.map +1 -0
- package/dist/coding/workspaceRegistry.js +230 -0
- package/dist/coding/worktree.d.ts +11 -14
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +41 -21
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/daemonLease.d.ts +12 -0
- package/dist/daemonLease.d.ts.map +1 -0
- package/dist/daemonLease.js +32 -0
- package/dist/goals/assessment.d.ts +115 -0
- package/dist/goals/assessment.d.ts.map +1 -0
- package/dist/goals/assessment.js +67 -0
- package/dist/goals/notes.d.ts +18 -0
- package/dist/goals/notes.d.ts.map +1 -0
- package/dist/goals/notes.js +72 -0
- package/dist/index.js +63 -15
- package/dist/jobs/goals.d.ts +15 -0
- package/dist/jobs/goals.d.ts.map +1 -0
- package/dist/jobs/goals.js +286 -0
- package/dist/jobs/weeklyReview.d.ts.map +1 -1
- package/dist/jobs/weeklyReview.js +3 -2
- package/dist/queue.d.ts +1 -0
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -0
- package/dist/room/client.d.ts +5 -0
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +124 -107
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +2 -0
- package/dist/room/durablePublish.d.ts +6 -0
- package/dist/room/durablePublish.d.ts.map +1 -0
- package/dist/room/durablePublish.js +19 -0
- package/dist/room/incidents.d.ts +1 -1
- package/dist/room/incidents.d.ts.map +1 -1
- package/dist/room/incidents.js +14 -7
- package/dist/room/turnQueue.d.ts.map +1 -1
- package/dist/room/turnQueue.js +27 -24
- package/dist/runtimeStore.d.ts +44 -0
- package/dist/runtimeStore.d.ts.map +1 -0
- package/dist/runtimeStore.js +188 -0
- package/dist/setup/server.js +1 -1
- package/dist/turnLog.d.ts +10 -40
- package/dist/turnLog.d.ts.map +1 -1
- package/dist/turnLog.js +33 -56
- package/package.json +4 -4
- package/src/automations/agent.ts +2 -0
- package/src/chat/server.ts +7 -1
- package/src/coding/conduct.ts +10 -147
- package/src/coding/runCodeTurn.ts +42 -61
- package/src/coding/workspaceRegistry.ts +210 -0
- package/src/coding/worktree.ts +44 -20
- package/src/config.ts +2 -0
- package/src/daemonLease.ts +33 -0
- package/src/goals/assessment.ts +106 -0
- package/src/goals/notes.ts +88 -0
- package/src/index.ts +63 -18
- package/src/jobs/goals.ts +384 -0
- package/src/jobs/weeklyReview.ts +4 -3
- package/src/queue.ts +4 -0
- package/src/room/client.ts +85 -80
- package/src/room/computer.ts +2 -0
- package/src/room/durablePublish.ts +25 -0
- package/src/room/incidents.ts +16 -8
- package/src/room/turnQueue.ts +26 -27
- package/src/runtimeStore.ts +190 -0
- package/src/setup/server.ts +1 -1
- package/src/turnLog.ts +32 -75
- package/vendor/decisions/dist/dayPlan.d.ts +9 -0
- package/vendor/decisions/dist/dayPlan.js +82 -0
- package/vendor/decisions/dist/index.d.ts +1 -0
- package/vendor/decisions/dist/index.js +1 -0
- package/vendor/decisions/dist/jev.js +3 -1
- package/vendor/decisions/src/dayPlan.ts +80 -0
- package/vendor/decisions/src/index.ts +1 -0
- package/vendor/decisions/src/jev.ts +3 -1
- package/vendor/mcp-server/dist/index.js +2 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts +4 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/goals.js +38 -0
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/mcp-server/src/index.ts +2 -0
- package/vendor/mcp-server/src/tools/goals.ts +62 -0
- package/vendor/runtime/README.md +2 -2
- package/vendor/runtime/dist/executor/asyncQueue.d.ts +1 -0
- package/vendor/runtime/dist/executor/asyncQueue.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/asyncQueue.js +3 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +25 -10
- package/vendor/runtime/dist/executor/codex.d.ts +1 -0
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +69 -36
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts +11 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +4 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts +3 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts +7 -2
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.d.ts +10 -3
- package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.js +18 -3
- package/vendor/runtime/dist/executor/codexSessions.d.ts +30 -0
- package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexSessions.js +88 -0
- package/vendor/runtime/dist/executor/health.d.ts +2 -1
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +17 -5
- package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -1
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +12 -5
- package/vendor/runtime/dist/executor/ownership.d.ts +35 -0
- package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/ownership.js +99 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts +1 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +5 -0
- package/vendor/runtime/dist/executor/types.d.ts +4 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts +1 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +12 -1
- package/vendor/runtime/dist/harness/types.d.ts +2 -1
- package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
- package/vendor/runtime/dist/index.d.ts +1 -0
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts +44 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.js +42 -0
- package/vendor/runtime/src/executor/asyncQueue.ts +3 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +20 -9
- package/vendor/runtime/src/executor/codex.ts +76 -44
- package/vendor/runtime/src/executor/codexProtocol/FunctionCallOutputContentItem.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/Personality.ts +3 -0
- package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/README.md +2 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/CyberAccessProgram.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/Model.ts +11 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/ModelAccessPrograms.ts +13 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +2 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadResumeParams.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStartParams.ts +4 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnStartParams.ts +7 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/UserInput.ts +1 -1
- package/vendor/runtime/src/executor/codexRpc.ts +22 -4
- package/vendor/runtime/src/executor/codexSessions.ts +108 -0
- package/vendor/runtime/src/executor/health.ts +16 -6
- package/vendor/runtime/src/executor/liveTurns.ts +12 -5
- package/vendor/runtime/src/executor/ownership.ts +76 -0
- package/vendor/runtime/src/executor/providerRouter.ts +6 -0
- package/vendor/runtime/src/executor/types.ts +4 -0
- package/vendor/runtime/src/harness/index.ts +12 -1
- package/vendor/runtime/src/harness/types.ts +2 -1
- package/vendor/runtime/src/index.ts +1 -0
- package/vendor/runtime/src/prompts/dayPlanning.ts +46 -0
- package/vendor/shared/dist/agentCommands.d.ts +1 -0
- package/vendor/shared/dist/agentCommands.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.d.ts +41 -0
- package/vendor/shared/dist/cardStudio.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.js +13 -3
- package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
- package/vendor/shared/dist/commandLocal.js +2 -0
- package/vendor/shared/dist/commands.d.ts +18 -0
- package/vendor/shared/dist/commands.d.ts.map +1 -1
- package/vendor/shared/dist/commands.js +2 -0
- package/vendor/shared/dist/computer.d.ts +7 -1
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +13 -2
- package/vendor/shared/dist/constants.d.ts +3 -3
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +5 -4
- package/vendor/shared/dist/dayPlan.d.ts +86 -0
- package/vendor/shared/dist/dayPlan.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlan.js +46 -0
- package/vendor/shared/dist/dayPlanning.d.ts +139 -0
- package/vendor/shared/dist/dayPlanning.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlanning.js +67 -0
- package/vendor/shared/dist/goalNotes.d.ts +4 -0
- package/vendor/shared/dist/goalNotes.d.ts.map +1 -0
- package/vendor/shared/dist/goalNotes.js +23 -0
- package/vendor/shared/dist/goals.d.ts +835 -0
- package/vendor/shared/dist/goals.d.ts.map +1 -0
- package/vendor/shared/dist/goals.js +198 -0
- package/vendor/shared/dist/index.d.ts +5 -0
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +5 -0
- package/vendor/shared/dist/schemas/harness.d.ts +155 -0
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +8 -0
- package/vendor/shared/dist/workspaces.d.ts +138 -0
- package/vendor/shared/dist/workspaces.d.ts.map +1 -0
- package/vendor/shared/dist/workspaces.js +40 -0
- package/vendor/shared/src/agentCommands.ts +1 -0
- package/vendor/shared/src/cardStudio.ts +13 -3
- package/vendor/shared/src/commandLocal.ts +2 -0
- package/vendor/shared/src/commands.ts +2 -0
- package/vendor/shared/src/computer.ts +18 -2
- package/vendor/shared/src/constants.ts +5 -4
- package/vendor/shared/src/dayPlan.ts +81 -0
- package/vendor/shared/src/dayPlanning.ts +77 -0
- package/vendor/shared/src/goalNotes.ts +23 -0
- package/vendor/shared/src/goals.ts +237 -0
- package/vendor/shared/src/index.ts +6 -0
- package/vendor/shared/src/schemas/harness.ts +8 -0
- package/vendor/shared/src/workspaces.ts +48 -0
- package/dist/coding/fleetIntegrate.d.ts +0 -37
- package/dist/coding/fleetIntegrate.d.ts.map +0 -1
- package/dist/coding/fleetIntegrate.js +0 -64
- package/dist/coding/openFleetPr.d.ts +0 -41
- package/dist/coding/openFleetPr.d.ts.map +0 -1
- package/dist/coding/openFleetPr.js +0 -121
- package/src/coding/fleetIntegrate.ts +0 -95
- package/src/coding/openFleetPr.ts +0 -148
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
import { ensureWorkspace, sessionBranch } from './worktree.js';
|
|
4
|
-
|
|
5
|
-
const exec = promisify(execFile);
|
|
6
|
-
|
|
7
|
-
async function git(cwd: string, args: string[]): Promise<string> {
|
|
8
|
-
const { stdout } = await exec('git', args, { cwd, maxBuffer: 32 * 1024 * 1024 });
|
|
9
|
-
return stdout;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FleetConflict {
|
|
13
|
-
workerId: string;
|
|
14
|
-
/** The files that couldn't merge cleanly. */
|
|
15
|
-
paths: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface IntegrationResult {
|
|
19
|
-
/** The branch the workers were integrated onto — the bare `lucid/<repo>` session, which
|
|
20
|
-
* is also where the fleet's single PR opens from. */
|
|
21
|
-
branch: string;
|
|
22
|
-
/** Worker ids that merged cleanly, in the order they landed. */
|
|
23
|
-
merged: string[];
|
|
24
|
-
/** Workers whose branch conflicted; their merge was aborted and left for the user to hand
|
|
25
|
-
* back to the worker as a fresh turn. */
|
|
26
|
-
conflicts: FleetConflict[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Integrate finished workers onto the fleet branch, one at a time in merge order.
|
|
31
|
-
*
|
|
32
|
-
* The integration worktree is the bare repo session (`lucid/<repo>`), reset to HEAD, so the
|
|
33
|
-
* fan-out's result is a single branch cut fresh from where the user started — clean history to
|
|
34
|
-
* open one PR from. Each worker's `fleet/<repo>/<workerId>` branch is merged in; a conflict is
|
|
35
|
-
* caught (not thrown), the merge aborted so the next worker can still land, and reported via
|
|
36
|
-
* `onConflict` so the conductor surfaces it in the feed rather than silently dropping work.
|
|
37
|
-
*
|
|
38
|
-
* Sequential and in order because that's where overlap actually bites: the workers ran in
|
|
39
|
-
* isolated worktrees and never raced each other on disk — only the merge can conflict, and only
|
|
40
|
-
* against what already landed.
|
|
41
|
-
*/
|
|
42
|
-
export async function integrateWorkers(
|
|
43
|
-
repoRoot: string,
|
|
44
|
-
repoId: string,
|
|
45
|
-
workers: { workerId: string; mergeOrder: number }[],
|
|
46
|
-
opts: {
|
|
47
|
-
baseDir?: string;
|
|
48
|
-
onMerged?: (workerId: string) => void;
|
|
49
|
-
onConflict?: (conflict: FleetConflict) => void;
|
|
50
|
-
} = {},
|
|
51
|
-
): Promise<IntegrationResult> {
|
|
52
|
-
const branch = sessionBranch(repoId);
|
|
53
|
-
// Fresh bare session = lucid/<repo> reset to HEAD: the integration target.
|
|
54
|
-
const ws = await ensureWorkspace(repoRoot, repoId, {
|
|
55
|
-
fresh: true,
|
|
56
|
-
baseDir: opts.baseDir,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const ordered = [...workers].sort((a, b) => a.mergeOrder - b.mergeOrder);
|
|
60
|
-
const merged: string[] = [];
|
|
61
|
-
const conflicts: FleetConflict[] = [];
|
|
62
|
-
|
|
63
|
-
for (const w of ordered) {
|
|
64
|
-
const workerBranch = sessionBranch(repoId, w.workerId);
|
|
65
|
-
try {
|
|
66
|
-
await git(ws.path, [
|
|
67
|
-
'merge',
|
|
68
|
-
'--no-ff',
|
|
69
|
-
'-m',
|
|
70
|
-
`Merge fleet worker ${w.workerId}`,
|
|
71
|
-
workerBranch,
|
|
72
|
-
]);
|
|
73
|
-
merged.push(w.workerId);
|
|
74
|
-
opts.onMerged?.(w.workerId);
|
|
75
|
-
} catch {
|
|
76
|
-
// A conflict (or any merge failure): record the unmerged paths, abort so the branch is
|
|
77
|
-
// clean for the next worker, and report. Never fatal — one bad lane can't sink the fleet.
|
|
78
|
-
const unmerged = await git(ws.path, [
|
|
79
|
-
'diff',
|
|
80
|
-
'--name-only',
|
|
81
|
-
'--diff-filter=U',
|
|
82
|
-
]).catch(() => '');
|
|
83
|
-
const paths = unmerged
|
|
84
|
-
.split('\n')
|
|
85
|
-
.map((s) => s.trim())
|
|
86
|
-
.filter(Boolean);
|
|
87
|
-
await git(ws.path, ['merge', '--abort']).catch(() => {});
|
|
88
|
-
const conflict: FleetConflict = { workerId: w.workerId, paths };
|
|
89
|
-
conflicts.push(conflict);
|
|
90
|
-
opts.onConflict?.(conflict);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return { branch, merged, conflicts };
|
|
95
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
|
|
4
|
-
const exec = promisify(execFile);
|
|
5
|
-
|
|
6
|
-
/** The daemon runs under launchd, whose PATH excludes Homebrew — so `gh` (from /opt/homebrew/bin
|
|
7
|
-
* or /usr/local/bin) may not resolve. Prepend the usual bins. (mirrors listPrs.ts) */
|
|
8
|
-
const GH_PATH = [process.env.PATH, '/opt/homebrew/bin', '/usr/local/bin'].filter(Boolean).join(':');
|
|
9
|
-
|
|
10
|
-
export interface FleetPrSummary {
|
|
11
|
-
title: string;
|
|
12
|
-
body: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Build the PR's title + body from the fleet goal and the workers that actually landed. Pure so
|
|
17
|
-
* it can be unit-tested; the spawn wrapper below is covered by a real run.
|
|
18
|
-
*/
|
|
19
|
-
export function fleetPrSummary(goal: string, mergedTitles: string[]): FleetPrSummary {
|
|
20
|
-
const g = goal.trim() || 'Fleet';
|
|
21
|
-
const title = `Fleet: ${g}`.slice(0, 120);
|
|
22
|
-
const lines = mergedTitles.length
|
|
23
|
-
? mergedTitles.map((t) => `- ${t}`).join('\n')
|
|
24
|
-
: '- (no worker changes)';
|
|
25
|
-
const body = `${g}\n\nMerged by the fleet:\n${lines}`;
|
|
26
|
-
return { title, body };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Every worker commit subject carries this, so the git log reads as Lucid's work. A PR title
|
|
30
|
-
* shouldn't wear it. */
|
|
31
|
-
const COMMIT_SUBJECT_PREFIX = /^Lucid:\s*/;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Per-feature delivery: build ONE worker's PR title + body.
|
|
35
|
-
*
|
|
36
|
-
* The title is the worker's own FIRST commit subject, which `codeCommitMessage` already built out
|
|
37
|
-
* of Lucid's summary of what it did. The lane title can't do that job and shouldn't have been
|
|
38
|
-
* asked to: it's `clampTitle(brief.split('\n')[0])`, so it's the opening line of whatever was
|
|
39
|
-
* typed at the board, which names the request rather than the change and is usually cut off
|
|
40
|
-
* mid-thought (#308). It stays as the fallback for a branch whose subjects couldn't be read.
|
|
41
|
-
*
|
|
42
|
-
* The first subject rather than the last, because a steered worker's later commits are
|
|
43
|
-
* refinements of the piece of work the branch is about. The rest go in the body under the brief
|
|
44
|
-
* that asked for them, which is the one thing the brief is genuinely good for. Pure, unit-tested.
|
|
45
|
-
*/
|
|
46
|
-
export function workerPrSummary(
|
|
47
|
-
title: string,
|
|
48
|
-
brief: string,
|
|
49
|
-
subjects: string[] = [],
|
|
50
|
-
): FleetPrSummary {
|
|
51
|
-
const clean = subjects.map((s) => s.replace(COMMIT_SUBJECT_PREFIX, '').trim()).filter(Boolean);
|
|
52
|
-
const t = (clean[0] || title.trim() || 'Fleet worker').slice(0, 120);
|
|
53
|
-
const b = brief.trim() || t;
|
|
54
|
-
// A single commit says nothing the title hasn't just said, so only list them once there are
|
|
55
|
-
// several and the list is actually telling you something.
|
|
56
|
-
const rest = clean.length > 1 ? `\n\nCommits:\n${clean.map((c) => `- ${c}`).join('\n')}` : '';
|
|
57
|
-
return { title: t, body: b + rest };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface FleetPrResult {
|
|
61
|
-
url?: string;
|
|
62
|
-
error?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function ghError(err: unknown): string {
|
|
66
|
-
const stderr = (err as { stderr?: unknown })?.stderr;
|
|
67
|
-
const raw =
|
|
68
|
-
typeof stderr === 'string' && stderr.trim()
|
|
69
|
-
? stderr
|
|
70
|
-
: err instanceof Error
|
|
71
|
-
? err.message
|
|
72
|
-
: String(err);
|
|
73
|
-
return (raw.split('\n')[0] ?? '').slice(0, 200);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Push the integration branch and open (or reuse) ONE pull request for the whole fan-out.
|
|
78
|
-
*
|
|
79
|
-
* Runs from the lucid/<repo> worktree, which is on the integration branch and shares the repo's
|
|
80
|
-
* GitHub remote. The branch is force-pushed because each fleet resets it fresh to HEAD before
|
|
81
|
-
* merging — its history is authored per-run, so the remote must follow. If a PR for the branch is
|
|
82
|
-
* already open (a re-integrated fleet), its URL is returned and the force-push updates it in place
|
|
83
|
-
* rather than opening a duplicate.
|
|
84
|
-
*
|
|
85
|
-
* Never throws: a missing/unauthed `gh`, or a repo with no GitHub remote, returns `{ error }` the
|
|
86
|
-
* phone can surface — the fleet already merged locally regardless.
|
|
87
|
-
*/
|
|
88
|
-
export async function openFleetPr(
|
|
89
|
-
worktreePath: string,
|
|
90
|
-
branch: string,
|
|
91
|
-
summary: FleetPrSummary,
|
|
92
|
-
base?: string,
|
|
93
|
-
): Promise<FleetPrResult> {
|
|
94
|
-
const env = { ...process.env, PATH: GH_PATH };
|
|
95
|
-
const run = (cmd: string, args: string[]) =>
|
|
96
|
-
exec(cmd, args, { cwd: worktreePath, env, maxBuffer: 8 * 1024 * 1024 });
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
await run('git', ['push', '--force', '-u', 'origin', branch]);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
return { error: ghError(err) };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Reuse an existing open PR for this branch rather than opening a duplicate — the force-push
|
|
105
|
-
// above already updated its head.
|
|
106
|
-
try {
|
|
107
|
-
const { stdout } = await run('gh', [
|
|
108
|
-
'pr',
|
|
109
|
-
'list',
|
|
110
|
-
'--head',
|
|
111
|
-
branch,
|
|
112
|
-
'--state',
|
|
113
|
-
'open',
|
|
114
|
-
'--json',
|
|
115
|
-
'url',
|
|
116
|
-
'--limit',
|
|
117
|
-
'1',
|
|
118
|
-
]);
|
|
119
|
-
const existing = JSON.parse(stdout) as { url: string }[];
|
|
120
|
-
if (existing[0]?.url) return { url: existing[0].url };
|
|
121
|
-
} catch {
|
|
122
|
-
// A listing failure shouldn't block a first PR — fall through to create.
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
const { stdout } = await run('gh', [
|
|
127
|
-
'pr',
|
|
128
|
-
'create',
|
|
129
|
-
'--head',
|
|
130
|
-
branch,
|
|
131
|
-
// Target the branch the fleet forked from (repo HEAD), NOT gh's default of the remote's
|
|
132
|
-
// default branch — those differ (e.g. a repo checked out on `develop` whose default is
|
|
133
|
-
// `main`), and defaulting would open a noisy PR full of unrelated commits.
|
|
134
|
-
...(base ? ['--base', base] : []),
|
|
135
|
-
'--title',
|
|
136
|
-
summary.title,
|
|
137
|
-
'--body',
|
|
138
|
-
summary.body,
|
|
139
|
-
]);
|
|
140
|
-
const url = stdout
|
|
141
|
-
.trim()
|
|
142
|
-
.split('\n')
|
|
143
|
-
.find((l) => l.startsWith('http'));
|
|
144
|
-
return url ? { url } : { error: 'PR created but no URL returned' };
|
|
145
|
-
} catch (err) {
|
|
146
|
-
return { error: ghError(err) };
|
|
147
|
-
}
|
|
148
|
-
}
|