@planu/cli 8.2.3 → 8.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [8.2.5] - 2026-09-24
4
+
5
+ - `sdd_complete_task` keeps up to 500 characters of verification evidence, cut at a word boundary, and stores `$` sequences literally
6
+ - `sdd_apply_file_patch` writes `replace_content` literally; `$&`, `` $` ``, `$'` and `$$` are no longer expanded
7
+ - `sdd_lock_spec` rejects File Manifest write entries under `.sdd`, `.git` or `planu/specs`, which `sdd_apply_file_patch` would always refuse
8
+ - `planu-guard` denies quoted flags git parses as `-n`/`--no-verify` (`git commit "-nm fix"`) and no longer flags the value of `-m`/`-F`
9
+ - `pnpm eval:skills` reports writes to `READ_ONLY` manifest paths as `OUT_OF_MANIFEST`
10
+ - `scripts/publish-local.sh` publishes with the existing npm session when no token is set
11
+
12
+ ## [8.2.4] - 2026-09-24
13
+
14
+ - MCP handshake reports the package.json version instead of a hardcoded one
15
+ - `sdd_lock_spec` requires GIVEN/WHEN/THEN acceptance criteria before locking
16
+ - `sdd_init_workspace` surfaces host pack and global skill copy failures instead of writing stubs
17
+ - a CREATE manifest entry accepts search/replace patches after the file exists
18
+ - Claude Code plugin ships `planu-guard` hooks: native writes are denied while a locked feature has an unchecked task, `git --no-verify` is denied, and session start re-injects the active task
19
+ - README documents the Codex plugin install and the Cursor install deeplink
20
+ - `pnpm eval:skills` also measures the spec-executor skill
21
+ - verification-auditor skill checks for silent failures
22
+
3
23
  ## [8.2.3] - 2026-09-24
4
24
 
5
25
  - manifest parser ignores `none` placeholder paths and re-evaluates the section at every heading, so a plan title containing "File Manifest" no longer empties the manifest (`sdd_lock_spec` / `sdd_apply_file_patch`)
package/README.md CHANGED
@@ -34,7 +34,26 @@ Claude Code users can install Planu as a plugin instead of hand-editing `.mcp.js
34
34
  /plugin install planu@planu
35
35
  ```
36
36
 
37
- This registers the same `npx -y @planu/cli@latest` server.
37
+ This registers the same `npx -y @planu/cli@latest` server. The plugin also ships `planu-guard` hooks: while a locked feature has an unchecked task, native `Write`/`Edit` inside the workspace is denied in favor of `sdd_apply_file_patch`; `git ... --no-verify` is denied; and session start re-injects the active task. Disable them with the plugin manager.
38
+
39
+ ### Codex plugin
40
+
41
+ Codex CLI reads the same marketplace:
42
+
43
+ ```
44
+ codex plugin marketplace add planu-dev/planu
45
+ codex plugin add planu@planu
46
+ ```
47
+
48
+ This registers the same `npx -y @planu/cli@latest` server as MCP server `planu`. The `planu-guard` hooks are Claude Code only.
49
+
50
+ ### Cursor one-click install
51
+
52
+ Open this link in a browser with Cursor installed. It installs the server below with `PLANU_WORKSPACE` bound to `${workspaceFolder}`:
53
+
54
+ ```
55
+ cursor://anysphere.cursor-deeplink/mcp/install?name=planu&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBwbGFudS9jbGlAbGF0ZXN0Il0sImVudiI6eyJQTEFOVV9XT1JLU1BBQ0UiOiIke3dvcmtzcGFjZUZvbGRlcn0ifX0=
56
+ ```
38
57
 
39
58
  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.
40
59
 
@@ -98,7 +117,7 @@ sdd_init_workspace → sdd_create_feature → architect trinity → sdd_lock_spe
98
117
  1. **Initialize:** `sdd_init_workspace` writes `.sdd/features`, stamps host rules, and copies cognitive skills into `.claude/skills/`, `.cursor/skills/`, `.agents/skills/`, and `.gemini/skills/`. Existing `AGENTS.md` is preserved unless `force: true` or it is still a v6 host contract.
99
118
  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.
