@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.
Files changed (39) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +9 -3
  3. package/dist/sdd-engine/canonical-tools.d.ts +38 -0
  4. package/dist/sdd-engine/canonical-tools.js +105 -2
  5. package/dist/sdd-engine/catalogue-presentation.d.ts +23 -0
  6. package/dist/sdd-engine/catalogue-presentation.js +123 -0
  7. package/dist/sdd-engine/client-workspace.d.ts +8 -1
  8. package/dist/sdd-engine/client-workspace.js +168 -1
  9. package/dist/sdd-engine/completion-snapshot.d.ts +2 -1
  10. package/dist/sdd-engine/completion-snapshot.js +81 -23
  11. package/dist/sdd-engine/contracts.d.ts +2 -24
  12. package/dist/sdd-engine/contracts.js +5 -19
  13. package/dist/sdd-engine/feature-authority.d.ts +3 -2
  14. package/dist/sdd-engine/feature-authority.js +29 -1
  15. package/dist/sdd-engine/host-rule-pack.js +16 -4
  16. package/dist/sdd-engine/host-skill-reader.d.ts +12 -11
  17. package/dist/sdd-engine/host-skill-reader.js +235 -225
  18. package/dist/sdd-engine/source-descriptor.d.ts +3 -0
  19. package/dist/sdd-engine/source-descriptor.js +356 -0
  20. package/dist/sdd-engine/tools/execution-tools.d.ts +2 -1
  21. package/dist/sdd-engine/tools/execution-tools.js +58 -33
  22. package/dist/sdd-engine/tools/feature-store.d.ts +6 -6
  23. package/dist/sdd-engine/tools/feature-store.js +188 -84
  24. package/dist/sdd-engine/tools/workspace-tools.d.ts +2 -1
  25. package/dist/sdd-engine/tools/workspace-tools.js +44 -35
  26. package/dist/sdd-engine/tools.js +4 -2
  27. package/dist/sdd-engine/workspace-init.d.ts +6 -0
  28. package/dist/sdd-engine/workspace-init.js +92 -2
  29. package/dist/sdd-engine/workspace-root.d.ts +33 -7
  30. package/dist/sdd-engine/workspace-root.js +222 -139
  31. package/dist/types/completion.d.ts +46 -2
  32. package/dist/types/resume-views.d.ts +36 -1
  33. package/dist/types/sdd-engine.d.ts +35 -61
  34. package/dist/types/verification.d.ts +59 -0
  35. package/package.json +2 -2
  36. package/templates/AGENTS.md +4 -0
  37. package/templates/host/planu-sdd.md +4 -0
  38. package/templates/skills/preflight-guardian.md +4 -0
  39. package/templates/skills/spec-executor.md +4 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [8.10.0] - 2026-11-15
2
+
3
+ - Add an opt-in compact feature catalogue with literal ID query, status filtering and pages of 16 by default, up to 32 entries.
4
+ - Bind MAC-protected cursors to the server, request and full physical catalogue snapshot; each compact response is limited to 8,192 UTF-8 bytes. Each scan reads and revalidates all eligible inputs, with at most eight feature readers per capture stage; total I/O is not bounded.
5
+ - Preserve the legacy default and nine tools. Read-only recovery observations and cursors grant no permission, retry authority or verification time; uncertain guards remain for operator review.
6
+ - Planning and file operations remain available on Windows; automated server verification requires macOS or Linux and fails closed on Windows. Native Windows execution remains unvalidated.
7
+
8
+ ## [8.9.0]
9
+
10
+ - Add an opt-in bounded source view with strict UTF-8 and a cursor bound to the server, request and physical snapshot.
11
+ - Limit each request to 65,536 source bytes and 64 descriptor reads, at most 200 completed selected lines and an 8,192-byte UTF-8 JSON response.
12
+ - The snapshot digest is metadata-based, not a content checksum; a same-UID replacement after the final filesystem check is not transactionally excluded.
13
+ - Preserve the legacy default and nine tools. The cursor grants no permission, retry authority or verification time.
14
+
1
15
  ## [8.8.0]
2
16
 
3
17
  - Add a version 1 server implementation capability descriptor to setup diagnostics for supported views and observations.
