@planu/cli 8.1.2 → 8.2.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 +15 -0
- package/README.md +16 -9
- package/dist/sdd-engine/contracts.d.ts +4 -0
- package/dist/sdd-engine/contracts.js +4 -0
- package/dist/sdd-engine/host-rule-pack.d.ts +4 -0
- package/dist/sdd-engine/host-rule-pack.js +90 -0
- package/dist/sdd-engine/lock-integrity.d.ts +15 -1
- package/dist/sdd-engine/lock-integrity.js +177 -3
- package/dist/sdd-engine/patch-sandbox.d.ts +2 -2
- package/dist/sdd-engine/patch-sandbox.js +100 -56
- package/dist/sdd-engine/server.js +1 -1
- package/dist/sdd-engine/task-window.js +35 -14
- package/dist/sdd-engine/tools/workspace-tools.js +36 -49
- package/dist/types/sdd-engine.d.ts +13 -1
- package/package.json +1 -1
- package/templates/AGENTS.md +12 -2
- package/templates/host/planu-sdd.md +9 -0
- package/templates/skills/git-janitor.md +4 -0
- package/templates/skills/lib-sync.md +1 -0
- package/templates/skills/preflight-guardian.md +4 -0
- package/templates/skills/reconciler.md +2 -2
- package/templates/skills/spec-architect.md +5 -1
- package/templates/skills/spec-executor.md +1 -0
- package/templates/skills/verification-auditor.md +1 -0
- package/templates/skills/visual-release-auditor.md +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [8.2.1] - 2026-09-21
|
|
4
|
+
|
|
5
|
+
- reject `sdd_apply_file_patch` under `planu/specs`; `sdd_list_features` / `sdd_init_workspace` warn when that tree exists, without a `legacy` catalog
|
|
6
|
+
- forbid `SPEC-*` stubs in skills: retire host hooks that still require `planu/specs/SPEC-*/spec.md`
|
|
7
|
+
- `sdd_init_workspace` always writes Planu-owned Cursor/Claude/Gemini host rules so FEAT-only wins over leftover v6 docs
|
|
8
|
+
- replace `AGENTS.md` only when it still requires `planu/specs/SPEC-*` or instructs calling `create_spec`; never clobber project `CLAUDE.md`
|
|
9
|
+
|
|
10
|
+
## [8.2.0] - 2026-09-21
|
|
11
|
+
|
|
12
|
+
- preserve existing `AGENTS.md` on `sdd_init_workspace` unless `force: true`
|
|
13
|
+
- `sdd_lock_spec` relock with `reason`, structural trinity gate, and `tasksHash`
|
|
14
|
+
- count every checkbox in `sdd_get_active_task`; File Manifest `*`/`**` for CREATE/MODIFY/READ_ONLY
|
|
15
|
+
|
|
1
16
|
## [8.1.2] - 2026-09-21
|
|
2
17
|
|
|
3
18
|
- ignore unexpanded `${workspaceFolder}` and a `PLANU_WORKSPACE` equal to `$HOME` so Cursor/Windsurf interpolation stays per-project
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Authentication is **not required**. Do not call `mcp_auth`.
|
|
|
25
25
|
|
|
26
26
|
## Installation
|
|
27
27
|
|
|
28
|
-
Paste this into **Claude Code, Cursor, Windsurf, Codex, or any MCP client**. Prefer a **project** config
|
|
28
|
+
Paste this into **Claude Code, Cursor, Windsurf, Codex, Copilot, Gemini CLI, OpenCode, or any stdio MCP client**. Prefer a **project** config so the host can bind the open folder. A user-global server with no workspace interpolation will start in `$HOME` and fail closed.
|
|
29
29
|
|
|
30
30
|
```json
|
|
31
31
|
{
|
|
@@ -44,9 +44,15 @@ Paste this into **Claude Code, Cursor, Windsurf, Codex, or any MCP client**. Pre
|
|
|
44
44
|
| Host | Where to put it | How the project is bound |
|
|
45
45
|
|---|---|---|
|
|
46
46
|
| Cursor | `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` | `${workspaceFolder}` is interpolated into `PLANU_WORKSPACE` (absolute or `~/...`). Cursor user-global `cwd` is not reliable. |
|
|
47
|
-
| Claude Code | `.mcp.json` in the project
|
|
48
|
-
|
|
|
49
|
-
|
|
|
47
|
+
| Claude Code | `.mcp.json` in the project | Process cwd is the launch directory; unexpanded `${workspaceFolder}` is ignored. |
|
|
48
|
+
| Codex | `.codex/config.toml` (trusted project) or `~/.codex/config.toml` | TOML `[mcp_servers.planu]`. ChatGPT desktop, Codex CLI, and Codex IDE share this file. Set `cwd` to the repo. JSON `mcpServers` is the wrong format. |
|
|
49
|
+
| Copilot / VS Code | `.vscode/mcp.json` | Top-level key is `servers`. `${workspaceFolder}` is interpolated. |
|
|
50
|
+
| Gemini CLI | `.gemini/settings.json` | `mcpServers` JSON. No `${workspaceFolder}` interpolation; use repo `cwd`. |
|
|
51
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | User-global Cascade config. Prefer an absolute project `PLANU_WORKSPACE`; do not use `$HOME`. |
|
|
52
|
+
| OpenCode | `opencode.json` | `mcp.planu` with `type: "local"` and a command array. |
|
|
53
|
+
| Claude Desktop | `claude_desktop_config.json` | `mcpServers` JSON. Set `PLANU_WORKSPACE` to an absolute project path. |
|
|
54
|
+
| ChatGPT web | Plugins / remote MCP only | Cannot spawn local stdio. Use Codex desktop or CLI for Planu. |
|
|
55
|
+
| Other stdio | Cline, Zed, JetBrains, Amazon Q | Same `npx -y @planu/cli@latest` process; bind via cwd, roots, or `PLANU_WORKSPACE`. |
|
|
50
56
|
|
|
51
57
|
`npx @planu/cli` starts the MCP stdio server (`cli`, `planu`, and `sdd-engine` are the same binary). Each host restart resolves **latest** from npm.
|
|
52
58
|
|
|
@@ -66,7 +72,7 @@ Local development in this repo:
|
|
|
66
72
|
}
|
|
67
73
|
```
|
|
68
74
|
|
|
69
|
-
The published server asks the host for MCP roots and binds to the open project that owns `.sdd/`. Unexpanded `${workspaceFolder}` and a `PLANU_WORKSPACE` equal to `$HOME` are ignored. A `~/...` workspace path is expanded against `$HOME` so hosts that interpolate tildes still bind the open folder. If the process cwd is still the user home directory, project-scoped tools return `ERR_WORKSPACE_UNRESOLVED` instead of creating `.sdd` under `$HOME`. Do not set a shell-global `PLANU_WORKSPACE`. `pnpm start` runs the MCP server.
|
|
75
|
+
The published server asks the host for MCP roots and binds to the open project that owns `.sdd/`. Unexpanded `${workspaceFolder}` and a `PLANU_WORKSPACE` equal to `$HOME` are ignored. A `~/...` workspace path is expanded against `$HOME` so hosts that interpolate tildes still bind the open folder. If the process cwd is still the user home directory, project-scoped tools return `ERR_WORKSPACE_UNRESOLVED` instead of creating `.sdd` under `$HOME`. `sdd_init_workspace` always writes Planu-owned Cursor, Claude, and Gemini host rules. Existing `AGENTS.md` is preserved unless `force: true` or the file still requires `planu/specs/SPEC-*` or instructs calling `create_spec`. `sdd_lock_spec` refuses empty skeletons and can reseal with `relock: true` and `reason`. Do not set a shell-global `PLANU_WORKSPACE`. `pnpm start` runs the MCP server.
|
|
70
76
|
|
|
71
77
|
**Requirements:** Node.js >= 22.13.
|
|
72
78
|
|
|
@@ -78,11 +84,12 @@ The published server asks the host for MCP roots and binds to the open project t
|
|
|
78
84
|
sdd_init_workspace → sdd_create_feature → architect trinity → sdd_lock_spec → execute tasks → verify → git-janitor
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
1. **Initialize:** `sdd_init_workspace` writes `.sdd
|
|
87
|
+
1. **Initialize:** `sdd_init_workspace` writes `.sdd/`, copies skills, and stamps `.cursor/rules/planu-sdd.mdc`, `.claude/rules/planu-sdd.md`, and `.gemini/planu-sdd.md`. Existing `AGENTS.md` is preserved unless `force: true` or it is still a v6 host contract.
|
|
82
88
|
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.
|
|
83
|
-
3. **Lock:** `sdd_lock_spec` hashes spec
|
|
84
|
-
4. **Execute:** `sdd_get_active_task` → `sdd_apply_file_patch` → `sdd_complete_task`. CREATE, MODIFY, READ_ONLY
|
|
85
|
-
5. **Verify:** independently prove acceptance criteria with `verification-auditor.md
|
|
89
|
+
3. **Lock:** `sdd_lock_spec` hashes spec, plan, and tasks. It rejects empty skeletons. Reseal after review with `relock: true` and `reason`.
|
|
90
|
+
4. **Execute:** `sdd_get_active_task` → `sdd_apply_file_patch` → `sdd_complete_task`. CREATE, MODIFY, and READ_ONLY may use `*` / `**` (dot-prefixed segments require an exact entry). DELETE is an exact path. `.sdd/` and `.git/` are never writable.
|
|
91
|
+
5. **Verify:** independently prove acceptance criteria with `verification-auditor.md`.
|
|
92
|
+
6. **Janitor:** prune local branches and orphaned worktrees only with authorization.
|
|
86
93
|
|
|
87
94
|
`sdd_list_features` enumerates executable `.sdd/features/FEAT-*` records only. Historical v6 records are not executed, enumerated, generated, or shipped by the v8 runtime.
|
|
88
95
|
|
|
@@ -18,6 +18,7 @@ export declare const ErrorCodeSchema: z.ZodEnum<{
|
|
|
18
18
|
ERR_FILE_OUT_OF_MANIFEST: "ERR_FILE_OUT_OF_MANIFEST";
|
|
19
19
|
ERR_INVALID_ARTIFACT: "ERR_INVALID_ARTIFACT";
|
|
20
20
|
ERR_INVALID_SLICE: "ERR_INVALID_SLICE";
|
|
21
|
+
ERR_LOCK_REASON_REQUIRED: "ERR_LOCK_REASON_REQUIRED";
|
|
21
22
|
ERR_PATCH_FAILED: "ERR_PATCH_FAILED";
|
|
22
23
|
ERR_PERMISSION_VIOLATION: "ERR_PERMISSION_VIOLATION";
|
|
23
24
|
ERR_SPEC_ALREADY_LOCKED: "ERR_SPEC_ALREADY_LOCKED";
|
|
@@ -25,6 +26,7 @@ export declare const ErrorCodeSchema: z.ZodEnum<{
|
|
|
25
26
|
ERR_SPEC_NOT_LOCKED: "ERR_SPEC_NOT_LOCKED";
|
|
26
27
|
ERR_TASK_NOT_FOUND: "ERR_TASK_NOT_FOUND";
|
|
27
28
|
ERR_TASK_OUT_OF_SEQUENCE: "ERR_TASK_OUT_OF_SEQUENCE";
|
|
29
|
+
ERR_TRINITY_INCOMPLETE: "ERR_TRINITY_INCOMPLETE";
|
|
28
30
|
ERR_WORKSPACE_UNRESOLVED: "ERR_WORKSPACE_UNRESOLVED";
|
|
29
31
|
}>;
|
|
30
32
|
export declare const InitWorkspaceInputSchema: z.ZodObject<{
|
|
@@ -48,6 +50,8 @@ export declare const CreateFeatureInputSchema: z.ZodObject<{
|
|
|
48
50
|
}, z.core.$strip>;
|
|
49
51
|
export declare const LockSpecInputSchema: z.ZodObject<{
|
|
50
52
|
feature_id: z.ZodString;
|
|
53
|
+
relock: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
51
55
|
}, z.core.$strip>;
|
|
52
56
|
export declare const ReadSpecArtifactInputSchema: z.ZodObject<{
|
|
53
57
|
feature_id: z.ZodString;
|
|
@@ -21,6 +21,8 @@ export const ErrorCodeSchema = z.enum([
|
|
|
21
21
|
'ERR_INVALID_ARTIFACT',
|
|
22
22
|
'ERR_INVALID_SLICE',
|
|
23
23
|
'ERR_WORKSPACE_UNRESOLVED',
|
|
24
|
+
'ERR_TRINITY_INCOMPLETE',
|
|
25
|
+
'ERR_LOCK_REASON_REQUIRED',
|
|
24
26
|
]);
|
|
25
27
|
export const InitWorkspaceInputSchema = z.object({
|
|
26
28
|
scope: z.enum(['global', 'project']),
|
|
@@ -35,6 +37,8 @@ export const CreateFeatureInputSchema = z.object({
|
|
|
35
37
|
});
|
|
36
38
|
export const LockSpecInputSchema = z.object({
|
|
37
39
|
feature_id: FeatureIdSchema,
|
|
40
|
+
relock: z.boolean().optional(),
|
|
41
|
+
reason: z.string().optional(),
|
|
38
42
|
});
|
|
39
43
|
export const ReadSpecArtifactInputSchema = z.object({
|
|
40
44
|
feature_id: FeatureIdSchema,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isStaleV6HostDoc(content: string): boolean;
|
|
2
|
+
export declare function copyGlobalRules(workspaceRoot: string, force?: boolean): Promise<'preserved' | 'replaced' | 'created'>;
|
|
3
|
+
export declare function installHostRulePack(workspaceRoot: string): Promise<string[]>;
|
|
4
|
+
//# sourceMappingURL=host-rule-pack.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const TEMPLATES_ROOT = path.resolve(moduleDir, '..', '..', 'templates');
|
|
6
|
+
const FALLBACK_HOST_BODY = `# Planu v8 host contract
|
|
7
|
+
|
|
8
|
+
The only SDD contract is \`.sdd/features/{FEAT-*}/spec.md\`, \`plan.md\`, and \`tasks.md\`.
|
|
9
|
+
|
|
10
|
+
- Feature IDs are \`FEAT-*\`. \`SPEC-001\` is invalid.
|
|
11
|
+
- Use the nine \`sdd_*\` tools. Never call deleted v6 tools (\`create_spec\`, \`challenge_spec\`, \`check_readiness\`, \`validate\`, \`planu_status\`, …).
|
|
12
|
+
- Never create, thin, or copy files under \`planu/specs/\`. Planu does not read that tree.
|
|
13
|
+
- If a pre-push, commitlint, or husky guard still requires \`planu/specs/SPEC-*/spec.md\`, that guard is the defect. Delete or rewrite it. Do not stub a SPEC file.
|
|
14
|
+
- Quality lives in \`.sdd/skills/\`. There is no validate MCP tool.
|
|
15
|
+
`;
|
|
16
|
+
const PROHIBITION = /\b(never|do not|don't|no longer|not|forbidden|prohibited|deleted|removed|retired|invalid|reject(?:s|ed)?)\b/iu;
|
|
17
|
+
const LEGACY_TREE = /planu\/specs\/SPEC-|write (?:specs )?to planu\/specs/iu;
|
|
18
|
+
const INSTRUCTS_CREATE_SPEC = /(?:call|calls|calling|use|uses|using|run|runs|running|invoke|invokes|invoking)\s+`?create_spec`?/iu;
|
|
19
|
+
function normalizeWraps(content) {
|
|
20
|
+
return content.replace(/\n[ \t]+(?![-*+]\s|\d+[.)]\s|#)/gu, ' ');
|
|
21
|
+
}
|
|
22
|
+
function sentencesOf(content) {
|
|
23
|
+
return normalizeWraps(content)
|
|
24
|
+
.split(/\n+|(?<=[.!?])\s+/)
|
|
25
|
+
.map((part) => part.trim())
|
|
26
|
+
.filter((part) => part.length > 0);
|
|
27
|
+
}
|
|
28
|
+
function isRequiredMention(sentence, mention) {
|
|
29
|
+
return mention.test(sentence) && !PROHIBITION.test(sentence);
|
|
30
|
+
}
|
|
31
|
+
export function isStaleV6HostDoc(content) {
|
|
32
|
+
return sentencesOf(content).some((sentence) => isRequiredMention(sentence, LEGACY_TREE) ||
|
|
33
|
+
isRequiredMention(sentence, INSTRUCTS_CREATE_SPEC));
|
|
34
|
+
}
|
|
35
|
+
export async function copyGlobalRules(workspaceRoot, force) {
|
|
36
|
+
const sourcePath = path.join(TEMPLATES_ROOT, 'AGENTS.md');
|
|
37
|
+
const targetPath = path.resolve(workspaceRoot, 'AGENTS.md');
|
|
38
|
+
const existed = await fs
|
|
39
|
+
.access(targetPath)
|
|
40
|
+
.then(() => true)
|
|
41
|
+
.catch(() => false);
|
|
42
|
+
const existing = existed ? await fs.readFile(targetPath, 'utf-8') : '';
|
|
43
|
+
if (existed && force !== true && !isStaleV6HostDoc(existing)) {
|
|
44
|
+
return 'preserved';
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const content = await fs.readFile(sourcePath, 'utf-8');
|
|
48
|
+
await fs.writeFile(targetPath, content, 'utf-8');
|
|
49
|
+
return existed ? 'replaced' : 'created';
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return existed ? 'preserved' : 'created';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function readHostBody() {
|
|
56
|
+
try {
|
|
57
|
+
return await fs.readFile(path.join(TEMPLATES_ROOT, 'host', 'planu-sdd.md'), 'utf-8');
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return FALLBACK_HOST_BODY;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export async function installHostRulePack(workspaceRoot) {
|
|
64
|
+
try {
|
|
65
|
+
const body = await readHostBody();
|
|
66
|
+
const cursorRule = `---
|
|
67
|
+
description: Planu v8 FEAT-only. Specs live in .sdd/features. Never write planu/specs or SPEC-* stubs.
|
|
68
|
+
alwaysApply: true
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
${body}`;
|
|
72
|
+
const targets = [
|
|
73
|
+
{ relative: path.join('.cursor', 'rules', 'planu-sdd.mdc'), contents: cursorRule },
|
|
74
|
+
{ relative: path.join('.claude', 'rules', 'planu-sdd.md'), contents: body },
|
|
75
|
+
{ relative: path.join('.gemini', 'planu-sdd.md'), contents: body },
|
|
76
|
+
];
|
|
77
|
+
const written = [];
|
|
78
|
+
for (const target of targets) {
|
|
79
|
+
const fullPath = path.join(workspaceRoot, target.relative);
|
|
80
|
+
await fs.mkdir(path.dirname(fullPath), { recursive: true });
|
|
81
|
+
await fs.writeFile(fullPath, target.contents, 'utf-8');
|
|
82
|
+
written.push(target.relative);
|
|
83
|
+
}
|
|
84
|
+
return written;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=host-rule-pack.js.map
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
import type { LockIntegrityResult } from '../types/sdd-engine.js';
|
|
1
|
+
import type { ErrorCode, LockIntegrityResult, ParsedManifest } from '../types/sdd-engine.js';
|
|
2
|
+
export declare function hashArtifact(content: string): string;
|
|
2
3
|
export declare function verifyLockedTrinity(featDir: string): Promise<LockIntegrityResult>;
|
|
4
|
+
export declare function parseManifestContent(content: string): ParsedManifest;
|
|
5
|
+
export declare function toPosixPath(value: string): string;
|
|
6
|
+
export declare function writeLockedTrinity(featDir: string, featureId: string, relock: boolean, reason: string | undefined): Promise<{
|
|
7
|
+
ok: true;
|
|
8
|
+
specHash: string;
|
|
9
|
+
planHash: string;
|
|
10
|
+
tasksHash: string;
|
|
11
|
+
relocked: boolean;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
code: ErrorCode;
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
3
17
|
//# sourceMappingURL=lock-integrity.d.ts.map
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
+
const CHECKBOX_TASK = /^[-*]\s*\[[ xX]\]/u;
|
|
5
|
+
export function hashArtifact(content) {
|
|
6
|
+
return createHash('sha256').update(content).digest('hex');
|
|
7
|
+
}
|
|
8
|
+
function assessTrinityCompleteness(specContent, planContent, tasksContent) {
|
|
9
|
+
const specOk = hasHeading(specContent, 'Out-of-Scope') &&
|
|
10
|
+
hasHeading(specContent, 'Error Matrix') &&
|
|
11
|
+
(hasHeading(specContent, 'Acceptance Criteria') || /\bGIVEN\b/u.test(specContent));
|
|
12
|
+
const planOk = hasHeading(planContent, 'Frozen Dependencies') && hasHeading(planContent, 'File Manifest');
|
|
13
|
+
const hasTask = tasksContent.split('\n').some((line) => CHECKBOX_TASK.test(line.trim()));
|
|
14
|
+
const manifest = scanManifest(planContent);
|
|
15
|
+
if (manifest.globDelete) {
|
|
16
|
+
return {
|
|
17
|
+
ok: false,
|
|
18
|
+
code: 'ERR_TRINITY_INCOMPLETE',
|
|
19
|
+
message: 'DELETE File Manifest entries must be exact paths, not globs.',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (specOk && planOk && hasTask && manifest.hasPath) {
|
|
23
|
+
return { ok: true };
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
code: 'ERR_TRINITY_INCOMPLETE',
|
|
28
|
+
message: 'Lock requires Out-of-Scope, Error Matrix, Acceptance Criteria or GIVEN, Frozen Dependencies, a File Manifest path, and at least one checkbox task.',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
4
31
|
export async function verifyLockedTrinity(featDir) {
|
|
5
32
|
const lockPath = path.join(featDir, '.lock');
|
|
6
33
|
let raw;
|
|
@@ -38,15 +65,162 @@ export async function verifyLockedTrinity(featDir) {
|
|
|
38
65
|
message: `Failed to read locked artifacts at '${featDir}'.`,
|
|
39
66
|
};
|
|
40
67
|
}
|
|
41
|
-
|
|
42
|
-
const planHash = createHash('sha256').update(planContent).digest('hex');
|
|
43
|
-
if (specHash !== lock.specHash || planHash !== lock.planHash) {
|
|
68
|
+
if (hashArtifact(specContent) !== lock.specHash || hashArtifact(planContent) !== lock.planHash) {
|
|
44
69
|
return {
|
|
45
70
|
ok: false,
|
|
46
71
|
code: 'ERR_SPEC_DRIFT',
|
|
47
72
|
message: 'Locked spec.md or plan.md changed after sdd_lock_spec. Re-lock is required.',
|
|
48
73
|
};
|
|
49
74
|
}
|
|
75
|
+
if (lock.tasksHash) {
|
|
76
|
+
let tasksContent;
|
|
77
|
+
try {
|
|
78
|
+
tasksContent = await fs.readFile(path.join(featDir, 'tasks.md'), 'utf-8');
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
code: 'ERR_SPEC_DRIFT',
|
|
84
|
+
message: 'Locked tasks.md is missing after sdd_lock_spec. Re-lock is required.',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (hashArtifact(tasksContent) !== lock.tasksHash) {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
code: 'ERR_SPEC_DRIFT',
|
|
91
|
+
message: 'Locked tasks.md changed after sdd_lock_spec. Re-lock is required.',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
50
95
|
return { ok: true };
|
|
51
96
|
}
|
|
97
|
+
function hasHeading(content, needle) {
|
|
98
|
+
const escaped = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
99
|
+
return new RegExp(`^#{1,3}\\s+.*${escaped}`, 'imu').test(content);
|
|
100
|
+
}
|
|
101
|
+
function scanManifest(planContent) {
|
|
102
|
+
const { allowedFiles } = parseManifestContent(planContent);
|
|
103
|
+
let globDelete = false;
|
|
104
|
+
for (const [entryPath, permission] of allowedFiles) {
|
|
105
|
+
if (permission === 'DELETE' && entryPath.includes('*')) {
|
|
106
|
+
globDelete = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { hasPath: allowedFiles.size > 0, globDelete };
|
|
110
|
+
}
|
|
111
|
+
export function parseManifestContent(content) {
|
|
112
|
+
const allowedFiles = new Map();
|
|
113
|
+
let inManifestSection = false;
|
|
114
|
+
for (const rawLine of content.split('\n')) {
|
|
115
|
+
const line = rawLine.trim();
|
|
116
|
+
if (/^#{1,3}\s+.*file\s+manifest/i.test(line)) {
|
|
117
|
+
inManifestSection = true;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (inManifestSection && /^#{1,3}\s+/.test(line)) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (inManifestSection && /^[-*]\s+/.test(line)) {
|
|
124
|
+
parseManifestLine(line, allowedFiles);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { allowedFiles };
|
|
128
|
+
}
|
|
129
|
+
function parseManifestLine(rawLine, allowedFiles) {
|
|
130
|
+
const item = rawLine.replace(/^[-*]\s+/, '').trim();
|
|
131
|
+
const prefixMatch = /^(CREATE|MODIFY|READ_ONLY|DELETE):\s*`?([^`\s#]+)`?\s*$/i.exec(item);
|
|
132
|
+
if (prefixMatch?.[1] && prefixMatch[2]) {
|
|
133
|
+
allowedFiles.set(toPosixPath(prefixMatch[2].trim()), prefixMatch[1].toUpperCase());
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const postfixMatch = /^`?([^`\s:#]+)`?:\s*(CREATE|MODIFY|READ_ONLY|DELETE)\s*$/i.exec(item);
|
|
137
|
+
if (postfixMatch?.[1] && postfixMatch[2]) {
|
|
138
|
+
allowedFiles.set(toPosixPath(postfixMatch[1].trim()), postfixMatch[2].toUpperCase());
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function toPosixPath(value) {
|
|
142
|
+
const posix = value.replaceAll('\\', '/');
|
|
143
|
+
const absolute = posix.startsWith('/');
|
|
144
|
+
const joined = posix
|
|
145
|
+
.split('/')
|
|
146
|
+
.filter((part) => part !== '' && part !== '.')
|
|
147
|
+
.join('/');
|
|
148
|
+
return absolute ? `/${joined}` : joined;
|
|
149
|
+
}
|
|
150
|
+
export async function writeLockedTrinity(featDir, featureId, relock, reason) {
|
|
151
|
+
const lockPath = path.join(featDir, '.lock');
|
|
152
|
+
const lockExists = await fs
|
|
153
|
+
.access(lockPath)
|
|
154
|
+
.then(() => true)
|
|
155
|
+
.catch(() => false);
|
|
156
|
+
if (lockExists && !relock) {
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
code: 'ERR_SPEC_ALREADY_LOCKED',
|
|
160
|
+
message: `Feature '${featureId}' is already locked for execution.`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const trimmedReason = reason?.trim() ?? '';
|
|
164
|
+
if (relock && trimmedReason.length < 8) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
code: 'ERR_LOCK_REASON_REQUIRED',
|
|
168
|
+
message: 'relock requires reason with at least 8 non-whitespace characters.',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return sealTrinityArtifacts(featDir, featureId, lockPath, lockExists, relock, trimmedReason);
|
|
172
|
+
}
|
|
173
|
+
async function sealTrinityArtifacts(featDir, featureId, lockPath, lockExists, relock, trimmedReason) {
|
|
174
|
+
let specContent;
|
|
175
|
+
let planContent;
|
|
176
|
+
let tasksContent;
|
|
177
|
+
try {
|
|
178
|
+
specContent = await fs.readFile(path.join(featDir, 'spec.md'), 'utf-8');
|
|
179
|
+
planContent = await fs.readFile(path.join(featDir, 'plan.md'), 'utf-8');
|
|
180
|
+
tasksContent = await fs.readFile(path.join(featDir, 'tasks.md'), 'utf-8');
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return {
|
|
184
|
+
ok: false,
|
|
185
|
+
code: 'ERR_FEATURE_NOT_FOUND',
|
|
186
|
+
message: `Failed to read base artifacts for '${featureId}'.`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const completeness = assessTrinityCompleteness(specContent, planContent, tasksContent);
|
|
190
|
+
if (!completeness.ok) {
|
|
191
|
+
return { ok: false, code: completeness.code, message: completeness.message };
|
|
192
|
+
}
|
|
193
|
+
let previous;
|
|
194
|
+
if (lockExists) {
|
|
195
|
+
try {
|
|
196
|
+
previous = JSON.parse(await fs.readFile(lockPath, 'utf-8'));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
previous = undefined;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const specHash = hashArtifact(specContent);
|
|
203
|
+
const planHash = hashArtifact(planContent);
|
|
204
|
+
const tasksHash = hashArtifact(tasksContent);
|
|
205
|
+
const lockedAt = new Date().toISOString();
|
|
206
|
+
const history = [...(previous?.relockHistory ?? [])];
|
|
207
|
+
if (relock && previous?.specHash && previous.planHash) {
|
|
208
|
+
history.push({
|
|
209
|
+
lockedAt: previous.lockedAt ?? lockedAt,
|
|
210
|
+
specHash: previous.specHash,
|
|
211
|
+
planHash: previous.planHash,
|
|
212
|
+
tasksHash: previous.tasksHash,
|
|
213
|
+
reason: trimmedReason,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const lockFile = {
|
|
217
|
+
lockedAt,
|
|
218
|
+
specHash,
|
|
219
|
+
planHash,
|
|
220
|
+
tasksHash,
|
|
221
|
+
...(history.length > 0 ? { relockHistory: history } : {}),
|
|
222
|
+
};
|
|
223
|
+
await fs.writeFile(lockPath, JSON.stringify(lockFile, null, 2), 'utf-8');
|
|
224
|
+
return { ok: true, specHash, planHash, tasksHash, relocked: relock };
|
|
225
|
+
}
|
|
52
226
|
//# sourceMappingURL=lock-integrity.js.map
|
|
@@ -3,12 +3,12 @@ export declare class PatchSandbox {
|
|
|
3
3
|
private readonly workspaceRoot;
|
|
4
4
|
constructor(workspaceRoot: string);
|
|
5
5
|
parsePlanManifest(planPath: string): Promise<ParsedManifest>;
|
|
6
|
-
private parseManifestLine;
|
|
7
6
|
applyPatch(manifest: ParsedManifest, targetRelativePath: string, searchContent: string, replaceContent: string): Promise<SddResult<PatchResultData>>;
|
|
8
7
|
private validateTargetContainment;
|
|
8
|
+
private rejectsProtectedRoot;
|
|
9
|
+
private rejectsResolvedProtectedRoot;
|
|
9
10
|
private isRawProtectedDelete;
|
|
10
11
|
private validateCreateTargetAbsent;
|
|
11
|
-
private isGitMetadataTarget;
|
|
12
12
|
private nearestExistingParent;
|
|
13
13
|
private isWithin;
|
|
14
14
|
private permissionViolation;
|
|
@@ -1,53 +1,22 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
+
import { parseManifestContent, toPosixPath } from './lock-integrity.js';
|
|
3
4
|
export class PatchSandbox {
|
|
4
5
|
workspaceRoot;
|
|
5
6
|
constructor(workspaceRoot) {
|
|
6
7
|
this.workspaceRoot = workspaceRoot;
|
|
7
8
|
}
|
|
8
9
|
async parsePlanManifest(planPath) {
|
|
9
|
-
const allowedFiles = new Map();
|
|
10
|
-
let content;
|
|
11
10
|
try {
|
|
12
|
-
|
|
11
|
+
return parseManifestContent(await fs.readFile(planPath, 'utf-8'));
|
|
13
12
|
}
|
|
14
13
|
catch {
|
|
15
|
-
return { allowedFiles };
|
|
16
|
-
}
|
|
17
|
-
const lines = content.split('\n');
|
|
18
|
-
let inManifestSection = false;
|
|
19
|
-
for (const rawLine of lines) {
|
|
20
|
-
const line = rawLine.trim();
|
|
21
|
-
if (/^#{1,3}\s+.*file\s+manifest/i.test(line)) {
|
|
22
|
-
inManifestSection = true;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (inManifestSection && /^#{1,3}\s+/.test(line)) {
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
if (inManifestSection && /^[-*]\s+/.test(line)) {
|
|
29
|
-
this.parseManifestLine(line, allowedFiles);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return { allowedFiles };
|
|
33
|
-
}
|
|
34
|
-
parseManifestLine(rawLine, allowedFiles) {
|
|
35
|
-
const item = rawLine.replace(/^[-*]\s+/, '').trim();
|
|
36
|
-
const prefixMatch = /^(CREATE|MODIFY|READ_ONLY|DELETE):\s*`?([^`\s#]+)`?\s*$/i.exec(item);
|
|
37
|
-
if (prefixMatch?.[1] && prefixMatch[2]) {
|
|
38
|
-
const perm = prefixMatch[1].toUpperCase();
|
|
39
|
-
allowedFiles.set(path.normalize(prefixMatch[2].trim()), perm);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const postfixMatch = /^`?([^`\s:#]+)`?:\s*(CREATE|MODIFY|READ_ONLY|DELETE)\s*$/i.exec(item);
|
|
43
|
-
if (postfixMatch?.[1] && postfixMatch[2]) {
|
|
44
|
-
const perm = postfixMatch[2].toUpperCase();
|
|
45
|
-
allowedFiles.set(path.normalize(postfixMatch[1].trim()), perm);
|
|
14
|
+
return { allowedFiles: new Map() };
|
|
46
15
|
}
|
|
47
16
|
}
|
|
48
17
|
async applyPatch(manifest, targetRelativePath, searchContent, replaceContent) {
|
|
49
|
-
const normalizedTarget =
|
|
50
|
-
const permission = manifest.allowedFiles
|
|
18
|
+
const normalizedTarget = toPosixPath(targetRelativePath);
|
|
19
|
+
const permission = resolveManifestPermission(manifest.allowedFiles, normalizedTarget);
|
|
51
20
|
if (!permission) {
|
|
52
21
|
return {
|
|
53
22
|
success: false,
|
|
@@ -88,8 +57,7 @@ export class PatchSandbox {
|
|
|
88
57
|
if (!this.isWithin(workspacePath, fullPath)) {
|
|
89
58
|
return this.permissionViolation(normalizedTarget);
|
|
90
59
|
}
|
|
91
|
-
if (
|
|
92
|
-
this.isRawProtectedDelete(workspacePath, fullPath, normalizedTarget)) {
|
|
60
|
+
if (this.rejectsProtectedRoot(workspacePath, fullPath, normalizedTarget, permission)) {
|
|
93
61
|
return this.permissionViolation(normalizedTarget);
|
|
94
62
|
}
|
|
95
63
|
const createError = permission === 'CREATE'
|
|
@@ -106,8 +74,7 @@ export class PatchSandbox {
|
|
|
106
74
|
if (!this.isWithin(workspaceRealPath, containmentTarget)) {
|
|
107
75
|
return this.permissionViolation(normalizedTarget);
|
|
108
76
|
}
|
|
109
|
-
if (
|
|
110
|
-
(await this.isGitMetadataTarget(workspaceRealPath, containmentTarget))) {
|
|
77
|
+
if (await this.rejectsResolvedProtectedRoot(workspaceRealPath, containmentTarget)) {
|
|
111
78
|
return this.permissionViolation(normalizedTarget);
|
|
112
79
|
}
|
|
113
80
|
}
|
|
@@ -118,10 +85,31 @@ export class PatchSandbox {
|
|
|
118
85
|
}
|
|
119
86
|
return null;
|
|
120
87
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
88
|
+
rejectsProtectedRoot(workspacePath, fullPath, normalizedTarget, permission) {
|
|
89
|
+
const sddRoot = path.resolve(workspacePath, '.sdd');
|
|
90
|
+
const gitRoot = path.resolve(workspacePath, '.git');
|
|
91
|
+
const legacySpecsRoot = path.resolve(workspacePath, 'planu', 'specs');
|
|
92
|
+
if (isSddEnginePath(normalizedTarget) ||
|
|
93
|
+
isGitPath(normalizedTarget) ||
|
|
94
|
+
isLegacySpecsPath(normalizedTarget) ||
|
|
95
|
+
this.isWithin(sddRoot, fullPath) ||
|
|
96
|
+
this.isWithin(gitRoot, fullPath) ||
|
|
97
|
+
this.isWithin(legacySpecsRoot, fullPath)) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
return permission === 'DELETE' && this.isRawProtectedDelete(workspacePath, fullPath);
|
|
101
|
+
}
|
|
102
|
+
async rejectsResolvedProtectedRoot(workspaceRealPath, containmentTarget) {
|
|
103
|
+
for (const dirName of ['.sdd', '.git', path.join('planu', 'specs')]) {
|
|
104
|
+
const realRoot = await fs.realpath(path.join(workspaceRealPath, dirName)).catch(() => null);
|
|
105
|
+
if (realRoot && this.isWithin(realRoot, containmentTarget)) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
isRawProtectedDelete(workspacePath, fullPath) {
|
|
112
|
+
return fullPath === workspacePath;
|
|
125
113
|
}
|
|
126
114
|
async validateCreateTargetAbsent(fullPath, normalizedTarget) {
|
|
127
115
|
try {
|
|
@@ -134,18 +122,6 @@ export class PatchSandbox {
|
|
|
134
122
|
: this.permissionViolation(normalizedTarget);
|
|
135
123
|
}
|
|
136
124
|
}
|
|
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
125
|
async nearestExistingParent(candidate, workspacePath) {
|
|
150
126
|
let current = candidate;
|
|
151
127
|
while (this.isWithin(workspacePath, current)) {
|
|
@@ -296,4 +272,72 @@ export class PatchSandbox {
|
|
|
296
272
|
}
|
|
297
273
|
}
|
|
298
274
|
}
|
|
275
|
+
function resolveManifestPermission(allowedFiles, normalizedTarget) {
|
|
276
|
+
const exact = allowedFiles.get(normalizedTarget);
|
|
277
|
+
if (exact) {
|
|
278
|
+
return exact;
|
|
279
|
+
}
|
|
280
|
+
let writeMatch;
|
|
281
|
+
for (const [pattern, permission] of allowedFiles) {
|
|
282
|
+
if (permission === 'DELETE' ||
|
|
283
|
+
!pattern.includes('*') ||
|
|
284
|
+
!globMatches(pattern, normalizedTarget)) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (permission === 'READ_ONLY') {
|
|
288
|
+
return 'READ_ONLY';
|
|
289
|
+
}
|
|
290
|
+
writeMatch ??= permission;
|
|
291
|
+
}
|
|
292
|
+
return writeMatch;
|
|
293
|
+
}
|
|
294
|
+
function globMatches(pattern, target) {
|
|
295
|
+
const posixPattern = toPosixPath(pattern);
|
|
296
|
+
const posixTarget = toPosixPath(target);
|
|
297
|
+
if (posixPattern.split('/').includes('..') ||
|
|
298
|
+
posixTarget.split('/').includes('..') ||
|
|
299
|
+
path.isAbsolute(posixPattern) ||
|
|
300
|
+
path.isAbsolute(posixTarget)) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return new RegExp(`^${globPatternToRegExpSource(posixPattern)}$`).test(posixTarget);
|
|
304
|
+
}
|
|
305
|
+
function isSddEnginePath(relativePath) {
|
|
306
|
+
const posix = toPosixPath(relativePath);
|
|
307
|
+
return posix === '.sdd' || posix.startsWith('.sdd/');
|
|
308
|
+
}
|
|
309
|
+
function isGitPath(relativePath) {
|
|
310
|
+
const posix = toPosixPath(relativePath);
|
|
311
|
+
return posix === '.git' || posix.startsWith('.git/');
|
|
312
|
+
}
|
|
313
|
+
function isLegacySpecsPath(relativePath) {
|
|
314
|
+
const posix = toPosixPath(relativePath);
|
|
315
|
+
return posix === 'planu/specs' || posix.startsWith('planu/specs/');
|
|
316
|
+
}
|
|
317
|
+
function globPatternToRegExpSource(pattern) {
|
|
318
|
+
let source = '';
|
|
319
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
320
|
+
const char = pattern[i] ?? '';
|
|
321
|
+
if (char === '*' && pattern[i + 1] === '*') {
|
|
322
|
+
i += 1;
|
|
323
|
+
if (pattern[i + 1] === '/') {
|
|
324
|
+
i += 1;
|
|
325
|
+
source += '(?:(?![.])[^/]+/)*';
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
source += '(?:(?![.])[^/]+/)*(?:(?![.])[^/]+)?';
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else if (char === '*') {
|
|
332
|
+
source += '(?![.])[^/]+';
|
|
333
|
+
}
|
|
334
|
+
else if ('\\^$+?.()|[]{}'.includes(char)) {
|
|
335
|
+
source += `\\${char}`;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
source += char;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return source;
|
|
342
|
+
}
|
|
299
343
|
//# sourceMappingURL=patch-sandbox.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { hashArtifact } from './lock-integrity.js';
|
|
2
4
|
export class TaskWindowManager {
|
|
3
5
|
async getActiveTask(tasksFilePath) {
|
|
4
6
|
let content;
|
|
@@ -66,22 +68,19 @@ export class TaskWindowManager {
|
|
|
66
68
|
if (statusChar === 'x') {
|
|
67
69
|
acc.completedTasks++;
|
|
68
70
|
if (acc.isCapturingActive) {
|
|
69
|
-
|
|
71
|
+
acc.isCapturingActive = false;
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
else {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (acc.isCapturingActive) {
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
74
|
+
else if (!acc.isCapturingActive && acc.activeTaskIndex === -1) {
|
|
75
|
+
acc.isCapturingActive = true;
|
|
76
|
+
acc.activeTaskIndex = acc.totalTasks;
|
|
77
|
+
const parsed = this.extractTaskId(match[2].trim(), acc.activeTaskIndex);
|
|
78
|
+
acc.activeTaskId = parsed.id;
|
|
79
|
+
acc.activeTaskTitle = parsed.title;
|
|
80
|
+
acc.activeTaskLines.push(line);
|
|
81
|
+
}
|
|
82
|
+
else if (acc.isCapturingActive) {
|
|
83
|
+
acc.isCapturingActive = false;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
else if (acc.isCapturingActive) {
|
|
@@ -152,6 +151,7 @@ export class TaskWindowManager {
|
|
|
152
151
|
};
|
|
153
152
|
}
|
|
154
153
|
await fs.writeFile(tasksFilePath, lines.join('\n'), 'utf-8');
|
|
154
|
+
await refreshTasksHashIfLocked(tasksFilePath, lines.join('\n'));
|
|
155
155
|
const checkRes = await this.getActiveTask(tasksFilePath);
|
|
156
156
|
const remainingTasks = checkRes.success && checkRes.data.activeTask
|
|
157
157
|
? checkRes.data.activeTask.totalTasks - checkRes.data.activeTask.completedTasks
|
|
@@ -166,4 +166,25 @@ export class TaskWindowManager {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
+
async function refreshTasksHashIfLocked(tasksFilePath, tasksContent) {
|
|
170
|
+
const lockPath = path.join(path.dirname(tasksFilePath), '.lock');
|
|
171
|
+
let raw;
|
|
172
|
+
try {
|
|
173
|
+
raw = await fs.readFile(lockPath, 'utf-8');
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const lock = JSON.parse(raw);
|
|
180
|
+
if (!lock.tasksHash) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
lock.tasksHash = hashArtifact(tasksContent);
|
|
184
|
+
await fs.writeFile(lockPath, JSON.stringify(lock, null, 2), 'utf-8');
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
169
190
|
//# sourceMappingURL=task-window.js.map
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
3
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
6
4
|
import { InitWorkspaceInputSchema, ListFeaturesInputSchema, CreateFeatureInputSchema, LockSpecInputSchema, } from '../contracts.js';
|
|
7
5
|
import { TaskWindowManager } from '../task-window.js';
|
|
8
6
|
import { formatResult } from './format-result.js';
|
|
9
7
|
import { homeFallbackFailure } from '../workspace-root.js';
|
|
8
|
+
import { writeLockedTrinity } from '../lock-integrity.js';
|
|
9
|
+
import { copyGlobalRules, installHostRulePack } from '../host-rule-pack.js';
|
|
10
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
10
11
|
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.';
|
|
12
|
+
const LEGACY_SPECS_HINT = 'Planu ignores planu/specs. Do not create SPEC-* stubs or copy a FEAT into that tree. Retire host hooks that require planu/specs/SPEC-*/spec.md; the only contract is .sdd/features/FEAT-*.';
|
|
13
|
+
async function composeWorkspaceHint(workspaceRoot, extra) {
|
|
14
|
+
const legacySpecsPresent = await fs
|
|
15
|
+
.access(path.join(workspaceRoot, 'planu', 'specs'))
|
|
16
|
+
.then(() => true)
|
|
17
|
+
.catch(() => false);
|
|
18
|
+
if (!legacySpecsPresent) {
|
|
19
|
+
return extra;
|
|
20
|
+
}
|
|
21
|
+
return extra ? `${extra} ${LEGACY_SPECS_HINT}` : LEGACY_SPECS_HINT;
|
|
22
|
+
}
|
|
11
23
|
export function registerWorkspaceTools(server, workspace) {
|
|
12
24
|
const taskWindow = new TaskWindowManager();
|
|
13
25
|
registerInitTool(server, workspace);
|
|
@@ -36,7 +48,9 @@ function registerInitTool(server, workspace) {
|
|
|
36
48
|
await fs.mkdir(featuresDir, { recursive: true });
|
|
37
49
|
await fs.mkdir(skillsDir, { recursive: true });
|
|
38
50
|
await copySkillTemplates(skillsDir);
|
|
39
|
-
await copyGlobalRules(resolved.workspaceRoot);
|
|
51
|
+
const agentsMd = await copyGlobalRules(resolved.workspaceRoot, args.force);
|
|
52
|
+
const hostRules = args.scope === 'project' ? await installHostRulePack(resolved.workspaceRoot) : [];
|
|
53
|
+
const hint = await composeWorkspaceHint(resolved.workspaceRoot, 'Commit .sdd/ with the project. Host quality gates must map .sdd/ as versioned documentation. Cursor, Claude, Gemini, and Codex load Planu-owned host rules from sdd_init_workspace.');
|
|
40
54
|
return formatResult({
|
|
41
55
|
success: true,
|
|
42
56
|
data: {
|
|
@@ -46,6 +60,9 @@ function registerInitTool(server, workspace) {
|
|
|
46
60
|
skillsDir,
|
|
47
61
|
workspaceRoot: resolved.workspaceRoot,
|
|
48
62
|
source: resolved.source,
|
|
63
|
+
agentsMd,
|
|
64
|
+
hostRules,
|
|
65
|
+
versionedHint: hint,
|
|
49
66
|
},
|
|
50
67
|
});
|
|
51
68
|
});
|
|
@@ -63,6 +80,7 @@ function registerListTool(server, workspace, taskWindow) {
|
|
|
63
80
|
}
|
|
64
81
|
const featuresDir = path.join(resolved.sddDir, 'features');
|
|
65
82
|
const featuresList = await collectFeatures(featuresDir, taskWindow, args.status_filter);
|
|
83
|
+
const hint = await composeWorkspaceHint(resolved.workspaceRoot, resolved.sddPresent ? undefined : MISSING_SDD_HINT);
|
|
66
84
|
return formatResult({
|
|
67
85
|
success: true,
|
|
68
86
|
data: {
|
|
@@ -71,7 +89,7 @@ function registerListTool(server, workspace, taskWindow) {
|
|
|
71
89
|
workspaceRoot: resolved.workspaceRoot,
|
|
72
90
|
sddPresent: resolved.sddPresent,
|
|
73
91
|
source: resolved.source,
|
|
74
|
-
hint
|
|
92
|
+
hint,
|
|
75
93
|
},
|
|
76
94
|
});
|
|
77
95
|
});
|
|
@@ -191,7 +209,7 @@ function createFeatureSlug(title) {
|
|
|
191
209
|
}
|
|
192
210
|
function registerLockTool(server, workspace) {
|
|
193
211
|
server.registerTool('sdd_lock_spec', {
|
|
194
|
-
description: 'Locks spec.md and
|
|
212
|
+
description: 'Locks spec.md, plan.md, and tasks.md. Pass relock=true and reason to reseal after review.',
|
|
195
213
|
inputSchema: LockSpecInputSchema.shape,
|
|
196
214
|
}, async (rawArgs) => {
|
|
197
215
|
const args = LockSpecInputSchema.parse(rawArgs);
|
|
@@ -201,7 +219,7 @@ function registerLockTool(server, workspace) {
|
|
|
201
219
|
return formatResult(homeError);
|
|
202
220
|
}
|
|
203
221
|
const featDir = path.join(resolved.sddDir, 'features', args.feature_id);
|
|
204
|
-
return executeLockSpec(featDir, args.feature_id);
|
|
222
|
+
return executeLockSpec(featDir, args.feature_id, args.relock === true, args.reason);
|
|
205
223
|
});
|
|
206
224
|
}
|
|
207
225
|
function isNodeErrorCode(err, code) {
|
|
@@ -223,17 +241,6 @@ async function copySkillTemplates(skillsDir) {
|
|
|
223
241
|
await fs.writeFile(path.join(skillsDir, 'spec-executor.md'), '# Spec Executor Skill\n\nOperate in Zero-Freedom mode.\n', 'utf-8');
|
|
224
242
|
}
|
|
225
243
|
}
|
|
226
|
-
async function copyGlobalRules(workspaceRoot) {
|
|
227
|
-
const sourcePath = path.resolve(moduleDir, '..', '..', '..', 'templates', 'AGENTS.md');
|
|
228
|
-
const targetPath = path.resolve(workspaceRoot, 'AGENTS.md');
|
|
229
|
-
try {
|
|
230
|
-
const content = await fs.readFile(sourcePath, 'utf-8');
|
|
231
|
-
await fs.writeFile(targetPath, content, 'utf-8');
|
|
232
|
-
}
|
|
233
|
-
catch {
|
|
234
|
-
// Ignore if not found
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
244
|
async function collectFeatures(featuresDir, taskWindow, statusFilter) {
|
|
238
245
|
const result = [];
|
|
239
246
|
try {
|
|
@@ -272,44 +279,24 @@ async function writeFeatureArtifacts(featDir, id, title) {
|
|
|
272
279
|
await fs.writeFile(path.join(featDir, 'plan.md'), initialPlan, 'utf-8');
|
|
273
280
|
await fs.writeFile(path.join(featDir, 'tasks.md'), initialTasks, 'utf-8');
|
|
274
281
|
}
|
|
275
|
-
async function executeLockSpec(featDir, featureId) {
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
.access(lockPath)
|
|
279
|
-
.then(() => true)
|
|
280
|
-
.catch(() => false);
|
|
281
|
-
if (lockExists) {
|
|
282
|
+
async function executeLockSpec(featDir, featureId, relock, reason) {
|
|
283
|
+
const outcome = await writeLockedTrinity(featDir, featureId, relock, reason);
|
|
284
|
+
if (!outcome.ok) {
|
|
282
285
|
return formatResult({
|
|
283
286
|
success: false,
|
|
284
|
-
error: {
|
|
285
|
-
code: 'ERR_SPEC_ALREADY_LOCKED',
|
|
286
|
-
message: `Feature '${featureId}' is already locked for execution.`,
|
|
287
|
-
trigger: 'sdd_lock_spec',
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
let specContent;
|
|
292
|
-
let planContent;
|
|
293
|
-
try {
|
|
294
|
-
specContent = await fs.readFile(path.join(featDir, 'spec.md'), 'utf-8');
|
|
295
|
-
planContent = await fs.readFile(path.join(featDir, 'plan.md'), 'utf-8');
|
|
296
|
-
}
|
|
297
|
-
catch {
|
|
298
|
-
return formatResult({
|
|
299
|
-
success: false,
|
|
300
|
-
error: {
|
|
301
|
-
code: 'ERR_FEATURE_NOT_FOUND',
|
|
302
|
-
message: `Failed to read base artifacts for '${featureId}'.`,
|
|
303
|
-
trigger: 'sdd_lock_spec',
|
|
304
|
-
},
|
|
287
|
+
error: { code: outcome.code, message: outcome.message, trigger: 'sdd_lock_spec' },
|
|
305
288
|
});
|
|
306
289
|
}
|
|
307
|
-
const specHash = createHash('sha256').update(specContent).digest('hex');
|
|
308
|
-
const planHash = createHash('sha256').update(planContent).digest('hex');
|
|
309
|
-
await fs.writeFile(lockPath, JSON.stringify({ lockedAt: new Date().toISOString(), specHash, planHash }, null, 2), 'utf-8');
|
|
310
290
|
return formatResult({
|
|
311
291
|
success: true,
|
|
312
|
-
data: {
|
|
292
|
+
data: {
|
|
293
|
+
featureId,
|
|
294
|
+
locked: true,
|
|
295
|
+
specHash: outcome.specHash,
|
|
296
|
+
planHash: outcome.planHash,
|
|
297
|
+
tasksHash: outcome.tasksHash,
|
|
298
|
+
relocked: outcome.relocked,
|
|
299
|
+
},
|
|
313
300
|
});
|
|
314
301
|
}
|
|
315
302
|
//# sourceMappingURL=workspace-tools.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type ArtifactType = 'spec' | 'plan' | 'tasks';
|
|
2
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';
|
|
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' | 'ERR_TRINITY_INCOMPLETE' | 'ERR_LOCK_REASON_REQUIRED';
|
|
4
4
|
export interface SddErrorDetails {
|
|
5
5
|
code: ErrorCode;
|
|
6
6
|
message: string;
|
|
@@ -29,6 +29,8 @@ export interface CreateFeatureInput {
|
|
|
29
29
|
}
|
|
30
30
|
export interface LockSpecInput {
|
|
31
31
|
feature_id: string;
|
|
32
|
+
relock?: boolean;
|
|
33
|
+
reason?: string;
|
|
32
34
|
}
|
|
33
35
|
export interface ReadSpecArtifactInput {
|
|
34
36
|
feature_id: string;
|
|
@@ -93,9 +95,19 @@ export interface FeatureSummary {
|
|
|
93
95
|
status: 'planning' | 'executing' | 'done';
|
|
94
96
|
locked: boolean;
|
|
95
97
|
}
|
|
98
|
+
export interface RelockRecord {
|
|
99
|
+
lockedAt: string;
|
|
100
|
+
specHash: string;
|
|
101
|
+
planHash: string;
|
|
102
|
+
tasksHash?: string;
|
|
103
|
+
reason: string;
|
|
104
|
+
}
|
|
96
105
|
export interface SddLockFile {
|
|
106
|
+
lockedAt?: string;
|
|
97
107
|
specHash?: string;
|
|
98
108
|
planHash?: string;
|
|
109
|
+
tasksHash?: string;
|
|
110
|
+
relockHistory?: RelockRecord[];
|
|
99
111
|
}
|
|
100
112
|
export interface LockIntegrityResult {
|
|
101
113
|
ok: boolean;
|
package/package.json
CHANGED
package/templates/AGENTS.md
CHANGED
|
@@ -5,8 +5,8 @@ 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 (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`.
|
|
8
|
+
- Before beginning any task, load and adopt the matching persona (Preflight Guardian, Spec Architect, Spec Executor, Verification Auditor, Visual Release 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`. For `website/**` or `planu.dev`, also adopt `visual-release-auditor.md`.
|
|
10
10
|
- Use `legacy-sunset.md` only for classified, snapshotted, and explicitly authorized permanent retirement.
|
|
11
11
|
- Core (`src/sdd-engine`) changes MUST follow `lib-sync.md`: update the published package, templates, server-card, and tests in the same change.
|
|
12
12
|
|
|
@@ -18,6 +18,7 @@ Canonical contract: `PLANU_V8_MANIFESTO.txt`.
|
|
|
18
18
|
| `spec-architect.md` | Creating or completing an unlocked Holy Trinity before user-approved lock. |
|
|
19
19
|
| `spec-executor.md` | Implementing the active task of a locked feature through canonical SDD tools. |
|
|
20
20
|
| `verification-auditor.md` | Independently proving completed implementation against acceptance criteria. |
|
|
21
|
+
| `visual-release-auditor.md` | Website or planu.dev layout, CSS, or deploy — browser proof at desktop and mobile. |
|
|
21
22
|
| `legacy-sunset.md` | Detaching, archiving, and explicitly authorized permanent legacy retirement. |
|
|
22
23
|
| `reconciler.md` | Requirements changed while a feature is still unlocked, or a locked delta must be identified. |
|
|
23
24
|
| `lib-sync.md` | Core or public package behavior, metadata, templates, or tool surface changes. |
|
|
@@ -43,9 +44,18 @@ Canonical contract: `PLANU_V8_MANIFESTO.txt`.
|
|
|
43
44
|
- Nine MCP tools: `sdd_init_workspace`, `sdd_list_features`, `sdd_create_feature`, `sdd_lock_spec`, `sdd_read_spec_artifact`, `sdd_read_file_slice`, `sdd_get_active_task`, `sdd_apply_file_patch`, `sdd_complete_task`.
|
|
44
45
|
- Deleted v6 names must never be called. Authentication is not required.
|
|
45
46
|
|
|
47
|
+
7. **No v6 spec tree:**
|
|
48
|
+
- Planu reads only `.sdd/features/FEAT-*`. Never create or thin `planu/specs/SPEC-*` to satisfy commitlint, husky, or a "known limitation".
|
|
49
|
+
- If a host hook still requires the retired v6 tree, delete or rewrite the hook. Duplicating a FEAT into SPEC is forbidden.
|
|
50
|
+
- `sdd_init_workspace` always stamps `.cursor/rules/planu-sdd.mdc`, `.claude/rules/planu-sdd.md`, and `.gemini/planu-sdd.md`. Existing `AGENTS.md` is preserved unless `force` is true or the file still treats the retired v6 tree as the contract. Never write `planu/specs/SPEC-*` and never call `create_spec`.
|
|
51
|
+
|
|
46
52
|
Failure to adhere to these rules compromises the SDD environment and is strictly forbidden.
|
|
47
53
|
|
|
48
54
|
## Git Hygiene (Mandatory)
|
|
49
55
|
|
|
50
56
|
- **Zero-Garbage Policy:** Never leave dangling git branches or orphaned `git worktree` directories after a feature is completed or aborted.
|
|
51
57
|
- When finishing a feature, always invoke the `git-janitor.md` skill before switching context.
|
|
58
|
+
|
|
59
|
+
## Full-cycle release (Mandatory)
|
|
60
|
+
|
|
61
|
+
Validated work is not done until it is on `main` and released. After verification-auditor PASS, visual-release-auditor PASS when the website changed, and an independent advanced review PASS: commit on `main`, push `origin main`, deploy `planu.dev` when website files changed (`pnpm --dir website build` + `wrangler deploy`), prove the live CSS hash, and publish `@planu/cli` when the public package contract or version changed. Do not stop at a local PASS or wait for a second "dale" to ship. Force-push to `main` remains forbidden.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Planu v8 host contract
|
|
2
|
+
|
|
3
|
+
The only SDD contract is `.sdd/features/{FEAT-*}/spec.md`, `plan.md`, and `tasks.md`.
|
|
4
|
+
|
|
5
|
+
- Feature IDs are `FEAT-*`. `SPEC-001` is invalid.
|
|
6
|
+
- Use the nine `sdd_*` tools. Never call deleted v6 tools (`create_spec`, `challenge_spec`, `check_readiness`, `validate`, `planu_status`, …).
|
|
7
|
+
- Never create, thin, or copy files under `planu/specs/`. Planu does not read that tree.
|
|
8
|
+
- If a pre-push, commitlint, or husky guard still requires `planu/specs/SPEC-*/spec.md`, that guard is the defect. Delete or rewrite it. Do not stub a SPEC file.
|
|
9
|
+
- Quality lives in `.sdd/skills/`. There is no validate MCP tool.
|
|
@@ -28,3 +28,7 @@ Never `git push --force` to `main`/`master`. Never skip hooks unless the user ex
|
|
|
28
28
|
- Include `git status --short`, ignored/untracked large artifacts, and stale generated reports in the hygiene report.
|
|
29
29
|
- Remote branches are observations unless the user explicitly authorizes remote deletion.
|
|
30
30
|
- Finish by rerunning `git status --short --branch`, `git worktree list`, and the surviving local-branch inventory.
|
|
31
|
+
|
|
32
|
+
## Full-cycle release
|
|
33
|
+
|
|
34
|
+
A feature is not finished at local PASS. After independent advanced review PASS: commit on `main`, push `origin HEAD` to `origin/main`, then release what changed (`pnpm --dir website build && wrangler deploy` for website; npm publish only when `package.json` version and lib-sync surfaces moved). Do not wait for another ship confirmation. Never `git push --force` to `main`.
|
|
@@ -17,6 +17,7 @@ Any change to the MCP core (`src/sdd-engine/**`, `src/types/sdd-engine.ts`, `src
|
|
|
17
17
|
|
|
18
18
|
2. **Cognitive starter pack (copied by `sdd_init_workspace`)**
|
|
19
19
|
- `templates/AGENTS.md`
|
|
20
|
+
- `templates/host/planu-sdd.md`
|
|
20
21
|
- `templates/skills/*.md`
|
|
21
22
|
- After editing templates, copy the same bytes into `.sdd/skills/` in this repo
|
|
22
23
|
|
|
@@ -46,6 +46,10 @@ Preflight never edits product files and never marks tasks complete.
|
|
|
46
46
|
- Confirm the command is scoped to the task and that required tools are available.
|
|
47
47
|
- Record checks that cannot run in the current environment. Do not convert blocked evidence into a pass.
|
|
48
48
|
|
|
49
|
+
6. **Retired v6 host tree**
|
|
50
|
+
- If `planu/specs/` exists, treat it as dead. Do not list, stub, thin, or copy FEAT contracts into `SPEC-*`.
|
|
51
|
+
- Host hooks that require `planu/specs/SPEC-*/spec.md` must be removed or rewritten to ignore that path. Duplicating specs is forbidden.
|
|
52
|
+
|
|
49
53
|
## Outcome
|
|
50
54
|
|
|
51
55
|
Return exactly one readiness result:
|
|
@@ -19,8 +19,8 @@ Your objective is to safely adapt `plan.md` and `tasks.md` when business require
|
|
|
19
19
|
- Do NOT rewrite the history of completed tasks; only adjust pending tasks or add new ones.
|
|
20
20
|
|
|
21
21
|
3. **Locked features:**
|
|
22
|
-
-
|
|
23
|
-
-
|
|
22
|
+
- Do not silently edit a locked `spec.md` / `plan.md` / `tasks.md`.
|
|
23
|
+
- After an approved review correction, reseal with `sdd_lock_spec` (`relock: true`, `reason`) so hashes and history stay traced.
|
|
24
24
|
|
|
25
25
|
4. **Language:**
|
|
26
26
|
- ALL updates to artifacts MUST be written entirely in Technical English.
|
|
@@ -30,7 +30,9 @@ 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
|
+
- `DELETE: path/to/file-or-directory` (exact path only; no globs)
|
|
34
|
+
- CREATE, MODIFY, and READ_ONLY may use `*` (one path segment) or `**` (many segments).
|
|
35
|
+
- `sdd_lock_spec` rejects incomplete trinities. Reseal after review with `relock: true` and `reason`.
|
|
34
36
|
- *Crucial Rule:* The MCP server rejects any file edit not declared in this manifest (`ERR_FILE_OUT_OF_MANIFEST`).
|
|
35
37
|
|
|
36
38
|
5. **Atomic Linear Tasks in `tasks.md`:**
|
|
@@ -48,6 +50,8 @@ Your objective is to produce airtight, deterministic, and unambiguous specificat
|
|
|
48
50
|
3. Review against the 5 laws above. An empty skeleton MUST NOT be locked.
|
|
49
51
|
4. Freeze the design by invoking `sdd_lock_spec(feature_id)` only after user approval.
|
|
50
52
|
|
|
53
|
+
Never author `planu/specs/**` or `SPEC-*` ids. If a host guard still requires that tree, the guard is the defect — do not emit a trace spec to appease it.
|
|
54
|
+
|
|
51
55
|
## LOCK READINESS GATE
|
|
52
56
|
|
|
53
57
|
Before authoring, adopt `preflight-guardian.md`. Before calling `sdd_lock_spec`, also require:
|
|
@@ -23,6 +23,7 @@ You do not make architectural decisions, you do not add dependencies, and you do
|
|
|
23
23
|
3. **Diff Sandboxing (Strict Perimeter Enforcement):**
|
|
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
|
+
- Never write `planu/specs/**` with MCP or native tools. `sdd_apply_file_patch` rejects that tree. Do not stub `SPEC-*` files to pass a host hook.
|
|
26
27
|
- 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
28
|
- Delete only through an exact `DELETE:` manifest entry with empty search and replacement payloads. Never substitute native filesystem deletion.
|
|
28
29
|
|
|
@@ -44,6 +44,7 @@ Count-only assertions, existence checks, snapshots without semantics, and tests
|
|
|
44
44
|
- Inspect final `git diff` and `git status --short`.
|
|
45
45
|
- Confirm no new dependency, generated artifact, secret, or out-of-manifest file was introduced.
|
|
46
46
|
- For public MCP changes, inspect the final consumer-visible tool schema and package surface, not only source declarations.
|
|
47
|
+
- For `website/**` or `planu.dev`, adopt `visual-release-auditor.md` and require executed browser evidence. Do not approve from tests or curl alone.
|
|
47
48
|
- For deletion or legacy retirement, prove absence from runtime reachability, package contents, templates, active documentation, and supported entrypoints.
|
|
48
49
|
|
|
49
50
|
## Verdict
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: visual-release-auditor
|
|
3
|
+
role: Live Surface Verifier
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# VISUAL RELEASE AUDITOR
|
|
7
|
+
|
|
8
|
+
Tests, curl, and a hero screenshot do not prove `planu.dev`. Adopt this skill whenever `website/**` changes, layout/CSS/HTML changes, or the site will be deployed.
|
|
9
|
+
|
|
10
|
+
## Required executed evidence
|
|
11
|
+
|
|
12
|
+
1. Open the real page in a browser (local Vite before deploy; `https://planu.dev/` after deploy).
|
|
13
|
+
2. Desktop ~1440px: header stays one row; hero shows copy and the contract card; `#commercial` places `.support-copy` beside `.lead-form`; footer `.donation-rail` spans the content width (~1180px).
|
|
14
|
+
3. Mobile ~390px: support, setup grid, and donation rail stack to one column; host tabs wrap; section titles are not hidden under the sticky header.
|
|
15
|
+
4. Confirm `link[rel=stylesheet]` matches the build hash. After wrangler, production HTML must reference the new CSS, not the previous asset.
|
|
16
|
+
5. Hit shared layout routes: `/`, `/privacy/`, `/changelog/`, and a 404.
|
|
17
|
+
|
|
18
|
+
Measure the grid. On desktop the form `x` is to the right of the copy. A collapsed donation column or an empty commercial column is FAIL.
|
|
19
|
+
|
|
20
|
+
## Verdict
|
|
21
|
+
|
|
22
|
+
- `APPROVED`: desktop, mobile, and production CSS hash all observed.
|
|
23
|
+
- `CHANGES_REQUESTED`: overlap, empty column, clipped heading, or stale CSS.
|
|
24
|
+
- `BLOCKED`: no browser; do not claim visual PASS.
|
|
25
|
+
|
|
26
|
+
Do not push or deploy website changes until APPROVED.
|