@webpresso/agent-kit 0.28.0 → 0.29.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -3
- package/README.md +2 -2
- package/bin/_run.js +6 -0
- package/bin/wp +5 -0
- package/catalog/base-kit/.github/actions/setup-webpresso/action.yml.tmpl +21 -0
- package/catalog/base-kit/.github/workflows/{ci.webpresso.yml.tmpl → ci.yml.tmpl} +17 -7
- package/catalog/base-kit/tsconfig.json.tmpl +1 -1
- package/catalog/docs/templates/blueprint.yaml +1 -1
- package/dist/esm/audit/_budgets.d.ts +9 -1
- package/dist/esm/audit/_budgets.js +8 -1
- package/dist/esm/audit/blueprint-db-consistency.js +2 -2
- package/dist/esm/audit/blueprint-lifecycle-sql.d.ts +17 -7
- package/dist/esm/audit/blueprint-lifecycle-sql.js +298 -48
- package/dist/esm/audit/blueprint-readme-drift.d.ts +6 -0
- package/dist/esm/audit/blueprint-readme-drift.js +110 -0
- package/dist/esm/audit/no-first-party-mjs.js +5 -4
- package/dist/esm/audit/package-surface.js +79 -10
- package/dist/esm/audit/repo-guardrails.d.ts +1 -1
- package/dist/esm/audit/repo-guardrails.js +43 -3
- package/dist/esm/audit/tech-debt-cadence.js +2 -3
- package/dist/esm/audit/toolchain-isolation.js +2 -3
- package/dist/esm/blueprint/core/parser.js +3 -2
- package/dist/esm/blueprint/core/schema.d.ts +3 -2
- package/dist/esm/blueprint/core/schema.js +1 -1
- package/dist/esm/blueprint/cross-repo/audit.js +3 -4
- package/dist/esm/blueprint/db/cold-start.js +2 -3
- package/dist/esm/blueprint/db/enums.d.ts +1 -1
- package/dist/esm/blueprint/db/ephemeral-projection.d.ts +25 -0
- package/dist/esm/blueprint/db/ephemeral-projection.js +36 -0
- package/dist/esm/blueprint/db/gc.d.ts +11 -0
- package/dist/esm/blueprint/db/gc.js +55 -0
- package/dist/esm/blueprint/db/ingester.js +39 -1
- package/dist/esm/blueprint/db/migrations/run.js +5 -3
- package/dist/esm/blueprint/db/paths.d.ts +13 -24
- package/dist/esm/blueprint/db/paths.js +25 -33
- package/dist/esm/blueprint/execution/progress-bridge.js +5 -4
- package/dist/esm/blueprint/freshness.d.ts +2 -0
- package/dist/esm/blueprint/freshness.js +3 -1
- package/dist/esm/blueprint/lifecycle/audit.js +6 -6
- package/dist/esm/blueprint/lifecycle/engine.d.ts +1 -1
- package/dist/esm/blueprint/lifecycle/engine.js +13 -9
- package/dist/esm/blueprint/lifecycle/transition-matrix.d.ts +5 -0
- package/dist/esm/blueprint/lifecycle/transition-matrix.js +20 -0
- package/dist/esm/blueprint/markdown/helpers.d.ts +1 -1
- package/dist/esm/blueprint/projection-ready.js +2 -0
- package/dist/esm/blueprint/service/BlueprintService.js +1 -1
- package/dist/esm/blueprint/service/blueprint-records.js +1 -1
- package/dist/esm/blueprint/tracked-document/parser.js +1 -1
- package/dist/esm/blueprint/utils/archive.d.ts +2 -2
- package/dist/esm/blueprint/utils/archive.js +5 -2
- package/dist/esm/blueprint/utils/package-assets.d.ts +13 -0
- package/dist/esm/blueprint/utils/package-assets.js +38 -6
- package/dist/esm/build/normalize-tsconfig-json-exports.d.ts +13 -0
- package/dist/esm/build/normalize-tsconfig-json-exports.js +39 -0
- package/dist/esm/build/package-manifest.js +12 -4
- package/dist/esm/build/release-policy.d.ts +9 -18
- package/dist/esm/build/release-policy.js +10 -19
- package/dist/esm/build/runtime-surface-policy.d.ts +14 -0
- package/dist/esm/build/runtime-surface-policy.js +13 -0
- package/dist/esm/cli/commands/audit-core.d.ts +2 -2
- package/dist/esm/cli/commands/audit.js +7 -3
- package/dist/esm/cli/commands/blueprint/db-commands.js +0 -3
- package/dist/esm/cli/commands/blueprint/mutations.d.ts +3 -2
- package/dist/esm/cli/commands/blueprint/mutations.js +45 -39
- package/dist/esm/cli/commands/blueprint/router-output.js +2 -2
- package/dist/esm/cli/commands/doctor.d.ts +1 -1
- package/dist/esm/cli/commands/doctor.js +4 -5
- package/dist/esm/cli/commands/init/config.d.ts +6 -10
- package/dist/esm/cli/commands/init/config.js +36 -20
- package/dist/esm/cli/commands/init/gitignore-patcher.js +0 -1
- package/dist/esm/cli/commands/init/index.d.ts +8 -1
- package/dist/esm/cli/commands/init/index.js +17 -19
- package/dist/esm/cli/commands/init/package-root.d.ts +20 -0
- package/dist/esm/cli/commands/init/package-root.js +110 -0
- package/dist/esm/cli/commands/init/scaffold-base-kit.js +5 -1
- package/dist/esm/cli/commands/init/scaffolders/agent-hooks/index.d.ts +3 -0
- package/dist/esm/cli/commands/init/scaffolders/agent-hooks/index.js +8 -24
- package/dist/esm/cli/commands/init/scaffolders/agent-kit-global/index.d.ts +9 -0
- package/dist/esm/cli/commands/init/scaffolders/agent-kit-global/index.js +79 -1
- package/dist/esm/cli/commands/init/scaffolders/claude-rules/index.js +2 -12
- package/dist/esm/cli/commands/init/scaffolders/subagents/index.js +2 -12
- package/dist/esm/config/tsconfig/cloudflare.json +1 -1
- package/dist/esm/config/tsconfig/library.json +1 -1
- package/dist/esm/config/tsconfig/react-library.json +3 -2
- package/dist/esm/config/tsconfig/react-router.json +1 -1
- package/dist/esm/dev/restore-dev-links/index.js +3 -4
- package/dist/esm/docs-linter/blueprint-plan.js +46 -4
- package/dist/esm/hooks/check-dev-link/index.js +3 -4
- package/dist/esm/hooks/doctor.d.ts +11 -0
- package/dist/esm/hooks/doctor.js +174 -30
- package/dist/esm/hooks/guard-switch/index.js +3 -5
- package/dist/esm/hooks/post-tool/lint-after-edit.js +4 -5
- package/dist/esm/hooks/pretool-guard/index.js +2 -4
- package/dist/esm/hooks/pretool-guard/runner.js +2 -4
- package/dist/esm/hooks/pretool-guard/validators/forbidden-commands.js +47 -6
- package/dist/esm/hooks/sessionstart/index.js +3 -4
- package/dist/esm/hooks/shared/direct-entrypoint.d.ts +10 -0
- package/dist/esm/hooks/shared/direct-entrypoint.js +21 -0
- package/dist/esm/hooks/stop/qa-changed-files.js +3 -5
- package/dist/esm/hooks/test-quality-check.js +3 -4
- package/dist/esm/mcp/blueprint-server.js +26 -3
- package/dist/esm/mcp/cli.js +2 -6
- package/dist/esm/mcp/server.d.ts +2 -0
- package/dist/esm/mcp/server.js +18 -3
- package/dist/esm/mcp/tools/_shared/audit-kinds.d.ts +1 -1
- package/dist/esm/mcp/tools/_shared/audit-kinds.js +1 -0
- package/dist/esm/mcp/tools/audit.d.ts +2 -1
- package/dist/esm/mcp/tools/audit.js +13 -3
- package/dist/esm/package.json +2 -0
- package/package.json +24 -15
- package/tsconfig/cloudflare.json +1 -1
- package/tsconfig/library.json +1 -1
- package/tsconfig/react-library.json +3 -2
- package/tsconfig/react-router.json +1 -1
- package/dist/esm/blueprint/db/legacy-migration.d.ts +0 -41
- package/dist/esm/blueprint/db/legacy-migration.js +0 -122
package/dist/esm/mcp/server.js
CHANGED
|
@@ -16,14 +16,29 @@ import { COMPILED_TOOL_REGISTRY } from './tools/_registry.js';
|
|
|
16
16
|
import { readOwnedPackageVersion } from '#runtime/package-version.js';
|
|
17
17
|
const SERVER_NAME = 'webpresso';
|
|
18
18
|
const SERVER_VERSION = readOwnedPackageVersion(import.meta.url);
|
|
19
|
+
function modulePathFromUrl(moduleUrl) {
|
|
20
|
+
try {
|
|
21
|
+
return fileURLToPath(moduleUrl);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function isBunSingleFileModuleUrl(moduleUrl) {
|
|
28
|
+
const modulePath = modulePathFromUrl(moduleUrl);
|
|
29
|
+
return modulePath === '/$bunfs/root' || modulePath?.startsWith('/$bunfs/root/') === true;
|
|
30
|
+
}
|
|
19
31
|
function defaultToolsDir() {
|
|
20
32
|
// import.meta.url resolves to either src/mcp/server.ts (dev/test via vitest)
|
|
21
33
|
// or dist/esm/mcp/server.js (built). The tools directory is colocated.
|
|
22
|
-
const
|
|
34
|
+
const modulePath = modulePathFromUrl(import.meta.url);
|
|
35
|
+
const here = dirname(modulePath ?? fileURLToPath(import.meta.url));
|
|
23
36
|
return join(here, 'tools');
|
|
24
37
|
}
|
|
25
|
-
function resolveDefaultToolLoadMode() {
|
|
26
|
-
return process.env.WP_MCP_TOOL_MODE === 'registry' ||
|
|
38
|
+
export function resolveDefaultToolLoadMode(moduleUrl = import.meta.url) {
|
|
39
|
+
return process.env.WP_MCP_TOOL_MODE === 'registry' ||
|
|
40
|
+
process.env.WP_COMPILED_RUNTIME === '1' ||
|
|
41
|
+
isBunSingleFileModuleUrl(moduleUrl)
|
|
27
42
|
? 'registry'
|
|
28
43
|
: 'filesystem';
|
|
29
44
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* dependency-free module so the hook runtime, which runs on every tool call,
|
|
8
8
|
* doesn't pull in the whole audit tool graph.
|
|
9
9
|
*/
|
|
10
|
-
export declare const AUDIT_KINDS: readonly ["tph", "tph-e2e", "agents", "catalog-drift", "package-surface", "docs-frontmatter", "blueprint-lifecycle", "architecture-drift", "cloudflare-deploy-contract", "absolute-path-policy", "no-first-party-mjs", "roadmap-links", "bundle-budget", "commit-message", "tech-debt", "hook-surface", "ai-contracts", "no-relative-package-scripts", "toolchain-isolation"];
|
|
10
|
+
export declare const AUDIT_KINDS: readonly ["tph", "tph-e2e", "agents", "catalog-drift", "package-surface", "docs-frontmatter", "blueprint-readme-drift", "blueprint-lifecycle", "architecture-drift", "cloudflare-deploy-contract", "absolute-path-policy", "no-first-party-mjs", "roadmap-links", "bundle-budget", "commit-message", "tech-debt", "hook-surface", "ai-contracts", "no-relative-package-scripts", "toolchain-isolation"];
|
|
11
11
|
export type AuditKind = (typeof AUDIT_KINDS)[number];
|
|
12
12
|
export declare function isAuditKind(value: string): value is AuditKind;
|
|
13
13
|
//# sourceMappingURL=audit-kinds.d.ts.map
|
|
@@ -20,13 +20,14 @@ declare const inputSchema: z.ZodObject<{
|
|
|
20
20
|
kind: z.ZodEnum<{
|
|
21
21
|
"no-relative-package-scripts": "no-relative-package-scripts";
|
|
22
22
|
agents: "agents";
|
|
23
|
-
"hook-surface": "hook-surface";
|
|
24
23
|
"tech-debt": "tech-debt";
|
|
24
|
+
"hook-surface": "hook-surface";
|
|
25
25
|
tph: "tph";
|
|
26
26
|
"tph-e2e": "tph-e2e";
|
|
27
27
|
"catalog-drift": "catalog-drift";
|
|
28
28
|
"package-surface": "package-surface";
|
|
29
29
|
"docs-frontmatter": "docs-frontmatter";
|
|
30
|
+
"blueprint-readme-drift": "blueprint-readme-drift";
|
|
30
31
|
"blueprint-lifecycle": "blueprint-lifecycle";
|
|
31
32
|
"architecture-drift": "architecture-drift";
|
|
32
33
|
"cloudflare-deploy-contract": "cloudflare-deploy-contract";
|
|
@@ -119,9 +119,19 @@ async function dispatch(input) {
|
|
|
119
119
|
details: auditResult,
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
+
case 'blueprint-readme-drift': {
|
|
123
|
+
const { auditBlueprintReadmeDrift } = await import('#audit/blueprint-readme-drift');
|
|
124
|
+
const auditResult = auditBlueprintReadmeDrift(input.cwd ?? input.directory ?? process.cwd());
|
|
125
|
+
return {
|
|
126
|
+
passed: auditResult.ok,
|
|
127
|
+
summary: summarizeRepoAudit(kind, auditResult),
|
|
128
|
+
kind,
|
|
129
|
+
details: auditResult,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
122
132
|
case 'blueprint-lifecycle': {
|
|
123
|
-
const {
|
|
124
|
-
const auditResult =
|
|
133
|
+
const { auditBlueprintLifecycleSql } = await import('#audit/blueprint-lifecycle-sql');
|
|
134
|
+
const auditResult = await auditBlueprintLifecycleSql(input.cwd ?? input.directory ?? process.cwd());
|
|
125
135
|
return {
|
|
126
136
|
passed: auditResult.ok,
|
|
127
137
|
summary: summarizeRepoAudit(kind, auditResult),
|
|
@@ -307,7 +317,7 @@ async function dispatch(input) {
|
|
|
307
317
|
}
|
|
308
318
|
const tool = {
|
|
309
319
|
name: 'wp_audit',
|
|
310
|
-
description: 'Run a packaged repo audit. `kind` selects the audit (tph, tph-e2e, catalog-drift, docs-frontmatter, blueprint-lifecycle, architecture-drift, absolute-path-policy, no-first-party-mjs, roadmap-links, bundle-budget, commit-message, tech-debt, hook-surface, package-surface, no-relative-package-scripts). Returns {passed, kind, details}.',
|
|
320
|
+
description: 'Run a packaged repo audit. `kind` selects the audit (tph, tph-e2e, catalog-drift, docs-frontmatter, blueprint-readme-drift, blueprint-lifecycle, architecture-drift, absolute-path-policy, no-first-party-mjs, roadmap-links, bundle-budget, commit-message, tech-debt, hook-surface, package-surface, no-relative-package-scripts). Returns {passed, kind, details}.',
|
|
311
321
|
inputSchema,
|
|
312
322
|
outputSchema,
|
|
313
323
|
annotations: {
|
package/dist/esm/package.json
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"#dev/*": "./dev/*.js",
|
|
19
19
|
"#audit/*.js": "./audit/*.js",
|
|
20
20
|
"#audit/*": "./audit/*.js",
|
|
21
|
+
"#build/*.js": "./build/*.js",
|
|
22
|
+
"#build/*": "./build/*.js",
|
|
21
23
|
"#docs-linter/*.js": "./docs-linter/*.js",
|
|
22
24
|
"#docs-linter/*": "./docs-linter/*.js",
|
|
23
25
|
"#config/tsconfig/*.js": "./config/tsconfig/*",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpresso/agent-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"preferGlobal": true,
|
|
32
32
|
"bin": {
|
|
33
|
-
"wp": "bin/wp
|
|
33
|
+
"wp": "bin/wp",
|
|
34
34
|
"wp-pretool-guard": "bin/wp-pretool-guard.js",
|
|
35
35
|
"wp-post-tool": "bin/wp-post-tool.js",
|
|
36
36
|
"wp-stop-qa": "bin/wp-stop-qa.js",
|
|
@@ -46,8 +46,10 @@
|
|
|
46
46
|
"docs-migrate": "bin/docs-migrate.js"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
|
-
"bin",
|
|
50
|
-
"
|
|
49
|
+
"bin/wp",
|
|
50
|
+
"bin/runtime-manifest.json",
|
|
51
|
+
"bin/*.js",
|
|
52
|
+
"dist/esm",
|
|
51
53
|
"!dist/**/*.map",
|
|
52
54
|
"!dist/**/__integration__/**",
|
|
53
55
|
"!dist/**/__mocks__/**",
|
|
@@ -83,6 +85,8 @@
|
|
|
83
85
|
"#dev/*": "./src/dev/*.ts",
|
|
84
86
|
"#audit/*.js": "./src/audit/*.ts",
|
|
85
87
|
"#audit/*": "./src/audit/*.ts",
|
|
88
|
+
"#build/*.js": "./src/build/*.ts",
|
|
89
|
+
"#build/*": "./src/build/*.ts",
|
|
86
90
|
"#docs-linter/*.js": "./src/docs-linter/*.ts",
|
|
87
91
|
"#docs-linter/*": "./src/docs-linter/*.ts",
|
|
88
92
|
"#config/tsconfig/*.js": "./src/config/tsconfig/*",
|
|
@@ -242,31 +246,36 @@
|
|
|
242
246
|
"import": {
|
|
243
247
|
"types": "./dist/esm/config/tsconfig/base.json",
|
|
244
248
|
"default": "./dist/esm/config/tsconfig/base.json"
|
|
245
|
-
}
|
|
249
|
+
},
|
|
250
|
+
"default": "./dist/esm/config/tsconfig/base.json"
|
|
246
251
|
},
|
|
247
252
|
"./tsconfig/cloudflare.json": {
|
|
248
253
|
"import": {
|
|
249
254
|
"types": "./dist/esm/config/tsconfig/cloudflare.json",
|
|
250
255
|
"default": "./dist/esm/config/tsconfig/cloudflare.json"
|
|
251
|
-
}
|
|
256
|
+
},
|
|
257
|
+
"default": "./dist/esm/config/tsconfig/cloudflare.json"
|
|
252
258
|
},
|
|
253
259
|
"./tsconfig/library.json": {
|
|
254
260
|
"import": {
|
|
255
261
|
"types": "./dist/esm/config/tsconfig/library.json",
|
|
256
262
|
"default": "./dist/esm/config/tsconfig/library.json"
|
|
257
|
-
}
|
|
263
|
+
},
|
|
264
|
+
"default": "./dist/esm/config/tsconfig/library.json"
|
|
258
265
|
},
|
|
259
266
|
"./tsconfig/react-library.json": {
|
|
260
267
|
"import": {
|
|
261
268
|
"types": "./dist/esm/config/tsconfig/react-library.json",
|
|
262
269
|
"default": "./dist/esm/config/tsconfig/react-library.json"
|
|
263
|
-
}
|
|
270
|
+
},
|
|
271
|
+
"default": "./dist/esm/config/tsconfig/react-library.json"
|
|
264
272
|
},
|
|
265
273
|
"./tsconfig/react-router.json": {
|
|
266
274
|
"import": {
|
|
267
275
|
"types": "./dist/esm/config/tsconfig/react-router.json",
|
|
268
276
|
"default": "./dist/esm/config/tsconfig/react-router.json"
|
|
269
|
-
}
|
|
277
|
+
},
|
|
278
|
+
"default": "./dist/esm/config/tsconfig/react-router.json"
|
|
270
279
|
},
|
|
271
280
|
"./vitest/node": {
|
|
272
281
|
"import": {
|
|
@@ -535,7 +544,7 @@
|
|
|
535
544
|
},
|
|
536
545
|
"scripts": {
|
|
537
546
|
"setup:agent": "wp setup",
|
|
538
|
-
"build": "tshy && vp run chmod-bins && vp run link-self-bins",
|
|
547
|
+
"build": "tshy && bun src/build/normalize-tsconfig-json-exports.ts && vp run chmod-bins && vp run link-self-bins",
|
|
539
548
|
"build:runtime-binaries": "bun scripts/build-runtime-binaries.ts",
|
|
540
549
|
"stage:plugin-runtime": "bun scripts/stage-plugin-runtime-artifacts.ts",
|
|
541
550
|
"postbuild": "vp run generate-skills && vp run sync-doc-templates",
|
|
@@ -710,10 +719,10 @@
|
|
|
710
719
|
"@stryker-mutator/typescript-checker": "^9.6.1",
|
|
711
720
|
"@playwright/test": "^1.55.0",
|
|
712
721
|
"wrangler": "^4.50.0",
|
|
713
|
-
"@webpresso/agent-kit-runtime-darwin-arm64": "0.
|
|
714
|
-
"@webpresso/agent-kit-runtime-darwin-x64": "0.
|
|
715
|
-
"@webpresso/agent-kit-runtime-linux-x64": "0.
|
|
716
|
-
"@webpresso/agent-kit-runtime-linux-arm64": "0.
|
|
717
|
-
"@webpresso/agent-kit-runtime-windows-x64": "0.
|
|
722
|
+
"@webpresso/agent-kit-runtime-darwin-arm64": "0.29.1",
|
|
723
|
+
"@webpresso/agent-kit-runtime-darwin-x64": "0.29.1",
|
|
724
|
+
"@webpresso/agent-kit-runtime-linux-x64": "0.29.1",
|
|
725
|
+
"@webpresso/agent-kit-runtime-linux-arm64": "0.29.1",
|
|
726
|
+
"@webpresso/agent-kit-runtime-windows-x64": "0.29.1"
|
|
718
727
|
}
|
|
719
728
|
}
|
package/tsconfig/cloudflare.json
CHANGED
package/tsconfig/library.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
3
|
"display": "React Library",
|
|
4
|
-
"extends": "
|
|
4
|
+
"extends": "@webpresso/agent-kit/tsconfig/library.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
6
|
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
|
7
|
-
"jsx": "react-jsx"
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"types": ["react", "react-dom"]
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
3
|
"display": "React Router v7",
|
|
4
|
-
"extends": "
|
|
4
|
+
"extends": "@webpresso/agent-kit/tsconfig/react-library.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
6
|
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
|
7
7
|
"jsx": "react-jsx",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Legacy DB deprecation + migration (F12 / R10 / E12, Task 1.1).
|
|
3
|
-
*
|
|
4
|
-
* Pre-worktree-scoping, the projection DB lived at
|
|
5
|
-
* `<cwd>/.agent/.blueprints.db`. Task 1.1 moves it under the worktree-scoped
|
|
6
|
-
* state-root path. For git repos that still have the legacy file (and any
|
|
7
|
-
* sibling `-wal` / `-shm` files from a crashed write), do the following on
|
|
8
|
-
* first access:
|
|
9
|
-
*
|
|
10
|
-
* 1. Log a one-line deprecation pointing at the new path.
|
|
11
|
-
* 2. If the destination does not exist, rename the legacy files to the new
|
|
12
|
-
* location. Sibling WAL/SHM are moved alongside the main DB.
|
|
13
|
-
* 3. If the destination already exists, leave both untouched and surface a
|
|
14
|
-
* failure-style warning. Callers should not double-count.
|
|
15
|
-
*
|
|
16
|
-
* Memoized per-repo so repeated calls within a process touch disk once.
|
|
17
|
-
*/
|
|
18
|
-
export declare const LEGACY_DB_SIBLINGS: readonly ["-wal", "-shm"];
|
|
19
|
-
export type MigrationOutcome = 'migrated' | 'destination-exists' | 'no-legacy' | 'not-git';
|
|
20
|
-
export interface MigrationResult {
|
|
21
|
-
readonly outcome: MigrationOutcome;
|
|
22
|
-
readonly legacyPath: string;
|
|
23
|
-
readonly destinationPath: string | null;
|
|
24
|
-
readonly movedSiblings: readonly string[];
|
|
25
|
-
readonly warning: string | null;
|
|
26
|
-
}
|
|
27
|
-
interface Logger {
|
|
28
|
-
warn(msg: string): void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Detect and (if safe) migrate a legacy `.agent/.blueprints.db` for `cwd`.
|
|
32
|
-
*
|
|
33
|
-
* Idempotent and memoized per `cwd`. Outside a git repo the function is a
|
|
34
|
-
* no-op (returns `outcome: 'not-git'`) because the legacy path *is* the
|
|
35
|
-
* canonical path in that case.
|
|
36
|
-
*/
|
|
37
|
-
export declare function migrateLegacyAgentDb(cwd: string, logger?: Logger): MigrationResult;
|
|
38
|
-
/** Test-only helper. */
|
|
39
|
-
export declare function _clearMigrationMemoForTests(): void;
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=legacy-migration.d.ts.map
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Legacy DB deprecation + migration (F12 / R10 / E12, Task 1.1).
|
|
3
|
-
*
|
|
4
|
-
* Pre-worktree-scoping, the projection DB lived at
|
|
5
|
-
* `<cwd>/.agent/.blueprints.db`. Task 1.1 moves it under the worktree-scoped
|
|
6
|
-
* state-root path. For git repos that still have the legacy file (and any
|
|
7
|
-
* sibling `-wal` / `-shm` files from a crashed write), do the following on
|
|
8
|
-
* first access:
|
|
9
|
-
*
|
|
10
|
-
* 1. Log a one-line deprecation pointing at the new path.
|
|
11
|
-
* 2. If the destination does not exist, rename the legacy files to the new
|
|
12
|
-
* location. Sibling WAL/SHM are moved alongside the main DB.
|
|
13
|
-
* 3. If the destination already exists, leave both untouched and surface a
|
|
14
|
-
* failure-style warning. Callers should not double-count.
|
|
15
|
-
*
|
|
16
|
-
* Memoized per-repo so repeated calls within a process touch disk once.
|
|
17
|
-
*/
|
|
18
|
-
import { existsSync, mkdirSync, renameSync } from 'node:fs';
|
|
19
|
-
import path from 'node:path';
|
|
20
|
-
import { LEGACY_AGENT_DIR, LEGACY_DB_FILENAME } from './paths.js';
|
|
21
|
-
import { getSurfacePath, NotInGitRepoError } from '#paths/state-root.js';
|
|
22
|
-
export const LEGACY_DB_SIBLINGS = ['-wal', '-shm'];
|
|
23
|
-
const defaultLogger = {
|
|
24
|
-
warn(msg) {
|
|
25
|
-
process.stderr.write(`${msg}\n`);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const memo = new Map();
|
|
29
|
-
function legacyDbPath(cwd) {
|
|
30
|
-
return path.join(cwd, LEGACY_AGENT_DIR, LEGACY_DB_FILENAME);
|
|
31
|
-
}
|
|
32
|
-
function moveOne(from, to) {
|
|
33
|
-
if (!existsSync(from))
|
|
34
|
-
return false;
|
|
35
|
-
renameSync(from, to);
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
function tryResolveDestination(cwd) {
|
|
39
|
-
// Call getSurfacePath directly (not resolveBlueprintProjectionDbPath) so
|
|
40
|
-
// we can distinguish "git repo, real worktree-scoped destination" from
|
|
41
|
-
// "non-git repo, legacy path IS canonical". The latter must not be treated
|
|
42
|
-
// as a migration target.
|
|
43
|
-
try {
|
|
44
|
-
return getSurfacePath('blueprints/blueprints.db', 'worktree', cwd);
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
if (err instanceof NotInGitRepoError)
|
|
48
|
-
return null;
|
|
49
|
-
throw err;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Detect and (if safe) migrate a legacy `.agent/.blueprints.db` for `cwd`.
|
|
54
|
-
*
|
|
55
|
-
* Idempotent and memoized per `cwd`. Outside a git repo the function is a
|
|
56
|
-
* no-op (returns `outcome: 'not-git'`) because the legacy path *is* the
|
|
57
|
-
* canonical path in that case.
|
|
58
|
-
*/
|
|
59
|
-
export function migrateLegacyAgentDb(cwd, logger = defaultLogger) {
|
|
60
|
-
const cached = memo.get(cwd);
|
|
61
|
-
if (cached !== undefined)
|
|
62
|
-
return cached;
|
|
63
|
-
const legacy = legacyDbPath(cwd);
|
|
64
|
-
const result = computeMigration(cwd, legacy, logger);
|
|
65
|
-
memo.set(cwd, result);
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
function computeMigration(cwd, legacy, logger) {
|
|
69
|
-
if (!existsSync(legacy)) {
|
|
70
|
-
return {
|
|
71
|
-
outcome: 'no-legacy',
|
|
72
|
-
legacyPath: legacy,
|
|
73
|
-
destinationPath: null,
|
|
74
|
-
movedSiblings: [],
|
|
75
|
-
warning: null,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const destination = tryResolveDestination(cwd);
|
|
79
|
-
if (destination === null) {
|
|
80
|
-
// Non-git: legacy path IS canonical; nothing to migrate.
|
|
81
|
-
return {
|
|
82
|
-
outcome: 'not-git',
|
|
83
|
-
legacyPath: legacy,
|
|
84
|
-
destinationPath: null,
|
|
85
|
-
movedSiblings: [],
|
|
86
|
-
warning: null,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (existsSync(destination)) {
|
|
90
|
-
const warning = `[blueprint] WARNING: legacy DB ${legacy} found but worktree DB already exists at ${destination}; leaving both untouched. Delete the legacy file once you have verified the new DB is current.`;
|
|
91
|
-
logger.warn(warning);
|
|
92
|
-
return {
|
|
93
|
-
outcome: 'destination-exists',
|
|
94
|
-
legacyPath: legacy,
|
|
95
|
-
destinationPath: destination,
|
|
96
|
-
movedSiblings: [],
|
|
97
|
-
warning,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
logger.warn(`[blueprint] deprecated: ${legacy} → ${destination} (migrating; legacy .agent/.blueprints.db will be removed)`);
|
|
101
|
-
// Ensure the destination directory exists before renames.
|
|
102
|
-
mkdirSync(path.dirname(destination), { recursive: true });
|
|
103
|
-
moveOne(legacy, destination);
|
|
104
|
-
const movedSiblings = [];
|
|
105
|
-
for (const suffix of LEGACY_DB_SIBLINGS) {
|
|
106
|
-
const moved = moveOne(`${legacy}${suffix}`, `${destination}${suffix}`);
|
|
107
|
-
if (moved)
|
|
108
|
-
movedSiblings.push(suffix);
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
outcome: 'migrated',
|
|
112
|
-
legacyPath: legacy,
|
|
113
|
-
destinationPath: destination,
|
|
114
|
-
movedSiblings,
|
|
115
|
-
warning: null,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/** Test-only helper. */
|
|
119
|
-
export function _clearMigrationMemoForTests() {
|
|
120
|
-
memo.clear();
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=legacy-migration.js.map
|