@vmz/vmz 0.0.2 → 0.0.3

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.
Files changed (65) hide show
  1. package/README.md +13 -9
  2. package/dist/application-cmd.d.ts +1 -2
  3. package/dist/application-cmd.js +9 -10
  4. package/dist/bundler-adapter.d.ts +2 -3
  5. package/dist/bundler-adapter.js +2 -3
  6. package/dist/cli.d.ts +10 -2
  7. package/dist/cli.js +119 -15
  8. package/dist/dev-session.d.ts +2 -2
  9. package/dist/dev-session.js +3 -3
  10. package/dist/document-build.js +1 -2
  11. package/dist/document-check.d.ts +1 -1
  12. package/dist/document-check.js +4 -4
  13. package/dist/document-cmd.d.ts +1 -2
  14. package/dist/document-cmd.js +2 -3
  15. package/dist/document-designs.js +1 -1
  16. package/dist/document-enrich.js +2 -3
  17. package/dist/document-evidence.d.ts +4 -4
  18. package/dist/document-evidence.js +20 -12
  19. package/dist/document-integrate.d.ts +0 -1
  20. package/dist/document-integrate.js +0 -1
  21. package/dist/document-interactive.d.ts +11 -11
  22. package/dist/document-interactive.js +12 -13
  23. package/dist/document-locale.d.ts +1 -1
  24. package/dist/document-locale.js +1 -1
  25. package/dist/document-markdown.d.ts +1 -2
  26. package/dist/document-markdown.js +13 -7
  27. package/dist/document-scan.d.ts +4 -4
  28. package/dist/document-scan.js +4 -4
  29. package/dist/document-schema.d.ts +28 -29
  30. package/dist/document-schema.js +28 -29
  31. package/dist/explain-cmd.js +3 -3
  32. package/dist/index.d.ts +340 -789
  33. package/dist/index.js +91 -80
  34. package/dist/invocation.d.ts +91 -0
  35. package/dist/invocation.js +190 -0
  36. package/dist/locale-check.d.ts +3 -3
  37. package/dist/locale-check.js +5 -6
  38. package/dist/locale-cmd.js +6 -7
  39. package/dist/locale-delivery.d.ts +38 -38
  40. package/dist/locale-delivery.js +39 -40
  41. package/dist/locale-router.d.ts +39 -40
  42. package/dist/locale-router.js +39 -40
  43. package/dist/locale-runtime.d.ts +39 -39
  44. package/dist/locale-runtime.js +44 -45
  45. package/dist/locale-schema.d.ts +1 -2
  46. package/dist/locale-schema.js +1 -2
  47. package/dist/locale-tooling.d.ts +13 -13
  48. package/dist/locale-tooling.js +14 -15
  49. package/dist/log.d.ts +1 -1
  50. package/dist/log.js +1 -1
  51. package/dist/packages.d.ts +1 -2
  52. package/dist/packages.js +1 -2
  53. package/dist/plugin-host.d.ts +1 -2
  54. package/dist/plugin-host.js +2 -3
  55. package/dist/refactor-cmd.d.ts +1 -1
  56. package/dist/refactor-cmd.js +6 -6
  57. package/dist/resolve-native-cli.d.ts +14 -0
  58. package/dist/resolve-native-cli.js +84 -0
  59. package/dist/resolve.d.ts +1 -2
  60. package/dist/resolve.js +1 -2
  61. package/dist/test-cmd.d.ts +2 -2
  62. package/dist/test-cmd.js +37 -17
  63. package/dist/watch-diff.d.ts +1 -1
  64. package/dist/watch-diff.js +1 -1
  65. package/package.json +31 -16
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * `vmz refactor` — X1 RouteId/field safe rename (plan + atomic apply).
3
+ * `vmz refactor` — RouteId/field safe rename (plan + atomic apply).
4
4
  */
5
5
  import { createWorkspace } from './index.js';
6
6
  import { log } from './log.js';
@@ -23,7 +23,7 @@ export async function cmdRefactor(argv) {
23
23
  return 1;
24
24
  }