100
119
  3. **Lock:** `sdd_lock_spec` hashes spec, plan, and tasks. It rejects empty skeletons. Reseal after review with `relock: true` and `reason`.
101
- 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.
120
+ 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. A CREATE entry accepts search/replace patches after the file exists. `.sdd/` and `.git/` are never writable.
102
121
  5. **Verify:** independently prove acceptance criteria with `verification-auditor.md`.
103
122
  6. **Janitor:** prune local branches and orphaned worktrees only with authorization.
104
123
 
@@ -150,7 +169,7 @@ MCP:
150
169
  node dist/sdd-engine/cli.js
151
170
  ```
152
171
 
153
- `pnpm eval:skills` is an operator-only eval of the spec-architect skill. It spends API budget by shelling out to the local `claude` CLI against a throwaway workspace, so it is not part of `pnpm check` and never runs in CI.
172
+ `pnpm eval:skills` is an operator-only eval of the spec-architect and spec-executor skills. Executor cases (`"skill": "executor"`) ship a locked trinity and fail on unchecked tasks, edits outside the File Manifest, or failing `checks`. It spends API budget by shelling out to the local `claude` CLI against a throwaway workspace, so it is not part of `pnpm check` and never runs in CI.
154
173
 
155
174
  ---
156
175
 
@@ -43,14 +43,9 @@ export async function copyGlobalRules(workspaceRoot, force) {
43
43
  if (existed && force !== true && !isStaleV6HostDoc(existing)) {
44
44
  return 'preserved';
45
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
- }
46
+ const content = await fs.readFile(sourcePath, 'utf-8');
47
+ await fs.writeFile(targetPath, content, 'utf-8');
48
+ return existed ? 'replaced' : 'created';
54
49
  }
55
50
  const HOST_SKILL_DESCRIPTIONS = {
56
51
  'preflight-guardian': 'Use before architecture, first execution, resumed work, or any change under src/sdd-engine.',
@@ -82,58 +77,48 @@ async function readHostBody() {
82
77
  }
83
78
  }
84
79
  export async function installHostSkillPack(workspaceRoot) {
85
- try {
86
- const skillsDir = path.join(TEMPLATES_ROOT, 'skills');
87
- const files = (await fs.readdir(skillsDir)).filter((file) => file.endsWith('.md'));
88
- const written = [];
89
- for (const file of files) {
90
- const slug = file.replace(/\.md$/u, '');
91
- const body = toHostSkillMarkdown(slug, await fs.readFile(path.join(skillsDir, file), 'utf-8'));
92
- const hostSlug = `planu-${slug}`;
93
- const targets = [
94
- path.join('.claude', 'skills', hostSlug, 'SKILL.md'),
95
- path.join('.cursor', 'skills', hostSlug, 'SKILL.md'),
96
- path.join('.agents', 'skills', hostSlug, 'SKILL.md'),
97
- path.join('.gemini', 'skills', `${hostSlug}.md`),
98
- ];
99
- for (const relative of targets) {
100
- const fullPath = path.join(workspaceRoot, relative);
101
- await fs.mkdir(path.dirname(fullPath), { recursive: true });
102
- await fs.writeFile(fullPath, body, 'utf-8');
103
- written.push(relative);
104
- }
80
+ const skillsDir = path.join(TEMPLATES_ROOT, 'skills');
81
+ const files = (await fs.readdir(skillsDir)).filter((file) => file.endsWith('.md'));
82
+ const written = [];
83
+ for (const file of files) {
84
+ const slug = file.replace(/\.md$/u, '');
85
+ const body = toHostSkillMarkdown(slug, await fs.readFile(path.join(skillsDir, file), 'utf-8'));
86
+ const hostSlug = `planu-${slug}`;
87
+ const targets = [
88
+ path.join('.claude', 'skills', hostSlug, 'SKILL.md'),
89
+ path.join('.cursor', 'skills', hostSlug, 'SKILL.md'),
90
+ path.join('.agents', 'skills', hostSlug, 'SKILL.md'),
91
+ path.join('.gemini', 'skills', `${hostSlug}.md`),
92
+ ];
93
+ for (const relative of targets) {
94
+ const fullPath = path.join(workspaceRoot, relative);
95
+ await fs.mkdir(path.dirname(fullPath), { recursive: true });
96
+ await fs.writeFile(fullPath, body, 'utf-8');
97
+ written.push(relative);
105
98
  }
106
- return written;
107
- }
108
- catch {
109
- return [];
110
99
  }
100
+ return written;
111
101
  }
112
102
  export async function installHostRulePack(workspaceRoot) {
113
- try {
114
- const body = await readHostBody();
115
- const cursorRule = `---
103
+ const body = await readHostBody();
104
+ const cursorRule = `---
116
105
  description: Planu v8 FEAT-only. Specs live in .sdd/features. Never write planu/specs or SPEC-* stubs.
117
106
  alwaysApply: true
118
107
  ---
119
108
 
120
109
  ${body}`;
