@planu/cli 5.7.9 → 5.7.11
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 +33 -0
- package/dist/.planu-build.json +1 -1
- package/dist/cli/commands/create.js +32 -1
- package/dist/cli/commands/inspect.js +2 -2
- package/dist/cli/commands/install.js +4 -4
- package/dist/cli/commands/offline.js +4 -4
- package/dist/cli/commands/serve.js +2 -2
- package/dist/cli/router.js +4 -4
- package/dist/config/registries/error-recovery.json +20 -0
- package/dist/config/version.d.ts +1 -1
- package/dist/config/version.js +5 -1
- package/dist/engine/auto-updater/config-detector.js +5 -5
- package/dist/engine/auto-updater/index.js +3 -3
- package/dist/engine/autopilot/state-updater.js +2 -2
- package/dist/engine/config-health/mcp-config-checker.js +2 -2
- package/dist/engine/errors/registry-loader.d.ts +1 -0
- package/dist/engine/errors/registry-loader.js +8 -2
- package/dist/engine/safety/lock-lease-store.d.ts +4 -0
- package/dist/engine/safety/lock-lease-store.js +11 -1
- package/dist/engine/spec-format/bdd-parser.js +6 -3
- package/dist/engine/spec-format/unified-spec-builder.js +8 -1
- package/dist/engine/telemetry/event-envelope.js +2 -2
- package/dist/engine/update-notifier.js +6 -6
- package/dist/engine/validation/validation-freshness.js +3 -2
- package/dist/engine/version-detector/bundled-version-checker.js +2 -2
- package/dist/hosts/codex/config-scaffold.js +2 -2
- package/dist/hosts/gemini/config-scaffold.js +2 -2
- package/dist/index.js +2 -2
- package/dist/native/lightweight-command-catalog.js +2 -2
- package/dist/storage/runtime-db.d.ts +4 -0
- package/dist/storage/runtime-db.js +11 -1
- package/dist/storage/spec-store.js +11 -4
- package/dist/storage/status-store/self-healing.js +3 -3
- package/dist/storage/status-store/version-sync.js +4 -4
- package/dist/tools/init-project/lifecycle-helpers.js +4 -4
- package/dist/tools/rollback-release.js +3 -3
- package/dist/tools/safe-handler.js +2 -2
- package/dist/tools/scaffold-plugin-handler.js +2 -2
- package/dist/tools/update-status/side-effects.js +3 -1
- package/dist/transports/http-transport.js +4 -4
- package/dist/transports/transport-factory.js +15 -6
- package/package.json +2 -1
- package/planu-plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [5.7.11] - 2026-09-02
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
- feat(scripts): add test-profile to rank the slowest test files
|
|
5
|
+
- feat(preflight): bail the related lane on the first failure
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
- fix(spec-format): strip a leading list marker from the goal sentence
|
|
9
|
+
- fix(spec-format): unique headerless scenario titles and problem-sentence goal fallback
|
|
10
|
+
- fix(update-status): treat a missing planu/conventions.json as no disabled hooks
|
|
11
|
+
- fix(storage): sync spec_version from spec.md on digest refresh
|
|
12
|
+
- fix(validation): read the bound source digest once before awaiting the git digest
|
|
13
|
+
- fix(scripts): test-profile returns 1 without a report and drops the stray declaration file
|
|
14
|
+
- fix(vitest): keep vitest.config.ts double-quote style out of prettier scope
|
|
15
|
+
- fix(transport): exit exactly once when the stdio hard-stop races the drain
|
|
16
|
+
|
|
17
|
+
### Performance
|
|
18
|
+
- perf(vitest): drop html, clover and text coverage reporters
|
|
19
|
+
|
|
20
|
+
### Refactoring
|
|
21
|
+
- refactor(spec-format): drop the unreachable when-fallback in headerless title suffixing
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [5.7.10] - 2026-09-02
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
- fix(config): read the package version lazily so store imports stay side-effect free
|
|
28
|
+
- fix(cli): reject invalid --ac-format and assert the review transition succeeds
|
|
29
|
+
- fix(cli): forward tags and acFormat from planu create and infer bdd for gherkin descriptions
|
|
30
|
+
- fix(errors): await the recovery registry before matching tool failures
|
|
31
|
+
- fix(storage): name versions and restart remediation when the local store schema is ahead
|
|
32
|
+
|
|
33
|
+
|
|
1
34
|
## [5.7.9] - 2026-09-02
|
|
2
35
|
|
|
3
36
|
### Bug Fixes
|
package/dist/.planu-build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":1,"commit":"
|
|
1
|
+
{"schemaVersion":1,"commit":"751d4ec85be2cb3fcb93112587d70211814166b0"}
|
|
@@ -4,10 +4,29 @@ import { resolve } from 'node:path';
|
|
|
4
4
|
import { handleCreateSpec } from '../../tools/create-spec.js';
|
|
5
5
|
import { writeCliResult } from '../formatter.js';
|
|
6
6
|
import { red } from '../colors.js';
|
|
7
|
+
const AC_FORMATS = new Set(['bdd', 'checkbox']);
|
|
8
|
+
const GHERKIN_DESCRIPTION_RE = /^(GIVEN|### Scenario \d+)/m;
|
|
9
|
+
function parseTags(rawTags) {
|
|
10
|
+
if (rawTags === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const tags = rawTags
|
|
14
|
+
.split(',')
|
|
15
|
+
.map((tag) => tag.trim())
|
|
16
|
+
.filter((tag) => tag.length > 0);
|
|
17
|
+
return tags.length > 0 ? tags : undefined;
|
|
18
|
+
}
|
|
19
|
+
function resolveAcFormat(rawAcFormat, description) {
|
|
20
|
+
if (rawAcFormat !== undefined) {
|
|
21
|
+
return rawAcFormat;
|
|
22
|
+
}
|
|
23
|
+
return GHERKIN_DESCRIPTION_RE.test(description) ? 'bdd' : undefined;
|
|
24
|
+
}
|
|
7
25
|
export const createCommand = {
|
|
8
26
|
name: 'create',
|
|
9
27
|
description: 'Create a new spec',
|
|
10
|
-
usage: 'planu create <title> [--type feature] [--description "..."] [--path .]'
|
|
28
|
+
usage: 'planu create <title> [--type feature] [--description "..."] [--path .] ' +
|
|
29
|
+
'[--tags a,b,c] [--ac-format bdd|checkbox]',
|
|
11
30
|
async run(args, flags) {
|
|
12
31
|
const { values, positionals } = parseArgs({
|
|
13
32
|
args,
|
|
@@ -18,6 +37,8 @@ export const createCommand = {
|
|
|
18
37
|
scope: { type: 'string' },
|
|
19
38
|
target: { type: 'string' },
|
|
20
39
|
feature: { type: 'string' },
|
|
40
|
+
tags: { type: 'string' },
|
|
41
|
+
'ac-format': { type: 'string' },
|
|
21
42
|
},
|
|
22
43
|
strict: false,
|
|
23
44
|
allowPositionals: true,
|
|
@@ -28,8 +49,16 @@ export const createCommand = {
|
|
|
28
49
|
process.exitCode = 1;
|
|
29
50
|
return;
|
|
30
51
|
}
|
|
52
|
+
const rawAcFormat = values['ac-format'];
|
|
53
|
+
if (rawAcFormat !== undefined && !AC_FORMATS.has(rawAcFormat)) {
|
|
54
|
+
process.stderr.write(`${red('Error:')} Invalid --ac-format "${rawAcFormat}". Expected "bdd" or "checkbox".\nUsage: ${createCommand.usage}\n`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
31
58
|
const projectPath = resolve(values.path ?? process.cwd());
|
|
32
59
|
const description = values.description ?? title;
|
|
60
|
+
const tags = parseTags(values.tags);
|
|
61
|
+
const acFormat = resolveAcFormat(rawAcFormat, description);
|
|
33
62
|
const result = await handleCreateSpec({
|
|
34
63
|
title,
|
|
35
64
|
description,
|
|
@@ -38,6 +67,8 @@ export const createCommand = {
|
|
|
38
67
|
scope: values.scope,
|
|
39
68
|
target: values.target,
|
|
40
69
|
feature: values.feature ?? undefined,
|
|
70
|
+
tags,
|
|
71
|
+
acFormat,
|
|
41
72
|
});
|
|
42
73
|
writeCliResult(result, flags, 'Spec created!');
|
|
43
74
|
},
|
|
@@ -2,7 +2,7 @@ import { lstat, readdir } from 'node:fs/promises';
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { basename, isAbsolute, join, relative, sep } from 'node:path';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import {
|
|
5
|
+
import { planuVersion } from '../../config/version.js';
|
|
6
6
|
import { createStorageCatalog } from '../../storage/storage-catalog.js';
|
|
7
7
|
import { resolveStorageLayout } from '../../storage/storage-layout.js';
|
|
8
8
|
import { RUNTIME_STORAGE_SCHEMA } from '../../engine/core-bridge.js';
|
|
@@ -98,7 +98,7 @@ export async function buildInspectionReport() {
|
|
|
98
98
|
})));
|
|
99
99
|
return {
|
|
100
100
|
schemaVersion: 1,
|
|
101
|
-
cliVersion:
|
|
101
|
+
cliVersion: planuVersion(),
|
|
102
102
|
offline: process.env.PLANU_OFFLINE === '1',
|
|
103
103
|
storageSchema: RUNTIME_STORAGE_SCHEMA,
|
|
104
104
|
installation,
|
|
@@ -4,7 +4,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, sta
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { dirname, isAbsolute, join } from 'node:path';
|
|
6
6
|
import { bold, cyan, green, yellow, dim } from '../colors.js';
|
|
7
|
-
import {
|
|
7
|
+
import { planuVersion } from '../../config/version.js';
|
|
8
8
|
import { confirm, select } from '../interactive.js';
|
|
9
9
|
import { resolveStorageLayout } from '../../storage/storage-layout.js';
|
|
10
10
|
import { removeCommercialState } from '../../engine/migrations/remove-commercial-state.js';
|
|
@@ -73,7 +73,7 @@ function buildMcpEntry() {
|
|
|
73
73
|
args: [
|
|
74
74
|
...(offline ? ['--offline'] : ['--prefer-offline']),
|
|
75
75
|
'-y',
|
|
76
|
-
`@planu/cli@${
|
|
76
|
+
`@planu/cli@${planuVersion()}`,
|
|
77
77
|
],
|
|
78
78
|
};
|
|
79
79
|
}
|
|
@@ -262,7 +262,7 @@ function printBanner() {
|
|
|
262
262
|
for (const line of art) {
|
|
263
263
|
process.stdout.write(`${teal(line)}\n`);
|
|
264
264
|
}
|
|
265
|
-
process.stdout.write(`\n ${dim(`Spec Driven Development MCP Server · v${
|
|
265
|
+
process.stdout.write(`\n ${dim(`Spec Driven Development MCP Server · v${planuVersion()}`)}\n`);
|
|
266
266
|
process.stdout.write(`\n ${bold('🔒 Privacy guarantee')}\n`);
|
|
267
267
|
process.stdout.write(` ${dim('·')} Everything runs ${bold('locally')} — no cloud, no servers\n`);
|
|
268
268
|
process.stdout.write(` ${dim('·')} Your code never leaves your machine. Planu is local-first.\n`);
|
|
@@ -355,7 +355,7 @@ async function installToPath(tool, targetPath, scope, quiet) {
|
|
|
355
355
|
format: tool.format,
|
|
356
356
|
scope,
|
|
357
357
|
package: '@planu/cli',
|
|
358
|
-
version:
|
|
358
|
+
version: planuVersion(),
|
|
359
359
|
offline: process.env.PLANU_OFFLINE === '1',
|
|
360
360
|
installedAt: new Date().toISOString(),
|
|
361
361
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { planuVersion } from '../../config/version.js';
|
|
3
3
|
import { RUNTIME_STORAGE_SCHEMA } from '../../engine/core-bridge.js';
|
|
4
4
|
const MCP_INITIALIZE_REQUEST = `${JSON.stringify({
|
|
5
5
|
jsonrpc: '2.0',
|
|
@@ -48,7 +48,7 @@ function provesStorageSchema(stdout) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
export function prepareOfflineRuntime() {
|
|
51
|
-
const packageSpec = `@planu/cli@${
|
|
51
|
+
const packageSpec = `@planu/cli@${planuVersion()}`;
|
|
52
52
|
const npmExecutable = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
53
53
|
const errors = [];
|
|
54
54
|
let cacheReady = true;
|
|
@@ -66,7 +66,7 @@ export function prepareOfflineRuntime() {
|
|
|
66
66
|
}
|
|
67
67
|
const npxExecutable = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
68
68
|
const smokeEnvironment = { ...process.env, PLANU_OFFLINE: '1' };
|
|
69
|
-
const mcpSmoke = spawnSync(npxExecutable, ['--offline', '-y', `@planu/cli@${
|
|
69
|
+
const mcpSmoke = spawnSync(npxExecutable, ['--offline', '-y', `@planu/cli@${planuVersion()}`], {
|
|
70
70
|
encoding: 'utf8',
|
|
71
71
|
timeout: 30_000,
|
|
72
72
|
env: smokeEnvironment,
|
|
@@ -76,7 +76,7 @@ export function prepareOfflineRuntime() {
|
|
|
76
76
|
if (!mcpStartupReady) {
|
|
77
77
|
errors.push(errorText(mcpSmoke, 'offline MCP startup handshake failed'));
|
|
78
78
|
}
|
|
79
|
-
const schemaSmoke = spawnSync(npxExecutable, ['--offline', '-y', `@planu/cli@${
|
|
79
|
+
const schemaSmoke = spawnSync(npxExecutable, ['--offline', '-y', `@planu/cli@${planuVersion()}`, 'inspect', '--json'], {
|
|
80
80
|
encoding: 'utf8',
|
|
81
81
|
timeout: 30_000,
|
|
82
82
|
env: smokeEnvironment,
|
|
@@ -18,13 +18,13 @@ export const serveCommand = {
|
|
|
18
18
|
// Re-invoke main server with --transport http flags
|
|
19
19
|
const { selectTransport } = await import('../../transports/transport-factory.js');
|
|
20
20
|
const { McpServer } = await import('@modelcontextprotocol/sdk/server/mcp.js');
|
|
21
|
-
const {
|
|
21
|
+
const { planuVersion } = await import('../../config/version.js');
|
|
22
22
|
const { withToolTracking } = await import('../../tools/tool-registry.js');
|
|
23
23
|
const { registerResources } = await import('../../resources/registry.js');
|
|
24
24
|
const { registerSpecTools } = await import('../../tools/register-spec-tools.js');
|
|
25
25
|
const { registerPlatformTools } = await import('../../tools/register-platform-tools.js');
|
|
26
26
|
process.stdout.write(`${green('Starting Planu MCP server')} on port ${cyan(port)}...\n`);
|
|
27
|
-
const server = withToolTracking(new McpServer({ name: `planu v${
|
|
27
|
+
const server = withToolTracking(new McpServer({ name: `planu v${planuVersion()}`, version: planuVersion() }));
|
|
28
28
|
registerResources(server);
|
|
29
29
|
registerSpecTools(server);
|
|
30
30
|
registerPlatformTools(server);
|
package/dist/cli/router.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// cli/router.ts — Command dispatch for CLI mode (SPEC-124)
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
|
-
import {
|
|
3
|
+
import { planuVersion } from '../config/version.js';
|
|
4
4
|
import { red, bold, cyan, dim } from './colors.js';
|
|
5
5
|
// Lazy-load commands to avoid importing tool handlers when not needed
|
|
6
6
|
async function loadCommands() {
|
|
@@ -62,7 +62,7 @@ async function loadCommands() {
|
|
|
62
62
|
}
|
|
63
63
|
function printHelp(commands) {
|
|
64
64
|
const lines = [
|
|
65
|
-
`${bold('planu')} ${dim(`v${
|
|
65
|
+
`${bold('planu')} ${dim(`v${planuVersion()}`)} — Spec Driven Development CLI`,
|
|
66
66
|
'',
|
|
67
67
|
`${cyan('Usage:')} planu <command> [options]`,
|
|
68
68
|
'',
|
|
@@ -104,7 +104,7 @@ export async function route(args) {
|
|
|
104
104
|
verbose: values.verbose,
|
|
105
105
|
};
|
|
106
106
|
if (values.version) {
|
|
107
|
-
process.stdout.write(`planu ${
|
|
107
|
+
process.stdout.write(`planu ${planuVersion()}\n`);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
const commands = await loadCommands();
|
|
@@ -118,7 +118,7 @@ export async function route(args) {
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
if (commandName === 'version') {
|
|
121
|
-
process.stdout.write(`planu ${
|
|
121
|
+
process.stdout.write(`planu ${planuVersion()}\n`);
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
const cmd = commands.get(commandName);
|
|
@@ -89,6 +89,26 @@
|
|
|
89
89
|
"args": {},
|
|
90
90
|
"rationale": "Review the input data against the schema documentation."
|
|
91
91
|
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "runtime_schema_ahead",
|
|
95
|
+
"match": { "code": "RUNTIME_SCHEMA_AHEAD" },
|
|
96
|
+
"what": "Runtime store schema is newer than this server supports",
|
|
97
|
+
"nextAction": {
|
|
98
|
+
"tool": "inspect",
|
|
99
|
+
"args": {},
|
|
100
|
+
"rationale": "Restart the MCP server so it loads the current dist; a newer Planu migrated the local store."
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "lock_schema_ahead",
|
|
105
|
+
"match": { "code": "LOCK_SCHEMA_AHEAD" },
|
|
106
|
+
"what": "Lock store schema is newer than this server supports",
|
|
107
|
+
"nextAction": {
|
|
108
|
+
"tool": "inspect",
|
|
109
|
+
"args": {},
|
|
110
|
+
"rationale": "Restart the MCP server so it loads the current dist; a newer Planu migrated the local store."
|
|
111
|
+
}
|
|
92
112
|
}
|
|
93
113
|
]
|
|
94
114
|
}
|
package/dist/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function planuVersion(): string;
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/config/version.js
CHANGED
|
@@ -12,5 +12,9 @@ function loadVersion() {
|
|
|
12
12
|
}
|
|
13
13
|
return version;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
let cachedVersion;
|
|
16
|
+
export function planuVersion() {
|
|
17
|
+
cachedVersion ??= loadVersion();
|
|
18
|
+
return cachedVersion;
|
|
19
|
+
}
|
|
16
20
|
//# sourceMappingURL=version.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import {
|
|
7
|
+
import { planuVersion } from '../../config/version.js';
|
|
8
8
|
import { reportClassifiedDegradation } from '../../errors/classified-degradation.js';
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
10
|
// Config path resolution
|
|
@@ -78,7 +78,7 @@ export async function detectPlanuInstall() {
|
|
|
78
78
|
if (location.configPath === null) {
|
|
79
79
|
return {
|
|
80
80
|
method: 'unknown',
|
|
81
|
-
currentVersion:
|
|
81
|
+
currentVersion: planuVersion(),
|
|
82
82
|
configPath: null,
|
|
83
83
|
mcpEntry: null,
|
|
84
84
|
};
|
|
@@ -93,7 +93,7 @@ export async function detectPlanuInstall() {
|
|
|
93
93
|
reportClassifiedDegradation('MCP_CONFIG_PARSE_FAILED', error);
|
|
94
94
|
return {
|
|
95
95
|
method: 'unknown',
|
|
96
|
-
currentVersion:
|
|
96
|
+
currentVersion: planuVersion(),
|
|
97
97
|
configPath: location.configPath,
|
|
98
98
|
mcpEntry: null,
|
|
99
99
|
};
|
|
@@ -102,7 +102,7 @@ export async function detectPlanuInstall() {
|
|
|
102
102
|
if (mcpEntry === null) {
|
|
103
103
|
return {
|
|
104
104
|
method: 'unknown',
|
|
105
|
-
currentVersion:
|
|
105
|
+
currentVersion: planuVersion(),
|
|
106
106
|
configPath: location.configPath,
|
|
107
107
|
mcpEntry: null,
|
|
108
108
|
};
|
|
@@ -110,7 +110,7 @@ export async function detectPlanuInstall() {
|
|
|
110
110
|
const method = detectInstallMethod(mcpEntry);
|
|
111
111
|
return {
|
|
112
112
|
method,
|
|
113
|
-
currentVersion:
|
|
113
|
+
currentVersion: planuVersion(),
|
|
114
114
|
configPath: location.configPath,
|
|
115
115
|
mcpEntry,
|
|
116
116
|
};
|
|
@@ -4,7 +4,7 @@ import { existsSync } from 'node:fs';
|
|
|
4
4
|
import { detectPlanuInstall } from './config-detector.js';
|
|
5
5
|
import { buildPinnedEntry } from './config-patcher.js';
|
|
6
6
|
import { fetchLatestVersion } from './npm-registry.js';
|
|
7
|
-
import {
|
|
7
|
+
import { planuVersion } from '../../config/version.js';
|
|
8
8
|
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
9
9
|
import { resolveStorageLayout } from '../../storage/storage-layout.js';
|
|
10
10
|
import { upgradeInventoriedAdapters } from './atomic-upgrade.js';
|
|
@@ -30,7 +30,7 @@ export async function checkForUpdates() {
|
|
|
30
30
|
'Legacy unpinned entry detected; run enable_auto_update to pin an exact release.';
|
|
31
31
|
}
|
|
32
32
|
else if (installInfo.method === 'global') {
|
|
33
|
-
updateCommand = `npm install -g @planu/cli@${latestVersion ??
|
|
33
|
+
updateCommand = `npm install -g @planu/cli@${latestVersion ?? planuVersion()}`;
|
|
34
34
|
}
|
|
35
35
|
else if (installInfo.method === 'local-path') {
|
|
36
36
|
updateCommand = 'Update your local installation and rebuild.';
|
|
@@ -69,7 +69,7 @@ export async function enableAutoUpdate(confirm, overrideConfigPath) {
|
|
|
69
69
|
// Build a minimal install info using the override path
|
|
70
70
|
installInfo = {
|
|
71
71
|
method: 'unknown',
|
|
72
|
-
currentVersion:
|
|
72
|
+
currentVersion: planuVersion(),
|
|
73
73
|
configPath: overrideConfigPath,
|
|
74
74
|
mcpEntry: null,
|
|
75
75
|
};
|
|
@@ -105,7 +105,7 @@ export async function refreshProjectStatus(projectPath, projectId) {
|
|
|
105
105
|
// eslint-disable-next-line no-restricted-syntax -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
106
106
|
const { specStore } = await import('../../storage/index.js');
|
|
107
107
|
const specs = await specStore.listSpecs(projectId);
|
|
108
|
-
const {
|
|
108
|
+
const { planuVersion } = await import('../../config/version.js');
|
|
109
109
|
const byStatus = {};
|
|
110
110
|
const byType = {};
|
|
111
111
|
for (const spec of specs) {
|
|
@@ -119,7 +119,7 @@ export async function refreshProjectStatus(projectPath, projectId) {
|
|
|
119
119
|
byStatus,
|
|
120
120
|
byType,
|
|
121
121
|
recentChanges: existing.recentChanges,
|
|
122
|
-
version:
|
|
122
|
+
version: planuVersion(),
|
|
123
123
|
};
|
|
124
124
|
await saveStatus(projectPath, status);
|
|
125
125
|
});
|
|
@@ -4,7 +4,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { isAbsolute, join } from 'node:path';
|
|
6
6
|
import { fileExists } from '../../core/shared/fs.js';
|
|
7
|
-
import {
|
|
7
|
+
import { planuVersion } from '../../config/version.js';
|
|
8
8
|
async function readIfExists(path) {
|
|
9
9
|
try {
|
|
10
10
|
return await readFile(path, 'utf-8');
|
|
@@ -14,7 +14,7 @@ async function readIfExists(path) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function replacementFix() {
|
|
17
|
-
return `Replace the Planu MCP entry with command "npx", args ["-y", "@planu/cli@${
|
|
17
|
+
return `Replace the Planu MCP entry with command "npx", args ["-y", "@planu/cli@${planuVersion()}"], and startup_timeout_sec 120 where the host supports it.`;
|
|
18
18
|
}
|
|
19
19
|
async function checkPathTarget(configFile, target) {
|
|
20
20
|
if (!target || !isAbsolute(target) || (await fileExists(target))) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RecoveryRegistry } from './recovery-registry.js';
|
|
2
2
|
export declare function getErrorRecoveryRegistry(): RecoveryRegistry;
|
|
3
|
+
export declare function ensureErrorRecoveryRegistry(): Promise<RecoveryRegistry>;
|
|
3
4
|
export declare function invalidateErrorRegistryCache(): void;
|
|
4
5
|
//# sourceMappingURL=registry-loader.d.ts.map
|
|
@@ -3,17 +3,23 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { RecoveryRegistry } from './recovery-registry.js';
|
|
4
4
|
const PACKAGE_REGISTRY_PATH = join(process.cwd(), 'src', 'config', 'registries', 'error-recovery.json');
|
|
5
5
|
let cachedRegistry;
|
|
6
|
+
let loadPromise;
|
|
6
7
|
export function getErrorRecoveryRegistry() {
|
|
7
8
|
if (cachedRegistry === undefined) {
|
|
8
9
|
cachedRegistry = new RecoveryRegistry({ rulesPath: PACKAGE_REGISTRY_PATH });
|
|
9
|
-
|
|
10
|
-
cachedRegistry.load().catch((err) => {
|
|
10
|
+
loadPromise = cachedRegistry.load().catch((err) => {
|
|
11
11
|
console.warn('[Planu] Failed to load error recovery registry:', err);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
return cachedRegistry;
|
|
15
15
|
}
|
|
16
|
+
export async function ensureErrorRecoveryRegistry() {
|
|
17
|
+
const registry = getErrorRecoveryRegistry();
|
|
18
|
+
await loadPromise;
|
|
19
|
+
return registry;
|
|
20
|
+
}
|
|
16
21
|
export function invalidateErrorRegistryCache() {
|
|
17
22
|
cachedRegistry = undefined;
|
|
23
|
+
loadPromise = undefined;
|
|
18
24
|
}
|
|
19
25
|
//# sourceMappingURL=registry-loader.js.map
|
|
@@ -3,7 +3,17 @@ import { dirname, isAbsolute, resolve } from 'node:path';
|
|
|
3
3
|
import { DatabaseSync } from 'node:sqlite';
|
|
4
4
|
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
5
5
|
import { resolveStorageLayout } from '../../storage/storage-layout.js';
|
|
6
|
+
import { planuVersion } from '../../config/version.js';
|
|
6
7
|
const SCHEMA_VERSION = 1;
|
|
8
|
+
export class LockSchemaAheadError extends Error {
|
|
9
|
+
code = 'LOCK_SCHEMA_AHEAD';
|
|
10
|
+
constructor(storeSchema, supportedSchema) {
|
|
11
|
+
super(`[Planu] Lock store schema ${String(storeSchema)} is newer than this server supports ` +
|
|
12
|
+
`(schema ${String(supportedSchema)}, Planu ${planuVersion()}). A newer Planu migrated it. ` +
|
|
13
|
+
`Restart the MCP server so it loads the current dist.`);
|
|
14
|
+
this.name = 'LockSchemaAheadError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
7
17
|
const DEFAULT_BUSY_TIMEOUT_MS = 5_000;
|
|
8
18
|
const BUSY_RETRY_INTERVAL_MS = 10;
|
|
9
19
|
const BUSY_WAIT = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
@@ -142,7 +152,7 @@ export class LockLeaseStore {
|
|
|
142
152
|
try {
|
|
143
153
|
const row = this.database.prepare('PRAGMA user_version').get();
|
|
144
154
|
if (row.user_version > SCHEMA_VERSION) {
|
|
145
|
-
throw new
|
|
155
|
+
throw new LockSchemaAheadError(row.user_version, SCHEMA_VERSION);
|
|
146
156
|
}
|
|
147
157
|
if (row.user_version === 0) {
|
|
148
158
|
this.database.exec(`
|
|
@@ -44,15 +44,19 @@ function isSingleLineGivenWhenThenText(text) {
|
|
|
44
44
|
function opensHeaderlessScenario(rawKeyword, text) {
|
|
45
45
|
return rawKeyword === 'given' || isSingleLineGivenWhenThenText(text);
|
|
46
46
|
}
|
|
47
|
+
function suffixedTitle(thenText, steps) {
|
|
48
|
+
return `${thenText} (given ${steps.find((step) => step.keyword === 'given')?.text ?? ''})`;
|
|
49
|
+
}
|
|
47
50
|
export function parseBddScenarios(markdown) {
|
|
48
51
|
const scenarios = [];
|
|
49
52
|
const lines = markdown.split('\n');
|
|
50
53
|
let current = null;
|
|
51
|
-
// Tracks whether the current scenario was auto-created (no Scenario: header)
|
|
52
54
|
let currentIsHeaderless = false;
|
|
55
|
+
const closedTitles = new Set();
|
|
53
56
|
const closeCurrent = () => {
|
|
54
57
|
if (current && hasThenSignal(current)) {
|
|
55
58
|
scenarios.push(current);
|
|
59
|
+
closedTitles.add(current.title);
|
|
56
60
|
}
|
|
57
61
|
current = null;
|
|
58
62
|
currentIsHeaderless = false;
|
|
@@ -88,9 +92,8 @@ export function parseBddScenarios(markdown) {
|
|
|
88
92
|
currentIsHeaderless = true;
|
|
89
93
|
}
|
|
90
94
|
current.steps.push({ keyword, text });
|
|
91
|
-
// For headerless scenarios, update the title to the THEN text for better descriptiveness
|
|
92
95
|
if (currentIsHeaderless && keyword === 'then') {
|
|
93
|
-
current.title = text;
|
|
96
|
+
current.title = closedTitles.has(text) ? suffixedTitle(text, current.steps) : text;
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
closeCurrent();
|
|
@@ -22,7 +22,7 @@ export function buildCanonicalUnifiedSpecContent(input) {
|
|
|
22
22
|
const proseBeforeHeading = source.split(/^##[ \t]+\S.*$/m, 1)[0]?.trim() ?? '';
|
|
23
23
|
const problem = firstNonEmpty(explicitProblem, proseBeforeHeading, source);
|
|
24
24
|
const explicitGoal = extractTopLevelSectionBody(source, 'Goal');
|
|
25
|
-
const goal = firstNonEmpty(explicitGoal,
|
|
25
|
+
const goal = firstNonEmpty(explicitGoal, firstSentence(problem), 'Needs decision: define the goal this spec must achieve.');
|
|
26
26
|
const explicitTechnical = extractTopLevelSectionBody(source, 'Technical');
|
|
27
27
|
const generatedNotes = extractTopLevelSectionBody(input.technicalBody, 'Implementation Notes');
|
|
28
28
|
const technical = firstNonEmpty(explicitTechnical, generatedNotes, groundedTechnicalFallback(input.files, input.criteria));
|
|
@@ -306,6 +306,13 @@ function extractTopLevelSectionBody(body, section) {
|
|
|
306
306
|
function renderSection(title, body) {
|
|
307
307
|
return `## ${title}\n\n${body.trim()}`;
|
|
308
308
|
}
|
|
309
|
+
function firstSentence(text) {
|
|
310
|
+
const paragraph = (text.split(/\n\s*\n/).find((part) => part.trim().length > 0) ?? '')
|
|
311
|
+
.trim()
|
|
312
|
+
.replace(/\s+/g, ' ')
|
|
313
|
+
.replace(/^(?:\d+[.)]|[-*+])\s+/, '');
|
|
314
|
+
return /^[\s\S]*?[.!?](?=\s|$)/.exec(paragraph)?.[0] ?? paragraph;
|
|
315
|
+
}
|
|
309
316
|
function firstNonEmpty(...values) {
|
|
310
317
|
return (values.find((value) => value !== undefined && value !== null && value.length > 0) ?? '');
|
|
311
318
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Every field is typed and closed; unknown fields or enum values are rejected rather than
|
|
3
3
|
// stored, so no free-form data (paths, args, spec content) has a code path into the envelope.
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
|
-
import {
|
|
5
|
+
import { planuVersion } from '../../config/version.js';
|
|
6
6
|
/** Ephemeral per-process session id, generated once at module load. */
|
|
7
7
|
export const TELEMETRY_SESSION_ID = randomUUID();
|
|
8
8
|
const EVENT_NAMES = new Set([
|
|
@@ -105,7 +105,7 @@ export function buildTelemetryEnvelope(name, fields, options = {}) {
|
|
|
105
105
|
occurredAt: clock().toISOString(),
|
|
106
106
|
anonymousInstallationId: fields.anonymousInstallationId,
|
|
107
107
|
sessionId: fields.sessionId,
|
|
108
|
-
planuVersion:
|
|
108
|
+
planuVersion: planuVersion(),
|
|
109
109
|
operatingSystem: resolveOperatingSystem(),
|
|
110
110
|
nodeMajor: resolveNodeMajor(),
|
|
111
111
|
mcpHost: fields.mcpHost ?? 'unknown',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { get } from 'node:https';
|
|
5
5
|
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import {
|
|
7
|
+
import { planuVersion } from '../config/version.js';
|
|
8
8
|
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
9
9
|
import { resolveStorageLayout } from '../storage/storage-layout.js';
|
|
10
10
|
import { assertNetworkAllowed } from './network-policy.js';
|
|
@@ -141,7 +141,7 @@ function isDeprecated(current, latest) {
|
|
|
141
141
|
function emitUpdateHint(latest, deprecated) {
|
|
142
142
|
const urgency = deprecated ? '🚨 OUTDATED' : '🆕 Update';
|
|
143
143
|
const msg = [
|
|
144
|
-
`[Planu] ${urgency}: v${
|
|
144
|
+
`[Planu] ${urgency}: v${planuVersion()} → v${latest}`,
|
|
145
145
|
`[Planu] Run: npm install -g @planu/cli@${latest}`,
|
|
146
146
|
`[Planu] Or: npx @planu/cli@${latest}`,
|
|
147
147
|
].join('\n');
|
|
@@ -149,14 +149,14 @@ function emitUpdateHint(latest, deprecated) {
|
|
|
149
149
|
isDeprecatedVersion = deprecated;
|
|
150
150
|
if (deprecated) {
|
|
151
151
|
pendingUpdateBanner = [
|
|
152
|
-
`🚨 Planu OUTDATED: v${
|
|
152
|
+
`🚨 Planu OUTDATED: v${planuVersion()} is ${DEPRECATED_MINOR_GAP}+ minor versions behind v${latest}.`,
|
|
153
153
|
`Some tools may not work correctly. Update NOW:`,
|
|
154
154
|
` npm install -g @planu/cli@${latest}`,
|
|
155
155
|
` — or run: check_update_status for instructions`,
|
|
156
156
|
].join('\n');
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
|
-
pendingUpdateBanner = `⚠️ Update available: v${
|
|
159
|
+
pendingUpdateBanner = `⚠️ Update available: v${planuVersion()} → v${latest}. Run: npm install -g @planu/cli@${latest}`;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
@@ -178,8 +178,8 @@ export async function checkForUpdates(dataDir) {
|
|
|
178
178
|
latest = await fetchLatestVersion();
|
|
179
179
|
writeCache(cachePath, latest);
|
|
180
180
|
}
|
|
181
|
-
if (isNewerVersion(
|
|
182
|
-
emitUpdateHint(latest, isDeprecated(
|
|
181
|
+
if (isNewerVersion(planuVersion(), latest)) {
|
|
182
|
+
emitUpdateHint(latest, isDeprecated(planuVersion(), latest));
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
catch {
|
|
@@ -658,9 +658,10 @@ export async function evaluateValidationFreshnessBarrier(lease, bindings) {
|
|
|
658
658
|
invalidateExactEpoch(lease, candidate);
|
|
659
659
|
return { fresh: false, reason: 'evidence-changed', changedInput: candidate.handoffPath };
|
|
660
660
|
}
|
|
661
|
+
const boundSourceDigest = candidate.bindings?.sourceDigest;
|
|
661
662
|
try {
|
|
662
|
-
if (
|
|
663
|
-
(await gitSourceTreeDigest(candidate.projectPath)) !==
|
|
663
|
+
if (boundSourceDigest !== undefined &&
|
|
664
|
+
(await gitSourceTreeDigest(candidate.projectPath)) !== boundSourceDigest) {
|
|
664
665
|
invalidateExactEpoch(lease, candidate);
|
|
665
666
|
return { fresh: false, reason: 'source-changed', changedInput: candidate.projectPath };
|
|
666
667
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// engine/version-detector/bundled-version-checker.ts — SPEC-756
|
|
2
2
|
// Detects when Planu is running as a bundled version inside another plugin (e.g. Superpowers)
|
|
3
3
|
// and compares it against the latest published version on npm.
|
|
4
|
-
import {
|
|
4
|
+
import { planuVersion } from '../../config/version.js';
|
|
5
5
|
const NPM_REGISTRY_URL = 'https://registry.npmjs.org/@planu/cli/latest';
|
|
6
6
|
const PACKAGE_NAME = '@planu/cli';
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
@@ -11,7 +11,7 @@ const PACKAGE_NAME = '@planu/cli';
|
|
|
11
11
|
* Returns the current running version of Planu from package.json.
|
|
12
12
|
*/
|
|
13
13
|
export function getCurrentVersion() {
|
|
14
|
-
return
|
|
14
|
+
return planuVersion();
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Fetches the latest published version from the npm registry.
|
|
@@ -13,7 +13,7 @@ import { join } from 'node:path';
|
|
|
13
13
|
import { detectCodexWorkspace } from './workspace-scope.js';
|
|
14
14
|
import { buildRulesForHost } from '../../engine/host-rules-templates/index.js';
|
|
15
15
|
import { assertEnglishOnlyArtifactText } from '../../engine/spec-language/english-only.js';
|
|
16
|
-
import {
|
|
16
|
+
import { planuVersion as currentPlanuVersion } from '../../config/version.js';
|
|
17
17
|
import { generateImplementerRole, generateReviewerRole, generateSpecWriterRole, } from '../../engine/ai-integration/codex/agent-roles-generator.js';
|
|
18
18
|
const CODEX_CONFIG_TOML = `# .openai/config.toml — Planu Codex workspace configuration
|
|
19
19
|
# Auto-generated by Planu init_project. Safe to customize.
|
|
@@ -61,7 +61,7 @@ MCP server registered in .openai/config.toml.
|
|
|
61
61
|
* `<!-- planu:rules:start -->` markers is replaced on subsequent runs.
|
|
62
62
|
* Safe to call on non-Codex environments — skips silently unless markers are present.
|
|
63
63
|
*/
|
|
64
|
-
export async function scaffoldCodexConfig(projectPath, planuVersion =
|
|
64
|
+
export async function scaffoldCodexConfig(projectPath, planuVersion = currentPlanuVersion()) {
|
|
65
65
|
const markers = detectCodexWorkspace(projectPath);
|
|
66
66
|
const isCodexEnv = markers.hasWorkspaceEnv || markers.hasCodexEnv || markers.isEnterprise;
|
|
67
67
|
// Only scaffold if Codex env markers are present, or if .openai/ already exists
|
|
@@ -6,7 +6,7 @@ import { writeFile, readFile, mkdir } from 'node:fs/promises';
|
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { buildRulesForHost } from '../../engine/host-rules-templates/index.js';
|
|
8
8
|
import { assertEnglishOnlyArtifactText } from '../../engine/spec-language/english-only.js';
|
|
9
|
-
import {
|
|
9
|
+
import { planuVersion as currentPlanuVersion } from '../../config/version.js';
|
|
10
10
|
import { fileExists } from '../../core/shared/fs.js';
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// File content generators
|
|
@@ -127,7 +127,7 @@ function buildPostToolHookSh() {
|
|
|
127
127
|
* Called by init_project when a Gemini workspace is detected.
|
|
128
128
|
* Integration hook for handler.ts: see REPORT at end of implementation.
|
|
129
129
|
*/
|
|
130
|
-
export async function scaffoldGeminiConfig(projectPath, planuVersion =
|
|
130
|
+
export async function scaffoldGeminiConfig(projectPath, planuVersion = currentPlanuVersion()) {
|
|
131
131
|
const filesCreated = [];
|
|
132
132
|
const filesSkipped = [];
|
|
133
133
|
const filesToWrite = [
|
package/dist/index.js
CHANGED
|
@@ -49,14 +49,14 @@ if (firstArg && KNOWN_COMMANDS.includes(firstArg)) {
|
|
|
49
49
|
// The official tool surface is registered in main() before transport connection
|
|
50
50
|
// so the first MCP tools/list response is complete for hosts that ignore
|
|
51
51
|
// notifications/tools/list_changed.
|
|
52
|
-
const [{ McpServer }, { SERVER_INSTRUCTIONS }, {
|
|
52
|
+
const [{ McpServer }, { SERVER_INSTRUCTIONS }, { planuVersion }, { withToolTracking, getRegisteredTools },] = await Promise.all([
|
|
53
53
|
import('@modelcontextprotocol/sdk/server/mcp.js'),
|
|
54
54
|
import('./config/server-instructions.js'),
|
|
55
55
|
import('./config/version.js'),
|
|
56
56
|
import('./tools/tool-registry.js'),
|
|
57
57
|
]);
|
|
58
58
|
function createMcpServer() {
|
|
59
|
-
const s = withToolTracking(new McpServer({ name: 'planu', version:
|
|
59
|
+
const s = withToolTracking(new McpServer({ name: 'planu', version: planuVersion() }, {
|
|
60
60
|
instructions: SERVER_INSTRUCTIONS,
|
|
61
61
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
62
62
|
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// native/lightweight-command-catalog.ts — SPEC-1069 native/plugin-lite command surface.
|
|
2
|
-
import {
|
|
2
|
+
import { planuVersion } from '../config/version.js';
|
|
3
3
|
export const LIGHTWEIGHT_COMMANDS = [
|
|
4
4
|
{
|
|
5
5
|
id: 'planu.status',
|
|
@@ -68,7 +68,7 @@ export function getLightweightCommands(host) {
|
|
|
68
68
|
}
|
|
69
69
|
return LIGHTWEIGHT_COMMANDS.filter((command) => command.hosts.includes(host));
|
|
70
70
|
}
|
|
71
|
-
export function buildNativeSurfaceManifest(version =
|
|
71
|
+
export function buildNativeSurfaceManifest(version = planuVersion()) {
|
|
72
72
|
return {
|
|
73
73
|
name: 'dev.planu.native',
|
|
74
74
|
displayName: 'Planu Native Lightweight Surface',
|
|
@@ -80,6 +80,10 @@ export declare class RuntimeDatabaseResourceExhaustedError extends Error {
|
|
|
80
80
|
readonly maxConnections: number;
|
|
81
81
|
constructor(databasePath: string, maxConnections: number);
|
|
82
82
|
}
|
|
83
|
+
export declare class RuntimeSchemaAheadError extends Error {
|
|
84
|
+
readonly code: 'RUNTIME_SCHEMA_AHEAD';
|
|
85
|
+
constructor(storeSchema: number, supportedSchema: number);
|
|
86
|
+
}
|
|
83
87
|
/** A bounded (one connection), transactional SQLite runtime store. */
|
|
84
88
|
export declare class RuntimeDatabase implements Disposable {
|
|
85
89
|
readonly path: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { mkdirSync } from 'node:fs';
|
|
3
3
|
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
4
4
|
import { DatabaseSync } from 'node:sqlite';
|
|
5
|
+
import { planuVersion } from '../config/version.js';
|
|
5
6
|
import { DURABLE_JOB_STATES, } from '../types/durable-job.js';
|
|
6
7
|
import { parseValidationReceiptPendingCheckpoint, } from '../types/durable-validation.js';
|
|
7
8
|
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
@@ -72,6 +73,15 @@ export class RuntimeDatabaseResourceExhaustedError extends Error {
|
|
|
72
73
|
this.name = 'RuntimeDatabaseResourceExhaustedError';
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
export class RuntimeSchemaAheadError extends Error {
|
|
77
|
+
code = 'RUNTIME_SCHEMA_AHEAD';
|
|
78
|
+
constructor(storeSchema, supportedSchema) {
|
|
79
|
+
super(`[Planu] Runtime store schema ${String(storeSchema)} is newer than this server supports ` +
|
|
80
|
+
`(schema ${String(supportedSchema)}, Planu ${planuVersion()}). A newer Planu migrated it. ` +
|
|
81
|
+
`Restart the MCP server so it loads the current dist.`);
|
|
82
|
+
this.name = 'RuntimeSchemaAheadError';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
75
85
|
function requireIdentifier(value, label) {
|
|
76
86
|
if (!value || value.length > 128 || !/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(value)) {
|
|
77
87
|
throw new Error(`[Planu] Invalid ${label}`);
|
|
@@ -179,7 +189,7 @@ export class RuntimeDatabase {
|
|
|
179
189
|
migrate() {
|
|
180
190
|
const row = this.database.prepare('PRAGMA user_version').get();
|
|
181
191
|
if (row.user_version > CURRENT_SCHEMA_VERSION) {
|
|
182
|
-
throw new
|
|
192
|
+
throw new RuntimeSchemaAheadError(row.user_version, CURRENT_SCHEMA_VERSION);
|
|
183
193
|
}
|
|
184
194
|
if (row.user_version === 0) {
|
|
185
195
|
this.database.exec(`
|
|
@@ -230,14 +230,16 @@ export async function discoverCanonicalSpecPath(specId, canonicalRoot) {
|
|
|
230
230
|
* getSpec/listSpecs is otherwise doing. Best-effort: failure to persist never
|
|
231
231
|
* blocks the caller — the freshly parsed value is already what gets returned.
|
|
232
232
|
*/
|
|
233
|
-
async function persistDigestRefresh(projectId, specId, title, contentDigest) {
|
|
233
|
+
async function persistDigestRefresh(projectId, specId, title, specVersion, contentDigest) {
|
|
234
234
|
await withSpecMutationLock(projectId, async () => {
|
|
235
235
|
const specs = await loadAll(projectId);
|
|
236
236
|
const idx = specs.findIndex((s) => s.id === specId);
|
|
237
237
|
if (idx === -1) {
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
|
-
const nextSpecs = specs.map((current, currentIdx) => currentIdx === idx
|
|
240
|
+
const nextSpecs = specs.map((current, currentIdx) => currentIdx === idx
|
|
241
|
+
? { ...current, title, spec_version: specVersion, contentDigest }
|
|
242
|
+
: current);
|
|
241
243
|
await saveAll(projectId, nextSpecs);
|
|
242
244
|
});
|
|
243
245
|
}
|
|
@@ -281,8 +283,13 @@ async function refreshSpecFromDisk(projectId, spec, canonicalRoot) {
|
|
|
281
283
|
return spec;
|
|
282
284
|
}
|
|
283
285
|
const fields = readFrontmatterScalars(content);
|
|
284
|
-
const refreshed = {
|
|
285
|
-
|
|
286
|
+
const refreshed = {
|
|
287
|
+
...spec,
|
|
288
|
+
title: fields.title ?? spec.title,
|
|
289
|
+
spec_version: fields.spec_version ?? spec.spec_version,
|
|
290
|
+
contentDigest: digest,
|
|
291
|
+
};
|
|
292
|
+
await persistDigestRefresh(projectId, spec.id, refreshed.title, refreshed.spec_version, digest).catch((error) => {
|
|
286
293
|
reportClassifiedDegradation('SPEC_CONTENT_DIGEST_REFRESH_PERSIST', error);
|
|
287
294
|
});
|
|
288
295
|
return refreshed;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { readFile, writeFile, rename, mkdir, readdir } from 'node:fs/promises';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { reportClassifiedDegradation } from '../../errors/classified-degradation.js';
|
|
10
|
-
import {
|
|
10
|
+
import { planuVersion } from '../../config/version.js';
|
|
11
11
|
import { atomicStatusWrite } from './atomic-status-write.js';
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
// Helpers
|
|
@@ -134,7 +134,7 @@ export async function rebuildStatusFromFrontmatters(params) {
|
|
|
134
134
|
byStatus,
|
|
135
135
|
byType,
|
|
136
136
|
recentChanges: [],
|
|
137
|
-
version:
|
|
137
|
+
version: planuVersion(),
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
const specsDir = join(projectPath, 'planu', 'specs');
|
|
@@ -173,7 +173,7 @@ export async function rebuildStatusFromFrontmatters(params) {
|
|
|
173
173
|
byStatus: byStatusResult,
|
|
174
174
|
byType: byTypeResult,
|
|
175
175
|
recentChanges: [],
|
|
176
|
-
version:
|
|
176
|
+
version: planuVersion(),
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Ensures status.json.version always reflects the current runtime Planu version.
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
|
-
import {
|
|
5
|
+
import { planuVersion } from '../../config/version.js';
|
|
6
6
|
import { atomicStatusWrite } from './atomic-status-write.js';
|
|
7
7
|
import { withStatusLock } from './file-lock.js';
|
|
8
8
|
/**
|
|
@@ -36,13 +36,13 @@ export async function syncVersionField(statusPath, force = false) {
|
|
|
36
36
|
throw new Error(`Status file is corrupt: ${statusPath}`, { cause: error });
|
|
37
37
|
}
|
|
38
38
|
const currentVersion = typeof parsed.version === 'string' ? parsed.version : undefined;
|
|
39
|
-
if (currentVersion ===
|
|
39
|
+
if (currentVersion === planuVersion()) {
|
|
40
40
|
return { synced: false };
|
|
41
41
|
}
|
|
42
|
-
parsed.version =
|
|
42
|
+
parsed.version = planuVersion();
|
|
43
43
|
parsed.updatedAt = new Date().toISOString();
|
|
44
44
|
await atomicStatusWrite(statusPath, parsed);
|
|
45
|
-
return { synced: true, from: currentVersion, to:
|
|
45
|
+
return { synced: true, from: currentVersion, to: planuVersion() };
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
/** Clear the session sync cache — TEST USE ONLY. */
|
|
@@ -6,7 +6,7 @@ import { scanProject } from '../../engine/project-scanner/index.js';
|
|
|
6
6
|
import { isTelemetryEnabled, hasNeverBeenPrompted, markAsPrompted, sendTelemetryEvent, } from '../../engine/telemetry/index.js';
|
|
7
7
|
import { generateProjectRules, writeRules } from '../../engine/rules-generator/index.js';
|
|
8
8
|
import { getWhatsNew } from '../../engine/whats-new.js';
|
|
9
|
-
import {
|
|
9
|
+
import { planuVersion } from '../../config/version.js';
|
|
10
10
|
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
/** SPEC-192: Run health check and store convention baseline (best-effort). */
|
|
@@ -80,10 +80,10 @@ export async function checkWhatsNew(configPath) {
|
|
|
80
80
|
const lastSeen = typeof raw === 'object' && raw !== null && 'lastSeenVersion' in raw
|
|
81
81
|
? String(raw.lastSeenVersion)
|
|
82
82
|
: '0.0.0';
|
|
83
|
-
const result = getWhatsNew(lastSeen,
|
|
83
|
+
const result = getWhatsNew(lastSeen, planuVersion());
|
|
84
84
|
// Update lastSeenVersion in config (fire-and-forget)
|
|
85
|
-
if (result !== null || lastSeen !==
|
|
86
|
-
const updated = { ...raw, lastSeenVersion:
|
|
85
|
+
if (result !== null || lastSeen !== planuVersion()) {
|
|
86
|
+
const updated = { ...raw, lastSeenVersion: planuVersion() };
|
|
87
87
|
await writeFile(configPath, JSON.stringify(updated, null, 2) + '\n', 'utf-8');
|
|
88
88
|
}
|
|
89
89
|
return result;
|
|
@@ -3,7 +3,7 @@ import { runRollback } from '../engine/release/rollback-runner.js';
|
|
|
3
3
|
import { writePostmortem } from '../engine/release/postmortem-generator.js';
|
|
4
4
|
import { appendTransitionEvent } from '../storage/transition-log.js';
|
|
5
5
|
import { formatKeyValue } from './output-formatter.js';
|
|
6
|
-
import {
|
|
6
|
+
import { planuVersion } from '../config/version.js';
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// Age guard (30 days)
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
@@ -48,7 +48,7 @@ async function getPublishDate(packageName, version) {
|
|
|
48
48
|
async function runVerificationSmokeTest(version) {
|
|
49
49
|
const { spawn } = await import('node:child_process');
|
|
50
50
|
return new Promise((resolve) => {
|
|
51
|
-
const child = spawn('npx', ['--yes', `@planu/cli@${
|
|
51
|
+
const child = spawn('npx', ['--yes', `@planu/cli@${planuVersion()}`, '--version'], {
|
|
52
52
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
53
53
|
});
|
|
54
54
|
let output = '';
|
|
@@ -181,7 +181,7 @@ export async function handleRollbackRelease(input) {
|
|
|
181
181
|
}
|
|
182
182
|
if (smokeTest && !smokeTest.ok) {
|
|
183
183
|
additionalHints.push('rollback_smoke_failed — npm cache may still serve old tarball. ' +
|
|
184
|
-
`Users can run: npm cache clean --force && npx --yes @planu/cli@${
|
|
184
|
+
`Users can run: npm cache clean --force && npx --yes @planu/cli@${planuVersion()} --version`);
|
|
185
185
|
}
|
|
186
186
|
return {
|
|
187
187
|
content: [
|
|
@@ -16,7 +16,7 @@ import { recordToolTokens as recordLlmTokens } from '../engine/llm-runtime/index
|
|
|
16
16
|
import { guardToolResultOutput } from './output-integrity-guard.js';
|
|
17
17
|
// SPEC-902: Structured error contract
|
|
18
18
|
import { wrapError, isStructuredError } from '../engine/errors/error-wrapper.js';
|
|
19
|
-
import {
|
|
19
|
+
import { ensureErrorRecoveryRegistry } from '../engine/errors/registry-loader.js';
|
|
20
20
|
import { structuredErrorToResult } from '../engine/errors/error-result.js';
|
|
21
21
|
import { checkBudgetEnforcement } from '../engine/cost-guardrails.js';
|
|
22
22
|
import { existsSync } from 'node:fs';
|
|
@@ -551,7 +551,7 @@ function safeWithTelemetry(toolName, handler) {
|
|
|
551
551
|
reportToolError(toolName, error);
|
|
552
552
|
}
|
|
553
553
|
// SPEC-902: Structured error contract with recovery hints
|
|
554
|
-
const registry =
|
|
554
|
+
const registry = await ensureErrorRecoveryRegistry();
|
|
555
555
|
const structured = isStructuredError(error)
|
|
556
556
|
? error
|
|
557
557
|
: wrapError(error, { toolName: toolName ?? 'unknown', registry });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { compactResult } from './output-formatter.js';
|
|
5
|
-
import {
|
|
5
|
+
import { planuVersion } from '../config/version.js';
|
|
6
6
|
function toPluginId(name) {
|
|
7
7
|
return name
|
|
8
8
|
.toLowerCase()
|
|
@@ -33,7 +33,7 @@ function generateManifest(id, name, description, extensions) {
|
|
|
33
33
|
author: 'Your Name',
|
|
34
34
|
description,
|
|
35
35
|
license: 'MIT',
|
|
36
|
-
planuVersion: `>=${
|
|
36
|
+
planuVersion: `>=${planuVersion()}`,
|
|
37
37
|
entryPoint: 'src/index.js',
|
|
38
38
|
permissions,
|
|
39
39
|
};
|
|
@@ -219,7 +219,9 @@ async function readDisabledByConfig(projectPath) {
|
|
|
219
219
|
return Array.isArray(disabled) ? new Set(disabled) : new Set();
|
|
220
220
|
}
|
|
221
221
|
catch (error) {
|
|
222
|
-
|
|
222
|
+
if (error.code === 'ENOENT') {
|
|
223
|
+
return new Set();
|
|
224
|
+
}
|
|
223
225
|
reportClassifiedDegradation('CASCADE_CONFIG_UNAVAILABLE', error);
|
|
224
226
|
return new Set();
|
|
225
227
|
}
|
|
@@ -3,7 +3,7 @@ import { createServer } from 'node:http';
|
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { getRequestListener } from '@hono/node-server';
|
|
5
5
|
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
6
|
-
import {
|
|
6
|
+
import { planuVersion } from '../config/version.js';
|
|
7
7
|
import { runWithSessionContext } from './session-context.js';
|
|
8
8
|
import { checkHttpRateLimit } from './http-rate-limiter.js';
|
|
9
9
|
import { loadOAuthConfig, extractBearerToken, validateToken } from './oauth-validator.js';
|
|
@@ -47,12 +47,12 @@ function setCorsHeaders(res, corsOrigin) {
|
|
|
47
47
|
function handleHealth(res) {
|
|
48
48
|
setSecurityHeaders(res);
|
|
49
49
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
50
|
-
res.end(JSON.stringify({ status: 'ok', version:
|
|
50
|
+
res.end(JSON.stringify({ status: 'ok', version: planuVersion() }));
|
|
51
51
|
}
|
|
52
52
|
const SERVER_CARD = JSON.stringify({
|
|
53
53
|
serverInfo: {
|
|
54
54
|
name: 'planu',
|
|
55
|
-
version:
|
|
55
|
+
version: planuVersion(),
|
|
56
56
|
description: "Spec Driven Development MCP server — gives AI coding agents structured memory of what to build, how to build it, and how to verify it's done. 105 tools, any language, no API key required.",
|
|
57
57
|
homepage: 'https://planu.dev',
|
|
58
58
|
repository: 'https://github.com/planu-dev/planu',
|
|
@@ -60,7 +60,7 @@ const SERVER_CARD = JSON.stringify({
|
|
|
60
60
|
authentication: { required: false },
|
|
61
61
|
capabilities: { tools: true, resources: true, prompts: false },
|
|
62
62
|
installation: {
|
|
63
|
-
npm: `npx -y @planu/cli@${
|
|
63
|
+
npm: `npx -y @planu/cli@${planuVersion()}`,
|
|
64
64
|
docker: 'docker run -i --rm ghcr.io/planu-dev/planu',
|
|
65
65
|
},
|
|
66
66
|
});
|
|
@@ -142,6 +142,17 @@ async function drainPostCommitWorkOnShutdown() {
|
|
|
142
142
|
reportClassifiedDegradation('POST_COMMIT_DRAIN_TIMEOUT', new Error(`Shutdown drain exceeded ${String(POST_COMMIT_DRAIN_MS)}ms with ${String(drainResult.pendingCount)} pending`));
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
function createExitOnce() {
|
|
146
|
+
let exited = false;
|
|
147
|
+
return () => {
|
|
148
|
+
if (exited) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
exited = true;
|
|
152
|
+
signalDescendants('SIGKILL');
|
|
153
|
+
process.exit(0);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
145
156
|
function installStdioShutdownHandlers(server) {
|
|
146
157
|
let shuttingDown = false;
|
|
147
158
|
const handlers = new Map();
|
|
@@ -170,10 +181,9 @@ function installStdioShutdownHandlers(server) {
|
|
|
170
181
|
shuttingDown = true;
|
|
171
182
|
removeHandlers();
|
|
172
183
|
console.error(`[Planu] MCP stdio ${reason}; shutting down.`);
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}, 1_500);
|
|
184
|
+
const exitOnce = createExitOnce();
|
|
185
|
+
const hardStop = setTimeout(exitOnce, 1_500);
|
|
186
|
+
hardStop.unref();
|
|
177
187
|
void import('../tools/safe-handler.js')
|
|
178
188
|
.then(({ abortActiveToolExecutions }) => {
|
|
179
189
|
abortActiveToolExecutions(`MCP stdio ${reason}`);
|
|
@@ -195,8 +205,7 @@ function installStdioShutdownHandlers(server) {
|
|
|
195
205
|
})
|
|
196
206
|
.finally(() => {
|
|
197
207
|
clearTimeout(hardStop);
|
|
198
|
-
|
|
199
|
-
process.exit(0);
|
|
208
|
+
exitOnce();
|
|
200
209
|
});
|
|
201
210
|
};
|
|
202
211
|
const end = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planu/cli",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.11",
|
|
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,7 @@
|
|
|
47
47
|
"test": "vitest run --maxWorkers=6",
|
|
48
48
|
"test:watch": "vitest",
|
|
49
49
|
"test:coverage": "vitest run --coverage --testTimeout=60000 --maxWorkers=6",
|
|
50
|
+
"test:profile": "node scripts/test-profile.mjs",
|
|
50
51
|
"test:release-gate": "vitest run --exclude 'tests/integration/**'",
|
|
51
52
|
"test:pre-push-scripts": "PLANU_PRE_PUSH_SCRIPTS_LANE=1 vitest run tests/scripts --reporter=dot",
|
|
52
53
|
"test:integration": "vitest run tests/integration",
|
package/planu-plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "dev.planu.cli",
|
|
3
3
|
"displayName": "Planu — Spec Driven Development",
|
|
4
4
|
"description": "Manage software specs, estimations, and autonomous SDD workflows. Language-agnostic MCP server for Claude Code.",
|
|
5
|
-
"version": "5.7.
|
|
5
|
+
"version": "5.7.11",
|
|
6
6
|
"icon": "assets/plugin/icon.svg",
|
|
7
7
|
"command": ["npx", "@planu/cli@latest"],
|
|
8
8
|
"packageName": "@planu/cli",
|