@planu/cli 8.1.0 → 8.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [8.1.2] - 2026-09-21
2
+
3
+ - ignore unexpanded `${workspaceFolder}` and a `PLANU_WORKSPACE` equal to `$HOME` so Cursor/Windsurf interpolation stays per-project
4
+ - expand `~/...` in `PLANU_WORKSPACE` against `$HOME` (Cursor may interpolate `${workspaceFolder}` as a tilde path)
5
+ - document project MCP install for Cursor, Claude Code, Windsurf, and Codex
6
+
7
+ ## [8.1.1] - 2026-09-21
8
+
9
+ - fail closed with `ERR_WORKSPACE_UNRESOLVED` when the resolved workspace is the user home directory without MCP roots or `PLANU_WORKSPACE`
10
+ - keep `sdd_init_workspace` `scope: global` on `~/.config/sdd`
11
+
1
12
  ## [8.1.0] - 2026-09-20
2
13
 
3
14
  ### Features
package/README.md CHANGED
@@ -25,20 +25,30 @@ Authentication is **not required**. Do not call `mcp_auth`.
25
25
 
26
26
  ## Installation
27
27
 
28
- Paste this into Claude Code, Cursor, Codex, or any MCP client:
28
+ Paste this into **Claude Code, Cursor, Windsurf, Codex, or any MCP client**. Prefer a **project** config (`.mcp.json` or `.cursor/mcp.json` in the repo you are editing) 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
  {
32
32
  "mcpServers": {
33
33
  "planu": {
34
34
  "command": "npx",
35
- "args": ["-y", "@planu/cli@latest"]
35
+ "args": ["-y", "@planu/cli@latest"],
36
+ "env": {
37
+ "PLANU_WORKSPACE": "${workspaceFolder}"
38
+ }
36
39
  }
37
40
  }
38
41
  }
39
42
  ```
40
43
 
41
- That is the whole install. `npx @planu/cli` starts the MCP stdio server (`cli`, `planu`, and `sdd-engine` are the same binary). Each host restart resolves **latest** from npm.
44
+ | Host | Where to put it | How the project is bound |
45
+ |---|---|---|
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, or Claude MCP settings | Process cwd is the launch directory; unexpanded `${workspaceFolder}` is ignored. |
48
+ | Windsurf | project MCP config (VS Code-compatible) | Use `${workspaceFolder}` the same way as Cursor. |
49
+ | Codex / other stdio | project MCP or the directory you launched from | Advertise MCP roots, or start the server with cwd = project. |
50
+
51
+ `npx @planu/cli` starts the MCP stdio server (`cli`, `planu`, and `sdd-engine` are the same binary). Each host restart resolves **latest** from npm.
42
52
 
43
53
  Local development in this repo:
44
54
 
@@ -47,14 +57,16 @@ Local development in this repo:
47
57
  "mcpServers": {
48
58
  "planu": {
49
59
  "command": "node",
50
- "args": ["dist/sdd-engine/cli.js"],
51
- "cwd": "/absolute/path/to/sdd-mcp-server"
60
+ "args": ["${workspaceFolder}/dist/sdd-engine/cli.js"],
61
+ "env": {
62
+ "PLANU_WORKSPACE": "${workspaceFolder}"
63
+ }
52
64
  }
53
65
  }
54
66
  }
55
67
  ```
56
68
 
57
- The published server asks the host for MCP roots and binds to the open project that owns `.sdd/`. Do not set a global `PLANU_WORKSPACE`: that pins every client to one repo. `PLANU_WORKSPACE` remains an optional per-process override. `pnpm start` runs the MCP server.
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.
58
70
 
59
71
  **Requirements:** Node.js >= 22.13.
60
72
 
@@ -25,6 +25,7 @@ export declare const ErrorCodeSchema: z.ZodEnum<{
25
25
  ERR_SPEC_NOT_LOCKED: "ERR_SPEC_NOT_LOCKED";
26
26
  ERR_TASK_NOT_FOUND: "ERR_TASK_NOT_FOUND";
27
27
  ERR_TASK_OUT_OF_SEQUENCE: "ERR_TASK_OUT_OF_SEQUENCE";
28
+ ERR_WORKSPACE_UNRESOLVED: "ERR_WORKSPACE_UNRESOLVED";
28
29
  }>;