121
- const targets = [
122
- { relative: path.join('.cursor', 'rules', 'planu-sdd.mdc'), contents: cursorRule },
123
- { relative: path.join('.claude', 'rules', 'planu-sdd.md'), contents: body },
124
- { relative: path.join('.gemini', 'planu-sdd.md'), contents: body },
125
- ];
126
- const written = [];
127
- for (const target of targets) {
128
- const fullPath = path.join(workspaceRoot, target.relative);
129
- await fs.mkdir(path.dirname(fullPath), { recursive: true });
130
- await fs.writeFile(fullPath, target.contents, 'utf-8');
131
- written.push(target.relative);
132
- }
133
- return written;
134
- }
135
- catch {
136
- return [];
110
+ const targets = [
111
+ { relative: path.join('.cursor', 'rules', 'planu-sdd.mdc'), contents: cursorRule },
112
+ { relative: path.join('.claude', 'rules', 'planu-sdd.md'), contents: body },
113
+ { relative: path.join('.gemini', 'planu-sdd.md'), contents: body },
114
+ ];
115
+ const written = [];
116
+ for (const target of targets) {
117
+ const fullPath = path.join(workspaceRoot, target.relative);
118
+ await fs.mkdir(path.dirname(fullPath), { recursive: true });
119
+ await fs.writeFile(fullPath, target.contents, 'utf-8');
120
+ written.push(target.relative);
137
121
  }
122
+ return written;
138
123
  }
139
124
  //# sourceMappingURL=host-rule-pack.js.map
@@ -2,13 +2,14 @@ import { createHash } from 'node:crypto';
2
2
  import * as fs from 'node:fs/promises';
3
3
  import * as path from 'node:path';
4
4
  const CHECKBOX_TASK = /^[-*]\s*\[[ xX]\]/u;
5
+ const BDD_KEYWORDS = [/\bGIVEN\b/u, /\bWHEN\b/u, /\bTHEN\b/u];
5
6
  export function hashArtifact(content) {
6
7
  return createHash('sha256').update(content).digest('hex');
7
8
  }
8
9
  function assessTrinityCompleteness(specContent, planContent, tasksContent) {
9
10
  const specOk = hasHeading(specContent, 'Out-of-Scope') &&
10
11
  hasHeading(specContent, 'Error Matrix') &&
11
- (hasHeading(specContent, 'Acceptance Criteria') || /\bGIVEN\b/u.test(specContent));
12
+ BDD_KEYWORDS.every((keyword) => keyword.test(specContent));
12
13
  const planOk = hasHeading(planContent, 'Frozen Dependencies') && hasHeading(planContent, 'File Manifest');
13
14
  const hasTask = tasksContent.split('\n').some((line) => CHECKBOX_TASK.test(line.trim()));
14
15
  const manifest = scanManifest(planContent);
@@ -19,13 +20,20 @@ function assessTrinityCompleteness(specContent, planContent, tasksContent) {
19
20
  message: 'DELETE File Manifest entries must be exact paths, not globs.',
20
21
  };
21
22
  }
23
+ if (manifest.protectedWrite !== null) {
24
+ return {
25
+ ok: false,
26
+ code: 'ERR_TRINITY_INCOMPLETE',
27
+ message: `File Manifest cannot grant writes on protected root path '${manifest.protectedWrite}' (.sdd, .git, planu/specs).`,
28
+ };
29
+ }
22
30
  if (specOk && planOk && hasTask && manifest.hasPath) {
23
31
  return { ok: true };
24
32
  }
