@planu/cli 8.1.0 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [8.1.1] - 2026-09-21
2
+
3
+ - fail closed with `ERR_WORKSPACE_UNRESOLVED` when the resolved workspace is the user home directory without MCP roots or `PLANU_WORKSPACE`
4
+ - keep `sdd_init_workspace` `scope: global` on `~/.config/sdd`
5
+
1
6
  ## [8.1.0] - 2026-09-20
2
7
 
3
8
  ### Features
package/README.md CHANGED
@@ -54,7 +54,7 @@ Local development in this repo:
54
54
  }
55
55
  ```
56
56
 
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.
57
+ The published server asks the host for MCP roots and binds to the open project that owns `.sdd/`. If the process cwd is the user home directory and roots are missing, project-scoped tools return `ERR_WORKSPACE_UNRESOLVED` instead of creating `.sdd` under `$HOME`. 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.
58
58
 
59
59
  **Requirements:** Node.js >= 22.13.
60
60
 
@@ -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.1',
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
2
  import { dirname, join, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
+ const ERR_WORKSPACE_UNRESOLVED_MESSAGE = 'Resolved workspace is the user home directory without MCP roots or PLANU_WORKSPACE. Set the MCP server cwd to the project, advertise MCP roots, or set a per-process PLANU_WORKSPACE. Do not pin PLANU_WORKSPACE globally.';
4
5
  export function parseMcpRootUri(uri) {
5
6
  const trimmed = uri.trim();
6
7
  if (!trimmed) {
@@ -50,6 +51,22 @@ export function resolveSddWorkspace(input = {}) {
50
51
  }
51
52
  return finish(startDir, 'fallback');
52
53
  }
54
+ export function isHomeFallbackWorkspace(resolved, env = process.env) {
55
+ return resolved.source === 'fallback' && isHomeDirectory(resolved.workspaceRoot, env);
56
+ }
57
+ export function homeFallbackFailure(resolved, trigger, env = process.env) {
58
+ if (!isHomeFallbackWorkspace(resolved, env)) {
59
+ return null;
60
+ }
61
+ return {
62
+ success: false,
63
+ error: {
64
+ code: 'ERR_WORKSPACE_UNRESOLVED',
65
+ message: ERR_WORKSPACE_UNRESOLVED_MESSAGE,
66
+ trigger,
67
+ },
68
+ };
69
+ }
53
70
  function finish(workspaceRoot, source) {
54
71
  const sddDir = join(workspaceRoot, '.sdd');
55
72
  return {
@@ -1,6 +1,6 @@
1
1
  export type ArtifactType = 'spec' | 'plan' | 'tasks';
2
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.1",
4
4
  "description": "Planu — MCP Server for Spec Driven Development. Cross-platform (Linux/macOS/Windows, x64/arm64).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -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-*`.