package/README.md CHANGED
@@ -144,14 +144,20 @@ The reviewed operator procedure is in the repository guide `docs/verification-bu
144
144
 
145
145
  ## Read-only diagnostics
146
146
 
147
- The existing nine tools expose additive diagnostics since 8.4.0; 8.5.0 adds compact resume and history views, and 8.6.0 adds bounded execution views and explicit evidence checkpoints. 8.7.0 adds advisory budget observations and verification process evidence. 8.8.0 adds the server implementation capability descriptor version 1 to setup diagnostics. An ordinary `sdd_get_active_task` request keeps its previous response shape.
147
+ For an opt-in feature catalogue, first require `engineCapabilities.version=1`, `views.sdd_list_features` containing `catalogue`, and `observations.featureCatalogue=1` in setup diagnostics. Request `view="catalogue"` and follow each non-null `nextCursor` on the same server, repeating query, status and page size. Each compact response is at most 8192 UTF-8 bytes and each capture stage runs at most eight feature readers concurrently; a complete scan still reads all eligible inputs, so total I/O is not bounded. The cursor grants no permission or certification.
148
+
149
+ 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 absent or unknown versions or capability values as unsupported; never probe a mutation. Request `sdd_read_file_slice` with `view="bounded"`, a path and line range, then follow each non-null `nextCursor` read-only on the same server instance with the same normalized path and range. The cursor binds the server, root, request and physical snapshot; the snapshot digest is not a checksum of file contents. The default legacy read remains unchanged.
150
+
151
+ Each request reads at most 65,536 source bytes in at most 64 descriptor read calls, completes at most 200 selected lines per page and returns a compact JSON text envelope of at most 8,192 UTF-8 bytes. A continuation grants no permission, retry authority or verification time. A same-UID replacement after the last filesystem check is not transactionally excluded.
152
+
153
+ The existing nine tools expose additive diagnostics since 8.4.0; 8.5.0 adds compact resume and history views, and 8.6.0 adds bounded execution views and explicit evidence checkpoints. 8.7.0 adds advisory budget observations and verification process evidence. 8.8.0 adds the server implementation capability descriptor version 1 to setup diagnostics. 8.9.0 adds the opt-in bounded source view. An ordinary `sdd_get_active_task` request keeps its previous response shape.
148
154
 
149
155
  `sdd_list_features` includes `hostSkills`. For example, a missing installed role can produce this field (other installed files match the available bundled reference):
150
156
 
151
157
  ```json