25
33
  return {
26
34
  ok: false,
27
35
  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.',
36
+ message: 'Lock requires Out-of-Scope, Error Matrix, GIVEN/WHEN/THEN acceptance criteria, Frozen Dependencies, a File Manifest path, and at least one checkbox task.',
29
37
  };
30
38
  }
31
39
  export async function verifyLockedTrinity(featDir) {
@@ -98,15 +106,23 @@ function hasHeading(content, needle) {
98
106
  const escaped = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
99
107
  return new RegExp(`^#{1,3}\\s+.*${escaped}`, 'imu').test(content);
100
108
  }
109
+ const PROTECTED_ROOTS = ['.sdd', '.git', 'planu/specs'];
101
110
  function scanManifest(planContent) {
102
111
  const { allowedFiles } = parseManifestContent(planContent);
103
112
  let globDelete = false;
113
+ let protectedWrite = null;
104
114
  for (const [entryPath, permission] of allowedFiles) {
105
115
  if (permission === 'DELETE' && entryPath.includes('*')) {
106
116
  globDelete = true;
107
117
  }
118
+ const normalized = path.posix.normalize(entryPath).toLowerCase();
119
+ if (permission !== 'READ_ONLY' &&
120
+ protectedWrite === null &&
121
+ PROTECTED_ROOTS.some((root) => normalized === root || normalized.startsWith(`${root}/`))) {
122
+ protectedWrite = entryPath;
123
+ }
108
124
  }
109
- return { hasPath: allowedFiles.size > 0, globDelete };
125
+ return { hasPath: allowedFiles.size > 0, globDelete, protectedWrite };
110
126
  }
111
127
  export function parseManifestContent(content) {
112
128
  const allowedFiles = new Map();
@@ -39,15 +39,16 @@ export class PatchSandbox {
39
39
  },
40
40
  };
41
41
  }
42
+ const effective = permission === 'CREATE' && searchContent !== '' ? 'MODIFY' : permission;
42
43
  const fullPath = path.resolve(this.workspaceRoot, normalizedTarget);
43
- const containmentError = await this.validateTargetContainment(fullPath, normalizedTarget, permission);
44
+ const containmentError = await this.validateTargetContainment(fullPath, normalizedTarget, effective);
44
45
  if (containmentError) {
45
46
  return containmentError;
46
47
  }
