@planu/cli 7.1.6 → 8.1.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 CHANGED
@@ -1,3 +1,39 @@
1
+ ## [8.1.0] - 2026-09-20
2
+
3
+ ### Features
4
+
5
+ - let `sdd_create_feature` atomically reserve global `FEAT-NNNN-TITLE` identifiers when `id` is omitted
6
+ - preserve explicit `FEAT-*` IDs for imports and compatibility
7
+ - derive deterministic uppercase ASCII slugs with a safe `FEATURE` fallback
8
+
9
+ ### Reliability
10
+
11
+ - use atomic directory creation to prevent concurrent feature requests from overwriting or sharing an identifier
12
+ - seed automatic numbering from both the existing global prefix and the count of pre-8.1 feature directories
13
+
14
+ ## [8.0.0] - 2026-09-20
15
+
16
+ ### Breaking Changes
17
+
18
+ - remove the runtime legacy catalog and the `data.legacy` field from `sdd_list_features`
19
+ - remove legacy public types, migration skill, v6 hooks, scripts, configuration, and packaged runtime assets
20
+ - establish a FEAT-only Planu v8 contract with exactly nine canonical MCP tools
21
+
22
+ ### Safety
23
+
24
+ - retain exact manifest-authorized DELETE with lexical and realpath containment, Git metadata protection, and atomic CREATE exclusivity
25
+ - add negative gates against legacy runtime and generated-surface reintroduction
26
+
27
+ ## [7.2.0] - 2026-09-20
28
+
29
+ - add exact manifest-authorized DELETE operations to `sdd_apply_file_patch`
30
+ - fail closed on sibling-prefix and symlink workspace escapes for every mutation
31
+ - protect the workspace root and `.git` from manifest-authorized deletion
32
+
33
+ ## [7.1.7] - 2026-09-20
34
+
35
+ - refresh zod, vitest, eslint, prettier, knip, and @types/node 22.20.4 (stay on Node 22 types)
36
+
1
37
  ## [7.1.6] - 2026-09-19
2
38
 
3
39
  - resolve the SDD workspace from MCP client `roots/list` so Cursor, Claude, and Codex bind to the open project, not the `npx` process cwd
@@ -6027,8 +6063,6 @@ Total: 275 tools (72 free + 192 pro + 11 always-on)
6027
6063
 
