@pulse-compute/wasm-compiler 0.0.0 → 1.0.0-beta.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.
Files changed (104) hide show
  1. package/README.md +52 -1
  2. package/bin/provider-proof-composition.js +34 -0
  3. package/bin/pulsewasm-extract.js +20 -0
  4. package/package.json +60 -5
  5. package/src/artifacts-dir.js +13 -0
  6. package/src/ast-json.js +52 -0
  7. package/src/build-manifest.js +354 -0
  8. package/src/canonical-api-compiler.js +245 -0
  9. package/src/canonical-native-compiler.js +411 -0
  10. package/src/canonical-native-plan.js +1477 -0
  11. package/src/canonical-project-compiler.js +1218 -0
  12. package/src/canonical-router-compiler.js +25 -0
  13. package/src/cli-intents.js +1235 -0
  14. package/src/cli.js +1927 -0
  15. package/src/codegen/assemblyscript-compile.js +3 -0
  16. package/src/codegen/assemblyscript-core.js +3 -0
  17. package/src/codegen/assemblyscript-shape.js +3 -0
  18. package/src/codegen/assemblyscript-wasm-smoke.js +3 -0
  19. package/src/codegen/backend-capabilities.js +3 -0
  20. package/src/codegen/channel-broadcaster.js +3 -0
  21. package/src/codegen/compiled-handlers.js +3 -0
  22. package/src/codegen/compiled-wasm-runtime.js +3 -0
  23. package/src/codegen/config-references.js +248 -0
  24. package/src/codegen/dispatch-ts.js +145 -0
  25. package/src/codegen/effect-composition.js +331 -0
  26. package/src/codegen/effect-runtime.js +418 -0
  27. package/src/codegen/execution-harness-ts.js +467 -0
  28. package/src/codegen/handler-bindings-ts.js +298 -0
  29. package/src/codegen/handler-library-contracts.js +3 -0
  30. package/src/codegen/host-capabilities.js +3 -0
  31. package/src/codegen/host-runtime-kernel.js +3 -0
  32. package/src/codegen/integrated-compiled-app.js +3 -0
  33. package/src/codegen/json-body.js +3 -0
  34. package/src/codegen/library-sidecars.js +3 -0
  35. package/src/codegen/local-harness-ts.js +453 -0
  36. package/src/codegen/pulse-wrapper.js +217 -0
  37. package/src/codegen/request-result-headers.js +3 -0
  38. package/src/codegen/schema-json-compile.js +3 -0
  39. package/src/codegen/schema-json-sidecar-v2.js +3 -0
  40. package/src/codegen/schema-json-sidecar.js +3 -0
  41. package/src/codegen/streaming-passthrough.js +3 -0
  42. package/src/codegen/wasm-host-abi.js +3 -0
  43. package/src/codegen/wasm-host-bridge.js +3 -0
  44. package/src/compiled-wasm-host-runtime-kv.js +3 -0
  45. package/src/config-resolver.js +813 -0
  46. package/src/crypto-requirement-planner.js +89 -0
  47. package/src/definitions/config-schema.js +14 -0
  48. package/src/definitions/handler-roles.js +14 -0
  49. package/src/definitions/path-grammar.js +14 -0
  50. package/src/definitions/router-api.js +14 -0
  51. package/src/diagnostics/codes.js +14 -0
  52. package/src/diagnostics/reporter.js +14 -0
  53. package/src/diagnostics.js +14 -0
  54. package/src/dispatch-table.js +400 -0
  55. package/src/events/event-emit.js +265 -0
  56. package/src/events/event-topology.js +127 -0
  57. package/src/execution-plan.js +463 -0
  58. package/src/extractor.js +2816 -0
  59. package/src/handler-eval.js +1154 -0
  60. package/src/handler-table.js +326 -0
  61. package/src/index.js +19 -0
  62. package/src/javascript-application-plan.js +181 -0
  63. package/src/kv-provider.js +3 -0
  64. package/src/path-table.js +60 -0
  65. package/src/path.js +14 -0
  66. package/src/patterns/config-define.js +30 -0
  67. package/src/patterns/dependency-call.js +18 -0
  68. package/src/patterns/env-lookup.js +13 -0
  69. package/src/patterns/handler-reference.js +29 -0
  70. package/src/patterns/path-literal.js +35 -0
  71. package/src/patterns/result.js +15 -0
  72. package/src/patterns/router-chain-call.js +50 -0
  73. package/src/patterns/router-construction.js +19 -0
  74. package/src/project/package-reachability.js +782 -0
  75. package/src/project/reachable-graph-builder.js +992 -0
  76. package/src/project/reachable-graph-contract.js +54 -0
  77. package/src/project/reachable-graph-implementation.js +36 -0
  78. package/src/project/router-module-linker.js +710 -0
  79. package/src/project-config-compiler.js +222 -0
  80. package/src/project-target-support.js +500 -0
  81. package/src/provider-toolchain.js +299 -0
  82. package/src/spine/async-surface-normalizer.js +312 -0
  83. package/src/spine/canonical-handler-ir.js +335 -0
  84. package/src/spine/canonical-native-module.js +87 -0
  85. package/src/spine/canonical-native-plan.js +89 -0
  86. package/src/spine/canonical-project.js +76 -0
  87. package/src/spine/canonical-router.js +155 -0
  88. package/src/spine/canonical-source.js +165 -0
  89. package/src/spine/diagnostic-authority.js +290 -0
  90. package/src/spine/equivalence.js +262 -0
  91. package/src/spine/guest-unit-stage.js +87 -0
  92. package/src/spine/handler-ir-emitter.js +454 -0
  93. package/src/spine/handler-ir-managed.js +1597 -0
  94. package/src/spine/handler-ir.js +797 -0
  95. package/src/spine/handler-surface-authority.js +585 -0
  96. package/src/spine/package-operation-seam.js +1015 -0
  97. package/src/spine/pipeline.js +202 -0
  98. package/src/spine/plain-handler-frontend.js +537 -0
  99. package/src/spine/provider-requirement-authority.js +208 -0
  100. package/src/spine/router-control-contract.js +17 -0
  101. package/src/spine/router-handler-frontend.js +513 -0
  102. package/src/spine/router-handler-ir.js +372 -0
  103. package/src/spine/router-topology-frontend.js +635 -0
  104. package/src/stable-id.js +14 -0