29
30
  export declare const InitWorkspaceInputSchema: z.ZodObject<{
30
31
  scope: z.ZodEnum<{
@@ -20,6 +20,7 @@ export const ErrorCodeSchema = z.enum([
20
20
  'ERR_PATCH_FAILED',
21
21
  'ERR_INVALID_ARTIFACT',
22
22
  'ERR_INVALID_SLICE',
23
+ 'ERR_WORKSPACE_UNRESOLVED',
23
24
  ]);
24
25
  export const InitWorkspaceInputSchema = z.object({
25
26
  scope: z.enum(['global', 'project']),
@@ -4,7 +4,7 @@ import { registerUltralightSddTools } from './tools.js';
4
4
  export function createUltralightSddServer(workspaceRoot) {
5
5
  const server = new McpServer({
6
6
  name: 'sdd-engine',
7
- version: '8.1.0',
7
+ version: '8.1.2',
8
8
  }, {
9
9
  capabilities: {
10
10
  tools: {},
@@ -5,6 +5,7 @@ import { PatchSandbox } from '../patch-sandbox.js';
5
5
  import { TaskWindowManager } from '../task-window.js';
6
6
  import { formatResult } from './format-result.js';
7
7
  import { verifyLockedTrinity } from '../lock-integrity.js';
8
+ import { homeFallbackFailure } from '../workspace-root.js';
8
9
  export function registerExecutionTools(server, workspace) {
9
10
  const taskWindow = new TaskWindowManager();
10
11
  registerReadArtifactTool(server, workspace);
@@ -20,6 +21,10 @@ function registerReadArtifactTool(server, workspace) {
20
21
  }, async (rawArgs) => {
21
22
  const args = ReadSpecArtifactInputSchema.parse(rawArgs);
22
23
  const resolved = await workspace.resolve();
24
+ const homeError = homeFallbackFailure(resolved, 'sdd_read_spec_artifact');
25
+ if (homeError) {
26
+ return formatResult(homeError);
27
+ }
23
28
  const targetPath = path.join(resolved.sddDir, 'features', args.feature_id, `${args.artifact}.md`);
24
29
  try {
25
30
  const text = await fs.readFile(targetPath, 'utf-8');
@@ -44,6 +49,10 @@ function registerReadFileSliceTool(server, workspace) {
44
49
  }, async (rawArgs) => {
45
50
  const args = ReadFileSliceInputSchema.parse(rawArgs);
46
51
  const resolved = await workspace.resolve();
52
+ const homeError = homeFallbackFailure(resolved, 'sdd_read_file_slice');
53
+ if (homeError) {
54
+ return formatResult(homeError);
55
+ }
47
56
  return executeReadFileSlice(resolved.workspaceRoot, args.path, args.start_line, args.end_line);
48
57
  });
49
58
  }
@@ -54,6 +63,10 @@ function registerGetActiveTaskTool(server, workspace, taskWindow) {
54
63
  }, async (rawArgs) => {
55
64
  const args = GetActiveTaskInputSchema.parse(rawArgs);
56
65
  const resolved = await workspace.resolve();
66
+ const homeError = homeFallbackFailure(resolved, 'sdd_get_active_task');
67
+ if (homeError) {
68
+ return formatResult(homeError);
69
+ }
57
70
  const tasksPath = path.join(resolved.sddDir, 'features', args.feature_id, 'tasks.md');
58
71
  const result = await taskWindow.getActiveTask(tasksPath);
59
72
  return formatResult(result);
@@ -66,6 +79,10 @@ function registerApplyPatchTool(server, workspace) {
66
79
  }, async (rawArgs) => {
67
80
  const args = ApplyFilePatchInputSchema.parse(rawArgs);
68
81
  const resolved = await workspace.resolve();
82
+ const homeError = homeFallbackFailure(resolved, 'sdd_apply_file_patch');
83
+ if (homeError) {
84
+ return formatResult(homeError);
85
+ }
69
86
  const patchSandbox = new PatchSandbox(resolved.workspaceRoot);
70
87
  return executeApplyPatch(resolved.sddDir, patchSandbox, args);
71
88
  });
@@ -77,6 +94,10 @@ function registerCompleteTaskTool(server, workspace, taskWindow) {
77
94
  }, async (rawArgs) => {
78
95
  const args = CompleteTaskInputSchema.parse(rawArgs);
79
96
  const resolved = await workspace.resolve();
97
+ const homeError = homeFallbackFailure(resolved, 'sdd_complete_task');
98
+ if (homeError) {
99
+ return formatResult(homeError);
100
+ }
80
101
  const featDir = path.join(resolved.sddDir, 'features', args.feature_id);
81
102
  const lockError = await requireLockedTrinity(featDir, 'sdd_complete_task');
82
103
  if (lockError) {
@@ -6,6 +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 { homeFallbackFailure } from '../workspace-root.js';
9
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.';
10
11
  export function registerWorkspaceTools(server, workspace) {
11
12
  const taskWindow = new TaskWindowManager();
@@ -21,6 +22,12 @@ function registerInitTool(server, workspace) {
21
22
  }, async (rawArgs) => {
22
23
  const args = InitWorkspaceInputSchema.parse(rawArgs);
23
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
+ }
24
31
  const targetBase = args.scope === 'global'
25
32
  ? path.join(process.env.HOME ?? '~', '.config', 'sdd')
26
33
  : resolved.sddDir;
@@ -50,6 +57,10 @@ function registerListTool(server, workspace, taskWindow) {
50
57
  }, async (rawArgs) => {
51
58
  const args = ListFeaturesInputSchema.parse(rawArgs);
52
59
  const resolved = await workspace.resolve();
60
+ const homeError = homeFallbackFailure(resolved, 'sdd_list_features');
61
+ if (homeError) {
62
+ return formatResult(homeError);
63
+ }
53
64
  const featuresDir = path.join(resolved.sddDir, 'features');
54
65
  const featuresList = await collectFeatures(featuresDir, taskWindow, args.status_filter);
55
66
  return formatResult({
@@ -72,6 +83,10 @@ function registerCreateTool(server, workspace) {
72
83
  }, async (rawArgs) => {
73
84
  const args = CreateFeatureInputSchema.parse(rawArgs);
74
85
  const resolved = await workspace.resolve();
86
+ const homeError = homeFallbackFailure(resolved, 'sdd_create_feature');
87
+ if (homeError) {
88
+ return formatResult(homeError);
89
+ }
75
90
  const featuresDir = path.join(resolved.sddDir, 'features');
76
91
  await fs.mkdir(featuresDir, { recursive: true });
77
92
  let featureId = args.id;
@@ -181,6 +196,10 @@ function registerLockTool(server, workspace) {
181
196
  }, async (rawArgs) => {
182
197
  const args = LockSpecInputSchema.parse(rawArgs);
183
198
  const resolved = await workspace.resolve();
199
+ const homeError = homeFallbackFailure(resolved, 'sdd_lock_spec');
200
+ if (homeError) {
201
+ return formatResult(homeError);
202
+ }
184
203
  const featDir = path.join(resolved.sddDir, 'features', args.feature_id);
185
204
  return executeLockSpec(featDir, args.feature_id);
186
205
  });
@@ -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
- import { dirname, join, resolve } from 'node:path';
2
+ import { dirname, join, resolve, sep } 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) {
@@ -28,9 +29,9 @@ export function resolveSddWorkspace(input = {}) {
28
29
  if (input.pinnedRoot?.trim()) {
29
30
  return finish(resolve(input.pinnedRoot.trim()), 'pin');
30
31
  }
31
- const fromEnv = env.PLANU_WORKSPACE?.trim();
32
+ const fromEnv = usablePlanuWorkspaceEnv(env);
32
33
  if (fromEnv) {
33
- return finish(resolve(fromEnv), 'env');
34
+ return finish(fromEnv, 'env');
34
35
  }
35
36
  const mcpDirs = unique((input.mcpRootUris ?? [])
36
37
  .map((uri) => parseMcpRootUri(uri))
@@ -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 {
@@ -79,6 +96,37 @@ function isHomeDirectory(dir, env) {
79
96
  }
80
97
  return resolve(dir) === resolve(home);
81
98
  }
99
+ function usablePlanuWorkspaceEnv(env) {
100
+ const fromEnv = env.PLANU_WORKSPACE?.trim();
101
+ if (!fromEnv || fromEnv.includes('${')) {
102
+ return null;
103
+ }
104
+ const expanded = expandHomePrefix(fromEnv, env);
105
+ if (!expanded) {
106
+ return null;
107
+ }
108
+ const resolved = resolve(expanded);
109
+ if (resolved.includes(`${sep}~${sep}`) || resolved.endsWith(`${sep}~`)) {
110
+ return null;
111
+ }
112
+ if (isHomeDirectory(resolved, env)) {
113
+ return null;
114
+ }
115
+ return resolved;
116
+ }
117
+ function expandHomePrefix(raw, env) {
118
+ if (raw === '~' || raw.startsWith('~/') || raw.startsWith('~\\')) {
119
+ const home = env.HOME?.trim() ?? env.USERPROFILE?.trim();
120
+ if (!home) {
121
+ return null;
122
+ }
123
+ if (raw === '~') {
124
+ return home;
125
+ }
126
+ return join(home, raw.slice(2));
127
+ }
128
+ return raw;
129
+ }
82
130
  function unique(values) {
83
131
  const seen = new Set();
84
132
  const out = [];
@@ -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';
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planu/cli",
3
- "version": "8.1.0",
3
+ "version": "8.1.2",
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",
@@ -24,7 +24,7 @@ Preflight never edits product files and never marks tasks complete.
24
24
  1. **Repository state**
25
25
  - Record `git status --short --branch`, HEAD, and registered worktrees.
26
26
  - Identify pre-existing user changes. Treat them as owned by the user and do not overwrite, stage, revert, or include them accidentally.
27
- - Confirm the intended workspace root. Stop on an ambiguous root.
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
28
 
29
29
  2. **Feature state**
30
30
  - Use `sdd_list_features` and name the selected `FEAT-*`.