@planu/cli 7.1.7 → 8.1.1

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 CHANGED
@@ -1,3 +1,40 @@
1
+ ## [8.1.1] - 2026-09-21
2
+
3
+ - fail closed with `ERR_WORKSPACE_UNRESOLVED` when the resolved workspace is the user home directory without MCP roots or `PLANU_WORKSPACE`
4
+ - keep `sdd_init_workspace` `scope: global` on `~/.config/sdd`
5
+
6
+ ## [8.1.0] - 2026-09-20
7
+
8
+ ### Features
9
+
10
+ - let `sdd_create_feature` atomically reserve global `FEAT-NNNN-TITLE` identifiers when `id` is omitted
11
+ - preserve explicit `FEAT-*` IDs for imports and compatibility
12
+ - derive deterministic uppercase ASCII slugs with a safe `FEATURE` fallback
13
+
14
+ ### Reliability
15
+
16
+ - use atomic directory creation to prevent concurrent feature requests from overwriting or sharing an identifier
17
+ - seed automatic numbering from both the existing global prefix and the count of pre-8.1 feature directories
18
+
19
+ ## [8.0.0] - 2026-09-20
20
+
21
+ ### Breaking Changes
22
+
23
+ - remove the runtime legacy catalog and the `data.legacy` field from `sdd_list_features`
24
+ - remove legacy public types, migration skill, v6 hooks, scripts, configuration, and packaged runtime assets
25
+ - establish a FEAT-only Planu v8 contract with exactly nine canonical MCP tools
26
+
27
+ ### Safety
28
+
29
+ - retain exact manifest-authorized DELETE with lexical and realpath containment, Git metadata protection, and atomic CREATE exclusivity
30
+ - add negative gates against legacy runtime and generated-surface reintroduction
31
+
32
+ ## [7.2.0] - 2026-09-20
33
+
34
+ - add exact manifest-authorized DELETE operations to `sdd_apply_file_patch`
35
+ - fail closed on sibling-prefix and symlink workspace escapes for every mutation
36
+ - protect the workspace root and `.git` from manifest-authorized deletion
37
+
1
38
  ## [7.1.7] - 2026-09-20
2
39
 
3
40
  - refresh zod, vitest, eslint, prettier, knip, and @types/node 22.20.4 (stay on Node 22 types)
@@ -6031,8 +6068,6 @@ Total: 275 tools (72 free + 192 pro + 11 always-on)
6031
6068
 
