@planu/cli 8.8.0 → 8.10.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 +14 -0
- package/README.md +9 -3
- package/dist/sdd-engine/canonical-tools.d.ts +38 -0
- package/dist/sdd-engine/canonical-tools.js +105 -2
- package/dist/sdd-engine/catalogue-presentation.d.ts +23 -0
- package/dist/sdd-engine/catalogue-presentation.js +123 -0
- package/dist/sdd-engine/client-workspace.d.ts +8 -1
- package/dist/sdd-engine/client-workspace.js +168 -1
- package/dist/sdd-engine/completion-snapshot.d.ts +2 -1
- package/dist/sdd-engine/completion-snapshot.js +81 -23
- package/dist/sdd-engine/contracts.d.ts +2 -24
- package/dist/sdd-engine/contracts.js +5 -19
- package/dist/sdd-engine/feature-authority.d.ts +3 -2
- package/dist/sdd-engine/feature-authority.js +29 -1
- package/dist/sdd-engine/host-rule-pack.js +16 -4
- package/dist/sdd-engine/host-skill-reader.d.ts +12 -11
- package/dist/sdd-engine/host-skill-reader.js +235 -225
- package/dist/sdd-engine/source-descriptor.d.ts +3 -0
- package/dist/sdd-engine/source-descriptor.js +356 -0
- package/dist/sdd-engine/tools/execution-tools.d.ts +2 -1
- package/dist/sdd-engine/tools/execution-tools.js +58 -33
- package/dist/sdd-engine/tools/feature-store.d.ts +6 -6
- package/dist/sdd-engine/tools/feature-store.js +188 -84
- package/dist/sdd-engine/tools/workspace-tools.d.ts +2 -1
- package/dist/sdd-engine/tools/workspace-tools.js +44 -35
- package/dist/sdd-engine/tools.js +4 -2
- package/dist/sdd-engine/workspace-init.d.ts +6 -0
- package/dist/sdd-engine/workspace-init.js +92 -2
- package/dist/sdd-engine/workspace-root.d.ts +33 -7
- package/dist/sdd-engine/workspace-root.js +222 -139
- package/dist/types/completion.d.ts +46 -2
- package/dist/types/resume-views.d.ts +36 -1
- package/dist/types/sdd-engine.d.ts +35 -61
- package/dist/types/verification.d.ts +59 -0
- package/package.json +2 -2
- package/templates/AGENTS.md +4 -0
- package/templates/host/planu-sdd.md +4 -0
- package/templates/skills/preflight-guardian.md +4 -0
- package/templates/skills/spec-executor.md +4 -0
|
@@ -1,133 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
2
3
|
import { lstat, open, readFile, realpath } from 'node:fs/promises';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export function parseMcpRootUri(uri) {
|
|
7
|
-
const trimmed = uri.trim();
|
|
8
|
-
if (!trimmed) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
if (trimmed.startsWith('file:')) {
|
|
13
|
-
return resolve(fileURLToPath(trimmed));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
if (trimmed.startsWith('/')) {
|
|
20
|
-
return resolve(trimmed);
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
export function resolveSddWorkspaceRoot(startDir = process.cwd(), env = process.env, mcpRootUris = []) {
|
|
25
|
-
return resolveSddWorkspace({ startDir, env, mcpRootUris }).workspaceRoot;
|
|
26
|
-
}
|
|
27
|
-
export function resolveSddWorkspace(input = {}) {
|
|
28
|
-
const env = input.env ?? process.env;
|
|
29
|
-
const startDir = resolve(input.startDir ?? process.cwd());
|
|
30
|
-
if (input.pinnedRoot?.trim()) {
|
|
31
|
-
return finish(resolve(input.pinnedRoot.trim()), 'pin');
|
|
32
|
-
}
|
|
33
|
-
const fromEnv = usablePlanuWorkspaceEnv(env);
|
|
34
|
-
if (fromEnv) {
|
|
35
|
-
return finish(fromEnv, 'env');
|
|
36
|
-
}
|
|
37
|
-
const mcpDirs = unique((input.mcpRootUris ?? [])
|
|
38
|
-
.map((uri) => parseMcpRootUri(uri))
|
|
39
|
-
.filter((dir) => dir !== null));
|
|
40
|
-
for (const dir of mcpDirs) {
|
|
41
|
-
const found = nearestProjectSdd(dir, env);
|
|
42
|
-
if (found) {
|
|
43
|
-
return finish(found, 'mcp_root');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const fromCwd = nearestProjectSdd(startDir, env);
|
|
47
|
-
if (fromCwd) {
|
|
48
|
-
return finish(fromCwd, 'cwd_walk');
|
|
49
|
-
}
|
|
50
|
-
if (mcpDirs[0]) {
|
|
51
|
-
return finish(mcpDirs[0], 'fallback');
|
|
52
|
-
}
|
|
53
|
-
return finish(startDir, 'fallback');
|
|
54
|
-
}
|
|
55
|
-
export function isHomeFallbackWorkspace(resolved, env = process.env) {
|
|
56
|
-
return resolved.source === 'fallback' && isHomeDirectory(resolved.workspaceRoot, env);
|
|
57
|
-
}
|
|
58
|
-
export function homeFallbackFailure(resolved, trigger, env = process.env) {
|
|
59
|
-
if (!isHomeFallbackWorkspace(resolved, env)) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
success: false,
|
|
64
|
-
error: {
|
|
65
|
-
code: 'ERR_WORKSPACE_UNRESOLVED',
|
|
66
|
-
message: ERR_WORKSPACE_UNRESOLVED_MESSAGE,
|
|
67
|
-
trigger,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function finish(workspaceRoot, source) {
|
|
72
|
-
const sddDir = join(workspaceRoot, '.sdd');
|
|
73
|
-
return {
|
|
74
|
-
workspaceRoot,
|
|
75
|
-
sddDir,
|
|
76
|
-
sddPresent: existsSync(sddDir),
|
|
77
|
-
source,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function nearestProjectSdd(startDir, env) {
|
|
81
|
-
let dir = resolve(startDir);
|
|
82
|
-
for (;;) {
|
|
83
|
-
if (existsSync(join(dir, '.sdd')) && !isHomeDirectory(dir, env)) {
|
|
84
|
-
return dir;
|
|
85
|
-
}
|
|
86
|
-
const parent = dirname(dir);
|
|
87
|
-
if (parent === dir) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
dir = parent;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function isHomeDirectory(dir, env) {
|
|
94
|
-
const home = env.HOME?.trim() ?? env.USERPROFILE?.trim();
|
|
95
|
-
if (!home) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
return resolve(dir) === resolve(home);
|
|
99
|
-
}
|
|
100
|
-
function usablePlanuWorkspaceEnv(env) {
|
|
101
|
-
const fromEnv = env.PLANU_WORKSPACE?.trim();
|
|
102
|
-
if (!fromEnv || fromEnv.includes('${')) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
const expanded = expandHomePrefix(fromEnv, env);
|
|
106
|
-
if (!expanded) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const resolved = resolve(expanded);
|
|
110
|
-
if (resolved.includes(`${sep}~${sep}`) || resolved.endsWith(`${sep}~`)) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
if (isHomeDirectory(resolved, env)) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
return resolved;
|
|
117
|
-
}
|
|
118
|
-
function expandHomePrefix(raw, env) {
|
|
119
|
-
if (raw === '~' || raw.startsWith('~/') || raw.startsWith('~\\')) {
|
|
120
|
-
const home = env.HOME?.trim() ?? env.USERPROFILE?.trim();
|
|
121
|
-
if (!home) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
if (raw === '~') {
|
|
125
|
-
return home;
|
|
126
|
-
}
|
|
127
|
-
return join(home, raw.slice(2));
|
|
128
|
-
}
|
|
129
|
-
return raw;
|
|
130
|
-
}
|
|
4
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { withSourceDescriptor } from './source-descriptor.js';
|
|
6
|
+
export { withSourceDescriptor } from './source-descriptor.js';
|
|
131
7
|
export async function readTextInsideWorkspace(workspaceRoot, absolutePath, options) {
|
|
132
8
|
let root;
|
|
133
9
|
try {
|
|
@@ -221,17 +97,224 @@ async function readBoundedDescriptor(handle, maxBytes) {
|
|
|
221
97
|
}
|
|
222
98
|
return { ok: true, text: bytes.subarray(0, total).toString('utf8') };
|
|
223
99
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
100
|
+
export { parseMcpRootUri, resolveSddWorkspaceRoot, resolveSddWorkspace, isHomeFallbackWorkspace, homeFallbackFailure, } from './client-workspace.js';
|
|
101
|
+
export async function readTextInsideWorkspaceDetailed(workspaceRoot, absolutePath, options) {
|
|
102
|
+
const { maxBytes } = options;
|
|
103
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0 || maxBytes > 65_536) {
|
|
104
|
+
return { ok: false, cause: 'read_failed' };
|
|
105
|
+
}
|
|
106
|
+
const root = resolve(workspaceRoot);
|
|
107
|
+
const local = relative(root, resolve(absolutePath));
|
|
108
|
+
if (!local || local === '..' || local.startsWith(`..${sep}`) || resolve(local) === local) {
|
|
109
|
+
return { ok: false, cause: 'unsafe_path' };
|
|
110
|
+
}
|
|
111
|
+
const result = await withSourceDescriptor(root, local, async (context) => {
|
|
112
|
+
let bytes = new Uint8Array(0);
|
|
113
|
+
while (bytes.length < maxBytes) {
|
|
114
|
+
const next = await context.read(bytes.length, maxBytes - bytes.length);
|
|
115
|
+
if (!next.length) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
bytes = new Uint8Array(next.buffer, next.byteOffset - bytes.length, bytes.length + next.length);
|
|
230
119
|
}
|
|
231
|
-
|
|
232
|
-
|
|
120
|
+
return bytes;
|
|
121
|
+
}, maxBytes);
|
|
122
|
+
if (!result.ok) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
cause: result.cause === 'cancelled' || result.cause === 'capability_unavailable'
|
|
126
|
+
? 'read_failed'
|
|
127
|
+
: result.cause,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
return {
|
|
132
|
+
ok: true,
|
|
133
|
+
text: new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(result.value),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return { ok: false, cause: 'invalid_content' };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const sourceCursorDomain = 'planu.read-cursor.v1';
|
|
141
|
+
const cursorHashPattern = /^[0-9a-f]{64}$/;
|
|
142
|
+
const cursorBase64Pattern = /^[A-Za-z0-9_-]+$/;
|
|
143
|
+
function isCursorInteger(value, min) {
|
|
144
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= min;
|
|
145
|
+
}
|
|
146
|
+
function isSourceCursorPayload(value) {
|
|
147
|
+
if (!Array.isArray(value) || value.length !== 8) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const [domain, kind, root, request, snapshot, consumed, line, offset] = value;
|
|
151
|
+
if (domain !== sourceCursorDomain || kind !== 'source') {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (![root, request, snapshot].every((hash) => typeof hash === 'string' && cursorHashPattern.test(hash))) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (!isCursorInteger(consumed, 1) || !isCursorInteger(line, 1) || !isCursorInteger(offset, 0)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return (line - 1 <= consumed && offset <= consumed - (line - 1) && (line !== 1 || offset === consumed));
|
|
161
|
+
}
|
|
162
|
+
function isCatalogueCursorPayload(value) {
|
|
163
|
+
if (!Array.isArray(value) || value.length !== 6) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
const [domain, kind, root, request, snapshot, lastId] = value;
|
|
167
|
+
return (domain === sourceCursorDomain &&
|
|
168
|
+
kind === 'catalogue' &&
|
|
169
|
+
[root, request, snapshot].every((hash) => typeof hash === 'string' && cursorHashPattern.test(hash)) &&
|
|
170
|
+
typeof lastId === 'string' &&
|
|
171
|
+
/^FEAT[-_][A-Z0-9_-]{1,123}$/u.test(lastId));
|
|
172
|
+
}
|
|
173
|
+
function isReadCursorPayload(value) {
|
|
174
|
+
return isSourceCursorPayload(value) || isCatalogueCursorPayload(value);
|
|
175
|
+
}
|
|
176
|
+
export function sourceRequestSha256(path, startLine, endLine) {
|
|
177
|
+
return createHash('sha256')
|
|
178
|
+
.update(JSON.stringify([sourceCursorDomain, 'source', path, startLine, endLine]))
|
|
179
|
+
.digest('hex');
|
|
180
|
+
}
|
|
181
|
+
export class ReadCursorCodec {
|
|
182
|
+
#key = randomBytes(32);
|
|
183
|
+
encode(payload) {
|
|
184
|
+
if (!isReadCursorPayload(payload)) {
|
|
185
|
+
throw new TypeError('Invalid source cursor payload');
|
|
186
|
+
}
|
|
187
|
+
const mac = createHmac('sha256', this.#key).update(JSON.stringify(payload)).digest('base64url');
|
|
188
|
+
const token = Buffer.from(JSON.stringify([payload, mac]), 'utf8').toString('base64url');
|
|
189
|
+
if (token.length > 1024) {
|
|
190
|
+
throw new TypeError('Invalid source cursor payload');
|
|
191
|
+
}
|
|
192
|
+
return token;
|
|
193
|
+
}
|
|
194
|
+
decode(token) {
|
|
195
|
+
if (typeof token !== 'string' || token.length > 1024 || !cursorBase64Pattern.test(token)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const bytes = Buffer.from(token, 'base64url');
|
|
200
|
+
if (bytes.toString('base64url') !== token) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
const json = new TextDecoder('utf-8', {
|
|
204
|
+
fatal: true,
|
|
205
|
+
ignoreBOM: true,
|
|
206
|
+
}).decode(bytes);
|
|
207
|
+
const envelope = JSON.parse(json);
|
|
208
|
+
if (!Array.isArray(envelope) || envelope.length !== 2 || JSON.stringify(envelope) !== json) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
const [payload, mac] = envelope;
|
|
212
|
+
if (!isReadCursorPayload(payload) ||
|
|
213
|
+
typeof mac !== 'string' ||
|
|
214
|
+
!cursorBase64Pattern.test(mac)) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
const actual = Buffer.from(mac, 'base64url');
|
|
218
|
+
if (actual.length !== 32 || actual.toString('base64url') !== mac) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const expected = createHmac('sha256', this.#key).update(JSON.stringify(payload)).digest();
|
|
222
|
+
return timingSafeEqual(actual, expected) ? payload : null;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const failures = {
|
|
230
|
+
slice_input_invalid: ['ERR_INVALID_SLICE', 'fix_inputs'],
|
|
231
|
+
slice_cursor_invalid: ['ERR_INVALID_SLICE', 'reread_slice'],
|
|
232
|
+
slice_cursor_stale: ['ERR_SPEC_DRIFT', 'reread_slice'],
|
|
233
|
+
slice_path_unsafe: ['ERR_PERMISSION_VIOLATION', 'inspect_artifacts'],
|
|
234
|
+
slice_capability_unavailable: ['ERR_PERMISSION_VIOLATION', 'use_supported_runtime'],
|
|
235
|
+
slice_unavailable: ['ERR_INVALID_SLICE', 'inspect_artifacts'],
|
|
236
|
+
slice_invalid_utf8: ['ERR_INVALID_SLICE', 'inspect_artifacts'],
|
|
237
|
+
slice_range_unavailable: ['ERR_INVALID_SLICE', 'fix_inputs'],
|
|
238
|
+
slice_response_too_large: ['ERR_INVALID_SLICE', 'inspect_artifacts'],
|
|
239
|
+
cancelled: ['ERR_VERIFICATION_FAILED', 'retry_read'],
|
|
240
|
+
};
|
|
241
|
+
export function failure(reason) {
|
|
242
|
+
const [code, nextAction] = failures[reason];
|
|
243
|
+
return {
|
|
244
|
+
success: false,
|
|
245
|
+
error: {
|
|
246
|
+
code,
|
|
247
|
+
message: 'Bounded source read is unavailable.',
|
|
248
|
+
trigger: 'sdd_read_file_slice',
|
|
249
|
+
details: { reason, nextAction },
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
export function slicePath(workspaceRoot, input) {
|
|
254
|
+
const { path, start_line: start, end_line: end } = input;
|
|
255
|
+
if (typeof path !== 'string' ||
|
|
256
|
+
!path ||
|
|
257
|
+
Buffer.byteLength(path, 'utf8') > 4096 ||
|
|
258
|
+
path.includes('\0') ||
|
|
259
|
+
![start, end].every(Number.isSafeInteger) ||
|
|
260
|
+
start < 1 ||
|
|
261
|
+
start > end) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
const local = relative(resolve(workspaceRoot), resolve(workspaceRoot, path));
|
|
265
|
+
if (/^[A-Za-z]:/.test(path) ||
|
|
266
|
+
local === '..' ||
|
|
267
|
+
local.startsWith(`..${sep}`) ||
|
|
268
|
+
isAbsolute(local)) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
const parts = path.split('/');
|
|
272
|
+
if (isAbsolute(path)) {
|
|
273
|
+
parts.shift();
|
|
274
|
+
}
|
|
275
|
+
return !local || parts.some((part) => ['', '.', '..'].includes(part) || part.includes('\\'))
|
|
276
|
+
? undefined
|
|
277
|
+
: local;
|
|
278
|
+
}
|
|
279
|
+
export function descriptorFailure(cause, cursor) {
|
|
280
|
+
switch (cause) {
|
|
281
|
+
case 'cancelled':
|
|
282
|
+
return 'cancelled';
|
|
283
|
+
case 'capability_unavailable':
|
|
284
|
+
return 'slice_capability_unavailable';
|
|
285
|
+
case 'unstable':
|
|
286
|
+
return 'slice_cursor_stale';
|
|
287
|
+
case 'not_found':
|
|
288
|
+
return cursor ? 'slice_cursor_stale' : 'slice_unavailable';
|
|
289
|
+
case 'unsafe_path':
|
|
290
|
+
return cursor ? 'slice_cursor_stale' : 'slice_path_unsafe';
|
|
291
|
+
case 'access_denied':
|
|
292
|
+
case 'invalid_content':
|
|
293
|
+
case 'over_limit':
|
|
294
|
+
case 'read_failed':
|
|
295
|
+
return 'slice_unavailable';
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
export function initialPosition(cursor, snapshot, input) {
|
|
299
|
+
if (!cursor) {
|
|
300
|
+
return { consumedBytes: 0, line: 1, lineOffsetBytes: 0 };
|
|
301
|
+
}
|
|
302
|
+
const [, , rootHash, , snapshotHash, consumedBytes, line, lineOffsetBytes] = cursor;
|
|
303
|
+
if (rootHash !== snapshot.rootIdentitySha256 || snapshotHash !== snapshot.snapshotSha256) {
|
|
304
|
+
return 'slice_cursor_stale';
|
|
305
|
+
}
|
|
306
|
+
if (consumedBytes >= snapshot.size || line > input.end_line) {
|
|
307
|
+
return 'slice_cursor_invalid';
|
|
308
|
+
}
|
|
309
|
+
return { consumedBytes, line, lineOffsetBytes };
|
|
310
|
+
}
|
|
311
|
+
export function requestCursor(input, path, codec) {
|
|
312
|
+
const cursor = input.cursor === undefined ? null : codec.decode(input.cursor);
|
|
313
|
+
if (input.cursor !== undefined &&
|
|
314
|
+
(cursor?.[1] !== 'source' ||
|
|
315
|
+
cursor[3] !== sourceRequestSha256(path, input.start_line, input.end_line))) {
|
|
316
|
+
return undefined;
|
|
233
317
|
}
|
|
234
|
-
return
|
|
318
|
+
return cursor?.[1] === 'source' ? cursor : null;
|
|
235
319
|
}
|
|
236
|
-
export { readTextInsideWorkspaceDetailed } from './host-skill-reader.js';
|
|
237
320
|
//# sourceMappingURL=workspace-root.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { KeyObject } from 'node:crypto';
|
|
2
2
|
import type { BigIntStats } from 'node:fs';
|
|
3
|
-
import type { SddLockFile, ErrorCode, TrinityIssue, FilePermission,
|
|
4
|
-
import type { ScopedVerificationSnapshot, ScopedTaskSelector, ScopedTaskSelection, VerificationBudgetDiagnostic } from './verification.js';
|
|
3
|
+
import type { HostSkillReadCause, FeatureSummary, SddLockFile, ErrorCode, TrinityIssue, FilePermission, SddResult, CompleteTaskResult, CheckpointJournalReference } from './sdd-engine.js';
|
|
4
|
+
import type { VerificationGate, VerificationReceipt, VerificationPreflight, ScopedVerificationSnapshot, ScopedTaskSelector, ScopedTaskSelection, VerificationBudgetDiagnostic } from './verification.js';
|
|
5
5
|
export type CompletionFailureReason = 'guard_present' | 'contract_drift' | 'cancelled' | 'persistence_uncertain';
|
|
6
6
|
export interface PhysicalIdentity {
|
|
7
7
|
dev: number;
|
|
@@ -260,5 +260,49 @@ export interface VerificationBudgetContext {
|
|
|
260
260
|
export type BudgetDeniedReason = Extract<VerificationBudgetDiagnostic, {
|
|
261
261
|
admission: 'denied';
|
|
262
262
|
}>['reason'];
|
|
263
|
+
export interface SourceDescriptorSnapshot {
|
|
264
|
+
readonly size: number;
|
|
265
|
+
readonly rootIdentitySha256: string;
|
|
266
|
+
readonly snapshotSha256: string;
|
|
267
|
+
}
|
|
268
|
+
export interface SourceDescriptorContext {
|
|
269
|
+
readonly snapshot: SourceDescriptorSnapshot;
|
|
270
|
+
read(position: number, length: number): Promise<Uint8Array>;
|
|
271
|
+
}
|
|
272
|
+
export type SourceDescriptorCallback<T> = (context: SourceDescriptorContext) => Promise<T>;
|
|
273
|
+
export type SourceDescriptorFailure = HostSkillReadCause | 'cancelled' | 'capability_unavailable';
|
|
274
|
+
export type SourceDescriptorResult<T> = {
|
|
275
|
+
ok: true;
|
|
276
|
+
value: T;
|
|
277
|
+
} | {
|
|
278
|
+
ok: false;
|
|
279
|
+
cause: SourceDescriptorFailure;
|
|
280
|
+
};
|
|
281
|
+
export interface CatalogueFileCapture {
|
|
282
|
+
rootIdentitySha256: string;
|
|
283
|
+
content: string;
|
|
284
|
+
rawSha256: string;
|
|
285
|
+
descriptor: string;
|
|
286
|
+
}
|
|
287
|
+
export interface CatalogueArtifactCapture {
|
|
288
|
+
directories: AuthorityDirectory[];
|
|
289
|
+
tasks: CatalogueFileCapture;
|
|
290
|
+
lock: CatalogueFileCapture | null;
|
|
291
|
+
}
|
|
292
|
+
export type CatalogueError = 'catalogue_input_invalid' | 'catalogue_cursor_invalid' | 'catalogue_cursor_stale' | 'catalogue_identifier_invalid' | 'catalogue_response_too_large' | 'catalogue_unavailable' | 'catalogue_path_unsafe' | 'catalogue_capability_unavailable' | 'guard_present' | 'persistence_uncertain' | 'cancelled';
|
|
293
|
+
export type DescriptorProfile = 'source' | 'catalogue' | number;
|
|
294
|
+
export interface CatalogueHead {
|
|
295
|
+
root: string;
|
|
296
|
+
rootHash: string;
|
|
297
|
+
identity: string[];
|
|
298
|
+
sddIdentity: string[] | null;
|
|
299
|
+
featuresIdentity: string[] | null;
|
|
300
|
+
features: string;
|
|
301
|
+
names: string[];
|
|
302
|
+
}
|
|
303
|
+
export interface CatalogueSnapshot {
|
|
304
|
+
entries: FeatureSummary[];
|
|
305
|
+
digest: string;
|
|
306
|
+
}
|
|
263
307
|
export {};
|
|
264
308
|
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -233,7 +233,8 @@ export interface EngineCapabilitiesV1 {
|
|
|
233
233
|
'sdd_get_active_task'
|
|
234
234
|
];
|
|
235
235
|
readonly views: {
|
|
236
|
-
readonly sdd_list_features: readonly ['setup_diagnostics'];
|
|
236
|
+
readonly sdd_list_features: readonly ['setup_diagnostics', 'catalogue'];
|
|
237
|
+
readonly sdd_read_file_slice?: readonly ['bounded'];
|
|
237
238
|
readonly sdd_get_active_task: readonly [
|
|
238
239
|
'verification_preflight',
|
|
239
240
|
'resume',
|
|
@@ -247,6 +248,8 @@ export interface EngineCapabilitiesV1 {
|
|
|
247
248
|
readonly sdd_lock_spec: readonly ['lock', 'evidence_checkpoint'];
|
|
248
249
|
};
|
|
249
250
|
readonly observations: {
|
|
251
|
+
readonly featureCatalogue: 1;
|
|
252
|
+
readonly sourceSlice?: 1;
|
|
250
253
|
readonly setupDiagnostics: 1;
|
|
251
254
|
readonly verificationPreflight: 1;
|
|
252
255
|
readonly resume: 1;
|
|
@@ -259,6 +262,14 @@ export interface EngineCapabilitiesV1 {
|
|
|
259
262
|
readonly verificationProcess: 1;
|
|
260
263
|
};
|
|
261
264
|
readonly limits: {
|
|
265
|
+
readonly featureCataloguePageSizeDefault: 16;
|
|
266
|
+
readonly featureCataloguePageSizeMax: 32;
|
|
267
|
+
readonly featureCatalogueQueryBytes: 128;
|
|
268
|
+
readonly featureCatalogueCursorCharacters: 1024;
|
|
269
|
+
readonly sourceSliceBytes?: 65536;
|
|
270
|
+
readonly sourceSliceReadCalls?: 64;
|
|
271
|
+
readonly sourceSliceLines?: 200;
|
|
272
|
+
readonly sourceSliceCursorCharacters?: 1024;
|
|
262
273
|
readonly compactTextBytes: 8192;
|
|
263
274
|
readonly defaultVerificationTimeoutMs: 180000;
|
|
264
275
|
};
|
|
@@ -312,4 +323,28 @@ export interface HostScanRow extends HostScanTarget {
|
|
|
312
323
|
read: HostSkillReadResult;
|
|
313
324
|
matches: boolean;
|
|
314
325
|
}
|
|
326
|
+
export interface SourceProgress {
|
|
327
|
+
consumedBytes: number;
|
|
328
|
+
line: number;
|
|
329
|
+
lineOffsetBytes: number;
|
|
330
|
+
}
|
|
331
|
+
export type SourceCursorPayload = [
|
|
332
|
+
domain: 'planu.read-cursor.v1',
|
|
333
|
+
kind: 'source',
|
|
334
|
+
rootIdentitySha256: string,
|
|
335
|
+
requestSha256: string,
|
|
336
|
+
snapshotSha256: string,
|
|
337
|
+
consumedBytes: number,
|
|
338
|
+
line: number,
|
|
339
|
+
lineOffsetBytes: number
|
|
340
|
+
];
|
|
341
|
+
export type CatalogueCursorPayload = [
|
|
342
|
+
domain: 'planu.read-cursor.v1',
|
|
343
|
+
kind: 'catalogue',
|
|
344
|
+
rootIdentitySha256: string,
|
|
345
|
+
requestSha256: string,
|
|
346
|
+
snapshotSha256: string,
|
|
347
|
+
lastId: string
|
|
348
|
+
];
|
|
349
|
+
export type ReadCursorPayload = SourceCursorPayload | CatalogueCursorPayload;
|
|
315
350
|
//# sourceMappingURL=resume-views.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VerificationEvidence, VerificationPreflight, VerificationProcessEvidence } from './verification.js';
|
|
2
|
+
export type { VerificationReceipt, ReceiptRejectionReason, ReceiptSetResult, GateAssessment, PreflightBlockerReason, PreflightAction, VerificationPreflight, ReceiptSetAssessment, VerificationGate, VerificationEvidence, } from './verification.js';
|
|
2
3
|
export type TrinityRule = 'out_of_scope' | 'error_matrix' | 'bdd' | 'frozen_dependencies' | 'manifest_path' | 'checkbox_task' | 'glob_delete' | 'protected_write' | 'receipt_policy_invalid' | 'artifact_missing' | 'artifact_unreadable';
|
|
3
4
|
export interface TrinityIssue {
|
|
4
5
|
artifact: 'spec.md' | 'plan.md' | 'tasks.md';
|
|
@@ -15,49 +16,6 @@ export interface ReceiptSealFailure {
|
|
|
15
16
|
issues: TrinityIssue[];
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
export type VerificationReceipt = Omit<VerificationEvidence, 'gates'> & {
|
|
19
|
-
gateId: string;
|
|
20
|
-
procedureSha256: string;
|
|
21
|
-
environmentSha256: string;
|
|
22
|
-
outcome: 'pass' | 'fail' | 'skipped' | 'partial';
|
|
23
|
-
evidenceSha256: string;
|
|
24
|
-
signature: string;
|
|
25
|
-
};
|
|
26
|
-
export type ReceiptRejectionReason = 'receipt_malformed' | 'receipt_missing' | 'receipt_duplicate' | 'receipt_unexpected' | 'receipt_invalid_signature' | 'receipt_context_mismatch' | 'receipt_candidate_mismatch' | 'receipt_observed_mismatch' | 'receipt_procedure_mismatch' | 'receipt_environment_mismatch' | 'receipt_non_pass';
|
|
27
|
-
export type ReceiptSetResult = {
|
|
28
|
-
ok: true;
|
|
29
|
-
gateCount: number;
|
|
30
|
-
receiptSetSha256: string;
|
|
31
|
-
} | {
|
|
32
|
-
ok: false;
|
|
33
|
-
reason: ReceiptRejectionReason;
|
|
34
|
-
gateId?: string;
|
|
35
|
-
};
|
|
36
|
-
export interface GateAssessment {
|
|
37
|
-
gateId: string;
|
|
38
|
-
state: 'receipt_valid' | 'receipt_missing' | 'receipt_rejected';
|
|
39
|
-
reason?: ReceiptRejectionReason;
|
|
40
|
-
}
|
|
41
|
-
export type PreflightBlockerReason = ReceiptRejectionReason | 'unlocked' | 'command_missing' | 'platform_unsupported' | 'receipt_input_unavailable' | 'receipt_observed_baseline_drift' | 'receipt_scoped_unsupported' | 'receipt_not_configured' | 'verification_policy_mismatch' | 'verification_policy_workspace_mismatch' | 'verification_state_unavailable' | 'verification_in_progress' | 'verification_grant_consumed' | 'verification_grant_quarantined';
|
|
42
|
-
interface PreflightBlocker {
|
|
43
|
-
reason: PreflightBlockerReason;
|
|
44
|
-
}
|
|
45
|
-
export type PreflightAction = 'fix_inputs' | 'review_observed_drift' | 'obtain_receipts' | 'use_supported_runtime' | 'review_lock' | 'review_verification_policy' | 'restore_verification' | 'attempt_integration' | 'none';
|
|
46
|
-
export interface VerificationPreflight {
|
|
47
|
-
budget?: VerificationBudgetDiagnostic;
|
|
48
|
-
version: 1;
|
|
49
|
-
taskId: string | null;
|
|
50
|
-
status: 'blocked' | 'ready_to_attempt' | 'not_applicable';
|
|
51
|
-
gates: GateAssessment[];
|
|
52
|
-
blockers: PreflightBlocker[];
|
|
53
|
-
integration: 'not_run';
|
|
54
|
-
nextAction: PreflightAction;
|
|
55
|
-
}
|
|
56
|
-
export interface ReceiptSetAssessment {
|
|
57
|
-
result: ReceiptSetResult;
|
|
58
|
-
gates: GateAssessment[];
|
|
59
|
-
blockers: PreflightBlocker[];
|
|
60
|
-
}
|
|
61
19
|
export type ArtifactType = 'spec' | 'plan' | 'tasks';
|
|
62
20
|
export type FilePermission = 'CREATE' | 'MODIFY' | 'READ_ONLY' | 'DELETE';
|
|
63
21
|
export type ErrorCode = 'ERR_FEATURE_NOT_FOUND' | 'ERR_FEATURE_ALREADY_EXISTS' | 'ERR_SPEC_NOT_LOCKED' | 'ERR_SPEC_ALREADY_LOCKED' | 'ERR_SPEC_DRIFT' | 'ERR_TASK_OUT_OF_SEQUENCE' | 'ERR_TASK_NOT_FOUND' | 'ERR_FILE_OUT_OF_MANIFEST' | 'ERR_PERMISSION_VIOLATION' | 'ERR_PATCH_FAILED' | 'ERR_INVALID_ARTIFACT' | 'ERR_INVALID_SLICE' | 'ERR_WORKSPACE_UNRESOLVED' | 'ERR_TRINITY_INCOMPLETE' | 'ERR_LOCK_REASON_REQUIRED' | 'ERR_VERIFICATION_MISSING' | 'ERR_VERIFICATION_FAILED';
|
|
@@ -82,7 +40,10 @@ export interface InitWorkspaceInput {
|
|
|
82
40
|
}
|
|
83
41
|
export interface ListFeaturesInput {
|
|
84
42
|
status_filter?: 'all' | 'planning' | 'executing' | 'done';
|
|
85
|
-
view?: 'setup_diagnostics';
|
|
43
|
+
view?: 'setup_diagnostics' | 'catalogue';
|
|
44
|
+
query?: string;
|
|
45
|
+
page_size?: number;
|
|
46
|
+
cursor?: string;
|
|
86
47
|
host?: 'all' | 'claude' | 'cursor' | 'codex' | 'gemini';
|
|
87
48
|
}
|
|
88
49
|
export interface CreateFeatureInput {
|
|
@@ -127,10 +88,31 @@ export interface ReadSpecArtifactInput {
|
|
|
127
88
|
feature_id: string;
|
|
128
89
|
artifact: ArtifactType;
|
|
129
90
|
}
|
|
91
|
+
export interface SourceSegmentV1 {
|
|
92
|
+
line: number;
|
|
93
|
+
lineOffsetBytes: number;
|
|
94
|
+
text: string;
|
|
95
|
+
endsLine: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface SourcePageV1 {
|
|
98
|
+
version: 1;
|
|
99
|
+
snapshotSha256: string;
|
|
100
|
+
requested: {
|
|
101
|
+
startLine: number;
|
|
102
|
+
endLine: number;
|
|
103
|
+
};
|
|
104
|
+
phase: 'seeking' | 'reading' | 'complete';
|
|
105
|
+
segments: SourceSegmentV1[];
|
|
106
|
+
reachedEof: boolean;
|
|
107
|
+
continuation: 'work_limit' | 'response_limit' | 'line_limit' | null;
|
|
108
|
+
nextCursor: string | null;
|
|
109
|
+
}
|
|
130
110
|
export interface ReadFileSliceInput {
|
|
131
111
|
path: string;
|
|
132
112
|
start_line: number;
|
|
133
113
|
end_line: number;
|
|
114
|
+
view?: 'bounded';
|
|
115
|
+
cursor?: string;
|
|
134
116
|
}
|
|
135
117
|
export interface RelockHistoryCursor {
|
|
136
118
|
snapshotSha256: string;
|
|
@@ -163,21 +145,6 @@ export interface ApplyFilePatchInput {
|
|
|
163
145
|
search_content: string;
|
|
164
146
|
replace_content: string;
|
|
165
147
|
}
|
|
166
|
-
export interface VerificationGate {
|
|
167
|
-
id: string;
|
|
168
|
-
procedureSha256: string;
|
|
169
|
-
environmentSha256: string;
|
|
170
|
-
}
|
|
171
|
-
export interface VerificationEvidence {
|
|
172
|
-
version: 1;
|
|
173
|
-
featureId: string;
|
|
174
|
-
taskId: string;
|
|
175
|
-
workspaceSha256: string;
|
|
176
|
-
lockSha256: string;
|
|
177
|
-
candidateSha256: string;
|
|
178
|
-
observedSha256: string;
|
|
179
|
-
gates: readonly VerificationGate[];
|
|
180
|
-
}
|
|
181
148
|
export interface CompleteTaskInput {
|
|
182
149
|
feature_id: string;
|
|
183
150
|
task_id: string;
|
|
@@ -225,6 +192,14 @@ export interface CompleteTaskResult {
|
|
|
225
192
|
receiptSetSha256: string;
|
|
226
193
|
};
|
|
227
194
|
}
|
|
195
|
+
export interface CataloguePageV1 {
|
|
196
|
+
version: 1;
|
|
197
|
+
snapshotSha256: string;
|
|
198
|
+
total: number;
|
|
199
|
+
offset: number;
|
|
200
|
+
entries: FeatureSummary[];
|
|
201
|
+
nextCursor: string | null;
|
|
202
|
+
}
|
|
228
203
|
export interface FeatureSummary {
|
|
229
204
|
id: string;
|
|
230
205
|
status: 'planning' | 'executing' | 'done';
|
|
@@ -296,5 +271,4 @@ export type HostSkillReadResult = {
|
|
|
296
271
|
ok: false;
|
|
297
272
|
cause: HostSkillReadCause;
|
|
298
273
|
};
|
|
299
|
-
export {};
|
|
300
274
|
//# sourceMappingURL=sdd-engine.d.ts.map
|