@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 +37 -2
- package/README.md +10 -10
- package/dist/sdd-engine/contracts.d.ts +4 -2
- package/dist/sdd-engine/contracts.js +3 -2
- package/dist/sdd-engine/patch-sandbox.d.ts +12 -5
- package/dist/sdd-engine/patch-sandbox.js +147 -21
- package/dist/sdd-engine/server.js +2 -2
- package/dist/sdd-engine/tools/execution-tools.js +22 -1
- package/dist/sdd-engine/tools/workspace-tools.js +111 -23
- package/dist/sdd-engine/workspace-root.d.ts +3 -1
- package/dist/sdd-engine/workspace-root.js +17 -0
- package/dist/types/sdd-engine.d.ts +8 -18
- package/package.json +4 -3
- package/templates/AGENTS.md +21 -5
- package/templates/skills/git-janitor.md +9 -0
- package/templates/skills/legacy-sunset.md +70 -0
- package/templates/skills/lib-sync.md +12 -0
- package/templates/skills/preflight-guardian.md +56 -0
- package/templates/skills/reconciler.md +8 -0
- package/templates/skills/spec-architect.md +14 -0
- package/templates/skills/spec-executor.md +10 -0
- package/templates/skills/verification-auditor.md +56 -0
- package/dist/sdd-engine/legacy-catalog.d.ts +0 -11
- package/dist/sdd-engine/legacy-catalog.js +0 -112
- package/templates/skills/legacy-migrator.md +0 -74
|
@@ -6,7 +6,7 @@ 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 {
|
|
9
|
+
import { homeFallbackFailure } from '../workspace-root.js';
|
|
10
10
|
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
11
|
export function registerWorkspaceTools(server, workspace) {
|
|
12
12
|
const taskWindow = new TaskWindowManager();
|
|
@@ -22,6 +22,12 @@ function registerInitTool(server, workspace) {
|
|
|
22
22
|
}, async (rawArgs) => {
|
|
23
23
|
const args = InitWorkspaceInputSchema.parse(rawArgs);
|
|
24
24
|
const resolved = await workspace.resolve();
|
|
25
|
+
if (args.scope === 'project') {
|
|
26
|
+
const homeError = homeFallbackFailure(resolved, 'sdd_init_workspace');
|
|
27
|
+
if (homeError) {
|
|
28
|
+
return formatResult(homeError);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
25
31
|
const targetBase = args.scope === 'global'
|
|
26
32
|
? path.join(process.env.HOME ?? '~', '.config', 'sdd')
|
|
27
33
|
: resolved.sddDir;
|
|
@@ -46,20 +52,22 @@ function registerInitTool(server, workspace) {
|
|
|
46
52
|
}
|
|
47
53
|
function registerListTool(server, workspace, taskWindow) {
|
|
48
54
|
server.registerTool('sdd_list_features', {
|
|
49
|
-
description: 'Lists
|
|
55
|
+
description: 'Lists executable Planu v8 FEAT-* features from .sdd/features only.',
|
|
50
56
|
inputSchema: ListFeaturesInputSchema.shape,
|
|
51
57
|
}, async (rawArgs) => {
|
|
52
58
|
const args = ListFeaturesInputSchema.parse(rawArgs);
|
|
53
59
|
const resolved = await workspace.resolve();
|
|
60
|
+
const homeError = homeFallbackFailure(resolved, 'sdd_list_features');
|
|
61
|
+
if (homeError) {
|
|
62
|
+
return formatResult(homeError);
|
|
63
|
+
}
|
|
54
64
|
const featuresDir = path.join(resolved.sddDir, 'features');
|
|
55
65
|
const featuresList = await collectFeatures(featuresDir, taskWindow, args.status_filter);
|
|
56
|
-
const legacy = await collectLegacyCatalog(resolved.workspaceRoot, resolved.sddDir);
|
|
57
66
|
return formatResult({
|
|
58
67
|
success: true,
|
|
59
68
|
data: {
|
|
60
69
|
total: featuresList.length,
|
|
61
70
|
features: featuresList,
|
|
62
|
-
legacy,
|
|
63
71
|
workspaceRoot: resolved.workspaceRoot,
|
|
64
72
|
sddPresent: resolved.sddPresent,
|
|
65
73
|
source: resolved.source,
|
|
@@ -70,34 +78,48 @@ function registerListTool(server, workspace, taskWindow) {
|
|
|
70
78
|
}
|
|
71
79
|
function registerCreateTool(server, workspace) {
|
|
72
80
|
server.registerTool('sdd_create_feature', {
|
|
73
|
-
description: 'Creates a
|
|
81
|
+
description: 'Creates a Holy Trinity feature. Omit id to atomically reserve the next global FEAT-NNNN-TITLE identifier; explicit FEAT-* IDs remain supported.',
|
|
74
82
|
inputSchema: CreateFeatureInputSchema.shape,
|
|
75
83
|
}, async (rawArgs) => {
|
|
76
84
|
const args = CreateFeatureInputSchema.parse(rawArgs);
|
|
77
85
|
const resolved = await workspace.resolve();
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
await fs.mkdir(featDir);
|
|
86
|
+
const homeError = homeFallbackFailure(resolved, 'sdd_create_feature');
|
|
87
|
+
if (homeError) {
|
|
88
|
+
return formatResult(homeError);
|
|
82
89
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
});
|
|
90
|
+
const featuresDir = path.join(resolved.sddDir, 'features');
|
|
91
|
+
await fs.mkdir(featuresDir, { recursive: true });
|
|
92
|
+
let featureId = args.id;
|
|
93
|
+
let featDir;
|
|
94
|
+
if (featureId) {
|
|
95
|
+
featDir = path.join(featuresDir, featureId);
|
|
96
|
+
try {
|
|
97
|
+
await fs.mkdir(featDir);
|
|
93
98
|
}
|
|
94
|
-
|
|
99
|
+
catch (err) {
|
|
100
|
+
if (isNodeErrorCode(err, 'EEXIST')) {
|
|
101
|
+
return formatResult({
|
|
102
|
+
success: false,
|
|
103
|
+
error: {
|
|
104
|
+
code: 'ERR_FEATURE_ALREADY_EXISTS',
|
|
105
|
+
message: `Feature '${featureId}' already exists in the workspace.`,
|
|
106
|
+
trigger: 'sdd_create_feature',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const reservation = await reserveAutomaticFeatureDirectory(featuresDir, args.title);
|
|
115
|
+
featureId = reservation.featureId;
|
|
116
|
+
featDir = reservation.featDir;
|
|
95
117
|
}
|
|
96
|
-
await writeFeatureArtifacts(featDir,
|
|
118
|
+
await writeFeatureArtifacts(featDir, featureId, args.title);
|
|
97
119
|
return formatResult({
|
|
98
120
|
success: true,
|
|
99
121
|
data: {
|
|
100
|
-
featureId
|
|
122
|
+
featureId,
|
|
101
123
|
artifactsCreated: ['spec.md', 'plan.md', 'tasks.md'],
|
|
102
124
|
directory: featDir,
|
|
103
125
|
workspaceRoot: resolved.workspaceRoot,
|
|
@@ -105,6 +127,68 @@ function registerCreateTool(server, workspace) {
|
|
|
105
127
|
});
|
|
106
128
|
});
|
|
107
129
|
}
|
|
130
|
+
async function reserveAutomaticFeatureDirectory(featuresDir, title) {
|
|
131
|
+
const entries = await fs.readdir(featuresDir, { withFileTypes: true });
|
|
132
|
+
const featureNames = entries
|
|
133
|
+
.filter((entry) => entry.isDirectory() && /^FEAT[-_]/u.test(entry.name))
|
|
134
|
+
.map((entry) => entry.name);
|
|
135
|
+
const allocatedSequences = entries.flatMap((entry) => {
|
|
136
|
+
if (!entry.isDirectory()) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
const sequence = /^FEAT-(\d+)-/u.exec(entry.name)?.[1] ?? /^\.FEAT-(\d+)\.reserve$/u.exec(entry.name)?.[1];
|
|
140
|
+
return sequence ? [Number(sequence)] : [];
|
|
141
|
+
});
|
|
142
|
+
const highestSequence = Math.max(0, ...allocatedSequences);
|
|
143
|
+
let nextSequence = Math.max(highestSequence + 1, featureNames.length + 1);
|
|
144
|
+
const slug = createFeatureSlug(title);
|
|
145
|
+
for (;;) {
|
|
146
|
+
const sequenceLabel = String(nextSequence).padStart(4, '0');
|
|
147
|
+
const reservationDir = path.join(featuresDir, `.FEAT-${sequenceLabel}.reserve`);
|
|
148
|
+
try {
|
|
149
|
+
await fs.mkdir(reservationDir);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
if (!isNodeErrorCode(err, 'EEXIST')) {
|
|
153
|
+
throw err;
|
|
154
|
+
}
|
|
155
|
+
nextSequence += 1;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const featureId = `FEAT-${sequenceLabel}-${slug}`;
|
|
159
|
+
const featDir = path.join(featuresDir, featureId);
|
|
160
|
+
try {
|
|
161
|
+
await fs.mkdir(featDir);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
await fs.rm(reservationDir, { recursive: true, force: true });
|
|
165
|
+
if (isNodeErrorCode(err, 'EEXIST')) {
|
|
166
|
+
nextSequence += 1;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
throw err;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
await fs.rm(reservationDir, { recursive: true, force: false });
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
await fs.rm(featDir, { recursive: true, force: true });
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
return { featureId, featDir };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function createFeatureSlug(title) {
|
|
182
|
+
const slug = title
|
|
183
|
+
.normalize('NFKD')
|
|
184
|
+
.replace(/[\u0300-\u036f]/gu, '')
|
|
185
|
+
.toUpperCase()
|
|
186
|
+
.replace(/[^A-Z0-9]+/gu, '-')
|
|
187
|
+
.replace(/^-+|-+$/gu, '')
|
|
188
|
+
.slice(0, 48)
|
|
189
|
+
.replace(/-+$/gu, '');
|
|
190
|
+
return slug || 'FEATURE';
|
|
191
|
+
}
|
|
108
192
|
function registerLockTool(server, workspace) {
|
|
109
193
|
server.registerTool('sdd_lock_spec', {
|
|
110
194
|
description: 'Locks spec.md and plan.md with cryptographic digests to enable execution phase.',
|
|
@@ -112,6 +196,10 @@ function registerLockTool(server, workspace) {
|
|
|
112
196
|
}, async (rawArgs) => {
|
|
113
197
|
const args = LockSpecInputSchema.parse(rawArgs);
|
|
114
198
|
const resolved = await workspace.resolve();
|
|
199
|
+
const homeError = homeFallbackFailure(resolved, 'sdd_lock_spec');
|
|
200
|
+
if (homeError) {
|
|
201
|
+
return formatResult(homeError);
|
|
202
|
+
}
|
|
115
203
|
const featDir = path.join(resolved.sddDir, 'features', args.feature_id);
|
|
116
204
|
return executeLockSpec(featDir, args.feature_id);
|
|
117
205
|
});
|
|
@@ -178,7 +266,7 @@ async function collectFeatures(featuresDir, taskWindow, statusFilter) {
|
|
|
178
266
|
}
|
|
179
267
|
async function writeFeatureArtifacts(featDir, id, title) {
|
|
180
268
|
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`;
|
|
269
|
+
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
270
|
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
271
|
await fs.writeFile(path.join(featDir, 'spec.md'), initialSpec, 'utf-8');
|
|
184
272
|
await fs.writeFile(path.join(featDir, 'plan.md'), initialPlan, 'utf-8');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { ResolvedSddWorkspace, ResolveSddWorkspaceInput } from '../types/sdd-engine.js';
|
|
1
|
+
import type { ResolvedSddWorkspace, ResolveSddWorkspaceInput, SddFailure } from '../types/sdd-engine.js';
|
|
2
2
|
export declare function parseMcpRootUri(uri: string): string | null;
|
|
3
3
|
export declare function resolveSddWorkspaceRoot(startDir?: string, env?: NodeJS.ProcessEnv, mcpRootUris?: readonly string[]): string;
|
|
4
4
|
export declare function resolveSddWorkspace(input?: ResolveSddWorkspaceInput): ResolvedSddWorkspace;
|
|
5
|
+
export declare function isHomeFallbackWorkspace(resolved: ResolvedSddWorkspace, env?: NodeJS.ProcessEnv): boolean;
|
|
6
|
+
export declare function homeFallbackFailure(resolved: ResolvedSddWorkspace, trigger: string, env?: NodeJS.ProcessEnv): SddFailure | null;
|
|
5
7
|
//# sourceMappingURL=workspace-root.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
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.';
|
|
4
5
|
export function parseMcpRootUri(uri) {
|
|
5
6
|
const trimmed = uri.trim();
|
|
6
7
|
if (!trimmed) {
|
|
@@ -50,6 +51,22 @@ export function resolveSddWorkspace(input = {}) {
|
|
|
50
51
|
}
|
|
51
52
|
return finish(startDir, 'fallback');
|
|
52
53
|
}
|
|
54
|
+
export function isHomeFallbackWorkspace(resolved, env = process.env) {
|
|
55
|
+
return resolved.source === 'fallback' && isHomeDirectory(resolved.workspaceRoot, env);
|
|
56
|
+
}
|
|
57
|
+
export function homeFallbackFailure(resolved, trigger, env = process.env) {
|
|
58
|
+
if (!isHomeFallbackWorkspace(resolved, env)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: {
|
|
64
|
+
code: 'ERR_WORKSPACE_UNRESOLVED',
|
|
65
|
+
message: ERR_WORKSPACE_UNRESOLVED_MESSAGE,
|
|
66
|
+
trigger,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
53
70
|
function finish(workspaceRoot, source) {
|
|
54
71
|
const sddDir = join(workspaceRoot, '.sdd');
|
|
55
72
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type ArtifactType = 'spec' | 'plan' | 'tasks';
|
|
2
|
-
export type FilePermission = 'CREATE' | 'MODIFY' | 'READ_ONLY';
|
|
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';
|
|
2
|
+
export type FilePermission = 'CREATE' | 'MODIFY' | 'READ_ONLY' | 'DELETE';
|
|
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' | 'ERR_WORKSPACE_UNRESOLVED';
|
|
4
4
|
export interface SddErrorDetails {
|
|
5
5
|
code: ErrorCode;
|
|
6
6
|
message: string;
|
|
@@ -24,7 +24,7 @@ export interface ListFeaturesInput {
|
|
|
24
24
|
status_filter?: 'all' | 'planning' | 'executing' | 'done';
|
|
25
25
|
}
|
|
26
26
|
export interface CreateFeatureInput {
|
|
27
|
-
id
|
|
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": "
|
|
3
|
+
"version": "8.1.1",
|
|
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",
|
|
@@ -104,8 +104,9 @@
|
|
|
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
|
|
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",
|
package/templates/AGENTS.md
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
# SDD Engine
|
|
1
|
+
# SDD Engine v8 — Master Global Rules
|
|
2
2
|
|
|
3
|
-
You are operating within a Spec-Driven Development environment (Planu
|
|
4
|
-
Canonical contract: `
|
|
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
|
|
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. If `sdd_list_features` returns `ERR_WORKSPACE_UNRESOLVED`, stop: do not initialize `.sdd` under `$HOME`. Advertise MCP roots or set the MCP server cwd to the project.
|
|
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
|