6028
6064
  * **ci:** add @semantic-release/changelog to auto-update CHANGELOG.md ([92834a3](https://github.com/imaintainer92/specforge-mcp/commit/92834a32440df8e7b3c62c7b0ad03c29ed99089d))
6029
6065
 
6030
- # Changelog
6031
-
6032
6066
  All notable changes to SpecForge are documented here.
6033
6067
 
6034
6068
  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`
@@ -60,19 +60,19 @@ The published server asks the host for MCP roots and binds to the open project t
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
  }>;
@@ -41,7 +42,7 @@ export declare const ListFeaturesInputSchema: z.ZodObject<{
41
42
  }>>;
42
43
  }, z.core.$strip>;
43
44
  export declare const CreateFeatureInputSchema: z.ZodObject<{
44
- id: z.ZodString;
45
+ id: z.ZodOptional<z.ZodString>;
45
46
  title: z.ZodString;
46
47
  }, z.core.$strip>;
47
48
  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',
@@ -29,7 +29,7 @@ export const ListFeaturesInputSchema = z.object({
29
29
  status_filter: z.enum(['all', 'planning', 'executing', 'done']).optional(),
30
30
  });
31
31
  export const CreateFeatureInputSchema = z.object({
32
- id: FeatureIdSchema,
32
+ id: FeatureIdSchema.optional(),
33
33
  title: z.string().min(3),
34
34
  });
35
35
  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.6',
7
+ version: '8.1.0',
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;
@@ -61,7 +61,7 @@ function registerGetActiveTaskTool(server, workspace, taskWindow) {
61
61
  }
62
62
  function registerApplyPatchTool(server, workspace) {
63
63
  server.registerTool('sdd_apply_file_patch', {
64
- description: 'Applies diff patches to files strictly authorized in plan.md File Manifest.',
64
+ 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
65
  inputSchema: ApplyFilePatchInputSchema.shape,
66
66
  }, async (rawArgs) => {
67
67
  const args = ApplyFilePatchInputSchema.parse(rawArgs);
@@ -6,7 +6,6 @@ const moduleDir = path.dirname(fileURLToPath(import.meta.url));
6
6
  import { InitWorkspaceInputSchema, ListFeaturesInputSchema, CreateFeatureInputSchema, LockSpecInputSchema, } from '../contracts.js';
7
7
  import { TaskWindowManager } from '../task-window.js';
8
8
  import { formatResult } from './format-result.js';
9
- import { collectLegacyCatalog } from '../legacy-catalog.js';
10
9
  const MISSING_SDD_HINT = 'No .sdd directory in the client project. Call sdd_init_workspace with scope=project. MCP hosts should advertise roots; do not pin PLANU_WORKSPACE globally.';
11
10
  export function registerWorkspaceTools(server, workspace) {
12
11
  const taskWindow = new TaskWindowManager();
@@ -46,20 +45,18 @@ function registerInitTool(server, workspace) {
46
45
  }
47
46
  function registerListTool(server, workspace, taskWindow) {
48
47
  server.registerTool('sdd_list_features', {
49
- description: 'Lists v7 FEAT-* features and a read-only catalog of legacy planu/specs SPEC-* (trace only; not executable until migrated).',
48
+ description: 'Lists executable Planu v8 FEAT-* features from .sdd/features only.',
50
49
  inputSchema: ListFeaturesInputSchema.shape,
51
50
  }, async (rawArgs) => {
52
51
  const args = ListFeaturesInputSchema.parse(rawArgs);
53
52
  const resolved = await workspace.resolve();
54
53
  const featuresDir = path.join(resolved.sddDir, 'features');
55
54
  const featuresList = await collectFeatures(featuresDir, taskWindow, args.status_filter);
56
- const legacy = await collectLegacyCatalog(resolved.workspaceRoot, resolved.sddDir);
57
55
  return formatResult({
58
56
  success: true,
59
57
  data: {
60
58
  total: featuresList.length,
61
59
  features: featuresList,
62
- legacy,
63
60
  workspaceRoot: resolved.workspaceRoot,
64
61
  sddPresent: resolved.sddPresent,
65
62
  source: resolved.source,
@@ -70,34 +67,44 @@ function registerListTool(server, workspace, taskWindow) {
70
67
  }
71
68
  function registerCreateTool(server, workspace) {
72
69
  server.registerTool('sdd_create_feature', {
73
- description: 'Creates a new feature conforming to The Holy Trinity (.sdd/features/{id}/[spec.md, plan.md, tasks.md]).',
70
+ description: 'Creates a Holy Trinity feature. Omit id to atomically reserve the next global FEAT-NNNN-TITLE identifier; explicit FEAT-* IDs remain supported.',
74
71
  inputSchema: CreateFeatureInputSchema.shape,
75
72
  }, async (rawArgs) => {
76
73
  const args = CreateFeatureInputSchema.parse(rawArgs);
77
74
  const resolved = await workspace.resolve();
78
- const featDir = path.join(resolved.sddDir, 'features', args.id);
79
- await fs.mkdir(path.dirname(featDir), { recursive: true });
80
- try {
81
- await fs.mkdir(featDir);
82
- }
83
- catch (err) {
84
- if (isNodeErrorCode(err, 'EEXIST')) {
85
- return formatResult({
86
- success: false,
87
- error: {
88
- code: 'ERR_FEATURE_ALREADY_EXISTS',
89
- message: `Feature '${args.id}' already exists in the workspace.`,
90
- trigger: 'sdd_create_feature',
91
- },
92
- });
75
+ const featuresDir = path.join(resolved.sddDir, 'features');
76
+ await fs.mkdir(featuresDir, { recursive: true });
77
+ let featureId = args.id;
78
+ let featDir;
79
+ if (featureId) {
80
+ featDir = path.join(featuresDir, featureId);
81
+ try {
82
+ await fs.mkdir(featDir);
83
+ }
84
+ catch (err) {
85
+ if (isNodeErrorCode(err, 'EEXIST')) {
86
+ return formatResult({
87
+ success: false,
88
+ error: {
89
+ code: 'ERR_FEATURE_ALREADY_EXISTS',
90
+ message: `Feature '${featureId}' already exists in the workspace.`,
91
+ trigger: 'sdd_create_feature',
92
+ },
93
+ });
94
+ }
95
+ throw err;
93
96
  }
94
- throw err;
95
97
  }
96
- await writeFeatureArtifacts(featDir, args.id, args.title);
98
+ else {
99
+ const reservation = await reserveAutomaticFeatureDirectory(featuresDir, args.title);
100
+ featureId = reservation.featureId;
101
+ featDir = reservation.featDir;
102
+ }
103
+ await writeFeatureArtifacts(featDir, featureId, args.title);
97
104
  return formatResult({
98
105
  success: true,
99
106
  data: {
100
- featureId: args.id,
107
+ featureId,
101
108
  artifactsCreated: ['spec.md', 'plan.md', 'tasks.md'],
102
109
  directory: featDir,
103
110
  workspaceRoot: resolved.workspaceRoot,
@@ -105,6 +112,68 @@ function registerCreateTool(server, workspace) {
105
112
  });
106
113
  });
107
114
  }
115
+ async function reserveAutomaticFeatureDirectory(featuresDir, title) {
116
+ const entries = await fs.readdir(featuresDir, { withFileTypes: true });
117
+ const featureNames = entries
118
+ .filter((entry) => entry.isDirectory() && /^FEAT[-_]/u.test(entry.name))
119
+ .map((entry) => entry.name);
120
+ const allocatedSequences = entries.flatMap((entry) => {
121
+ if (!entry.isDirectory()) {
122
+ return [];
123
+ }
124
+ const sequence = /^FEAT-(\d+)-/u.exec(entry.name)?.[1] ?? /^\.FEAT-(\d+)\.reserve$/u.exec(entry.name)?.[1];
125
+ return sequence ? [Number(sequence)] : [];
126
+ });
127
+ const highestSequence = Math.max(0, ...allocatedSequences);
128
+ let nextSequence = Math.max(highestSequence + 1, featureNames.length + 1);
129
+ const slug = createFeatureSlug(title);
130
+ for (;;) {
131
+ const sequenceLabel = String(nextSequence).padStart(4, '0');
132
+ const reservationDir = path.join(featuresDir, `.FEAT-${sequenceLabel}.reserve`);
133
+ try {
134
+ await fs.mkdir(reservationDir);
135
+ }
136
+ catch (err) {
137
+ if (!isNodeErrorCode(err, 'EEXIST')) {
138
+ throw err;
139
+ }
140
+ nextSequence += 1;
141
+ continue;
142
+ }
143
+ const featureId = `FEAT-${sequenceLabel}-${slug}`;
144
+ const featDir = path.join(featuresDir, featureId);
145
+ try {
146
+ await fs.mkdir(featDir);
147
+ }
148
+ catch (err) {
149
+ await fs.rm(reservationDir, { recursive: true, force: true });
150
+ if (isNodeErrorCode(err, 'EEXIST')) {
151
+ nextSequence += 1;
152
+ continue;
153
+ }
154
+ throw err;
155
+ }
156
+ try {
157
+ await fs.rm(reservationDir, { recursive: true, force: false });
158
+ }
159
+ catch (err) {
160
+ await fs.rm(featDir, { recursive: true, force: true });
161
+ throw err;
162
+ }
163
+ return { featureId, featDir };
164
+ }
165
+ }
166
+ function createFeatureSlug(title) {
167
+ const slug = title
168
+ .normalize('NFKD')
169
+ .replace(/[\u0300-\u036f]/gu, '')
170
+ .toUpperCase()
171
+ .replace(/[^A-Z0-9]+/gu, '-')
172
+ .replace(/^-+|-+$/gu, '')
173
+ .slice(0, 48)
174
+ .replace(/-+$/gu, '');
175
+ return slug || 'FEATURE';
176
+ }
108
177
  function registerLockTool(server, workspace) {
109
178
  server.registerTool('sdd_lock_spec', {
110
179
  description: 'Locks spec.md and plan.md with cryptographic digests to enable execution phase.',
@@ -178,7 +247,7 @@ async function collectFeatures(featuresDir, taskWindow, statusFilter) {
178
247
  }
179
248
  async function writeFeatureArtifacts(featDir, id, title) {
180
249
  const initialSpec = `# Spec: ${title}\nFeature ID: ${id}\n\n## 1. Out-of-Scope (Mandatory)\n- Explicitly list all modules, dependencies, and behaviors strictly forbidden from being modified.\n\n## 2. Contracts & Data Models\n- Define strict types, interfaces, structs, or schemas using the project's native programming language. Zero loose types.\n\n## 3. Error Matrix\n| Trigger | Condition | Error Code | Status / Payload |\n|---|---|---|---|\n| Invalid input | Missing required field | ERR_INVALID_INPUT | 400 Bad Request |\n`;
181
- const initialPlan = `# Plan: ${title}\nFeature ID: ${id}\n\n## Frozen Dependencies\n- (Frozen dependencies: zero new packages or dependencies allowed without architectural authorization)\n\n## File Manifest\n- CREATE: \n- MODIFY: \n- READ_ONLY: \n`;
250
+ const initialPlan = `# Plan: ${title}\nFeature ID: ${id}\n\n## Frozen Dependencies\n- (Frozen dependencies: zero new packages or dependencies allowed without architectural authorization)\n\n## File Manifest\n- CREATE: \n- MODIFY: \n- READ_ONLY: \n- DELETE: \n`;
182
251
  const initialTasks = `# Tasks: ${title}\nFeature ID: ${id}\n\n- [ ] TASK-1: Define core data structures and initial contracts\n Verification: <executable test command>\n`;
183
252
  await fs.writeFile(path.join(featDir, 'spec.md'), initialSpec, 'utf-8');
184
253
  await fs.writeFile(path.join(featDir, 'plan.md'), initialPlan, 'utf-8');
@@ -1,5 +1,5 @@
1
1
  export type ArtifactType = 'spec' | 'plan' | 'tasks';
2
- export type FilePermission = 'CREATE' | 'MODIFY' | 'READ_ONLY';
2
+ export type FilePermission = 'CREATE' | 'MODIFY' | 'READ_ONLY' | 'DELETE';
3
3
  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';
4
4
  export interface SddErrorDetails {
5
5
  code: ErrorCode;
@@ -24,7 +24,7 @@ export interface ListFeaturesInput {
24
24
  status_filter?: 'all' | 'planning' | 'executing' | 'done';
25
25
  }
26
26
  export interface CreateFeatureInput {
27
- id: string;
27
+ id?: string;
28
28
  title: string;
29
29
  }
30
30
  export interface LockSpecInput {
@@ -56,6 +56,11 @@ export interface CompleteTaskInput {
56
56
  export interface ParsedManifest {
57
57
  allowedFiles: Map<string, FilePermission>;
58
58
  }
59
+ export interface PatchResultData {
60
+ appliedTo: string;
61
+ bytesWritten: number;
62
+ deleted?: true;
63
+ }
59
64
  export interface ActiveTaskDetails {
60
65
  taskId: string;
61
66
  taskTitle: string;
@@ -88,21 +93,6 @@ export interface FeatureSummary {
88
93
  status: 'planning' | 'executing' | 'done';
89
94
  locked: boolean;
90
95
  }
91
- export interface LegacySpecSummary {
92
- id: string;
93
- title: string;
94
- lifecycle: 'active' | 'archive' | 'unknown';
95
- legacyStatus: string | null;
96
- path: string;
97
- migratedTo: string | null;
98
- }
99
- export interface LegacyCatalogSummary {
100
- total: number;
101
- active: number;
102
- archive: number;
103
- unknown: number;
104
- specs: LegacySpecSummary[];
105
- }
106
96
  export interface SddLockFile {
107
97
  specHash?: string;
108
98
  planHash?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "7.1.6",
3
+ "version": "8.1.0",
4
4
  "description": "Planu — MCP Server for Spec Driven Development. Cross-platform (Linux/macOS/Windows, x64/arm64).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -72,7 +72,7 @@
72
72
  "license": "SEE LICENSE IN LICENSE",
73
73
  "dependencies": {
74
74
  "@modelcontextprotocol/sdk": "^1.30.0",
75
- "zod": "^4.6.2"
75
+ "zod": "^4.6.5"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@commitlint/cli": "^21.2.2",
@@ -80,19 +80,19 @@
80
80
  "@eslint/js": "^10.0.1",
81
81
  "@secretlint/secretlint-rule-no-homedir": "^13.0.5",
82
82
  "@secretlint/secretlint-rule-preset-recommend": "^13.0.5",
83
- "@types/node": "^22.20.2",
83
+ "@types/node": "^22.20.4",
84
84
  "@typescript/native": "npm:typescript@^7.0.2",
85
- "@vitest/coverage-v8": "^5.0.0",
86
- "eslint": "10.10.0",
85
+ "@vitest/coverage-v8": "^5.0.1",
86
+ "eslint": "10.11.0",
87
87
  "eslint-config-prettier": "^10.1.8",
88
88
  "eslint-import-resolver-typescript": "^4.4.5",
89
89
  "eslint-plugin-import": "^2.32.0",
90
90
  "husky": "^9.1.7",
91
91
  "jiti": "2.7.0",
92
- "knip": "^6.35.1",
92
+ "knip": "^6.37.0",
93
93
  "lint-staged": "^17.5.1",
94
94
  "madge": "^8.0.0",
95
- "prettier": "^3.9.6",
95
+ "prettier": "^3.9.8",
96
96
  "qrcode": "1.5.4",
97
97
  "secretlint": "^13.0.5",
98
98
  "tsc-alias": "^1.9.5",
@@ -100,12 +100,13 @@
100
100
  "typescript": "npm:@typescript/typescript6@^6.0.2",
101
101
  "typescript-eslint": "^8.70.0",
102
102
  "vite": "^8.3.0",
103
- "vitest": "^5.0.0"
103
+ "vitest": "^5.0.1"
104
104
  },
105
105
  "scripts": {
106
106
  "check:tool-registration": "bash scripts/check-tool-registration.sh",
107
+ "check:skill-sync": "node scripts/check-skill-sync.mjs",
107
108
  "build": "pnpm build:ts",
108
- "build:ts": "pnpm clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node scripts/copy-runtime-assets.mjs",
109
+ "build:ts": "pnpm clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
109
110
  "dev": "tsc --watch",
110
111
  "start": "node dist/sdd-engine/cli.js",
111
112
  "clean": "rm -rf dist",
@@ -118,7 +119,7 @@
118
119
  "test": "vitest run --maxWorkers=6",
119
120
  "test:watch": "vitest",
120
121
  "test:coverage": "vitest run --coverage --testTimeout=60000 --maxWorkers=6",
121
- "check": "pnpm typecheck && pnpm lint:gate && pnpm format:check && pnpm check:destructive-ops && pnpm check:tool-registration && pnpm check:sdd-core",
122
+ "check": "pnpm typecheck && pnpm lint:gate && pnpm format:check && pnpm check:destructive-ops && pnpm check:tool-registration && pnpm check:skill-sync && pnpm check:sdd-core",
122
123
  "check:sdd-core": "node scripts/check-sdd-core-closure.mjs",
123
124
  "check:destructive-ops": "bash scripts/check-no-automatic-destructive-ops.sh",
124
125
  "check:deps:fresh": "node scripts/check-dependency-freshness.mjs",
@@ -1,16 +1,32 @@
1
- # SDD Engine v7 — Master Global Rules
1
+ # SDD Engine v8 — Master Global Rules
2
2
 
3
- You are operating within a Spec-Driven Development environment (Planu v7).
4
- Canonical contract: `PLANU_V7_MANIFESTO.txt`.
3
+ You are operating within a Spec-Driven Development environment (Planu v8).
4
+ Canonical contract: `PLANU_V8_MANIFESTO.txt`.
5
5
 
6
6
  1. **SDD Skills Primacy:**
7
7
  - ALWAYS refer to `.sdd/skills/` for role directives.
8
- - Before beginning any task, load and adopt the matching persona (Spec Architect, Spec Executor, Legacy Migrator, Reconciler, Git Janitor, Lib Sync).
8
+ - Before beginning any task, load and adopt the matching persona (Preflight Guardian, Spec Architect, Spec Executor, Verification Auditor, Legacy Sunset, Reconciler, Git Janitor, Lib Sync).
9
+ - Start architecture and execution with `preflight-guardian.md`; finish implementation with the independent `verification-auditor.md`.
10
+ - Use `legacy-sunset.md` only for classified, snapshotted, and explicitly authorized permanent retirement.
9
11
  - Core (`src/sdd-engine`) changes MUST follow `lib-sync.md`: update the published package, templates, server-card, and tests in the same change.
10
12
 
13
+ ### Role activation boundaries
14
+
15
+ | Skill | Use when |
16
+ |---|---|
17
+ | `preflight-guardian.md` | Before architecture, first execution, resumed work, or any core change. |
18
+ | `spec-architect.md` | Creating or completing an unlocked Holy Trinity before user-approved lock. |
19
+ | `spec-executor.md` | Implementing the active task of a locked feature through canonical SDD tools. |
20
+ | `verification-auditor.md` | Independently proving completed implementation against acceptance criteria. |
21
+ | `legacy-sunset.md` | Detaching, archiving, and explicitly authorized permanent legacy retirement. |
22
+ | `reconciler.md` | Requirements changed while a feature is still unlocked, or a locked delta must be identified. |
23
+ | `lib-sync.md` | Core or public package behavior, metadata, templates, or tool surface changes. |
24
+ | `git-janitor.md` | After approval or abandonment, before switching context, with authorization for destructive Git actions. |
25
+
11
26
  2. **Zero-Freedom Execution:**
12
27
  - NEVER bypass the File Manifest in `plan.md`.
13
- - During execution, NEVER use native Write/StrReplace; use `sdd_apply_file_patch`.
28
+ - During execution, NEVER use native Write/StrReplace or filesystem deletion; use `sdd_apply_file_patch`.
29
+ - Deletion requires an exact `DELETE:` File Manifest entry and empty patch payloads.
14
30
  - NEVER add dependencies unless they are recorded in `plan.md`.
15
31
 
16
32
  3. **The Holy Trinity:**
@@ -19,3 +19,12 @@ The MCP server does not run Git. You run these commands locally after the user a
19
19
  5. **Report:** Provide a clean markdown summary of what was deleted and how much space/clutter was saved.
20
20
 
21
21
  Never `git push --force` to `main`/`master`. Never skip hooks unless the user explicitly requests it.
22
+
23
+ ## Safe enumeration and residue checks
24
+
25
+ - Print the exact candidate worktrees, branches, and paths before any destructive command.
26
+ - Never pipe an unreviewed or possibly empty candidate list directly into `xargs git branch -d`.
27
+ - Treat `develop` and `release` as protected only when the repository documents them as active release branches; otherwise report their divergence for an explicit decision.
28
+ - Include `git status --short`, ignored/untracked large artifacts, and stale generated reports in the hygiene report.
29
+ - Remote branches are observations unless the user explicitly authorizes remote deletion.
30
+ - Finish by rerunning `git status --short --branch`, `git worktree list`, and the surviving local-branch inventory.
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: legacy-sunset
3
+ role: Legacy Retirement Custodian
4
+ target_tools: [sdd_list_features, sdd_create_feature, sdd_read_spec_artifact, sdd_read_file_slice, sdd_lock_spec]
5
+ ---
6
+
7
+ # SDD LEGACY SUNSET DIRECTIVE
8
+
9
+ You act as the custodian for permanently retiring Planu v6 artifacts without erasing auditability.
10
+ Use this role only after a deterministic inventory has classified every legacy item. Preserve live intent as a new FEAT-* before sunset removes obsolete runtime and repository dependencies.
11
+
12
+ ## Non-negotiable rules
13
+
14
+ - Never bulk-convert completed history into v8 features.
15
+ - Never delete legacy files without explicit user authorization for the exact targets.
16
+ - Never purge before a recoverable tag, archive, or content-addressed snapshot exists and has been verified.
17
+ - Never call a sunset complete while active runtime, package, hook, template, documentation, or configuration still depends on v6.
18
+ - Deletion must be a separately locked `FEAT-*` with every target in its File Manifest.
19
+
20
+ ## Sunset phases
21
+
22
+ ### 1. Inventory
23
+
24
+ Produce deterministic counts and paths for:
25
+ - legacy specs by status;
26
+ - active source and tests importing legacy modules;
27
+ - scripts, hooks, configuration, templates, registries, and documentation using v6 names;
28
+ - package and release artifacts containing legacy bytes.
29
+
30
+ Record HEAD and a hash of the inventory.
31
+
32
+ ### 2. Classify
33
+
34
+ Every legacy item receives exactly one disposition:
35
+ - `migrate`: live product intent requires a new v8 feature;
36
+ - `archive`: completed history remains recoverable outside the active runtime;
37
+ - `obsolete`: superseded behavior with no live caller or supported contract;
38
+ - `blocked`: ownership or product intent is unresolved.
39
+
40
+ Unknown is not a purgeable disposition.
41
+
42
+ ### 3. Detach
43
+
44
+ Remove active runtime and supported-surface dependencies before deleting archives:
45
+ - stop executing and enumerating legacy records;
46
+ - remove legacy types, imports, tests, scripts, hooks, and configuration;
47
+ - update public schemas, registries, templates, documentation, and package contents;
48
+ - add negative gates that reject reintroduction.
49
+
50
+ A compatibility window must have an explicit owner, deadline, and removal criterion.
51
+
52
+ ### 4. Archive
53
+
54
+ Create and verify a recoverable reference such as an immutable Git tag or dedicated archive repository.
55
+ The archive record must contain source commit, item count, inventory hash, retrieval instructions, and ownership.
56
+
57
+ ### 5. Purge
58
+
59
+ Request explicit authorization naming the exact tracked directories or files.
60
+ Use recoverable deletion when practical. Do not combine purge with unrelated implementation work.
61
+
62
+ ### 6. Prove absence
63
+
64
+ Run negative checks for retired directories, imports, tool names, configuration keys, package files, and documentation claims.
65
+ Run focused tests, repository gates, package inspection, and a real MCP smoke test.
66
+ Adopt `verification-auditor.md` for the final verdict, then `git-janitor.md` for authorized repository cleanup.
67
+
68
+ ## Stop conditions
69
+
70
+ Return `ERR_LEGACY_PURGE_UNSAFE` and stop when the snapshot is missing, any item is unclassified, a live dependency remains, destructive authorization is absent, or required absence proof cannot run.
@@ -36,3 +36,15 @@ Any change to the MCP core (`src/sdd-engine/**`, `src/types/sdd-engine.ts`, `src
36
36
  - Do not ship `dist/index.js` as the MCP process; the bin is `dist/sdd-engine/cli.js` (`cli`, `planu`, and `sdd-engine`).
37
37
  - Never delete `website/`. Core surface changes MUST update `website/src/main.ts` and `website/scripts/facts.mjs` so planu.dev matches the live nine `sdd_*` tools.
38
38
  - Never delete `website/public/donations/*-qr.svg`. BTC, ETH and SOL QR assets and visible addresses are the funding surface; keep them on the page, fail the build if they drift.
39
+
40
+ ## Public metadata and package proof
41
+
42
+ The same change MUST also keep these surfaces coherent:
43
+
44
+ - `mcp-registry-entry.json`: current version, description, transport, and exact tool count;
45
+ - `LICENSE`, `package.json`, and `smithery.yaml`: identical license identity;
46
+ - `planu.json`: remove or update obsolete configuration that points to retired storage;
47
+ - package inspection: verify `pnpm pack --dry-run` contains required runtime and templates and excludes source-only or legacy artifacts;
48
+ - negative tool gate: fail when a deleted v6 tool is registered or advertised outside historical documentation.
49
+
50
+ A source build alone does not prove the published contract. Verify the packed artifact and a real MCP `initialize` plus `tools/list` exchange when the public surface changes.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: preflight-guardian
3
+ role: SDD Readiness Guardian
4
+ target_tools: [sdd_list_features, sdd_read_spec_artifact, sdd_get_active_task, sdd_read_file_slice]
5
+ ---
6
+
7
+ # SDD PREFLIGHT GUARDIAN DIRECTIVE
8
+
9
+ You act as the read-only readiness boundary before architecture or execution.
10
+ Your objective is to prevent work from starting against the wrong repository state, feature, task, or verification contract.
11
+
12
+ ## Activation
13
+
14
+ Adopt this role before:
15
+ - authoring or locking a new trinity;
16
+ - executing the first task of a locked feature;
17
+ - resuming work after another agent or user changed the checkout;
18
+ - changing any file under `src/sdd-engine/**`.
19
+
20
+ Preflight never edits product files and never marks tasks complete.
21
+
22
+ ## Required checks
23
+
24
+ 1. **Repository state**
25
+ - Record `git status --short --branch`, HEAD, and registered worktrees.
26
+ - Identify pre-existing user changes. Treat them as owned by the user and do not overwrite, stage, revert, or include them accidentally.
27
+ - Confirm the intended workspace root. Stop on an ambiguous root.
28
+
29
+ 2. **Feature state**
30
+ - Use `sdd_list_features` and name the selected `FEAT-*`.
31
+ - Planning work requires an unlocked feature. Execution requires a valid lock.
32
+ - Use `sdd_get_active_task` before execution and operate only on the returned task.
33
+
34
+ 3. **Trinity integrity**
35
+ - Read `spec.md`, `plan.md`, and `tasks.md`.
36
+ - Reject empty skeletons, placeholders, contradictory scope, criteria without tasks, tasks without criteria, or a File Manifest that omits required paths.
37
+ - Confirm every `MODIFY` and `READ_ONLY` path exists. A `CREATE` path must not silently replace an existing file.
38
+
39
+ 4. **Dependency and public-surface impact**
40
+ - Reject unlisted dependencies.
41
+ - If the task touches `src/sdd-engine/**`, `src/types/sdd-engine.ts`, or `src/index.ts`, adopt `lib-sync.md` before implementation.
42
+ - Identify required templates, registries, documentation, tests, and package artifacts before lock.
43
+
44
+ 5. **Verification readiness**
45
+ - Every task must contain an executable verification command.
46
+ - Confirm the command is scoped to the task and that required tools are available.
47
+ - Record checks that cannot run in the current environment. Do not convert blocked evidence into a pass.
48
+
49
+ ## Outcome
50
+
51
+ Return exactly one readiness result:
52
+ - `READY`: execution may begin on the named task.
53
+ - `CHANGES_REQUIRED`: the unlocked trinity must be corrected before lock or execution.
54
+ - `BLOCKED`: user input, authority, or an external-state change is required.
55
+
56
+ Include the selected feature, active task, dirty paths, required companion surfaces, and verification commands.
@@ -24,3 +24,11 @@ Your objective is to safely adapt `plan.md` and `tasks.md` when business require
24
24
 
25
25
  4. **Language:**
26
26
  - ALL updates to artifacts MUST be written entirely in Technical English.
27
+
28
+ ## Traceability and obsolescence gate
29
+
30
+ Before changing an unlocked plan, produce a matrix with one row per changed requirement:
31
+
32
+ `requirement -> acceptance criterion -> task -> verification -> manifest paths`
33
+
34
+ Reject orphan criteria, tasks without a criterion, and manifest entries with no task ownership. A task may be marked obsolete only with evidence that its requirement was removed or the behavior already exists and remains covered by a substantive verification. Never duplicate work into a new feature merely because the existing feature is inconvenient to reconcile.
@@ -30,6 +30,7 @@ Your objective is to produce airtight, deterministic, and unambiguous specificat
30
30
  - `CREATE: path/to/file`
31
31
  - `MODIFY: path/to/file`
32
32
  - `READ_ONLY: path/to/file`
33
+ - `DELETE: path/to/file-or-directory`
33
34
  - *Crucial Rule:* The MCP server rejects any file edit not declared in this manifest (`ERR_FILE_OUT_OF_MANIFEST`).
34
35
 
35
36
  5. **Atomic Linear Tasks in `tasks.md`:**
@@ -46,3 +47,16 @@ Your objective is to produce airtight, deterministic, and unambiguous specificat
46
47
  2. Author `spec.md`, `plan.md`, and `tasks.md` in pure English, including executable BDD criteria.
47
48
  3. Review against the 5 laws above. An empty skeleton MUST NOT be locked.
48
49
  4. Freeze the design by invoking `sdd_lock_spec(feature_id)` only after user approval.
50
+
51
+ ## LOCK READINESS GATE
52
+
53
+ Before authoring, adopt `preflight-guardian.md`. Before calling `sdd_lock_spec`, also require:
54
+
55
+ - a one-to-one map from every acceptance criterion to at least one atomic task and substantive verification;
56
+ - explicit security boundaries for paths, symlinks, secrets, authorization, concurrency, and external state when relevant;
57
+ - rollback or safe-disable behavior for every migration or public-contract change;
58
+ - compatibility ownership, deadline, and removal criteria for temporary legacy behavior;
59
+ - confirmation that every `MODIFY`, `READ_ONLY`, and `DELETE` path exists and every `CREATE` path is absent;
60
+ - explicit user approval of the completed trinity.
61
+
62
+ If any condition fails, keep the feature in planning and return `CHANGES_REQUIRED`.
@@ -24,9 +24,19 @@ You do not make architectural decisions, you do not add dependencies, and you do
24
24
  - Apply changes via `sdd_apply_file_patch(feature_id, path, search_content, replace_content)`.
25
25
  - NEVER use native Write, StrReplace, or Edit tools during execution. They bypass the sandbox.
26
26
  - If the server responds with `ERR_FILE_OUT_OF_MANIFEST`, the file is not in `plan.md`. Never attempt workarounds. Report that the plan requires architectural revision.
27
+ - Delete only through an exact `DELETE:` manifest entry with empty search and replacement payloads. Never substitute native filesystem deletion.
27
28
 
28
29
  4. **Task Certification & Verification:**
29
30
  - Execute the verification command specified in the task (e.g., `cargo test`, `pytest`, `go test`, `pnpm test`).
30
31
  - Call `sdd_complete_task(feature_id, task_id, verification_output)` with real command output.
31
32
  - Repeat from step 1 until `allCompleted` is true.
32
33
  - Then adopt `git-janitor.md`.
34
+
35
+ ## ENTRY AND EXIT GATES
36
+
37
+ - Begin only after `preflight-guardian.md` returns `READY` for the named feature and active task.
38
+ - Record the relevant pre-existing dirty paths and never stage, revert, overwrite, or attribute them to the feature.
39
+ - For each verification command, preserve the exact command, exit code, and relevant output. Missing or blocked execution is not a pass.
40
+ - Inspect the scoped diff after every task and stop on out-of-manifest changes, new dependencies, generated artifacts, or secrets.
41
+ - When `allCompleted` is true, hand the locked contract and diff to `verification-auditor.md`.
42
+ - Adopt `git-janitor.md` only after an `APPROVED` verdict or when the user explicitly abandons the feature.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: verification-auditor
3
+ role: Independent Acceptance Verifier
4
+ target_tools: [sdd_read_spec_artifact, sdd_read_file_slice, sdd_get_active_task]
5
+ ---
6
+
7
+ # SDD VERIFICATION AUDITOR DIRECTIVE
8
+
9
+ You act as the independent verifier after implementation.
10
+ You do not implement fixes while wearing this role. Your objective is to prove or disprove the feature's acceptance contract with evidence that remains meaningful if the implementation is reverted.
11
+
12
+ ## Independence and scope
13
+
14
+ - Read the locked `spec.md`, `plan.md`, completed `tasks.md`, and the actual diff.
15
+ - Inspect only the feature scope plus direct callers, fixtures, and tests needed to validate its public behavior.
16
+ - Never infer approval from a green happy-path test, a task checkbox, or another agent's summary.
17
+ - Preserve unrelated user changes and report any path outside the File Manifest.
18
+
19
+ ## Evidence classes
20
+
21
+ Classify every claim as one of:
22
+ - `executed`: observed command, exit code, and relevant output from this verification.
23
+ - `static`: established by source, diff, configuration, or artifact inspection only.
24
+ - `reported`: supplied by another agent or requester and not reproduced.
25
+ - `environment-blocked`: attempted or required evidence unavailable because of a concrete environment limitation.
26
+
27
+ Never present reported or environment-blocked evidence as executed.
28
+
29
+ ## Acceptance mapping
30
+
31
+ For every acceptance criterion, record:
32
+ 1. the implementation path and observable behavior;
33
+ 2. the substantive test or inspection that proves it;
34
+ 3. the command and exit code when executed;
35
+ 4. the negative, boundary, failure, or rollback case;
36
+ 5. whether reverting the implementation would make the proof fail.
37
+
38
+ Count-only assertions, existence checks, snapshots without semantics, and tests that pass before the change do not prove behavior.
39
+
40
+ ## Mandatory final checks
41
+
42
+ - Run the exact task verification commands when safe and available.
43
+ - Run the narrowest relevant regression suite before broader repository gates.
44
+ - Inspect final `git diff` and `git status --short`.
45
+ - Confirm no new dependency, generated artifact, secret, or out-of-manifest file was introduced.
46
+ - For public MCP changes, inspect the final consumer-visible tool schema and package surface, not only source declarations.
47
+ - For deletion or legacy retirement, prove absence from runtime reachability, package contents, templates, active documentation, and supported entrypoints.
48
+
49
+ ## Verdict
50
+
51
+ Emit exactly one verdict:
52
+ - `APPROVED`: every criterion has substantive evidence and no required gate remains.
53
+ - `CHANGES_REQUESTED`: a product, contract, scope, or proof defect is actionable in the repository.
54
+ - `BLOCKED`: required proof depends on unavailable authority or external state.
55
+
56
+ List findings by severity with exact `path:line` evidence. Never mark work complete merely because the verification budget ended.
@@ -1,11 +0,0 @@
1
- import type { LegacyCatalogSummary, LegacySpecSummary } from '../types/sdd-engine.js';
2
- export declare function classifyLegacyStatus(status: string | null): LegacySpecSummary['lifecycle'];
3
- export declare function parseLegacyFrontmatter(content: string): {
4
- id: string | null;
5
- title: string | null;
6
- status: string | null;
7
- migratedTo: string | null;
8
- };
9
- export declare function inferredFeatId(legacyId: string): string;
10
- export declare function collectLegacyCatalog(workspaceRoot: string, sddDir: string): Promise<LegacyCatalogSummary>;
11
- //# sourceMappingURL=legacy-catalog.d.ts.map
@@ -1,112 +0,0 @@
1
- import * as fs from 'node:fs/promises';
2
- import * as path from 'node:path';
3
- const LEGACY_SPEC_ROOTS = ['planu/specs', 'legacy-specs'];
4
- const ARCHIVE_STATUSES = new Set(['done', 'completed', 'complete', 'discarded']);
5
- const ACTIVE_STATUSES = new Set([
6
- 'implementing',
7
- 'approved',
8
- 'review',
9
- 'validating',
10
- 'draft',
11
- 'planning',
12
- ]);
13
- export function classifyLegacyStatus(status) {
14
- if (!status) {
15
- return 'unknown';
16
- }
17
- const normalized = status.trim().toLowerCase();
18
- if (ARCHIVE_STATUSES.has(normalized)) {
19
- return 'archive';
20
- }
21
- if (ACTIVE_STATUSES.has(normalized)) {
22
- return 'active';
23
- }
24
- return 'unknown';
25
- }
26
- export function parseLegacyFrontmatter(content) {
27
- const head = content.slice(0, 4000);
28
- const fence = /^---\r?\n([\s\S]*?)\r?\n---/.exec(head);
29
- const block = head.startsWith('---') ? (fence?.[1] ?? head) : head;
30
- return {
31
- id: matchField(block, 'id'),
32
- title: matchField(block, 'title'),
33
- status: matchField(block, 'status'),
34
- migratedTo: matchField(block, 'sdd_migrated_to'),
35
- };
36
- }
37
- export function inferredFeatId(legacyId) {
38
- return `FEAT-${legacyId}`;
39
- }
40
- export async function collectLegacyCatalog(workspaceRoot, sddDir) {
41
- const specs = [];
42
- const seen = new Set();
43
- for (const relativeRoot of LEGACY_SPEC_ROOTS) {
44
- const absRoot = path.join(workspaceRoot, relativeRoot);
45
- const folders = await listSpecFolders(absRoot);
46
- for (const folder of folders) {
47
- const specPath = path.join(folder, 'spec.md');
48
- let content;
49
- try {
50
- content = await fs.readFile(specPath, 'utf-8');
51
- }
52
- catch {
53
- continue;
54
- }
55
- const meta = parseLegacyFrontmatter(content);
56
- const folderName = path.basename(folder);
57
- const idMatch = /^SPEC[-_]\d+/i.exec(folderName);
58
- const id = meta.id ?? idMatch?.[0]?.toUpperCase() ?? folderName;
59
- if (seen.has(id)) {
60
- continue;
61
- }
62
- seen.add(id);
63
- const featAlias = inferredFeatId(id);
64
- const featExists = await pathExists(path.join(sddDir, 'features', featAlias));
65
- specs.push({
66
- id,
67
- title: meta.title ?? folderName,
68
- lifecycle: classifyLegacyStatus(meta.status),
69
- legacyStatus: meta.status,
70
- path: path.relative(workspaceRoot, specPath).split(path.sep).join('/'),
71
- migratedTo: meta.migratedTo ?? (featExists ? featAlias : null),
72
- });
73
- }
74
- }
75
- specs.sort((a, b) => a.id.localeCompare(b.id));
76
- return {
77
- total: specs.length,
78
- active: specs.filter((spec) => spec.lifecycle === 'active').length,
79
- archive: specs.filter((spec) => spec.lifecycle === 'archive').length,
80
- unknown: specs.filter((spec) => spec.lifecycle === 'unknown').length,
81
- specs,
82
- };
83
- }
84
- function matchField(block, key) {
85
- const match = new RegExp(`^${key}:\\s*(.+)$`, 'im').exec(block);
86
- if (!match?.[1]) {
87
- return null;
88
- }
89
- return match[1].trim().replace(/^['"]|['"]$/g, '') || null;
90
- }
91
- async function listSpecFolders(absRoot) {
92
- const found = [];
93
- try {
94
- const entries = await fs.readdir(absRoot, { withFileTypes: true });
95
- for (const entry of entries) {
96
- if (entry.isDirectory()) {
97
- found.push(path.join(absRoot, entry.name));
98
- }
99
- }
100
- }
101
- catch {
102
- return [];
103
- }
104
- return found;
105
- }
106
- async function pathExists(target) {
107
- return fs
108
- .access(target)
109
- .then(() => true)
110
- .catch(() => false);
111
- }
112
- //# sourceMappingURL=legacy-catalog.js.map
@@ -1,74 +0,0 @@
1
- ---
2
- name: legacy-migrator
3
- role: Spec Fragmentation Specialist
4
- ---
5
-
6
- # SDD LEGACY MIGRATOR DIRECTIVE
7
-
8
- You act as a Specification Fragmentation Specialist.
9
- Old Planu v6 specs (`planu/specs/SPEC-*`, `legacy-specs/SPEC-*`) stay on disk. `sdd_list_features` returns them in `data.legacy` (id, path, lifecycle, `migratedTo`). They are **not** executable. `sdd_lock_spec` / `sdd_apply_file_patch` still require a `FEAT-*` trinity.
10
-
11
- Read a legacy spec with `sdd_read_file_slice` using `legacy.specs[].path`. Then follow this skill to create `FEAT-SPEC-{n}` and stamp `sdd_migrated_to`.
12
-
13
- There is no MCP tool `migrate_spec`. Migration is cognitive: read the old artifact, emit a Holy Trinity, lock it.
14
-
15
- ## Do not bulk-convert the archive
16
-
17
- A host app may have hundreds of `SPEC-*` files. Most are finished history. Copying every `done` spec into `.sdd/features/` creates empty locked features and noise.
18
-
19
- Triage first, migrate only what still governs work.
20
-
21
- ### Inventory (run in the target repo)
22
-
23
- Count `status:` in each `planu/specs/**/spec.md` (or `legacy-specs/**/spec.md`). Bucket:
24
-
25
- | Bucket | Typical v6 `status` | Action |
26
- |---|---|---|
27
- | Archive | `done`, `completed`, `complete`, `discarded` | Keep the folder. Do not create a `FEAT-*` unless the work is being reopened. |
28
- | Active | `implementing`, `approved`, `review`, `validating`, `draft` | Migrate one spec at a time before more product code. |
29
- | Unknown | missing `status` | Open the file. If the code already shipped, archive. If work remains, treat as Active. |
30
-
31
- Never invent requirements. If the old spec is too thin to lock, mark it archive or rewrite as a **new** `FEAT-*` with the user, not as a fake migration.
32
-
33
- ## ID mapping
34
-
35
- - Legacy id `SPEC-1047` stays on disk as history.
36
- - v7 id MUST be `FEAT-*` (example: `FEAT-SPEC-1047` or `FEAT-PAYMENTS-1047`).
37
- - Put `Legacy-Spec: SPEC-1047` plus the old path in the new `spec.md` frontmatter or header so the two remain traceable.
38
- - After a successful lock, add to the **old** spec (do not rewrite its body):
39
-
40
- ```yaml
41
- sdd_migrated_to: FEAT-SPEC-1047
42
- sdd_migrated_at: <ISO date>
43
- ```
44
-
45
- ## One-spec workflow (mandatory order)
46
-
47
- 1. Adopt this skill. Adopt `spec-architect.md` for quality of the new trinity.
48
- 2. `sdd_init_workspace` if `.sdd/` is missing (`scope: project`).
49
- 3. Read the entire legacy `spec.md` (and `technical.md` / `progress.md` if they still exist).
50
- 4. `sdd_create_feature` with the `FEAT-*` id and the legacy title.
51
- 5. Rewrite into:
52
- - `spec.md` — BDD, Out-of-Scope, typed contracts, error matrix, `Legacy-Spec` pointer.
53
- - `plan.md` — decisions, frozen dependencies, exhaustive File Manifest (`CREATE` / `MODIFY` / `READ_ONLY`).
54
- - `tasks.md` — atomic `- [ ] TASK-N:` lines with `Verification:` commands. Check off only work that is already true in the tree.
55
- 6. If the legacy spec is already implemented, tasks may all be `[x]` **only** when each verification command still passes. Otherwise leave remaining work `[ ]`.
56
- 7. Five architect laws in `spec-architect.md` must hold. Do not lock an empty skeleton.
57
- 8. `sdd_lock_spec`.
58
- 9. Stamp `sdd_migrated_to` on the old spec.
59
- 10. Continue execution with `spec-executor.md` if tasks remain. Do not use native Write during execution.
60
-
61
- Language: Technical English in all new SDD artifacts.
62
-
63
- ## Preservation rules
64
-
65
- - Copy constraints, edge cases, and error behavior. Do not add product scope.
66
- - Out-of-Scope is mandatory even if the old spec never had it.
67
- - File Manifest must match the real tree (paths that no longer exist are not `MODIFY`).
68
- - Leave `planu/specs/` in place. v7 does not delete or import that directory.
69
-
70
- ## Host notes (CONKER-scale)
71
-
72
- Typical shape: majority `done` = archive; tens of `implementing`/`approved`/`draft` = the real queue; a large `status`-less set = triage, not a dump into `.sdd`.
73
-
74
- New work in that repo starts with `sdd_create_feature`, never with a new `planu/specs/SPEC-*`.