25
25
  function printRefactorHelp() {
26
- console.log(`vmz refactor — workspace edit plans (X1)
26
+ console.log(`vmz refactor — workspace edit plans
27
27
 
28
28
  Usage:
29
29
  vmz refactor rename --kind <route_id|field|method|component|capability> --from <id> --to <id> [path]
@@ -136,16 +136,16 @@ function cmdRename(argv) {
136
136
  else {
137
137
  log.info(`rename ${kind} \`${from}\` → \`${to}\` → ${plan.status}`);
138
138
  for (const p of plan.preconditions || []) {
139
- console.log(` precondition: ${p}`);
139
+ console.log(` precondition: ${p}`);
140
140
  }
141
141
  for (const e of plan.edits || []) {
142
- console.log(` edit ${e.path} @${e.start}..${e.end} → ${JSON.stringify(e.newText)}`);
142
+ console.log(` edit ${e.path} @${e.start}..${e.end} → ${JSON.stringify(e.newText)}`);
143
143
  }
144
144
  for (const d of plan.diagnostics || []) {
145
- console.log(` ${d.severity || 'info'}: ${d.message}`);
145
+ console.log(` ${d.severity || 'info'}: ${d.message}`);
146
146
  }
147
147
  if ((plan.edits || []).length === 0) {
148
- console.log(' edits: (none)');
148
+ console.log(' edits: (none)');
149
149
  }
150
150
  }
151
151
  return plan.status === 'rejected' ? 1 : 0;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Resolve the native `vmz` CLI binary (vmz-tools), never the Node wrapper.
3
+ * Used by `vmz lsp` / `vmz mcp` so stdio servers stay one binary for all hosts.
4
+ */
5
+ /**
6
+ * @param {string} [startDir]
7
+ * @returns {string | null}
8
+ */
9
+ export declare function findRepoRoot(startDir?: string): string;
10
+ /**
11
+ * @param {{ cwd?: string }} [opts]
12
+ * @returns {string | null} absolute path to native vmz binary
13
+ */
14
+ export declare function resolveNativeVmzCli(opts?: {}): any;
@@ -0,0 +1,84 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Resolve the native `vmz` CLI binary (vmz-tools), never the Node wrapper.
4
+ * Used by `vmz lsp` / `vmz mcp` so stdio servers stay one binary for all hosts.
5
+ */
6
+ import { existsSync, statSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ const exe = process.platform === 'win32' ? 'vmz.exe' : 'vmz';
10
+ /**
11
+ * @param {string} [startDir]
12
+ * @returns {string | null}
13
+ */
14
+ export function findRepoRoot(startDir = process.cwd()) {
15
+ let dir = path.resolve(startDir);
16
+ for (let i = 0; i < 12; i++) {
17
+ if (existsSync(path.join(dir, 'Cargo.toml')) && existsSync(path.join(dir, 'package.json'))) {
18
+ return dir;
19
+ }
20
+ const parent = path.dirname(dir);
21
+ if (parent === dir)
22
+ break;
23
+ dir = parent;
24
+ }
25
+ return null;
26
+ }
27
+ /**
28
+ * Prefer the newer of release/debug so a fresh `cargo build` is not shadowed by a stale release.
29
+ * @param {string} repo
30
+ * @returns {string | null}
31
+ */
32
+ function pickNewestProfileBinary(repo) {
33
+ /** @type {{ path: string, mtime: number } | null} */
34
+ let best = null;
35
+ for (const profile of ['release', 'debug']) {
36
+ const candidate = path.join(repo, 'target', profile, exe);
37
+ if (!existsSync(candidate))
38
+ continue;
39
+ let mtime = 0;
40
+ try {
41
+ mtime = statSync(candidate).mtimeMs;
42
+ }
43
+ catch {
44
+ continue;
45
+ }
46
+ if (!best || mtime > best.mtime)
47
+ best = { path: candidate, mtime };
48
+ }
49
+ return best?.path ?? null;
50
+ }
51
+ /**
52
+ * @param {{ cwd?: string }} [opts]
53
+ * @returns {string | null} absolute path to native vmz binary
54
+ */
55
+ export function resolveNativeVmzCli(opts = {}) {
56
+ if (typeof process.env.VMZ_NATIVE === 'string' && process.env.VMZ_NATIVE.trim()) {
57
+ const p = path.resolve(process.env.VMZ_NATIVE.trim());
58
+ if (existsSync(p))
59
+ return p;
60
+ }
61
+ const roots = [];
62
+ if (opts.cwd)
63
+ roots.push(path.resolve(opts.cwd));
64
+ roots.push(process.cwd());
65
+ try {
66
+ const here = path.dirname(fileURLToPath(import.meta.url));
67
+ // packages/runtimes/vmz/dist → repo root
68
+ roots.push(path.resolve(here, '../../../..'));
69
+ }
70
+ catch {
71
+ /* ignore */
72
+ }
73
+ const seen = new Set();
74
+ for (const start of roots) {
75
+ const repo = findRepoRoot(start);
76
+ if (!repo || seen.has(repo))
77
+ continue;
78
+ seen.add(repo);
79
+ const picked = pickNewestProfileBinary(repo);
80
+ if (picked)
81
+ return picked;
82
+ }
83
+ return null;
84
+ }
package/dist/resolve.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Shared project path resolution for the Node CLI host (N2).
3
- * Design: `规划设计/vmz/14-Node-NAPI与插件宿主.md`
2
+ * Shared project path resolution for the Node CLI host .
4
3
  */
5
4
  /**
6
5
  * @param {string} startDir
package/dist/resolve.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * Shared project path resolution for the Node CLI host (N2).
4
- * Design: `规划设计/vmz/14-Node-NAPI与插件宿主.md`
3
+ * Shared project path resolution for the Node CLI host .
5
4
  */
6
5
  import { existsSync, readFileSync } from 'node:fs';
7
6
  import path from 'node:path';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * `vmz test` command 鈥?discovery / build / filter / TestReport orchestration.
3
- * Semantics live in `@vmz/test`.
2
+ * `vmz test` command discovery / build / filter / TestReport orchestration.
3
+ * Semantics live in `@vmz/test` (optional peer — not installed with bare `@vmz/vmz`).
4
4
  */
5
5
  /**
6
6
  * @param {Record<string, string | boolean> & { _: string[] }} args
package/dist/test-cmd.js CHANGED
@@ -1,17 +1,37 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * `vmz test` command 鈥?discovery / build / filter / TestReport orchestration.
4
- * Semantics live in `@vmz/test`.
3
+ * `vmz test` command discovery / build / filter / TestReport orchestration.
4
+ * Semantics live in `@vmz/test` (optional peer — not installed with bare `@vmz/vmz`).
5
5
  */
6
6
  import path from 'node:path';
7
- import { discoverTestManifests, buildTestReport, parseModes, buildForCompile, runCompileManifest, runLogicManifest, runSsrManifest, runResumeManifest, runBrowserManifest, runDeploymentManifest, } from '@vmz/test';
8
7
  import { createWorkspace } from './index.js';
9
8
  import { log } from './log.js';
9
+ /**
10
+ * @returns {Promise<typeof import('@vmz/test')>}
11
+ */
12
+ async function loadTestPackage() {
13
+ try {
14
+ return await import('@vmz/test');
15
+ }
16
+ catch (e) {
17
+ const detail = e instanceof Error ? e.message : String(e);
18
+ throw new Error('`vmz test` needs `@vmz/test` (optional peer of `@vmz/vmz`).\n' + ' Install: pnpm add -D @vmz/test\n' + ` Detail: ${detail}`);
19
+ }
20
+ }
10
21
  /**
11
22
  * @param {Record<string, string | boolean> & { _: string[] }} args
12
23
  * @returns {Promise<number>}
13
24
  */
14
25
  export async function cmdTest(args) {
26
+ let test;
27
+ try {
28
+ test = await loadTestPackage();
29
+ }
30
+ catch (e) {
31
+ log.error(e instanceof Error ? e.message : String(e));
32
+ return 1;
33
+ }
34
+ const { discoverTestManifests, buildTestReport, parseModes, buildForCompile, runCompileManifest, runLogicManifest, runSsrManifest, runResumeManifest, runBrowserManifest, runDeploymentManifest, } = test;
15
35
  const project = path.resolve(String(args._[0] || '.'));
16
36
  let modes;
17
37
  try {
@@ -74,7 +94,7 @@ export async function cmdTest(args) {
74
94
  const ws = createWorkspace({ root: project, outDir });
75
95
  try {
76
96
  if (typeof ws.selectTestsAffected !== 'function') {
77
- log.error('selectTestsAffected missing on Workspace 鈥?rebuild native (`pnpm napi:build`)');
97
+ log.error('selectTestsAffected missing on Workspace rebuild native (`pnpm napi:build`)');
78
98
  return 1;
79
99
  }
80
100
  const raw = ws.selectTestsAffected();
@@ -85,14 +105,14 @@ export async function cmdTest(args) {
85
105
  log.error(`test selection not JSON: ${e}`);
86
106
  return 1;
87
107
  }
88
- log.info(`affected selection: ${testSelection.status} 鈥?${testSelection.reason} (chunks=${(testSelection.affectedChunkIds || []).length})`);
108
+ log.info(`affected selection: ${testSelection.status} — ${testSelection.reason} (chunks=${(testSelection.affectedChunkIds || []).length})`);
89
109
  const ids = new Set((testSelection.testIds || []).map(String));
90
110
  const chunks = new Set((testSelection.affectedChunkIds || []).map(String));
91
111
  if (ids.size > 0) {
92
112
  selected = selected.filter((m) => ids.has(String(m.id || '')));
93
113
  }
94
114
  else if (chunks.size > 0) {
95
- // Scaffold fallback: match manifest program.chunkId until graph鈫抰est edges exist.
115
+ // Scaffold fallback: match manifest program.chunkId until graph->test edges exist.
96
116
  selected = selected.filter((m) => {
97
117
  const program = m.program && typeof m.program === 'object' ? m.program : {};
98
118
  const chunk = program.chunkId ? String(program.chunkId) : '';
@@ -115,13 +135,13 @@ export async function cmdTest(args) {
115
135
  selected = selected.filter((m) => Array.isArray(m.modes) && m.modes.some((x) => modes.includes(x)));
116
136
  }
117
137
  /** @type {Array<{
118
- * testId: string,
119
- * file: string,
120
- * modes: string[],
121
- * programId: string|null,
122
- * planId: string|null,
123
- * status: string,
124
- * diagnostics: unknown[],
138
+ * testId: string,
139
+ * file: string,
140
+ * modes: string[],
141
+ * programId: string|null,
142
+ * planId: string|null,
143
+ * status: string,
144
+ * diagnostics: unknown[],
125
145
  * }>} */
126
146
  let tests;
127
147
  if (wantList) {
@@ -288,7 +308,7 @@ export async function cmdTest(args) {
288
308
  else {
289
309
  console.log(`vmz test: ${tests.length} test(s) under ${project}`);
290
310
  for (const t of tests) {
291
- console.log(` ${t.testId}\t${t.file}\t[${t.modes.join(',')}]`);
311
+ console.log(` ${t.testId}\t${t.file}\t[${t.modes.join(',')}]`);
292
312
  }
293
313
  }
294
314
  if (errors.length) {
@@ -316,10 +336,10 @@ export async function cmdTest(args) {
316
336
  }
317
337
  console.log(`vmz test: ${tests.length} test(s) — ${reportStatus}`);
318
338
  for (const t of tests) {
319
- console.log(` ${t.status}\t${t.testId}\t${t.file}`);
339
+ console.log(` ${t.status}\t${t.testId}\t${t.file}`);
320
340
  for (const d of t.diagnostics || []) {
321
341
  if (d && typeof d === 'object' && d.severity === 'error') {
322
- console.log(` ! ${d.message}`);
342
+ console.log(` ! ${d.message}`);
323
343
  if (process.env.GITHUB_ACTIONS === 'true') {
324
344
  const msg = String(d.message || 'error').replace(/[\r\n]+/g, ' ');
325
345
  console.log(`::error title=vmz test ${t.testId}::${msg}`);
@@ -333,7 +353,7 @@ export async function cmdTest(args) {
333
353
  }
334
354
  }
335
355
  if (tests.length === 0) {
336
- console.log(' (add *.vmz.test.json manifests)');
356
+ console.log(' (add *.vmz.test.json manifests)');
337
357
  }
338
358
  if (errors.length)
339
359
  return 2;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Track per-file fingerprints so dev rebuilds only dirty leaves (N4).
2
+ * Track per-file fingerprints so dev rebuilds only dirty leaves (session).
3
3
  */
4
4
  /**
5
5
  * @param {string} srcDir
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * Track per-file fingerprints so dev rebuilds only dirty leaves (N4).
3
+ * Track per-file fingerprints so dev rebuilds only dirty leaves (session).
4
4
  */
5
5
  import { existsSync, readdirSync, statSync } from 'node:fs';
6
6
  import path from 'node:path';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vmz/vmz",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "VMZ Node toolchain — N-API workspace session + CLI",
6
6
  "license": "MIT",
@@ -48,25 +48,40 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@vmz/plugin": "0.0.2",
52
- "@vmz/plugin-markdown-it": "0.0.2",
53
- "@vmz/protocol": "0.0.2",
54
- "@vmz/test": "0.0.2",
51
+ "@vmz/core": "0.0.3",
52
+ "@vmz/plugin": "0.0.3",
53
+ "@vmz/protocol": "0.0.3",
55
54
  "jiti": "^2.6.1",
56
- "json5": "^2.2.3",
55
+ "json5": "^2.2.3"
56
+ },
57
+ "peerDependencies": {
58
+ "@vmz/plugin-markdown-it": "0.0.3",
59
+ "@vmz/test": "0.0.3",
57
60
  "typescript": "^5.8.3"
58
61
  },
62
+ "peerDependenciesMeta": {
63
+ "@vmz/plugin-markdown-it": {
64
+ "optional": true
65
+ },
66
+ "@vmz/test": {
67
+ "optional": true
68
+ },
69
+ "typescript": {
70
+ "optional": true
71
+ }
72
+ },
59
73
  "files": [
60
74
  "bin",
61
75
  "dist",
62
- "*.node",
63
76
  "README.md"
64
77
  ],
65
78
  "scripts": {
66
- "build:native": "node ../../../scripts/build-napi.mjs",
79
+ "build:native": "node ../../../scripts/build/napi.mjs",
67
80
  "build": "pnpm run build:native && pnpm run build:js",
68
- "test": "node ./tests/run-node-tests.mjs",
69
- "build:js": "tsc -p tsconfig.json && node ../../../scripts/copy-vmz-public-api.mjs"
81
+ "test": "node --experimental-strip-types ./tests/run-node-tests.ts",
82
+ "verify": "node --import ../../../scripts/test/resolve-ts-from-js.mjs --experimental-strip-types ./tests/conformance/run.ts",
83
+ "verify:list": "node --import ../../../scripts/test/resolve-ts-from-js.mjs --experimental-strip-types ./tests/conformance/run.ts --list",
84
+ "build:js": "tsc -p tsconfig.json && node ../../../scripts/build/copy-vmz-public-api.mjs"
70
85
  },
71
86
  "keywords": [
72
87
  "vmz",
@@ -75,12 +90,12 @@
75
90
  "cli"
76
91
  ],
77
92
  "optionalDependencies": {
78
- "@vmz/vmz-win32-x64": "0.0.2",
79
- "@vmz/vmz-win32-arm64": "0.0.2",
80
- "@vmz/vmz-darwin-x64": "0.0.2",
81
- "@vmz/vmz-darwin-arm64": "0.0.2",
82
- "@vmz/vmz-linux-x64": "0.0.2",
83
- "@vmz/vmz-linux-arm64": "0.0.2"
93
+ "@vmz/vmz-win32-x64": "0.0.3",
94
+ "@vmz/vmz-win32-arm64": "0.0.3",
95
+ "@vmz/vmz-darwin-x64": "0.0.3",
96
+ "@vmz/vmz-darwin-arm64": "0.0.3",
97
+ "@vmz/vmz-linux-x64": "0.0.3",
98
+ "@vmz/vmz-linux-arm64": "0.0.3"
84
99
  },
85
100
  "publishConfig": {
86
101
  "access": "public"