@planu/cli 8.3.0 → 8.4.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/CHANGELOG.md +7 -0
- package/README.md +61 -2
- package/dist/sdd-engine/contracts.d.ts +5 -3
- package/dist/sdd-engine/contracts.js +23 -10
- package/dist/sdd-engine/feature-manifest.d.ts +2 -5
- package/dist/sdd-engine/feature-manifest.js +109 -184
- package/dist/sdd-engine/host-rule-pack.d.ts +5 -0
- package/dist/sdd-engine/host-rule-pack.js +102 -43
- package/dist/sdd-engine/host-skill-reader.d.ts +6 -0
- package/dist/sdd-engine/host-skill-reader.js +187 -0
- package/dist/sdd-engine/lock-integrity.d.ts +1 -0
- package/dist/sdd-engine/lock-integrity.js +25 -17
- package/dist/sdd-engine/receipt-assessment.d.ts +12 -0
- package/dist/sdd-engine/receipt-assessment.js +223 -0
- package/dist/sdd-engine/server.js +2 -4
- package/dist/sdd-engine/task-content.d.ts +11 -0
- package/dist/sdd-engine/task-content.js +28 -0
- package/dist/sdd-engine/task-window.d.ts +1 -0
- package/dist/sdd-engine/task-window.js +8 -1
- package/dist/sdd-engine/tools/execution-tools.d.ts +1 -11
- package/dist/sdd-engine/tools/execution-tools.js +5 -29
- package/dist/sdd-engine/tools/workspace-tools.d.ts +1 -1
- package/dist/sdd-engine/tools/workspace-tools.js +17 -9
- package/dist/sdd-engine/tools.d.ts +2 -1
- package/dist/sdd-engine/tools.js +4 -2
- package/dist/sdd-engine/trinity-structure.d.ts +25 -0
- package/dist/sdd-engine/trinity-structure.js +317 -0
- package/dist/sdd-engine/verification-preflight.d.ts +4 -0
- package/dist/sdd-engine/verification-preflight.js +271 -0
- package/dist/sdd-engine/verification-receipts.d.ts +2 -10
- package/dist/sdd-engine/verification-receipts.js +2 -169
- package/dist/sdd-engine/workspace-root.d.ts +1 -0
- package/dist/sdd-engine/workspace-root.js +1 -0
- package/dist/types/completion.d.ts +9 -2
- package/dist/types/sdd-engine.d.ts +71 -0
- package/package.json +1 -1
- package/templates/AGENTS.md +8 -0
- package/templates/host/planu-sdd.md +8 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const maxVerificationReceipts = 32;
|
|
4
|
+
export const gateIdPattern = /^[a-z][a-z0-9-]{0,31}$/u;
|
|
5
|
+
export const taskIdPattern = /^TASK-[1-9][0-9]{0,18}$/u;
|
|
6
|
+
export const featureIdPattern = /^FEAT[-_][A-Z0-9_-]{1,123}$/u;
|
|
7
|
+
export const sha256Schema = z.string().regex(/^[0-9a-f]{64}$/u);
|
|
8
|
+
function decodeCanonicalBase64Url(value) {
|
|
9
|
+
if (!/^[A-Za-z0-9_-]+$/u.test(value)) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const decoded = Buffer.from(value, 'base64url');
|
|
13
|
+
return decoded.toString('base64url') === value ? decoded : undefined;
|
|
14
|
+
}
|
|
15
|
+
export function importReceiptPublicKey(value) {
|
|
16
|
+
const der = value.length <= 128 ? decodeCanonicalBase64Url(value) : undefined;
|
|
17
|
+
if (!der) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const key = createPublicKey({ key: der, format: 'der', type: 'spki' });
|
|
22
|
+
if (key.asymmetricKeyType !== 'ed25519') {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return key.export({ format: 'der', type: 'spki' }).equals(der) ? key : undefined;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const receiptSchema = z.strictObject({
|
|
32
|
+
version: z.literal(1),
|
|
33
|
+
featureId: z.string().regex(featureIdPattern),
|
|
34
|
+
taskId: z.string().regex(taskIdPattern),
|
|
35
|
+
workspaceSha256: sha256Schema,
|
|
36
|
+
lockSha256: sha256Schema,
|
|
37
|
+
candidateSha256: sha256Schema,
|
|
38
|
+
observedSha256: sha256Schema,
|
|
39
|
+
gateId: z.string().regex(gateIdPattern),
|
|
40
|
+
procedureSha256: sha256Schema,
|
|
41
|
+
environmentSha256: sha256Schema,
|
|
42
|
+
outcome: z.enum(['pass', 'fail', 'skipped', 'partial']),
|
|
43
|
+
evidenceSha256: sha256Schema,
|
|
44
|
+
signature: z.string().regex(/^[A-Za-z0-9_-]{86}$/u),
|
|
45
|
+
});
|
|
46
|
+
const RECEIPT_KEY_COUNT = Object.keys(receiptSchema.shape).length;
|
|
47
|
+
function receiptMessage(receipt) {
|
|
48
|
+
return [
|
|
49
|
+
'planu.verification-receipt.v1',
|
|
50
|
+
receipt.featureId,
|
|
51
|
+
receipt.taskId,
|
|
52
|
+
receipt.workspaceSha256,
|
|
53
|
+
receipt.lockSha256,
|
|
54
|
+
receipt.candidateSha256,
|
|
55
|
+
receipt.observedSha256,
|
|
56
|
+
receipt.gateId,
|
|
57
|
+
receipt.procedureSha256,
|
|
58
|
+
receipt.environmentSha256,
|
|
59
|
+
receipt.outcome,
|
|
60
|
+
receipt.evidenceSha256,
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
function decodeReceipt(input) {
|
|
64
|
+
if (typeof input !== 'object' ||
|
|
65
|
+
input === null ||
|
|
66
|
+
Object.keys(input).length !== RECEIPT_KEY_COUNT) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const parsed = receiptSchema.safeParse(input);
|
|
70
|
+
if (!parsed.success) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const signature = decodeCanonicalBase64Url(parsed.data.signature);
|
|
74
|
+
if (signature?.length !== 64) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
receipt: parsed.data,
|
|
79
|
+
message: receiptMessage(parsed.data),
|
|
80
|
+
signature,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function matchCoverage(signed, gates) {
|
|
84
|
+
const required = new Set(gates.map((gate) => gate.id));
|
|
85
|
+
const byGate = new Map();
|
|
86
|
+
for (const entry of signed) {
|
|
87
|
+
const gateId = entry.receipt.gateId;
|
|
88
|
+
if (!required.has(gateId)) {
|
|
89
|
+
return { ok: false, reason: 'receipt_unexpected' };
|
|
90
|
+
}
|
|
91
|
+
if (byGate.has(gateId)) {
|
|
92
|
+
return { ok: false, reason: 'receipt_duplicate', gateId };
|
|
93
|
+
}
|
|
94
|
+
byGate.set(gateId, entry);
|
|
95
|
+
}
|
|
96
|
+
const matched = [];
|
|
97
|
+
for (const gate of gates) {
|
|
98
|
+
const entry = byGate.get(gate.id);
|
|
99
|
+
if (!entry) {
|
|
100
|
+
return { ok: false, reason: 'receipt_missing', gateId: gate.id };
|
|
101
|
+
}
|
|
102
|
+
matched.push({ ...entry, gate });
|
|
103
|
+
}
|
|
104
|
+
return { ok: true, matched };
|
|
105
|
+
}
|
|
106
|
+
function validateClaims(matched, challenge) {
|
|
107
|
+
const checks = [
|
|
108
|
+
[
|
|
109
|
+
(receipt) => receipt.workspaceSha256 === challenge.workspaceSha256 &&
|
|
110
|
+
receipt.featureId === challenge.featureId &&
|
|
111
|
+
receipt.taskId === challenge.taskId &&
|
|
112
|
+
receipt.lockSha256 === challenge.lockSha256,
|
|
113
|
+
'receipt_context_mismatch',
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
(receipt) => receipt.candidateSha256 === challenge.candidateSha256,
|
|
117
|
+
'receipt_candidate_mismatch',
|
|
118
|
+
],
|
|
119
|
+
[(receipt) => receipt.observedSha256 === challenge.observedSha256, 'receipt_observed_mismatch'],
|
|
120
|
+
[
|
|
121
|
+
(receipt, gate) => receipt.procedureSha256 === gate.procedureSha256,
|
|
122
|
+
'receipt_procedure_mismatch',
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
(receipt, gate) => receipt.environmentSha256 === gate.environmentSha256,
|
|
126
|
+
'receipt_environment_mismatch',
|
|
127
|
+
],
|
|
128
|
+
[(receipt) => receipt.outcome === 'pass', 'receipt_non_pass'],
|
|
129
|
+
];
|
|
130
|
+
for (const [accepts, reason] of checks) {
|
|
131
|
+
const failed = matched.find(({ receipt, gate }) => !accepts(receipt, gate));
|
|
132
|
+
if (failed) {
|
|
133
|
+
return { ok: false, reason, gateId: failed.gate.id };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
function validateReceiptSet(input, challenge, publicKey) {
|
|
139
|
+
const gates = [...challenge.gates].sort((left, right) => left.id < right.id ? -1 : left.id === right.id ? 0 : 1);
|
|
140
|
+
if (input === undefined) {
|
|
141
|
+
const gateId = gates[0]?.id;
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
reason: 'receipt_missing',
|
|
145
|
+
...(gateId ? { gateId } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (!Array.isArray(input) || input.length < 1 || input.length > maxVerificationReceipts) {
|
|
149
|
+
return { ok: false, reason: 'receipt_malformed' };
|
|
150
|
+
}
|
|
151
|
+
const signed = [];
|
|
152
|
+
for (const raw of input) {
|
|
153
|
+
const receipt = decodeReceipt(raw);
|
|
154
|
+
if (!receipt) {
|
|
155
|
+
return { ok: false, reason: 'receipt_malformed' };
|
|
156
|
+
}
|
|
157
|
+
signed.push(receipt);
|
|
158
|
+
}
|
|
159
|
+
const coverage = matchCoverage(signed, gates);
|
|
160
|
+
if (!coverage.ok) {
|
|
161
|
+
return coverage;
|
|
162
|
+
}
|
|
163
|
+
for (const { receipt, message, signature } of coverage.matched) {
|
|
164
|
+
if (!verify(null, Buffer.from(JSON.stringify(message), 'utf8'), publicKey, signature)) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
reason: 'receipt_invalid_signature',
|
|
168
|
+
gateId: receipt.gateId,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const rejected = validateClaims(coverage.matched, challenge);
|
|
173
|
+
if (rejected) {
|
|
174
|
+
return rejected;
|
|
175
|
+
}
|
|
176
|
+
const entries = coverage.matched.map(({ message, receipt }) => [message, receipt.signature]);
|
|
177
|
+
const receiptSetSha256 = createHash('sha256')
|
|
178
|
+
.update(JSON.stringify(['planu.verification-receipt-set.v1', entries]), 'utf8')
|
|
179
|
+
.digest('hex');
|
|
180
|
+
return { ok: true, gateCount: entries.length, receiptSetSha256 };
|
|
181
|
+
}
|
|
182
|
+
export function assessVerificationReceiptSet(input, challenge, publicKey) {
|
|
183
|
+
const result = validateReceiptSet(input, challenge, publicKey);
|
|
184
|
+
const gates = [...challenge.gates]
|
|
185
|
+
.sort((left, right) => (left.id < right.id ? -1 : left.id === right.id ? 0 : 1))
|
|
186
|
+
.slice(0, maxVerificationReceipts)
|
|
187
|
+
.map((gate) => {
|
|
188
|
+
const subset = Array.isArray(input) && input.length >= 1 && input.length <= maxVerificationReceipts
|
|
189
|
+
? input.filter((entry) => typeof entry === 'object' &&
|
|
190
|
+
entry !== null &&
|
|
191
|
+
'gateId' in entry &&
|
|
192
|
+
entry.gateId === gate.id)
|
|
193
|
+
: input;
|
|
194
|
+
const selected = Array.isArray(input) && input.length >= 1 && Array.isArray(subset) && subset.length === 0
|
|
195
|
+
? undefined
|
|
196
|
+
: subset;
|
|
197
|
+
const checked = validateReceiptSet(selected, { ...challenge, gates: [gate] }, publicKey);
|
|
198
|
+
if (checked.ok) {
|
|
199
|
+
return { gateId: gate.id, state: 'receipt_valid' };
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
gateId: gate.id,
|
|
203
|
+
state: checked.reason === 'receipt_missing' ? 'receipt_missing' : 'receipt_rejected',
|
|
204
|
+
reason: checked.reason,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
const reasons = new Set();
|
|
208
|
+
if (!result.ok && !gates.some((gate) => gate.reason === result.reason)) {
|
|
209
|
+
reasons.add(result.reason);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
result,
|
|
213
|
+
gates,
|
|
214
|
+
blockers: [...reasons]
|
|
215
|
+
.sort()
|
|
216
|
+
.slice(0, 16)
|
|
217
|
+
.map((reason) => ({ reason })),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export function validateVerificationReceiptSet(input, challenge, publicKey) {
|
|
221
|
+
return validateReceiptSet(input, challenge, publicKey);
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=receipt-assessment.js.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
3
|
import { captureVerificationPolicy, resolveVerificationPolicy } from './verification-policy.js';
|
|
5
|
-
import { registerUltralightSddTools } from './tools.js';
|
|
6
|
-
const { version } = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
4
|
+
import { bundledPackageVersion as version, registerUltralightSddTools } from './tools.js';
|
|
7
5
|
export function createUltralightSddServer(workspaceRoot, options) {
|
|
8
6
|
const policy = resolveVerificationPolicy(options?.verificationPolicy, workspaceRoot);
|
|
9
7
|
const server = new McpServer({ name: 'sdd-engine', version }, {
|
|
@@ -11,7 +9,7 @@ export function createUltralightSddServer(workspaceRoot, options) {
|
|
|
11
9
|
instructions: 'First use: call sdd_list_features. If setup is missing or unverified, call sdd_init_workspace(scope=project) only for the identified project and requested setup. Then use sdd_read_file_slice to read .agents/skills/planu-preflight-guardian/SKILL.md and the matching role. Keep one active task, the locked File Manifest and all nine tools. Installed files do not prove a host catalog reload; explain client-dependent discovery and never initialize on connect.',
|
|
12
10
|
});
|
|
13
11
|
const pinnedRoot = policy.mode === 'scoped' ? policy.workspaceRoot : workspaceRoot;
|
|
14
|
-
const tasks = registerUltralightSddTools(server, pinnedRoot, policy);
|
|
12
|
+
const tasks = registerUltralightSddTools(server, pinnedRoot, policy, version);
|
|
15
13
|
{
|
|
16
14
|
const close = server.close.bind(server);
|
|
17
15
|
server.close = async () => {
|
|
@@ -12,4 +12,15 @@ export declare function hasReceiptDirective(line: string): boolean;
|
|
|
12
12
|
export declare function receiptCommand(block: TaskBlock): string | undefined;
|
|
13
13
|
export declare function countTaskIds(blocks: readonly TaskBlock[]): Map<string, number>;
|
|
14
14
|
export declare function dueTaskOrdinals(blocks: readonly TaskBlock[], counts: ReadonlyMap<string, number>): Map<string, number>;
|
|
15
|
+
export declare function sliceNumberedSource(fileData: string, startLine: number, endLine: number): {
|
|
16
|
+
ok: true;
|
|
17
|
+
totalLines: number;
|
|
18
|
+
startLine: number;
|
|
19
|
+
endLine: number;
|
|
20
|
+
truncated: boolean;
|
|
21
|
+
text: string;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
totalLines: number;
|
|
25
|
+
};
|
|
15
26
|
//# sourceMappingURL=task-content.d.ts.map
|
|
@@ -226,4 +226,32 @@ export function dueTaskOrdinals(blocks, counts) {
|
|
|
226
226
|
}
|
|
227
227
|
return due;
|
|
228
228
|
}
|
|
229
|
+
const SLICE_LINE_CAP = 200;
|
|
230
|
+
function sourceLines(fileData) {
|
|
231
|
+
if (fileData.length === 0) {
|
|
232
|
+
return [];
|
|
233
|
+
}
|
|
234
|
+
const parts = fileData.split('\n');
|
|
235
|
+
if (fileData.endsWith('\n')) {
|
|
236
|
+
parts.pop();
|
|
237
|
+
}
|
|
238
|
+
return parts;
|
|
239
|
+
}
|
|
240
|
+
export function sliceNumberedSource(fileData, startLine, endLine) {
|
|
241
|
+
const lines = sourceLines(fileData);
|
|
242
|
+
if (startLine > lines.length) {
|
|
243
|
+
return { ok: false, totalLines: lines.length };
|
|
244
|
+
}
|
|
245
|
+
const requestedEnd = Math.min(endLine, lines.length);
|
|
246
|
+
const cappedEnd = Math.min(requestedEnd, startLine + SLICE_LINE_CAP - 1);
|
|
247
|
+
const slice = lines.slice(startLine - 1, cappedEnd);
|
|
248
|
+
return {
|
|
249
|
+
ok: true,
|
|
250
|
+
totalLines: lines.length,
|
|
251
|
+
startLine,
|
|
252
|
+
endLine: cappedEnd,
|
|
253
|
+
truncated: cappedEnd < requestedEnd,
|
|
254
|
+
text: slice.map((content, index) => `${startLine + index}: ${content}`).join('\n'),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
229
257
|
//# sourceMappingURL=task-content.js.map
|
|
@@ -10,6 +10,7 @@ export declare class TaskWindowManager {
|
|
|
10
10
|
private activeTaskFromContent;
|
|
11
11
|
private selectScopedTask;
|
|
12
12
|
getActiveTask(tasksFilePath: string): Promise<SddResult<ActiveTaskResult>>;
|
|
13
|
+
getVerificationPreflight(tasksPath: string, workspaceRoot: string, receipts?: unknown, signal?: AbortSignal): Promise<SddResult<ActiveTaskResult>>;
|
|
13
14
|
getCatalogueEntry(featDir: string): Promise<SddResult<FeatureSummary>>;
|
|
14
15
|
completeTask(tasksFilePath: string, taskId: string, workspaceRoot: string, _verificationOutput: string, signal?: AbortSignal, receipts?: unknown): Promise<SddResult<CompleteTaskResult>>;
|
|
15
16
|
private completeOwned;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import { ScopedVerificationCoordinator, runScopedVerification } from './verification-runner.js';
|
|
3
3
|
import { isScopedVerificationFeature, persistScopedCompletionFiles, scopedFeaturePathFailure, } from './verification-policy.js';
|
|
4
|
+
import { getVerificationPreflight } from './verification-preflight.js';
|
|
4
5
|
import { executionCard } from './lock-integrity.js';
|
|
5
6
|
import { parseVerificationReceiptPolicy } from './feature-manifest.js';
|
|
6
7
|
import { completeReceiptTask } from './verification-receipts.js';
|
|
@@ -75,6 +76,9 @@ export class TaskWindowManager {
|
|
|
75
76
|
return completionError(error, 'sdd_get_active_task');
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
async getVerificationPreflight(tasksPath, workspaceRoot, receipts, signal) {
|
|
80
|
+
return getVerificationPreflight(tasksPath, workspaceRoot, verificationCommand, receipts, this.scopedPolicy, signal);
|
|
81
|
+
}
|
|
78
82
|
async getCatalogueEntry(featDir) {
|
|
79
83
|
const id = path.basename(featDir);
|
|
80
84
|
try {
|
|
@@ -106,7 +110,10 @@ export class TaskWindowManager {
|
|
|
106
110
|
if (pathFailure) {
|
|
107
111
|
return pathFailure;
|
|
108
112
|
}
|
|
109
|
-
const lease = await acquireCompletionLease(feature, {
|
|
113
|
+
const lease = await acquireCompletionLease(feature, {
|
|
114
|
+
operation: 'complete',
|
|
115
|
+
workspaceRoot,
|
|
116
|
+
});
|
|
110
117
|
try {
|
|
111
118
|
const snapshot = await captureCompletionSnapshot(feature, {
|
|
112
119
|
writable: true,
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import type { VerificationPolicy } from '../../types/verification.js';
|
|
2
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { TaskWindowManager } from '../task-window.js';
|
|
4
|
+
export { sliceNumberedSource } from '../task-content.js';
|
|
4
5
|
import type { SddWorkspaceHandle } from '../../types/sdd-engine.js';
|
|
5
|
-
export declare function sliceNumberedSource(fileData: string, startLine: number, endLine: number): {
|
|
6
|
-
ok: true;
|
|
7
|
-
totalLines: number;
|
|
8
|
-
startLine: number;
|
|
9
|
-
endLine: number;
|
|
10
|
-
truncated: boolean;
|
|
11
|
-
text: string;
|
|
12
|
-
} | {
|
|
13
|
-
ok: false;
|
|
14
|
-
totalLines: number;
|
|
15
|
-
};
|
|
16
6
|
export declare function registerExecutionTools(server: McpServer, workspace: SddWorkspaceHandle, policy?: VerificationPolicy): TaskWindowManager;
|
|
17
7
|
//# sourceMappingURL=execution-tools.d.ts.map
|
|
@@ -2,7 +2,8 @@ import * as path from 'node:path';
|
|
|
2
2
|
import { ReadSpecArtifactInputSchema, ReadFileSliceInputSchema, GetActiveTaskInputSchema, ApplyFilePatchInputSchema, CompleteTaskInputSchema, } from '../contracts.js';
|
|
3
3
|
import { PatchSandbox } from '../patch-sandbox.js';
|
|
4
4
|
import { TaskWindowManager, verificationCommand } from '../task-window.js';
|
|
5
|
-
import { activeTaskFromContent, hasReceiptDirective } from '../task-content.js';
|
|
5
|
+
import { activeTaskFromContent, hasReceiptDirective, sliceNumberedSource, } from '../task-content.js';
|
|
6
|
+
export { sliceNumberedSource } from '../task-content.js';
|
|
6
7
|
import { parseManifestContent, parseVerificationReceiptPolicy, toPosixPath, } from '../feature-manifest.js';
|
|
7
8
|
import { captureReceiptEvidence } from '../verification-receipts.js';
|
|
8
9
|
import { captureVerificationRoot, checkReceiptPatchTarget, revalidateVerificationInputs, } from '../verification-inputs.js';
|
|
@@ -12,34 +13,6 @@ import { acquireCompletionLease, inspectCompletionGuard } from '../completion-gu
|
|
|
12
13
|
import { captureCompletionSnapshot, revalidateCompletionSnapshot } from '../completion-snapshot.js';
|
|
13
14
|
import { homeFallbackFailure, readTextInsideWorkspace } from '../workspace-root.js';
|
|
14
15
|
import { guardFailure } from '../feature-authority.js';
|
|
15
|
-
const SLICE_LINE_CAP = 200;
|
|
16
|
-
function sourceLines(fileData) {
|
|
17
|
-
if (fileData.length === 0) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const parts = fileData.split('\n');
|
|
21
|
-
if (fileData.endsWith('\n')) {
|
|
22
|
-
parts.pop();
|
|
23
|
-
}
|
|
24
|
-
return parts;
|
|
25
|
-
}
|
|
26
|
-
export function sliceNumberedSource(fileData, startLine, endLine) {
|
|
27
|
-
const lines = sourceLines(fileData);
|
|
28
|
-
if (startLine > lines.length) {
|
|
29
|
-
return { ok: false, totalLines: lines.length };
|
|
30
|
-
}
|
|
31
|
-
const requestedEnd = Math.min(endLine, lines.length);
|
|
32
|
-
const cappedEnd = Math.min(requestedEnd, startLine + SLICE_LINE_CAP - 1);
|
|
33
|
-
const slice = lines.slice(startLine - 1, cappedEnd);
|
|
34
|
-
return {
|
|
35
|
-
ok: true,
|
|
36
|
-
totalLines: lines.length,
|
|
37
|
-
startLine,
|
|
38
|
-
endLine: cappedEnd,
|
|
39
|
-
truncated: cappedEnd < requestedEnd,
|
|
40
|
-
text: slice.map((content, index) => `${startLine + index}: ${content}`).join('\n'),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
16
|
export function registerExecutionTools(server, workspace, policy) {
|
|
44
17
|
const taskWindow = new TaskWindowManager(policy);
|
|
45
18
|
registerReadArtifactTool(server, workspace);
|
|
@@ -103,6 +76,9 @@ function registerGetActiveTaskTool(server, workspace, taskWindow) {
|
|
|
103
76
|
return formatResult(homeError);
|
|
104
77
|
}
|
|
105
78
|
const tasksPath = path.join(resolved.sddDir, 'features', args.feature_id, 'tasks.md');
|
|
79
|
+
if (args.view === 'verification_preflight') {
|
|
80
|
+
return formatResult(await taskWindow.getVerificationPreflight(tasksPath, resolved.workspaceRoot, args.verification_receipts, extra.signal));
|
|
81
|
+
}
|
|
106
82
|
const result = await taskWindow.getActiveTask(tasksPath);
|
|
107
83
|
const active = result.success ? result.data.activeTask : null;
|
|
108
84
|
if (result.success &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { SddWorkspaceHandle } from '../../types/sdd-engine.js';
|
|
3
|
-
export declare function registerWorkspaceTools(server: McpServer, workspace: SddWorkspaceHandle): void;
|
|
3
|
+
export declare function registerWorkspaceTools(server: McpServer, workspace: SddWorkspaceHandle, bundledVersion?: string): void;
|
|
4
4
|
//# sourceMappingURL=workspace-tools.d.ts.map
|
|
@@ -6,19 +6,21 @@ import { TaskWindowManager } from '../task-window.js';
|
|
|
6
6
|
import { formatResult } from './format-result.js';
|
|
7
7
|
import { homeFallbackFailure } from '../workspace-root.js';
|
|
8
8
|
import { prepareProjectInitialization } from '../workspace-init.js';
|
|
9
|
-
import { writeLockedTrinity } from '../lock-integrity.js';
|
|
9
|
+
import { readTrinityFailureIssues, writeLockedTrinity } from '../lock-integrity.js';
|
|
10
10
|
import { CompletionGuardError } from '../feature-authority.js';
|
|
11
11
|
import { reserveAutomaticFeatureDirectory, createExplicitFeatureDirectory, collectFeatures, featurePathFailure, writeFeatureArtifacts, } from './feature-store.js';
|
|
12
|
-
import { copyGlobalRules, installCursorGuard, installHostRulePack, installHostSkillPack, inspectHostSkillPack, } from '../host-rule-pack.js';
|
|
12
|
+
import { copyGlobalRules, installCursorGuard, installHostRulePack, installHostSkillPack, inspectHostSkillPack, inspectHostSkillPackDetailed, } from '../host-rule-pack.js';
|
|
13
13
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
const MISSING_SDD_HINT = 'No .sdd directory in the client project. Call sdd_init_workspace with scope=project. MCP hosts should advertise roots; do not pin PLANU_WORKSPACE globally.';
|
|
15
15
|
const LEGACY_SPECS_HINT = 'Planu ignores planu/specs. Do not create SPEC-* stubs or copy a FEAT into that tree. Retire host hooks that require planu/specs/SPEC-*/spec.md; the only contract is .sdd/features/FEAT-*.';
|
|
16
|
-
async function composeWorkspaceHint(workspaceRoot, extra) {
|
|
16
|
+
async function composeWorkspaceHint(workspaceRoot, extra, suppliedPack) {
|
|
17
17
|
const legacySpecsPresent = await fs
|
|
18
18
|
.access(path.join(workspaceRoot, 'planu', 'specs'))
|
|
19
19
|
.then(() => true)
|
|
20
20
|
.catch(() => false);
|
|
21
|
-
const pack =
|
|
21
|
+
const pack = suppliedPack
|
|
22
|
+
? suppliedPack.hint
|
|
23
|
+
: await inspectHostSkillPack(workspaceRoot).catch(() => 'Planu host skill verification was unavailable. Run sdd_init_workspace for requested project setup and read the matching role.');
|
|
22
24
|
const combined = [extra, pack, legacySpecsPresent ? LEGACY_SPECS_HINT : undefined]
|
|
23
25
|
.filter((item) => item !== undefined)
|
|
24
26
|
.join(' ');
|
|
@@ -37,10 +39,10 @@ async function composeWorkspaceHint(workspaceRoot, extra) {
|
|
|
37
39
|
}
|
|
38
40
|
return bounded;
|
|
39
41
|
}
|
|
40
|
-
export function registerWorkspaceTools(server, workspace) {
|
|
42
|
+
export function registerWorkspaceTools(server, workspace, bundledVersion) {
|
|
41
43
|
const taskWindow = new TaskWindowManager();
|
|
42
44
|
registerInitTool(server, workspace);
|
|
43
|
-
registerListTool(server, workspace, taskWindow);
|
|
45
|
+
registerListTool(server, workspace, taskWindow, bundledVersion);
|
|
44
46
|
registerCreateTool(server, workspace);
|
|
45
47
|
registerLockTool(server, workspace);
|
|
46
48
|
}
|
|
@@ -96,7 +98,7 @@ function registerInitTool(server, workspace) {
|
|
|
96
98
|
});
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
|
-
function registerListTool(server, workspace, taskWindow) {
|
|
101
|
+
function registerListTool(server, workspace, taskWindow, bundledVersion) {
|
|
100
102
|
server.registerTool('sdd_list_features', {
|
|
101
103
|
description: 'Lists executable Planu v8 FEAT-* features from .sdd/features only.',
|
|
102
104
|
inputSchema: ListFeaturesInputSchema.shape,
|
|
@@ -117,12 +119,14 @@ function registerListTool(server, workspace, taskWindow) {
|
|
|
117
119
|
return formatResult(collected);
|
|
118
120
|
}
|
|
119
121
|
const featuresList = collected.data;
|
|
120
|
-
const
|
|
122
|
+
const skillScan = await inspectHostSkillPackDetailed(resolved.workspaceRoot, bundledVersion ?? 'unknown');
|
|
123
|
+
const hint = await composeWorkspaceHint(resolved.workspaceRoot, resolved.sddPresent ? undefined : MISSING_SDD_HINT, skillScan);
|
|
121
124
|
return formatResult({
|
|
122
125
|
success: true,
|
|
123
126
|
data: {
|
|
124
127
|
total: featuresList.length,
|
|
125
128
|
features: featuresList,
|
|
129
|
+
hostSkills: skillScan.hostSkills,
|
|
126
130
|
workspaceRoot: resolved.workspaceRoot,
|
|
127
131
|
sddPresent: resolved.sddPresent,
|
|
128
132
|
source: resolved.source,
|
|
@@ -219,6 +223,7 @@ async function executeLockSpec(featDir, featureId, relock, reason) {
|
|
|
219
223
|
outcome = await writeLockedTrinity(featDir, featureId, relock, reason);
|
|
220
224
|
}
|
|
221
225
|
catch (error) {
|
|
226
|
+
const issues = readTrinityFailureIssues(error);
|
|
222
227
|
return formatResult({
|
|
223
228
|
success: false,
|
|
224
229
|
error: {
|
|
@@ -227,7 +232,10 @@ async function executeLockSpec(featDir, featureId, relock, reason) {
|
|
|
227
232
|
? error.message
|
|
228
233
|
: 'The feature could not be safely locked.',
|
|
229
234
|
trigger: 'sdd_lock_spec',
|
|
230
|
-
details: {
|
|
235
|
+
details: {
|
|
236
|
+
reason: error instanceof CompletionGuardError ? error.reason : 'failed',
|
|
237
|
+
...(issues ? { issues } : {}),
|
|
238
|
+
},
|
|
231
239
|
},
|
|
232
240
|
});
|
|
233
241
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { VerificationPolicy } from '../types/verification.js';
|
|
2
2
|
import type { TaskWindowManager } from './task-window.js';
|
|
3
3
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
export declare
|
|
4
|
+
export declare const bundledPackageVersion: string;
|
|
5
|
+
export declare function registerUltralightSddTools(server: McpServer, pinnedRoot?: string, policy?: VerificationPolicy, bundledVersion?: string): TaskWindowManager;
|
|
5
6
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/sdd-engine/tools.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
1
2
|
import { McpClientWorkspace } from './client-workspace.js';
|
|
2
3
|
import { registerWorkspaceTools } from './tools/workspace-tools.js';
|
|
3
4
|
import { registerExecutionTools } from './tools/execution-tools.js';
|
|
4
|
-
export
|
|
5
|
+
export const bundledPackageVersion = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version;
|
|
6
|
+
export function registerUltralightSddTools(server, pinnedRoot, policy, bundledVersion = bundledPackageVersion) {
|
|
5
7
|
const workspace = new McpClientWorkspace(server, pinnedRoot);
|
|
6
|
-
registerWorkspaceTools(server, workspace);
|
|
8
|
+
registerWorkspaceTools(server, workspace, bundledVersion);
|
|
7
9
|
return registerExecutionTools(server, workspace, policy);
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { CompletionGuardError } from './feature-authority.js';
|
|
3
|
+
import type { ReceiptPolicyText, ReceiptPolicyResult, TaskBlock, ManifestEntry, ParsedManifest, TrinityIssue } from '../types/sdd-engine.js';
|
|
4
|
+
import type { TrinityCompleteness } from '../types/completion.js';
|
|
5
|
+
export declare function assessTrinityCompleteness(specContent: string, planContent: string, tasksContent: string): TrinityCompleteness;
|
|
6
|
+
export declare function parseManifestContent(content: string): ParsedManifest;
|
|
7
|
+
export declare function manifestEntries(content: string): ManifestEntry[];
|
|
8
|
+
export declare function toPosixPath(value: string): string;
|
|
9
|
+
export declare class TrinityReadError extends CompletionGuardError {
|
|
10
|
+
readonly issues: TrinityIssue[];
|
|
11
|
+
constructor(error: CompletionGuardError, artifact: TrinityIssue['artifact']);
|
|
12
|
+
}
|
|
13
|
+
export declare function readTrinityFailureIssues(error: unknown): TrinityIssue[] | undefined;
|
|
14
|
+
export declare function policyText(plan: string): ReceiptPolicyText;
|
|
15
|
+
export declare function invalidTask(block: TaskBlock, duplicateLineIndex?: number): Extract<ReceiptPolicyResult, {
|
|
16
|
+
status: 'invalid';
|
|
17
|
+
}>;
|
|
18
|
+
export declare function invalidCandidate(entries: readonly ManifestEntry[], paths: readonly string[]): ManifestEntry | undefined;
|
|
19
|
+
export declare function candidateIssue(entry: ManifestEntry | undefined): TrinityIssue;
|
|
20
|
+
export declare function policyIssueLine(issue: z.core.$ZodIssue, locations: ReadonlyMap<string, number>): number | undefined;
|
|
21
|
+
export declare function candidateCreationIssue(rawPath: string, creates: readonly {
|
|
22
|
+
path: string;
|
|
23
|
+
requiredFromTaskId: string;
|
|
24
|
+
}[], requiredFrom: number | undefined, locations: ReadonlyMap<string, number>): TrinityIssue;
|
|
25
|
+
//# sourceMappingURL=trinity-structure.d.ts.map
|