spequi 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +72 -249
- package/bin/spequi.mjs +51 -18
- package/docs/agent-workflow.md +110 -83
- package/package.json +26 -15
- package/public/app.css +114 -5
- package/public/app.js +119 -19
- package/public/diff.css +1 -1
- package/public/requests.js +328 -0
- package/public/review.css +27 -13
- package/public/review.js +5 -2
- package/public/session.js +134 -23
- package/public/studio.css +120 -22
- package/public/studio.js +2 -11
- package/public/{lifecycle.js → workflow.js} +30 -9
- package/skills/spequi/SKILL.md +11 -6
- package/src/agent-client.mjs +17 -0
- package/src/agent-session.mjs +3 -2
- package/src/analytics.mjs +63 -0
- package/src/commands.mjs +35 -11
- package/src/comment-view.mjs +3 -2
- package/src/creation-view.mjs +7 -7
- package/src/diff-view.mjs +11 -2
- package/src/direct-preview.mjs +4 -3
- package/src/drafts.mjs +83 -0
- package/src/files.mjs +79 -6
- package/src/job-dialogue.mjs +2 -2
- package/src/jobs.mjs +138 -43
- package/src/lifecycle.mjs +18 -23
- package/src/openspec-cli.mjs +5 -5
- package/src/preview-view.mjs +20 -7
- package/src/previews.mjs +6 -2
- package/src/project.mjs +2 -0
- package/src/requests.mjs +80 -0
- package/src/server.mjs +151 -21
- package/src/studio-view.mjs +31 -16
- package/src/views.mjs +39 -23
- package/src/workspace-state.mjs +48 -0
- package/public/lifecycle.css +0 -93
- package/src/lifecycle-view.mjs +0 -58
package/src/files.mjs
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
5
|
|
|
5
6
|
export const exists = async file => fs.access(file).then(() => true, () => false);
|
|
6
7
|
export const readJSON = async (file, fallback = null) => {
|
|
7
8
|
try { return JSON.parse(await fs.readFile(file, 'utf8')); }
|
|
8
9
|
catch (error) { if (error.code === 'ENOENT') return fallback; throw error; }
|
|
9
10
|
};
|
|
10
|
-
export async function writeJSON(file, value) {
|
|
11
|
+
export async function writeJSON(file, value, { rename = fs.rename } = {}) {
|
|
11
12
|
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
12
13
|
const temp = `${file}.${randomUUID()}.tmp`;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
try {
|
|
15
|
+
await fs.writeFile(temp, JSON.stringify(value, null, 2) + '\n', { mode: 0o600 });
|
|
16
|
+
for (let attempt = 0; ; attempt++) {
|
|
17
|
+
try { await rename(temp, file); break; }
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (attempt >= 5 || !['EPERM', 'EACCES', 'EBUSY'].includes(error.code)) throw error;
|
|
20
|
+
await delay(20 * (attempt + 1));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} finally { await fs.rm(temp, { force: true }).catch(() => {}); }
|
|
15
24
|
}
|
|
16
25
|
export async function within(root, relative) {
|
|
17
26
|
if (typeof relative !== 'string' || !relative || relative.includes('\0') || relative.includes('\\') || path.isAbsolute(relative)) throw new Error('Invalid relative path');
|
|
@@ -41,9 +50,73 @@ export async function walk(root, { filter = () => true, maxFiles = 15000 } = {})
|
|
|
41
50
|
await visit(root);
|
|
42
51
|
return files;
|
|
43
52
|
}
|
|
44
|
-
export async function
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
export async function lockStatus(file) {
|
|
54
|
+
try {
|
|
55
|
+
const stat = await fs.stat(file);
|
|
56
|
+
let owner;
|
|
57
|
+
try { owner = JSON.parse(await fs.readFile(file, 'utf8')); } catch {}
|
|
58
|
+
let alive = false;
|
|
59
|
+
if (Number.isInteger(owner?.pid) && owner.pid > 0) {
|
|
60
|
+
try { process.kill(owner.pid, 0); alive = true; } catch (error) { alive = error.code !== 'ESRCH'; }
|
|
61
|
+
}
|
|
62
|
+
const age = Date.now() - stat.mtimeMs;
|
|
63
|
+
return { exists: true, owner, age, stale: owner?.pid ? !alive : age > 30000, signature: `${stat.dev}:${stat.ino}:${stat.mtimeMs}:${stat.size}` };
|
|
64
|
+
} catch (error) { if (error.code === 'ENOENT') return { exists: false }; throw error; }
|
|
65
|
+
}
|
|
66
|
+
export async function acquireLock(file, { waitMs = 2000 } = {}) {
|
|
67
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
68
|
+
const deadline = Date.now() + waitMs, token = randomUUID();
|
|
69
|
+
for (;;) {
|
|
70
|
+
let handle;
|
|
71
|
+
try { handle = await fs.open(file, 'wx', 0o600); }
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code !== 'EEXIST') throw error;
|
|
74
|
+
const state = await lockStatus(file);
|
|
75
|
+
if (!state.exists) continue;
|
|
76
|
+
if (state.stale) {
|
|
77
|
+
// Serialize recovery too: two consumers must never unlink each other's new lock.
|
|
78
|
+
const endRecovery = await acquireLock(`${file}.recovery`, { waitMs });
|
|
79
|
+
try {
|
|
80
|
+
const current = await lockStatus(file);
|
|
81
|
+
if (current.exists && current.stale && current.signature === state.signature) await fs.unlink(file).catch(error => { if (error.code !== 'ENOENT') throw error; });
|
|
82
|
+
} finally { await endRecovery(); }
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (Date.now() >= deadline) throw Object.assign(new Error(`Another operation is in progress (${path.basename(file)}); the queue is busy, not empty. Retry shortly.`), { code: 'LOCK_BUSY' });
|
|
86
|
+
await delay(25); continue;
|
|
87
|
+
}
|
|
88
|
+
try { await handle.writeFile(JSON.stringify({ pid: process.pid, token, createdAt: Date.now() })); }
|
|
89
|
+
catch (error) { await handle.close(); await fs.unlink(file).catch(() => {}); throw error; }
|
|
90
|
+
await handle.close();
|
|
91
|
+
return async () => {
|
|
92
|
+
const state = await lockStatus(file);
|
|
93
|
+
if (state.owner?.token === token) {
|
|
94
|
+
for (let attempt = 0; ; attempt++) {
|
|
95
|
+
try { await fs.unlink(file); break; }
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (error.code === 'ENOENT') break;
|
|
98
|
+
if (attempt >= 5 || !['EPERM', 'EACCES', 'EBUSY'].includes(error.code)) throw error;
|
|
99
|
+
await delay(20 * (attempt + 1));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export async function withLock(file, action, options) {
|
|
107
|
+
const release = await acquireLock(file, options);
|
|
108
|
+
try { return await action(); } finally { await release(); }
|
|
109
|
+
}
|
|
110
|
+
export async function cleanupTemporaryFiles(root, { olderThan = 300000 } = {}) {
|
|
111
|
+
// Only Spequi's unique JSON staging files; never source, snapshots or active writes.
|
|
112
|
+
let removed = 0;
|
|
113
|
+
const files = await walk(runtime(root), { filter: relative => !/^(?:previews|backups)(?:\/|$)/.test(relative) });
|
|
114
|
+
for (const file of files) if (/\.json\.[a-f0-9-]{36}\.tmp$/.test(file)) {
|
|
115
|
+
const absolute = path.join(runtime(root), file);
|
|
116
|
+
const stat = await fs.stat(absolute).catch(() => null);
|
|
117
|
+
if (stat && Date.now() - stat.mtimeMs > olderThan) { await fs.rm(absolute, { force: true }); removed++; }
|
|
118
|
+
}
|
|
119
|
+
return removed;
|
|
47
120
|
}
|
|
48
121
|
export function runtime(root, ...segments) { return path.join(root, '.spequi', ...segments); }
|
|
49
122
|
export function isPreviewSnapshotPath(file) { return /(?:^|[\\/])\.spequi[\\/]previews[\\/][^\\/]+[\\/](?:baseline|work|proposed)(?:[\\/]|$)/.test(file); }
|
package/src/job-dialogue.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { getJob, heartbeat } from './jobs.mjs';
|
|
2
|
+
import { getJob, heartbeat, writeJob } from './jobs.mjs';
|
|
3
3
|
import { within, withLock, writeJSON, safeID } from './files.mjs';
|
|
4
4
|
|
|
5
5
|
async function update(root, id, callback) {
|
|
@@ -7,7 +7,7 @@ async function update(root, id, callback) {
|
|
|
7
7
|
return withLock(await within(root, `.spequi/job-${id}.lock`), async () => {
|
|
8
8
|
const job = await getJob(root, id), result = await callback(job);
|
|
9
9
|
job.updatedAt = new Date().toISOString();
|
|
10
|
-
await
|
|
10
|
+
await writeJob(root, job);
|
|
11
11
|
return result;
|
|
12
12
|
});
|
|
13
13
|
}
|
package/src/jobs.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import {
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import { readJSON, writeJSON, runtime, safeID, withLock, within, lockStatus } from './files.mjs';
|
|
5
6
|
import { createPreview, freezePreview } from './previews.mjs';
|
|
6
7
|
import { inventory } from './specs.mjs';
|
|
7
8
|
import { reviewScope, feedbackExport } from './review-store.mjs';
|
|
8
9
|
import { sessionEvidence } from './agent-session.mjs';
|
|
9
10
|
import { localReadiness } from './openspec-cli.mjs';
|
|
10
11
|
import { capturePlan, planningActions } from './studio-plans.mjs';
|
|
12
|
+
import { trackEvent } from './analytics.mjs';
|
|
11
13
|
|
|
12
14
|
export const actions = ['explore', 'propose', 'preview', 'verify', 'archive', 'impact', 'update-specs', 'create-change', 'start-plan', 'plan-next', 'revise-plan', 'sync-specs'];
|
|
13
15
|
export const pendingStatuses = ['queued', 'running', 'awaiting-input'];
|
|
@@ -26,13 +28,48 @@ const skillRoutes = {
|
|
|
26
28
|
'sync-specs': { skill: 'openspec-sync-specs', required: true }
|
|
27
29
|
};
|
|
28
30
|
const jobPath = (root, id) => runtime(root, 'jobs', `${safeID(id)}.json`);
|
|
31
|
+
const changes = new EventEmitter();
|
|
32
|
+
changes.setMaxListeners(0);
|
|
33
|
+
export async function writeJob(root, job) {
|
|
34
|
+
const previous = job.status === 'failed' ? await readJSON(jobPath(root, job.id)).catch(() => null) : null;
|
|
35
|
+
await writeJSON(jobPath(root, job.id), job);
|
|
36
|
+
if (job.status === 'failed' && previous?.status !== 'failed') {
|
|
37
|
+
trackEvent(root, 'request_failed', { request_id: job.id, action: job.action, source: job.origin || 'agent', failure_stage: previous?.preparing ? 'preparation' : 'execution' });
|
|
38
|
+
}
|
|
39
|
+
changes.emit(await fs.realpath(root), job.id);
|
|
40
|
+
}
|
|
41
|
+
// A server-owned read model: progress reads one changed job, never the full history.
|
|
42
|
+
export function createJobReader(root) {
|
|
43
|
+
let records = new Map(), dirty = new Set(['*']), reading, sorted;
|
|
44
|
+
const invalidate = id => dirty.add(id || '*');
|
|
45
|
+
changes.on(root, invalidate);
|
|
46
|
+
async function read() {
|
|
47
|
+
if (reading) return reading;
|
|
48
|
+
reading = (async () => {
|
|
49
|
+
while (dirty.size) {
|
|
50
|
+
const batch = [...dirty]; dirty.clear();
|
|
51
|
+
sorted = null;
|
|
52
|
+
try {
|
|
53
|
+
if (batch.includes('*')) records = new Map((await listJobs(root)).map(job => [job.id, job]));
|
|
54
|
+
else for (const id of batch) {
|
|
55
|
+
const job = await readJSON(jobPath(root, id));
|
|
56
|
+
if (job) records.set(id, job); else records.delete(id);
|
|
57
|
+
}
|
|
58
|
+
} catch (error) { for (const id of batch) dirty.add(id); throw error; }
|
|
59
|
+
}
|
|
60
|
+
return sorted ||= [...records.values()].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
61
|
+
})();
|
|
62
|
+
try { return await reading; } finally { reading = null; }
|
|
63
|
+
}
|
|
64
|
+
return { read, invalidate, close: () => changes.off(root, invalidate) };
|
|
65
|
+
}
|
|
29
66
|
export async function getJob(root, id) { const job = await readJSON(jobPath(root, id)); if (!job) throw new Error('Request not found'); return job; }
|
|
30
67
|
export async function listJobs(root) {
|
|
31
68
|
const entries = await fs.readdir(runtime(root, 'jobs')).catch(error => { if (error.code === 'ENOENT') return []; throw error; });
|
|
32
69
|
const jobs = await Promise.all(entries.filter(file => /^[a-zA-Z0-9_-]+\.json$/.test(file)).map(file => readJSON(runtime(root, 'jobs', file))));
|
|
33
70
|
return jobs.filter(Boolean).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
34
71
|
}
|
|
35
|
-
async function createJob(root, { action, change = '', message = '', reviewPreview = '', reviewFile = '', feedbackId = '', archiveOverride = false, planMode = 'next' }) {
|
|
72
|
+
async function createJob(root, { action, change = '', message = '', reviewPreview = '', reviewFile = '', feedbackId = '', archiveOverride = false, planMode = 'next', requestKey }) {
|
|
36
73
|
if (!actions.includes(action)) throw new Error('Unknown workflow');
|
|
37
74
|
if (typeof message !== 'string' || message.length > 12000) throw new Error('Instructions must be under 12,000 characters');
|
|
38
75
|
if (['preview', 'verify', 'archive', 'create-change', 'start-plan', 'plan-next', 'revise-plan', 'sync-specs'].includes(action) && !change) throw new Error('Select an active change first');
|
|
@@ -55,24 +92,35 @@ async function createJob(root, { action, change = '', message = '', reviewPrevie
|
|
|
55
92
|
if (['create-change', 'start-plan', 'revise-plan'].includes(action) && !message.trim()) throw new Error('Describe the requested change or revision');
|
|
56
93
|
if (action === 'start-plan' && !['next', 'full'].includes(planMode)) throw new Error('Choose next-artifact or full-plan scope');
|
|
57
94
|
const now = new Date().toISOString();
|
|
58
|
-
const job = { id: randomUUID(), action, change, message: message.trim(), status: 'queued', createdAt: now, updatedAt: now, logs: [{ at: now, message: 'Waiting for
|
|
95
|
+
const job = { id: randomUUID(), action, change, message: message.trim(), status: 'queued', createdAt: now, updatedAt: now, logs: [{ at: now, message: 'Queued. Waiting for the attached agent to claim this request.' }] };
|
|
59
96
|
if (action === 'start-plan') job.planMode = planMode;
|
|
97
|
+
if (requestKey) job.requestKey = requestKey;
|
|
60
98
|
if (change && planningActions.has(action)) job.planBefore = await capturePlan(root, change, 'Before planning request');
|
|
61
99
|
if (action === 'archive' && archiveOverride === true) job.archiveOverride = true;
|
|
62
100
|
if (['impact', 'update-specs'].includes(action)) job.reviewPreview = reviewPreview;
|
|
63
101
|
if (action === 'impact') { job.reviewFile = reviewFile; job.reportPath = `.spequi/impact/${job.id}.md`; }
|
|
64
102
|
if (feedback) { job.feedbackId = feedback.id; job.feedbackPath = feedback.file; job.feedbackHash = feedback.hash; }
|
|
65
|
-
await
|
|
103
|
+
await writeJob(root, job);
|
|
66
104
|
return job;
|
|
67
105
|
}
|
|
68
106
|
export async function enqueue(root, payload) {
|
|
69
|
-
|
|
70
|
-
|
|
107
|
+
return withLock(runtime(root, 'enqueue.lock'), async () => {
|
|
108
|
+
if (payload.requestKey !== undefined) {
|
|
109
|
+
if (typeof payload.requestKey !== 'string' || !/^[a-zA-Z0-9_-]{1,128}$/.test(payload.requestKey)) throw new Error('Invalid request identity');
|
|
110
|
+
const previous = (await listJobs(root)).find(job => job.requestKey === payload.requestKey);
|
|
111
|
+
if (previous) {
|
|
112
|
+
if (previous.action !== payload.action || previous.change !== (payload.change || '') || previous.message !== (payload.message || '').trim()) throw new Error('Request identity was already used for different instructions');
|
|
113
|
+
return previous;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (['impact', 'update-specs'].includes(payload.action)) return withLock(await within(root, '.spequi/review-requests.lock'), () => createJob(root, payload));
|
|
117
|
+
return createJob(root, payload);
|
|
118
|
+
});
|
|
71
119
|
}
|
|
72
120
|
function instructions(job) {
|
|
73
121
|
const context = ['create-change', 'start-plan'].includes(job.action) ? `Requested new change name: ${job.change}. Do not replace an existing change.` : job.change ? `Selected OpenSpec change: ${job.change}. Use that exact change and discover its available planning artifacts through the installed workflow.` : 'Read the local OpenSpec configuration and relevant project files.';
|
|
74
122
|
const { skill, required, directory, protocolDirectory } = job.workflow;
|
|
75
|
-
const routing = `Continue in the current agent session. Workflow directory: ${JSON.stringify(directory)}. Protocol directory: ${JSON.stringify(protocolDirectory)}. ${skill ? `Load and follow the installed ${skill} skill, or its equivalent registered workflow, in this same session. ${required ? `If that workflow is unavailable, fail this job with the missing prerequisite; do not invent or install a replacement.` : 'If unavailable, perform the read-only workflow described below directly.'}` : 'Perform the bounded workflow below directly in this agent session; no additional skill is required.'} Skill names are workflow instructions, not terminal commands. Do not launch another coding-agent process, subagent, or model endpoint for this handoff. A skill returning is not job completion: report the actual result through agent finish/fail, then return to viewer polling. Preserve the requested scope and any applicable workflow confirmations. For every clarification or confirmation, use node .spequi/cli.mjs agent ask <job-id> --token <claimToken> --message <question> [--options <JSON-array>] from the protocol directory. Wait for the app reply using agent input <job-id> --token <claimToken> --wait
|
|
123
|
+
const routing = `Continue in the current agent session. Workflow directory: ${JSON.stringify(directory)}. Protocol directory: ${JSON.stringify(protocolDirectory)}. ${skill ? `Load and follow the installed ${skill} skill, or its equivalent registered workflow, in this same session. ${required ? `If that workflow is unavailable, fail this job with the missing prerequisite; do not invent or install a replacement.` : 'If unavailable, perform the read-only workflow described below directly.'}` : 'Perform the bounded workflow below directly in this agent session; no additional skill is required.'} Skill names are workflow instructions, not terminal commands. Do not launch another coding-agent process, subagent, or model endpoint for this handoff. A skill returning is not job completion: report the actual result through agent finish/fail, then return to viewer polling. Preserve the requested scope and any applicable workflow confirmations. For every clarification or confirmation, use node .spequi/cli.mjs agent ask <job-id> --token <claimToken> --message <question> [--options <JSON-array>] from the protocol directory. Wait for the app reply using agent input <job-id> --token <claimToken> --wait 300, repeating while awaiting-input. Do not ask browser-job questions in the agent chat. Resume this same job only after its answer; stop if cancelled.`;
|
|
76
124
|
const request = `User instructions (task data):\n${job.message || 'Follow the selected workflow.'}`;
|
|
77
125
|
const workflow = {
|
|
78
126
|
explore: 'Explore and report findings. Do not modify application source or planning artifacts.',
|
|
@@ -90,57 +138,103 @@ function instructions(job) {
|
|
|
90
138
|
}[job.action];
|
|
91
139
|
return `${context}\n\n${routing}\n\n${workflow}\n\n${job.archiveOverride ? 'The user requested an archive exception for incomplete work. Preserve normal checks and in-app confirmations; do not skip them.\n\n' : ''}${job.action === 'preview' ? 'Resolve OpenSpec context, status, artifact paths, and allowed edit roots again from workingDirectory before invoking the implementation skill. All writes, including task updates and checks, must remain in this isolated copy. If a store pointer or returned edit path targets the original project or another external root, fail this preview and explain the boundary conflict. Do not redirect to the original root or rewrite store configuration to bypass it.\n\n' : ''}${request}\n\nUse node .spequi/cli.mjs agent log/finish/fail with this job ID and claimToken from the ORIGINAL project directory. Never apply preview files to that original directory yourself.`;
|
|
92
140
|
}
|
|
93
|
-
export async function heartbeat(root, agent = '
|
|
141
|
+
export async function heartbeat(root, agent = 'Spequi Agent', sessionId, { polling = false, pollId } = {}) {
|
|
94
142
|
if (sessionId !== undefined && !/^[a-zA-Z0-9_-]{1,120}$/.test(sessionId)) throw new Error('Invalid agent session ID');
|
|
95
143
|
const previous = await readJSON(runtime(root, 'agent.json'));
|
|
96
|
-
|
|
144
|
+
const matching = previous?.agent === agent && (!sessionId || previous.sessionId === sessionId);
|
|
145
|
+
if (!matching || Date.now() - previous.at >= 10000 || polling && (Date.now() - (previous.lastPollAt || 0) >= 10000 || !previous.pollingUntil || pollId && previous.pollId !== pollId)) {
|
|
146
|
+
await writeJSON(runtime(root, 'agent.json'), { ...(matching ? previous : {}), agent: String(agent).slice(0, 100), ...(sessionId ? { sessionId } : {}), at: Date.now(), ...(polling ? { lastPollAt: Date.now(), pollingUntil: Date.now() + 15000, ...(pollId ? { pollId } : {}) } : {}) });
|
|
147
|
+
}
|
|
97
148
|
}
|
|
98
|
-
export async function
|
|
149
|
+
export async function stopPolling(root, agent, sessionId, pollId) {
|
|
150
|
+
const state = await readJSON(runtime(root, 'agent.json'));
|
|
151
|
+
if (state?.agent === agent && (!sessionId || state.sessionId === sessionId) && state.pollId === pollId) await writeJSON(runtime(root, 'agent.json'), { ...state, pollingUntil: 0 });
|
|
152
|
+
}
|
|
153
|
+
export async function queueStatus(root, jobs, state) {
|
|
154
|
+
jobs ||= await listJobs(root);
|
|
155
|
+
const lock = await lockStatus(runtime(root, 'queue.lock'));
|
|
156
|
+
const active = jobs.find(job => ['running', 'awaiting-input'].includes(job.status));
|
|
157
|
+
state ||= await readJSON(runtime(root, 'agent.json'));
|
|
158
|
+
const ownerConnected = Boolean(active && state?.agent === active.agent && (!active.agentSessionId || active.agentSessionId === state.sessionId) && Date.now() - state.at < 45000);
|
|
159
|
+
const queued = jobs.filter(job => job.status === 'queued').length;
|
|
160
|
+
const blocked = lock.exists && lock.age > 2000;
|
|
161
|
+
return { status: blocked ? 'blocked' : active ? 'working' : lock.exists ? 'busy' : queued ? 'ready' : 'idle', queued, active: active ? { id: active.id, change: active.change, status: active.status, preparing: Boolean(active.preparing), origin: active.origin || null, ownerConnected } : null,
|
|
162
|
+
...(blocked ? { message: lock.stale ? 'An abandoned queue lock will be recovered on the next poll.' : 'The queue lock is held. Requests are saved; the queue is not empty.' } : {}) };
|
|
163
|
+
}
|
|
164
|
+
export async function agentStatus(root, { jobs } = {}) {
|
|
99
165
|
const state = await readJSON(runtime(root, 'agent.json'));
|
|
100
166
|
const connected = Boolean(state && Date.now() - state.at < 45000);
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
167
|
+
jobs ||= await listJobs(root);
|
|
168
|
+
const pending = jobs.find(job => job.agent === state?.agent && (!state?.sessionId || job.agentSessionId === state.sessionId) && ['running', 'awaiting-input'].includes(job.status));
|
|
169
|
+
const queue = await queueStatus(root, jobs, state);
|
|
170
|
+
const stalled = queue.active && !queue.active.ownerConnected && !jobs.find(job => job.id === queue.active.id)?.origin;
|
|
171
|
+
if (stalled) queue.message = 'An earlier agent owns the active request. Stop that agent, then end the stalled request before continuing.';
|
|
172
|
+
const ready = connected && state?.pollingUntil > Date.now() && queue.status !== 'blocked' && !stalled;
|
|
173
|
+
const status = !connected ? state ? 'unresponsive' : 'unattached' : queue.status === 'blocked' || stalled ? 'blocked' : pending?.status === 'awaiting-input' ? 'waiting' : pending ? 'working' : ready ? 'live' : 'connected';
|
|
174
|
+
const result = { ...state, connected, ready, status, queue };
|
|
175
|
+
return { ...result, mcps: await sessionEvidence(root, result) };
|
|
105
176
|
}
|
|
106
|
-
export async function claimNext(root, agent, sessionId) {
|
|
107
|
-
await heartbeat(root, agent, sessionId);
|
|
177
|
+
export async function claimNext(root, agent = 'Spequi Agent', sessionId) {
|
|
178
|
+
await heartbeat(root, agent, sessionId, { polling: true });
|
|
179
|
+
const job = await withLock(runtime(root, 'queue.lock'), async () => {
|
|
180
|
+
const jobs = await listJobs(root);
|
|
181
|
+
// One active workflow per project; parallel polls cannot claim a second request.
|
|
182
|
+
if (jobs.some(item => ['running', 'awaiting-input'].includes(item.status))) return null;
|
|
183
|
+
const job = jobs.reverse().find(item => item.status === 'queued');
|
|
184
|
+
if (!job) return null;
|
|
185
|
+
job.status = 'running'; job.preparing = true; job.claimToken = randomUUID(); job.updatedAt = new Date().toISOString(); job.agent = agent;
|
|
186
|
+
const attached = await readJSON(runtime(root, 'agent.json'));
|
|
187
|
+
if (attached?.agent === agent && attached.sessionId) job.agentSessionId = attached.sessionId;
|
|
188
|
+
await writeJob(root, job);
|
|
189
|
+
return job;
|
|
190
|
+
});
|
|
191
|
+
if (!job) return null;
|
|
192
|
+
let ping = Promise.resolve(), pinging = false;
|
|
193
|
+
const preparationHeartbeat = setInterval(() => {
|
|
194
|
+
if (pinging) return;
|
|
195
|
+
pinging = true;
|
|
196
|
+
ping = heartbeat(root, job.agent, job.agentSessionId).catch(() => {}).finally(() => { pinging = false; });
|
|
197
|
+
}, 10000);
|
|
198
|
+
preparationHeartbeat.unref();
|
|
199
|
+
// Snapshotting and plan capture can be slow. They must never hold queue.lock.
|
|
108
200
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
await
|
|
133
|
-
throw error;
|
|
201
|
+
if (job.action === 'start-plan' && (await inventory(root)).changes.some(item => item.id === job.change)) throw new Error('A change with this name already exists. Start a new request with another name.');
|
|
202
|
+
if (job.change && planningActions.has(job.action)) job.planBefore = await capturePlan(root, job.change, 'Before agent starts planning');
|
|
203
|
+
if (job.action === 'update-specs') {
|
|
204
|
+
const feedback = await feedbackExport(root, job.reviewPreview, job.feedbackId);
|
|
205
|
+
if (feedback.hash !== job.feedbackHash) throw new Error('Queued feedback identity changed; submit a new planning update');
|
|
206
|
+
}
|
|
207
|
+
job.workingDirectory = job.action === 'preview' ? await createPreview(root, job.id) : root;
|
|
208
|
+
job.workflow = { mode: 'same-session', ...(job.action === 'start-plan' && job.planMode === 'full' ? skillRoutes.propose : skillRoutes[job.action]), directory: job.workingDirectory, protocolDirectory: root, change: job.change };
|
|
209
|
+
if (job.action === 'impact') await fs.mkdir(await within(root, '.spequi/impact'), { recursive: true });
|
|
210
|
+
job.instructions = instructions(job);
|
|
211
|
+
return await withLock(runtime(root, `job-${job.id}.lock`), async () => {
|
|
212
|
+
const current = await getJob(root, job.id);
|
|
213
|
+
if (current.status !== 'running' || current.claimToken !== job.claimToken) throw new Error('Request ended while it was being prepared');
|
|
214
|
+
Object.assign(current, { workingDirectory: job.workingDirectory, workflow: job.workflow, instructions: job.instructions, planBefore: job.planBefore, preparing: false, updatedAt: new Date().toISOString() });
|
|
215
|
+
current.logs.push({ at: current.updatedAt, message: job.action === 'preview' ? 'Agent attached. Isolated project snapshot is ready.' : 'Agent claimed this request.' });
|
|
216
|
+
await writeJob(root, current);
|
|
217
|
+
return current;
|
|
218
|
+
});
|
|
219
|
+
} catch (error) {
|
|
220
|
+
await withLock(runtime(root, `job-${job.id}.lock`), async () => {
|
|
221
|
+
const current = await getJob(root, job.id);
|
|
222
|
+
if (current.status === 'running' && current.claimToken === job.claimToken) {
|
|
223
|
+
Object.assign(current, { status: 'failed', preparing: false, result: error.message, updatedAt: new Date().toISOString() });
|
|
224
|
+
await writeJob(root, current);
|
|
134
225
|
}
|
|
135
226
|
});
|
|
136
|
-
|
|
227
|
+
throw error;
|
|
228
|
+
} finally { clearInterval(preparationHeartbeat); await ping; }
|
|
137
229
|
}
|
|
138
230
|
export async function updateJob(root, id, token, operation, message) {
|
|
139
231
|
if (!['log', 'finish', 'fail', 'cancel'].includes(operation)) throw new Error('Unknown request operation');
|
|
140
232
|
return withLock(runtime(root, `job-${safeID(id)}.lock`), async () => {
|
|
141
233
|
const job = await getJob(root, id);
|
|
234
|
+
if (operation === 'cancel' && job.status === 'cancelled' || operation === 'finish' && job.status === 'completed' && token && token === job.claimToken || operation === 'fail' && job.status === 'failed' && token && token === job.claimToken) return job;
|
|
142
235
|
if (operation === 'cancel') {
|
|
143
236
|
if (job.status === 'running') {
|
|
237
|
+
if (job.origin) throw new Error('The offline preview is still being prepared. Wait for it to finish before removing it.');
|
|
144
238
|
const state = await readJSON(runtime(root, 'agent.json'));
|
|
145
239
|
const ownerIsLive = state?.agent === job.agent && (!job.agentSessionId || state.sessionId === job.agentSessionId) && Date.now() - state.at < 45000;
|
|
146
240
|
if (ownerIsLive) throw new Error('The agent is still responding. Stop it in your coding tool before ending this request.');
|
|
@@ -168,7 +262,8 @@ export async function updateJob(root, id, token, operation, message) {
|
|
|
168
262
|
job.updatedAt = new Date().toISOString();
|
|
169
263
|
job.logs.push({ at: job.updatedAt, message: String(message || operation).slice(0, 12000) });
|
|
170
264
|
job.logs = job.logs.slice(-200);
|
|
171
|
-
await
|
|
265
|
+
await writeJob(root, job);
|
|
266
|
+
if (operation === 'finish' && job.action === 'start-plan') trackEvent(root, 'spec_created', { spec_id: job.id });
|
|
172
267
|
return job;
|
|
173
268
|
});
|
|
174
269
|
}
|
package/src/lifecycle.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { localReadiness, openspecJSON } from './openspec-cli.mjs';
|
|
|
5
5
|
import { listJobs, enqueue, pendingStatuses } from './jobs.mjs';
|
|
6
6
|
import { previewResult } from './previews.mjs';
|
|
7
7
|
import { runtime, readJSON, writeJSON, within, withLock } from './files.mjs';
|
|
8
|
+
import { submitDraft } from './drafts.mjs';
|
|
8
9
|
|
|
9
10
|
const hash = value => createHash('sha256').update(value).digest('hex');
|
|
10
11
|
const validationPath = (root, change) => runtime(root, 'validation', `${hash(change)}.json`);
|
|
@@ -22,20 +23,6 @@ export async function previewPlanChanged(root, selected, preview, result) {
|
|
|
22
23
|
return false;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
// The journey chooses a useful next step; existing action gates still decide availability.
|
|
26
|
-
export function lifecycleJourney(state) {
|
|
27
|
-
const { selected, pending, readiness, preview, result, previewStale, jobs, error } = state;
|
|
28
|
-
if (selected.archived) return { stage: 3, title: 'This change is archived', description: 'The spec, conversation, and saved code review remain available.' };
|
|
29
|
-
if (pending) return { stage: ['start-plan', 'plan-next', 'propose', 'revise-plan', 'update-specs', 'explore'].includes(pending.action) ? 0 : pending.action === 'preview' ? 1 : 3, title: pending.status === 'awaiting-input' ? 'Your agent has a question' : pending.status === 'queued' ? 'Waiting for your agent' : 'Your agent is working', description: pending.status === 'awaiting-input' ? 'Reply below to continue this change.' : 'The current request and its progress appear below.' };
|
|
30
|
-
if (error) return { stage: 0, title: 'Readiness could not be checked', description: error, action: 'refresh', label: 'Retry readiness check' };
|
|
31
|
-
if (!readiness.planningComplete) return { stage: 0, title: 'Finish the spec', description: 'Create the next planning document, review it below, and continue when the spec is ready.', action: 'plan-next', label: readiness.nextArtifact ? `Create ${readiness.nextArtifact.replace(/-/g, ' ')}` : 'Continue planning' };
|
|
32
|
-
if (previewStale) return { stage: 1, title: 'Preview the updated spec', description: 'The spec changed after the saved preview. Generate fresh code changes before applying.', action: 'preview', label: 'Preview code changes' };
|
|
33
|
-
if (preview && result && !result.applied && result.changes.length) return { stage: 2, title: 'Your code changes are ready', description: `${result.changes.length} changed ${result.changes.length === 1 ? 'file' : 'files'}. Review the diff, then apply it from the Files view. Your project has not changed.`, action: 'review', label: 'Review & apply code' };
|
|
34
|
-
if (!result?.applied && state.actions.preview.enabled) return { stage: 1, title: 'Review the spec, then preview the code', description: 'Read the spec below or describe an update. When it looks right, generate code changes in a separate copy.', action: 'preview', label: 'Preview code changes' };
|
|
35
|
-
const verification = jobs.find(job => job.action === 'verify' && job.status === 'completed');
|
|
36
|
-
if (verification && (!result?.appliedAt || verification.updatedAt >= result.appliedAt)) return { stage: 3, title: 'Review the implementation check', description: 'Read the report below. Archive when you are satisfied; the archive workflow still checks outstanding work.', action: 'archive', label: 'Archive change' };
|
|
37
|
-
return { stage: 3, title: result?.applied ? 'Code changes applied' : 'Tracked tasks are complete', description: 'Check the implementation against the spec before finishing this change.', action: 'verify', label: 'Check implementation' };
|
|
38
|
-
}
|
|
39
26
|
async function fingerprint(root, selected) {
|
|
40
27
|
const files = [];
|
|
41
28
|
for (const file of selected.files) files.push([file, hash(await readArtifact(root, file))]);
|
|
@@ -45,15 +32,15 @@ async function fingerprint(root, selected) {
|
|
|
45
32
|
export function lifecycleActions({ selected, readiness, error, pending, preview, result, previewStale }) {
|
|
46
33
|
const actions = {};
|
|
47
34
|
const add = (action, label, reason = '') => { actions[action] = { action, label, enabled: !reason, reason }; };
|
|
48
|
-
const common = selected?.archived ? 'This change is archived.' : pending ? 'Finish or cancel the current workflow first.' : error || '';
|
|
35
|
+
const common = selected?.archived ? 'This change is archived.' : pending ? 'Finish or cancel the current workflow first.' : error || (!readiness ? 'Checking OpenSpec readiness…' : '');
|
|
49
36
|
const planning = !readiness?.planningComplete ? 'Complete the required planning artifacts first.' : '';
|
|
50
37
|
const complete = readiness && readiness.tasks.done === readiness.tasks.total;
|
|
38
|
+
add('refresh', 'Refresh readiness', selected?.archived ? 'This change is archived.' : '');
|
|
51
39
|
add('explore', 'Explore this change', common);
|
|
52
40
|
add('plan-next', 'Create next artifact', common || (!readiness?.nextArtifact ? 'No planning artifact is ready. Existing artifacts can be revised below.' : ''));
|
|
53
41
|
add('propose', 'Generate full plan', common || (readiness?.planningComplete ? 'The plan already exists. Request a revision instead.' : ''));
|
|
54
42
|
add('revise-plan', 'Request a plan revision', common || (!selected?.files.length ? 'Create the first planning artifact before revising it.' : ''));
|
|
55
43
|
add('preview', 'Generate implementation', common || planning || (readiness?.applyState !== 'ready' ? complete ? 'All tracked tasks are checked. Review existing work or revise the plan.' : 'The schema is not ready for implementation.' : ''));
|
|
56
|
-
add('review', 'Review files', !preview || !result ? 'Create an implementation preview first.' : '');
|
|
57
44
|
add('apply', result?.applied ? 'Changes applied' : 'Apply changes', selected?.archived ? 'This change is archived.' : !result?.changes.length ? 'No proposed file changes to apply.' : result.applied ? 'This preview was already applied.' : previewStale ? 'The spec changed. Generate a fresh code preview before applying.' : result.unsupported.length ? 'The preview contains unsupported files.' : pending ? 'Finish the current workflow first.' : '');
|
|
58
45
|
add('verify', 'Verify implementation', common || planning || (!result?.applied && !complete ? 'Apply a reviewed preview or finish the tracked implementation first.' : ''));
|
|
59
46
|
add('validate', 'Validate specification', selected?.archived ? 'This change is archived.' : error || '');
|
|
@@ -64,10 +51,10 @@ export function lifecycleActions({ selected, readiness, error, pending, preview,
|
|
|
64
51
|
return actions;
|
|
65
52
|
}
|
|
66
53
|
|
|
67
|
-
export async function lifecycleState(root, change = '', { jobs, getReadiness = localReadiness } = {}) {
|
|
54
|
+
export async function lifecycleState(root, change = '', { jobs, selected, getReadiness = localReadiness } = {}) {
|
|
68
55
|
jobs ||= await listJobs(root);
|
|
69
56
|
if (!change) return { selected: null, jobs: jobs.filter(job => !job.change || ['create-change', 'start-plan'].includes(job.action)), actions: {}, readiness: null, error: '' };
|
|
70
|
-
|
|
57
|
+
selected ||= (await inventory(root)).changes.find(item => item.id === change);
|
|
71
58
|
if (!selected) throw new Error('Select an existing change');
|
|
72
59
|
const relevant = jobs.filter(job => jobMatchesChange(job, selected));
|
|
73
60
|
const pending = relevant.find(job => pendingStatuses.includes(job.status));
|
|
@@ -85,19 +72,27 @@ export async function lifecycleState(root, change = '', { jobs, getReadiness = l
|
|
|
85
72
|
}
|
|
86
73
|
|
|
87
74
|
export async function requestLifecycle(root, payload, { getReadiness = localReadiness, runCLI = openspecJSON } = {}) {
|
|
88
|
-
const { action, change = '', message = '', planMode = 'next' } = payload;
|
|
75
|
+
const { action, change = '', message = '', planMode = 'next', requestKey, draftId } = payload;
|
|
89
76
|
if (typeof change !== 'string' || change.length > 160) throw new Error('Invalid change name');
|
|
90
77
|
const allowed = ['start-plan', 'create-change', 'explore', 'plan-next', 'propose', 'revise-plan', 'preview', 'verify', 'validate', 'refresh', 'sync-specs', 'archive', 'archive-override'];
|
|
91
78
|
if (!allowed.includes(action)) throw new Error('Unknown lifecycle action');
|
|
92
79
|
const lock = await within(root, `.spequi/lifecycle-${hash(change || 'project')}.lock`);
|
|
93
80
|
return withLock(lock, async () => {
|
|
81
|
+
if (requestKey) {
|
|
82
|
+
const previous = (await listJobs(root)).find(job => job.requestKey === requestKey);
|
|
83
|
+
if (previous) {
|
|
84
|
+
if (previous.change !== change || previous.action !== (action === 'archive-override' ? 'archive' : action) || message && previous.message !== message.trim()) throw new Error('Request identity was already used for different instructions');
|
|
85
|
+
return { job: previous, url: previous.action === 'start-plan' ? `/?view=studio&new=1&creation=${previous.id}` : `/?${new URLSearchParams({ change, view: 'studio' })}` };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
94
88
|
if (['start-plan', 'create-change'].includes(action) || (!change && action === 'explore')) {
|
|
95
89
|
const context = await runCLI(root, 'context');
|
|
96
90
|
if (!context.root?.path || await fs.realpath(context.root.path) !== await fs.realpath(root)) throw new Error('OpenSpec must resolve to this project before starting a change.');
|
|
97
91
|
const pending = (await listJobs(root)).find(job => job.change === change && pendingStatuses.includes(job.status));
|
|
98
92
|
if (pending) throw new Error('A workflow for this change is already pending.');
|
|
99
|
-
const
|
|
100
|
-
|
|
93
|
+
const create = () => enqueue(root, { action, change, message, planMode, requestKey });
|
|
94
|
+
const job = draftId && action === 'start-plan' ? await submitDraft(root, draftId, create) : await create();
|
|
95
|
+
return { job, url: action === 'start-plan' ? `/?view=studio&new=1&creation=${job.id}` : '/?view=studio&new=1' };
|
|
101
96
|
}
|
|
102
97
|
const state = await lifecycleState(root, change, { getReadiness });
|
|
103
98
|
if (action === 'refresh') return { refreshed: true, readiness: state.readiness, error: state.error };
|
|
@@ -113,7 +108,7 @@ export async function requestLifecycle(root, payload, { getReadiness = localRead
|
|
|
113
108
|
return { validation };
|
|
114
109
|
}
|
|
115
110
|
const goal = message || state.jobs.find(job => ['create-change', 'start-plan'].includes(job.action))?.message || 'Continue the selected workflow for this exact change.';
|
|
116
|
-
const job = await enqueue(root, { action: action === 'archive-override' ? 'archive' : action, change, message: goal, archiveOverride: action === 'archive-override' });
|
|
117
|
-
return { job, url: `/?${new URLSearchParams({ change, view: '
|
|
111
|
+
const job = await enqueue(root, { action: action === 'archive-override' ? 'archive' : action, change, message: goal, archiveOverride: action === 'archive-override', requestKey });
|
|
112
|
+
return { job, url: `/?${new URLSearchParams({ change, view: 'studio' })}` };
|
|
118
113
|
});
|
|
119
114
|
}
|
package/src/openspec-cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import * as fs from 'node:fs/promises';
|
|
|
5
5
|
const exec = promisify(execFile);
|
|
6
6
|
const isWin = process.platform === 'win32';
|
|
7
7
|
// This adapter exposes only read-only OpenSpec operations, never arbitrary commands.
|
|
8
|
-
export async function openspecJSON(root, operation, change = '') {
|
|
8
|
+
export async function openspecJSON(root, operation, change = '', { signal } = {}) {
|
|
9
9
|
if (change && (typeof change !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,160}$/.test(change))) throw new Error('Invalid change name');
|
|
10
10
|
const args = {
|
|
11
11
|
context: ['context', '--json'], list: ['list', '--json'],
|
|
@@ -15,7 +15,7 @@ export async function openspecJSON(root, operation, change = '') {
|
|
|
15
15
|
}[operation];
|
|
16
16
|
if (!args || (['status', 'apply', 'validate'].includes(operation) && !change)) throw new Error('Unsupported local OpenSpec operation');
|
|
17
17
|
let stdout;
|
|
18
|
-
try { ({ stdout } = await exec('openspec', args, { cwd: root, timeout: 15000, maxBuffer: 2 * 1024 * 1024, windowsHide: !isWin, shell: isWin, env: { ...process.env, NO_COLOR: '1', DO_NOT_TRACK: '1', OPENSPEC_TELEMETRY_DISABLED: '1' } })); }
|
|
18
|
+
try { ({ stdout } = await exec('openspec', args, { cwd: root, signal, timeout: 15000, maxBuffer: 2 * 1024 * 1024, windowsHide: !isWin, shell: isWin, env: { ...process.env, NO_COLOR: '1', DO_NOT_TRACK: '1', OPENSPEC_TELEMETRY_DISABLED: '1' } })); }
|
|
19
19
|
catch (error) {
|
|
20
20
|
if (error.killed) throw new Error('OpenSpec timed out. Retry the local check.');
|
|
21
21
|
if (!error.stdout) throw new Error('OpenSpec CLI is unavailable or could not run. Install it in this environment and retry.');
|
|
@@ -27,10 +27,10 @@ export async function openspecJSON(root, operation, change = '') {
|
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export async function localReadiness(root, change) {
|
|
31
|
-
const context = await openspecJSON(root, 'context');
|
|
30
|
+
export async function localReadiness(root, change, options = {}) {
|
|
31
|
+
const context = await openspecJSON(root, 'context', '', options);
|
|
32
32
|
if (!context.root?.path || await fs.realpath(context.root.path) !== await fs.realpath(root)) throw new Error('OpenSpec resolves to a different project or external store. Open that root explicitly before operating.');
|
|
33
|
-
const [status, listing, apply] = await Promise.all([openspecJSON(root, 'status', change), openspecJSON(root, 'list'), openspecJSON(root, 'apply', change)]);
|
|
33
|
+
const [status, listing, apply] = await Promise.all([openspecJSON(root, 'status', change, options), openspecJSON(root, 'list', '', options), openspecJSON(root, 'apply', change, options)]);
|
|
34
34
|
const entry = listing.changes?.find(item => item.name === change);
|
|
35
35
|
if (typeof status.schemaName !== 'string' || !Array.isArray(status.artifacts) || status.artifacts.some(item => !item || typeof item.id !== 'string' || !['done', 'skipped', 'ready', 'blocked'].includes(item.status)) || !['ready', 'blocked', 'all_done'].includes(apply.state) || !entry || !Number.isInteger(entry.totalTasks) || !Number.isInteger(entry.completedTasks) || entry.completedTasks < 0 || entry.completedTasks > entry.totalTasks) throw new Error('OpenSpec did not return valid artifact and task readiness.');
|
|
36
36
|
return { schema: status.schemaName, artifacts: status.artifacts, artifactPaths: status.artifactPaths || {},
|