@vmz/vmz 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/application-cmd.d.ts +6 -16
  2. package/dist/application-cmd.js +34 -180
  3. package/dist/author-input.d.ts +40 -19
  4. package/dist/author-input.js +2 -16
  5. package/dist/build-assemble.d.ts +63 -41
  6. package/dist/build-assemble.js +42 -43
  7. package/dist/bundler-adapter.d.ts +46 -48
  8. package/dist/bundler-adapter.js +4 -43
  9. package/dist/cdn-policy.d.ts +77 -93
  10. package/dist/cdn-policy.js +10 -16
  11. package/dist/cli-localize.d.ts +34 -0
  12. package/dist/cli-localize.js +58 -0
  13. package/dist/cli.d.ts +8 -19
  14. package/dist/cli.js +69 -252
  15. package/dist/content-addressed-assets.d.ts +24 -10
  16. package/dist/content-addressed-assets.js +2 -7
  17. package/dist/delivery-profile.d.ts +54 -27
  18. package/dist/delivery-profile.js +15 -13
  19. package/dist/dev-session.d.ts +29 -23
  20. package/dist/dev-session.js +0 -21
  21. package/dist/dev-watch-roots.d.ts +34 -25
  22. package/dist/dev-watch-roots.js +0 -31
  23. package/dist/document-build.d.ts +22 -97
  24. package/dist/document-build.js +4 -19
  25. package/dist/document-check.d.ts +30 -53
  26. package/dist/document-check.js +14 -29
  27. package/dist/document-cmd.d.ts +3 -6
  28. package/dist/document-cmd.js +19 -79
  29. package/dist/document-designs.d.ts +5 -8
  30. package/dist/document-designs.js +2 -15
  31. package/dist/document-enrich.d.ts +52 -24
  32. package/dist/document-enrich.js +4 -32
  33. package/dist/document-evidence.d.ts +46 -43
  34. package/dist/document-evidence.js +6 -47
  35. package/dist/document-integrate.d.ts +13 -29
  36. package/dist/document-integrate.js +2 -13
  37. package/dist/document-interactive.d.ts +45 -67
  38. package/dist/document-interactive.js +9 -50
  39. package/dist/document-layout-render.d.ts +7 -16
  40. package/dist/document-layout-render.js +0 -17
  41. package/dist/document-locale.d.ts +12 -25
  42. package/dist/document-locale.js +3 -14
  43. package/dist/document-markdown.d.ts +9 -5
  44. package/dist/document-markdown.js +0 -4
  45. package/dist/document-routing-config.d.ts +7 -14
  46. package/dist/document-routing-config.js +0 -9
  47. package/dist/document-scan.d.ts +14 -18
  48. package/dist/document-scan.js +2 -23
  49. package/dist/document-schema.d.ts +154 -41
  50. package/dist/document-schema.js +0 -35
  51. package/dist/embedded-packaging.d.ts +20 -8
  52. package/dist/embedded-packaging.js +0 -1
  53. package/dist/explain-cmd.d.ts +4 -3
  54. package/dist/explain-cmd.js +16 -65
  55. package/dist/index.d.ts +70 -143
  56. package/dist/index.js +16 -136
  57. package/dist/invocation.d.ts +29 -50
  58. package/dist/invocation.js +11 -57
  59. package/dist/locale-check.d.ts +69 -70
  60. package/dist/locale-check.js +5 -66
  61. package/dist/locale-cmd.d.ts +2 -5
  62. package/dist/locale-cmd.js +62 -142
  63. package/dist/locale-delivery.d.ts +294 -191
  64. package/dist/locale-delivery.js +8 -94
  65. package/dist/locale-route-emit.d.ts +23 -9
  66. package/dist/locale-route-emit.js +0 -7
  67. package/dist/locale-router.d.ts +189 -162
  68. package/dist/locale-router.js +13 -122
  69. package/dist/locale-runtime.d.ts +292 -262
  70. package/dist/locale-runtime.js +8 -102
  71. package/dist/locale-schema.js +0 -1
  72. package/dist/locale-tooling.d.ts +100 -63
  73. package/dist/locale-tooling.js +7 -45
  74. package/dist/log.d.ts +22 -15
  75. package/dist/log.js +24 -21
  76. package/dist/native-addon.d.ts +10 -9
  77. package/dist/native-addon.js +1 -10
  78. package/dist/pack-client-packages.d.ts +5 -1
  79. package/dist/pack-client-packages.js +0 -6
  80. package/dist/pack.d.ts +17 -15
  81. package/dist/pack.js +0 -12
  82. package/dist/packages.d.ts +10 -23
  83. package/dist/packages.js +1 -37
  84. package/dist/plan-cmd.d.ts +6 -0
  85. package/dist/plan-cmd.js +35 -0
  86. package/dist/plugin-host.js +0 -1
  87. package/dist/port.d.ts +2 -10
  88. package/dist/port.js +2 -11
  89. package/dist/pretty-json.d.ts +9 -19
  90. package/dist/pretty-json.js +3 -17
  91. package/dist/production-observability.d.ts +37 -181
  92. package/dist/production-observability.js +1 -9
  93. package/dist/production-test-pack.d.ts +17 -3
  94. package/dist/production-test-pack.js +0 -2
  95. package/dist/public-static-assets.d.ts +6 -1
  96. package/dist/public-static-assets.js +0 -5
  97. package/dist/refactor-cmd.d.ts +3 -6
  98. package/dist/refactor-cmd.js +16 -69
  99. package/dist/release-cmd.d.ts +7 -6
  100. package/dist/release-cmd.js +17 -59
  101. package/dist/release-pack.d.ts +7 -3
  102. package/dist/release-pack.js +0 -6
  103. package/dist/resolve.d.ts +15 -19
  104. package/dist/resolve.js +1 -15
  105. package/dist/server-artifact.d.ts +30 -75
  106. package/dist/server-artifact.js +0 -10
  107. package/dist/server-language-backend.d.ts +22 -79
  108. package/dist/server-language-backend.js +0 -26
  109. package/dist/site-delivery.d.ts +46 -59
  110. package/dist/site-delivery.js +3 -8
  111. package/dist/site-favicon.d.ts +6 -1
  112. package/dist/site-favicon.js +0 -5
  113. package/dist/static-emit.d.ts +73 -103
  114. package/dist/static-emit.js +1 -26
  115. package/dist/test-cmd.d.ts +3 -5
  116. package/dist/test-cmd.js +15 -25
  117. package/dist/test-compile.js +0 -1
  118. package/dist/test-discover.js +0 -1
  119. package/dist/test-logic.js +0 -1
  120. package/dist/test-protocol.js +0 -1
  121. package/dist/toolchain-dx.d.ts +11 -0
  122. package/dist/toolchain-dx.js +10 -0
  123. package/dist/watch-diff.d.ts +4 -13
  124. package/dist/watch-diff.js +0 -17
  125. package/dist/wechat-packaging.d.ts +8 -7
  126. package/dist/wechat-packaging.js +0 -6
  127. package/locales/en-US/cli.json +105 -0
  128. package/locales/locales.json +4 -0
  129. package/package.json +15 -12
  130. package/dist/resolve-native-cli.d.ts +0 -14
  131. package/dist/resolve-native-cli.js +0 -84
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * VMZ Node host: N-API workspace + npm CLI.
4
3
  * Coarse-grained only — no transform hooks / per-AST callbacks.
