@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
|
@@ -29,6 +29,12 @@ export declare function sessionBranch(repoId: string, workerId?: string): string
|
|
|
29
29
|
export declare function sessionWorktreePath(repoId: string, baseDir?: string, workerId?: string): string;
|
|
30
30
|
/** The branch checked out in `repoRoot`, or `HEAD` when detached. */
|
|
31
31
|
export declare function currentBranch(repoRoot: string): Promise<string>;
|
|
32
|
+
export declare function workspaceBranchExists(repoRoot: string, repoId: string, workerId?: string): Promise<boolean>;
|
|
33
|
+
/** Resolve the fetched remote base without changing the existing checkout. */
|
|
34
|
+
export declare function workspaceBase(repoRoot: string, configured?: string): Promise<{
|
|
35
|
+
ref: string;
|
|
36
|
+
sha: string;
|
|
37
|
+
}>;
|
|
32
38
|
/**
|
|
33
39
|
* How many commits this worktree's HEAD carries that `base` doesn't.
|
|
34
40
|
*
|
|
@@ -62,23 +68,12 @@ export declare function githubWebUrlFromRemote(raw: string): string | undefined;
|
|
|
62
68
|
* `git remote` rather than `gh` so it needs no auth and works even when `gh` is absent — the phone
|
|
63
69
|
* appends `/pulls`, `/issues`, `/projects` to jump straight there. */
|
|
64
70
|
export declare function repoWebUrl(repoRoot: string): Promise<string | undefined>;
|
|
65
|
-
/**
|
|
66
|
-
* Prepare the workspace for a coding turn.
|
|
67
|
-
*
|
|
68
|
-
* `worktree` (default): ensure the persistent worktree for this repo's session exists
|
|
69
|
-
* on its `lucid/<repoId>` branch, at a STABLE path so Claude Code's `--resume` resolves
|
|
70
|
-
* across turns. `fresh: true` (a new session — no resume) resets the branch and worktree
|
|
71
|
-
* to HEAD, discarding any prior session's state. Otherwise the existing worktree is
|
|
72
|
-
* reused as-is so prior turns' commits (files) carry forward; if it's missing (first
|
|
73
|
-
* turn, or pruned), it's created off HEAD.
|
|
74
|
-
*
|
|
75
|
-
* `in-place` (#121): the user's own checkout, on its live branch, uncommitted work and
|
|
76
|
-
* all — the point of the mode is that Lucid continues from where the user left off, so
|
|
77
|
-
* `fresh` resets NOTHING here. It would mean discarding their work.
|
|
78
|
-
*/
|
|
71
|
+
/** Resolve a persistent workspace. Provider session changes never reset its files. */
|
|
79
72
|
export declare function ensureWorkspace(repoRoot: string, repoId: string, opts?: {
|
|
80
73
|
mode?: WorkspaceMode;
|
|
74
|
+
/** Legacy callers may pass this; conversation resets never reset a workspace. */
|
|
81
75
|
fresh?: boolean;
|
|
76
|
+
startPoint?: string;
|
|
82
77
|
baseDir?: string;
|
|
83
78
|
/** Conductor worker id (the fleet subtask's id). Present → an isolated per-worker
|
|
84
79
|
* worktree/branch so N workers run in parallel on one repo. Absent → the classic
|
|
@@ -146,4 +141,6 @@ export declare function commitWorkspace(ws: Workspace, message: string, paths: s
|
|
|
146
141
|
export declare function removeWorktree(repoRoot: string, ws: Workspace, opts?: {
|
|
147
142
|
keepBranch?: boolean;
|
|
148
143
|
}): Promise<void>;
|
|
144
|
+
/** A review can inspect tracked changes without staging or reading unrelated untracked files. */
|
|
145
|
+
export declare function reviewDiff(ws: Workspace): Promise<string>;
|
|
149
146
|
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/coding/worktree.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAStD;;kEAEkE;AAClE,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;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 export function sessionWorktreePath(repoId, baseDir = WORKTREE_BASE, workerId) {
|
|
|
46
46
|
export async function currentBranch(repoRoot) {
|
|
47
47
|
return (await git(repoRoot, ['rev-parse', '--abbrev-ref', 'HEAD'])).trim();
|
|
48
48
|
}
|
|
49
|
+
export async function workspaceBranchExists(repoRoot, repoId, workerId) {
|
|
50
|
+
return git(repoRoot, ['show-ref', '--verify', `refs/heads/${sessionBranch(repoId, workerId)}`]).then(() => true, () => false);
|
|
51
|
+
}
|
|
52
|
+
/** Resolve the fetched remote base without changing the existing checkout. */
|
|
53
|
+
export async function workspaceBase(repoRoot, configured) {
|
|
54
|
+
const remotes = (await git(repoRoot, ['remote'])).trim().split('\n');
|
|
55
|
+
if (!remotes.includes('origin')) {
|
|
56
|
+
if (configured)
|
|
57
|
+
throw new Error('The configured workspace base requires an origin remote.');
|
|
58
|
+
return { ref: 'HEAD', sha: (await git(repoRoot, ['rev-parse', 'HEAD'])).trim() };
|
|
59
|
+
}
|
|
60
|
+
await git(repoRoot, ['fetch', 'origin']);
|
|
61
|
+
let ref = configured;
|
|
62
|
+
if (!ref) {
|
|
63
|
+
const remoteHead = await git(repoRoot, ['ls-remote', '--symref', 'origin', 'HEAD']);
|
|
64
|
+
const branch = /^ref: refs\/heads\/(.+)\s+HEAD$/m.exec(remoteHead)?.[1];
|
|
65
|
+
if (!branch)
|
|
66
|
+
throw new Error('Could not resolve the remote default branch. Set this repository\'s baseRef.');
|
|
67
|
+
ref = `origin/${branch}`;
|
|
68
|
+
}
|
|
69
|
+
if (!ref.startsWith('origin/'))
|
|
70
|
+
ref = `origin/${ref}`;
|
|
71
|
+
const sha = (await git(repoRoot, ['rev-parse', '--verify', '--end-of-options', `${ref}^{commit}`])).trim();
|
|
72
|
+
return { ref, sha };
|
|
73
|
+
}
|
|
49
74
|
/**
|
|
50
75
|
* How many commits this worktree's HEAD carries that `base` doesn't.
|
|
51
76
|
*
|
|
@@ -113,20 +138,7 @@ export async function repoWebUrl(repoRoot) {
|
|
|
113
138
|
const raw = await git(repoRoot, ['remote', 'get-url', 'origin']).catch(() => '');
|
|
114
139
|
return githubWebUrlFromRemote(raw);
|
|
115
140
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Prepare the workspace for a coding turn.
|
|
118
|
-
*
|
|
119
|
-
* `worktree` (default): ensure the persistent worktree for this repo's session exists
|
|
120
|
-
* on its `lucid/<repoId>` branch, at a STABLE path so Claude Code's `--resume` resolves
|
|
121
|
-
* across turns. `fresh: true` (a new session — no resume) resets the branch and worktree
|
|
122
|
-
* to HEAD, discarding any prior session's state. Otherwise the existing worktree is
|
|
123
|
-
* reused as-is so prior turns' commits (files) carry forward; if it's missing (first
|
|
124
|
-
* turn, or pruned), it's created off HEAD.
|
|
125
|
-
*
|
|
126
|
-
* `in-place` (#121): the user's own checkout, on its live branch, uncommitted work and
|
|
127
|
-
* all — the point of the mode is that Lucid continues from where the user left off, so
|
|
128
|
-
* `fresh` resets NOTHING here. It would mean discarding their work.
|
|
129
|
-
*/
|
|
141
|
+
/** Resolve a persistent workspace. Provider session changes never reset its files. */
|
|
130
142
|
export async function ensureWorkspace(repoRoot, repoId, opts = {}) {
|
|
131
143
|
const mode = opts.mode ?? 'worktree';
|
|
132
144
|
if (mode === 'in-place') {
|
|
@@ -136,13 +148,15 @@ export async function ensureWorkspace(repoRoot, repoId, opts = {}) {
|
|
|
136
148
|
const branch = sessionBranch(repoId, opts.workerId);
|
|
137
149
|
const path = sessionWorktreePath(repoId, baseDir, opts.workerId);
|
|
138
150
|
mkdirSync(baseDir, { recursive: true });
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
await git(repoRoot,
|
|
151
|
+
if (existsSync(path)) {
|
|
152
|
+
return { path, branch: await currentBranch(path), mode };
|
|
153
|
+
}
|
|
154
|
+
// Recover branches left behind by the old automatic delivery path.
|
|
155
|
+
const existing = await git(repoRoot, ['show-ref', '--verify', `refs/heads/${branch}`])
|
|
156
|
+
.then(() => true, () => false);
|
|
157
|
+
await git(repoRoot, existing
|
|
158
|
+
? ['worktree', 'add', path, branch]
|
|
159
|
+
: ['worktree', 'add', '-b', branch, path, opts.startPoint ?? 'HEAD']);
|
|
146
160
|
return { path, branch, mode };
|
|
147
161
|
}
|
|
148
162
|
/**
|
|
@@ -262,3 +276,9 @@ export async function removeWorktree(repoRoot, ws, opts = {}) {
|
|
|
262
276
|
}
|
|
263
277
|
}
|
|
264
278
|
}
|
|
279
|
+
/** A review can inspect tracked changes without staging or reading unrelated untracked files. */
|
|
280
|
+
export async function reviewDiff(ws) {
|
|
281
|
+
const diff = await git(ws.path, ['diff', '--no-ext-diff', '--no-textconv', 'HEAD', '--']);
|
|
282
|
+
const limit = 80_000;
|
|
283
|
+
return diff.length > limit ? diff.slice(0, limit) + '\n[Diff truncated. Read the relevant files for the rest.]' : diff;
|
|
284
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export declare const INCIDENTS_DIR: string;
|
|
|
20
20
|
export declare const VOICE_DIAG_DIR: string;
|
|
21
21
|
/** An allowlisted repo Lucid may code in (M7). The phone sends the `id`, never a path. */
|
|
22
22
|
export interface RepoEntry {
|
|
23
|
+
/** Remote base for new workers, e.g. origin/main; defaults to origin's HEAD. */
|
|
24
|
+
baseRef?: string;
|
|
23
25
|
/** Short name the phone selects, e.g. `"lucidity"`. */
|
|
24
26
|
id: string;
|
|
25
27
|
/** Absolute path to the repo on this machine. `~` expands. */
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,aAAa,EACb,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE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,SAAS,CAc7B;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,MAAoB,GAC/B,MAAM,EAAE,CASV;AAED,4FAA4F;AAC5F,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,MAAoB,GAC/B,SAAS,EAAE,CAmBb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The OS releases this lock on exit, including a crash. Never unlink its database. */
|
|
2
|
+
export declare class DaemonLease {
|
|
3
|
+
readonly owner: {
|
|
4
|
+
epoch: `${string}-${string}-${string}-${string}-${string}`;
|
|
5
|
+
pid: number;
|
|
6
|
+
startedAt: string;
|
|
7
|
+
};
|
|
8
|
+
private db;
|
|
9
|
+
constructor(directory: string);
|
|
10
|
+
close(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=daemonLease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemonLease.d.ts","sourceRoot":"","sources":["../src/daemonLease.ts"],"names":[],"mappings":"AAMA,uFAAuF;AACvF,qBAAa,WAAW;IACtB,QAAQ,CAAC,KAAK;;;;MAAkF;IAChG,OAAO,CAAC,EAAE,CAAM;gBAEJ,SAAS,EAAE,MAAM;IAgB7B,KAAK,IAAI,IAAI;CAKd"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @ts-expect-error Node 22 runtime API; the repository's Node type baseline is 20.
|
|
2
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
3
|
+
import { chmodSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
/** The OS releases this lock on exit, including a crash. Never unlink its database. */
|
|
7
|
+
export class DaemonLease {
|
|
8
|
+
owner = { epoch: randomUUID(), pid: process.pid, startedAt: new Date().toISOString() };
|
|
9
|
+
db;
|
|
10
|
+
constructor(directory) {
|
|
11
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
12
|
+
const path = join(directory, 'daemon-owner.sqlite');
|
|
13
|
+
const db = new DatabaseSync(path);
|
|
14
|
+
try {
|
|
15
|
+
chmodSync(path, 0o600);
|
|
16
|
+
db.exec('PRAGMA busy_timeout=0; BEGIN EXCLUSIVE;');
|
|
17
|
+
this.db = db;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
db.close();
|
|
21
|
+
if (error.errcode === 5)
|
|
22
|
+
throw new Error('Lucidity is already running for this configuration. Stop that daemon before starting another.');
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
close() {
|
|
27
|
+
if (!this.db)
|
|
28
|
+
return;
|
|
29
|
+
this.db.close();
|
|
30
|
+
this.db = undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { type GoalCandidate, type GoalCheck, type GoalDetail, type GoalEvidence } from '@lucidity/shared';
|
|
2
|
+
/** Keep stored evidence intact; send a bounded, explicitly partial view to the model. */
|
|
3
|
+
export declare function goalAssessmentInput(input: {
|
|
4
|
+
detail: GoalDetail;
|
|
5
|
+
period: Pick<GoalCheck, 'cadence' | 'key' | 'start' | 'end'>;
|
|
6
|
+
sources: GoalCandidate[];
|
|
7
|
+
evidence: GoalEvidence[];
|
|
8
|
+
complete: boolean;
|
|
9
|
+
}): {
|
|
10
|
+
goal: {
|
|
11
|
+
title: string;
|
|
12
|
+
timeframe: {
|
|
13
|
+
start: string;
|
|
14
|
+
end: string;
|
|
15
|
+
precision: "custom" | "year" | "month" | "quarter";
|
|
16
|
+
timeZone: string;
|
|
17
|
+
};
|
|
18
|
+
status: "completed" | "archived" | "paused" | "active";
|
|
19
|
+
tracking: boolean;
|
|
20
|
+
reviews: ("weekly" | "monthly" | "yearly")[];
|
|
21
|
+
id: string;
|
|
22
|
+
revision: number;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
};
|
|
26
|
+
period: Pick<{
|
|
27
|
+
key: string;
|
|
28
|
+
cadence: "daily" | "weekly" | "monthly" | "yearly";
|
|
29
|
+
start: string;
|
|
30
|
+
end: string;
|
|
31
|
+
checkedAt: string;
|
|
32
|
+
signal: "unknown" | "moving" | "quiet";
|
|
33
|
+
summary: string;
|
|
34
|
+
evidence: {
|
|
35
|
+
key: string;
|
|
36
|
+
reference: {
|
|
37
|
+
kind: "project" | "task" | "habit" | "note";
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
at: string;
|
|
41
|
+
kind: "task_completed" | "task_started" | "task_reopened" | "task_changed" | "habit_check_in" | "note_changed";
|
|
42
|
+
title: string | null;
|
|
43
|
+
available: boolean;
|
|
44
|
+
}[];
|
|
45
|
+
references: {
|
|
46
|
+
kind: "project" | "task" | "habit" | "note";
|
|
47
|
+
id: string;
|
|
48
|
+
}[];
|
|
49
|
+
timeframe: {
|
|
50
|
+
start: string;
|
|
51
|
+
end: string;
|
|
52
|
+
precision: "custom" | "year" | "month" | "quarter";
|
|
53
|
+
timeZone: string;
|
|
54
|
+
};
|
|
55
|
+
}, "end" | "start" | "key" | "cadence">;
|
|
56
|
+
sources: {
|
|
57
|
+
title: string;
|
|
58
|
+
description: string | null;
|
|
59
|
+
kind: "project" | "task" | "habit" | "note";
|
|
60
|
+
id: string;
|
|
61
|
+
updatedAt: string | null;
|
|
62
|
+
status: string | null;
|
|
63
|
+
projectId: string | null;
|
|
64
|
+
}[];
|
|
65
|
+
notes: {
|
|
66
|
+
kind: "project" | "task" | "habit" | "note";
|
|
67
|
+
id: string;
|
|
68
|
+
}[];
|
|
69
|
+
evidence: {
|
|
70
|
+
title: string | null;
|
|
71
|
+
key: string;
|
|
72
|
+
reference: {
|
|
73
|
+
kind: "project" | "task" | "habit" | "note";
|
|
74
|
+
id: string;
|
|
75
|
+
};
|
|
76
|
+
at: string;
|
|
77
|
+
kind: "task_completed" | "task_started" | "task_reopened" | "task_changed" | "habit_check_in" | "note_changed";
|
|
78
|
+
available: boolean;
|
|
79
|
+
}[];
|
|
80
|
+
priorChecks: {
|
|
81
|
+
key: string;
|
|
82
|
+
cadence: "daily" | "weekly" | "monthly" | "yearly";
|
|
83
|
+
start: string;
|
|
84
|
+
end: string;
|
|
85
|
+
signal: "unknown" | "moving" | "quiet";
|
|
86
|
+
summary: string;
|
|
87
|
+
timeframe: {
|
|
88
|
+
start: string;
|
|
89
|
+
end: string;
|
|
90
|
+
precision: "custom" | "year" | "month" | "quarter";
|
|
91
|
+
timeZone: string;
|
|
92
|
+
};
|
|
93
|
+
}[];
|
|
94
|
+
complete: boolean;
|
|
95
|
+
coverage: {
|
|
96
|
+
sources: {
|
|
97
|
+
provided: number;
|
|
98
|
+
total: number;
|
|
99
|
+
};
|
|
100
|
+
evidence: {
|
|
101
|
+
provided: number;
|
|
102
|
+
total: number;
|
|
103
|
+
};
|
|
104
|
+
priorChecks: {
|
|
105
|
+
provided: number;
|
|
106
|
+
total: number;
|
|
107
|
+
};
|
|
108
|
+
notes: {
|
|
109
|
+
provided: number;
|
|
110
|
+
total: number;
|
|
111
|
+
};
|
|
112
|
+
descriptionsAreExcerpts: boolean;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=assessment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment.d.ts","sourceRoot":"","sources":["../../src/goals/assessment.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAc1B,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC,CAAC;IAC7D,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8EA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { goalReferenceKey, } from '@lucidity/shared';
|
|
2
|
+
function bounded(items, characters, count) {
|
|
3
|
+
const result = [];
|
|
4
|
+
let used = 2;
|
|
5
|
+
for (const item of items) {
|
|
6
|
+
const size = JSON.stringify(item).length + 1;
|
|
7
|
+
if (result.length >= count || used + size > characters)
|
|
8
|
+
break;
|
|
9
|
+
result.push(item);
|
|
10
|
+
used += size;
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
/** Keep stored evidence intact; send a bounded, explicitly partial view to the model. */
|
|
15
|
+
export function goalAssessmentInput(input) {
|
|
16
|
+
const { detail, period, complete } = input;
|
|
17
|
+
const direct = new Set(detail.links
|
|
18
|
+
.filter((link) => link.state === 'active')
|
|
19
|
+
.map(goalReferenceKey));
|
|
20
|
+
const dated = new Set(input.evidence.map((item) => goalReferenceKey(item.reference)));
|
|
21
|
+
const priority = (source) => direct.has(goalReferenceKey(source))
|
|
22
|
+
? 0
|
|
23
|
+
: dated.has(goalReferenceKey(source))
|
|
24
|
+
? 1
|
|
25
|
+
: 2;
|
|
26
|
+
const sources = bounded([...input.sources]
|
|
27
|
+
.sort((a, b) => priority(a) - priority(b) ||
|
|
28
|
+
(b.updatedAt ?? '').localeCompare(a.updatedAt ?? ''))
|
|
29
|
+
.map((source) => ({
|
|
30
|
+
...source,
|
|
31
|
+
title: source.title.slice(0, 240),
|
|
32
|
+
description: source.description?.slice(0, 600) ?? null,
|
|
33
|
+
})), 30_000, 100);
|
|
34
|
+
const evidence = bounded([...input.evidence]
|
|
35
|
+
.sort((a, b) => b.at.localeCompare(a.at))
|
|
36
|
+
.map((item) => ({ ...item, title: item.title?.slice(0, 240) ?? null })), 15_000, 100);
|
|
37
|
+
const priorChecks = bounded(detail.checks.slice(0, 14).map((check) => ({
|
|
38
|
+
key: check.key,
|
|
39
|
+
cadence: check.cadence,
|
|
40
|
+
start: check.start,
|
|
41
|
+
end: check.end,
|
|
42
|
+
signal: check.signal,
|
|
43
|
+
summary: check.summary.slice(0, 400),
|
|
44
|
+
timeframe: check.timeframe,
|
|
45
|
+
})), 6_000, 14);
|
|
46
|
+
const allNotes = detail.links.filter((link) => link.kind === 'note' && link.state === 'active');
|
|
47
|
+
const notes = bounded(allNotes.map(({ kind, id }) => ({ kind, id })), 3_000, 40);
|
|
48
|
+
return {
|
|
49
|
+
goal: detail.goal,
|
|
50
|
+
period,
|
|
51
|
+
sources,
|
|
52
|
+
notes,
|
|
53
|
+
evidence,
|
|
54
|
+
priorChecks,
|
|
55
|
+
complete,
|
|
56
|
+
coverage: {
|
|
57
|
+
sources: { provided: sources.length, total: input.sources.length },
|
|
58
|
+
evidence: { provided: evidence.length, total: input.evidence.length },
|
|
59
|
+
priorChecks: {
|
|
60
|
+
provided: priorChecks.length,
|
|
61
|
+
total: detail.checks.length,
|
|
62
|
+
},
|
|
63
|
+
notes: { provided: notes.length, total: allNotes.length },
|
|
64
|
+
descriptionsAreExcerpts: true,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type GoalCandidate } from '@lucidity/shared';
|
|
2
|
+
export interface GoalNote extends GoalCandidate {
|
|
3
|
+
kind: 'note';
|
|
4
|
+
path: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export interface GoalNotes {
|
|
8
|
+
list(): {
|
|
9
|
+
notes: GoalNote[];
|
|
10
|
+
complete: boolean;
|
|
11
|
+
};
|
|
12
|
+
link(note: GoalNote): void;
|
|
13
|
+
read(id: string): GoalNote;
|
|
14
|
+
saveDraft(id: string, markdown: string): void;
|
|
15
|
+
}
|
|
16
|
+
/** Paths and note text never leave this computer for the hosted Goals API. */
|
|
17
|
+
export declare function createGoalNotes(root: string | undefined): GoalNotes | undefined;
|
|
18
|
+
//# sourceMappingURL=notes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.d.ts","sourceRoot":"","sources":["../../src/goals/notes.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,SAAS;IACxB,IAAI,IAAI;QAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACjD,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/C;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,SAAS,GAAG,SAAS,CAgEvB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { listNotes, readNote, editNote, writeNote } from '@lucidity/notes';
|
|
3
|
+
import { goalNoteId, withGoalNoteId, } from '@lucidity/shared';
|
|
4
|
+
/** Paths and note text never leave this computer for the hosted Goals API. */
|
|
5
|
+
export function createGoalNotes(root) {
|
|
6
|
+
if (!root)
|
|
7
|
+
return undefined;
|
|
8
|
+
function scan() {
|
|
9
|
+
const summaries = listNotes(root, { limit: 2001 });
|
|
10
|
+
const notes = [];
|
|
11
|
+
let complete = summaries.length <= 2000;
|
|
12
|
+
for (const summary of summaries.slice(0, 2000)) {
|
|
13
|
+
try {
|
|
14
|
+
const note = readNote(root, summary.path);
|
|
15
|
+
notes.push({
|
|
16
|
+
kind: 'note',
|
|
17
|
+
id: goalNoteId(note.content) ?? randomUUID(),
|
|
18
|
+
path: note.path,
|
|
19
|
+
content: note.content,
|
|
20
|
+
title: note.title,
|
|
21
|
+
description: note.body.slice(0, 2000),
|
|
22
|
+
updatedAt: note.mtime,
|
|
23
|
+
status: null,
|
|
24
|
+
projectId: null,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
complete = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const counts = new Map();
|
|
32
|
+
notes.forEach((note) => counts.set(note.id, (counts.get(note.id) ?? 0) + 1));
|
|
33
|
+
if ([...counts.values()].some((count) => count > 1))
|
|
34
|
+
complete = false;
|
|
35
|
+
return {
|
|
36
|
+
notes: notes.filter((note) => counts.get(note.id) === 1),
|
|
37
|
+
complete,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
list: scan,
|
|
42
|
+
link(note) {
|
|
43
|
+
const current = readNote(root, note.path);
|
|
44
|
+
if (current.content !== note.content)
|
|
45
|
+
throw new Error('The note changed during linking. Try again.');
|
|
46
|
+
const next = withGoalNoteId(current.content, note.id);
|
|
47
|
+
if (next !== current.content) {
|
|
48
|
+
if (!current.content)
|
|
49
|
+
throw new Error('Write something in this note before linking it.');
|
|
50
|
+
editNote(root, note.path, current.content, next);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
read(id) {
|
|
54
|
+
const note = scan().notes.find((item) => goalNoteId(item.content) === id);
|
|
55
|
+
if (!note)
|
|
56
|
+
throw new Error('The linked note is not available in this vault.');
|
|
57
|
+
return note;
|
|
58
|
+
},
|
|
59
|
+
saveDraft(id, markdown) {
|
|
60
|
+
const content = withGoalNoteId(markdown, id);
|
|
61
|
+
const path = `Goals/Draft-${id}.md`;
|
|
62
|
+
try {
|
|
63
|
+
writeNote(root, path, content, 'create');
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// Idempotent retry of our own exact output; never overwrite a user's edits.
|
|
67
|
+
if (readNote(root, path).content !== content)
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|