package/src/cli.js ADDED
@@ -0,0 +1,1927 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const { extractFromFile } = require('./extractor.js');
6
+ const { resolveConfigFromFile } = require('./config-resolver.js');
7
+ const { ExtractionError, createDiagnosticsEnvelope, formatDiagnostics } = require('./diagnostics.js');
8
+ const {
9
+ applyCliIntent,
10
+ createArtifactsList,
11
+ createDoctorArtifact,
12
+ createExplainArtifact,
13
+ knownFeatures,
14
+ pushUnique,
15
+ splitList
16
+ } = require('./cli-intents.js');
17
+ const { createBuildManifest, makeArtifactRecord } = require('./build-manifest.js');
18
+ const { getDefaultArtifactsDir } = require('@pulse-compute/wasm-build-support/artifacts-dir');
19
+ const { normalizeArtifactFile } = require('@pulse-compute/wasm-build-support/files');
20
+
21
+ const BUILD_COMMANDS = new Set(['build', 'extract']);
22
+ const PLAN_COMMANDS = new Set(['plan']);
23
+ const DOCTOR_COMMANDS = new Set(['doctor']);
24
+ const EXPLAIN_COMMANDS = new Set(['explain']);
25
+ const ARTIFACT_COMMANDS = new Set(['artifacts', 'artifact']);
26
+ const CONFIG_COMMANDS = new Set(['resolve-config', 'config']);
27
+
28
+ function requireValue(argv, index, flag) {
29
+ const value = argv[index];
30
+ if (!value || value.startsWith('--')) {
31
+ throw new Error(`${flag} requires a value.`);
32
+ }
33
+ return value;
34
+ }
35
+
36
+ function parseEnvAssignment(value) {
37
+ const index = value.indexOf('=');
38
+ if (index <= 0) {
39
+ throw new Error(`Invalid --env value "${value}". Use NAME=value.`);
40
+ }
41
+ return [value.slice(0, index), value.slice(index + 1)];
42
+ }
43
+
44
+ function parseArgs(argv, defaults = {}) {
45
+ const args = {
46
+ command: 'build',
47
+ entry: undefined,
48
+ config: undefined,
49
+ outDir: defaults.defaultOutDir || path.join(process.cwd(), 'artifacts'),
50
+ outDirExplicit: false,
51
+ root: undefined,
52
+ profile: undefined,
53
+ targetIntent: undefined,
54
+ providerIntent: undefined,
55
+ features: [],
56
+ diagnosticsFile: undefined,
57
+ manifestFile: undefined,
58
+ artifactsAction: undefined,
59
+ outputFormat: 'text',
60
+ env: {},
61
+ includeAst: false,
62
+ emitDispatchTs: false,
63
+ emitHandlerBindings: false,
64
+ emitExecutionHarness: false,
65
+ emitAssemblyScriptShape: false,
66
+ emitAssemblyScriptCore: false,
67
+ emitAssemblyScriptCompile: false,
68
+ emitWasmSmoke: false,
69
+ emitLocalHarness: false,
70
+ emitWasmHostAbi: false,
71
+ emitWasmHostBridge: false,
72
+ emitRequestResultHeaders: false,
73
+ emitChannelBroadcaster: false,
74
+ emitJsonBody: false,
75
+ emitBackendCapabilities: false,
76
+ emitHostRuntimeKernel: false,
77
+ emitNodeAdapter: false,
78
+ emitHandlerLibraryContracts: false,
79
+ emitAssetsLoweringPlan: false,
80
+ emitNodeAssetsProviderProof: false,
81
+ emitFastlyAssetsProviderProof: false,
82
+ emitFastlyAssetsPackageOutParityProof: false,
83
+ emitRouteHandlerEffectPlan: false,
84
+ emitNodeRouteHandlerEffectProof: false,
85
+ emitFastlyRouteHandlerEffectProof: false,
86
+ emitFastlyLifecycleParityProof: false,
87
+ emitNodeLiveOriginRouteHandlerEffectProof: false,
88
+ emitNodeCompiledRouteHandlerEffectBridge: false,
89
+ emitRouteHandlerContextLoweringPlan: false,
90
+ emitHandlerIoLifecyclePlan: false,
91
+ emitRequestJsonBodyPlan: false,
92
+ emitNodeRequestJsonBodyProof: false,
93
+ emitSchemaDecodeResultPlan: false,
94
+ emitNodeSchemaDecodeResultProof: false,
95
+ emitSchemaResponseCodecPlan: false,
96
+ emitNodeSchemaResponseCodecProof: false,
97
+ emitBackendJsonRequestBodyPlan: false,
98
+ emitNodeBackendJsonRequestBodyProof: false,
99
+ emitHostCapabilities: false,
100
+ emitEffectRuntime: false,
101
+ emitEffectComposition: false,
102
+ emitCompiledHandlers: false,
103
+ emitSchemaJsonCompile: false,
104
+ emitSchemaJsonSidecar: false,
105
+ emitSchemaJsonGenericParser: false,
106
+ emitLibrarySidecars: false,
107
+ emitStreamingPassthrough: false,
108
+ emitIntegratedCompiledApp: false,
109
+ emitCompiledWasmRuntime: false,
110
+ emitPulseWrapper: false,
111
+ emitFastlyReadiness: false,
112
+ emitFastlyHostcallBinding: false,
113
+ emitFastlyAdapter: false,
114
+ emitFastlyCommandEntry: false,
115
+ configOnly: false,
116
+ strict: true,
117
+ noStrictRequested: false,
118
+ help: false
119
+ };
120
+
121
+ const tokens = argv.slice();
122
+ if (tokens.length > 0) {
123
+ const first = tokens[0];
124
+ if (BUILD_COMMANDS.has(first)) {
125
+ args.command = 'build';
126
+ tokens.shift();
127
+ } else if (PLAN_COMMANDS.has(first)) {
128
+ args.command = 'plan';
129
+ tokens.shift();
130
+ } else if (DOCTOR_COMMANDS.has(first)) {
131
+ args.command = 'doctor';
132
+ tokens.shift();
133
+ } else if (EXPLAIN_COMMANDS.has(first)) {
134
+ args.command = 'explain';
135
+ tokens.shift();
136
+ } else if (ARTIFACT_COMMANDS.has(first)) {
137
+ args.command = 'artifacts';
138
+ args.artifactsAction = 'list';
139
+ tokens.shift();
140
+ } else if (CONFIG_COMMANDS.has(first)) {
141
+ args.command = 'resolve-config';
142
+ args.configOnly = true;
143
+ tokens.shift();
144
+ }
145
+ }
146
+
147
+ for (let i = 0; i < tokens.length; i += 1) {
148
+ const token = tokens[i];
149
+ if (token === '--help' || token === '-h') {
150
+ args.help = true;
151
+ continue;
152
+ }
153
+ if (token === '--json') {
154
+ args.outputFormat = 'json';
155
+ continue;
156
+ }
157
+ if (token === '--format') {
158
+ args.outputFormat = requireValue(tokens, ++i, token);
159
+ continue;
160
+ }
161
+ if (token.startsWith('--format=')) {
162
+ args.outputFormat = token.slice('--format='.length);
163
+ continue;
164
+ }
165
+ if (token === '--target') {
166
+ args.targetIntent = requireValue(tokens, ++i, token);
167
+ continue;
168
+ }
169
+ if (token.startsWith('--target=')) {
170
+ args.targetIntent = token.slice('--target='.length);
171
+ continue;
172
+ }
173
+ if (token === '--provider') {
174
+ args.providerIntent = requireValue(tokens, ++i, token);
175
+ continue;
176
+ }
177
+ if (token.startsWith('--provider=')) {
178
+ args.providerIntent = token.slice('--provider='.length);
179
+ continue;
180
+ }
181
+ if (token === '--feature' || token === '--features') {
182
+ pushUnique(args.features, splitList(requireValue(tokens, ++i, token)));
183
+ continue;
184
+ }
185
+ if (token.startsWith('--feature=')) {
186
+ pushUnique(args.features, splitList(token.slice('--feature='.length)));
187
+ continue;
188
+ }
189
+ if (token.startsWith('--features=')) {
190
+ pushUnique(args.features, splitList(token.slice('--features='.length)));
191
+ continue;
192
+ }
193
+ if (token === '--diagnostics') {
194
+ args.diagnosticsFile = requireValue(tokens, ++i, token);
195
+ continue;
196
+ }
197
+ if (token.startsWith('--diagnostics=')) {
198
+ args.diagnosticsFile = token.slice('--diagnostics='.length);
199
+ continue;
200
+ }
201
+ if (token === '--manifest') {
202
+ args.manifestFile = requireValue(tokens, ++i, token);
203
+ continue;
204
+ }
205
+ if (token.startsWith('--manifest=')) {
206
+ args.manifestFile = token.slice('--manifest='.length);
207
+ continue;
208
+ }
209
+ if (token === '--ast' || token === '--emit-ast') {
210
+ args.includeAst = true;
211
+ continue;
212
+ }
213
+ if (token === '--emit-dispatch-ts' || token === '--dispatch-ts') {
214
+ args.emitDispatchTs = true;
215
+ continue;
216
+ }
217
+ if (token === '--emit-handler-bindings' || token === '--handler-bindings') {
218
+ args.emitHandlerBindings = true;
219
+ args.emitDispatchTs = true;
220
+ continue;
221
+ }
222
+ if (token === '--emit-execution-harness' || token === '--execution-harness') {
223
+ args.emitExecutionHarness = true;
224
+ args.emitHandlerBindings = true;
225
+ args.emitDispatchTs = true;
226
+ continue;
227
+ }
228
+ if (token === '--emit-assemblyscript-shape' || token === '--assemblyscript-shape' || token === '--emit-as-shape' || token === '--as-shape') {
229
+ args.emitAssemblyScriptShape = true;
230
+ continue;
231
+ }
232
+ if (token === '--emit-assemblyscript-core' || token === '--assemblyscript-core' || token === '--emit-as-core' || token === '--as-core') {
233
+ args.emitAssemblyScriptCore = true;
234
+ args.emitAssemblyScriptShape = true;
235
+ continue;
236
+ }
237
+ if (token === '--emit-assemblyscript-compile' || token === '--assemblyscript-compile' || token === '--emit-as-compile' || token === '--as-compile' || token === '--compile-as') {
238
+ args.emitAssemblyScriptCompile = true;
239
+ args.emitAssemblyScriptCore = true;
240
+ args.emitAssemblyScriptShape = true;
241
+ continue;
242
+ }
243
+ if (token === '--emit-wasm-smoke' || token === '--wasm-smoke' || token === '--emit-assemblyscript-wasm-smoke' || token === '--assemblyscript-wasm-smoke' || token === '--emit-as-wasm-smoke' || token === '--as-wasm-smoke') {
244
+ args.emitWasmSmoke = true;
245
+ args.emitAssemblyScriptCompile = true;
246
+ args.emitAssemblyScriptCore = true;
247
+ args.emitAssemblyScriptShape = true;
248
+ continue;
249
+ }
250
+ if (token === '--emit-local-harness' || token === '--local-harness') {
251
+ args.emitLocalHarness = true;
252
+ args.emitExecutionHarness = true;
253
+ args.emitHandlerBindings = true;
254
+ args.emitDispatchTs = true;
255
+ args.emitAssemblyScriptCore = true;
256
+ args.emitAssemblyScriptShape = true;
257
+ continue;
258
+ }
259
+ if (token === '--emit-wasm-host-abi' || token === '--wasm-host-abi' || token === '--host-abi' || token === '--emit-host-abi') {
260
+ args.emitWasmHostAbi = true;
261
+ continue;
262
+ }
263
+ if (token === '--emit-wasm-host-bridge' || token === '--wasm-host-bridge' || token === '--host-bridge' || token === '--emit-host-bridge') {
264
+ args.emitWasmHostBridge = true;
265
+ args.emitWasmHostAbi = true;
266
+ args.emitAssemblyScriptCore = true;
267
+ args.emitAssemblyScriptShape = true;
268
+ continue;
269
+ }
270
+ if (token === '--emit-request-result-headers' || token === '--request-result-headers' || token === '--headers-adaptor' || token === '--emit-headers-adaptor') {
271
+ args.emitRequestResultHeaders = true;
272
+ args.emitWasmHostAbi = true;
273
+ continue;
274
+ }
275
+ if (token === '--emit-channel-broadcaster' || token === '--channel-broadcaster' || token === '--broadcaster-adaptor' || token === '--emit-broadcaster-adaptor') {
276
+ args.emitChannelBroadcaster = true;
277
+ args.emitRequestResultHeaders = true;
278
+ args.emitWasmHostAbi = true;
279
+ continue;
280
+ }
281
+ if (token === '--emit-json-body' || token === '--json-body' || token === '--emit-body-json' || token === '--body-json') {
282
+ args.emitJsonBody = true;
283
+ args.emitRequestResultHeaders = true;
284
+ args.emitWasmHostAbi = true;
285
+ continue;
286
+ }
287
+ if (token === '--emit-backend-capabilities' || token === '--backend-capabilities' || token === '--emit-ctx-fetch' || token === '--ctx-fetch') {
288
+ args.emitBackendCapabilities = true;
289
+ continue;
290
+ }
291
+ if (token === '--emit-host-runtime-kernel' || token === '--host-runtime-kernel' || token === '--host-runtime' || token === '--emit-host-runtime') {
292
+ args.emitHostRuntimeKernel = true;
293
+ args.emitWasmHostBridge = true;
294
+ args.emitWasmHostAbi = true;
295
+ args.emitAssemblyScriptCore = true;
296
+ args.emitAssemblyScriptShape = true;
297
+ args.emitJsonBody = true;
298
+ args.emitRequestResultHeaders = true;
299
+ args.emitChannelBroadcaster = true;
300
+ args.emitBackendCapabilities = true;
301
+ continue;
302
+ }
303
+ if (token === '--emit-node-adapter' || token === '--node-adapter' || token === '--emit-node-host-adapter' || token === '--node-host-adapter') {
304
+ args.emitNodeAdapter = true;
305
+ args.emitHostRuntimeKernel = true;
306
+ args.emitWasmHostBridge = true;
307
+ args.emitWasmHostAbi = true;
308
+ args.emitAssemblyScriptCore = true;
309
+ args.emitAssemblyScriptShape = true;
310
+ args.emitJsonBody = true;
311
+ args.emitRequestResultHeaders = true;
312
+ args.emitChannelBroadcaster = true;
313
+ args.emitBackendCapabilities = true;
314
+ continue;
315
+ }
316
+ if (token === '--emit-handler-library-contracts' || token === '--handler-library-contracts' || token === '--emit-library-contracts' || token === '--library-contracts') {
317
+ args.emitHandlerLibraryContracts = true;
318
+ continue;
319
+ }
320
+ if (token === '--emit-assets-lowering-plan' || token === '--assets-lowering-plan' || token === '--emit-assets-plan') {
321
+ args.emitAssetsLoweringPlan = true;
322
+ args.emitHandlerLibraryContracts = true;
323
+ continue;
324
+ }
325
+ if (token === '--emit-assets-compiled-wasm-sidecar-plan' || token === '--assets-compiled-wasm-sidecar-plan' || token === '--emit-assets-sidecar-plan') {
326
+ args.emitAssetsCompiledWasmSidecarPlan = true;
327
+ args.emitAssetsLoweringPlan = true;
328
+ args.emitHandlerLibraryContracts = true;
329
+ continue;
330
+ }
331
+ if (token === '--emit-assets-sidecar-compile-link-proof' || token === '--assets-sidecar-compile-link-proof' || token === '--emit-assets-sidecar-link-proof') {
332
+ args.emitAssetsSidecarCompileLinkProof = true;
333
+ args.emitAssetsCompiledWasmSidecarPlan = true;
334
+ args.emitAssetsLoweringPlan = true;
335
+ args.emitHandlerLibraryContracts = true;
336
+ continue;
337
+ }
338
+ if (token === '--emit-node-assets-provider-proof' || token === '--node-assets-provider-proof' || token === '--emit-node-assets-proof') {
339
+ args.emitNodeAssetsProviderProof = true;
340
+ args.emitAssetsLoweringPlan = true;
341
+ args.emitHandlerLibraryContracts = true;
342
+ continue;
343
+ }
344
+ if (token === '--emit-node-compiled-wasm-assets-lifecycle-proof' || token === '--node-compiled-wasm-assets-lifecycle-proof' || token === '--emit-node-compiled-assets-proof') {
345
+ args.emitNodeCompiledWasmAssetsLifecycleProof = true;
346
+ args.emitAssetsCompiledWasmSidecarPlan = true;
347
+ args.emitAssetsLoweringPlan = true;
348
+ args.emitHandlerLibraryContracts = true;
349
+ continue;
350
+ }
351
+ if (token === '--emit-fastly-assets-provider-proof' || token === '--fastly-assets-provider-proof' || token === '--emit-fastly-assets-proof') {
352
+ args.emitFastlyAssetsProviderProof = true;
353
+ args.emitAssetsLoweringPlan = true;
354
+ args.emitHandlerLibraryContracts = true;
355
+ continue;
356
+ }
357
+ if (token === '--emit-fastly-assets-package-out-parity-proof' || token === '--fastly-assets-package-out-parity-proof' || token === '--emit-fastly-assets-package-proof') {
358
+ args.emitFastlyAssetsPackageOutParityProof = true;
359
+ args.emitFastlyAssetsProviderProof = true;
360
+ args.emitAssetsCompiledWasmSidecarPlan = true;
361
+ args.emitAssetsLoweringPlan = true;
362
+ args.emitHandlerLibraryContracts = true;
363
+ continue;
364
+ }
365
+ if (token === '--emit-route-handler-effect-plan' || token === '--route-handler-effect-plan' || token === '--emit-route-handler-effects' || token === '--route-handler-effects' || token === '--emit-route-effects' || token === '--route-effects' || token === '--emit-ctx-resolve-plan' || token === '--ctx-resolve-plan') {
366
+ args.emitRouteHandlerContextLoweringPlan = true;
367
+ args.emitRouteHandlerEffectPlan = true;
368
+ args.emitEffectComposition = true;
369
+ args.emitEffectRuntime = true;
370
+ continue;
371
+ }
372
+ if (token === '--emit-node-route-handler-effect-proof' || token === '--node-route-handler-effect-proof' || token === '--emit-node-route-handler-effects' || token === '--node-route-handler-effects' || token === '--emit-node-route-effects' || token === '--node-route-effects' || token === '--emit-node-ctx-resolve-proof' || token === '--node-ctx-resolve-proof') {
373
+ args.emitNodeRouteHandlerEffectProof = true;
374
+ args.emitRouteHandlerContextLoweringPlan = true;
375
+ args.emitRouteHandlerEffectPlan = true;
376
+ args.emitEffectComposition = true;
377
+ args.emitEffectRuntime = true;
378
+ continue;
379
+ }
380
+ if (token === '--emit-node-live-origin-route-handler-effect-proof' || token === '--node-live-origin-route-handler-effect-proof' || token === '--emit-node-live-origin-route-effects' || token === '--node-live-origin-route-effects' || token === '--emit-node-live-origin-ctx-resolve-proof' || token === '--node-live-origin-ctx-resolve-proof') {
381
+ args.emitNodeLiveOriginRouteHandlerEffectProof = true;
382
+ args.emitRouteHandlerContextLoweringPlan = true;
383
+ args.emitRouteHandlerEffectPlan = true;
384
+ args.emitEffectComposition = true;
385
+ args.emitEffectRuntime = true;
386
+ continue;
387
+ }
388
+ if (token === '--emit-node-compiled-route-handler-effect-bridge' || token === '--node-compiled-route-handler-effect-bridge' || token === '--emit-node-compiled-route-effects' || token === '--node-compiled-route-effects' || token === '--emit-node-compiled-ctx-resolve-bridge' || token === '--node-compiled-ctx-resolve-bridge') {
389
+ args.emitNodeCompiledRouteHandlerEffectBridge = true;
390
+ args.emitRouteHandlerContextLoweringPlan = true;
391
+ args.emitRouteHandlerEffectPlan = true;
392
+ args.emitEffectComposition = true;
393
+ args.emitEffectRuntime = true;
394
+ args.emitCompiledHandlers = true;
395
+ args.emitAssemblyScriptCore = true;
396
+ args.emitAssemblyScriptShape = true;
397
+ continue;
398
+ }
399
+ if (token === '--emit-fastly-route-handler-effect-proof' || token === '--fastly-route-handler-effect-proof' || token === '--emit-fastly-route-handler-effects' || token === '--fastly-route-handler-effects' || token === '--emit-fastly-route-effects' || token === '--fastly-route-effects' || token === '--emit-fastly-ctx-resolve-proof' || token === '--fastly-ctx-resolve-proof') {
400
+ args.emitFastlyRouteHandlerEffectProof = true;
401
+ args.emitRouteHandlerContextLoweringPlan = true;
402
+ args.emitRouteHandlerEffectPlan = true;
403
+ args.emitEffectComposition = true;
404
+ args.emitEffectRuntime = true;
405
+ continue;
406
+ }
407
+ if (token === '--emit-route-handler-context-lowering' || token === '--route-handler-context-lowering' || token === '--emit-route-handler-context-plan' || token === '--route-handler-context-plan' || token === '--emit-context-lowering' || token === '--context-lowering' || token === '--emit-ctx-lowering' || token === '--ctx-lowering' || token === '--sync-context') {
408
+ args.emitRouteHandlerContextLoweringPlan = true;
409
+ continue;
410
+ }
411
+ if (token === '--emit-handler-io-lifecycle-plan' || token === '--handler-io-lifecycle-plan' || token === '--emit-handler-io-lifecycle' || token === '--handler-io-lifecycle' || token === '--emit-handler-io' || token === '--handler-io' || token === '--io-lifecycle') {
412
+ args.emitHandlerIoLifecyclePlan = true;
413
+ args.emitRouteHandlerContextLoweringPlan = true;
414
+ args.emitRouteHandlerEffectPlan = true;
415
+ args.emitEffectComposition = true;
416
+ args.emitEffectRuntime = true;
417
+ continue;
418
+ }
419
+ if (token === '--emit-request-json-body-plan' || token === '--request-json-body-plan' || token === '--emit-request-json-body' || token === '--request-json-body' || token === '--emit-ctx-req-json' || token === '--ctx-req-json') {
420
+ args.emitRequestJsonBodyPlan = true;
421
+ args.emitSchemaJsonSidecar = true;
422
+ args.emitJsonBody = true;
423
+ args.emitRequestResultHeaders = true;
424
+ args.emitRouteHandlerContextLoweringPlan = true;
425
+ continue;
426
+ }
427
+ if (token === '--emit-node-request-json-body-proof' || token === '--node-request-json-body-proof' || token === '--emit-node-ctx-req-json-proof' || token === '--node-ctx-req-json-proof') {
428
+ args.emitNodeRequestJsonBodyProof = true;
429
+ args.emitRequestJsonBodyPlan = true;
430
+ args.emitSchemaJsonSidecar = true;
431
+ args.emitJsonBody = true;
432
+ args.emitRequestResultHeaders = true;
433
+ args.emitRouteHandlerContextLoweringPlan = true;
434
+ args.emitCompiledHandlers = true;
435
+ args.emitAssemblyScriptCore = true;
436
+ args.emitAssemblyScriptShape = true;
437
+ continue;
438
+ }
439
+ if (token === '--emit-schema-decode-result-plan' || token === '--schema-decode-result-plan' || token === '--emit-schema-decode-result' || token === '--schema-decode-result' || token === '--emit-ctx-req-json-schema' || token === '--ctx-req-json-schema') {
440
+ args.emitSchemaDecodeResultPlan = true;
441
+ args.emitRequestJsonBodyPlan = true;
442
+ args.emitSchemaJsonSidecar = true;
443
+ args.emitJsonBody = true;
444
+ args.emitRequestResultHeaders = true;
445
+ args.emitRouteHandlerContextLoweringPlan = true;
446
+ continue;
447
+ }
448
+ if (token === '--emit-node-schema-decode-result-proof' || token === '--node-schema-decode-result-proof' || token === '--emit-node-ctx-req-json-schema-proof' || token === '--node-ctx-req-json-schema-proof') {
449
+ args.emitNodeSchemaDecodeResultProof = true;
450
+ args.emitSchemaDecodeResultPlan = true;
451
+ args.emitRequestJsonBodyPlan = true;
452
+ args.emitSchemaJsonSidecar = true;
453
+ args.emitJsonBody = true;
454
+ args.emitRequestResultHeaders = true;
455
+ args.emitRouteHandlerContextLoweringPlan = true;
456
+ args.emitCompiledHandlers = true;
457
+ args.emitAssemblyScriptCore = true;
458
+ args.emitAssemblyScriptShape = true;
459
+ continue;
460
+ }
461
+ if (token === '--emit-schema-response-codec-plan' || token === '--schema-response-codec-plan' || token === '--emit-schema-response-codec' || token === '--schema-response-codec' || token === '--emit-ctx-result-json-schema' || token === '--ctx-result-json-schema') {
462
+ args.emitSchemaResponseCodecPlan = true;
463
+ args.emitSchemaDecodeResultPlan = true;
464
+ args.emitRequestJsonBodyPlan = true;
465
+ args.emitSchemaJsonSidecar = true;
466
+ args.emitJsonBody = true;
467
+ args.emitRequestResultHeaders = true;
468
+ args.emitRouteHandlerContextLoweringPlan = true;
469
+ args.emitRouteHandlerEffectPlan = true;
470
+ continue;
471
+ }
472
+ if (token === '--emit-node-schema-response-codec-proof' || token === '--node-schema-response-codec-proof' || token === '--emit-node-ctx-result-json-schema-proof' || token === '--node-ctx-result-json-schema-proof') {
473
+ args.emitNodeSchemaResponseCodecProof = true;
474
+ args.emitSchemaResponseCodecPlan = true;
475
+ args.emitSchemaDecodeResultPlan = true;
476
+ args.emitRequestJsonBodyPlan = true;
477
+ args.emitSchemaJsonSidecar = true;
478
+ args.emitJsonBody = true;
479
+ args.emitRequestResultHeaders = true;
480
+ args.emitRouteHandlerContextLoweringPlan = true;
481
+ args.emitRouteHandlerEffectPlan = true;
482
+ args.emitCompiledHandlers = true;
483
+ args.emitAssemblyScriptCore = true;
484
+ args.emitAssemblyScriptShape = true;
485
+ continue;
486
+ }
487
+ if (token === '--emit-backend-json-request-body-plan' || token === '--backend-json-request-body-plan' || token === '--emit-backend-json-request-body' || token === '--backend-json-request-body' || token === '--emit-fetch-json-body' || token === '--fetch-json-body' || token === '--ctx-fetch-json') {
488
+ args.emitBackendJsonRequestBodyPlan = true;
489
+ args.emitSchemaResponseCodecPlan = true;
490
+ args.emitSchemaDecodeResultPlan = true;
491
+ args.emitRequestJsonBodyPlan = true;
492
+ args.emitSchemaJsonSidecar = true;
493
+ args.emitJsonBody = true;
494
+ args.emitRequestResultHeaders = true;
495
+ args.emitRouteHandlerContextLoweringPlan = true;
496
+ args.emitRouteHandlerEffectPlan = true;
497
+ continue;
498
+ }
499
+ if (token === '--emit-node-backend-json-request-body-proof' || token === '--node-backend-json-request-body-proof' || token === '--emit-node-backend-json-request-body' || token === '--node-backend-json-request-body' || token === '--emit-node-fetch-json-body-proof' || token === '--node-fetch-json-body-proof') {
500
+ args.emitNodeBackendJsonRequestBodyProof = true;
501
+ args.emitBackendJsonRequestBodyPlan = true;
502
+ args.emitSchemaResponseCodecPlan = true;
503
+ args.emitSchemaDecodeResultPlan = true;
504
+ args.emitRequestJsonBodyPlan = true;
505
+ args.emitSchemaJsonSidecar = true;
506
+ args.emitJsonBody = true;
507
+ args.emitRequestResultHeaders = true;
508
+ args.emitRouteHandlerContextLoweringPlan = true;
509
+ args.emitRouteHandlerEffectPlan = true;
510
+ continue;
511
+ }
512
+ if (token === '--emit-fastly-lifecycle-parity-proof' || token === '--fastly-lifecycle-parity-proof' || token === '--emit-fastly-lifecycle-parity' || token === '--fastly-lifecycle-parity' || token === '--fastly-provider-lifecycle' || token === '--fastly-reference-lifecycle') {
513
+ args.emitFastlyLifecycleParityProof = true;
514
+ args.emitBackendJsonRequestBodyPlan = true;
515
+ args.emitHandlerIoLifecyclePlan = true;
516
+ args.emitSchemaResponseCodecPlan = true;
517
+ args.emitSchemaDecodeResultPlan = true;
518
+ args.emitRequestJsonBodyPlan = true;
519
+ args.emitSchemaJsonSidecar = true;
520
+ args.emitJsonBody = true;
521
+ args.emitRequestResultHeaders = true;
522
+ args.emitRouteHandlerContextLoweringPlan = true;
523
+ args.emitRouteHandlerEffectPlan = true;
524
+ args.emitEffectComposition = true;
525
+ args.emitEffectRuntime = true;
526
+ continue;
527
+ }
528
+ if (token === '--emit-host-capabilities' || token === '--host-capabilities' || token === '--emit-wasi-provider-map' || token === '--wasi-provider-map') {
529
+ args.emitHostCapabilities = true;
530
+ args.emitHandlerLibraryContracts = true;
531
+ args.emitRequestResultHeaders = true;
532
+ args.emitChannelBroadcaster = true;
533
+ args.emitJsonBody = true;
534
+ args.emitBackendCapabilities = true;
535
+ args.emitWasmHostAbi = true;
536
+ continue;
537
+ }
538
+ if (token === '--emit-effect-runtime' || token === '--effect-runtime' || token === '--emit-effects' || token === '--effects') {
539
+ args.emitEffectRuntime = true;
540
+ args.emitRouteHandlerContextLoweringPlan = true;
541
+ args.emitRouteHandlerEffectPlan = true;
542
+ args.emitHostCapabilities = true;
543
+ args.emitHandlerLibraryContracts = true;
544
+ args.emitRequestResultHeaders = true;
545
+ args.emitChannelBroadcaster = true;
546
+ args.emitJsonBody = true;
547
+ args.emitBackendCapabilities = true;
548
+ args.emitWasmHostAbi = true;
549
+ continue;
550
+ }
551
+ if (token === '--emit-effect-composition' || token === '--effect-composition' || token === '--emit-effect-continuations' || token === '--effect-continuations') {
552
+ args.emitEffectComposition = true;
553
+ args.emitRouteHandlerContextLoweringPlan = true;
554
+ args.emitRouteHandlerEffectPlan = true;
555
+ args.emitEffectRuntime = true;
556
+ args.emitHostCapabilities = true;
557
+ args.emitHandlerLibraryContracts = true;
558
+ args.emitRequestResultHeaders = true;
559
+ args.emitChannelBroadcaster = true;
560
+ args.emitJsonBody = true;
561
+ args.emitBackendCapabilities = true;
562
+ args.emitWasmHostAbi = true;
563
+ continue;
564
+ }
565
+ if (token === '--emit-compiled-handlers' || token === '--compiled-handlers' || token === '--emit-compiled-user-handlers' || token === '--compiled-user-handlers') {
566
+ args.emitCompiledHandlers = true;
567
+ args.emitRouteHandlerContextLoweringPlan = true;
568
+ args.emitAssemblyScriptCore = true;
569
+ args.emitAssemblyScriptShape = true;
570
+ continue;
571
+ }
572
+ if (token === '--emit-schema-json-compile' || token === '--schema-json-compile') {
573
+ args.emitSchemaJsonCompile = true;
574
+ args.emitJsonBody = true;
575
+ args.emitWasmHostAbi = true;
576
+ continue;
577
+ }
578
+ if (token === '--emit-schema-json-sidecar' || token === '--schema-json-sidecar' || token === '--emit-schema-json' || token === '--schema-json') {
579
+ args.emitSchemaJsonSidecar = true;
580
+ args.emitJsonBody = true;
581
+ args.emitWasmHostAbi = true;
582
+ continue;
583
+ }
584
+ if (token === '--emit-schema-json-generic-parser' || token === '--schema-json-generic-parser' || token === '--emit-schema-json-parser' || token === '--schema-json-parser' || token === '--emit-as-json-parser' || token === '--as-json-parser') {
585
+ args.emitSchemaJsonGenericParser = true;
586
+ args.emitJsonBody = true;
587
+ args.emitWasmHostAbi = true;
588
+ continue;
589
+ }
590
+ if (token === '--emit-library-sidecars' || token === '--library-sidecars' || token === '--emit-sidecar-consumption' || token === '--sidecar-consumption') {
591
+ args.emitLibrarySidecars = true;
592
+ args.emitHandlerLibraryContracts = true;
593
+ continue;
594
+ }
595
+ if (token === '--emit-streaming-passthrough' || token === '--streaming-passthrough' || token === '--emit-stream-result' || token === '--stream-result') {
596
+ args.emitStreamingPassthrough = true;
597
+ args.emitNodeAdapter = true;
598
+ args.emitHostRuntimeKernel = true;
599
+ args.emitWasmHostBridge = true;
600
+ args.emitWasmHostAbi = true;
601
+ args.emitRequestResultHeaders = true;
602
+ args.emitJsonBody = true;
603
+ args.emitChannelBroadcaster = true;
604
+ args.emitBackendCapabilities = true;
605
+ args.emitAssemblyScriptCore = true;
606
+ args.emitAssemblyScriptShape = true;
607
+ continue;
608
+ }
609
+ if (token === '--emit-integrated-compiled-app' || token === '--integrated-compiled-app' || token === '--emit-integrated-smoke' || token === '--integrated-smoke') {
610
+ args.emitIntegratedCompiledApp = true;
611
+ args.emitAssemblyScriptCore = true;
612
+ args.emitAssemblyScriptShape = true;
613
+ args.emitSchemaJsonSidecar = true;
614
+ args.emitLibrarySidecars = true;
615
+ args.emitJsonBody = true;
616
+ args.emitWasmHostAbi = true;
617
+ args.emitHandlerLibraryContracts = true;
618
+ continue;
619
+ }
620
+ if (token === '--emit-compiled-wasm-runtime' || token === '--compiled-wasm-runtime' || token === '--emit-local-compiled-wasm-runtime' || token === '--local-compiled-wasm-runtime') {
621
+ args.emitCompiledWasmRuntime = true;
622
+ args.emitIntegratedCompiledApp = true;
623
+ args.emitAssemblyScriptCore = true;
624
+ args.emitAssemblyScriptShape = true;
625
+ args.emitSchemaJsonSidecar = true;
626
+ args.emitLibrarySidecars = true;
627
+ args.emitJsonBody = true;
628
+ args.emitWasmHostAbi = true;
629
+ args.emitHandlerLibraryContracts = true;
630
+ continue;
631
+ }
632
+ if (token === '--emit-pulse-wrapper' || token === '--pulse-wrapper' || token === '--emit-wrapper-integration' || token === '--wrapper-integration') {
633
+ args.emitPulseWrapper = true;
634
+ args.emitCompiledWasmRuntime = true;
635
+ args.emitIntegratedCompiledApp = true;
636
+ args.emitAssemblyScriptCore = true;
637
+ args.emitAssemblyScriptShape = true;
638
+ args.emitSchemaJsonSidecar = true;
639
+ args.emitLibrarySidecars = true;
640
+ args.emitJsonBody = true;
641
+ args.emitWasmHostAbi = true;
642
+ args.emitHandlerLibraryContracts = true;
643
+ continue;
644
+ }
645
+ if (token === '--emit-fastly-hostcall-binding' || token === '--fastly-hostcall-binding' || token === '--emit-fastly-binding-contract' || token === '--fastly-binding-contract' || token === '--emit-fastly-hostcalls' || token === '--fastly-hostcalls') {
646
+ args.emitFastlyHostcallBinding = true;
647
+ args.emitFastlyReadiness = true;
648
+ args.emitPulseWrapper = true;
649
+ args.emitCompiledWasmRuntime = true;
650
+ args.emitIntegratedCompiledApp = true;
651
+ args.emitAssemblyScriptCore = true;
652
+ args.emitAssemblyScriptShape = true;
653
+ args.emitSchemaJsonSidecar = true;
654
+ args.emitLibrarySidecars = true;
655
+ args.emitJsonBody = true;
656
+ args.emitWasmHostAbi = true;
657
+ args.emitHandlerLibraryContracts = true;
658
+ args.emitHostCapabilities = true;
659
+ args.emitEffectComposition = true;
660
+ continue;
661
+ }
662
+ if (token === '--emit-fastly-adapter' || token === '--fastly-adapter' || token === '--emit-fastly-stream-header-adapter' || token === '--fastly-stream-header-adapter') {
663
+ args.emitFastlyAdapter = true;
664
+ args.emitFastlyHostcallBinding = true;
665
+ args.emitFastlyReadiness = true;
666
+ args.emitPulseWrapper = true;
667
+ args.emitCompiledWasmRuntime = true;
668
+ args.emitIntegratedCompiledApp = true;
669
+ args.emitAssemblyScriptCore = true;
670
+ args.emitAssemblyScriptShape = true;
671
+ args.emitSchemaJsonSidecar = true;
672
+ args.emitLibrarySidecars = true;
673
+ args.emitJsonBody = true;
674
+ args.emitWasmHostAbi = true;
675
+ args.emitHandlerLibraryContracts = true;
676
+ args.emitHostCapabilities = true;
677
+ args.emitEffectComposition = true;
678
+ continue;
679
+ }
680
+ if (token === '--emit-fastly-command-entry' || token === '--fastly-command-entry' || token === '--emit-fastly-start' || token === '--fastly-start' || token === '--emit-fastly-command' || token === '--fastly-command') {
681
+ args.emitFastlyCommandEntry = true;
682
+ args.emitFastlyAdapter = true;
683
+ args.emitFastlyHostcallBinding = true;
684
+ args.emitFastlyReadiness = true;
685
+ args.emitPulseWrapper = true;
686
+ args.emitCompiledWasmRuntime = true;
687
+ args.emitIntegratedCompiledApp = true;
688
+ args.emitAssemblyScriptCore = true;
689
+ args.emitAssemblyScriptShape = true;
690
+ args.emitSchemaJsonSidecar = true;
691
+ args.emitLibrarySidecars = true;
692
+ args.emitJsonBody = true;
693
+ args.emitWasmHostAbi = true;
694
+ args.emitHandlerLibraryContracts = true;
695
+ args.emitHostCapabilities = true;
696
+ args.emitEffectComposition = true;
697
+ continue;
698
+ }
699
+ if (token === '--emit-fastly-readiness' || token === '--fastly-readiness' || token === '--emit-fastly-audit' || token === '--fastly-audit') {
700
+ args.emitFastlyReadiness = true;
701
+ args.emitPulseWrapper = true;
702
+ args.emitCompiledWasmRuntime = true;
703
+ args.emitIntegratedCompiledApp = true;
704
+ args.emitAssemblyScriptCore = true;
705
+ args.emitAssemblyScriptShape = true;
706
+ args.emitSchemaJsonSidecar = true;
707
+ args.emitLibrarySidecars = true;
708
+ args.emitJsonBody = true;
709
+ args.emitWasmHostAbi = true;
710
+ args.emitHandlerLibraryContracts = true;
711
+ args.emitHostCapabilities = true;
712
+ args.emitEffectComposition = true;
713
+ continue;
714
+ }
715
+ if (token === '--strict') {
716
+ args.strict = true;
717
+ continue;
718
+ }
719
+ if (token === '--no-strict') {
720
+ args.strict = false;
721
+ args.noStrictRequested = true;
722
+ continue;
723
+ }
724
+ if (token === '--config-only') {
725
+ args.configOnly = true;
726
+ args.command = 'resolve-config';
727
+ continue;
728
+ }
729
+ if (token === '--config' || token === '-c') {
730
+ args.config = requireValue(tokens, ++i, token);
731
+ continue;
732
+ }
733
+ if (token.startsWith('--config=')) {
734
+ args.config = token.slice('--config='.length);
735
+ continue;
736
+ }
737
+ if (token === '--profile' || token === '-p') {
738
+ args.profile = requireValue(tokens, ++i, token);
739
+ continue;
740
+ }
741
+ if (token.startsWith('--profile=')) {
742
+ args.profile = token.slice('--profile='.length);
743
+ continue;
744
+ }
745
+ if (token === '--env') {
746
+ const [name, value] = parseEnvAssignment(requireValue(tokens, ++i, token));
747
+ args.env[name] = value;
748
+ continue;
749
+ }
750
+ if (token.startsWith('--env=')) {
751
+ const [name, value] = parseEnvAssignment(token.slice('--env='.length));
752
+ args.env[name] = value;
753
+ continue;
754
+ }
755
+ if (token === '--out' || token === '-o') {
756
+ args.outDir = requireValue(tokens, ++i, token);
757
+ args.outDirExplicit = true;
758
+ continue;
759
+ }
760
+ if (token.startsWith('--out=')) {
761
+ args.outDir = token.slice('--out='.length);
762
+ args.outDirExplicit = true;
763
+ continue;
764
+ }
765
+ if (token === '--root' || token === '-r') {
766
+ args.root = requireValue(tokens, ++i, token);
767
+ continue;
768
+ }
769
+ if (token.startsWith('--root=')) {
770
+ args.root = token.slice('--root='.length);
771
+ continue;
772
+ }
773
+ if (!token.startsWith('-')) {
774
+ if (args.command === 'explain') {
775
+ if (!args.diagnosticsFile) {
776
+ args.diagnosticsFile = token;
777
+ continue;
778
+ }
779
+ throw new Error(`Unexpected explain argument: ${token}`);
780
+ }
781
+ if (args.command === 'artifacts') {
782
+ if (!args.artifactsAction || args.artifactsAction === 'list') {
783
+ args.artifactsAction = token;
784
+ continue;
785
+ }
786
+ throw new Error(`Unexpected artifacts argument: ${token}`);
787
+ }
788
+ if (!args.entry) {
789
+ args.entry = token;
790
+ continue;
791
+ }
792
+ }
793
+ throw new Error(`Unexpected argument: ${token}`);
794
+ }
795
+
796
+ if (args.command === 'artifacts' && !args.artifactsAction) args.artifactsAction = 'list';
797
+ if (args.command === 'artifacts' && args.artifactsAction !== 'list') {
798
+ throw new Error(`Unsupported artifacts action "${args.artifactsAction}". Expected "list".`);
799
+ }
800
+ if (args.outputFormat !== 'text' && args.outputFormat !== 'json') {
801
+ throw new Error(`Unsupported --format value "${args.outputFormat}". Expected text or json.`);
802
+ }
803
+
804
+ return applyCliIntent(args);
805
+ }
806
+
807
+ function usage() {
808
+ return `PulseWasm CLI
809
+
810
+ Usage:
811
+ pulsewasm plan <entry.js|entry.ts> [--root app] [--out .pulsewasm] [--features assets,route-context,route-effects,handler-io] [--target wasm] [--provider none|node|fastly]
812
+ pulsewasm plan --config pulse.config.ts [--profile edge] [--env NAME=value] [--out .pulsewasm] [--features assets,route-context,route-effects,handler-io]
813
+ pulsewasm build <entry.js|entry.ts> [--root app] [--out .pulsewasm] [--target js|wasm|wasm-smoke] [--provider none|node|fastly] [--features assets,schema,route-context,route-effects,handler-io]
814
+ pulsewasm build --config pulse.config.ts [--profile edge] [--env NAME=value] [--out .pulsewasm] [--target js|wasm|wasm-smoke] [--provider none|node|fastly]
815
+ pulsewasm doctor <entry.js|entry.ts> [--root app] [--out .pulsewasm] [--target wasm] [--provider none|node|fastly]
816
+ pulsewasm doctor --config pulse.config.ts [--profile edge] [--env NAME=value] [--out .pulsewasm]
817
+ pulsewasm explain [diagnostics.json|--diagnostics diagnostics.json] [--format text|json]
818
+ pulsewasm artifacts list [--out .pulsewasm|--manifest build-manifest.json] [--format text|json]
819
+ pulsewasm resolve-config --config pulse.config.ts [--profile edge] [--env NAME=value] [--out .pulsewasm]
820
+
821
+ Compatibility:
822
+ pulsewasm-extract is still supported and accepts the same commands.
823
+ Existing low-level --emit-* flags remain available as debug/test escapes.
824
+ Backward-compatible build aliases still work:
825
+ pulsewasm-extract <entry.js|entry.ts> [--root app] [--out artifacts] [--ast]
826
+ pulsewasm-extract --config pulse.config.ts --config-only [--profile edge] [--env NAME=value]
827
+
828
+ Intent presets:
829
+ plan emits route metadata plus package/lifecycle plans, including ctx.resolve route-effect plans; no provider proof is emitted unless requested explicitly.
830
+ build preserves the existing build gatekeeper and can add --target/--provider/--features presets.
831
+ doctor runs the plan-oriented checks and writes cli-doctor.json with user-actionable status.
832
+ explain groups diagnostics by severity/code for humans or JSON tools.
833
+ artifacts list prints artifact producer ownership and why each artifact exists.
834
+
835
+ Preset options:
836
+ --target js emit TypeScript dispatch metadata.
837
+ --target wasm emit AssemblyScript/Wasm planning metadata, without forcing a Wasm smoke compile.
838
+ --target wasm-smoke opt into the AS/Wasm smoke compile path.
839
+ --provider node include provider-relevant host capability metadata without forcing Node provider proof/runtime output.
840
+ --provider fastly include provider-relevant host capability metadata without forcing Fastly provider proof/runtime output.
841
+ --features route-context emit route-handler-context-lowering-plan.json for the synchronous ctx surface.
842
+ --features route-effects emit ctx.resolve/ctx.fetch route-handler-effect-plan.json without provider execution.
843
+ --features handler-io emit handler-io-lifecycle-plan.json unifying ctx, request body, backend/origin, schema, and response posture.
844
+ --features request-json emit request-json-body-plan.json for lazy ctx.req.json/parse request body reads.
845
+ --features schema-decode-result emit schema-decode-result-plan.json for ctx.req.json("Schema") accessor validation.
846
+ --features schema-response-codec emit schema-response-codec-plan.json for ctx.result.json("Schema", ref) and ctx.resolved().json("Schema").
847
+ --features node-request-json-body-proof emits the Node compiled-Wasm proof for lazy ctx.req.json body reads.
848
+ --features node-schema-decode-result-proof emits the Node compiled-Wasm proof for schema-backed ctx.req.json("Schema") decode results.
849
+ --features node-schema-response-codec-proof emits the Node compiled-Wasm proof for schema-backed ctx.result.json("Schema", ref).
850
+ --features node-route-handler-effect-proof emits the Node local fixture proof that consumes route-handler-effect-plan.json.
851
+ --features node-live-origin-route-handler-effect-proof emits a Node proof that performs real local HTTP origin GET/HEAD using configured backend baseUrl values.
852
+ --features node-compiled-route-handler-effect-bridge emits a compiled-Wasm Node resolve/resume bridge proof over live-origin fetches.
853
+ --features fastly-route-handler-effect-proof emits the Fastly symbolic-backend fixture proof that consumes route-handler-effect-plan.json.
854
+ --features fastly-lifecycle-parity-proof emits the Fastly reference lifecycle parity/classification proof.
855
+ --features assets-compiled-wasm-sidecar emit assets-compiled-wasm-sidecar-plan.json for package-owned AS sidecar readiness.
856
+ --features node-compiled-wasm-assets-lifecycle-proof emits the Node compiled-Wasm terminal assets lifecycle proof.
857
+ --features fastly-assets-package-out-parity-proof emits the Fastly assets package-out parity/readiness proof.
858
+ --features LIST add comma-separated feature presets. Known features: ${knownFeatures().join(', ')}.
859
+
860
+ Core outputs:
861
+ build-manifest.json deterministic build manifest, artifact hashes, pass list, status
862
+ diagnostics.json deterministic diagnostics envelope
863
+ route-plan.json flattened deterministic PulseWasm route plan
864
+ handler-table.json resolved handler/function table with stable handler IDs
865
+ execution-plan.json runtime-parity ordered entry scanner metadata
866
+ assets-lowering-plan.json optional package-owned pulse.assets validate-and-plan artifact
867
+ assets-compiled-wasm-sidecar-plan.json optional package-owned pulse.assets AS sidecar readiness artifact
868
+ node-compiled-wasm-assets-lifecycle-proof.json optional Pass 49 Node compiled-Wasm terminal assets lifecycle proof
869
+ fastly-assets-package-out-parity-proof.json optional Pass 50 Fastly package-out assets parity proof
870
+ route-handler-context-lowering-plan.json optional Pass 31 synchronous ctx lowering plan artifact
871
+ route-handler-effect-plan.json optional ctx.resolve/ctx.fetch lifecycle plan artifact
872
+ handler-io-lifecycle-plan.json optional Pass 36 unified handler I/O lifecycle plan artifact
873
+ request-json-body-plan.json optional Pass 39 lazy request JSON body plan artifact
874
+ schema-decode-result-plan.json optional Pass 40 schema-backed decode result plan artifact
875
+ schema-response-codec-plan.json optional Pass 41 schema-backed response/origin codec plan artifact
876
+ node-request-json-body-proof.json optional Pass 39 Node compiled-Wasm proof for ctx.req.json
877
+ node-schema-decode-result-proof.json optional Pass 40 Node compiled-Wasm proof for ctx.req.json("Schema")
878
+ node-schema-response-codec-proof.json optional Pass 41 Node compiled-Wasm proof for ctx.result.json("Schema", ref)
879
+ schema-json-generic-parser.json optional generic AS JSON parser fallback artifact
880
+ node-route-handler-effect-proof.json optional Node provider-owned proof for planned ctx.fetch effects
881
+ node-live-origin-route-handler-effect-proof.json optional Node provider-owned live-origin HTTP proof for planned ctx.fetch effects
882
+ node-compiled-route-handler-effect-bridge.json optional Node compiled-Wasm resolve/resume bridge proof for planned ctx.fetch effects
883
+ fastly-route-handler-effect-proof.json optional Fastly provider-owned proof for planned ctx.fetch effects
884
+ cli-doctor.json optional doctor summary when using the doctor intent
885
+
886
+ Examples:
887
+ pulsewasm plan --config ./examples/integrated.config.js --profile edge --out ./.pulsewasm
888
+ pulsewasm build --config ./examples/integrated.config.js --profile edge --target wasm --provider node --features assets,route-effects,handler-io --out ./.pulsewasm
889
+ pulsewasm doctor --config ./examples/integrated.config.js --profile edge --out ./.pulsewasm
890
+ pulsewasm explain ./.pulsewasm/diagnostics.json
891
+ pulsewasm artifacts list --out ./.pulsewasm
892
+ `;
893
+ }
894
+ function jsonText(value) {
895
+ return `${JSON.stringify(value, null, 2)}\n`;
896
+ }
897
+
898
+ function artifactName(outDir, filePath) {
899
+ const rel = path.relative(outDir, filePath).replace(/\\/g, '/');
900
+ return rel && !rel.startsWith('..') && !path.isAbsolute(rel) ? rel : path.basename(filePath);
901
+ }
902
+
903
+ function writeJson(filePath, value, artifactRecords, outDir = path.dirname(filePath)) {
904
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
905
+ const text = jsonText(value);
906
+ fs.writeFileSync(filePath, text, 'utf8');
907
+ if (artifactRecords) {
908
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, filePath), value, text));
909
+ }
910
+ return text;
911
+ }
912
+
913
+ function writeText(filePath, text, artifactRecords, outDir = path.dirname(filePath)) {
914
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
915
+ fs.writeFileSync(filePath, text, 'utf8');
916
+ if (artifactRecords) {
917
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, filePath), undefined, text));
918
+ }
919
+ return text;
920
+ }
921
+
922
+ function writeDiagnostics(outDir, envelope, artifactRecords) {
923
+ writeJson(path.join(outDir, 'diagnostics.json'), envelope, artifactRecords, outDir);
924
+ }
925
+
926
+ function readJsonFile(filePath) {
927
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
928
+ }
929
+
930
+ function resolveCliInput(cwd, filePath) {
931
+ return path.resolve(cwd, filePath);
932
+ }
933
+
934
+ const PULSE_CONFIG_CANDIDATES = ['pulse.config.js', 'pulse.config.cjs', 'pulse.config.mjs', 'pulse.config.ts', 'pulse.config.mts', 'pulse.config.cts'];
935
+
936
+ function discoverSiblingConfigForEntry(cwd, entryArg) {
937
+ if (!entryArg) return undefined;
938
+ const entryAbs = path.resolve(cwd, entryArg);
939
+ const dir = path.dirname(entryAbs);
940
+ for (const name of PULSE_CONFIG_CANDIDATES) {
941
+ const candidate = path.join(dir, name);
942
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
943
+ }
944
+ return undefined;
945
+ }
946
+
947
+ function resolveEntryPath(cwd, entryArg, configDir, entryCameFromConfig) {
948
+ if (path.isAbsolute(entryArg)) return entryArg;
949
+ if (entryCameFromConfig && configDir) {
950
+ const configRelative = path.resolve(configDir, entryArg);
951
+ if (fs.existsSync(configRelative)) return configRelative;
952
+ }
953
+ return path.resolve(cwd, entryArg);
954
+ }
955
+
956
+ function formatExplainText(explanation) {
957
+ const lines = [];
958
+ lines.push('PulseWasm diagnostics explanation');
959
+ lines.push(` source: ${explanation.source}`);
960
+ lines.push(` status: ${explanation.status}`);
961
+ lines.push(` diagnostics: ${explanation.counts?.total || 0} (${explanation.counts?.error || 0} error, ${explanation.counts?.warning || 0} warning, ${explanation.counts?.info || 0} info)`);
962
+ if (!explanation.groups || explanation.groups.length === 0) {
963
+ lines.push(' No diagnostics found.');
964
+ return `${lines.join('\n')}\n`;
965
+ }
966
+ for (const group of explanation.groups) {
967
+ lines.push(`\n${group.severity.toUpperCase()} ${group.code} (${group.count})`);
968
+ for (const message of group.messages || []) {
969
+ lines.push(` - ${message}`);
970
+ }
971
+ }
972
+ return `${lines.join('\n')}\n`;
973
+ }
974
+
975
+ function formatArtifactsText(list) {
976
+ const lines = [];
977
+ lines.push('PulseWasm artifacts');
978
+ lines.push(` manifest: ${list.source}`);
979
+ lines.push(` status: ${list.status}`);
980
+ if (list.command) lines.push(` command: ${list.command}`);
981
+ if (list.outDir) lines.push(` outDir: ${list.outDir}`);
982
+ lines.push(` artifacts: ${list.artifactCount}`);
983
+ for (const artifact of list.artifacts || []) {
984
+ const version = artifact.version ? ` [${artifact.version}]` : '';
985
+ lines.push(`\n- ${artifact.file}${version}`);
986
+ lines.push(` producer: ${artifact.producer}`);
987
+ lines.push(` why: ${artifact.why}`);
988
+ if (artifact.bytes !== undefined) lines.push(` bytes: ${artifact.bytes}`);
989
+ }
990
+ return `${lines.join('\n')}\n`;
991
+ }
992
+
993
+ function writeDoctor(outDir, args, diagnostics, result, resolvedConfig, artifactRecords) {
994
+ const doctor = createDoctorArtifact({ args, diagnostics, result, resolvedConfig });
995
+ writeJson(path.join(outDir, 'cli-doctor.json'), doctor, artifactRecords, outDir);
996
+ return doctor;
997
+ }
998
+
999
+ function withConfigPass(diagnostics, resolvedConfig, cwd) {
1000
+ if (!resolvedConfig) return diagnostics;
1001
+ const pass = {
1002
+ name: 'config-resolve',
1003
+ status: 'ok',
1004
+ summary: {
1005
+ profile: resolvedConfig.profile || resolvedConfig.selectedProfile,
1006
+ entry: resolvedConfig.entry,
1007
+ rootRouter: resolvedConfig.rootRouter,
1008
+ engine: resolvedConfig.runtime?.engine || resolvedConfig.target
1009
+ }
1010
+ };
1011
+ return createDiagnosticsEnvelope({
1012
+ source: diagnostics?.source,
1013
+ status: diagnostics?.status || 'ok',
1014
+ diagnostics: diagnostics?.diagnostics || [],
1015
+ passes: [pass].concat(diagnostics?.passes || []),
1016
+ summary: {
1017
+ config: {
1018
+ profile: resolvedConfig.profile || resolvedConfig.selectedProfile,
1019
+ source: resolvedConfig.artifact?.source
1020
+ },
1021
+ extraction: diagnostics?.summary
1022
+ },
1023
+ cwd
1024
+ });
1025
+ }
1026
+
1027
+ function writeBuildManifest(outDir, options, artifactRecords) {
1028
+ const refreshed = [];
1029
+ const byFile = new Map();
1030
+ for (const record of artifactRecords || []) byFile.set(record.file, record);
1031
+ for (const [file, record] of byFile) {
1032
+ const absolute = path.join(outDir, file);
1033
+ if (!fs.existsSync(absolute)) continue;
1034
+ normalizeArtifactFile(absolute);
1035
+ const buffer = fs.readFileSync(absolute);
1036
+ const next = makeArtifactRecord(file, undefined, buffer);
1037
+ if (record.version !== undefined) next.version = record.version;
1038
+ refreshed.push(next);
1039
+ }
1040
+ const manifest = createBuildManifest({ ...options, artifactRecords: refreshed });
1041
+ writeJson(path.join(outDir, 'build-manifest.json'), manifest);
1042
+ return manifest;
1043
+ }
1044
+
1045
+ async function runCli(argv, io = {}) {
1046
+ const cwd = io.cwd || process.cwd();
1047
+ const stdout = io.stdout || process.stdout;
1048
+ const stderr = io.stderr || process.stderr;
1049
+ const providerProofs = io.providerProofs && typeof io.providerProofs === 'object'
1050
+ ? io.providerProofs
1051
+ : Object.freeze({});
1052
+ function providerProof(name) {
1053
+ const proof = providerProofs[name];
1054
+ if (typeof proof !== 'function') {
1055
+ throw new TypeError(`Pulse legacy provider proof ${name} requires an explicit CLI/testing composition root.`);
1056
+ }
1057
+ return proof;
1058
+ }
1059
+ function exitIfRequested() {
1060
+ if (io.exitOnComplete) process.exit(process.exitCode || 0);
1061
+ }
1062
+ const defaultOutDir = io.defaultOutDir || getDefaultArtifactsDir(cwd);
1063
+ let args = { command: 'build', outDir: defaultOutDir, strict: true, configOnly: false, includeAst: false, emitDispatchTs: false, emitHandlerBindings: false, emitExecutionHarness: false, emitAssemblyScriptShape: false, emitAssemblyScriptCore: false, emitAssemblyScriptCompile: false, emitWasmSmoke: false, emitLocalHarness: false, emitWasmHostAbi: false, emitWasmHostBridge: false, emitRequestResultHeaders: false, emitChannelBroadcaster: false, emitJsonBody: false, emitBackendCapabilities: false, emitHostRuntimeKernel: false, emitNodeAdapter: false, emitHandlerLibraryContracts: false, emitAssetsLoweringPlan: false, emitNodeAssetsProviderProof: false, emitFastlyAssetsProviderProof: false, emitFastlyAssetsPackageOutParityProof: false, emitRouteHandlerEffectPlan: false, emitNodeLiveOriginRouteHandlerEffectProof: false, emitNodeCompiledRouteHandlerEffectBridge: false, emitRouteHandlerContextLoweringPlan: false,
1064
+ emitHandlerIoLifecyclePlan: false, emitHostCapabilities: false, emitEffectRuntime: false, emitEffectComposition: false, emitCompiledHandlers: false, emitSchemaJsonCompile: false, emitSchemaJsonSidecar: false, emitSchemaJsonGenericParser: false, emitLibrarySidecars: false, emitStreamingPassthrough: false, emitIntegratedCompiledApp: false, emitCompiledWasmRuntime: false, emitPulseWrapper: false, emitFastlyReadiness: false, emitFastlyHostcallBinding: false, emitFastlyAdapter: false, emitFastlyCommandEntry: false };
1065
+
1066
+ try {
1067
+ args = parseArgs(argv, { defaultOutDir });
1068
+ } catch (error) {
1069
+ const outDir = path.resolve(cwd, args.outDir || defaultOutDir);
1070
+ const artifactRecords = [];
1071
+ const diagnostics = createDiagnosticsEnvelope({
1072
+ source: '<cli>',
1073
+ status: 'error',
1074
+ diagnostics: [{
1075
+ phase: 'cli',
1076
+ code: 'PULSEWASM_CLI_INVALID_ARGUMENTS',
1077
+ message: error && error.message ? error.message : String(error),
1078
+ severity: 'error',
1079
+ loc: { file: '<cli>' }
1080
+ }],
1081
+ passes: [],
1082
+ summary: { strict: true },
1083
+ cwd
1084
+ });
1085
+ try {
1086
+ writeDiagnostics(outDir, diagnostics, artifactRecords);
1087
+ writeBuildManifest(outDir, { cwd, outDir, args, status: 'error', diagnostics }, artifactRecords);
1088
+ } catch (_) {
1089
+ // stderr remains the fallback when artifacts cannot be written.
1090
+ }
1091
+ stderr.write(`PulseWasm build failed.\n${formatDiagnostics(diagnostics.diagnostics)}\n`);
1092
+ stderr.write(` diagnostics: ${path.join(outDir, 'diagnostics.json')}\n`);
1093
+ stderr.write(` build manifest: ${path.join(outDir, 'build-manifest.json')}\n`);
1094
+ process.exitCode = 1;
1095
+ return;
1096
+ }
1097
+
1098
+ if (args.help) {
1099
+ stdout.write(usage());
1100
+ exitIfRequested();
1101
+ return;
1102
+ }
1103
+
1104
+ if (args.command === 'explain') {
1105
+ const diagnosticsFile = resolveCliInput(cwd, args.diagnosticsFile || path.join(args.outDir, 'diagnostics.json'));
1106
+ const envelope = readJsonFile(diagnosticsFile);
1107
+ const explanation = createExplainArtifact(envelope, diagnosticsFile);
1108
+ stdout.write(args.outputFormat === 'json' ? jsonText(explanation) : formatExplainText(explanation));
1109
+ exitIfRequested();
1110
+ return;
1111
+ }
1112
+
1113
+ if (args.command === 'artifacts') {
1114
+ const manifestFile = resolveCliInput(cwd, args.manifestFile || path.join(args.outDir, 'build-manifest.json'));
1115
+ const manifest = readJsonFile(manifestFile);
1116
+ const list = createArtifactsList(manifest, manifestFile);
1117
+ stdout.write(args.outputFormat === 'json' ? jsonText(list) : formatArtifactsText(list));
1118
+ exitIfRequested();
1119
+ return;
1120
+ }
1121
+
1122
+ let outDir = path.resolve(cwd, args.outDir);
1123
+ const artifactRecords = [];
1124
+ let resolvedConfig;
1125
+ let entry;
1126
+ let root;
1127
+
1128
+ try {
1129
+ if (args.noStrictRequested) {
1130
+ throw new ExtractionError({
1131
+ phase: 'cli',
1132
+ code: 'PULSEWASM_NO_STRICT_UNSUPPORTED',
1133
+ message: '--no-strict is not supported in PulseWasm Phase 7. The gatekeeper is strict by default.',
1134
+ hint: 'Remove --no-strict. Future non-strict/advisory modes must be defined explicitly before use.',
1135
+ loc: { file: '<cli>' }
1136
+ });
1137
+ }
1138
+ let configFileAbs;
1139
+ let configDir;
1140
+ if (!args.config && args.entry) {
1141
+ const discovered = discoverSiblingConfigForEntry(cwd, args.entry);
1142
+ if (discovered) {
1143
+ args.config = path.relative(cwd, discovered).replace(/\\/g, '/');
1144
+ args.configDiscoveredFromEntry = true;
1145
+ }
1146
+ }
1147
+ if (args.config) {
1148
+ configFileAbs = path.resolve(cwd, args.config);
1149
+ configDir = path.dirname(configFileAbs);
1150
+ resolvedConfig = resolveConfigFromFile(configFileAbs, {
1151
+ cwd,
1152
+ profile: args.profile,
1153
+ env: {
1154
+ ...(process.env || {}),
1155
+ ...(io.env || {}),
1156
+ ...args.env
1157
+ }
1158
+ });
1159
+ if (!args.outDirExplicit && resolvedConfig.outDir) {
1160
+ outDir = path.resolve(configDir, resolvedConfig.outDir);
1161
+ }
1162
+ writeJson(path.join(outDir, 'resolved-config.json'), resolvedConfig.artifact, artifactRecords);
1163
+ }
1164
+
1165
+ if (args.configOnly) {
1166
+ if (!args.config) {
1167
+ throw new ExtractionError({
1168
+ phase: 'cli',
1169
+ code: 'PULSEWASM_CONFIG_ONLY_REQUIRES_CONFIG',
1170
+ message: '--config-only or resolve-config requires --config <pulse.config.ts>.',
1171
+ hint: 'Pass a Pulse config file to resolve.',
1172
+ loc: { file: '<cli>' }
1173
+ });
1174
+ }
1175
+ const diagnostics = createDiagnosticsEnvelope({
1176
+ source: args.config ? path.resolve(cwd, args.config) : '<cli>',
1177
+ status: 'ok',
1178
+ diagnostics: [],
1179
+ passes: [{ name: 'config-resolve', status: 'ok', summary: { profile: resolvedConfig?.profile || resolvedConfig?.selectedProfile } }],
1180
+ summary: { configOnly: true, profile: resolvedConfig?.profile || resolvedConfig?.selectedProfile, strict: args.strict },
1181
+ cwd
1182
+ });
1183
+ writeDiagnostics(outDir, diagnostics, artifactRecords);
1184
+ writeBuildManifest(outDir, {
1185
+ cwd,
1186
+ outDir,
1187
+ args,
1188
+ status: 'ok',
1189
+ resolvedConfig,
1190
+ diagnostics,
1191
+ entry: resolvedConfig?.entry,
1192
+ rootRouter: resolvedConfig?.rootRouter
1193
+ }, artifactRecords);
1194
+ stdout.write(`PulseWasm config resolved.\n`);
1195
+ stdout.write(` resolved config: ${path.join(outDir, 'resolved-config.json')}\n`);
1196
+ stdout.write(` diagnostics: ${path.join(outDir, 'diagnostics.json')}\n`);
1197
+ stdout.write(` build manifest: ${path.join(outDir, 'build-manifest.json')}\n`);
1198
+ exitIfRequested();
1199
+ return;
1200
+ }
1201
+
1202
+ const entryFromConfig = resolvedConfig?.entry;
1203
+ const rootFromConfig = resolvedConfig?.rootRouter;
1204
+ const entryArg = args.entry || entryFromConfig;
1205
+ if (!entryArg) {
1206
+ throw new ExtractionError({
1207
+ phase: 'cli',
1208
+ code: 'PULSEWASM_ENTRY_REQUIRED',
1209
+ message: 'PulseWasm build requires an entry file.',
1210
+ hint: 'Pass an entry file as a positional argument or define config.entry as a static string.',
1211
+ loc: { file: '<cli>' }
1212
+ });
1213
+ }
1214
+
1215
+ entry = resolveEntryPath(cwd, entryArg, configDir, !args.entry && Boolean(entryFromConfig));
1216
+ root = args.root || rootFromConfig;
1217
+
1218
+ const result = extractFromFile(entry, {
1219
+ cwd,
1220
+ root,
1221
+ includeAst: args.includeAst,
1222
+ emitDispatchTs: args.emitDispatchTs,
1223
+ emitHandlerBindings: args.emitHandlerBindings,
1224
+ emitExecutionHarness: args.emitExecutionHarness,
1225
+ emitAssemblyScriptShape: args.emitAssemblyScriptShape,
1226
+ emitAssemblyScriptCore: args.emitAssemblyScriptCore,
1227
+ emitAssemblyScriptCompile: args.emitAssemblyScriptCompile,
1228
+ emitWasmSmoke: args.emitWasmSmoke,
1229
+ emitLocalHarness: args.emitLocalHarness,
1230
+ emitWasmHostAbi: args.emitWasmHostAbi,
1231
+ emitWasmHostBridge: args.emitWasmHostBridge,
1232
+ emitRequestResultHeaders: args.emitRequestResultHeaders,
1233
+ emitChannelBroadcaster: args.emitChannelBroadcaster,
1234
+ emitJsonBody: args.emitJsonBody,
1235
+ emitBackendCapabilities: args.emitBackendCapabilities,
1236
+ emitHostRuntimeKernel: args.emitHostRuntimeKernel,
1237
+ emitNodeAdapter: args.emitNodeAdapter,
1238
+ emitHandlerLibraryContracts: args.emitHandlerLibraryContracts,
1239
+ emitAssetsLoweringPlan: args.emitAssetsLoweringPlan,
1240
+ emitAssetsCompiledWasmSidecarPlan: args.emitAssetsCompiledWasmSidecarPlan,
1241
+ emitAssetsSidecarCompileLinkProof: args.emitAssetsSidecarCompileLinkProof,
1242
+ emitNodeAssetsProviderProof: args.emitNodeAssetsProviderProof,
1243
+ emitNodeCompiledWasmAssetsLifecycleProof: args.emitNodeCompiledWasmAssetsLifecycleProof,
1244
+ emitFastlyAssetsProviderProof: args.emitFastlyAssetsProviderProof,
1245
+ emitFastlyAssetsPackageOutParityProof: args.emitFastlyAssetsPackageOutParityProof,
1246
+ emitNodeRouteHandlerEffectProof: args.emitNodeRouteHandlerEffectProof,
1247
+ emitFastlyRouteHandlerEffectProof: args.emitFastlyRouteHandlerEffectProof,
1248
+ emitFastlyLifecycleParityProof: args.emitFastlyLifecycleParityProof,
1249
+ emitRouteHandlerEffectPlan: args.emitRouteHandlerEffectPlan,
1250
+ emitRouteHandlerContextLoweringPlan: args.emitRouteHandlerContextLoweringPlan,
1251
+ emitHandlerIoLifecyclePlan: args.emitHandlerIoLifecyclePlan,
1252
+ emitRequestJsonBodyPlan: args.emitRequestJsonBodyPlan,
1253
+ emitSchemaDecodeResultPlan: args.emitSchemaDecodeResultPlan,
1254
+ emitSchemaResponseCodecPlan: args.emitSchemaResponseCodecPlan,
1255
+ emitBackendJsonRequestBodyPlan: args.emitBackendJsonRequestBodyPlan,
1256
+ emitNodeBackendJsonRequestBodyProof: args.emitNodeBackendJsonRequestBodyProof,
1257
+ emitNodeRequestJsonBodyProof: args.emitNodeRequestJsonBodyProof,
1258
+ emitNodeSchemaDecodeResultProof: args.emitNodeSchemaDecodeResultProof,
1259
+ emitNodeSchemaResponseCodecProof: args.emitNodeSchemaResponseCodecProof,
1260
+ emitHostCapabilities: args.emitHostCapabilities,
1261
+ emitEffectRuntime: args.emitEffectRuntime,
1262
+ emitEffectComposition: args.emitEffectComposition,
1263
+ emitCompiledHandlers: args.emitCompiledHandlers,
1264
+ emitSchemaJsonCompile: args.emitSchemaJsonCompile,
1265
+ emitSchemaJsonSidecar: args.emitSchemaJsonSidecar,
1266
+ emitSchemaJsonGenericParser: args.emitSchemaJsonGenericParser,
1267
+ emitLibrarySidecars: args.emitLibrarySidecars,
1268
+ emitStreamingPassthrough: args.emitStreamingPassthrough,
1269
+ emitIntegratedCompiledApp: args.emitIntegratedCompiledApp,
1270
+ emitCompiledWasmRuntime: args.emitCompiledWasmRuntime,
1271
+ emitPulseWrapper: args.emitPulseWrapper,
1272
+ emitFastlyReadiness: args.emitFastlyReadiness,
1273
+ emitFastlyHostcallBinding: args.emitFastlyHostcallBinding,
1274
+ emitFastlyAdapter: args.emitFastlyAdapter,
1275
+ emitFastlyCommandEntry: args.emitFastlyCommandEntry,
1276
+ resolvedConfig: resolvedConfig?.artifact,
1277
+ configRoot: configDir || path.dirname(entry),
1278
+ outDir,
1279
+ providerProofs
1280
+ });
1281
+
1282
+ const diagnostics = withConfigPass(result.diagnostics, resolvedConfig, cwd);
1283
+
1284
+ if (args.emitNodeLiveOriginRouteHandlerEffectProof) {
1285
+ const liveProof = await providerProof('buildNodeLiveOriginRouteHandlerEffectProof')({
1286
+ cwd,
1287
+ generatedBy: result.summary && result.summary.generatedBy,
1288
+ routeHandlerEffectPlan: result.routeHandlerEffectPlan,
1289
+ resolvedConfig: resolvedConfig?.artifact,
1290
+ mode: 'cli-live-origin-http'
1291
+ });
1292
+ const liveProofErrors = liveProof.diagnostics.filter((entry) => (entry.severity || 'error') === 'error');
1293
+ if (liveProofErrors.length > 0) {
1294
+ throw new ExtractionError(liveProofErrors, {
1295
+ passes: [...(diagnostics.passes || []), { name: 'node-live-origin-route-handler-effect-proof', status: 'error', summary: liveProof.artifact.summary }],
1296
+ source: entry,
1297
+ summary: result.summary
1298
+ });
1299
+ }
1300
+ result.nodeLiveOriginRouteHandlerEffectProof = liveProof;
1301
+ diagnostics.passes = [...(diagnostics.passes || []), { name: 'node-live-origin-route-handler-effect-proof', status: 'ok', summary: liveProof.artifact.summary }];
1302
+ }
1303
+
1304
+ if (args.emitNodeCompiledRouteHandlerEffectBridge) {
1305
+ const compiledBridge = await providerProof('buildNodeCompiledRouteHandlerEffectBridge')({
1306
+ cwd,
1307
+ outDir,
1308
+ generatedBy: result.summary && result.summary.generatedBy,
1309
+ routeHandlerEffectPlan: result.routeHandlerEffectPlan,
1310
+ compiledHandlers: result.compiledHandlers,
1311
+ resolvedConfig: resolvedConfig?.artifact,
1312
+ mode: 'cli-compiled-wasm-live-origin-bridge'
1313
+ });
1314
+ const compiledBridgeErrors = compiledBridge.diagnostics.filter((entry) => (entry.severity || 'error') === 'error');
1315
+ if (compiledBridgeErrors.length > 0) {
1316
+ throw new ExtractionError(compiledBridgeErrors, {
1317
+ passes: [...(diagnostics.passes || []), { name: 'node-compiled-route-handler-effect-bridge', status: 'error', summary: compiledBridge.artifact.summary }],
1318
+ source: entry,
1319
+ summary: result.summary
1320
+ });
1321
+ }
1322
+ result.nodeCompiledRouteHandlerEffectBridge = compiledBridge;
1323
+ diagnostics.passes = [...(diagnostics.passes || []), { name: 'node-compiled-route-handler-effect-bridge', status: 'ok', summary: compiledBridge.artifact.summary }];
1324
+ }
1325
+
1326
+ if (args.emitNodeBackendJsonRequestBodyProof) {
1327
+ const backendJsonProof = await providerProof('buildNodeBackendJsonRequestBodyProof')({
1328
+ cwd,
1329
+ generatedBy: result.summary && result.summary.generatedBy,
1330
+ routeHandlerEffectPlan: result.routeHandlerEffectPlan,
1331
+ backendJsonRequestBodyPlan: result.backendJsonRequestBodyPlan,
1332
+ requestJsonBodyPlan: result.requestJsonBodyPlan,
1333
+ resolvedConfig: resolvedConfig?.artifact,
1334
+ mode: 'cli-node-backend-json-request-body-proof'
1335
+ });
1336
+ const backendJsonProofErrors = backendJsonProof.diagnostics.filter((entry) => (entry.severity || 'error') === 'error');
1337
+ if (backendJsonProofErrors.length > 0) {
1338
+ throw new ExtractionError(backendJsonProofErrors, {
1339
+ passes: [...(diagnostics.passes || []), { name: 'node-backend-json-request-body-proof', status: 'error', summary: backendJsonProof.artifact.summary }],
1340
+ source: entry,
1341
+ summary: result.summary
1342
+ });
1343
+ }
1344
+ result.nodeBackendJsonRequestBodyProof = backendJsonProof;
1345
+ diagnostics.passes = [...(diagnostics.passes || []), { name: 'node-backend-json-request-body-proof', status: 'ok', summary: backendJsonProof.artifact.summary }];
1346
+ }
1347
+
1348
+ writeJson(path.join(outDir, 'symbol-index.json'), result.symbolIndex, artifactRecords);
1349
+ writeJson(path.join(outDir, 'handler-table.json'), result.handlerTable, artifactRecords);
1350
+ writeJson(path.join(outDir, 'handler-eval.json'), result.handlerEval, artifactRecords);
1351
+ writeJson(path.join(outDir, 'path-table.json'), result.pathTable, artifactRecords);
1352
+ writeJson(path.join(outDir, 'dispatch-table.json'), result.dispatchTable, artifactRecords);
1353
+ writeJson(path.join(outDir, 'execution-plan.json'), result.executionPlan, artifactRecords);
1354
+ if (result.handlerBindings) {
1355
+ writeJson(path.join(outDir, 'handler-bindings.json'), result.handlerBindings.artifact, artifactRecords);
1356
+ }
1357
+ if (result.executionHarness) {
1358
+ writeJson(path.join(outDir, 'execution-harness.json'), result.executionHarness.artifact, artifactRecords);
1359
+ }
1360
+ if (result.localHarness) {
1361
+ writeJson(path.join(outDir, 'local-harness.json'), result.localHarness.artifact, artifactRecords);
1362
+ }
1363
+ if (result.assemblyScriptShape) {
1364
+ writeJson(path.join(outDir, 'assemblyscript-shape.json'), result.assemblyScriptShape.artifact, artifactRecords);
1365
+ writeJson(path.join(outDir, 'generated/as/manifest.json'), result.assemblyScriptShape.manifest, artifactRecords, outDir);
1366
+ for (const file of result.assemblyScriptShape.files) {
1367
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1368
+ }
1369
+ }
1370
+ if (result.assemblyScriptCore) {
1371
+ writeJson(path.join(outDir, 'assemblyscript-core.json'), result.assemblyScriptCore.artifact, artifactRecords);
1372
+ if (result.assemblyScriptCore.handlersArtifact) {
1373
+ writeJson(path.join(outDir, 'assemblyscript-handlers.json'), result.assemblyScriptCore.handlersArtifact, artifactRecords);
1374
+ }
1375
+ for (const file of result.assemblyScriptCore.files) {
1376
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1377
+ }
1378
+ }
1379
+ if (result.assemblyScriptCompile) {
1380
+ writeJson(path.join(outDir, 'assemblyscript-compile.json'), result.assemblyScriptCompile.artifact, artifactRecords);
1381
+ for (const output of result.assemblyScriptCompile.outputFiles || []) {
1382
+ const abs = path.resolve(cwd, output.file);
1383
+ if (fs.existsSync(abs)) {
1384
+ const buffer = fs.readFileSync(abs);
1385
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1386
+ }
1387
+ }
1388
+ }
1389
+ if (result.assemblyScriptWasmSmoke) {
1390
+ writeJson(path.join(outDir, 'assemblyscript-wasm-smoke.json'), result.assemblyScriptWasmSmoke.artifact, artifactRecords);
1391
+ for (const file of result.assemblyScriptWasmSmoke.files || []) {
1392
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1393
+ }
1394
+ for (const output of result.assemblyScriptWasmSmoke.outputFiles || []) {
1395
+ const abs = path.resolve(cwd, output.file);
1396
+ if (fs.existsSync(abs)) {
1397
+ const buffer = fs.readFileSync(abs);
1398
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1399
+ }
1400
+ }
1401
+ }
1402
+ if (result.wasmHostAbi) {
1403
+ writeJson(path.join(outDir, 'wasm-host-abi.json'), result.wasmHostAbi.artifact, artifactRecords);
1404
+ for (const file of result.wasmHostAbi.files || []) {
1405
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1406
+ }
1407
+ }
1408
+ if (result.wasmHostBridge) {
1409
+ writeJson(path.join(outDir, 'wasm-host-bridge.json'), result.wasmHostBridge.artifact, artifactRecords);
1410
+ for (const file of result.wasmHostBridge.files || []) {
1411
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1412
+ }
1413
+ for (const output of result.wasmHostBridge.outputFiles || []) {
1414
+ const abs = path.resolve(cwd, output.file);
1415
+ if (fs.existsSync(abs)) {
1416
+ const buffer = fs.readFileSync(abs);
1417
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1418
+ }
1419
+ }
1420
+ }
1421
+ if (result.requestResultHeaders) {
1422
+ writeJson(path.join(outDir, 'request-result-headers.json'), result.requestResultHeaders.artifact, artifactRecords);
1423
+ for (const file of result.requestResultHeaders.files || []) {
1424
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1425
+ }
1426
+ }
1427
+ if (result.channelBroadcaster) {
1428
+ writeJson(path.join(outDir, 'channel-broadcaster.json'), result.channelBroadcaster.artifact, artifactRecords);
1429
+ for (const file of result.channelBroadcaster.files || []) {
1430
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1431
+ }
1432
+ }
1433
+ if (result.jsonBody) {
1434
+ writeJson(path.join(outDir, 'json-body.json'), result.jsonBody.artifact, artifactRecords);
1435
+ for (const file of result.jsonBody.files || []) {
1436
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1437
+ }
1438
+ }
1439
+ if (result.backendCapabilities) {
1440
+ writeJson(path.join(outDir, 'backend-capabilities.json'), result.backendCapabilities.artifact, artifactRecords);
1441
+ for (const file of result.backendCapabilities.files || []) {
1442
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1443
+ }
1444
+ }
1445
+ if (result.hostRuntimeKernel) {
1446
+ writeJson(path.join(outDir, 'host-runtime-kernel.json'), result.hostRuntimeKernel.artifact, artifactRecords);
1447
+ for (const file of result.hostRuntimeKernel.files || []) {
1448
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1449
+ }
1450
+ }
1451
+ if (result.nodeAdapter) {
1452
+ writeJson(path.join(outDir, 'node-adapter.json'), result.nodeAdapter.artifact, artifactRecords);
1453
+ for (const file of result.nodeAdapter.files || []) {
1454
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1455
+ }
1456
+ }
1457
+ if (result.handlerLibraryContracts) {
1458
+ writeJson(path.join(outDir, 'handler-library-contracts.json'), result.handlerLibraryContracts.artifact, artifactRecords);
1459
+ writeJson(path.join(outDir, 'handler-execution-modes.json'), result.handlerLibraryContracts.handlerExecutionModes, artifactRecords);
1460
+ writeJson(path.join(outDir, 'library-contract-schema.json'), result.handlerLibraryContracts.libraryContractSchema, artifactRecords);
1461
+ writeJson(path.join(outDir, 'library-capabilities.json'), result.handlerLibraryContracts.libraryCapabilities, artifactRecords);
1462
+ writeJson(path.join(outDir, 'library-compatibility-report.json'), result.handlerLibraryContracts.libraryCompatibilityReport, artifactRecords);
1463
+ for (const file of result.handlerLibraryContracts.files || []) {
1464
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1465
+ }
1466
+ }
1467
+ if (result.assetsLoweringPlan) {
1468
+ writeJson(path.join(outDir, 'assets-lowering-plan.json'), result.assetsLoweringPlan.artifact, artifactRecords);
1469
+ }
1470
+ if (result.assetsCompiledWasmSidecarPlan) {
1471
+ writeJson(path.join(outDir, 'assets-compiled-wasm-sidecar-plan.json'), result.assetsCompiledWasmSidecarPlan.artifact, artifactRecords);
1472
+ }
1473
+ if (result.assetsSidecarCompileLinkProof) {
1474
+ writeJson(path.join(outDir, 'assets-sidecar-compile-link-proof.json'), result.assetsSidecarCompileLinkProof.artifact, artifactRecords);
1475
+ }
1476
+ if (result.nodeAssetsProviderProof) {
1477
+ writeJson(path.join(outDir, 'node-assets-provider-proof.json'), result.nodeAssetsProviderProof.artifact, artifactRecords);
1478
+ }
1479
+ if (result.nodeCompiledWasmAssetsLifecycleProof) {
1480
+ writeJson(path.join(outDir, 'node-compiled-wasm-assets-lifecycle-proof.json'), result.nodeCompiledWasmAssetsLifecycleProof.artifact, artifactRecords);
1481
+ }
1482
+ if (result.fastlyAssetsProviderProof) {
1483
+ writeJson(path.join(outDir, 'fastly-assets-provider-proof.json'), result.fastlyAssetsProviderProof.artifact, artifactRecords);
1484
+ }
1485
+ if (result.fastlyAssetsPackageOutParityProof) {
1486
+ writeJson(path.join(outDir, 'fastly-assets-package-out-parity-proof.json'), result.fastlyAssetsPackageOutParityProof.artifact, artifactRecords);
1487
+ }
1488
+ if (result.routeHandlerEffectPlan) {
1489
+ writeJson(path.join(outDir, 'route-handler-effect-plan.json'), result.routeHandlerEffectPlan.artifact, artifactRecords);
1490
+ }
1491
+ if (result.nodeRouteHandlerEffectProof) {
1492
+ writeJson(path.join(outDir, 'node-route-handler-effect-proof.json'), result.nodeRouteHandlerEffectProof.artifact, artifactRecords);
1493
+ }
1494
+ if (result.nodeLiveOriginRouteHandlerEffectProof) {
1495
+ writeJson(path.join(outDir, 'node-live-origin-route-handler-effect-proof.json'), result.nodeLiveOriginRouteHandlerEffectProof.artifact, artifactRecords);
1496
+ }
1497
+ if (result.nodeCompiledRouteHandlerEffectBridge) {
1498
+ writeJson(path.join(outDir, 'node-compiled-route-handler-effect-bridge.json'), result.nodeCompiledRouteHandlerEffectBridge.artifact, artifactRecords);
1499
+ for (const file of result.nodeCompiledRouteHandlerEffectBridge.files || []) writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1500
+ for (const output of result.nodeCompiledRouteHandlerEffectBridge.outputFiles || []) {
1501
+ const abs = path.resolve(cwd, output.file);
1502
+ if (fs.existsSync(abs)) {
1503
+ const buffer = fs.readFileSync(abs);
1504
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1505
+ }
1506
+ }
1507
+ }
1508
+ if (result.fastlyRouteHandlerEffectProof) {
1509
+ writeJson(path.join(outDir, 'fastly-route-handler-effect-proof.json'), result.fastlyRouteHandlerEffectProof.artifact, artifactRecords);
1510
+ }
1511
+ if (result.fastlyLifecycleParityProof) {
1512
+ writeJson(path.join(outDir, 'fastly-lifecycle-parity-proof.json'), result.fastlyLifecycleParityProof.artifact, artifactRecords);
1513
+ }
1514
+ if (result.routeHandlerContextLoweringPlan) {
1515
+ writeJson(path.join(outDir, 'route-handler-context-lowering-plan.json'), result.routeHandlerContextLoweringPlan.artifact, artifactRecords);
1516
+ }
1517
+ if (result.handlerIoLifecyclePlan) {
1518
+ writeJson(path.join(outDir, 'handler-io-lifecycle-plan.json'), result.handlerIoLifecyclePlan.artifact, artifactRecords);
1519
+ }
1520
+ if (result.requestJsonBodyPlan) {
1521
+ writeJson(path.join(outDir, 'request-json-body-plan.json'), result.requestJsonBodyPlan.artifact, artifactRecords);
1522
+ }
1523
+ if (result.schemaDecodeResultPlan) {
1524
+ writeJson(path.join(outDir, 'schema-decode-result-plan.json'), result.schemaDecodeResultPlan.artifact, artifactRecords);
1525
+ }
1526
+ if (result.schemaResponseCodecPlan) {
1527
+ writeJson(path.join(outDir, 'schema-response-codec-plan.json'), result.schemaResponseCodecPlan.artifact, artifactRecords);
1528
+ }
1529
+ if (result.backendJsonRequestBodyPlan) {
1530
+ writeJson(path.join(outDir, 'backend-json-request-body-plan.json'), result.backendJsonRequestBodyPlan.artifact, artifactRecords);
1531
+ }
1532
+ if (result.nodeBackendJsonRequestBodyProof) {
1533
+ writeJson(path.join(outDir, 'node-backend-json-request-body-proof.json'), result.nodeBackendJsonRequestBodyProof.artifact, artifactRecords);
1534
+ }
1535
+ if (result.nodeRequestJsonBodyProof) {
1536
+ writeJson(path.join(outDir, 'node-request-json-body-proof.json'), result.nodeRequestJsonBodyProof.artifact, artifactRecords);
1537
+ for (const file of result.nodeRequestJsonBodyProof.files || []) writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1538
+ for (const output of result.nodeRequestJsonBodyProof.outputFiles || []) {
1539
+ const abs = path.resolve(cwd, output.file);
1540
+ if (fs.existsSync(abs)) {
1541
+ const buffer = fs.readFileSync(abs);
1542
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1543
+ }
1544
+ }
1545
+ }
1546
+ if (result.nodeSchemaDecodeResultProof) {
1547
+ writeJson(path.join(outDir, 'node-schema-decode-result-proof.json'), result.nodeSchemaDecodeResultProof.artifact, artifactRecords);
1548
+ for (const file of result.nodeSchemaDecodeResultProof.files || []) writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1549
+ for (const output of result.nodeSchemaDecodeResultProof.outputFiles || []) {
1550
+ const abs = path.resolve(cwd, output.file);
1551
+ if (fs.existsSync(abs)) {
1552
+ const buffer = fs.readFileSync(abs);
1553
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1554
+ }
1555
+ }
1556
+ }
1557
+ if (result.nodeSchemaResponseCodecProof) {
1558
+ writeJson(path.join(outDir, 'node-schema-response-codec-proof.json'), result.nodeSchemaResponseCodecProof.artifact, artifactRecords);
1559
+ for (const file of result.nodeSchemaResponseCodecProof.files || []) writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1560
+ for (const output of result.nodeSchemaResponseCodecProof.outputFiles || []) {
1561
+ const abs = path.resolve(cwd, output.file);
1562
+ if (fs.existsSync(abs)) {
1563
+ const buffer = fs.readFileSync(abs);
1564
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1565
+ }
1566
+ }
1567
+ }
1568
+ if (result.hostCapabilities) {
1569
+ writeJson(path.join(outDir, 'host-capabilities.json'), result.hostCapabilities.artifact, artifactRecords);
1570
+ writeJson(path.join(outDir, 'host-capability-contract.json'), result.hostCapabilities.hostCapabilityContract, artifactRecords);
1571
+ writeJson(path.join(outDir, 'wasi-provider-map.json'), result.hostCapabilities.wasiProviderMap, artifactRecords);
1572
+ writeJson(path.join(outDir, 'capability-provider-report.json'), result.hostCapabilities.capabilityProviderReport, artifactRecords);
1573
+ for (const file of result.hostCapabilities.files || []) {
1574
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1575
+ }
1576
+ }
1577
+ if (result.effectRuntime) {
1578
+ writeJson(path.join(outDir, 'effect-runtime.json'), result.effectRuntime.artifact, artifactRecords);
1579
+ writeJson(path.join(outDir, 'effect-runtime-contract.json'), result.effectRuntime.effectRuntimeContract, artifactRecords);
1580
+ writeJson(path.join(outDir, 'effect-kind-registry.json'), result.effectRuntime.effectKindRegistry, artifactRecords);
1581
+ writeJson(path.join(outDir, 'effect-resume-protocol.json'), result.effectRuntime.effectResumeProtocol, artifactRecords);
1582
+ writeJson(path.join(outDir, 'effect-timeout-policy.json'), result.effectRuntime.effectTimeoutPolicy, artifactRecords);
1583
+ for (const file of result.effectRuntime.files || []) {
1584
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1585
+ }
1586
+ }
1587
+ if (result.effectComposition) {
1588
+ writeJson(path.join(outDir, 'effect-composition.json'), result.effectComposition.artifact, artifactRecords);
1589
+ writeJson(path.join(outDir, 'effect-plan-contract.json'), result.effectComposition.effectPlanContract, artifactRecords);
1590
+ writeJson(path.join(outDir, 'effect-continuation-contract.json'), result.effectComposition.effectContinuationContract, artifactRecords);
1591
+ writeJson(path.join(outDir, 'timeout-scope-policy.json'), result.effectComposition.timeoutScopePolicy, artifactRecords);
1592
+ for (const file of result.effectComposition.files || []) {
1593
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1594
+ }
1595
+ }
1596
+ if (result.schemaJsonCompile) {
1597
+ writeJson(path.join(outDir, 'schema-json-compile.json'), result.schemaJsonCompile.artifact, artifactRecords);
1598
+ writeJson(path.join(outDir, 'schema-json-compile-smoke.json'), result.schemaJsonCompile.smoke, artifactRecords);
1599
+ for (const file of result.schemaJsonCompile.files || []) {
1600
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1601
+ }
1602
+ }
1603
+ if (result.schemaJsonGenericParser) {
1604
+ writeJson(path.join(outDir, 'schema-json-generic-parser.json'), result.schemaJsonGenericParser.artifact, artifactRecords);
1605
+ writeJson(path.join(outDir, 'schema-json-generic-parser-plan.json'), result.schemaJsonGenericParser.plan, artifactRecords);
1606
+ writeJson(path.join(outDir, 'schema-json-generic-parser-abi.json'), result.schemaJsonGenericParser.sidecarAbi, artifactRecords);
1607
+ writeJson(path.join(outDir, 'schema-json-generic-parser-smoke.json'), result.schemaJsonGenericParser.smoke, artifactRecords);
1608
+ writeJson(path.join(outDir, 'schema-json-parser-report.json'), result.schemaJsonGenericParser.report, artifactRecords);
1609
+ writeJson(path.join(outDir, 'schema-json-registry.json'), result.schemaJsonGenericParser.registry, artifactRecords);
1610
+ writeJson(path.join(outDir, 'schema-json-sidecar-abi.json'), result.schemaJsonGenericParser.sidecarAbi, artifactRecords);
1611
+ writeJson(path.join(outDir, 'schema-json-body-policy.json'), result.schemaJsonGenericParser.bodyPolicy, artifactRecords);
1612
+ for (const file of result.schemaJsonGenericParser.files || []) {
1613
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1614
+ }
1615
+ for (const output of result.schemaJsonGenericParser.outputFiles || []) {
1616
+ const abs = path.resolve(cwd, output.file);
1617
+ if (fs.existsSync(abs)) {
1618
+ const buffer = fs.readFileSync(abs);
1619
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1620
+ }
1621
+ }
1622
+ }
1623
+ if (result.schemaJsonSidecar) {
1624
+ writeJson(path.join(outDir, 'schema-json-sidecar.json'), result.schemaJsonSidecar.artifact, artifactRecords);
1625
+ writeJson(path.join(outDir, 'schema-json-plan.json'), result.schemaJsonSidecar.plan, artifactRecords);
1626
+ writeJson(path.join(outDir, 'schema-json-parser-report.json'), result.schemaJsonSidecar.report, artifactRecords);
1627
+ writeJson(path.join(outDir, 'schema-json-registry.json'), result.schemaJsonSidecar.registry, artifactRecords);
1628
+ writeJson(path.join(outDir, 'schema-json-sidecar-abi.json'), result.schemaJsonSidecar.sidecarAbi, artifactRecords);
1629
+ writeJson(path.join(outDir, 'schema-json-body-policy.json'), result.schemaJsonSidecar.bodyPolicy, artifactRecords);
1630
+ writeJson(path.join(outDir, 'schema-json-smoke.json'), result.schemaJsonSidecar.smoke, artifactRecords);
1631
+ for (const file of result.schemaJsonSidecar.files || []) {
1632
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1633
+ }
1634
+ for (const output of result.schemaJsonSidecar.outputFiles || []) {
1635
+ const abs = path.resolve(cwd, output.file);
1636
+ if (fs.existsSync(abs)) {
1637
+ const buffer = fs.readFileSync(abs);
1638
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1639
+ }
1640
+ }
1641
+ }
1642
+ if (result.librarySidecars) {
1643
+ writeJson(path.join(outDir, 'library-sidecar-consumption.json'), result.librarySidecars.artifact, artifactRecords);
1644
+ writeJson(path.join(outDir, 'api-surface.json'), result.librarySidecars.apiSurface, artifactRecords);
1645
+ writeJson(path.join(outDir, 'ctx-extension-scope-map.json'), result.librarySidecars.ctxExtensionScopeMap, artifactRecords);
1646
+ writeJson(path.join(outDir, 'lifecycle-ordering.json'), result.librarySidecars.lifecycleOrdering, artifactRecords);
1647
+ writeJson(path.join(outDir, 'library-sidecar-smoke.json'), result.librarySidecars.smoke, artifactRecords);
1648
+ for (const file of result.librarySidecars.files || []) {
1649
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1650
+ }
1651
+ for (const output of result.librarySidecars.outputFiles || []) {
1652
+ const abs = path.resolve(cwd, output.file);
1653
+ if (fs.existsSync(abs)) {
1654
+ const buffer = fs.readFileSync(abs);
1655
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1656
+ }
1657
+ }
1658
+ }
1659
+ if (result.streamingPassthrough) {
1660
+ writeJson(path.join(outDir, 'streaming-passthrough.json'), result.streamingPassthrough.artifact, artifactRecords);
1661
+ writeJson(path.join(outDir, 'stream-result-abi.json'), result.streamingPassthrough.streamResultAbi, artifactRecords);
1662
+ writeJson(path.join(outDir, 'response-passthrough-policy.json'), result.streamingPassthrough.responsePassthroughPolicy, artifactRecords);
1663
+ writeJson(path.join(outDir, 'streaming-passthrough-smoke.json'), result.streamingPassthrough.smoke, artifactRecords);
1664
+ for (const file of result.streamingPassthrough.files || []) {
1665
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1666
+ }
1667
+ }
1668
+ if (result.integratedCompiledApp) {
1669
+ writeJson(path.join(outDir, 'integrated-compiled-app.json'), result.integratedCompiledApp.artifact, artifactRecords);
1670
+ writeJson(path.join(outDir, 'integrated-link-report.json'), result.integratedCompiledApp.linkReport, artifactRecords);
1671
+ writeJson(path.join(outDir, 'integrated-compiled-app-smoke.json'), result.integratedCompiledApp.smoke, artifactRecords);
1672
+ for (const file of result.integratedCompiledApp.files || []) {
1673
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1674
+ }
1675
+ for (const output of result.integratedCompiledApp.outputFiles || []) {
1676
+ const abs = path.resolve(cwd, output.file);
1677
+ if (fs.existsSync(abs)) {
1678
+ const buffer = fs.readFileSync(abs);
1679
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1680
+ }
1681
+ }
1682
+ }
1683
+ if (result.compiledWasmRuntime) {
1684
+ writeJson(path.join(outDir, 'compiled-wasm-runtime.json'), result.compiledWasmRuntime.artifact, artifactRecords);
1685
+ writeJson(path.join(outDir, 'compiled-wasm-host-runtime.json'), result.compiledWasmRuntime.hostRuntime, artifactRecords);
1686
+ writeJson(path.join(outDir, 'compiled-wasm-node-adapter.json'), result.compiledWasmRuntime.nodeAdapter, artifactRecords);
1687
+ writeJson(path.join(outDir, 'compiled-wasm-runtime-smoke.json'), result.compiledWasmRuntime.smoke, artifactRecords);
1688
+ for (const file of result.compiledWasmRuntime.files || []) {
1689
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1690
+ }
1691
+ for (const output of result.compiledWasmRuntime.outputFiles || []) {
1692
+ const abs = path.resolve(cwd, output.file);
1693
+ if (fs.existsSync(abs)) {
1694
+ const buffer = fs.readFileSync(abs);
1695
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1696
+ }
1697
+ }
1698
+ }
1699
+ if (result.pulseWrapper) {
1700
+ writeJson(path.join(outDir, 'wrapper-integration.json'), result.pulseWrapper.artifact, artifactRecords);
1701
+ writeJson(path.join(outDir, 'pulse-build-output.json'), result.pulseWrapper.buildOutput, artifactRecords);
1702
+ writeJson(path.join(outDir, 'pulse-dev-runtime.json'), result.pulseWrapper.devRuntime, artifactRecords);
1703
+ for (const file of result.pulseWrapper.files || []) {
1704
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1705
+ }
1706
+ }
1707
+ if (result.fastlyReadiness) {
1708
+ writeJson(path.join(outDir, 'fastly-readiness.json'), result.fastlyReadiness.artifact, artifactRecords);
1709
+ writeJson(path.join(outDir, 'fastly-sdk-audit.json'), result.fastlyReadiness.sdkAudit, artifactRecords);
1710
+ writeJson(path.join(outDir, 'fastly-hostcall-map.json'), result.fastlyReadiness.hostcallMap, artifactRecords);
1711
+ writeJson(path.join(outDir, 'fastly-capability-map.json'), result.fastlyReadiness.capabilityMap, artifactRecords);
1712
+ writeJson(path.join(outDir, 'fastly-packaging-plan.json'), result.fastlyReadiness.packagingPlan, artifactRecords);
1713
+ writeJson(path.join(outDir, 'fastly-risk-report.json'), result.fastlyReadiness.riskReport, artifactRecords);
1714
+ writeJson(path.join(outDir, 'fastly-adapter-plan.json'), result.fastlyReadiness.adapterPlan, artifactRecords);
1715
+ for (const file of result.fastlyReadiness.files || []) {
1716
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1717
+ }
1718
+ }
1719
+ if (result.fastlyHostcallBinding) {
1720
+ writeJson(path.join(outDir, 'fastly-hostcall-binding-contract.json'), result.fastlyHostcallBinding.artifact, artifactRecords);
1721
+ writeJson(path.join(outDir, 'fastly-hostcall-modules.json'), result.fastlyHostcallBinding.hostcallModules, artifactRecords);
1722
+ writeJson(path.join(outDir, 'fastly-ref-lifecycle.json'), result.fastlyHostcallBinding.refLifecycle, artifactRecords);
1723
+ writeJson(path.join(outDir, 'fastly-stream-binding-plan.json'), result.fastlyHostcallBinding.streamBindingPlan, artifactRecords);
1724
+ writeJson(path.join(outDir, 'fastly-pack-inputs.json'), result.fastlyHostcallBinding.packInputs, artifactRecords);
1725
+ writeJson(path.join(outDir, 'fastly-binding-risk-report.json'), result.fastlyHostcallBinding.riskReport, artifactRecords);
1726
+ for (const file of result.fastlyHostcallBinding.files || []) {
1727
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1728
+ }
1729
+ }
1730
+ if (result.fastlyAdapter) {
1731
+ writeJson(path.join(outDir, 'fastly-adapter.json'), result.fastlyAdapter.artifact, artifactRecords);
1732
+ writeJson(path.join(outDir, 'fastly-stream-header-adapter.json'), result.fastlyAdapter.streamHeaderAdapter, artifactRecords);
1733
+ writeJson(path.join(outDir, 'fastly-local-smoke.json'), result.fastlyAdapter.localSmoke, artifactRecords);
1734
+ writeJson(path.join(outDir, 'fastly-packaging-smoke.json'), result.fastlyAdapter.packagingSmoke, artifactRecords);
1735
+ writeJson(path.join(outDir, 'fastly-deployment-readiness.json'), result.fastlyAdapter.deploymentReadiness, artifactRecords);
1736
+ for (const file of result.fastlyAdapter.files || []) {
1737
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1738
+ }
1739
+ for (const output of result.fastlyAdapter.outputFiles || []) {
1740
+ const abs = path.resolve(cwd, output.file);
1741
+ if (fs.existsSync(abs)) {
1742
+ const buffer = fs.readFileSync(abs);
1743
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1744
+ }
1745
+ }
1746
+ }
1747
+ if (result.fastlyCommandEntry) {
1748
+ writeJson(path.join(outDir, 'fastly-command-entry.json'), result.fastlyCommandEntry.artifact, artifactRecords);
1749
+ writeJson(path.join(outDir, 'fastly-start-export-audit.json'), result.fastlyCommandEntry.startExportAudit, artifactRecords);
1750
+ writeJson(path.join(outDir, 'fastly-command-import-audit.json'), result.fastlyCommandEntry.importAudit, artifactRecords);
1751
+ writeJson(path.join(outDir, 'fastly-serve-gate.json'), result.fastlyCommandEntry.serveGate, artifactRecords);
1752
+ writeJson(path.join(outDir, 'fastly-command-smoke.json'), result.fastlyCommandEntry.commandSmoke, artifactRecords);
1753
+ for (const file of result.fastlyCommandEntry.files || []) {
1754
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1755
+ }
1756
+ for (const output of result.fastlyCommandEntry.outputFiles || []) {
1757
+ const abs = path.resolve(cwd, output.file);
1758
+ if (fs.existsSync(abs)) {
1759
+ const buffer = fs.readFileSync(abs);
1760
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1761
+ }
1762
+ }
1763
+ }
1764
+ if (result.compiledHandlers) {
1765
+ writeJson(path.join(outDir, 'compiled-handler-plan.json'), result.compiledHandlers.artifact, artifactRecords);
1766
+ writeJson(path.join(outDir, 'handler-lowering-report.json'), result.compiledHandlers.report, artifactRecords);
1767
+ writeJson(path.join(outDir, 'compiled-handler-hardening.json'), result.compiledHandlers.hardening, artifactRecords);
1768
+ writeJson(path.join(outDir, 'compiled-handler-smoke.json'), result.compiledHandlers.smoke, artifactRecords);
1769
+ for (const file of result.compiledHandlers.files || []) {
1770
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1771
+ }
1772
+ for (const output of result.compiledHandlers.outputFiles || []) {
1773
+ const abs = path.resolve(cwd, output.file);
1774
+ if (fs.existsSync(abs)) {
1775
+ const buffer = fs.readFileSync(abs);
1776
+ artifactRecords.push(makeArtifactRecord(artifactName(outDir, abs), undefined, buffer));
1777
+ }
1778
+ }
1779
+ }
1780
+ if (result.deploymentPosture) {
1781
+ writeJson(path.join(outDir, 'deployment-posture.json'), result.deploymentPosture.artifact, artifactRecords);
1782
+ }
1783
+ if (result.dispatchTs) {
1784
+ writeJson(path.join(outDir, 'generated/manifest.json'), result.dispatchTs.manifest, artifactRecords, outDir);
1785
+ for (const file of result.dispatchTs.files) {
1786
+ writeText(path.join(outDir, file.file), file.text, artifactRecords, outDir);
1787
+ }
1788
+ }
1789
+ writeJson(path.join(outDir, 'route-plan.json'), result.routePlan, artifactRecords);
1790
+ writeJson(path.join(outDir, 'route-id-map.json'), result.routeIdMap, artifactRecords);
1791
+ writeJson(path.join(outDir, 'router-ir.json'), result.routerIR, artifactRecords);
1792
+ writeJson(path.join(outDir, 'router-tree.json'), result.routerTree, artifactRecords);
1793
+ writeDiagnostics(outDir, diagnostics, artifactRecords);
1794
+ if (args.command === 'doctor') {
1795
+ writeDoctor(outDir, args, diagnostics, result, resolvedConfig, artifactRecords);
1796
+ }
1797
+ if (args.includeAst) {
1798
+ writeJson(path.join(outDir, 'ast.json'), result.ast, artifactRecords);
1799
+ }
1800
+ writeBuildManifest(outDir, {
1801
+ cwd,
1802
+ outDir,
1803
+ args,
1804
+ status: 'ok',
1805
+ resolvedConfig,
1806
+ result,
1807
+ diagnostics,
1808
+ entry,
1809
+ rootRouter: root
1810
+ }, artifactRecords);
1811
+
1812
+ const completion = args.command === 'plan' ? 'PulseWasm plan complete.' : args.command === 'doctor' ? 'PulseWasm doctor complete.' : 'PulseWasm build complete.';
1813
+ stdout.write(`${completion}\n`);
1814
+ if (resolvedConfig) stdout.write(` resolved config: ${path.join(outDir, 'resolved-config.json')}\n`);
1815
+ if (args.command === 'doctor') stdout.write(` doctor: ${path.join(outDir, 'cli-doctor.json')}\n`);
1816
+ stdout.write(` symbol index: ${path.join(outDir, 'symbol-index.json')}\n`);
1817
+ stdout.write(` handler table: ${path.join(outDir, 'handler-table.json')}\n`);
1818
+ stdout.write(` handler eval: ${path.join(outDir, 'handler-eval.json')}\n`);
1819
+ stdout.write(` path table: ${path.join(outDir, 'path-table.json')}\n`);
1820
+ stdout.write(` dispatch table: ${path.join(outDir, 'dispatch-table.json')}\n`);
1821
+ stdout.write(` execution plan: ${path.join(outDir, 'execution-plan.json')}\n`);
1822
+ if (result.handlerBindings) stdout.write(` handler bindings: ${path.join(outDir, 'handler-bindings.json')}\n`);
1823
+ if (result.executionHarness) stdout.write(` execution harness: ${path.join(outDir, 'execution-harness.json')}\n`);
1824
+ if (result.localHarness) stdout.write(` local harness: ${path.join(outDir, 'local-harness.json')}\n`);
1825
+ if (result.assemblyScriptShape) stdout.write(` AssemblyScript shape: ${path.join(outDir, 'assemblyscript-shape.json')}\n`);
1826
+ if (result.assemblyScriptCore) {
1827
+ stdout.write(` AssemblyScript core: ${path.join(outDir, 'assemblyscript-core.json')}\n`);
1828
+ if (result.assemblyScriptCore.handlersArtifact) stdout.write(` AssemblyScript handlers: ${path.join(outDir, 'assemblyscript-handlers.json')}\n`);
1829
+ }
1830
+ if (result.assemblyScriptCompile) stdout.write(` AssemblyScript compile: ${path.join(outDir, 'assemblyscript-compile.json')}\n`);
1831
+ if (result.assemblyScriptWasmSmoke) stdout.write(` AssemblyScript Wasm smoke: ${path.join(outDir, 'assemblyscript-wasm-smoke.json')}\n`);
1832
+ if (result.wasmHostAbi) stdout.write(` Wasm host ABI: ${path.join(outDir, 'wasm-host-abi.json')}\n`);
1833
+ if (result.wasmHostBridge) stdout.write(` Wasm host bridge: ${path.join(outDir, 'wasm-host-bridge.json')}\n`);
1834
+ if (result.requestResultHeaders) stdout.write(` request/result/headers: ${path.join(outDir, 'request-result-headers.json')}\n`);
1835
+ if (result.channelBroadcaster) stdout.write(` channel/broadcaster: ${path.join(outDir, 'channel-broadcaster.json')}\n`);
1836
+ if (result.jsonBody) stdout.write(` JSON/body ABI: ${path.join(outDir, 'json-body.json')}\n`);
1837
+ if (result.backendCapabilities) stdout.write(` backend capabilities: ${path.join(outDir, 'backend-capabilities.json')}\n`);
1838
+ if (result.hostRuntimeKernel) stdout.write(` host runtime kernel: ${path.join(outDir, 'host-runtime-kernel.json')}\n`);
1839
+ if (result.nodeAdapter) stdout.write(` Node adapter: ${path.join(outDir, 'node-adapter.json')}\n`);
1840
+ if (result.handlerLibraryContracts) stdout.write(` handler/library contracts: ${path.join(outDir, 'handler-library-contracts.json')}\n`);
1841
+ if (result.assetsLoweringPlan) stdout.write(` assets lowering plan: ${path.join(outDir, 'assets-lowering-plan.json')}\n`);
1842
+ if (result.assetsCompiledWasmSidecarPlan) stdout.write(` assets compiled-Wasm sidecar plan: ${path.join(outDir, 'assets-compiled-wasm-sidecar-plan.json')}\n`);
1843
+ if (result.assetsSidecarCompileLinkProof) stdout.write(` assets sidecar compile/link proof: ${path.join(outDir, 'assets-sidecar-compile-link-proof.json')}\n`);
1844
+ if (result.nodeAssetsProviderProof) stdout.write(` Node assets provider proof: ${path.join(outDir, 'node-assets-provider-proof.json')}\n`);
1845
+ if (result.nodeCompiledWasmAssetsLifecycleProof) stdout.write(` Node compiled-Wasm assets lifecycle proof: ${path.join(outDir, 'node-compiled-wasm-assets-lifecycle-proof.json')}\n`);
1846
+ if (result.fastlyAssetsProviderProof) stdout.write(` Fastly assets provider proof: ${path.join(outDir, 'fastly-assets-provider-proof.json')}\n`);
1847
+ if (result.fastlyAssetsPackageOutParityProof) stdout.write(` Fastly assets package-out parity proof: ${path.join(outDir, 'fastly-assets-package-out-parity-proof.json')}\n`);
1848
+ if (result.routeHandlerEffectPlan) stdout.write(` route handler effect plan: ${path.join(outDir, 'route-handler-effect-plan.json')}\n`);
1849
+ if (result.nodeRouteHandlerEffectProof) stdout.write(` Node route handler effect proof: ${path.join(outDir, 'node-route-handler-effect-proof.json')}\n`);
1850
+ if (result.nodeLiveOriginRouteHandlerEffectProof) stdout.write(` Node live-origin route handler effect proof: ${path.join(outDir, 'node-live-origin-route-handler-effect-proof.json')}\n`);
1851
+ if (result.nodeCompiledRouteHandlerEffectBridge) stdout.write(` Node compiled route handler effect bridge: ${path.join(outDir, 'node-compiled-route-handler-effect-bridge.json')}\n`);
1852
+ if (result.fastlyRouteHandlerEffectProof) stdout.write(` Fastly route handler effect proof: ${path.join(outDir, 'fastly-route-handler-effect-proof.json')}\n`);
1853
+ if (result.fastlyLifecycleParityProof) stdout.write(` Fastly lifecycle parity proof: ${path.join(outDir, 'fastly-lifecycle-parity-proof.json')}\n`);
1854
+ if (result.routeHandlerContextLoweringPlan) stdout.write(` route handler context lowering plan: ${path.join(outDir, 'route-handler-context-lowering-plan.json')}\n`);
1855
+ if (result.handlerIoLifecyclePlan) stdout.write(` handler I/O lifecycle plan: ${path.join(outDir, 'handler-io-lifecycle-plan.json')}\n`);
1856
+ if (result.requestJsonBodyPlan) stdout.write(` request JSON body plan: ${path.join(outDir, 'request-json-body-plan.json')}\n`);
1857
+ if (result.backendJsonRequestBodyPlan) stdout.write(` backend JSON request body plan: ${path.join(outDir, 'backend-json-request-body-plan.json')}\n`);
1858
+ if (result.nodeBackendJsonRequestBodyProof) stdout.write(` Node backend JSON request body proof: ${path.join(outDir, 'node-backend-json-request-body-proof.json')}\n`);
1859
+ if (result.nodeRequestJsonBodyProof) stdout.write(` Node request JSON body proof: ${path.join(outDir, 'node-request-json-body-proof.json')}\n`);
1860
+ if (result.hostCapabilities) stdout.write(` host capabilities: ${path.join(outDir, 'host-capabilities.json')}\n`);
1861
+ if (result.effectRuntime) stdout.write(` effect runtime: ${path.join(outDir, 'effect-runtime.json')}\n`);
1862
+ if (result.effectComposition) stdout.write(` effect composition: ${path.join(outDir, 'effect-composition.json')}\n`);
1863
+ if (result.schemaJsonCompile) stdout.write(` schema JSON compile: ${path.join(outDir, 'schema-json-compile.json')}\n`);
1864
+ if (result.schemaJsonGenericParser) stdout.write(` schema JSON generic parser: ${path.join(outDir, 'schema-json-generic-parser.json')}\n`);
1865
+ if (result.schemaJsonSidecar) stdout.write(` schema JSON sidecar: ${path.join(outDir, 'schema-json-sidecar.json')}\n`);
1866
+ if (result.librarySidecars) stdout.write(` library sidecars: ${path.join(outDir, 'library-sidecar-consumption.json')}\n`);
1867
+ if (result.streamingPassthrough) stdout.write(` streaming/pass-through: ${path.join(outDir, 'streaming-passthrough.json')}\n`);
1868
+ if (result.compiledHandlers) stdout.write(` compiled handlers: ${path.join(outDir, 'compiled-handler-plan.json')}\n`);
1869
+ if (result.compiledWasmRuntime) stdout.write(` compiled-wasm runtime: ${path.join(outDir, 'compiled-wasm-runtime.json')}\n`);
1870
+ if (result.pulseWrapper) stdout.write(` Pulse wrapper: ${path.join(outDir, 'wrapper-integration.json')}\n`);
1871
+ if (result.fastlyReadiness) stdout.write(` Fastly readiness: ${path.join(outDir, 'fastly-readiness.json')}\n`);
1872
+ if (result.fastlyHostcallBinding) stdout.write(` Fastly hostcall binding: ${path.join(outDir, 'fastly-hostcall-binding-contract.json')}\n`);
1873
+ if (result.fastlyAdapter) stdout.write(` Fastly adapter: ${path.join(outDir, 'fastly-adapter.json')}\n`);
1874
+ if (result.fastlyCommandEntry) stdout.write(` Fastly command entry: ${path.join(outDir, 'fastly-command-entry.json')}\n`);
1875
+ if (result.deploymentPosture) stdout.write(` deployment posture: ${path.join(outDir, 'deployment-posture.json')}\n`);
1876
+ if (result.dispatchTs) stdout.write(` dispatch TS: ${path.join(outDir, 'generated/dispatch.ts')}\n`);
1877
+ stdout.write(` route-plan: ${path.join(outDir, 'route-plan.json')}\n`);
1878
+ stdout.write(` route-id-map: ${path.join(outDir, 'route-id-map.json')}\n`);
1879
+ stdout.write(` router IR: ${path.join(outDir, 'router-ir.json')}\n`);
1880
+ stdout.write(` tree: ${path.join(outDir, 'router-tree.json')}\n`);
1881
+ stdout.write(` diagnostics: ${path.join(outDir, 'diagnostics.json')}\n`);
1882
+ if (args.includeAst) stdout.write(` AST: ${path.join(outDir, 'ast.json')}\n`);
1883
+ stdout.write(` build manifest: ${path.join(outDir, 'build-manifest.json')}\n`);
1884
+ exitIfRequested();
1885
+ } catch (error) {
1886
+ if (error instanceof ExtractionError) {
1887
+ const diagnostics = createDiagnosticsEnvelope({
1888
+ source: error.source || entry || args.entry || args.config || '<cli>',
1889
+ status: 'error',
1890
+ diagnostics: error.diagnostics,
1891
+ passes: error.passes || [],
1892
+ summary: { ...(error.summary || {}), strict: args.strict },
1893
+ cwd
1894
+ });
1895
+ try {
1896
+ writeDiagnostics(outDir, diagnostics, artifactRecords);
1897
+ if (args.command === 'doctor') {
1898
+ writeDoctor(outDir, args, diagnostics, null, resolvedConfig, artifactRecords);
1899
+ }
1900
+ writeBuildManifest(outDir, {
1901
+ cwd,
1902
+ outDir,
1903
+ args,
1904
+ status: 'error',
1905
+ resolvedConfig,
1906
+ diagnostics,
1907
+ entry,
1908
+ rootRouter: root
1909
+ }, artifactRecords);
1910
+ } catch (_) {
1911
+ // stderr remains the fallback when the diagnostics artifacts cannot be written.
1912
+ }
1913
+ stderr.write(`${args.command === 'doctor' ? 'PulseWasm doctor failed.' : args.command === 'plan' ? 'PulseWasm plan failed.' : 'PulseWasm build failed.'}\n${formatDiagnostics(error.diagnostics)}\n`);
1914
+ stderr.write(` diagnostics: ${path.join(outDir, 'diagnostics.json')}\n`);
1915
+ stderr.write(` build manifest: ${path.join(outDir, 'build-manifest.json')}\n`);
1916
+ process.exitCode = 1;
1917
+ return;
1918
+ }
1919
+ throw error;
1920
+ }
1921
+ }
1922
+
1923
+ module.exports = {
1924
+ parseArgs,
1925
+ runCli,
1926
+ usage
1927
+ };