@planu/cli 8.2.17 → 8.2.18
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 +12 -0
- package/README.md +14 -2
- package/dist/sdd-engine/completion-guard.d.ts +28 -0
- package/dist/sdd-engine/completion-guard.js +320 -0
- package/dist/sdd-engine/completion-snapshot.d.ts +11 -0
- package/dist/sdd-engine/completion-snapshot.js +155 -0
- package/dist/sdd-engine/feature-authority.d.ts +20 -0
- package/dist/sdd-engine/feature-authority.js +199 -0
- package/dist/sdd-engine/feature-manifest.d.ts +6 -0
- package/dist/sdd-engine/feature-manifest.js +116 -0
- package/dist/sdd-engine/host-rule-pack.d.ts +1 -0
- package/dist/sdd-engine/host-rule-pack.js +63 -7
- package/dist/sdd-engine/lock-integrity.d.ts +3 -18
- package/dist/sdd-engine/lock-integrity.js +192 -217
- package/dist/sdd-engine/patch-sandbox.js +1 -1
- package/dist/sdd-engine/server.js +4 -6
- package/dist/sdd-engine/task-content.d.ts +8 -0
- package/dist/sdd-engine/task-content.js +132 -0
- package/dist/sdd-engine/task-failures.d.ts +12 -0
- package/dist/sdd-engine/task-failures.js +125 -0
- package/dist/sdd-engine/task-window.d.ts +10 -4
- package/dist/sdd-engine/task-window.js +177 -246
- package/dist/sdd-engine/tools/execution-tools.js +29 -26
- package/dist/sdd-engine/tools/feature-store.d.ts +11 -0
- package/dist/sdd-engine/tools/feature-store.js +224 -0
- package/dist/sdd-engine/tools/workspace-tools.js +65 -127
- package/dist/sdd-engine/workspace-root.d.ts +3 -1
- package/dist/sdd-engine/workspace-root.js +69 -3
- package/dist/types/completion.d.ts +77 -0
- package/dist/types/completion.js +2 -0
- package/package.json +2 -2
- package/templates/AGENTS.md +4 -0
- package/templates/host/planu-sdd.md +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { readFile, realpath } from 'node:fs/promises';
|
|
1
|
+
import { constants, existsSync } from 'node:fs';
|
|
2
|
+
import { lstat, open, readFile, realpath } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join, resolve, sep } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
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.';
|
|
@@ -128,7 +128,7 @@ function expandHomePrefix(raw, env) {
|
|
|
128
128
|
}
|
|
129
129
|
return raw;
|
|
130
130
|
}
|
|
131
|
-
export async function readTextInsideWorkspace(workspaceRoot, absolutePath) {
|
|
131
|
+
export async function readTextInsideWorkspace(workspaceRoot, absolutePath, options) {
|
|
132
132
|
let root;
|
|
133
133
|
try {
|
|
134
134
|
root = await realpath(workspaceRoot);
|
|
@@ -148,6 +148,13 @@ export async function readTextInsideWorkspace(workspaceRoot, absolutePath) {
|
|
|
148
148
|
if (realTarget !== root && !realTarget.startsWith(boundary)) {
|
|
149
149
|
return { ok: false, reason: 'outside' };
|
|
150
150
|
}
|
|
151
|
+
if (options !== undefined) {
|
|
152
|
+
const { maxBytes } = options;
|
|
153
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0 || maxBytes > 65_536) {
|
|
154
|
+
return { ok: false, reason: 'missing' };
|
|
155
|
+
}
|
|
156
|
+
return readBoundedTextInsideWorkspace(root, boundary, realTarget, maxBytes);
|
|
157
|
+
}
|
|
151
158
|
try {
|
|
152
159
|
return { ok: true, text: await readFile(realTarget, 'utf8') };
|
|
153
160
|
}
|
|
@@ -155,6 +162,65 @@ export async function readTextInsideWorkspace(workspaceRoot, absolutePath) {
|
|
|
155
162
|
return { ok: false, reason: 'missing' };
|
|
156
163
|
}
|
|
157
164
|
}
|
|
165
|
+
async function readBoundedTextInsideWorkspace(root, boundary, realTarget, maxBytes) {
|
|
166
|
+
let handle;
|
|
167
|
+
const readBounded = async () => {
|
|
168
|
+
try {
|
|
169
|
+
const before = await lstat(realTarget);
|
|
170
|
+
if (!before.isFile() || before.size > maxBytes) {
|
|
171
|
+
return { ok: false, reason: 'missing' };
|
|
172
|
+
}
|
|
173
|
+
// Nonblocking open prevents a regular-file replacement with a FIFO from hanging.
|
|
174
|
+
handle = await open(realTarget, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
175
|
+
const opened = await handle.stat();
|
|
176
|
+
if (!opened.isFile() ||
|
|
177
|
+
opened.size > maxBytes ||
|
|
178
|
+
opened.dev !== before.dev ||
|
|
179
|
+
opened.ino !== before.ino) {
|
|
180
|
+
return { ok: false, reason: 'missing' };
|
|
181
|
+
}
|
|
182
|
+
const currentTarget = await realpath(realTarget);
|
|
183
|
+
if (currentTarget !== realTarget ||
|
|
184
|
+
(currentTarget !== root && !currentTarget.startsWith(boundary))) {
|
|
185
|
+
return { ok: false, reason: 'outside' };
|
|
186
|
+
}
|
|
187
|
+
const revalidated = await lstat(currentTarget);
|
|
188
|
+
if (!revalidated.isFile() ||
|
|
189
|
+
revalidated.dev !== opened.dev ||
|
|
190
|
+
revalidated.ino !== opened.ino) {
|
|
191
|
+
return { ok: false, reason: 'missing' };
|
|
192
|
+
}
|
|
193
|
+
return await readBoundedDescriptor(handle, maxBytes);
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
return { ok: false, reason: 'missing' };
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const result = await readBounded();
|
|
200
|
+
try {
|
|
201
|
+
await handle?.close();
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return { ok: false, reason: 'missing' };
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
async function readBoundedDescriptor(handle, maxBytes) {
|
|
209
|
+
// Bound total descriptor reads, including when the file grows after stat.
|
|
210
|
+
const bytes = Buffer.alloc(maxBytes);
|
|
211
|
+
let total = 0;
|
|
212
|
+
while (total < bytes.length) {
|
|
213
|
+
const { bytesRead } = await handle.read(bytes, total, bytes.length - total, total);
|
|
214
|
+
if (bytesRead === 0) {
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
total += bytesRead;
|
|
218
|
+
}
|
|
219
|
+
if (total > maxBytes || (await handle.stat()).size > maxBytes) {
|
|
220
|
+
return { ok: false, reason: 'missing' };
|
|
221
|
+
}
|
|
222
|
+
return { ok: true, text: bytes.subarray(0, total).toString('utf8') };
|
|
223
|
+
}
|
|
158
224
|
function unique(values) {
|
|
159
225
|
const seen = new Set();
|
|
160
226
|
const out = [];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { SddLockFile, ErrorCode } from './sdd-engine.js';
|
|
2
|
+
export type CompletionFailureReason = 'guard_present' | 'contract_drift' | 'cancelled' | 'persistence_uncertain';
|
|
3
|
+
export interface PhysicalIdentity {
|
|
4
|
+
dev: number;
|
|
5
|
+
ino: number;
|
|
6
|
+
mode: number;
|
|
7
|
+
uid: number;
|
|
8
|
+
nlink: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ArtifactCapture {
|
|
11
|
+
content: string;
|
|
12
|
+
identity: PhysicalIdentity;
|
|
13
|
+
}
|
|
14
|
+
export interface AuthorityDirectory {
|
|
15
|
+
directory: string;
|
|
16
|
+
identity: PhysicalIdentity;
|
|
17
|
+
}
|
|
18
|
+
export interface GuardRecord {
|
|
19
|
+
version: 1;
|
|
20
|
+
pid: number;
|
|
21
|
+
host: string;
|
|
22
|
+
nonce: string;
|
|
23
|
+
startedAt: string;
|
|
24
|
+
operation: 'complete' | 'patch' | 'lock';
|
|
25
|
+
phase: 'running' | 'persisting';
|
|
26
|
+
featureDev: number;
|
|
27
|
+
featureIno: number;
|
|
28
|
+
taskId?: string;
|
|
29
|
+
commandDigest?: string;
|
|
30
|
+
snapshotDigest?: string;
|
|
31
|
+
predecessor?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CompletionSnapshot {
|
|
34
|
+
featDir: string;
|
|
35
|
+
directories: AuthorityDirectory[];
|
|
36
|
+
artifacts: Record<'spec.md' | 'plan.md' | 'tasks.md' | '.lock', ArtifactCapture>;
|
|
37
|
+
specContent: string;
|
|
38
|
+
planContent: string;
|
|
39
|
+
tasksContent: string;
|
|
40
|
+
lockContent: string;
|
|
41
|
+
lock: SddLockFile;
|
|
42
|
+
digest: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CompletionLeaseOptions {
|
|
45
|
+
operation?: 'complete' | 'patch' | 'lock';
|
|
46
|
+
workspaceRoot?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface CompletionSnapshotOptions {
|
|
49
|
+
writable?: boolean;
|
|
50
|
+
workspaceRoot?: string;
|
|
51
|
+
validateLock?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export type TrinityCaptures = Record<'spec.md' | 'plan.md' | 'tasks.md', ArtifactCapture>;
|
|
54
|
+
export type TrinityCompleteness = {
|
|
55
|
+
ok: true;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
code: ErrorCode;
|
|
59
|
+
message: string;
|
|
60
|
+
details?: {
|
|
61
|
+
missing: string[];
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export type SealResult = {
|
|
65
|
+
ok: true;
|
|
66
|
+
specHash: string;
|
|
67
|
+
planHash: string;
|
|
68
|
+
tasksHash: string;
|
|
69
|
+
relocked: boolean;
|
|
70
|
+
} | Exclude<TrinityCompleteness, {
|
|
71
|
+
ok: true;
|
|
72
|
+
}>;
|
|
73
|
+
export interface PreviousLock {
|
|
74
|
+
previous?: SddLockFile;
|
|
75
|
+
artifact?: ArtifactCapture;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=completion.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planu/cli",
|
|
3
|
-
"version": "8.2.
|
|
4
|
-
"description": "Planu — MCP
|
|
3
|
+
"version": "8.2.18",
|
|
4
|
+
"description": "Planu — MCP server for Spec Driven Development. Planning and file operations on macOS/Linux/Windows; automated verification requires macOS/Linux (POSIX).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
package/templates/AGENTS.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
You are operating within a Spec-Driven Development environment (Planu v8).
|
|
4
4
|
Canonical contract: `PLANU_V8_MANIFESTO.txt`.
|
|
5
5
|
|
|
6
|
+
## First use in this project
|
|
7
|
+
|
|
8
|
+
After the local client has registered the MCP server and the intended project is open, use `sdd_list_features` to inspect setup. A setup request authorizes `sdd_init_workspace(scope="project")` in that identified project; connecting or inspecting alone does not. Use the default `force=false` to preserve an existing current AGENTS.md. Read `.agents/skills/planu-preflight-guardian/SKILL.md` and the matching role immediately with `sdd_read_file_slice` before feature work. Initialization installs nine roles in four host formats. Matching files do not prove that the host has loaded them: a host/session catalog reload may be required, separately from restarting the MCP server. Do not promise automatic compliance by every client or model.
|
|
9
|
+
|
|
6
10
|
1. **SDD Skills Primacy:**
|
|
7
11
|
- ALWAYS refer to `.claude/skills/planu-*`, `.cursor/skills/planu-*`, `.agents/skills/planu-*`, or `.gemini/skills/planu-*` for role directives. Specs stay in `.sdd/features`.
|
|
8
12
|
- 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).
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The only SDD contract is `.sdd/features/{FEAT-*}/spec.md`, `plan.md`, and `tasks.md`.
|
|
4
4
|
|
|
5
|
+
## First use in this project
|
|
6
|
+
|
|
7
|
+
After the local client has registered the MCP server and the intended project is open, use `sdd_list_features` to inspect setup. A setup request authorizes `sdd_init_workspace(scope="project")` in that identified project; connecting or inspecting alone does not. Use the default `force=false` to preserve an existing current AGENTS.md. Read `.agents/skills/planu-preflight-guardian/SKILL.md` and the matching role immediately with `sdd_read_file_slice` before feature work. Initialization installs nine roles in four host formats. Matching files do not prove that the host has loaded them: a host/session catalog reload may be required, separately from restarting the MCP server. Do not promise automatic compliance by every client or model.
|
|
8
|
+
|
|
5
9
|
- Feature IDs are `FEAT-*`. `SPEC-001` is invalid.
|
|
6
10
|
- Use the nine `sdd_*` tools. Never call deleted v6 tools (`create_spec`, `challenge_spec`, `check_readiness`, `validate`, `planu_status`, …).
|
|
7
11
|
- Never create, thin, or copy files under `planu/specs/`. Planu does not read that tree.
|