152
158
  {
153
159
  "version": 1,
154
- "bundledVersion": "8.8.0",
160
+ "bundledVersion": "8.10.0",
155
161
  "baseline": "available",
156
162
  "catalog": "unverified",
157
163
  "issues": [{
@@ -384,7 +390,7 @@ See the [Planu Proprietary Free-Use License](LICENSE) and [planu.dev/license](ht
384
390
  "mcpServers": {
385
391
  "planu": {
386
392
  "command": "npx",
387
- "args": ["-y", "@planu/cli@8.8.0"],
393
+ "args": ["-y", "@planu/cli@8.10.0"],
388
394
  "cwd": ".",
389
395
  "env": {
390
396
  "PLANU_WORKSPACE": "."
@@ -1,4 +1,6 @@
1
+ import type { ListFeaturesInput, SddResult } from '../types/sdd-engine.js';
1
2
  import type { EngineCapabilitiesV1 } from '../types/resume-views.js';
3
+ import { z } from 'zod';
2
4
  export declare const CANONICAL_SDD_TOOL_NAMES: readonly ['sdd_init_workspace', 'sdd_list_features', 'sdd_create_feature', 'sdd_lock_spec', 'sdd_read_spec_artifact', 'sdd_read_file_slice', 'sdd_get_active_task', 'sdd_apply_file_patch', 'sdd_complete_task'];
3
5
  export declare const ENGINE_CAPABILITIES: EngineCapabilitiesV1;
4
6
  export declare const TOOL_ANNOTATIONS: Readonly<{
@@ -30,4 +32,40 @@ export declare const TOOL_ANNOTATIONS: Readonly<{
30
32
  readOnlyHint: false;
31
33
  }>;
32
34
  }>;
35
+ export declare const ListFeaturesInputSchema: z.ZodObject<{
36
+ status_filter: z.ZodOptional<z.ZodEnum<{
37
+ all: "all";
38
+ done: "done";
39
+ executing: "executing";
40
+ planning: "planning";
41
+ }>>;
42
+ view: z.ZodOptional<z.ZodEnum<{
43
+ catalogue: "catalogue";
44
+ setup_diagnostics: "setup_diagnostics";
45
+ }>>;
46
+ query: z.ZodOptional<z.ZodString>;
47
+ page_size: z.ZodOptional<z.ZodNumber>;
48
+ cursor: z.ZodOptional<z.ZodString>;
49
+ host: z.ZodOptional<z.ZodEnum<{
50
+ all: "all";
51
+ claude: "claude";
52
+ codex: "codex";
53
+ cursor: "cursor";
54
+ gemini: "gemini";
55
+ }>>;
56
+ }, z.core.$strip>;
57
+ export declare const ReadFileSliceInputSchema: z.ZodObject<{
58
+ path: z.ZodString;
59
+ start_line: z.ZodNumber;
60
+ end_line: z.ZodNumber;
61
+ view: z.ZodOptional<z.ZodLiteral<"bounded">>;
62
+ cursor: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>;
64
+ export declare function catalogueInputFailure(): SddResult<never>;
65
+ export declare function listInputFailure(): SddResult<never>;
66
+ export declare function catalogueDispatchFailure(reason: 'cancelled' | 'catalogue_unavailable'): SddResult<never>;
67
+ export declare function boundedWorkspaceHint(parts: (string | undefined)[]): string | undefined;
68
+ export declare 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-*.";
69
+ export declare function hasCatalogueOptions(input: ListFeaturesInput): boolean;
70
+ export declare function signalIsAborted(signal: AbortSignal): boolean;
33
71
  //# sourceMappingURL=canonical-tools.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  export const CANONICAL_SDD_TOOL_NAMES = [
2
3
  'sdd_init_workspace',
3
4
  'sdd_list_features',
@@ -19,7 +20,8 @@ export const ENGINE_CAPABILITIES = Object.freeze({
19
20
  'sdd_get_active_task',
20
21
  ]),
21
22
  views: Object.freeze({
22
- sdd_list_features: Object.freeze(['setup_diagnostics']),
23
+ sdd_list_features: Object.freeze(['setup_diagnostics', 'catalogue']),
24
+ sdd_read_file_slice: Object.freeze(['bounded']),
23
25
  sdd_get_active_task: Object.freeze([
24
26
  'verification_preflight',
25
27
  'resume',
@@ -33,6 +35,8 @@ export const ENGINE_CAPABILITIES = Object.freeze({
33
35
  sdd_lock_spec: Object.freeze(['lock', 'evidence_checkpoint']),
34
36
  }),
35
37
  observations: Object.freeze({
38
+ featureCatalogue: 1,
39
+ sourceSlice: 1,
36
40
  setupDiagnostics: 1,
37
41
  verificationPreflight: 1,
38
42
  resume: 1,
@@ -44,7 +48,18 @@ export const ENGINE_CAPABILITIES = Object.freeze({
44
48
  verificationBudget: 1,
45
49
  verificationProcess: 1,
46
50
  }),
47
- limits: Object.freeze({ compactTextBytes: 8192, defaultVerificationTimeoutMs: 180000 }),
51
+ limits: Object.freeze({
52
+ featureCataloguePageSizeDefault: 16,
53
+ featureCataloguePageSizeMax: 32,
54
+ featureCatalogueQueryBytes: 128,
55
+ featureCatalogueCursorCharacters: 1024,
56
+ compactTextBytes: 8192,
57
+ defaultVerificationTimeoutMs: 180000,
58
+ sourceSliceBytes: 65536,
59
+ sourceSliceReadCalls: 64,
60
+ sourceSliceLines: 200,
61
+ sourceSliceCursorCharacters: 1024,
62
+ }),
48
63
  });
49
64
  export const TOOL_ANNOTATIONS = Object.freeze({
50
65
  sdd_init_workspace: Object.freeze({ readOnlyHint: false }),
@@ -57,4 +72,92 @@ export const TOOL_ANNOTATIONS = Object.freeze({
57
72
  sdd_apply_file_patch: Object.freeze({ readOnlyHint: false }),
58
73
  sdd_complete_task: Object.freeze({ readOnlyHint: false }),
59
74
  });
75
+ export const ListFeaturesInputSchema = z
76
+ .object({
77
+ status_filter: z.enum(['all', 'planning', 'executing', 'done']).optional(),
78
+ view: z
79
+ .enum(['setup_diagnostics', 'catalogue'], {
80
+ error: 'Invalid setup diagnostic view.',
81
+ })
82
+ .optional(),
83
+ query: z.string().optional(),
84
+ page_size: z.number().optional(),
85
+ cursor: z.string().optional(),
86
+ host: z
87
+ .enum(['all', 'claude', 'cursor', 'codex', 'gemini'], {
88
+ error: 'Invalid setup diagnostic host.',
89
+ })
90
+ .optional(),
91
+ })
92
+ .refine((input) => input.host === undefined || input.view !== undefined, {
93
+ message: 'Host requires setup diagnostics view.',
94
+ });
95
+ export const ReadFileSliceInputSchema = z.object({
96
+ path: z.string().min(1),
97
+ start_line: z.number().int().min(1),
98
+ end_line: z.number().int().min(1),
99
+ view: z.literal('bounded').optional(),
100
+ cursor: z.string().optional(),
101
+ });
102
+ export function catalogueInputFailure() {
103
+ return {
104
+ success: false,
105
+ error: {
106
+ code: 'ERR_INVALID_ARTIFACT',
107
+ message: 'Feature catalogue input is invalid.',
108
+ trigger: 'sdd_list_features',
109
+ details: { reason: 'catalogue_input_invalid', nextAction: 'fix_inputs' },
110
+ },
111
+ };
112
+ }
113
+ export function listInputFailure() {
114
+ return {
115
+ success: false,
116
+ error: {
117
+ code: 'ERR_INVALID_ARTIFACT',
118
+ message: 'Compact task read is unavailable; follow the bounded next action.',
119
+ trigger: 'sdd_list_features',
120
+ details: { reason: 'compact_input_invalid', nextAction: 'fix_inputs' },
121
+ },
122
+ };
123
+ }
124
+ export function catalogueDispatchFailure(reason) {
125
+ const cancelled = reason === 'cancelled';
126
+ return {
127
+ success: false,
128
+ error: {
129
+ code: cancelled ? 'ERR_VERIFICATION_FAILED' : 'ERR_INVALID_ARTIFACT',
130
+ message: 'Feature catalogue read is unavailable.',
131
+ trigger: 'sdd_list_features',
132
+ details: {
133
+ reason,
134
+ nextAction: cancelled ? 'retry_read' : 'inspect_artifacts',
135
+ },
136
+ },
137
+ };
138
+ }
139
+ export function boundedWorkspaceHint(parts) {
140
+ const combined = parts.filter((item) => item !== undefined).join(' ');
141
+ if (!combined) {
142
+ return undefined;
143
+ }
144
+ let bounded = '';
145
+ let bytes = 0;
146
+ for (const character of combined) {
147
+ const size = new TextEncoder().encode(character).byteLength;
148
+ if (bytes + size > 1024) {
149
+ break;
150
+ }
151
+ bounded += character;
152
+ bytes += size;
153
+ }
154
+ return bounded;
155
+ }
156
+ export 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-*.';
157
+ export function hasCatalogueOptions(input) {
158
+ return input.query !== undefined || input.page_size !== undefined || input.cursor !== undefined;
159
+ }
160
+ export function signalIsAborted(signal) {
161
+ return signal.aborted;
162
+ }
60
163
  //# sourceMappingURL=canonical-tools.js.map
@@ -0,0 +1,23 @@
1
+ import type { CataloguePageV1, ErrorCode, FeatureSummary, ListFeaturesInput, SddFailure, SddResult } from '../types/sdd-engine.js';
2
+ import type { CatalogueCursorPayload } from '../types/resume-views.js';
3
+ import type { ReadCursorCodec } from './workspace-root.js';
4
+ import type { CatalogueError, CatalogueFileCapture, CompletionFailureReason } from '../types/completion.js';
5
+ export declare function compactCatalogueFailure(reason: CatalogueError): SddFailure;
6
+ export declare function catalogueOptions(input: ListFeaturesInput): {
7
+ query: string;
8
+ status: 'all' | 'planning' | 'executing' | 'done';
9
+ size: number;
10
+ } | null;
11
+ export declare function compactIdValid(value: string): boolean;
12
+ export declare function cataloguePage(entries: FeatureSummary[], root: string, snapshot: string, request: string, options: NonNullable<ReturnType<typeof catalogueOptions>>, cursor: CatalogueCursorPayload | null, codec: ReadCursorCodec): SddResult<{
13
+ catalogue: CataloguePageV1;
14
+ }>;
15
+ export declare class CatalogueReadError extends Error {
16
+ readonly reason: CatalogueError;
17
+ constructor(reason: CatalogueError);
18
+ }
19
+ export declare function checkCatalogueAbort(signal?: AbortSignal): void;
20
+ export declare function catalogueCursor(input: string | undefined, request: string, codec: ReadCursorCodec): CatalogueCursorPayload | null | undefined;
21
+ export declare function sameCatalogueRoot(root: string, tasks: CatalogueFileCapture, lock: CatalogueFileCapture | null): boolean;
22
+ export declare function classifyCatalogueError(category: 'catalogue' | 'guard' | 'other', reason: CatalogueError | CompletionFailureReason | undefined, code: ErrorCode | undefined, revalidation: boolean, aborted: boolean): CatalogueError;
23
+ //# sourceMappingURL=catalogue-presentation.d.ts.map
@@ -0,0 +1,123 @@
1
+ const catalogueErrors = {
2
+ catalogue_input_invalid: ['ERR_INVALID_ARTIFACT', 'fix_inputs'],
3
+ catalogue_cursor_invalid: ['ERR_INVALID_ARTIFACT', 'reread_catalogue'],
4
+ catalogue_cursor_stale: ['ERR_SPEC_DRIFT', 'reread_catalogue'],
5
+ catalogue_identifier_invalid: ['ERR_INVALID_ARTIFACT', 'inspect_artifacts'],
6
+ catalogue_response_too_large: ['ERR_INVALID_ARTIFACT', 'inspect_artifacts'],
7
+ catalogue_unavailable: ['ERR_INVALID_ARTIFACT', 'inspect_artifacts'],
8
+ catalogue_path_unsafe: ['ERR_PERMISSION_VIOLATION', 'inspect_artifacts'],
9
+ catalogue_capability_unavailable: ['ERR_PERMISSION_VIOLATION', 'use_supported_runtime'],
10
+ guard_present: ['ERR_TASK_OUT_OF_SEQUENCE', 'wait_for_guard'],
11
+ persistence_uncertain: ['ERR_VERIFICATION_FAILED', 'inspect_recovery'],
12
+ cancelled: ['ERR_VERIFICATION_FAILED', 'retry_read'],
13
+ };
14
+ export function compactCatalogueFailure(reason) {
15
+ const [code, nextAction] = catalogueErrors[reason];
16
+ return {
17
+ success: false,
18
+ error: {
19
+ code,
20
+ message: 'Feature catalogue read is unavailable.',
21
+ trigger: 'sdd_list_features',
22
+ details: { reason, nextAction },
23
+ },
24
+ };
25
+ }
26
+ function asciiFold(value) {
27
+ return value.replace(/[A-Z]/gu, (letter) => String.fromCharCode(letter.charCodeAt(0) + 32));
28
+ }
29
+ export function catalogueOptions(input) {
30
+ const { query = '', page_size: size = 16, status_filter: status = 'all' } = input;
31
+ if (input.view !== 'catalogue' ||
32
+ input.host !== undefined ||
33
+ typeof query !== 'string' ||
34
+ new TextEncoder().encode(query).byteLength > 128 ||
35
+ Array.from(query, (character) => character.charCodeAt(0)).some((code) => code < 32 || (code >= 127 && code < 160)) ||
36
+ !Number.isSafeInteger(size) ||
37
+ size < 1 ||
38
+ size > 32 ||
39
+ !['all', 'planning', 'executing', 'done'].includes(status)) {
40
+ return null;
41
+ }
42
+ return { query: asciiFold(query.trim()), status, size };
43
+ }
44
+ export function compactIdValid(value) {
45
+ return value.length <= 128 && /^[A-Z0-9_-]+$/u.test(value);
46
+ }
47
+ export function cataloguePage(entries, root, snapshot, request, options, cursor, codec) {
48
+ const matching = entries.filter((entry) => asciiFold(entry.id).includes(options.query) &&
49
+ (options.status === 'all' || entry.status === options.status));
50
+ const index = cursor ? matching.findIndex((entry) => entry.id === cursor[5]) + 1 : 0;
51
+ if (cursor && (index === 0 || index >= matching.length)) {
52
+ return compactCatalogueFailure('catalogue_cursor_invalid');
53
+ }
54
+ const page = {
55
+ version: 1,
56
+ snapshotSha256: snapshot,
57
+ total: matching.length,
58
+ offset: index,
59
+ entries: [],
60
+ nextCursor: null,
61
+ };
62
+ for (const entry of matching.slice(index, index + options.size)) {
63
+ const nextEntries = [...page.entries, entry];
64
+ const next = index + nextEntries.length < matching.length
65
+ ? codec.encode(['planu.read-cursor.v1', 'catalogue', root, request, snapshot, entry.id])
66
+ : null;
67
+ const candidate = { ...page, entries: nextEntries, nextCursor: next };
68
+ if (new TextEncoder().encode(JSON.stringify({ success: true, data: { catalogue: candidate } }))
69
+ .byteLength > 8192) {
70
+ break;
71
+ }
72
+ page.entries = nextEntries;
73
+ page.nextCursor = next;
74
+ }
75
+ if (matching.length > index && page.entries.length === 0) {
76
+ return compactCatalogueFailure('catalogue_response_too_large');
77
+ }
78
+ if (new TextEncoder().encode(JSON.stringify({ success: true, data: { catalogue: page } }))
79
+ .byteLength > 8192) {
80
+ return compactCatalogueFailure('catalogue_response_too_large');
81
+ }
82
+ return { success: true, data: { catalogue: page } };
83
+ }
84
+ export class CatalogueReadError extends Error {
85
+ reason;
86
+ constructor(reason) {
87
+ super(reason);
88
+ this.reason = reason;
89
+ }
90
+ }
91
+ export function checkCatalogueAbort(signal) {
92
+ if (signal?.aborted) {
93
+ throw new CatalogueReadError('cancelled');
94
+ }
95
+ }
96
+ export function catalogueCursor(input, request, codec) {
97
+ if (input === undefined) {
98
+ return null;
99
+ }
100
+ const decoded = codec.decode(input);
101
+ return decoded?.[1] === 'catalogue' && decoded[3] === request ? decoded : undefined;
102
+ }
103
+ export function sameCatalogueRoot(root, tasks, lock) {
104
+ return tasks.rootIdentitySha256 === root && (!lock || lock.rootIdentitySha256 === root);
105
+ }
106
+ export function classifyCatalogueError(category, reason, code, revalidation, aborted) {
107
+ if (category === 'guard' && (reason === 'persistence_uncertain' || reason === 'guard_present')) {
108
+ return reason;
109
+ }
110
+ if (aborted || reason === 'cancelled') {
111
+ return 'cancelled';
112
+ }
113
+ if (category === 'catalogue' && reason && reason !== 'contract_drift') {
114
+ return revalidation && reason !== 'catalogue_capability_unavailable'
115
+ ? 'catalogue_cursor_stale'
116
+ : reason;
117
+ }
118
+ if (revalidation || code === 'ERR_SPEC_DRIFT') {
119
+ return 'catalogue_cursor_stale';
120
+ }
121
+ return code === 'ERR_PERMISSION_VIOLATION' ? 'catalogue_path_unsafe' : 'catalogue_unavailable';
122
+ }
123
+ //# sourceMappingURL=catalogue-presentation.js.map
@@ -1,5 +1,6 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { ResolvedSddWorkspace, SddWorkspaceHandle } from '../types/sdd-engine.js';
2
+ import type { SetupDiagnostics } from '../types/resume-views.js';
3
+ import type { ResolvedSddWorkspace, ResolveSddWorkspaceInput, SddFailure, SddWorkspaceHandle } from '../types/sdd-engine.js';
3
4
  export declare class McpClientWorkspace implements SddWorkspaceHandle {
4
5
  private readonly server;
5
6
  private readonly pinnedRoot;
@@ -11,4 +12,10 @@ export declare class McpClientWorkspace implements SddWorkspaceHandle {
11
12
  private ensureRootsListener;
12
13
  private loadRootUris;
13
14
  }
15
+ export declare function parseMcpRootUri(uri: string): string | null;
16
+ export declare function resolveSddWorkspaceRoot(startDir?: string, env?: NodeJS.ProcessEnv, mcpRootUris?: readonly string[]): string;
17
+ export declare function resolveSddWorkspace(input?: ResolveSddWorkspaceInput): ResolvedSddWorkspace;
18
+ export declare function isHomeFallbackWorkspace(resolved: ResolvedSddWorkspace, env?: NodeJS.ProcessEnv): boolean;
19
+ export declare function homeFallbackFailure(resolved: ResolvedSddWorkspace, trigger: string, env?: NodeJS.ProcessEnv): SddFailure | null;
20
+ export declare function clientInfo(value: unknown): Pick<SetupDiagnostics, 'client' | 'clientMetadataCause'>;
14
21
  //# sourceMappingURL=client-workspace.d.ts.map
@@ -1,5 +1,7 @@
1
1
  import { RootsListChangedNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
2
- import { resolveSddWorkspace } from './workspace-root.js';
2
+ import { existsSync } from 'node:fs';
3
+ import { dirname, join, resolve, sep } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
3
5
  const LIST_ROOTS_TIMEOUT_MS = 2000;
4
6
  export class McpClientWorkspace {
5
7
  server;
@@ -54,4 +56,169 @@ export class McpClientWorkspace {
54
56
  return this.rootUris;
55
57
  }
56
58
  }
59
+ 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.';
60
+ export function parseMcpRootUri(uri) {
61
+ const trimmed = uri.trim();
62
+ if (!trimmed) {
63
+ return null;
64
+ }
65
+ try {
66
+ if (trimmed.startsWith('file:')) {
67
+ return resolve(fileURLToPath(trimmed));
68
+ }
69
+ }
70
+ catch {
71
+ return null;
72
+ }
73
+ if (trimmed.startsWith('/')) {
74
+ return resolve(trimmed);
75
+ }
76
+ return null;
77
+ }
78
+ export function resolveSddWorkspaceRoot(startDir = process.cwd(), env = process.env, mcpRootUris = []) {
79
+ return resolveSddWorkspace({ startDir, env, mcpRootUris }).workspaceRoot;
80
+ }
81
+ export function resolveSddWorkspace(input = {}) {
82
+ const env = input.env ?? process.env;
83
+ const startDir = resolve(input.startDir ?? process.cwd());
84
+ if (input.pinnedRoot?.trim()) {
85
+ return finish(resolve(input.pinnedRoot.trim()), 'pin');
86
+ }
87
+ const fromEnv = usablePlanuWorkspaceEnv(env);
88
+ if (fromEnv) {
89
+ return finish(fromEnv, 'env');
90
+ }
91
+ const mcpDirs = unique((input.mcpRootUris ?? [])
92
+ .map((uri) => parseMcpRootUri(uri))
93
+ .filter((dir) => dir !== null));
94
+ for (const dir of mcpDirs) {
95
+ const found = nearestProjectSdd(dir, env);
96
+ if (found) {
97
+ return finish(found, 'mcp_root');
98
+ }
99
+ }
100
+ const fromCwd = nearestProjectSdd(startDir, env);
101
+ if (fromCwd) {
102
+ return finish(fromCwd, 'cwd_walk');
103
+ }
104
+ if (mcpDirs[0]) {
105
+ return finish(mcpDirs[0], 'fallback');
106
+ }
107
+ return finish(startDir, 'fallback');
108
+ }
109
+ export function isHomeFallbackWorkspace(resolved, env = process.env) {
110
+ return resolved.source === 'fallback' && isHomeDirectory(resolved.workspaceRoot, env);
111
+ }
112
+ export function homeFallbackFailure(resolved, trigger, env = process.env) {
113
+ if (!isHomeFallbackWorkspace(resolved, env)) {
114
+ return null;
115
+ }
116
+ return {
117
+ success: false,
118
+ error: {
119
+ code: 'ERR_WORKSPACE_UNRESOLVED',
120
+ message: ERR_WORKSPACE_UNRESOLVED_MESSAGE,
121
+ trigger,
122
+ },
123
+ };
124
+ }
125
+ function finish(workspaceRoot, source) {
126
+ const sddDir = join(workspaceRoot, '.sdd');
127
+ return {
128
+ workspaceRoot,
129
+ sddDir,
130
+ sddPresent: existsSync(sddDir),
131
+ source,
132
+ };
133
+ }
134
+ function nearestProjectSdd(startDir, env) {
135
+ let dir = resolve(startDir);
136
+ for (;;) {
137
+ if (existsSync(join(dir, '.sdd')) && !isHomeDirectory(dir, env)) {
138
+ return dir;
139
+ }
140
+ const parent = dirname(dir);
141
+ if (parent === dir) {
142
+ return null;
143
+ }
144
+ dir = parent;
145
+ }
146
+ }
147
+ function isHomeDirectory(dir, env) {
148
+ const home = env.HOME?.trim() ?? env.USERPROFILE?.trim();
149
+ if (!home) {
150
+ return false;
151
+ }
152
+ return resolve(dir) === resolve(home);
153
+ }
154
+ function usablePlanuWorkspaceEnv(env) {
155
+ const fromEnv = env.PLANU_WORKSPACE?.trim();
156
+ if (!fromEnv || fromEnv.includes('${')) {
157
+ return null;
158
+ }
159
+ const expanded = expandHomePrefix(fromEnv, env);
160
+ if (!expanded) {
161
+ return null;
162
+ }
163
+ const resolved = resolve(expanded);
164
+ if (resolved.includes(`${sep}~${sep}`) || resolved.endsWith(`${sep}~`)) {
165
+ return null;
166
+ }
167
+ if (isHomeDirectory(resolved, env)) {
168
+ return null;
169
+ }
170
+ return resolved;
171
+ }
172
+ function expandHomePrefix(raw, env) {
173
+ if (raw === '~' || raw.startsWith('~/') || raw.startsWith('~\\')) {
174
+ const home = env.HOME?.trim() ?? env.USERPROFILE?.trim();
175
+ if (!home) {
176
+ return null;
177
+ }
178
+ if (raw === '~') {
179
+ return home;
180
+ }
181
+ return join(home, raw.slice(2));
182
+ }
183
+ return raw;
184
+ }
185
+ function unique(values) {
186
+ const seen = new Set();
187
+ const out = [];
188
+ for (const value of values) {
189
+ if (seen.has(value)) {
190
+ continue;
191
+ }
192
+ seen.add(value);
193
+ out.push(value);
194
+ }
195
+ return out;
196
+ }
197
+ export function clientInfo(value) {
198
+ if (value === undefined || value === null) {
199
+ return { client: null, clientMetadataCause: 'unavailable' };
200
+ }
201
+ if (typeof value !== 'object' ||
202
+ !('name' in value) ||
203
+ !('version' in value) ||
204
+ typeof value.name !== 'string' ||
205
+ typeof value.version !== 'string' ||
206
+ Array.from(value.name + value.version).some((char) => {
207
+ const code = char.codePointAt(0) ?? 0;
208
+ return code < 32 || (code >= 127 && code <= 159);
209
+ })) {
210
+ return { client: null, clientMetadataCause: 'invalid' };
211
+ }
212
+ if (Buffer.byteLength(value.name) > 128 || Buffer.byteLength(value.version) > 128) {
213
+ return { client: null, clientMetadataCause: 'over_limit' };
214
+ }
215
+ return {
216
+ client: {
217
+ name: value.name,
218
+ version: value.version,
219
+ source: 'initialize',
220
+ provenance: 'client_reported',
221
+ },
222
+ };
223
+ }
57
224
  //# sourceMappingURL=client-workspace.js.map
@@ -1,12 +1,13 @@
1
1
  import type { ScopedVerificationSnapshot } from '../types/verification.js';
2
2
  import type { CompleteTaskResult, SddResult } from '../types/sdd-engine.js';
3
- import type { CompletionSnapshot, CompletionSnapshotOptions } from '../types/completion.js';
3
+ import type { CatalogueArtifactCapture, CompletionSnapshot, CompletionSnapshotOptions } from '../types/completion.js';
4
4
  import { type CompletionLease } from './completion-guard.js';
5
5
  /** Catalogue reads need task status and lock presence, not an execution readiness card. */
6
6
  export declare function readCatalogueArtifacts(featDir: string): Promise<{
7
7
  tasksContent: string;
8
8
  locked: boolean;
9
9
  }>;
10
+ export declare function captureCatalogueArtifacts(featDir: string, workspaceRoot: string, signal?: AbortSignal): Promise<CatalogueArtifactCapture>;
10
11
  export declare function captureCompletionSnapshot(requestedFeatDir: string, options?: CompletionSnapshotOptions): Promise<CompletionSnapshot>;
11
12
  export declare function revalidateCompletionSnapshot(snapshot: CompletionSnapshot): Promise<void>;
12
13
  export declare function commitOwnedScopedTask(taskId: string, scopedSnapshot: ScopedVerificationSnapshot, output: string, signal: AbortSignal, snapshot: CompletionSnapshot, lease: CompletionLease, persist: (written: string) => Promise<SddResult<null>>): Promise<SddResult<CompleteTaskResult>>;