6032
6069
  * **ci:** add @semantic-release/changelog to auto-update CHANGELOG.md ([92834a3](https://github.com/imaintainer92/specforge-mcp/commit/92834a32440df8e7b3c62c7b0ad03c29ed99089d))
6033
6070
 
6034
- # Changelog
6035
-
6036
6071
  All notable changes to SpecForge are documented here.
6037
6072
 
6038
6073
  Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) · Versioning: [SemVer](https://semver.org/)
package/README.md CHANGED
@@ -8,12 +8,12 @@
8
8
 
9
9
  ## What is Planu?
10
10
 
11
- Planu v7 is a **thin MCP sandbox + cognitive skills** stack for Spec Driven Development. It does not restore the legacy 160-tool Node.js gate machine. Canonical design: [`PLANU_V7_MANIFESTO.txt`](PLANU_V7_MANIFESTO.txt).
11
+ Planu v8 is a **thin MCP sandbox + cognitive skills** stack for Spec Driven Development. Its supported runtime is FEAT-only and exposes exactly nine canonical tools. Canonical design: [`PLANU_V8_MANIFESTO.txt`](PLANU_V8_MANIFESTO.txt).
12
12
 
13
13
  **Spec first, always.** No locked trinity means no product code.
14
14
 
15
15
  - **The Holy Trinity** — `.sdd/features/{FEAT-*}/[spec.md, plan.md, tasks.md]`
16
- - **Zero-Freedom Execution** — mutations go through `sdd_apply_file_patch`; the File Manifest is the sandbox
16
+ - **Zero-Freedom Execution** — mutations and exact `DELETE:` operations go through `sdd_apply_file_patch`; the File Manifest is the sandbox
17
17
  - **Single Task Window** — `sdd_get_active_task` + `sdd_read_file_slice`
18
18
  - **9 Canonical MCP Tools** — listed below
19
19
  - **Cognitive gates** — `.sdd/skills/` personas replace `challenge_spec` / `check_readiness` / `validate`
@@ -54,25 +54,25 @@ Local development in this repo:
54
54
  }
55
55
  ```
56
56
 
57
- The published server asks the host for MCP roots and binds to the open project that owns `.sdd/`. Do not set a global `PLANU_WORKSPACE`: that pins every client to one repo. `PLANU_WORKSPACE` remains an optional per-process override. `pnpm start` runs the MCP server.
57
+ The published server asks the host for MCP roots and binds to the open project that owns `.sdd/`. If the process cwd is the user home directory and roots are missing, project-scoped tools return `ERR_WORKSPACE_UNRESOLVED` instead of creating `.sdd` under `$HOME`. Do not set a global `PLANU_WORKSPACE`: that pins every client to one repo. `PLANU_WORKSPACE` remains an optional per-process override. `pnpm start` runs the MCP server.
58
58
 
59
59
  **Requirements:** Node.js >= 22.13.
60
60
 
61
61
  ---
62
62
 
63
- ## The SDD Lifecycle (v7)
63
+ ## The SDD Lifecycle (v8)
64
64
 
65
65
  ```text
66
- sdd_init_workspace → sdd_create_feature → architect trinity → sdd_lock_spec → execute tasks → git-janitor
66
+ sdd_init_workspace → sdd_create_feature → architect trinity → sdd_lock_spec → execute tasks → verify → git-janitor
67
67
  ```
68
68
 
69
69
  1. **Initialize:** `sdd_init_workspace` writes `.sdd/` and copies `AGENTS.md` plus skills.
70
- 2. **Architect:** Adopt `spec-architect.md`. Feature ids are `FEAT-*` (`SPEC-001` is rejected).
70
+ 2. **Architect:** Adopt `spec-architect.md`. Call `sdd_create_feature` with a title and omit `id` to reserve the next global `FEAT-NNNN-TITLE` identifier. Explicit `FEAT-*` IDs remain supported for imports; `SPEC-001` is rejected.
71
71
  3. **Lock:** `sdd_lock_spec` hashes spec/plan. Do not lock an empty skeleton (cognitive rule).
72
- 4. **Execute:** `sdd_get_active_task` → `sdd_apply_file_patch` → `sdd_complete_task`.
73
- 5. **Janitor:** prune local branches and orphaned worktrees.
72
+ 4. **Execute:** `sdd_get_active_task` → `sdd_apply_file_patch` → `sdd_complete_task`. CREATE, MODIFY, READ_ONLY, and DELETE permissions are exact manifest entries.
73
+ 5. **Verify:** independently prove acceptance criteria with `verification-auditor.md`.\n6. **Janitor:** prune local branches and orphaned worktrees only with authorization.
74
74
 
75
- Legacy `planu/specs/SPEC-*` files stay on disk. `sdd_list_features` returns them under `legacy` (id, path, archive/active/unknown, `migratedTo`) so the trace is never empty. They are not executable until migrated via `.sdd/skills/legacy-migrator.md` into `.sdd/features/FEAT-*`. There is no bulk rewrite of `done` specs.
75
+ `sdd_list_features` enumerates executable `.sdd/features/FEAT-*` records only. Historical v6 records are not executed, enumerated, generated, or shipped by the v8 runtime.
76
76
 
77
77
  ### Canonical tools
78
78
 
@@ -95,7 +95,7 @@ src/
95
95
  │ ├── plan.md
96
96
  │ ├── tasks.md
97
97
  │ └── .lock
98
- └── skills/ # architect, executor, janitor, reconciler, migrator
98
+ └── skills/ # preflight, architect, executor, verifier, sunset, reconciler, lib-sync, janitor
99
99
  ```
100
100
 
101
101
  ---
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export type { ArtifactType, FilePermission, ErrorCode, SddErrorDetails, SddSuccess, SddFailure, SddResult, InitWorkspaceInput, ListFeaturesInput, CreateFeatureInput, LockSpecInput, ReadSpecArtifactInput, ReadFileSliceInput, GetActiveTaskInput, ApplyFilePatchInput, CompleteTaskInput, ParsedManifest, ActiveTaskDetails, ActiveTaskResult, CompleteTaskResult, FeatureSummary, LegacySpecSummary, LegacyCatalogSummary, } from '../types/sdd-engine.js';
2
+ export type { ArtifactType, FilePermission, ErrorCode, SddErrorDetails, SddSuccess, SddFailure, SddResult, InitWorkspaceInput, ListFeaturesInput, CreateFeatureInput, LockSpecInput, ReadSpecArtifactInput, ReadFileSliceInput, GetActiveTaskInput, ApplyFilePatchInput, CompleteTaskInput, ParsedManifest, ActiveTaskDetails, ActiveTaskResult, CompleteTaskResult, FeatureSummary, } from '../types/sdd-engine.js';
3
3
  export declare const FeatureIdSchema: z.ZodString;
4
4
  export declare const ArtifactTypeSchema: z.ZodEnum<{
5
5
  plan: "plan";
@@ -8,6 +8,7 @@ export declare const ArtifactTypeSchema: z.ZodEnum<{
8
8
  }>;
9
9
  export declare const FilePermissionSchema: z.ZodEnum<{
10
10
  CREATE: "CREATE";
11
+ DELETE: "DELETE";
11
12
  MODIFY: "MODIFY";
12
13
  READ_ONLY: "READ_ONLY";
13
14
  }>;
@@ -24,6 +25,7 @@ export declare const ErrorCodeSchema: z.ZodEnum<{
24
25
  ERR_SPEC_NOT_LOCKED: "ERR_SPEC_NOT_LOCKED";
25
26
  ERR_TASK_NOT_FOUND: "ERR_TASK_NOT_FOUND";
26
27
  ERR_TASK_OUT_OF_SEQUENCE: "ERR_TASK_OUT_OF_SEQUENCE";
28
+ ERR_WORKSPACE_UNRESOLVED: "ERR_WORKSPACE_UNRESOLVED";
27
29
  }>;
28
30
  export declare const InitWorkspaceInputSchema: z.ZodObject<{
29
31
  scope: z.ZodEnum<{
@@ -41,7 +43,7 @@ export declare const ListFeaturesInputSchema: z.ZodObject<{
41
43
  }>>;
42
44
  }, z.core.$strip>;
43
45
  export declare const CreateFeatureInputSchema: z.ZodObject<{
44
- id: z.ZodString;
46
+ id: z.ZodOptional<z.ZodString>;
45
47
  title: z.ZodString;
46
48
  }, z.core.$strip>;
47
49
  export declare const LockSpecInputSchema: z.ZodObject<{
@@ -6,7 +6,7 @@ export const FeatureIdSchema = z
6
6
  message: 'El Feature ID debe cumplir con el formato FEAT-XXXX o FEAT_XXXX (letras mayúsculas, números, guiones).',
7
7
  });
8
8
  export const ArtifactTypeSchema = z.enum(['spec', 'plan', 'tasks']);
9
- export const FilePermissionSchema = z.enum(['CREATE', 'MODIFY', 'READ_ONLY']);
9
+ export const FilePermissionSchema = z.enum(['CREATE', 'MODIFY', 'READ_ONLY', 'DELETE']);
10
10
  export const ErrorCodeSchema = z.enum([
11
11
  'ERR_FEATURE_NOT_FOUND',
12
12
  'ERR_FEATURE_ALREADY_EXISTS',
@@ -20,6 +20,7 @@ export const ErrorCodeSchema = z.enum([
20
20
  'ERR_PATCH_FAILED',
21
21
  'ERR_INVALID_ARTIFACT',
22
22
  'ERR_INVALID_SLICE',
23
+ 'ERR_WORKSPACE_UNRESOLVED',
23
24
  ]);
24
25
  export const InitWorkspaceInputSchema = z.object({
25
26
  scope: z.enum(['global', 'project']),
@@ -29,7 +30,7 @@ export const ListFeaturesInputSchema = z.object({
29
30
  status_filter: z.enum(['all', 'planning', 'executing', 'done']).optional(),
30
31
  });
31
32
  export const CreateFeatureInputSchema = z.object({
32
- id: FeatureIdSchema,
33
+ id: FeatureIdSchema.optional(),
33
34
  title: z.string().min(3),
34
35
  });
35
36
  export const LockSpecInputSchema = z.object({
@@ -1,14 +1,21 @@
1
- import type { ParsedManifest, SddResult } from '../types/sdd-engine.js';
1
+ import type { ParsedManifest, PatchResultData, SddResult } from '../types/sdd-engine.js';
2
2
  export declare class PatchSandbox {
3
3
  private readonly workspaceRoot;
4
4
  constructor(workspaceRoot: string);
5
5
  parsePlanManifest(planPath: string): Promise<ParsedManifest>;
6
6
  private parseManifestLine;
7
- applyPatch(manifest: ParsedManifest, targetRelativePath: string, searchContent: string, replaceContent: string): Promise<SddResult<{
8
- appliedTo: string;
9
- bytesWritten: number;
10
- }>>;
7
+ applyPatch(manifest: ParsedManifest, targetRelativePath: string, searchContent: string, replaceContent: string): Promise<SddResult<PatchResultData>>;
8
+ private validateTargetContainment;
9
+ private isRawProtectedDelete;
10
+ private validateCreateTargetAbsent;
11
+ private isGitMetadataTarget;
12
+ private nearestExistingParent;
13
+ private isWithin;
14
+ private permissionViolation;
15
+ private patchFailure;
16
+ private isNodeErrorCode;
11
17
  private executeCreatePatch;
18
+ private executeDeletePatch;
12
19
  private executeModifyPatch;
13
20
  }
14
21
  //# sourceMappingURL=patch-sandbox.d.ts.map
@@ -33,13 +33,13 @@ export class PatchSandbox {
33
33
  }
34
34
  parseManifestLine(rawLine, allowedFiles) {
35
35
  const item = rawLine.replace(/^[-*]\s+/, '').trim();
36
- const prefixMatch = /^(CREATE|MODIFY|READ_ONLY):\s*`?([^`\s#]+)`?/i.exec(item);
36
+ const prefixMatch = /^(CREATE|MODIFY|READ_ONLY|DELETE):\s*`?([^`\s#]+)`?\s*$/i.exec(item);
37
37
  if (prefixMatch?.[1] && prefixMatch[2]) {
38
38
  const perm = prefixMatch[1].toUpperCase();
39
39
  allowedFiles.set(path.normalize(prefixMatch[2].trim()), perm);
40
40
  return;
41
41
  }
42
- const postfixMatch = /^`?([^`\s:#]+)`?:\s*(CREATE|MODIFY|READ_ONLY)/i.exec(item);
42
+ const postfixMatch = /^`?([^`\s:#]+)`?:\s*(CREATE|MODIFY|READ_ONLY|DELETE)\s*$/i.exec(item);
43
43
  if (postfixMatch?.[1] && postfixMatch[2]) {
44
44
  const perm = postfixMatch[2].toUpperCase();
45
45
  allowedFiles.set(path.normalize(postfixMatch[1].trim()), perm);
@@ -71,40 +71,136 @@ export class PatchSandbox {
71
71
  };
72
72
  }
73
73
  const fullPath = path.resolve(this.workspaceRoot, normalizedTarget);
74
- if (!fullPath.startsWith(path.resolve(this.workspaceRoot))) {
75
- return {
76
- success: false,
77
- error: {
78
- code: 'ERR_PERMISSION_VIOLATION',
79
- message: `Access outside workspace boundaries denied: '${normalizedTarget}'.`,
80
- trigger: 'sdd_apply_file_patch',
81
- },
82
- };
74
+ const containmentError = await this.validateTargetContainment(fullPath, normalizedTarget, permission);
75
+ if (containmentError) {
76
+ return containmentError;
83
77
  }
84
78
  if (permission === 'CREATE') {
85
79
  return this.executeCreatePatch(fullPath, normalizedTarget, searchContent, replaceContent);
86
80
  }
81
+ if (permission === 'DELETE') {
82
+ return this.executeDeletePatch(fullPath, normalizedTarget, searchContent, replaceContent);
83
+ }
87
84
  return this.executeModifyPatch(fullPath, normalizedTarget, searchContent, replaceContent);
88
85
  }
89
- async executeCreatePatch(fullPath, normalizedTarget, searchContent, replaceContent) {
86
+ async validateTargetContainment(fullPath, normalizedTarget, permission) {
87
+ const workspacePath = path.resolve(this.workspaceRoot);
88
+ if (!this.isWithin(workspacePath, fullPath)) {
89
+ return this.permissionViolation(normalizedTarget);
90
+ }
91
+ if (permission === 'DELETE' &&
92
+ this.isRawProtectedDelete(workspacePath, fullPath, normalizedTarget)) {
93
+ return this.permissionViolation(normalizedTarget);
94
+ }
95
+ const createError = permission === 'CREATE'
96
+ ? await this.validateCreateTargetAbsent(fullPath, normalizedTarget)
97
+ : null;
98
+ if (createError) {
99
+ return createError;
100
+ }
90
101
  try {
91
- await fs.mkdir(path.dirname(fullPath), { recursive: true });
92
- let targetContent = replaceContent;
102
+ const workspaceRealPath = await fs.realpath(workspacePath);
103
+ const containmentTarget = permission === 'CREATE'
104
+ ? await this.nearestExistingParent(path.dirname(fullPath), workspacePath)
105
+ : await fs.realpath(fullPath);
106
+ if (!this.isWithin(workspaceRealPath, containmentTarget)) {
107
+ return this.permissionViolation(normalizedTarget);
108
+ }
109
+ if (permission === 'DELETE' &&
110
+ (await this.isGitMetadataTarget(workspaceRealPath, containmentTarget))) {
111
+ return this.permissionViolation(normalizedTarget);
112
+ }
113
+ }
114
+ catch (err) {
115
+ if (!this.isNodeErrorCode(err, 'ENOENT')) {
116
+ return this.permissionViolation(normalizedTarget);
117
+ }
118
+ }
119
+ return null;
120
+ }
121
+ isRawProtectedDelete(workspacePath, fullPath, normalizedTarget) {
122
+ return (fullPath === workspacePath ||
123
+ normalizedTarget === '.git' ||
124
+ normalizedTarget.startsWith(`.git${path.sep}`));
125
+ }
126
+ async validateCreateTargetAbsent(fullPath, normalizedTarget) {
127
+ try {
128
+ await fs.lstat(fullPath);
129
+ return this.patchFailure(`CREATE target already exists: '${normalizedTarget}'.`);
130
+ }
131
+ catch (err) {
132
+ return this.isNodeErrorCode(err, 'ENOENT')
133
+ ? null
134
+ : this.permissionViolation(normalizedTarget);
135
+ }
136
+ }
137
+ async isGitMetadataTarget(workspaceRealPath, containmentTarget) {
138
+ try {
139
+ const gitRealPath = await fs.realpath(path.join(workspaceRealPath, '.git'));
140
+ return this.isWithin(gitRealPath, containmentTarget);
141
+ }
142
+ catch (err) {
143
+ if (this.isNodeErrorCode(err, 'ENOENT')) {
144
+ return false;
145
+ }
146
+ throw err;
147
+ }
148
+ }
149
+ async nearestExistingParent(candidate, workspacePath) {
150
+ let current = candidate;
151
+ while (this.isWithin(workspacePath, current)) {
93
152
  try {
94
- const existing = await fs.readFile(fullPath, 'utf-8');
95
- if (searchContent && existing.includes(searchContent)) {
96
- targetContent = existing.replace(searchContent, replaceContent);
153
+ return await fs.realpath(current);
154
+ }
155
+ catch (err) {
156
+ if (!this.isNodeErrorCode(err, 'ENOENT')) {
157
+ throw err;
97
158
  }
98
159
  }
99
- catch {
100
- // File does not exist yet; initialized with replaceContent
160
+ if (current === workspacePath) {
161
+ break;
101
162
  }
102
- await fs.writeFile(fullPath, targetContent, 'utf-8');
163
+ current = path.dirname(current);
164
+ }
165
+ return fs.realpath(workspacePath);
166
+ }
167
+ isWithin(root, target) {
168
+ const relative = path.relative(root, target);
169
+ return (relative === '' ||
170
+ (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)));
171
+ }
172
+ permissionViolation(normalizedTarget) {
173
+ return {
174
+ success: false,
175
+ error: {
176
+ code: 'ERR_PERMISSION_VIOLATION',
177
+ message: `Access outside protected workspace boundaries denied: '${normalizedTarget}'.`,
178
+ trigger: 'sdd_apply_file_patch',
179
+ },
180
+ };
181
+ }
182
+ patchFailure(message) {
183
+ return {
184
+ success: false,
185
+ error: {
186
+ code: 'ERR_PATCH_FAILED',
187
+ message,
188
+ trigger: 'sdd_apply_file_patch',
189
+ },
190
+ };
191
+ }
192
+ isNodeErrorCode(err, code) {
193
+ return typeof err === 'object' && err !== null && 'code' in err && err.code === code;
194
+ }
195
+ async executeCreatePatch(fullPath, normalizedTarget, _searchContent, replaceContent) {
196
+ try {
197
+ await fs.mkdir(path.dirname(fullPath), { recursive: true });
198
+ await fs.writeFile(fullPath, replaceContent, { encoding: 'utf-8', flag: 'wx' });
103
199
  return {
104
200
  success: true,
105
201
  data: {
106
202
  appliedTo: normalizedTarget,
107
- bytesWritten: Buffer.byteLength(targetContent, 'utf-8'),
203
+ bytesWritten: Buffer.byteLength(replaceContent, 'utf-8'),
108
204
  },
109
205
  };
110
206
  }
@@ -119,6 +215,36 @@ export class PatchSandbox {
119
215
  };
120
216
  }
121
217
  }
218
+ async executeDeletePatch(fullPath, normalizedTarget, searchContent, replaceContent) {
219
+ if (searchContent !== '' || replaceContent !== '') {
220
+ return {
221
+ success: false,
222
+ error: {
223
+ code: 'ERR_PATCH_FAILED',
224
+ message: `DELETE requires empty search_content and replace_content for '${normalizedTarget}'.`,
225
+ trigger: 'sdd_apply_file_patch',
226
+ },
227
+ };
228
+ }
229
+ try {
230
+ const stat = await fs.lstat(fullPath);
231
+ await fs.rm(fullPath, { recursive: stat.isDirectory(), force: false });
232
+ return {
233
+ success: true,
234
+ data: { appliedTo: normalizedTarget, bytesWritten: 0, deleted: true },
235
+ };
236
+ }
237
+ catch (err) {
238
+ return {
239
+ success: false,
240
+ error: {
241
+ code: 'ERR_PATCH_FAILED',
242
+ message: `Failed to delete '${normalizedTarget}': ${err instanceof Error ? err.message : String(err)}`,
243
+ trigger: 'sdd_apply_file_patch',
244
+ },
245
+ };
246
+ }
247
+ }
122
248
  async executeModifyPatch(fullPath, normalizedTarget, searchContent, replaceContent) {
123
249
  let existingContent;
124
250
  try {
@@ -4,12 +4,12 @@ import { registerUltralightSddTools } from './tools.js';
4
4
  export function createUltralightSddServer(workspaceRoot) {
5
5
  const server = new McpServer({
6
6
  name: 'sdd-engine',
7
- version: '7.1.7',
7
+ version: '8.1.1',
8
8
  }, {
9
9
  capabilities: {
10
10
  tools: {},
11
11
  },
12
- instructions: 'SDD Engine v7: state arbiter, File Manifest sandbox, and single-task context window for Spec-Driven Development.',
12
+ instructions: 'SDD Engine v8: FEAT-only state arbiter, File Manifest sandbox, and single-task context window for Spec-Driven Development.',
13
13
  });
14
14
  registerUltralightSddTools(server, workspaceRoot);
15
15
  return server;
@@ -5,6 +5,7 @@ import { PatchSandbox } from '../patch-sandbox.js';
5
5
  import { TaskWindowManager } from '../task-window.js';
6
6
  import { formatResult } from './format-result.js';
7
7
  import { verifyLockedTrinity } from '../lock-integrity.js';
8
+ import { homeFallbackFailure } from '../workspace-root.js';
8
9
  export function registerExecutionTools(server, workspace) {
9
10
  const taskWindow = new TaskWindowManager();
10
11
  registerReadArtifactTool(server, workspace);
@@ -20,6 +21,10 @@ function registerReadArtifactTool(server, workspace) {
20
21
  }, async (rawArgs) => {
21
22
  const args = ReadSpecArtifactInputSchema.parse(rawArgs);
22
23
  const resolved = await workspace.resolve();
24
+ const homeError = homeFallbackFailure(resolved, 'sdd_read_spec_artifact');
25
+ if (homeError) {
26
+ return formatResult(homeError);
27
+ }
23
28
  const targetPath = path.join(resolved.sddDir, 'features', args.feature_id, `${args.artifact}.md`);
24
29
  try {
25
30
  const text = await fs.readFile(targetPath, 'utf-8');
@@ -44,6 +49,10 @@ function registerReadFileSliceTool(server, workspace) {
44
49
  }, async (rawArgs) => {
45
50
  const args = ReadFileSliceInputSchema.parse(rawArgs);
46
51
  const resolved = await workspace.resolve();
52
+ const homeError = homeFallbackFailure(resolved, 'sdd_read_file_slice');
53
+ if (homeError) {
54
+ return formatResult(homeError);
55
+ }
47
56
  return executeReadFileSlice(resolved.workspaceRoot, args.path, args.start_line, args.end_line);
48
57
  });
49
58
  }
@@ -54,6 +63,10 @@ function registerGetActiveTaskTool(server, workspace, taskWindow) {
54
63
  }, async (rawArgs) => {
55
64
  const args = GetActiveTaskInputSchema.parse(rawArgs);
56
65
  const resolved = await workspace.resolve();
66
+ const homeError = homeFallbackFailure(resolved, 'sdd_get_active_task');
67
+ if (homeError) {
68
+ return formatResult(homeError);
69
+ }
57
70
  const tasksPath = path.join(resolved.sddDir, 'features', args.feature_id, 'tasks.md');
58
71
  const result = await taskWindow.getActiveTask(tasksPath);
59
72
  return formatResult(result);
@@ -61,11 +74,15 @@ function registerGetActiveTaskTool(server, workspace, taskWindow) {
61
74
  }
62
75
  function registerApplyPatchTool(server, workspace) {
63
76
  server.registerTool('sdd_apply_file_patch', {
64
- description: 'Applies diff patches to files strictly authorized in plan.md File Manifest.',
77
+ description: 'Applies CREATE and MODIFY patches, or exact DELETE operations, strictly authorized in plan.md File Manifest. DELETE requires empty search_content and replace_content.',
65
78
  inputSchema: ApplyFilePatchInputSchema.shape,
66
79
  }, async (rawArgs) => {
67
80
  const args = ApplyFilePatchInputSchema.parse(rawArgs);
68
81
  const resolved = await workspace.resolve();
82
+ const homeError = homeFallbackFailure(resolved, 'sdd_apply_file_patch');
83
+ if (homeError) {
84
+ return formatResult(homeError);
85
+ }
69
86
  const patchSandbox = new PatchSandbox(resolved.workspaceRoot);
70
87
  return executeApplyPatch(resolved.sddDir, patchSandbox, args);
71
88
  });
@@ -77,6 +94,10 @@ function registerCompleteTaskTool(server, workspace, taskWindow) {
77
94
  }, async (rawArgs) => {
78
95
  const args = CompleteTaskInputSchema.parse(rawArgs);
79
96
  const resolved = await workspace.resolve();
97
+ const homeError = homeFallbackFailure(resolved, 'sdd_complete_task');
98
+ if (homeError) {
99
+ return formatResult(homeError);
100
+ }
80
101
  const featDir = path.join(resolved.sddDir, 'features', args.feature_id);
81
102
  const lockError = await requireLockedTrinity(featDir, 'sdd_complete_task');
82
103
  if (lockError) {