@opencorelabs/lucidity 0.7.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 +9 -2
- 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 +57 -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 +116 -101
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +1 -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 +57 -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 +77 -74
- package/src/room/computer.ts +1 -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/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 +20 -9
- 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 +68 -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 +2 -0
- package/vendor/runtime/dist/executor/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/src/executor/asyncQueue.ts +3 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +16 -9
- package/vendor/runtime/src/executor/codex.ts +75 -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 +2 -0
- package/vendor/runtime/src/index.ts +1 -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/computer.d.ts +7 -1
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +12 -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/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 +3 -0
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +3 -0
- package/vendor/shared/dist/schemas/harness.d.ts +101 -0
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +6 -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/computer.ts +16 -2
- package/vendor/shared/src/constants.ts +5 -4
- package/vendor/shared/src/goalNotes.ts +23 -0
- package/vendor/shared/src/goals.ts +237 -0
- package/vendor/shared/src/index.ts +4 -0
- package/vendor/shared/src/schemas/harness.ts +6 -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
|
@@ -8,6 +8,7 @@ export const CardIdSchema = z.enum([
|
|
|
8
8
|
'habit-contributions',
|
|
9
9
|
'focus',
|
|
10
10
|
'weekly-review',
|
|
11
|
+
'goals',
|
|
11
12
|
]);
|
|
12
13
|
export type CardId = z.infer<typeof CardIdSchema>;
|
|
13
14
|
export const CardStyleSchema = z.enum(['glance', 'act']);
|
|
@@ -19,6 +20,13 @@ export const CARD_CATALOG: {
|
|
|
19
20
|
source: string;
|
|
20
21
|
styles: boolean;
|
|
21
22
|
}[] = [
|
|
23
|
+
{
|
|
24
|
+
id: 'goals',
|
|
25
|
+
name: 'Goals',
|
|
26
|
+
description: 'Something you want to achieve, with a timeframe and quiet checks from Lucid.',
|
|
27
|
+
source: 'Linked tasks, projects, private notes and habits',
|
|
28
|
+
styles: true,
|
|
29
|
+
},
|
|
22
30
|
{
|
|
23
31
|
id: 'attention',
|
|
24
32
|
name: 'Attention',
|
|
@@ -73,9 +81,10 @@ export const CARD_CATALOG: {
|
|
|
73
81
|
export const CardPreferencesSchema = z.object({
|
|
74
82
|
order: z
|
|
75
83
|
.array(CardIdSchema)
|
|
76
|
-
.max(
|
|
84
|
+
.max(8)
|
|
77
85
|
.refine((ids) => new Set(ids).size === ids.length),
|
|
78
86
|
styles: z.object({
|
|
87
|
+
goals: CardStyleSchema.default('glance'),
|
|
79
88
|
habits: CardStyleSchema,
|
|
80
89
|
'habit-contributions': CardStyleSchema.default('glance'),
|
|
81
90
|
focus: CardStyleSchema,
|
|
@@ -88,6 +97,7 @@ export type StyledCardId = keyof CardPreferences['styles'];
|
|
|
88
97
|
export const DEFAULT_CARD_PREFERENCES: CardPreferences = {
|
|
89
98
|
order: ['attention', 'today', 'github'],
|
|
90
99
|
styles: {
|
|
100
|
+
goals: 'glance',
|
|
91
101
|
habits: 'act',
|
|
92
102
|
'habit-contributions': 'glance',
|
|
93
103
|
focus: 'act',
|
|
@@ -99,7 +109,7 @@ export const CardPreferenceChangeSchema = z.discriminatedUnion('type', [
|
|
|
99
109
|
z.object({
|
|
100
110
|
type: z.literal('add'),
|
|
101
111
|
id: CardIdSchema,
|
|
102
|
-
index: z.number().int().min(0).max(
|
|
112
|
+
index: z.number().int().min(0).max(7).optional(),
|
|
103
113
|
}),
|
|
104
114
|
z.object({ type: z.literal('remove'), id: CardIdSchema }),
|
|
105
115
|
z.object({
|
|
@@ -109,7 +119,7 @@ export const CardPreferenceChangeSchema = z.discriminatedUnion('type', [
|
|
|
109
119
|
}),
|
|
110
120
|
z.object({
|
|
111
121
|
type: z.literal('style'),
|
|
112
|
-
id: z.enum(['habits', 'habit-contributions', 'focus', 'weekly-review']),
|
|
122
|
+
id: z.enum(['habits', 'habit-contributions', 'focus', 'weekly-review', 'goals']),
|
|
113
123
|
style: CardStyleSchema,
|
|
114
124
|
}),
|
|
115
125
|
z.object({ type: z.literal('dismiss'), key: z.string().min(1).max(240) }),
|
|
@@ -49,6 +49,8 @@ export const ComputerPresenceSchema = z.object({
|
|
|
49
49
|
});
|
|
50
50
|
export type ComputerPresence = z.infer<typeof ComputerPresenceSchema>;
|
|
51
51
|
export type ComputerFeature =
|
|
52
|
+
| 'checkout-history'
|
|
53
|
+
| 'workspaces'
|
|
52
54
|
| 'turn-queue'
|
|
53
55
|
| 'provider-handoff'
|
|
54
56
|
| 'queue-control'
|
|
@@ -229,15 +231,27 @@ export function computerAvailability(
|
|
|
229
231
|
|
|
230
232
|
/** Session affinity can be read in RN without importing Node Buffer. Legacy IDs are Claude. */
|
|
231
233
|
export function sessionProvider(resume?: string): ComputerProvider | undefined {
|
|
234
|
+
return sessionPreferences(resume)?.provider;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Saved overrides are needed when a conversation keeps a different provider from settings. */
|
|
238
|
+
export function sessionPreferences(resume?: string):
|
|
239
|
+
| { provider: ComputerProvider; model?: string; effort?: string }
|
|
240
|
+
| undefined {
|
|
232
241
|
if (!resume) return undefined;
|
|
233
|
-
if (!resume.startsWith('lucidity-session:')) return 'claude';
|
|
242
|
+
if (!resume.startsWith('lucidity-session:')) return { provider: 'claude' };
|
|
234
243
|
try {
|
|
235
244
|
const encoded = resume
|
|
236
245
|
.slice('lucidity-session:'.length)
|
|
237
246
|
.replace(/-/g, '+')
|
|
238
247
|
.replace(/_/g, '/');
|
|
239
248
|
const session = JSON.parse(atob(encoded));
|
|
240
|
-
|
|
249
|
+
if (session.provider !== 'codex' && session.provider !== 'claude') return undefined;
|
|
250
|
+
return {
|
|
251
|
+
provider: session.provider,
|
|
252
|
+
model: typeof session.model === 'string' ? session.model : undefined,
|
|
253
|
+
effort: typeof session.effort === 'string' ? session.effort : undefined,
|
|
254
|
+
};
|
|
241
255
|
} catch {
|
|
242
256
|
return undefined;
|
|
243
257
|
}
|
|
@@ -379,6 +379,7 @@ export function normalizeBio(input: string): string | null {
|
|
|
379
379
|
// re-fetches an interrupted turn's frames from the daemon's durable turn log
|
|
380
380
|
// (`sinceSeq` onward) so a dropped reply is recovered, never re-run.
|
|
381
381
|
export const HARNESS_REQUEST_KINDS = [
|
|
382
|
+
'workspaces',
|
|
382
383
|
'getAutomations',
|
|
383
384
|
'automation',
|
|
384
385
|
'queue-control',
|
|
@@ -429,7 +430,7 @@ export const EFFORT_LEVELS = [
|
|
|
429
430
|
export const EFFORT_OPTIONS = [
|
|
430
431
|
{
|
|
431
432
|
value: 'auto',
|
|
432
|
-
label: '
|
|
433
|
+
label: 'Automatic',
|
|
433
434
|
blurb: 'Use the model’s recommended effort',
|
|
434
435
|
},
|
|
435
436
|
{ value: 'low', label: 'Low', blurb: 'Fastest, least thorough' },
|
|
@@ -446,13 +447,13 @@ export const EFFORT_OPTIONS = [
|
|
|
446
447
|
|
|
447
448
|
/** A safe fallback when the live provider catalog is unavailable. Never guess a version. */
|
|
448
449
|
export function claudeModelLabel(alias: string): string {
|
|
449
|
-
return alias === 'default' ? '
|
|
450
|
+
return alias === 'default' ? 'Claude' : alias;
|
|
450
451
|
}
|
|
451
452
|
|
|
452
|
-
/** Friendly label for an effort level; unset
|
|
453
|
+
/** Friendly label for an effort level; unset values use automatic reasoning. */
|
|
453
454
|
export function effortLabel(value: string | null | undefined): string {
|
|
454
455
|
return (
|
|
455
|
-
EFFORT_OPTIONS.find((e) => e.value === value)?.label ?? '
|
|
456
|
+
EFFORT_OPTIONS.find((e) => e.value === value)?.label ?? 'Automatic'
|
|
456
457
|
);
|
|
457
458
|
}
|
|
458
459
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseFrontmatter } from './notes.js';
|
|
3
|
+
|
|
4
|
+
/** The UUID travels with the note when it is renamed or moved in the private vault. */
|
|
5
|
+
export function goalNoteId(content: string): string | null {
|
|
6
|
+
const parsed = z.uuid().safeParse(parseFrontmatter(content).data.lucidity_id);
|
|
7
|
+
return parsed.success ? parsed.data : null;
|
|
8
|
+
}
|
|
9
|
+
export function withGoalNoteId(content: string, id: string): string {
|
|
10
|
+
z.uuid().parse(id);
|
|
11
|
+
const existing = goalNoteId(content);
|
|
12
|
+
if (existing) {
|
|
13
|
+
if (existing !== id) throw new Error('This note already has a different identity. Reload it.');
|
|
14
|
+
return content;
|
|
15
|
+
}
|
|
16
|
+
if (content.startsWith('---')) {
|
|
17
|
+
const open = /^---[ \t]*\r?\n/.exec(content);
|
|
18
|
+
if (!open || !/^---[ \t]*(?:\r?\n|$)/m.test(content.slice(open[0].length)) || /^lucidity_id\s*:/m.test(content))
|
|
19
|
+
throw new Error('Fix the note’s frontmatter before linking it.');
|
|
20
|
+
return open[0] + `lucidity_id: ${id}\n` + content.slice(open[0].length);
|
|
21
|
+
}
|
|
22
|
+
return `---\nlucidity_id: ${id}\n---\n${content}`;
|
|
23
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
StudioDateSchema,
|
|
4
|
+
studioLocalDate,
|
|
5
|
+
shiftStudioDate,
|
|
6
|
+
} from './cardStudio.js';
|
|
7
|
+
|
|
8
|
+
export const GoalTimeZoneSchema = z
|
|
9
|
+
.string()
|
|
10
|
+
.max(100)
|
|
11
|
+
.refine((zone) => {
|
|
12
|
+
try {
|
|
13
|
+
new Intl.DateTimeFormat('en', { timeZone: zone });
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}, 'Choose a valid time zone.');
|
|
19
|
+
export const GoalTimeframeSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
start: StudioDateSchema,
|
|
22
|
+
end: StudioDateSchema,
|
|
23
|
+
precision: z.enum(['month', 'quarter', 'year', 'custom']),
|
|
24
|
+
timeZone: GoalTimeZoneSchema,
|
|
25
|
+
})
|
|
26
|
+
.refine(
|
|
27
|
+
(value) => value.end >= value.start,
|
|
28
|
+
'The end must be on or after the start.',
|
|
29
|
+
);
|
|
30
|
+
export type GoalTimeframe = z.infer<typeof GoalTimeframeSchema>;
|
|
31
|
+
export const GoalStatusSchema = z.enum([
|
|
32
|
+
'active',
|
|
33
|
+
'paused',
|
|
34
|
+
'completed',
|
|
35
|
+
'archived',
|
|
36
|
+
]);
|
|
37
|
+
export const GoalCadenceSchema = z.enum(['weekly', 'monthly', 'yearly']);
|
|
38
|
+
export type GoalCadence = z.infer<typeof GoalCadenceSchema>;
|
|
39
|
+
export const GoalInputSchema = z.object({
|
|
40
|
+
title: z.string().trim().min(1).max(240),
|
|
41
|
+
timeframe: GoalTimeframeSchema,
|
|
42
|
+
status: GoalStatusSchema.default('active'),
|
|
43
|
+
tracking: z.boolean().default(true),
|
|
44
|
+
reviews: z
|
|
45
|
+
.array(GoalCadenceSchema)
|
|
46
|
+
.max(3)
|
|
47
|
+
.default(['weekly', 'monthly'])
|
|
48
|
+
.refine((values) => new Set(values).size === values.length),
|
|
49
|
+
});
|
|
50
|
+
export type GoalInput = z.infer<typeof GoalInputSchema>;
|
|
51
|
+
export const SaveGoalSchema = GoalInputSchema.extend({
|
|
52
|
+
id: z.uuid(),
|
|
53
|
+
revision: z.number().int().nonnegative(),
|
|
54
|
+
});
|
|
55
|
+
export const GoalSchema = GoalInputSchema.extend({
|
|
56
|
+
id: z.uuid(),
|
|
57
|
+
revision: z.number().int().nonnegative(),
|
|
58
|
+
createdAt: z.iso.datetime(),
|
|
59
|
+
updatedAt: z.iso.datetime(),
|
|
60
|
+
});
|
|
61
|
+
export type Goal = z.infer<typeof GoalSchema>;
|
|
62
|
+
export const GoalReferenceSchema = z.object({
|
|
63
|
+
kind: z.enum(['task', 'project', 'habit', 'note']),
|
|
64
|
+
id: z.uuid(),
|
|
65
|
+
});
|
|
66
|
+
export type GoalReference = z.infer<typeof GoalReferenceSchema>;
|
|
67
|
+
export const goalReferenceKey = (ref: GoalReference) => `${ref.kind}:${ref.id}`;
|
|
68
|
+
export const GoalLinkInputSchema = GoalReferenceSchema.extend({
|
|
69
|
+
source: z.enum(['manual', 'ai']).default('manual'),
|
|
70
|
+
reason: z.string().trim().min(1).max(240),
|
|
71
|
+
state: z.enum(['active', 'rejected']).default('active'),
|
|
72
|
+
});
|
|
73
|
+
export const GoalLinkSchema = GoalLinkInputSchema.extend({
|
|
74
|
+
title: z.string().nullable(),
|
|
75
|
+
available: z.boolean(),
|
|
76
|
+
updatedAt: z.iso.datetime(),
|
|
77
|
+
});
|
|
78
|
+
export type GoalLink = z.infer<typeof GoalLinkSchema>;
|
|
79
|
+
export const GoalEvidenceSchema = z.object({
|
|
80
|
+
key: z.string(),
|
|
81
|
+
reference: GoalReferenceSchema,
|
|
82
|
+
at: z.iso.datetime(),
|
|
83
|
+
kind: z.enum([
|
|
84
|
+
'task_completed',
|
|
85
|
+
'task_started',
|
|
86
|
+
'task_reopened',
|
|
87
|
+
'task_changed',
|
|
88
|
+
'habit_check_in',
|
|
89
|
+
'note_changed',
|
|
90
|
+
]),
|
|
91
|
+
title: z.string().nullable(),
|
|
92
|
+
available: z.boolean(),
|
|
93
|
+
});
|
|
94
|
+
export type GoalEvidence = z.infer<typeof GoalEvidenceSchema>;
|
|
95
|
+
export const GoalCheckSchema = z.object({
|
|
96
|
+
key: z.string(),
|
|
97
|
+
cadence: z.enum(['daily', 'weekly', 'monthly', 'yearly']),
|
|
98
|
+
start: StudioDateSchema,
|
|
99
|
+
end: StudioDateSchema,
|
|
100
|
+
checkedAt: z.iso.datetime(),
|
|
101
|
+
signal: z.enum(['moving', 'quiet', 'unknown']),
|
|
102
|
+
summary: z.string(),
|
|
103
|
+
evidence: z.array(GoalEvidenceSchema),
|
|
104
|
+
references: z.array(GoalReferenceSchema),
|
|
105
|
+
timeframe: GoalTimeframeSchema,
|
|
106
|
+
});
|
|
107
|
+
export type GoalCheck = z.infer<typeof GoalCheckSchema>;
|
|
108
|
+
export const GoalActionSchema = z.object({
|
|
109
|
+
id: z.uuid(),
|
|
110
|
+
goalId: z.uuid(),
|
|
111
|
+
title: z.string(),
|
|
112
|
+
instruction: z.string(),
|
|
113
|
+
references: z.array(GoalReferenceSchema),
|
|
114
|
+
status: z.enum([
|
|
115
|
+
'proposed',
|
|
116
|
+
'approved',
|
|
117
|
+
'running',
|
|
118
|
+
'completed',
|
|
119
|
+
'cancelled',
|
|
120
|
+
'failed',
|
|
121
|
+
]),
|
|
122
|
+
createdAt: z.iso.datetime(),
|
|
123
|
+
updatedAt: z.iso.datetime(),
|
|
124
|
+
resultNoteId: z.uuid().nullable(),
|
|
125
|
+
resultMarkdown: z.string().nullable(),
|
|
126
|
+
error: z.string().nullable(),
|
|
127
|
+
});
|
|
128
|
+
export type GoalAction = z.infer<typeof GoalActionSchema>;
|
|
129
|
+
export const GoalDetailSchema = z.object({
|
|
130
|
+
goal: GoalSchema,
|
|
131
|
+
links: z.array(GoalLinkSchema),
|
|
132
|
+
checks: z.array(GoalCheckSchema),
|
|
133
|
+
actions: z.array(GoalActionSchema),
|
|
134
|
+
});
|
|
135
|
+
export type GoalDetail = z.infer<typeof GoalDetailSchema>;
|
|
136
|
+
export const GoalsSnapshotSchema = z.object({
|
|
137
|
+
goals: z.array(GoalDetailSchema),
|
|
138
|
+
refreshedAt: z.iso.datetime(),
|
|
139
|
+
});
|
|
140
|
+
export type GoalsSnapshot = z.infer<typeof GoalsSnapshotSchema>;
|
|
141
|
+
|
|
142
|
+
/** Date-only arithmetic deliberately ignores DST and the computer's current zone. */
|
|
143
|
+
export function goalDaysRemaining(
|
|
144
|
+
timeframe: GoalTimeframe,
|
|
145
|
+
now = new Date(),
|
|
146
|
+
): number {
|
|
147
|
+
return Math.round(
|
|
148
|
+
(Date.parse(timeframe.end) -
|
|
149
|
+
Date.parse(studioLocalDate(now, timeframe.timeZone))) /
|
|
150
|
+
86_400_000,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
export function goalPeriod(
|
|
154
|
+
cadence: 'daily' | GoalCadence,
|
|
155
|
+
today: string,
|
|
156
|
+
): { start: string; end: string; key: string } {
|
|
157
|
+
StudioDateSchema.parse(today);
|
|
158
|
+
let start = today,
|
|
159
|
+
end = today;
|
|
160
|
+
if (cadence === 'weekly') {
|
|
161
|
+
const day = new Date(today + 'T12:00:00Z').getUTCDay();
|
|
162
|
+
end = shiftStudioDate(today, -((day + 6) % 7) - 1);
|
|
163
|
+
start = shiftStudioDate(end, -6);
|
|
164
|
+
} else if (cadence === 'monthly') {
|
|
165
|
+
end = shiftStudioDate(today.slice(0, 8) + '01', -1);
|
|
166
|
+
start = end.slice(0, 8) + '01';
|
|
167
|
+
} else if (cadence === 'yearly') {
|
|
168
|
+
const year = Number(today.slice(0, 4)) - 1;
|
|
169
|
+
start = `${year}-01-01`;
|
|
170
|
+
end = `${year}-12-31`;
|
|
171
|
+
}
|
|
172
|
+
return { start, end, key: `${cadence}:${start}` };
|
|
173
|
+
}
|
|
174
|
+
/** Completed periods only, with no backlog flood after a computer wakes. */
|
|
175
|
+
export function dueGoalPeriods(
|
|
176
|
+
goal: Goal,
|
|
177
|
+
existing: readonly Pick<GoalCheck, 'key'>[],
|
|
178
|
+
now = new Date(),
|
|
179
|
+
) {
|
|
180
|
+
if (!goal.tracking || goal.status !== 'active') return [];
|
|
181
|
+
const today = studioLocalDate(now, goal.timeframe.timeZone);
|
|
182
|
+
if (today < goal.timeframe.start) return [];
|
|
183
|
+
const created = studioLocalDate(
|
|
184
|
+
new Date(goal.createdAt),
|
|
185
|
+
goal.timeframe.timeZone,
|
|
186
|
+
);
|
|
187
|
+
return (['daily', ...goal.reviews] as const)
|
|
188
|
+
.map((cadence) => ({ cadence, ...goalPeriod(cadence, today) }))
|
|
189
|
+
.filter(
|
|
190
|
+
(period) =>
|
|
191
|
+
period.end >= created &&
|
|
192
|
+
period.end >= goal.timeframe.start &&
|
|
193
|
+
!existing.some((check) => check.key === period.key),
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const GoalAnalysisSchema = z.object({
|
|
198
|
+
links: z
|
|
199
|
+
.array(GoalReferenceSchema.extend({ reason: z.string().max(240) }))
|
|
200
|
+
.max(12),
|
|
201
|
+
summary: z.string().trim().min(1).max(400),
|
|
202
|
+
help: z
|
|
203
|
+
.object({
|
|
204
|
+
title: z.string().max(100),
|
|
205
|
+
instruction: z.string().max(800),
|
|
206
|
+
references: z.array(GoalReferenceSchema).min(1).max(12),
|
|
207
|
+
})
|
|
208
|
+
.nullable(),
|
|
209
|
+
});
|
|
210
|
+
export type GoalAnalysis = z.infer<typeof GoalAnalysisSchema>;
|
|
211
|
+
|
|
212
|
+
export const GoalCandidateSchema = GoalReferenceSchema.extend({
|
|
213
|
+
title: z.string(),
|
|
214
|
+
description: z.string().nullable(),
|
|
215
|
+
updatedAt: z.iso.datetime().nullable(),
|
|
216
|
+
status: z.string().nullable(),
|
|
217
|
+
projectId: z.uuid().nullable(),
|
|
218
|
+
});
|
|
219
|
+
export type GoalCandidate = z.infer<typeof GoalCandidateSchema>;
|
|
220
|
+
export const GoalTrackingContextSchema = z.object({
|
|
221
|
+
detail: GoalDetailSchema,
|
|
222
|
+
candidates: z.array(GoalCandidateSchema),
|
|
223
|
+
evidence: z.array(GoalEvidenceSchema),
|
|
224
|
+
complete: z.boolean(),
|
|
225
|
+
});
|
|
226
|
+
export type GoalTrackingContext = z.infer<typeof GoalTrackingContextSchema>;
|
|
227
|
+
export const RecordGoalCheckSchema = z.object({
|
|
228
|
+
revision: z.number().int().positive(),
|
|
229
|
+
cadence: z.enum(['daily', 'weekly', 'monthly', 'yearly']),
|
|
230
|
+
summary: z.string().trim().min(1).max(400),
|
|
231
|
+
noteObservations: z
|
|
232
|
+
.array(z.object({ id: z.uuid(), at: z.iso.datetime() }))
|
|
233
|
+
.max(100)
|
|
234
|
+
.default([]),
|
|
235
|
+
notesAvailable: z.boolean().default(false),
|
|
236
|
+
help: GoalAnalysisSchema.shape.help,
|
|
237
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './dayPlanning.js';
|
|
2
|
+
export * from './workspaces.js';
|
|
2
3
|
export * from './githubContributions.js';
|
|
3
4
|
export * from './projectCapture.js';
|
|
4
5
|
export * from './taskActivity.js';
|
|
@@ -446,3 +447,6 @@ export * from './dayPlan.js';
|
|
|
446
447
|
|
|
447
448
|
export { parseAgentCommand, findAgentCommand } from './agentCommands.js';
|
|
448
449
|
export type { AgentCommandOption, AgentCommandContext } from './agentCommands.js';
|
|
450
|
+
|
|
451
|
+
export * from './goals.js';
|
|
452
|
+
export * from './goalNotes.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { WorkspaceCommandSchema, WorkspaceSnapshotSchema } from '../workspaces.js';
|
|
2
3
|
import {
|
|
3
4
|
VoiceCaptureAudioSchema,
|
|
4
5
|
VoiceCaptureReceiptSchema,
|
|
@@ -506,6 +507,7 @@ export const AttentionRequestSchema = HarnessRequestBase.extend({
|
|
|
506
507
|
});
|
|
507
508
|
|
|
508
509
|
export const HarnessRequestSchema = z.discriminatedUnion('kind', [
|
|
510
|
+
HarnessRequestBase.extend({ kind: z.literal('workspaces'), command: WorkspaceCommandSchema }),
|
|
509
511
|
HarnessRequestBase.extend({
|
|
510
512
|
kind: z.literal('voice-capture'),
|
|
511
513
|
credentialId: z.uuid(),
|
|
@@ -789,6 +791,7 @@ export const CommandsResponseSchema = HarnessResponseBase.extend({
|
|
|
789
791
|
description: z.string(),
|
|
790
792
|
argumentHint: z.string(),
|
|
791
793
|
acceptsArguments: z.boolean().optional(),
|
|
794
|
+
startsConversation: z.boolean().optional(),
|
|
792
795
|
aliases: z.array(z.string()).optional(),
|
|
793
796
|
clearsContext: z.boolean().optional(),
|
|
794
797
|
}),
|
|
@@ -796,6 +799,7 @@ export const CommandsResponseSchema = HarnessResponseBase.extend({
|
|
|
796
799
|
});
|
|
797
800
|
|
|
798
801
|
export const HarnessResponseSchema = z.discriminatedUnion('kind', [
|
|
802
|
+
HarnessResponseBase.extend({ kind: z.literal('workspaces'), snapshot: WorkspaceSnapshotSchema }),
|
|
799
803
|
HarnessResponseBase.extend({
|
|
800
804
|
kind: z.literal('voice-capture'),
|
|
801
805
|
receipt: VoiceCaptureReceiptSchema.nullable(),
|
|
@@ -895,6 +899,7 @@ export const HarnessStreamEventSchema = z.discriminatedUnion('type', [
|
|
|
895
899
|
// ran — on `branch` — so the phone shows a quiet "checkout moved" notice on the bubble
|
|
896
900
|
// instead of the old dead-end rejection that made the user re-send.
|
|
897
901
|
movedFrom: z.string().optional(),
|
|
902
|
+
checkpointWarning: z.string().optional(),
|
|
898
903
|
}),
|
|
899
904
|
z.object({
|
|
900
905
|
// The result of a `clone` turn (#78): the new repo's id, once cloned into the
|
|
@@ -965,6 +970,7 @@ export const HarnessStreamEventSchema = z.discriminatedUnion('type', [
|
|
|
965
970
|
type: z.literal('error'),
|
|
966
971
|
requestId: z.uuidv7(),
|
|
967
972
|
message: z.string(),
|
|
973
|
+
code: z.string().optional(),
|
|
968
974
|
}),
|
|
969
975
|
// A `cancel` request successfully stopped this in-flight turn.
|
|
970
976
|
z.object({
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const SavedChatMessageSchema = z.object({
|
|
4
|
+
id: z.string().min(1), role: z.enum(['user', 'lucid', 'notice']), text: z.string(),
|
|
5
|
+
}).passthrough();
|
|
6
|
+
|
|
7
|
+
export const WorkerWorkspaceSchema = z.object({
|
|
8
|
+
workerId: z.uuidv7(), repoId: z.string().min(1), title: z.string().min(1).max(200),
|
|
9
|
+
brief: z.string().max(8000).default(''),
|
|
10
|
+
workspaceId: z.string(), conversationId: z.string(),
|
|
11
|
+
state: z.enum(['creating', 'ready', 'setup_failed', 'archived']),
|
|
12
|
+
branch: z.string().optional(), baseRef: z.string().optional(), baseSha: z.string().optional(),
|
|
13
|
+
resume: z.string().optional(), error: z.string().optional(),
|
|
14
|
+
createdAt: z.string(), updatedAt: z.string(),
|
|
15
|
+
});
|
|
16
|
+
export type WorkerWorkspace = z.infer<typeof WorkerWorkspaceSchema>;
|
|
17
|
+
|
|
18
|
+
export const WorkspaceCommandSchema = z.object({
|
|
19
|
+
action: z.enum(['list', 'create', 'history', 'archive', 'restore', 'import', 'clear-history']),
|
|
20
|
+
repoId: z.string().min(1).optional(), workerId: z.uuidv7().optional(),
|
|
21
|
+
checkout: z.boolean().optional(), revision: z.string().optional(),
|
|
22
|
+
title: z.string().trim().min(1).max(200).optional(),
|
|
23
|
+
brief: z.string().max(8000).optional(), before: z.string().optional(),
|
|
24
|
+
legacy: z.object({
|
|
25
|
+
messages: z.array(SavedChatMessageSchema).max(10_000), resume: z.string().optional(),
|
|
26
|
+
sessionCheckout: z.boolean().optional(),
|
|
27
|
+
}).optional(),
|
|
28
|
+
});
|
|
29
|
+
export type WorkspaceCommand = z.infer<typeof WorkspaceCommandSchema>;
|
|
30
|
+
|
|
31
|
+
export const WorkspaceRunSchema = z.object({
|
|
32
|
+
requestId: z.string(), prompt: z.string(),
|
|
33
|
+
handoff: z.object({ from: z.enum(['claude', 'codex']), to: z.enum(['claude', 'codex']) }).optional(),
|
|
34
|
+
frames: z.array(z.record(z.string(), z.unknown())),
|
|
35
|
+
terminated: z.boolean(),
|
|
36
|
+
});
|
|
37
|
+
export type WorkspaceRun = z.infer<typeof WorkspaceRunSchema>;
|
|
38
|
+
export const WorkspaceSnapshotSchema = z.object({
|
|
39
|
+
workers: z.array(WorkerWorkspaceSchema),
|
|
40
|
+
checkout: z.object({
|
|
41
|
+
repoId: z.string(), conversationId: z.string(), revision: z.string(),
|
|
42
|
+
resume: z.string().optional(),
|
|
43
|
+
}).optional(),
|
|
44
|
+
runs: z.array(WorkspaceRunSchema).optional(),
|
|
45
|
+
legacyMessages: z.array(SavedChatMessageSchema).optional(),
|
|
46
|
+
nextBefore: z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
export type WorkspaceSnapshot = z.infer<typeof WorkspaceSnapshotSchema>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export interface FleetConflict {
|
|
2
|
-
workerId: string;
|
|
3
|
-
/** The files that couldn't merge cleanly. */
|
|
4
|
-
paths: string[];
|
|
5
|
-
}
|
|
6
|
-
export interface IntegrationResult {
|
|
7
|
-
/** The branch the workers were integrated onto — the bare `lucid/<repo>` session, which
|
|
8
|
-
* is also where the fleet's single PR opens from. */
|
|
9
|
-
branch: string;
|
|
10
|
-
/** Worker ids that merged cleanly, in the order they landed. */
|
|
11
|
-
merged: string[];
|
|
12
|
-
/** Workers whose branch conflicted; their merge was aborted and left for the user to hand
|
|
13
|
-
* back to the worker as a fresh turn. */
|
|
14
|
-
conflicts: FleetConflict[];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Integrate finished workers onto the fleet branch, one at a time in merge order.
|
|
18
|
-
*
|
|
19
|
-
* The integration worktree is the bare repo session (`lucid/<repo>`), reset to HEAD, so the
|
|
20
|
-
* fan-out's result is a single branch cut fresh from where the user started — clean history to
|
|
21
|
-
* open one PR from. Each worker's `fleet/<repo>/<workerId>` branch is merged in; a conflict is
|
|
22
|
-
* caught (not thrown), the merge aborted so the next worker can still land, and reported via
|
|
23
|
-
* `onConflict` so the conductor surfaces it in the feed rather than silently dropping work.
|
|
24
|
-
*
|
|
25
|
-
* Sequential and in order because that's where overlap actually bites: the workers ran in
|
|
26
|
-
* isolated worktrees and never raced each other on disk — only the merge can conflict, and only
|
|
27
|
-
* against what already landed.
|
|
28
|
-
*/
|
|
29
|
-
export declare function integrateWorkers(repoRoot: string, repoId: string, workers: {
|
|
30
|
-
workerId: string;
|
|
31
|
-
mergeOrder: number;
|
|
32
|
-
}[], opts?: {
|
|
33
|
-
baseDir?: string;
|
|
34
|
-
onMerged?: (workerId: string) => void;
|
|
35
|
-
onConflict?: (conflict: FleetConflict) => void;
|
|
36
|
-
}): Promise<IntegrationResult>;
|
|
37
|
-
//# sourceMappingURL=fleetIntegrate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fleetIntegrate.d.ts","sourceRoot":"","sources":["../../src/coding/fleetIntegrate.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC;0DACsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;8CAC0C;IAC1C,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,EACnD,IAAI,GAAE;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C,GACL,OAAO,CAAC,iBAAiB,CAAC,CA4C5B"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
import { ensureWorkspace, sessionBranch } from './worktree.js';
|
|
4
|
-
const exec = promisify(execFile);
|
|
5
|
-
async function git(cwd, args) {
|
|
6
|
-
const { stdout } = await exec('git', args, { cwd, maxBuffer: 32 * 1024 * 1024 });
|
|
7
|
-
return stdout;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Integrate finished workers onto the fleet branch, one at a time in merge order.
|
|
11
|
-
*
|
|
12
|
-
* The integration worktree is the bare repo session (`lucid/<repo>`), reset to HEAD, so the
|
|
13
|
-
* fan-out's result is a single branch cut fresh from where the user started — clean history to
|
|
14
|
-
* open one PR from. Each worker's `fleet/<repo>/<workerId>` branch is merged in; a conflict is
|
|
15
|
-
* caught (not thrown), the merge aborted so the next worker can still land, and reported via
|
|
16
|
-
* `onConflict` so the conductor surfaces it in the feed rather than silently dropping work.
|
|
17
|
-
*
|
|
18
|
-
* Sequential and in order because that's where overlap actually bites: the workers ran in
|
|
19
|
-
* isolated worktrees and never raced each other on disk — only the merge can conflict, and only
|
|
20
|
-
* against what already landed.
|
|
21
|
-
*/
|
|
22
|
-
export async function integrateWorkers(repoRoot, repoId, workers, opts = {}) {
|
|
23
|
-
const branch = sessionBranch(repoId);
|
|
24
|
-
// Fresh bare session = lucid/<repo> reset to HEAD: the integration target.
|
|
25
|
-
const ws = await ensureWorkspace(repoRoot, repoId, {
|
|
26
|
-
fresh: true,
|
|
27
|
-
baseDir: opts.baseDir,
|
|
28
|
-
});
|
|
29
|
-
const ordered = [...workers].sort((a, b) => a.mergeOrder - b.mergeOrder);
|
|
30
|
-
const merged = [];
|
|
31
|
-
const conflicts = [];
|
|
32
|
-
for (const w of ordered) {
|
|
33
|
-
const workerBranch = sessionBranch(repoId, w.workerId);
|
|
34
|
-
try {
|
|
35
|
-
await git(ws.path, [
|
|
36
|
-
'merge',
|
|
37
|
-
'--no-ff',
|
|
38
|
-
'-m',
|
|
39
|
-
`Merge fleet worker ${w.workerId}`,
|
|
40
|
-
workerBranch,
|
|
41
|
-
]);
|
|
42
|
-
merged.push(w.workerId);
|
|
43
|
-
opts.onMerged?.(w.workerId);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// A conflict (or any merge failure): record the unmerged paths, abort so the branch is
|
|
47
|
-
// clean for the next worker, and report. Never fatal — one bad lane can't sink the fleet.
|
|
48
|
-
const unmerged = await git(ws.path, [
|
|
49
|
-
'diff',
|
|
50
|
-
'--name-only',
|
|
51
|
-
'--diff-filter=U',
|
|
52
|
-
]).catch(() => '');
|
|
53
|
-
const paths = unmerged
|
|
54
|
-
.split('\n')
|
|
55
|
-
.map((s) => s.trim())
|
|
56
|
-
.filter(Boolean);
|
|
57
|
-
await git(ws.path, ['merge', '--abort']).catch(() => { });
|
|
58
|
-
const conflict = { workerId: w.workerId, paths };
|
|
59
|
-
conflicts.push(conflict);
|
|
60
|
-
opts.onConflict?.(conflict);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return { branch, merged, conflicts };
|
|
64
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export interface FleetPrSummary {
|
|
2
|
-
title: string;
|
|
3
|
-
body: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Build the PR's title + body from the fleet goal and the workers that actually landed. Pure so
|
|
7
|
-
* it can be unit-tested; the spawn wrapper below is covered by a real run.
|
|
8
|
-
*/
|
|
9
|
-
export declare function fleetPrSummary(goal: string, mergedTitles: string[]): FleetPrSummary;
|
|
10
|
-
/**
|
|
11
|
-
* Per-feature delivery: build ONE worker's PR title + body.
|
|
12
|
-
*
|
|
13
|
-
* The title is the worker's own FIRST commit subject, which `codeCommitMessage` already built out
|
|
14
|
-
* of Lucid's summary of what it did. The lane title can't do that job and shouldn't have been
|
|
15
|
-
* asked to: it's `clampTitle(brief.split('\n')[0])`, so it's the opening line of whatever was
|
|
16
|
-
* typed at the board, which names the request rather than the change and is usually cut off
|
|
17
|
-
* mid-thought (#308). It stays as the fallback for a branch whose subjects couldn't be read.
|
|
18
|
-
*
|
|
19
|
-
* The first subject rather than the last, because a steered worker's later commits are
|
|
20
|
-
* refinements of the piece of work the branch is about. The rest go in the body under the brief
|
|
21
|
-
* that asked for them, which is the one thing the brief is genuinely good for. Pure, unit-tested.
|
|
22
|
-
*/
|
|
23
|
-
export declare function workerPrSummary(title: string, brief: string, subjects?: string[]): FleetPrSummary;
|
|
24
|
-
export interface FleetPrResult {
|
|
25
|
-
url?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Push the integration branch and open (or reuse) ONE pull request for the whole fan-out.
|
|
30
|
-
*
|
|
31
|
-
* Runs from the lucid/<repo> worktree, which is on the integration branch and shares the repo's
|
|
32
|
-
* GitHub remote. The branch is force-pushed because each fleet resets it fresh to HEAD before
|
|
33
|
-
* merging — its history is authored per-run, so the remote must follow. If a PR for the branch is
|
|
34
|
-
* already open (a re-integrated fleet), its URL is returned and the force-push updates it in place
|
|
35
|
-
* rather than opening a duplicate.
|
|
36
|
-
*
|
|
37
|
-
* Never throws: a missing/unauthed `gh`, or a repo with no GitHub remote, returns `{ error }` the
|
|
38
|
-
* phone can surface — the fleet already merged locally regardless.
|
|
39
|
-
*/
|
|
40
|
-
export declare function openFleetPr(worktreePath: string, branch: string, summary: FleetPrSummary, base?: string): Promise<FleetPrResult>;
|
|
41
|
-
//# sourceMappingURL=openFleetPr.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openFleetPr.d.ts","sourceRoot":"","sources":["../../src/coding/openFleetPr.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,cAAc,CAQnF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAM,EAAO,GACtB,cAAc,CAQhB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,cAAc,EACvB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,CAAC,CAuDxB"}
|