@@ -13,9 +12,6 @@ import { HOST_PROTOCOL, COMPILER_PROTOCOL, PROGRAM_IR_SCHEMA, PLUGIN_PROTOCOL, D
13
12
  const require = createRequire(import.meta.url);
14
13
  const here = path.dirname(fileURLToPath(import.meta.url));
15
14
  const pkgRoot = path.join(here, '..');
16
- /**
17
- * @returns {{ hostProtocol: string, compilerProtocol: string, programIrSchema: string, pluginProtocol: string }}
18
- */
19
15
  export function expectedProtocol() {
20
16
  return {
21
17
  hostProtocol: HOST_PROTOCOL,
@@ -55,13 +51,11 @@ function platformShort(triple = platformTriple()) {
55
51
  /**
56
52
  * Resolve native `.node` via the platform optionalDependency
57
53
  * (`@vmz/vmz-<short>`; transitional fallback `@vmz/vmz-<short>`).
58
- * @returns {string}
59
54
  */
60
55
  export function resolveNativePath() {
61
56
  const triple = platformTriple();
62
57
  const short = platformShort(triple);
63
58
  const names = [`@vmz/vmz-${short}`, `@vmz/vmz-${short}`];
64
- /** @type {string[]} */
65
59
  const candidates = [];
66
60
  for (const name of names) {
67
61
  try {
@@ -84,9 +78,6 @@ export function resolveNativePath() {
84
78
  `Looked in:\n${candidates.map((c) => ` - ${c}`).join('\n')}`);
85
79
  }
86
80
  let _native;
87
- /**
88
- * @returns {typeof import('./index.js') extends never ? any : any}
89
- */
90
81
  export function loadNative() {
91
82
  if (_native)
92
83
  return _native;
@@ -94,16 +85,6 @@ export function loadNative() {
94
85
  _native = require(addonPath);
95
86
  return _native;
96
87
  }
97
- /**
98
- * @typedef {object} ProtocolVersions
99
- * @property {string} hostProtocol
100
- * @property {string} compilerProtocol
101
- * @property {string} programIrSchema
102
- * @property {string} pluginProtocol
103
- */
104
- /**
105
- * @returns {ProtocolVersions}
106
- */
107
88
  export function getProtocolVersions() {
108
89
  const native = loadNative();
109
90
  const n = native.getProtocolVersions();
@@ -114,9 +95,6 @@ export function getProtocolVersions() {
114
95
  pluginProtocol: n.pluginProtocol,
115
96
  };
116
97
  }
117
- /**
118
- * @param {ProtocolVersions} [host]
119
- */
120
98
  export function handshake(host = expectedProtocol()) {
121
99
  const native = loadNative();
122
100
  native.handshakeProtocols({
@@ -126,10 +104,7 @@ export function handshake(host = expectedProtocol()) {
126
104
  pluginProtocol: host.pluginProtocol,
127
105
  });
128
106
  }
129
- /**
130
- * Resolve `@vmz/core` package `dist/` for runtime JS copies into app outDir.
131
- * @returns {string | null}
132
- */
107
+ /** Resolve `@vmz/core` package `dist/` for runtime JS copies into app outDir. */
133
108
  export function resolveCoreRuntimeDist() {
134
109
  try {
135
110
  // Prefer a real export subpath — `package.json` is often blocked by "exports".
@@ -153,11 +128,7 @@ export const SERVE_HOST_RUNTIME_FILES = [
153
128
  ['render-host.js', 'render-host.js'],
154
129
  ['route-layout-chain.js', 'route-layout-chain.js'],
155
130
  ];
156
- /**
157
- * Copy serve-host + registry bootstrap modules from `@vmz/core` into app outDir.
158
- * @param {string} outDir
159
- * @param {string} [coreDist]
160
- */
131
+ /** Copy serve-host + registry bootstrap modules from `@vmz/core` into app outDir. */
161
132
  export function materializeServeHostRuntime(outDir, coreDist = resolveCoreRuntimeDist()) {
162
133
  if (!coreDist) {
163
134
  throw new Error('materializeServeHostRuntime: @vmz/core dist not found');
@@ -171,17 +142,7 @@ export function materializeServeHostRuntime(outDir, coreDist = resolveCoreRuntim
171
142
  copyFileSync(src, dst);
172
143
  }
173
144
  }
174
- /**
175
- * @typedef {object} WorkspaceOptions
176
- * @property {string} root
177
- * @property {string} [outDir]
178
- * @property {string} [runtimeDist]
179
- * @property {ProtocolVersions} [protocol]
180
- */
181
- /**
182
- * Create a long-lived compile workspace .
183
- * @param {WorkspaceOptions} options
184
- */
145
+ /** Create a long-lived compile workspace. */
185
146
  export function createWorkspace(options) {
186
147
  const native = loadNative();
187
148
  const protocol = options.protocol ?? expectedProtocol();
@@ -217,20 +178,12 @@ export function createWorkspace(options) {
217
178
  });
218
179
  }
219
180
  }
220
- /**
221
- * frozen application composition protocol catalog.
222
- * @returns {string}
223
- */
181
+ /** frozen application composition protocol catalog. */
224
182
  export function queryApplicationProtocolCatalog() {
225
183
  const native = loadNative();
226
184
  return native.queryApplicationProtocolCatalog();
227
185
  }
228
- /**
229
- * check host applications.config.json5 against workspace package descriptors.
230
- * @param {string} hostRoot
231
- * @param {string[]} packageRoots
232
- * @returns {string} ApplicationCheckReport JSON
233
- */
186
+ /** check host applications.config.json5 against workspace package descriptors. */
234
187
  export function checkApplicationsJson(hostRoot, packageRoots) {
235
188
  const native = loadNative();
236
189
  return native.checkApplicationsJson(hostRoot, packageRoots);
@@ -334,63 +287,32 @@ export function checkMultiPlatformContractJson(rootPath) {
334
287
  const native = loadNative();
335
288
  return native.checkMultiPlatformContractJson(rootPath);
336
289
  }
337
- /**
338
- * prove independent `/` + non-root ApplicationBase; scan non-relocatable URLs.
339
- * @param {string} packageRoot
340
- * @param {string} [relocateBase]
341
- * @returns {string}
342
- */
290
+ /** prove independent `/` + non-root ApplicationBase; scan non-relocatable URLs. */
343
291
  export function checkApplicationRelocatableJson(packageRoot, relocateBase) {
344
292
  const native = loadNative();
345
293
  return native.checkApplicationRelocatableJson(packageRoot, relocateBase ?? null);
346
294
  }
347
- /**
348
- * apply ApplicationBase to a logical relocation manifest.
349
- * @param {string} manifestJson
350
- * @param {string} base
351
- * @returns {string}
352
- */
295
+ /** apply ApplicationBase to a logical relocation manifest. */
353
296
  export function relocateApplicationManifestJson(manifestJson, base) {
354
297
  const native = loadNative();
355
298
  return native.relocateApplicationManifestJson(manifestJson, base);
356
299
  }
357
- /**
358
- * independent ApplicationArtifact + MountTable/Catalog boundary (refs only).
359
- * @param {string} hostRoot
360
- * @param {string[]} packageRoots
361
- * @returns {string}
362
- */
300
+ /** independent ApplicationArtifact + MountTable/Catalog boundary (refs only). */
363
301
  export function checkApplicationArtifactBoundaryJson(hostRoot, packageRoots) {
364
302
  const native = loadNative();
365
303
  return native.checkApplicationArtifactBoundaryJson(hostRoot, packageRoots);
366
304
  }
367
- /**
368
- * absolute isolation namespaces + failure containment.
369
- * @param {string} hostRoot
370
- * @param {string[]} packageRoots
371
- * @returns {string}
372
- */
305
+ /** absolute isolation namespaces + failure containment. */
373
306
  export function checkApplicationIsolationJson(hostRoot, packageRoots) {
374
307
  const native = loadNative();
375
308
  return native.checkApplicationIsolationJson(hostRoot, packageRoots);
376
309
  }
377
- /**
378
- * host catalog consumption + cross-application Link resolution.
379
- * @param {string} hostRoot
380
- * @param {string[]} packageRoots
381
- * @returns {string}
382
- */
310
+ /** host catalog consumption + cross-application Link resolution. */
383
311
  export function checkApplicationHostCompositionJson(hostRoot, packageRoots) {
384
312
  const native = loadNative();
385
313
  return native.checkApplicationHostCompositionJson(hostRoot, packageRoots);
386
314
  }
387
- /**
388
- * multi-session affected rebuild + MountTable proxy + mounted tests + deploy adapter.
389
- * @param {string} hostRoot
390
- * @param {string[]} packageRoots
391
- * @param {string[]} [dirtyPaths]
392
- * @returns {string}
393
- */
315
+ /** multi-session affected rebuild + MountTable proxy + mounted tests + deploy adapter. */
394
316
  export function checkApplicationDevTestDeployJson(hostRoot, packageRoots, dirtyPaths = []) {
395
317
  const native = loadNative();
396
318
  return native.checkApplicationDevTestDeployJson(hostRoot, packageRoots, dirtyPaths);
@@ -398,13 +320,15 @@ export function checkApplicationDevTestDeployJson(hostRoot, packageRoots, dirtyP
398
320
  export { createDevSession, listWatchedFiles, srcFingerprint } from './dev-session.js';
399
321
  export { coalesceRootBurst, collectDevWatchRoots, mergeDirtySets, localLinkDependencyRoots, watchRootForSourceFile, } from './dev-watch-roots.js';
400
322
  export { findAvailablePort } from './port.js';
401
- export { runCli, parseArgs, printHelp, printGlobalHelp, printProjectHelp } from './cli.js';
323
+ export { runCli, printHelp, printGlobalHelp, printProjectHelp } from './cli.js';
324
+ export { createCli, formatDiagnostic, formatDiagnostics, t } from './toolchain-dx.js';
325
+ export { VMZ_CLI_CATALOG_EN_US, createVmzCliLocalize, flattenCatalog, loadCliCatalog, loadCliLocalesManifest, resolveCliLocalesRoot, resolveVmzLocale, translateCatalog, vmzCliLocalize, } from './toolchain-dx.js';
402
326
  export { findNearestProjectVmz, getInvocationContext, isGlobalAllowedCommand, isUnderNodeModules, resolveThisPackageRoot, resolveVmzBin, gateGlobalProjectCommand, } from './invocation.js';
403
327
  export { resolveWorkspaceDirs, findPackageJson, readPackageMeta } from './resolve.js';
404
328
  export { resolvePackageRoot, resolveWorkspacePackages } from './packages.js';
405
329
  export { log } from './log.js';
406
- export { cmdApplication, runCheck as runApplicationCheck } from './application-cmd.js';
407
- export { cmdArtifact } from './release-cmd.js';
330
+ export { registerApplicationCommands, runCheck as runApplicationCheck } from './application-cmd.js';
331
+ export { registerArtifactCommands, runArtifact } from './release-cmd.js';
408
332
  export { ARTIFACT_DIFF_SCHEMA, DELIVERY_ARTIFACT_MANIFEST_SCHEMA, RELEASE_ENVELOPE_SCHEMA, ROUTE_REALIZATION_TABLE_SCHEMA, atomicWritePointer, canonicalJson, diffArtifacts, loadReleaseEnvelope, packRelease, publishRelease, readPointer, rollbackRelease, sha256File, sha256Hex, } from './release-pack.js';
409
333
  // APPLICATION_ARTIFACT_SCHEMA lives in @vmz/protocol (already re-exported above);
410
334
  // release-pack keeps a local constant for envelope writes — do not dual-export the name.
@@ -531,14 +455,6 @@ export default {
531
455
  PROFILE_CONFORMANCE_STATE_SNAPSHOT_SCHEMA,
532
456
  PROFILE_CONFORMANCE_TRACE_SCHEMA,
533
457
  PROFILE_CONFORMANCE_HOST_RUN_SCHEMA,
534
- PROFILE_CONFORMANCE_SCENARIO_SCHEMA,
535
- PROFILE_CONFORMANCE_CHECK_SCHEMA,
536
- PROFILE_CONFORMANCE_SURFACE_ROLES,
537
- PROFILE_DIAG_STABLE_ID_DIVERGENCE,
538
- PROFILE_DIAG_STATE_RESULT_DIVERGENCE,
539
- PROFILE_DIAG_TRACE_INVARIANT_BROKEN,
540
- PROFILE_DIAG_CONFORMANCE_HOST_INCOMPLETE,
541
- PROFILE_DIAG_CONFORMANCE_SURFACE_ROLE_MISMATCH,
542
458
  PROFILE_LIFECYCLE_SCENARIO_SCHEMA,
543
459
  PROFILE_LIFECYCLE_RECOVERY_CHECK_SCHEMA,
544
460
  PROFILE_LIFECYCLE_HOST_KINDS,
@@ -553,28 +469,9 @@ export default {
553
469
  PROFILE_DELIVERY_UPDATE_POLICY_SCHEMA,
554
470
  PROFILE_DELIVERY_ARTIFACT_MANIFEST_SCHEMA,
555
471
  PROFILE_DELIVERY_PROOF_MANIFEST_SCHEMA,
556
- PROFILE_DELIVERY_PROOF_SCENARIO_SCHEMA,
557
- PROFILE_DELIVERY_PROOF_CHECK_SCHEMA,
558
472
  PROFILE_DELIVERY_UPDATE_CHANNELS,
559
473
  PROFILE_DELIVERY_ASSET_STRATEGIES,
560
- PROFILE_DIAG_DELIVERY_CONSTRAINT_EXCEEDED,
561
- PROFILE_DIAG_HOST_PLAN_VERSION_MISMATCH,
562
474
  PROFILE_DIAG_PROOF_MANIFEST_INCOMPLETE,
563
- PROFILE_DIAG_PROOF_COPIES_SEMANTIC_IR,
564
- PROFILE_DIAG_UPDATE_WITHOUT_REPROOF,
565
- PROFILE_DIAG_SECURITY_POLICY_INSECURE,
566
- PROFILE_CONFORMANCE_FIXTURE_SCHEMA,
567
- PROFILE_CONFORMANCE_STATE_SNAPSHOT_SCHEMA,
568
- PROFILE_CONFORMANCE_TRACE_SCHEMA,
569
- PROFILE_CONFORMANCE_HOST_RUN_SCHEMA,
570
- PROFILE_CONFORMANCE_SCENARIO_SCHEMA,
571
- PROFILE_CONFORMANCE_CHECK_SCHEMA,
572
- PROFILE_CONFORMANCE_SURFACE_ROLES,
573
- PROFILE_DIAG_STABLE_ID_DIVERGENCE,
574
- PROFILE_DIAG_STATE_RESULT_DIVERGENCE,
575
- PROFILE_DIAG_TRACE_INVARIANT_BROKEN,
576
- PROFILE_DIAG_CONFORMANCE_HOST_INCOMPLETE,
577
- PROFILE_DIAG_CONFORMANCE_SURFACE_ROLE_MISMATCH,
578
475
  PROFILE_SOLVER_CHECK_SCHEMA,
579
476
  PROFILE_HOST_RESOLUTION_MANIFEST_SCHEMA,
580
477
  PROFILE_EXECUTOR_CHECK_SCHEMA,
@@ -602,22 +499,6 @@ export default {
602
499
  PROFILE_SURFACE_KINDS,
603
500
  PROFILE_UNIFIED_LIFECYCLE_EVENTS,
604
501
  PROFILE_CORE_ID_PREFIX,
605
- PROFILE_SOLVER_CHECK_SCHEMA,
606
- PROFILE_HOST_RESOLUTION_MANIFEST_SCHEMA,
607
- PROFILE_EXECUTOR_CHECK_SCHEMA,
608
- PROFILE_EXECUTOR_SCENARIO_SCHEMA,
609
- PROFILE_DIAG_SURFACE_NO_MATCH,
610
- PROFILE_DIAG_SURFACE_AMBIGUOUS,
611
- PROFILE_DIAG_CAPABILITY_UNRESOLVED,
612
- PROFILE_DIAG_CAPABILITY_PERMISSION_UNDECLARED,
613
- PROFILE_DIAG_ROUTE_UNREALIZABLE,
614
- PROFILE_DIAG_STALE_GENERATION,
615
- PROFILE_DIAG_MISSING_ENVELOPE_IDS,
616
- PROFILE_DIAG_SURFACE_OWNS_STATE,
617
- PROFILE_DIAG_PRIVATE_OBJECT_CROSSING,
618
- PROFILE_DIAG_SPLIT_TRANSACTION,
619
- PROFILE_DIAG_DISPOSE_NOT_AUTHORITATIVE,
620
- PROFILE_DIAG_CANCEL_NOT_PROPAGATED,
621
502
  profileCatalog,
622
503
  localeCatalog,
623
504
  queryNativeHostProtocolCatalog,
@@ -666,7 +547,6 @@ export default {
666
547
  NATIVE_HOST_DEEP_LINK_SCHEMA,
667
548
  NATIVE_HOST_LOCAL_BUNDLE_SCHEMA,
668
549
  NATIVE_HOST_DIAG_MISSING_SHELL_HOOK,
669
- NATIVE_HOST_DIAG_PLATFORM_SEMANTIC_FORK,
670
550
  NATIVE_HOST_DIAG_REMOTE_ENTRY_DEFAULT,
671
551
  NATIVE_HOST_DIAG_MISSING_ENTRY_ARTIFACT,
672
552
  NATIVE_HOST_REQUIRED_SHELL_HOOKS,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `vmz` CLI invocation modes (JS gate only; Rust binary stays full).
2
+ * `vmz` CLI invocation modes (JS gate for `@vmz/vmz` only).
3
3
  *
4
4
  * Product install face: workspace `vmz` / publish `@vmz/vmz` (bin still `vmz`).
5
5
  *
@@ -7,62 +7,41 @@
7
7
  * - **developer**: monorepo source checkout (`packages/runtimes/vmz`, not under node_modules)
8
8
  * - **project**: app's nearest `node_modules/vmz` or `node_modules/@vmz/vmz`
9
9
  * - **global**: npm/pnpm global (or any install under node_modules that is not the nearest project one)
10
- *
11
- */
12
- /**
13
- * Package root of the running `vmz` / `@vmz/vmz` install.
14
- * @param {string} [fromUrl]
15
10
  */
11
+ export type InvocationMode = 'developer' | 'project' | 'global';
12
+ /** Package root of the running `vmz` / `@vmz/vmz` install. */
16
13
  export declare function resolveThisPackageRoot(fromUrl?: string): string;
17
- /**
18
- * Walk from `startDir` for nearest project CLI package root.
19
- * @param {string} startDir
20
- * @returns {string | null}
21
- */
22
- export declare function findNearestProjectVmz(startDir: any): string;
23
- /**
24
- * Resolve CLI entry (`bin/vmz.js`).
25
- * @param {string} packageRoot
26
- * @returns {string | null}
27
- */
28
- export declare function resolveVmzBin(packageRoot: any): string;
29
- /**
30
- * @param {string} packageRoot
31
- */
32
- export declare function isUnderNodeModules(packageRoot: any): boolean;
33
- /**
34
- * @param {{
35
- * cwd?: string,
36
- * thisPackageRoot?: string,
37
- * }} [opts]
38
- */
39
- export declare function getInvocationContext(opts?: {}): {
40
- mode: any;
14
+ /** Walk from `startDir` for nearest project CLI package root. */
15
+ export declare function findNearestProjectVmz(startDir: string): string | null;
16
+ /** Resolve CLI entry (`bin/vmz.js`). */
17
+ export declare function resolveVmzBin(packageRoot: string): string | null;
18
+ export declare function isUnderNodeModules(packageRoot: string): boolean;
19
+ export type InvocationContext = {
20
+ mode: InvocationMode;
41
21
  cwd: string;
42
22
  thisPackageRoot: string;
43
- nearestProjectVmz: string;
23
+ nearestProjectVmz: string | null;
44
24
  isDeveloper: boolean;
45
25
  isProjectLocal: boolean;
46
26
  /** @deprecated prefer `mode === 'global'`; kept for call sites */
47
27
  isGlobalLike: boolean;
48
28
  };
49
- /**
50
- * @param {string | undefined} cmd
51
- */
52
- export declare function isGlobalAllowedCommand(cmd: any): boolean;
53
- /**
54
- * @param {string} bin
55
- * @param {string[]} argv
56
- * @returns {Promise<number>}
57
- */
58
- export declare function reexecProjectVmz(bin: any, argv: any): Promise<unknown>;
59
- /**
60
- * @returns {Promise<{ action: 'proceed' } | { action: 'exit', code: number }>}
61
- */
62
- export declare function gateGlobalProjectCommand(opts: any): Promise<{
63
- action: string;
64
- code?: undefined;
29
+ export declare function getInvocationContext(opts?: {
30
+ cwd?: string;
31
+ thisPackageRoot?: string;
32
+ }): InvocationContext;
33
+ export declare function isGlobalAllowedCommand(cmd: string | undefined): boolean;
34
+ export declare function reexecProjectVmz(bin: string, argv: string[]): Promise<number>;
35
+ export type GateResult = {
36
+ action: 'proceed';
65
37
  } | {
66
- action: string;
67
- code: any;
68
- }>;
38
+ action: 'exit';
39
+ code: number;
40
+ };
41
+ export declare function gateGlobalProjectCommand(opts: {
42
+ argv: string[];
43
+ cwd?: string;
44
+ thisPackageRoot?: string;
45
+ reexec?: (bin: string, argv: string[]) => Promise<number>;
46
+ logError?: (msg: string) => void;
47
+ }): Promise<GateResult>;
@@ -1,6 +1,5 @@
1
- // @ts-nocheck
2
1
  /**
3
- * `vmz` CLI invocation modes (JS gate only; Rust binary stays full).
2
+ * `vmz` CLI invocation modes (JS gate for `@vmz/vmz` only).
4
3
  *
5
4
  * Product install face: workspace `vmz` / publish `@vmz/vmz` (bin still `vmz`).
6
5
  *
@@ -8,24 +7,17 @@
8
7
  * - **developer**: monorepo source checkout (`packages/runtimes/vmz`, not under node_modules)
9
8
  * - **project**: app's nearest `node_modules/vmz` or `node_modules/@vmz/vmz`
10
9
  * - **global**: npm/pnpm global (or any install under node_modules that is not the nearest project one)
11
- *
12
10
  */
13
11
  import { spawn } from 'node:child_process';
14
12
  import { existsSync, realpathSync } from 'node:fs';
15
13
  import path from 'node:path';
16
14
  import { fileURLToPath } from 'node:url';
17
- /** @typedef {'developer' | 'project' | 'global'} InvocationMode */
15
+ import { vmzCliLocalize } from './cli-localize.js';
18
16
  const PROJECT_PKG_SEGMENTS = [['@vmz', 'vmz'], ['vmz']];
19
- /**
20
- * Package root of the running `vmz` / `@vmz/vmz` install.
21
- * @param {string} [fromUrl]
22
- */
17
+ /** Package root of the running `vmz` / `@vmz/vmz` install. */
23
18
  export function resolveThisPackageRoot(fromUrl = import.meta.url) {
24
19
  return path.resolve(path.dirname(fileURLToPath(fromUrl)), '..');
25
20
  }
26
- /**
27
- * @param {string} p
28
- */
29
21
  function tryRealpath(p) {
30
22
  try {
31
23
  return realpathSync(p);
@@ -34,11 +26,7 @@ function tryRealpath(p) {
34
26
  return path.resolve(p);
35
27
  }
36
28
  }
37
- /**
38
- * Walk from `startDir` for nearest project CLI package root.
39
- * @param {string} startDir
40
- * @returns {string | null}
41
- */
29
+ /** Walk from `startDir` for nearest project CLI package root. */
42
30
  export function findNearestProjectVmz(startDir) {
43
31
  let dir = path.resolve(startDir);
44
32
  for (;;) {
@@ -55,37 +43,23 @@ export function findNearestProjectVmz(startDir) {
55
43
  dir = parent;
56
44
  }
57
45
  }
58
- /**
59
- * Resolve CLI entry (`bin/vmz.js`).
60
- * @param {string} packageRoot
61
- * @returns {string | null}
62
- */
46
+ /** Resolve CLI entry (`bin/vmz.js`). */
63
47
  export function resolveVmzBin(packageRoot) {
64
48
  const bin = path.join(packageRoot, 'bin', 'vmz.js');
65
49
  if (existsSync(bin))
66
50
  return tryRealpath(bin);
67
51
  return null;
68
52
  }
69
- /**
70
- * @param {string} packageRoot
71
- */
72
53
  export function isUnderNodeModules(packageRoot) {
73
54
  const norm = path.normalize(packageRoot);
74
55
  const parts = norm.split(path.sep);
75
56
  return parts.includes('node_modules');
76
57
  }
77
- /**
78
- * @param {{
79
- * cwd?: string,
80
- * thisPackageRoot?: string,
81
- * }} [opts]
82
- */
83
58
  export function getInvocationContext(opts = {}) {
84
59
  const cwd = path.resolve(opts.cwd ?? process.cwd());
85
60
  const thisPackageRoot = tryRealpath(opts.thisPackageRoot ?? resolveThisPackageRoot());
86
61
  const nearestProjectVmz = findNearestProjectVmz(cwd);
87
62
  const underNm = isUnderNodeModules(thisPackageRoot);
88
- /** @type {InvocationMode} */
89
63
  let mode;
90
64
  if (!underNm) {
91
65
  mode = 'developer';
@@ -103,30 +77,14 @@ export function getInvocationContext(opts = {}) {
103
77
  nearestProjectVmz,
104
78
  isDeveloper: mode === 'developer',
105
79
  isProjectLocal: mode === 'project',
106
- /** @deprecated prefer `mode === 'global'`; kept for call sites */
107
80
  isGlobalLike: mode === 'global',
108
81
  };
109
82
  }
110
- /**
111
- * @param {string | undefined} cmd
112
- */
113
83
  export function isGlobalAllowedCommand(cmd) {
114
84
  if (!cmd)
115
85
  return true;
116
- return (cmd === 'help' ||
117
- cmd === '-h' ||
118
- cmd === '--help' ||
119
- cmd === 'version' ||
120
- cmd === '-V' ||
121
- cmd === '--version' ||
122
- cmd === 'new' ||
123
- cmd === 'init');
86
+ return cmd === 'help' || cmd === '-h' || cmd === '--help' || cmd === 'version' || cmd === '-V' || cmd === '--version';
124
87
  }
125
- /**
126
- * @param {string} bin
127
- * @param {string[]} argv
128
- * @returns {Promise<number>}
129
- */
130
88
  export function reexecProjectVmz(bin, argv) {
131
89
  return new Promise((resolve) => {
132
90
  const child = spawn(process.execPath, [bin, ...argv], {
@@ -142,9 +100,6 @@ export function reexecProjectVmz(bin, argv) {
142
100
  });
143
101
  });
144
102
  }
145
- /**
146
- * @returns {Promise<{ action: 'proceed' } | { action: 'exit', code: number }>}
147
- */
148
103
  export async function gateGlobalProjectCommand(opts) {
149
104
  const { argv, cwd = process.cwd(), thisPackageRoot, reexec = reexecProjectVmz, logError = (msg) => console.error(msg) } = opts;
150
105
  const ctx = getInvocationContext({ cwd, thisPackageRoot });
@@ -154,16 +109,15 @@ export async function gateGlobalProjectCommand(opts) {
154
109
  if (ctx.nearestProjectVmz && ctx.nearestProjectVmz !== ctx.thisPackageRoot) {
155
110
  const bin = resolveVmzBin(ctx.nearestProjectVmz);
156
111
  if (!bin) {
157
- logError('found project `vmz` / `@vmz/vmz` but bin/vmz.js is missing.');
112
+ logError(vmzCliLocalize.t('cli.err.project_bin_missing'));
158
113
  return { action: 'exit', code: 1 };
159
114
  }
160
115
  const code = await reexec(bin, argv);
161
116
  return { action: 'exit', code };
162
117
  }
163
- logError('this `vmz` is a global install (mode=global); project commands need a project install.');
164
- logError('Install in the app: pnpm add -D @vmz/vmz');
165
- logError('Or scaffold: vmz new <dir>');
166
- logError('Then run: pnpm exec vmz <command>');
167
- logError('(developer mode: run from vmz-framework packages/runtimes/vmz source — full CLI)');
118
+ logError(vmzCliLocalize.t('cli.err.global_needs_project'));
119
+ logError(vmzCliLocalize.t('cli.err.global_install_hint'));
120
+ logError(vmzCliLocalize.t('cli.err.global_run_hint'));
121
+ logError(vmzCliLocalize.t('cli.err.global_developer_hint'));
168
122
  return { action: 'exit', code: 1 };
169
123
  }