@planu/cli 8.8.0 → 8.9.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.
@@ -1,133 +1,9 @@
1
- import { constants, existsSync } from 'node:fs';
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 { dirname, join, resolve, sep } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- const ERR_WORKSPACE_UNRESOLVED_MESSAGE = 'Resolved workspace is the user home directory without MCP roots or PLANU_WORKSPACE. Set the MCP server cwd to the project, advertise MCP roots, or set a per-process PLANU_WORKSPACE. Do not pin PLANU_WORKSPACE globally.';
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,206 @@ async function readBoundedDescriptor(handle, maxBytes) {
221
97
  }
222
98
  return { ok: true, text: bytes.subarray(0, total).toString('utf8') };
223
99
  }
224
- function unique(values) {
225
- const seen = new Set();
226
- const out = [];
227
- for (const value of values) {
228
- if (seen.has(value)) {
229
- continue;
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);
119
+ }
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
+ export function sourceRequestSha256(path, startLine, endLine) {
163
+ return createHash('sha256')
164
+ .update(JSON.stringify([sourceCursorDomain, 'source', path, startLine, endLine]))
165
+ .digest('hex');
166
+ }
167
+ export class ReadCursorCodec {
168
+ #key = randomBytes(32);
169
+ encode(payload) {
170
+ if (!isSourceCursorPayload(payload)) {
171
+ throw new TypeError('Invalid source cursor payload');
172
+ }
173
+ const mac = createHmac('sha256', this.#key).update(JSON.stringify(payload)).digest('base64url');
174
+ const token = Buffer.from(JSON.stringify([payload, mac]), 'utf8').toString('base64url');
175
+ if (token.length > 1024) {
176
+ throw new TypeError('Invalid source cursor payload');
230
177
  }
231
- seen.add(value);
232
- out.push(value);
178
+ return token;
179
+ }
180
+ decode(token) {
181
+ if (typeof token !== 'string' || token.length > 1024 || !cursorBase64Pattern.test(token)) {
182
+ return null;
183
+ }
184
+ try {
185
+ const bytes = Buffer.from(token, 'base64url');
186
+ if (bytes.toString('base64url') !== token) {
187
+ return null;
188
+ }
189
+ const json = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
190
+ const envelope = JSON.parse(json);
191
+ if (!Array.isArray(envelope) || envelope.length !== 2 || JSON.stringify(envelope) !== json) {
192
+ return null;
193
+ }
194
+ const [payload, mac] = envelope;
195
+ if (!isSourceCursorPayload(payload) ||
196
+ typeof mac !== 'string' ||
197
+ !cursorBase64Pattern.test(mac)) {
198
+ return null;
199
+ }
200
+ const actual = Buffer.from(mac, 'base64url');
201
+ if (actual.length !== 32 || actual.toString('base64url') !== mac) {
202
+ return null;
203
+ }
204
+ const expected = createHmac('sha256', this.#key).update(JSON.stringify(payload)).digest();
205
+ return timingSafeEqual(actual, expected) ? payload : null;
206
+ }
207
+ catch {
208
+ return null;
209
+ }
210
+ }
211
+ }
212
+ const failures = {
213
+ slice_input_invalid: ['ERR_INVALID_SLICE', 'fix_inputs'],
214
+ slice_cursor_invalid: ['ERR_INVALID_SLICE', 'reread_slice'],
215
+ slice_cursor_stale: ['ERR_SPEC_DRIFT', 'reread_slice'],
216
+ slice_path_unsafe: ['ERR_PERMISSION_VIOLATION', 'inspect_artifacts'],
217
+ slice_capability_unavailable: ['ERR_PERMISSION_VIOLATION', 'use_supported_runtime'],
218
+ slice_unavailable: ['ERR_INVALID_SLICE', 'inspect_artifacts'],
219
+ slice_invalid_utf8: ['ERR_INVALID_SLICE', 'inspect_artifacts'],
220
+ slice_range_unavailable: ['ERR_INVALID_SLICE', 'fix_inputs'],
221
+ slice_response_too_large: ['ERR_INVALID_SLICE', 'inspect_artifacts'],
222
+ cancelled: ['ERR_VERIFICATION_FAILED', 'retry_read'],
223
+ };
224
+ export function failure(reason) {
225
+ const [code, nextAction] = failures[reason];
226
+ return {
227
+ success: false,
228
+ error: {
229
+ code,
230
+ message: 'Bounded source read is unavailable.',
231
+ trigger: 'sdd_read_file_slice',
232
+ details: { reason, nextAction },
233
+ },
234
+ };
235
+ }
236
+ export function slicePath(workspaceRoot, input) {
237
+ const { path, start_line: start, end_line: end } = input;
238
+ if (typeof path !== 'string' ||
239
+ !path ||
240
+ Buffer.byteLength(path, 'utf8') > 4096 ||
241
+ path.includes('\0') ||
242
+ ![start, end].every(Number.isSafeInteger) ||
243
+ start < 1 ||
244
+ start > end) {
245
+ return undefined;
246
+ }
247
+ const local = relative(resolve(workspaceRoot), resolve(workspaceRoot, path));
248
+ if (/^[A-Za-z]:/.test(path) ||
249
+ local === '..' ||
250
+ local.startsWith(`..${sep}`) ||
251
+ isAbsolute(local)) {
252
+ return null;
253
+ }
254
+ const parts = path.split('/');
255
+ if (isAbsolute(path)) {
256
+ parts.shift();
257
+ }
258
+ return !local || parts.some((part) => ['', '.', '..'].includes(part) || part.includes('\\'))
259
+ ? undefined
260
+ : local;
261
+ }
262
+ export function descriptorFailure(cause, cursor) {
263
+ switch (cause) {
264
+ case 'cancelled':
265
+ return 'cancelled';
266
+ case 'capability_unavailable':
267
+ return 'slice_capability_unavailable';
268
+ case 'unstable':
269
+ return 'slice_cursor_stale';
270
+ case 'not_found':
271
+ return cursor ? 'slice_cursor_stale' : 'slice_unavailable';
272
+ case 'unsafe_path':
273
+ return cursor ? 'slice_cursor_stale' : 'slice_path_unsafe';
274
+ case 'access_denied':
275
+ case 'invalid_content':
276
+ case 'over_limit':
277
+ case 'read_failed':
278
+ return 'slice_unavailable';
279
+ }
280
+ }
281
+ export function initialPosition(cursor, snapshot, input) {
282
+ if (!cursor) {
283
+ return { consumedBytes: 0, line: 1, lineOffsetBytes: 0 };
284
+ }
285
+ const [, , rootHash, , snapshotHash, consumedBytes, line, lineOffsetBytes] = cursor;
286
+ if (rootHash !== snapshot.rootIdentitySha256 || snapshotHash !== snapshot.snapshotSha256) {
287
+ return 'slice_cursor_stale';
288
+ }
289
+ if (consumedBytes >= snapshot.size || line > input.end_line) {
290
+ return 'slice_cursor_invalid';
291
+ }
292
+ return { consumedBytes, line, lineOffsetBytes };
293
+ }
294
+ export function requestCursor(input, path, codec) {
295
+ const cursor = input.cursor === undefined ? null : codec.decode(input.cursor);
296
+ if (input.cursor !== undefined &&
297
+ cursor?.[3] !== sourceRequestSha256(path, input.start_line, input.end_line)) {
298
+ return undefined;
233
299
  }
234
- return out;
300
+ return cursor;
235
301
  }
236
- export { readTextInsideWorkspaceDetailed } from './host-skill-reader.js';
237
302
  //# 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, VerificationGate, VerificationReceipt, SddResult, CompleteTaskResult, CheckpointJournalReference, VerificationPreflight } from './sdd-engine.js';
4
- import type { ScopedVerificationSnapshot, ScopedTaskSelector, ScopedTaskSelection, VerificationBudgetDiagnostic } from './verification.js';
3
+ import type { HostSkillReadCause, 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,23 @@ 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
+ };
263
281
  export {};
264
282
  //# sourceMappingURL=completion.d.ts.map
@@ -234,6 +234,7 @@ export interface EngineCapabilitiesV1 {
234
234
  ];
235
235
  readonly views: {
236
236
  readonly sdd_list_features: readonly ['setup_diagnostics'];
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,7 @@ export interface EngineCapabilitiesV1 {
247
248
  readonly sdd_lock_spec: readonly ['lock', 'evidence_checkpoint'];
248
249
  };
249
250
  readonly observations: {
251
+ readonly sourceSlice?: 1;
250
252
  readonly setupDiagnostics: 1;
251
253
  readonly verificationPreflight: 1;
252
254
  readonly resume: 1;
@@ -259,6 +261,10 @@ export interface EngineCapabilitiesV1 {
259
261
  readonly verificationProcess: 1;
260
262
  };
261
263
  readonly limits: {
264
+ readonly sourceSliceBytes?: 65536;
265
+ readonly sourceSliceReadCalls?: 64;
266
+ readonly sourceSliceLines?: 200;
267
+ readonly sourceSliceCursorCharacters?: 1024;
262
268
  readonly compactTextBytes: 8192;
263
269
  readonly defaultVerificationTimeoutMs: 180000;
264
270
  };
@@ -312,4 +318,19 @@ export interface HostScanRow extends HostScanTarget {
312
318
  read: HostSkillReadResult;
313
319
  matches: boolean;
314
320
  }
321
+ export interface SourceProgress {
322
+ consumedBytes: number;
323
+ line: number;
324
+ lineOffsetBytes: number;
325
+ }
326
+ export type SourceCursorPayload = [
327
+ domain: 'planu.read-cursor.v1',
328
+ kind: 'source',
329
+ rootIdentitySha256: string,
330
+ requestSha256: string,
331
+ snapshotSha256: string,
332
+ consumedBytes: number,
333
+ line: number,
334
+ lineOffsetBytes: number
335
+ ];
315
336
  //# sourceMappingURL=resume-views.d.ts.map
@@ -1,4 +1,5 @@
1
- import type { VerificationBudgetDiagnostic, VerificationProcessEvidence } from './verification.js';
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';
@@ -127,10 +85,31 @@ export interface ReadSpecArtifactInput {
127
85
  feature_id: string;
128
86
  artifact: ArtifactType;
129
87
  }
88
+ export interface SourceSegmentV1 {
89
+ line: number;
90
+ lineOffsetBytes: number;
91
+ text: string;
92
+ endsLine: boolean;
93
+ }
94
+ export interface SourcePageV1 {
95
+ version: 1;
96
+ snapshotSha256: string;
97
+ requested: {
98
+ startLine: number;
99
+ endLine: number;
100
+ };
101
+ phase: 'seeking' | 'reading' | 'complete';
102
+ segments: SourceSegmentV1[];
103
+ reachedEof: boolean;
104
+ continuation: 'work_limit' | 'response_limit' | 'line_limit' | null;
105
+ nextCursor: string | null;
106
+ }
130
107
  export interface ReadFileSliceInput {
131
108
  path: string;
132
109
  start_line: number;
133
110
  end_line: number;
111
+ view?: 'bounded';
112
+ cursor?: string;
134
113
  }
135
114
  export interface RelockHistoryCursor {
136
115
  snapshotSha256: string;
@@ -163,21 +142,6 @@ export interface ApplyFilePatchInput {
163
142
  search_content: string;
164
143
  replace_content: string;
165
144
  }
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
145
  export interface CompleteTaskInput {
182
146
  feature_id: string;
183
147
  task_id: string;
@@ -296,5 +260,4 @@ export type HostSkillReadResult = {
296
260
  ok: false;
297
261
  cause: HostSkillReadCause;
298
262
  };
299
- export {};
300
263
  //# sourceMappingURL=sdd-engine.d.ts.map
@@ -97,4 +97,63 @@ export interface VerificationProcessEvidence {
97
97
  readonly cleanupScope: 'owned_process_group';
98
98
  readonly fixturePostconditions: 'unknown';
99
99
  }
100
+ export type VerificationReceipt = Omit<VerificationEvidence, 'gates'> & {
101
+ gateId: string;
102
+ procedureSha256: string;
103
+ environmentSha256: string;
104
+ outcome: 'pass' | 'fail' | 'skipped' | 'partial';
105
+ evidenceSha256: string;
106
+ signature: string;
107
+ };
108
+ 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';
109
+ export type ReceiptSetResult = {
110
+ ok: true;
111
+ gateCount: number;
112
+ receiptSetSha256: string;
113
+ } | {
114
+ ok: false;
115
+ reason: ReceiptRejectionReason;
116
+ gateId?: string;
117
+ };
118
+ export interface GateAssessment {
119
+ gateId: string;
120
+ state: 'receipt_valid' | 'receipt_missing' | 'receipt_rejected';
121
+ reason?: ReceiptRejectionReason;
122
+ }
123
+ 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';
124
+ interface PreflightBlocker {
125
+ reason: PreflightBlockerReason;
126
+ }
127
+ export type PreflightAction = 'fix_inputs' | 'review_observed_drift' | 'obtain_receipts' | 'use_supported_runtime' | 'review_lock' | 'review_verification_policy' | 'restore_verification' | 'attempt_integration' | 'none';
128
+ export interface VerificationPreflight {
129
+ budget?: VerificationBudgetDiagnostic;
130
+ version: 1;
131
+ taskId: string | null;
132
+ status: 'blocked' | 'ready_to_attempt' | 'not_applicable';
133
+ gates: GateAssessment[];
134
+ blockers: PreflightBlocker[];
135
+ integration: 'not_run';
136
+ nextAction: PreflightAction;
137
+ }
138
+ export interface ReceiptSetAssessment {
139
+ result: ReceiptSetResult;
140
+ gates: GateAssessment[];
141
+ blockers: PreflightBlocker[];
142
+ }
143
+ export interface VerificationGate {
144
+ id: string;
145
+ procedureSha256: string;
146
+ environmentSha256: string;
147
+ }
148
+ export interface VerificationEvidence {
149
+ version: 1;
150
+ featureId: string;
151
+ taskId: string;
152
+ workspaceSha256: string;
153
+ lockSha256: string;
154
+ candidateSha256: string;
155
+ observedSha256: string;
156
+ gates: readonly VerificationGate[];
157
+ }
158
+ export {};
100
159
  //# sourceMappingURL=verification.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "8.8.0",
3
+ "version": "8.9.0",
4
4
  "description": "Planu — MCP server for Spec Driven Development. Planning and file operations on macOS/Linux/Windows; automated verification requires macOS/Linux (POSIX).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,6 +11,8 @@ After the local client has registered the MCP server and the intended project is
11
11
 
12
12
  ## Read-only diagnostics
13
13
 
14
+ For an opt-in bounded source read, first require `engineCapabilities.version=1`, `views.sdd_read_file_slice` containing `bounded`, and `observations.sourceSlice=1` in setup diagnostics. Treat an absent or unknown descriptor version or capability value as unsupported; do not probe a mutation. Use `sdd_read_file_slice` with `view="bounded"` and the required path and line range. Follow a non-null `nextCursor` read-only on the same server instance, repeating the same normalized path and range; the cursor is bound to that server, root, request and physical snapshot. Stop when `nextCursor` is null. The physical snapshot digest is not a content checksum. A same-UID replacement after the last filesystem check is not transactionally excluded. This view and its cursor grant no permission, retry authority or verification time. The default legacy read remains unchanged.
15
+
14
16
  Use `sdd_list_features.hostSkills` to identify fixed installed role paths, causes and the bundled reference version. `catalog` stays `unverified` even when files match. An unavailable baseline requires inspecting the installation; unsafe paths require inspection before authorized setup. Project setup and client catalogue reload are explicit, separate actions.
15
17
 
16
18
  For a rejected `sdd_lock_spec`, inspect `error.details.issues` for artifact, stable rule and optional 1-based original source line. Missing or ambiguous locations omit the line. Existing rejection codes and legacy details remain authoritative; rejection writes no lock. Do not automatically relock.
@@ -10,6 +10,8 @@ After the local client has registered the MCP server and the intended project is
10
10
 
11
11
  ## Read-only diagnostics
12
12
 
13
+ For an opt-in bounded source read, first require `engineCapabilities.version=1`, `views.sdd_read_file_slice` containing `bounded`, and `observations.sourceSlice=1` in setup diagnostics. Treat an absent or unknown descriptor version or capability value as unsupported; do not probe a mutation. Use `sdd_read_file_slice` with `view="bounded"` and the required path and line range. Follow a non-null `nextCursor` read-only on the same server instance, repeating the same normalized path and range; the cursor is bound to that server, root, request and physical snapshot. Stop when `nextCursor` is null. The physical snapshot digest is not a content checksum. A same-UID replacement after the last filesystem check is not transactionally excluded. This view and its cursor grant no permission, retry authority or verification time. The default legacy read remains unchanged.
14
+
13
15
  Use `sdd_list_features.hostSkills` to identify fixed installed role paths, causes and the bundled reference version. `catalog` stays `unverified` even when files match. An unavailable baseline requires inspecting the installation; unsafe paths require inspection before authorized setup. Project setup and client catalogue reload are explicit, separate actions.
14
16
 
15
17
  For a rejected `sdd_lock_spec`, inspect `error.details.issues` for artifact, stable rule and optional 1-based original source line. Missing or ambiguous locations omit the line. Existing rejection codes and legacy details remain authoritative; rejection writes no lock. Do not automatically relock.
@@ -54,6 +54,8 @@ Preflight never edits product files and never marks tasks complete.
54
54
 
55
55
  ## Connection and read-only views
56
56
 
57
+ For an opt-in bounded source read, first require `engineCapabilities.version=1`, `views.sdd_read_file_slice` containing `bounded`, and `observations.sourceSlice=1` in setup diagnostics. Treat an absent or unknown descriptor version or capability value as unsupported; do not probe a mutation. Use `sdd_read_file_slice` with `view="bounded"` and the required path and line range. Follow a non-null `nextCursor` read-only on the same server instance, repeating the same normalized path and range; the cursor is bound to that server, root, request and physical snapshot. Stop when `nextCursor` is null. The physical snapshot digest is not a content checksum. A same-UID replacement after the last filesystem check is not transactionally excluded. This view and its cursor grant no permission, retry authority or verification time. The default legacy read remains unchanged.
58
+
57
59
  For supported connections, inspect `sdd_list_features` with `view="setup_diagnostics"` and an optional fixed `host`; server registration, installed file hashes and client-reported identity do not prove the host-effective catalogue. Reload the client catalogue only when needed. For a locked task use `execution_window`, follow its `execution_detail` cursors and `evidence_history` pages; reread the window when a cursor is stale. These views are non-certifying. Explicitly record an already observed attempt with `sdd_lock_spec(operation="evidence_checkpoint")` only after inspecting the selected connection’s advertised input schema for `operation`, `checkpoint` and `task_id` and confirming a supporting engine version. The global 8.5.1 server does not gain new inputs from source edits: never probe an unknown mutation, or fall back to lock/relock, because old schemas may strip fields and seal instead. Report unsupported capability. The journal retains only explicitly recorded observations; failures are not recorded automatically. Its caller-reported outcome is not certification; the server captures identity and eligible digests. Preserve uncertain guards for operator review.
58
60
 
59
61
  ## Outcome
@@ -37,6 +37,8 @@ You do not make architectural decisions, you do not add dependencies, and you do
37
37
 
38
38
  ## Evidence and current connection
39
39
 
40
+ For an opt-in bounded source read, first require `engineCapabilities.version=1`, `views.sdd_read_file_slice` containing `bounded`, and `observations.sourceSlice=1` in setup diagnostics. Treat an absent or unknown descriptor version or capability value as unsupported; do not probe a mutation. Use `sdd_read_file_slice` with `view="bounded"` and the required path and line range. Follow a non-null `nextCursor` read-only on the same server instance, repeating the same normalized path and range; the cursor is bound to that server, root, request and physical snapshot. Stop when `nextCursor` is null. The physical snapshot digest is not a content checksum. A same-UID replacement after the last filesystem check is not transactionally excluded. This view and its cursor grant no permission, retry authority or verification time. The default legacy read remains unchanged.
41
+
40
42
  For supported connections, inspect `sdd_list_features` with `view="setup_diagnostics"` and an optional fixed `host`; server registration, installed file hashes and client-reported identity do not prove the host-effective catalogue. Reload the client catalogue only when needed. For a locked task use `execution_window`, follow its `execution_detail` cursors and `evidence_history` pages; reread the window when a cursor is stale. These views are non-certifying. Explicitly record an already observed attempt with `sdd_lock_spec(operation="evidence_checkpoint")` only after inspecting the selected connection’s advertised input schema for `operation`, `checkpoint` and `task_id` and confirming a supporting engine version. The global 8.5.1 server does not gain new inputs from source edits: never probe an unknown mutation, or fall back to lock/relock, because old schemas may strip fields and seal instead. Report unsupported capability. The journal retains only explicitly recorded observations; failures are not recorded automatically. Its caller-reported outcome is not certification; the server captures identity and eligible digests. Preserve uncertain guards for operator review.
41
43
 
42
44
  Display evidence separately: optional smoke is caller-reported and never gate coverage; each required gate needs a valid matching PASS receipt; missing evidence, skipped/partial observations or unavailable inputs are pending; challenge mismatches (workspace, feature, task, lock, candidate, observed input, procedure or environment) and signature, shape or coverage failures are stale/rejected. Receipt v1 has no TTL. Even valid receipts require fresh integration; `ready_to_attempt` permits an attempt only. Obtain signed receipts from the operator-controlled issuer. Do not grant budgets, edit authority or treat the journal as a certificate.