47
- if (permission === 'CREATE') {
48
+ if (effective === 'CREATE') {
48
49
  return this.executeCreatePatch(fullPath, normalizedTarget, searchContent, replaceContent);
49
50
  }
50
- if (permission === 'DELETE') {
51
+ if (effective === 'DELETE') {
51
52
  return this.executeDeletePatch(fullPath, normalizedTarget, searchContent, replaceContent);
52
53
  }
53
54
  return this.executeModifyPatch(fullPath, normalizedTarget, searchContent, replaceContent);
@@ -248,7 +249,7 @@ export class PatchSandbox {
248
249
  };
249
250
  }
250
251
  const updatedContent = searchContent
251
- ? existingContent.replace(searchContent, replaceContent)
252
+ ? existingContent.replace(searchContent, () => replaceContent)
252
253
  : replaceContent;
253
254
  try {
254
255
  await fs.writeFile(fullPath, updatedContent, 'utf-8');
@@ -1,10 +1,12 @@
1
+ import { readFileSync } from 'node:fs';
1
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
4
  import { registerUltralightSddTools } from './tools.js';
5
+ const { version } = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
4
6
  export function createUltralightSddServer(workspaceRoot) {
5
7
  const server = new McpServer({
6
8
  name: 'sdd-engine',
7
- version: '8.2.2',
9
+ version,
8
10
  }, {
9
11
  capabilities: {
10
12
  tools: {},
@@ -128,13 +128,13 @@ export class TaskWindowManager {
128
128
  },
129
129
  };
130
130
  }
131
- const cleanOutput = verificationOutput.trim().replace(/\s+/g, ' ').slice(0, 120);
131
+ const cleanOutput = summarizeEvidence(verificationOutput);
132
132
  const regexExact = new RegExp(`^(\\s*[-*]\\s*\\[)[\\s/](\\]\\s*(?:${taskId}\\b|.*\\b${taskId}\\b.*))`, 'i');
133
133
  let taskFound = false;
134
134
  for (let i = 0; i < lines.length; i++) {
135
135
  const line = lines[i];
136
136
  if (line !== undefined && regexExact.test(line)) {
137
- lines[i] = line.replace(regexExact, `$1x$2 — [Verified: ${cleanOutput}]`);
137
+ lines[i] = line.replace(regexExact, (_, open, rest) => `${open}x${rest} — [Verified: ${cleanOutput}]`);
138
138
  taskFound = true;
139
139
  break;
140
140
  }
@@ -166,6 +166,16 @@ export class TaskWindowManager {
166
166
  };
167
167
  }
168
168
  }
169
+ const EVIDENCE_LIMIT = 500;
170
+ function summarizeEvidence(output) {
171
+ const collapsed = output.trim().replace(/\s+/g, ' ');
172
+ if (collapsed.length <= EVIDENCE_LIMIT) {
173
+ return collapsed;
174
+ }
175
+ const head = Array.from(collapsed).slice(0, EVIDENCE_LIMIT).join('');
176
+ const lastSpace = head.lastIndexOf(' ');
177
+ return `${(lastSpace > 0 ? head.slice(0, lastSpace) : head).trimEnd()}…`;
178
+ }
169
179
  async function refreshTasksHashIfLocked(tasksFilePath, tasksContent) {
170
180
  const lockPath = path.join(path.dirname(tasksFilePath), '.lock');
171
181
  let raw;
@@ -233,19 +233,13 @@ function isNodeErrorCode(err, code) {
233
233
  }
234
234
  async function copySkillTemplates(skillsDir) {
235
235
  const sourceSkillsDir = path.resolve(moduleDir, '..', '..', '..', 'templates', 'skills');
236
- try {
237
- const files = await fs.readdir(sourceSkillsDir);
238
- for (const file of files) {
239
- if (file.endsWith('.md')) {
240
- const content = await fs.readFile(path.join(sourceSkillsDir, file), 'utf-8');
241
- await fs.writeFile(path.join(skillsDir, file), content, 'utf-8');
242
- }
236
+ const files = await fs.readdir(sourceSkillsDir);
237
+ for (const file of files) {
238
+ if (file.endsWith('.md')) {
239
+ const content = await fs.readFile(path.join(sourceSkillsDir, file), 'utf-8');
240
+ await fs.writeFile(path.join(skillsDir, file), content, 'utf-8');
243
241
  }
244
242
  }
245
- catch {
246
- await fs.writeFile(path.join(skillsDir, 'spec-architect.md'), '# Spec Architect Skill\n\nDefine Out-of-Scope, Contracts, and File Manifest.\n', 'utf-8');
247
- await fs.writeFile(path.join(skillsDir, 'spec-executor.md'), '# Spec Executor Skill\n\nOperate in Zero-Freedom mode.\n', 'utf-8');
248
- }
249
243
  }
250
244
  async function collectFeatures(featuresDir, taskWindow, statusFilter) {
251
245
  const result = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "8.2.3",
3
+ "version": "8.2.5",
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",
@@ -47,6 +47,12 @@ Count-only assertions, existence checks, snapshots without semantics, and tests
47
47
  - For `website/**` or `planu.dev`, adopt `visual-release-auditor.md` and require executed browser evidence. Do not approve from tests or curl alone.
48
48
  - For deletion or legacy retirement, prove absence from runtime reachability, package contents, templates, active documentation, and supported entrypoints.
49
49
 
50
+ ## Silent failures
51
+
52
+ - Search the diff for swallowed failures: empty catch blocks, catch blocks returning defaults ([], '', false, null, success values), .catch(() => …) that converts a rejection into success, || true, and ignored exit codes.
53
+ - Each one must rethrow, return a typed error the caller surfaces, or be a deliberate probe or fallback whose safety is evident from the code.
54
+ - A result that reports success, created, or an empty list while the underlying operation failed is CHANGES_REQUESTED.
55
+
50
56
  ## Verdict
51
57
 
52
58
  Emit exactly one verdict: