@synergenius/flow-weaver 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +122 -0
- package/README.md +315 -0
- package/dist/annotation-generator.d.ts +45 -0
- package/dist/annotation-generator.js +557 -0
- package/dist/api/builder.d.ts +223 -0
- package/dist/api/builder.js +345 -0
- package/dist/api/compile.d.ts +92 -0
- package/dist/api/compile.js +149 -0
- package/dist/api/extract-types.d.ts +29 -0
- package/dist/api/extract-types.js +57 -0
- package/dist/api/generate-in-place.d.ts +73 -0
- package/dist/api/generate-in-place.js +1353 -0
- package/dist/api/generate.d.ts +83 -0
- package/dist/api/generate.js +510 -0
- package/dist/api/helpers.d.ts +248 -0
- package/dist/api/helpers.js +285 -0
- package/dist/api/index.d.ts +46 -0
- package/dist/api/index.js +45 -0
- package/dist/api/inline-runtime.d.ts +27 -0
- package/dist/api/inline-runtime.js +551 -0
- package/dist/api/manipulation/connections.d.ts +79 -0
- package/dist/api/manipulation/connections.js +151 -0
- package/dist/api/manipulation/index.d.ts +34 -0
- package/dist/api/manipulation/index.js +41 -0
- package/dist/api/manipulation/node-types.d.ts +123 -0
- package/dist/api/manipulation/node-types.js +200 -0
- package/dist/api/manipulation/nodes.d.ts +144 -0
- package/dist/api/manipulation/nodes.js +333 -0
- package/dist/api/manipulation/ports.d.ts +59 -0
- package/dist/api/manipulation/ports.js +228 -0
- package/dist/api/manipulation/scopes.d.ts +52 -0
- package/dist/api/manipulation/scopes.js +156 -0
- package/dist/api/manipulation/validation.d.ts +6 -0
- package/dist/api/manipulation/validation.js +6 -0
- package/dist/api/manipulation/workflow.d.ts +81 -0
- package/dist/api/manipulation/workflow.js +116 -0
- package/dist/api/manipulation.d.ts +8 -0
- package/dist/api/manipulation.js +8 -0
- package/dist/api/parse.d.ts +48 -0
- package/dist/api/parse.js +110 -0
- package/dist/api/patterns.d.ts +112 -0
- package/dist/api/patterns.js +306 -0
- package/dist/api/query.d.ts +429 -0
- package/dist/api/query.js +816 -0
- package/dist/api/templates.d.ts +98 -0
- package/dist/api/templates.js +117 -0
- package/dist/api/transform.d.ts +31 -0
- package/dist/api/transform.js +40 -0
- package/dist/api/validate.d.ts +25 -0
- package/dist/api/validate.js +39 -0
- package/dist/api/workflow-file-operations.d.ts +29 -0
- package/dist/api/workflow-file-operations.js +180 -0
- package/dist/ast/builder.d.ts +210 -0
- package/dist/ast/builder.js +395 -0
- package/dist/ast/index.d.ts +5 -0
- package/dist/ast/index.js +5 -0
- package/dist/ast/serialization-node.d.ts +6 -0
- package/dist/ast/serialization-node.js +30 -0
- package/dist/ast/serialization.d.ts +43 -0
- package/dist/ast/serialization.js +134 -0
- package/dist/ast/types.d.ts +852 -0
- package/dist/ast/types.js +2 -0
- package/dist/ast/workflow-utils.d.ts +54 -0
- package/dist/ast/workflow-utils.js +114 -0
- package/dist/body-generator.d.ts +31 -0
- package/dist/body-generator.js +35 -0
- package/dist/built-in-nodes/delay.d.ts +11 -0
- package/dist/built-in-nodes/delay.js +29 -0
- package/dist/built-in-nodes/index.d.ts +5 -0
- package/dist/built-in-nodes/index.js +4 -0
- package/dist/built-in-nodes/invoke-workflow.d.ts +13 -0
- package/dist/built-in-nodes/invoke-workflow.js +25 -0
- package/dist/built-in-nodes/mock-types.d.ts +18 -0
- package/dist/built-in-nodes/mock-types.js +12 -0
- package/dist/built-in-nodes/wait-for-event.d.ts +13 -0
- package/dist/built-in-nodes/wait-for-event.js +25 -0
- package/dist/chevrotain-parser/connect-parser.d.ts +24 -0
- package/dist/chevrotain-parser/connect-parser.js +98 -0
- package/dist/chevrotain-parser/grammar-diagrams.d.ts +29 -0
- package/dist/chevrotain-parser/grammar-diagrams.js +264 -0
- package/dist/chevrotain-parser/index.d.ts +25 -0
- package/dist/chevrotain-parser/index.js +27 -0
- package/dist/chevrotain-parser/map-parser.d.ts +33 -0
- package/dist/chevrotain-parser/map-parser.js +130 -0
- package/dist/chevrotain-parser/node-parser.d.ts +36 -0
- package/dist/chevrotain-parser/node-parser.js +466 -0
- package/dist/chevrotain-parser/path-parser.d.ts +28 -0
- package/dist/chevrotain-parser/path-parser.js +118 -0
- package/dist/chevrotain-parser/port-parser.d.ts +36 -0
- package/dist/chevrotain-parser/port-parser.js +442 -0
- package/dist/chevrotain-parser/position-parser.d.ts +20 -0
- package/dist/chevrotain-parser/position-parser.js +83 -0
- package/dist/chevrotain-parser/scope-parser.d.ts +19 -0
- package/dist/chevrotain-parser/scope-parser.js +104 -0
- package/dist/chevrotain-parser/tokens.d.ts +78 -0
- package/dist/chevrotain-parser/tokens.js +384 -0
- package/dist/chevrotain-parser/trigger-cancel-parser.d.ts +50 -0
- package/dist/chevrotain-parser/trigger-cancel-parser.js +282 -0
- package/dist/cli/commands/changelog.d.ts +13 -0
- package/dist/cli/commands/changelog.js +135 -0
- package/dist/cli/commands/compile.d.ts +64 -0
- package/dist/cli/commands/compile.js +278 -0
- package/dist/cli/commands/create.d.ts +33 -0
- package/dist/cli/commands/create.js +147 -0
- package/dist/cli/commands/describe.d.ts +68 -0
- package/dist/cli/commands/describe.js +377 -0
- package/dist/cli/commands/dev.d.ts +32 -0
- package/dist/cli/commands/dev.js +384 -0
- package/dist/cli/commands/diagram.d.ts +13 -0
- package/dist/cli/commands/diagram.js +33 -0
- package/dist/cli/commands/diff.d.ts +11 -0
- package/dist/cli/commands/diff.js +59 -0
- package/dist/cli/commands/doctor.d.ts +57 -0
- package/dist/cli/commands/doctor.js +719 -0
- package/dist/cli/commands/export.d.ts +57 -0
- package/dist/cli/commands/export.js +163 -0
- package/dist/cli/commands/grammar.d.ts +9 -0
- package/dist/cli/commands/grammar.js +39 -0
- package/dist/cli/commands/init.d.ts +59 -0
- package/dist/cli/commands/init.js +435 -0
- package/dist/cli/commands/listen.d.ts +16 -0
- package/dist/cli/commands/listen.js +39 -0
- package/dist/cli/commands/market.d.ts +52 -0
- package/dist/cli/commands/market.js +436 -0
- package/dist/cli/commands/migrate.d.ts +13 -0
- package/dist/cli/commands/migrate.js +89 -0
- package/dist/cli/commands/openapi.d.ts +37 -0
- package/dist/cli/commands/openapi.js +67 -0
- package/dist/cli/commands/pattern.d.ts +34 -0
- package/dist/cli/commands/pattern.js +185 -0
- package/dist/cli/commands/plugin.d.ts +16 -0
- package/dist/cli/commands/plugin.js +176 -0
- package/dist/cli/commands/run.d.ts +49 -0
- package/dist/cli/commands/run.js +191 -0
- package/dist/cli/commands/serve.d.ts +45 -0
- package/dist/cli/commands/serve.js +81 -0
- package/dist/cli/commands/templates.d.ts +8 -0
- package/dist/cli/commands/templates.js +54 -0
- package/dist/cli/commands/ui.d.ts +16 -0
- package/dist/cli/commands/ui.js +130 -0
- package/dist/cli/commands/validate.d.ts +12 -0
- package/dist/cli/commands/validate.js +247 -0
- package/dist/cli/commands/watch.d.ts +9 -0
- package/dist/cli/commands/watch.js +70 -0
- package/dist/cli/flow-weaver.mjs +92924 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +742 -0
- package/dist/cli/templates/ai/mock-provider.d.ts +7 -0
- package/dist/cli/templates/ai/mock-provider.js +64 -0
- package/dist/cli/templates/ai/types.d.ts +47 -0
- package/dist/cli/templates/ai/types.js +5 -0
- package/dist/cli/templates/approvals/index.d.ts +15 -0
- package/dist/cli/templates/approvals/index.js +241 -0
- package/dist/cli/templates/index.d.ts +102 -0
- package/dist/cli/templates/index.js +101 -0
- package/dist/cli/templates/nodes/agent-router.d.ts +3 -0
- package/dist/cli/templates/nodes/agent-router.js +114 -0
- package/dist/cli/templates/nodes/aggregator.d.ts +7 -0
- package/dist/cli/templates/nodes/aggregator.js +63 -0
- package/dist/cli/templates/nodes/conversation-memory.d.ts +3 -0
- package/dist/cli/templates/nodes/conversation-memory.js +85 -0
- package/dist/cli/templates/nodes/http.d.ts +7 -0
- package/dist/cli/templates/nodes/http.js +80 -0
- package/dist/cli/templates/nodes/human-approval.d.ts +3 -0
- package/dist/cli/templates/nodes/human-approval.js +110 -0
- package/dist/cli/templates/nodes/json-extractor.d.ts +3 -0
- package/dist/cli/templates/nodes/json-extractor.js +119 -0
- package/dist/cli/templates/nodes/llm-call.d.ts +3 -0
- package/dist/cli/templates/nodes/llm-call.js +106 -0
- package/dist/cli/templates/nodes/prompt-template.d.ts +3 -0
- package/dist/cli/templates/nodes/prompt-template.js +52 -0
- package/dist/cli/templates/nodes/rag-retriever.d.ts +3 -0
- package/dist/cli/templates/nodes/rag-retriever.js +128 -0
- package/dist/cli/templates/nodes/tool-executor.d.ts +3 -0
- package/dist/cli/templates/nodes/tool-executor.js +108 -0
- package/dist/cli/templates/nodes/transformer.d.ts +7 -0
- package/dist/cli/templates/nodes/transformer.js +68 -0
- package/dist/cli/templates/nodes/validator.d.ts +7 -0
- package/dist/cli/templates/nodes/validator.js +62 -0
- package/dist/cli/templates/providers/index.d.ts +14 -0
- package/dist/cli/templates/providers/index.js +239 -0
- package/dist/cli/templates/shared/approval-types.d.ts +9 -0
- package/dist/cli/templates/shared/approval-types.js +31 -0
- package/dist/cli/templates/shared/llm-types.d.ts +15 -0
- package/dist/cli/templates/shared/llm-types.js +104 -0
- package/dist/cli/templates/workflows/aggregator.d.ts +7 -0
- package/dist/cli/templates/workflows/aggregator.js +104 -0
- package/dist/cli/templates/workflows/ai-agent-durable.d.ts +8 -0
- package/dist/cli/templates/workflows/ai-agent-durable.js +338 -0
- package/dist/cli/templates/workflows/ai-agent.d.ts +31 -0
- package/dist/cli/templates/workflows/ai-agent.js +326 -0
- package/dist/cli/templates/workflows/ai-chat.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-chat.js +169 -0
- package/dist/cli/templates/workflows/ai-pipeline-durable.d.ts +8 -0
- package/dist/cli/templates/workflows/ai-pipeline-durable.js +330 -0
- package/dist/cli/templates/workflows/ai-rag.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-rag.js +186 -0
- package/dist/cli/templates/workflows/ai-react.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-react.js +294 -0
- package/dist/cli/templates/workflows/conditional.d.ts +12 -0
- package/dist/cli/templates/workflows/conditional.js +142 -0
- package/dist/cli/templates/workflows/error-handler.d.ts +7 -0
- package/dist/cli/templates/workflows/error-handler.js +147 -0
- package/dist/cli/templates/workflows/foreach.d.ts +7 -0
- package/dist/cli/templates/workflows/foreach.js +143 -0
- package/dist/cli/templates/workflows/sequential.d.ts +7 -0
- package/dist/cli/templates/workflows/sequential.js +198 -0
- package/dist/cli/templates/workflows/webhook.d.ts +7 -0
- package/dist/cli/templates/workflows/webhook.js +161 -0
- package/dist/cli/utils/logger.d.ts +15 -0
- package/dist/cli/utils/logger.js +46 -0
- package/dist/constants.d.ts +100 -0
- package/dist/constants.js +125 -0
- package/dist/defaults.d.ts +3 -0
- package/dist/defaults.js +3 -0
- package/dist/deployment/config/defaults.d.ts +29 -0
- package/dist/deployment/config/defaults.js +98 -0
- package/dist/deployment/config/loader.d.ts +24 -0
- package/dist/deployment/config/loader.js +236 -0
- package/dist/deployment/config/types.d.ts +117 -0
- package/dist/deployment/config/types.js +5 -0
- package/dist/deployment/core/adapters.d.ts +90 -0
- package/dist/deployment/core/adapters.js +251 -0
- package/dist/deployment/core/executor.d.ts +62 -0
- package/dist/deployment/core/executor.js +197 -0
- package/dist/deployment/core/formatters.d.ts +57 -0
- package/dist/deployment/core/formatters.js +170 -0
- package/dist/deployment/index.d.ts +31 -0
- package/dist/deployment/index.js +48 -0
- package/dist/deployment/openapi/generator.d.ts +146 -0
- package/dist/deployment/openapi/generator.js +347 -0
- package/dist/deployment/openapi/schema-converter.d.ts +49 -0
- package/dist/deployment/openapi/schema-converter.js +192 -0
- package/dist/deployment/targets/base.d.ts +316 -0
- package/dist/deployment/targets/base.js +823 -0
- package/dist/deployment/targets/cloudflare.d.ts +23 -0
- package/dist/deployment/targets/cloudflare.js +1125 -0
- package/dist/deployment/targets/inngest.d.ts +38 -0
- package/dist/deployment/targets/inngest.js +926 -0
- package/dist/deployment/targets/lambda.d.ts +23 -0
- package/dist/deployment/targets/lambda.js +1289 -0
- package/dist/deployment/targets/vercel.d.ts +23 -0
- package/dist/deployment/targets/vercel.js +886 -0
- package/dist/deployment/types.d.ts +183 -0
- package/dist/deployment/types.js +8 -0
- package/dist/diagram/geometry.d.ts +26 -0
- package/dist/diagram/geometry.js +850 -0
- package/dist/diagram/index.d.ts +16 -0
- package/dist/diagram/index.js +42 -0
- package/dist/diagram/layout.d.ts +11 -0
- package/dist/diagram/layout.js +143 -0
- package/dist/diagram/orthogonal-router.d.ts +79 -0
- package/dist/diagram/orthogonal-router.js +568 -0
- package/dist/diagram/renderer.d.ts +3 -0
- package/dist/diagram/renderer.js +207 -0
- package/dist/diagram/theme.d.ts +20 -0
- package/dist/diagram/theme.js +189 -0
- package/dist/diagram/types.d.ts +70 -0
- package/dist/diagram/types.js +2 -0
- package/dist/diff/WorkflowDiffer.d.ts +13 -0
- package/dist/diff/WorkflowDiffer.js +429 -0
- package/dist/diff/formatDiff.d.ts +10 -0
- package/dist/diff/formatDiff.js +220 -0
- package/dist/diff/impact.d.ts +29 -0
- package/dist/diff/impact.js +119 -0
- package/dist/diff/index.d.ts +10 -0
- package/dist/diff/index.js +9 -0
- package/dist/diff/types.d.ts +138 -0
- package/dist/diff/types.js +35 -0
- package/dist/doc-metadata/extractors/annotations.d.ts +56 -0
- package/dist/doc-metadata/extractors/annotations.js +337 -0
- package/dist/doc-metadata/extractors/cli-commands.d.ts +17 -0
- package/dist/doc-metadata/extractors/cli-commands.js +355 -0
- package/dist/doc-metadata/extractors/mcp-tools.d.ts +16 -0
- package/dist/doc-metadata/extractors/mcp-tools.js +689 -0
- package/dist/doc-metadata/extractors/plugin-api.d.ts +19 -0
- package/dist/doc-metadata/extractors/plugin-api.js +279 -0
- package/dist/doc-metadata/index.d.ts +5 -0
- package/dist/doc-metadata/index.js +4 -0
- package/dist/doc-metadata/types.d.ts +120 -0
- package/dist/doc-metadata/types.js +5 -0
- package/dist/editor-completions/annotationValues.d.ts +12 -0
- package/dist/editor-completions/annotationValues.js +138 -0
- package/dist/editor-completions/contextParser.d.ts +40 -0
- package/dist/editor-completions/contextParser.js +410 -0
- package/dist/editor-completions/dataTypes.d.ts +16 -0
- package/dist/editor-completions/dataTypes.js +95 -0
- package/dist/editor-completions/goToDefinition.d.ts +27 -0
- package/dist/editor-completions/goToDefinition.js +112 -0
- package/dist/editor-completions/index.d.ts +39 -0
- package/dist/editor-completions/index.js +181 -0
- package/dist/editor-completions/jsDocAnnotations.d.ts +29 -0
- package/dist/editor-completions/jsDocAnnotations.js +357 -0
- package/dist/editor-completions/modifierCompletions.d.ts +17 -0
- package/dist/editor-completions/modifierCompletions.js +197 -0
- package/dist/editor-completions/types.d.ts +119 -0
- package/dist/editor-completions/types.js +8 -0
- package/dist/export/index.d.ts +68 -0
- package/dist/export/index.js +1074 -0
- package/dist/export/templates.d.ts +24 -0
- package/dist/export/templates.js +186 -0
- package/dist/friendly-errors.d.ts +35 -0
- package/dist/friendly-errors.js +375 -0
- package/dist/function-like.d.ts +38 -0
- package/dist/function-like.js +83 -0
- package/dist/generated-branding.d.ts +16 -0
- package/dist/generated-branding.js +22 -0
- package/dist/generator/async-detection.d.ts +27 -0
- package/dist/generator/async-detection.js +56 -0
- package/dist/generator/code-utils.d.ts +76 -0
- package/dist/generator/code-utils.js +410 -0
- package/dist/generator/control-flow.d.ts +54 -0
- package/dist/generator/control-flow.js +284 -0
- package/dist/generator/inngest.d.ts +53 -0
- package/dist/generator/inngest.js +1126 -0
- package/dist/generator/scope-function-generator.d.ts +78 -0
- package/dist/generator/scope-function-generator.js +360 -0
- package/dist/generator/unified.d.ts +42 -0
- package/dist/generator/unified.js +1504 -0
- package/dist/generator.d.ts +54 -0
- package/dist/generator.js +100 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +89 -0
- package/dist/jsdoc-parser.d.ts +308 -0
- package/dist/jsdoc-parser.js +923 -0
- package/dist/jsdoc-port-sync/constants.d.ts +41 -0
- package/dist/jsdoc-port-sync/constants.js +103 -0
- package/dist/jsdoc-port-sync/diff.d.ts +76 -0
- package/dist/jsdoc-port-sync/diff.js +319 -0
- package/dist/jsdoc-port-sync/index.d.ts +42 -0
- package/dist/jsdoc-port-sync/index.js +45 -0
- package/dist/jsdoc-port-sync/port-parser.d.ts +68 -0
- package/dist/jsdoc-port-sync/port-parser.js +579 -0
- package/dist/jsdoc-port-sync/rename.d.ts +21 -0
- package/dist/jsdoc-port-sync/rename.js +256 -0
- package/dist/jsdoc-port-sync/signature-parser.d.ts +104 -0
- package/dist/jsdoc-port-sync/signature-parser.js +559 -0
- package/dist/jsdoc-port-sync/sync.d.ts +36 -0
- package/dist/jsdoc-port-sync/sync.js +644 -0
- package/dist/jsdoc-port-sync.d.ts +10 -0
- package/dist/jsdoc-port-sync.js +10 -0
- package/dist/marketplace/index.d.ts +11 -0
- package/dist/marketplace/index.js +10 -0
- package/dist/marketplace/manifest.d.ts +32 -0
- package/dist/marketplace/manifest.js +176 -0
- package/dist/marketplace/registry.d.ts +30 -0
- package/dist/marketplace/registry.js +100 -0
- package/dist/marketplace/types.d.ts +154 -0
- package/dist/marketplace/types.js +9 -0
- package/dist/marketplace/validator.d.ts +13 -0
- package/dist/marketplace/validator.js +131 -0
- package/dist/mcp/auto-registration.d.ts +3 -0
- package/dist/mcp/auto-registration.js +62 -0
- package/dist/mcp/editor-connection.d.ts +50 -0
- package/dist/mcp/editor-connection.js +125 -0
- package/dist/mcp/event-buffer.d.ts +62 -0
- package/dist/mcp/event-buffer.js +150 -0
- package/dist/mcp/index.d.ts +12 -0
- package/dist/mcp/index.js +11 -0
- package/dist/mcp/resources.d.ts +14 -0
- package/dist/mcp/resources.js +55 -0
- package/dist/mcp/response-utils.d.ts +63 -0
- package/dist/mcp/response-utils.js +89 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +99 -0
- package/dist/mcp/tools-diagram.d.ts +8 -0
- package/dist/mcp/tools-diagram.js +53 -0
- package/dist/mcp/tools-editor.d.ts +5 -0
- package/dist/mcp/tools-editor.js +190 -0
- package/dist/mcp/tools-export.d.ts +9 -0
- package/dist/mcp/tools-export.js +180 -0
- package/dist/mcp/tools-marketplace.d.ts +9 -0
- package/dist/mcp/tools-marketplace.js +132 -0
- package/dist/mcp/tools-pattern.d.ts +3 -0
- package/dist/mcp/tools-pattern.js +783 -0
- package/dist/mcp/tools-query.d.ts +3 -0
- package/dist/mcp/tools-query.js +364 -0
- package/dist/mcp/tools-template.d.ts +10 -0
- package/dist/mcp/tools-template.js +119 -0
- package/dist/mcp/types.d.ts +70 -0
- package/dist/mcp/types.js +8 -0
- package/dist/mcp/workflow-executor.d.ts +47 -0
- package/dist/mcp/workflow-executor.js +133 -0
- package/dist/migration/registry.d.ts +30 -0
- package/dist/migration/registry.js +29 -0
- package/dist/node-types-generator.d.ts +49 -0
- package/dist/node-types-generator.js +139 -0
- package/dist/npm-packages.d.ts +56 -0
- package/dist/npm-packages.js +255 -0
- package/dist/parser.d.ts +204 -0
- package/dist/parser.js +2100 -0
- package/dist/plugin/PluginPanel.d.ts +12 -0
- package/dist/plugin/PluginPanel.js +5 -0
- package/dist/plugin/index.d.ts +13 -0
- package/dist/plugin/index.js +14 -0
- package/dist/plugin/types.d.ts +75 -0
- package/dist/plugin/types.js +8 -0
- package/dist/resolve-package-types.d.ts +17 -0
- package/dist/resolve-package-types.js +123 -0
- package/dist/runtime/CancellationError.d.ts +11 -0
- package/dist/runtime/CancellationError.js +20 -0
- package/dist/runtime/ExecutionContext.d.ts +146 -0
- package/dist/runtime/ExecutionContext.js +235 -0
- package/dist/runtime/builtin-functions.d.ts +8 -0
- package/dist/runtime/builtin-functions.js +549 -0
- package/dist/runtime/events.d.ts +50 -0
- package/dist/runtime/events.js +2 -0
- package/dist/runtime/function-registry.d.ts +59 -0
- package/dist/runtime/function-registry.js +66 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/parameter-resolver.d.ts +62 -0
- package/dist/runtime/parameter-resolver.js +113 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +6 -0
- package/dist/server/types.d.ts +93 -0
- package/dist/server/types.js +5 -0
- package/dist/server/webhook-server.d.ts +50 -0
- package/dist/server/webhook-server.js +269 -0
- package/dist/server/workflow-registry.d.ts +61 -0
- package/dist/server/workflow-registry.js +202 -0
- package/dist/shared-project.d.ts +9 -0
- package/dist/shared-project.js +28 -0
- package/dist/sugar-optimizer.d.ts +40 -0
- package/dist/sugar-optimizer.js +387 -0
- package/dist/testing/assertions.d.ts +51 -0
- package/dist/testing/assertions.js +127 -0
- package/dist/testing/index.d.ts +30 -0
- package/dist/testing/index.js +24 -0
- package/dist/testing/mock-approval.d.ts +81 -0
- package/dist/testing/mock-approval.js +98 -0
- package/dist/testing/mock-llm.d.ts +124 -0
- package/dist/testing/mock-llm.js +119 -0
- package/dist/testing/recorder.d.ts +72 -0
- package/dist/testing/recorder.js +70 -0
- package/dist/testing/replayer.d.ts +56 -0
- package/dist/testing/replayer.js +143 -0
- package/dist/testing/token-tracker.d.ts +71 -0
- package/dist/testing/token-tracker.js +94 -0
- package/dist/type-checker.d.ts +42 -0
- package/dist/type-checker.js +190 -0
- package/dist/type-mappings.d.ts +29 -0
- package/dist/type-mappings.js +125 -0
- package/dist/types/branded-ports.d.ts +151 -0
- package/dist/types/branded-ports.js +121 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.js +15 -0
- package/dist/utils/error-utils.d.ts +15 -0
- package/dist/utils/error-utils.js +27 -0
- package/dist/utils/lru-cache.d.ts +15 -0
- package/dist/utils/lru-cache.js +40 -0
- package/dist/utils/port-ordering.d.ts +26 -0
- package/dist/utils/port-ordering.js +88 -0
- package/dist/utils/port-tag-utils.d.ts +23 -0
- package/dist/utils/port-tag-utils.js +41 -0
- package/dist/utils/string-distance.d.ts +14 -0
- package/dist/utils/string-distance.js +56 -0
- package/dist/validation/agent-detection.d.ts +33 -0
- package/dist/validation/agent-detection.js +115 -0
- package/dist/validation/agent-rules.d.ts +48 -0
- package/dist/validation/agent-rules.js +262 -0
- package/dist/validator.d.ts +92 -0
- package/dist/validator.js +970 -0
- package/package.json +109 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* Doctor command - validates project environment and configuration for flow-weaver compatibility
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import * as YAML from 'js-yaml';
|
|
9
|
+
import { logger } from '../utils/logger.js';
|
|
10
|
+
// ── Utility ──────────────────────────────────────────────────────────────────
|
|
11
|
+
/**
|
|
12
|
+
* Strips single-line (//) and multi-line comments from JSON-like text,
|
|
13
|
+
* preserving string contents that may contain // or slash-star sequences.
|
|
14
|
+
*/
|
|
15
|
+
export function stripJsonComments(text) {
|
|
16
|
+
let result = '';
|
|
17
|
+
let i = 0;
|
|
18
|
+
while (i < text.length) {
|
|
19
|
+
// String literal — copy verbatim
|
|
20
|
+
if (text[i] === '"') {
|
|
21
|
+
const start = i;
|
|
22
|
+
i++; // skip opening quote
|
|
23
|
+
while (i < text.length && text[i] !== '"') {
|
|
24
|
+
if (text[i] === '\\')
|
|
25
|
+
i++; // skip escaped char
|
|
26
|
+
i++;
|
|
27
|
+
}
|
|
28
|
+
i++; // skip closing quote
|
|
29
|
+
result += text.slice(start, i);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
// Single-line comment
|
|
33
|
+
if (text[i] === '/' && text[i + 1] === '/') {
|
|
34
|
+
while (i < text.length && text[i] !== '\n')
|
|
35
|
+
i++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// Multi-line comment
|
|
39
|
+
if (text[i] === '/' && text[i + 1] === '*') {
|
|
40
|
+
i += 2;
|
|
41
|
+
while (i < text.length && !(text[i] === '*' && text[i + 1] === '/'))
|
|
42
|
+
i++;
|
|
43
|
+
i += 2; // skip closing */
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
result += text[i];
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
// ── Module Format Detection ──────────────────────────────────────────────────
|
|
52
|
+
/**
|
|
53
|
+
* Detect the project's module format from package.json and tsconfig.json
|
|
54
|
+
*/
|
|
55
|
+
export function detectProjectModuleFormat(cwd) {
|
|
56
|
+
// First check package.json "type" field
|
|
57
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
58
|
+
if (fs.existsSync(pkgPath)) {
|
|
59
|
+
try {
|
|
60
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
61
|
+
if (pkg.type === 'module') {
|
|
62
|
+
return { format: 'esm', source: 'package.json', details: '"type": "module"' };
|
|
63
|
+
}
|
|
64
|
+
// "commonjs" or no type field means CJS
|
|
65
|
+
if (pkg.type === 'commonjs' || !pkg.type) {
|
|
66
|
+
return {
|
|
67
|
+
format: 'cjs',
|
|
68
|
+
source: 'package.json',
|
|
69
|
+
details: pkg.type ? '"type": "commonjs"' : 'no "type" field (defaults to CommonJS)',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Fall through to tsconfig check
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Check tsconfig.json "module" setting
|
|
78
|
+
const tsconfigPath = path.join(cwd, 'tsconfig.json');
|
|
79
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
80
|
+
try {
|
|
81
|
+
const raw = fs.readFileSync(tsconfigPath, 'utf8');
|
|
82
|
+
const parsed = JSON.parse(stripJsonComments(raw));
|
|
83
|
+
const compilerOptions = (parsed.compilerOptions ?? {});
|
|
84
|
+
const mod = typeof compilerOptions.module === 'string'
|
|
85
|
+
? compilerOptions.module.toLowerCase()
|
|
86
|
+
: undefined;
|
|
87
|
+
if (mod === 'commonjs') {
|
|
88
|
+
return { format: 'cjs', source: 'tsconfig', details: '"module": "commonjs"' };
|
|
89
|
+
}
|
|
90
|
+
if (mod && ['es2015', 'es2020', 'es2022', 'esnext', 'nodenext', 'node16'].includes(mod)) {
|
|
91
|
+
return {
|
|
92
|
+
format: 'esm',
|
|
93
|
+
source: 'tsconfig',
|
|
94
|
+
details: `"module": "${compilerOptions.module}"`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Fall through to default
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Default to ESM for new projects
|
|
103
|
+
return { format: 'esm', source: 'default', details: 'defaulting to ESM' };
|
|
104
|
+
}
|
|
105
|
+
// ── Check functions ──────────────────────────────────────────────────────────
|
|
106
|
+
export function checkNodeVersion() {
|
|
107
|
+
const major = parseInt(process.version.slice(1), 10);
|
|
108
|
+
if (major >= 18) {
|
|
109
|
+
return {
|
|
110
|
+
name: 'Node.js version',
|
|
111
|
+
status: 'pass',
|
|
112
|
+
message: `Node.js ${process.version} (>= 18 required)`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
name: 'Node.js version',
|
|
117
|
+
status: 'fail',
|
|
118
|
+
message: `Node.js ${process.version} is below the minimum (18)`,
|
|
119
|
+
fix: 'Install Node.js 18 or later: https://nodejs.org',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export function checkTypeScriptVersion(cwd) {
|
|
123
|
+
const tsPath = path.join(cwd, 'node_modules', 'typescript', 'package.json');
|
|
124
|
+
if (!fs.existsSync(tsPath)) {
|
|
125
|
+
return {
|
|
126
|
+
name: 'TypeScript version',
|
|
127
|
+
status: 'fail',
|
|
128
|
+
message: 'TypeScript is not installed locally',
|
|
129
|
+
fix: 'npm install -D typescript',
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const tsPkg = JSON.parse(fs.readFileSync(tsPath, 'utf8'));
|
|
134
|
+
const major = parseInt(tsPkg.version.split('.')[0], 10);
|
|
135
|
+
if (major >= 5) {
|
|
136
|
+
return {
|
|
137
|
+
name: 'TypeScript version',
|
|
138
|
+
status: 'pass',
|
|
139
|
+
message: `TypeScript ${tsPkg.version} (>= 5.0 required)`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
name: 'TypeScript version',
|
|
144
|
+
status: 'fail',
|
|
145
|
+
message: `TypeScript ${tsPkg.version} is below the minimum (5.0)`,
|
|
146
|
+
fix: 'npm install -D typescript@latest',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return {
|
|
151
|
+
name: 'TypeScript version',
|
|
152
|
+
status: 'fail',
|
|
153
|
+
message: 'Could not read TypeScript version',
|
|
154
|
+
fix: 'npm install -D typescript@latest',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export function checkPackageJsonType(cwd) {
|
|
159
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
160
|
+
if (!fs.existsSync(pkgPath)) {
|
|
161
|
+
return {
|
|
162
|
+
name: 'package.json "type"',
|
|
163
|
+
status: 'fail',
|
|
164
|
+
message: 'No package.json found',
|
|
165
|
+
fix: 'Run npm init -y',
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
170
|
+
if (pkg.type === 'module') {
|
|
171
|
+
return {
|
|
172
|
+
name: 'package.json "type"',
|
|
173
|
+
status: 'pass',
|
|
174
|
+
message: '"type": "module" is set (ESM project)',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
if (pkg.type === 'commonjs') {
|
|
178
|
+
return {
|
|
179
|
+
name: 'package.json "type"',
|
|
180
|
+
status: 'pass',
|
|
181
|
+
message: '"type": "commonjs" is set (CJS project)',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
// No type field - defaults to CommonJS
|
|
185
|
+
return {
|
|
186
|
+
name: 'package.json "type"',
|
|
187
|
+
status: 'pass',
|
|
188
|
+
message: 'No "type" field (defaults to CommonJS)',
|
|
189
|
+
details: 'Add "type": "module" if you prefer ESM',
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return {
|
|
194
|
+
name: 'package.json "type"',
|
|
195
|
+
status: 'fail',
|
|
196
|
+
message: 'Could not parse package.json',
|
|
197
|
+
fix: 'Fix JSON syntax in package.json',
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function readTsconfig(cwd) {
|
|
202
|
+
const tsconfigPath = path.join(cwd, 'tsconfig.json');
|
|
203
|
+
if (!fs.existsSync(tsconfigPath)) {
|
|
204
|
+
return { parsed: null, error: 'No tsconfig.json found' };
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const raw = fs.readFileSync(tsconfigPath, 'utf8');
|
|
208
|
+
const parsed = JSON.parse(stripJsonComments(raw));
|
|
209
|
+
return { parsed };
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return { parsed: null, error: 'Could not parse tsconfig.json' };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export function checkTsconfigModule(cwd) {
|
|
216
|
+
const { parsed, error } = readTsconfig(cwd);
|
|
217
|
+
if (!parsed) {
|
|
218
|
+
return {
|
|
219
|
+
name: 'tsconfig "module"',
|
|
220
|
+
status: 'warn',
|
|
221
|
+
message: error ?? 'No tsconfig.json found',
|
|
222
|
+
fix: 'Create a tsconfig.json with appropriate "module" setting',
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const compilerOptions = (parsed.compilerOptions ?? {});
|
|
226
|
+
const mod = typeof compilerOptions.module === 'string' ? compilerOptions.module.toLowerCase() : undefined;
|
|
227
|
+
if (!mod) {
|
|
228
|
+
return {
|
|
229
|
+
name: 'tsconfig "module"',
|
|
230
|
+
status: 'warn',
|
|
231
|
+
message: '"module" is not set in compilerOptions',
|
|
232
|
+
fix: 'Set "module" in tsconfig.json compilerOptions (e.g., "nodenext" for ESM, "commonjs" for CJS)',
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// Detect project format to validate consistency
|
|
236
|
+
const detection = detectProjectModuleFormat(cwd);
|
|
237
|
+
// CommonJS module setting
|
|
238
|
+
if (mod === 'commonjs') {
|
|
239
|
+
if (detection.format === 'cjs') {
|
|
240
|
+
return {
|
|
241
|
+
name: 'tsconfig "module"',
|
|
242
|
+
status: 'pass',
|
|
243
|
+
message: '"module": "commonjs" (CJS project)',
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
name: 'tsconfig "module"',
|
|
248
|
+
status: 'warn',
|
|
249
|
+
message: '"module" is "commonjs" but package.json suggests ESM',
|
|
250
|
+
fix: 'Align tsconfig.json "module" with package.json "type"',
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// ESM module settings
|
|
254
|
+
const esmModules = ['es2015', 'es2020', 'es2022', 'esnext', 'nodenext', 'node16'];
|
|
255
|
+
if (esmModules.includes(mod)) {
|
|
256
|
+
if (detection.format === 'esm') {
|
|
257
|
+
return {
|
|
258
|
+
name: 'tsconfig "module"',
|
|
259
|
+
status: 'pass',
|
|
260
|
+
message: `"module": "${compilerOptions.module}" (ESM project)`,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
name: 'tsconfig "module"',
|
|
265
|
+
status: 'warn',
|
|
266
|
+
message: `"module" is "${compilerOptions.module}" but package.json suggests CJS`,
|
|
267
|
+
fix: 'Align tsconfig.json "module" with package.json "type"',
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
name: 'tsconfig "module"',
|
|
272
|
+
status: 'pass',
|
|
273
|
+
message: `"module": "${compilerOptions.module}"`,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
export function checkTsconfigModuleResolution(cwd) {
|
|
277
|
+
const { parsed, error } = readTsconfig(cwd);
|
|
278
|
+
if (!parsed) {
|
|
279
|
+
return {
|
|
280
|
+
name: 'tsconfig "moduleResolution"',
|
|
281
|
+
status: 'warn',
|
|
282
|
+
message: error ?? 'No tsconfig.json found',
|
|
283
|
+
fix: 'Create a tsconfig.json with "moduleResolution": "nodenext" or "bundler"',
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
const compilerOptions = (parsed.compilerOptions ?? {});
|
|
287
|
+
const res = typeof compilerOptions.moduleResolution === 'string'
|
|
288
|
+
? compilerOptions.moduleResolution.toLowerCase()
|
|
289
|
+
: undefined;
|
|
290
|
+
if (!res) {
|
|
291
|
+
return {
|
|
292
|
+
name: 'tsconfig "moduleResolution"',
|
|
293
|
+
status: 'warn',
|
|
294
|
+
message: '"moduleResolution" is not set in compilerOptions',
|
|
295
|
+
fix: 'Set "moduleResolution": "nodenext" in tsconfig.json compilerOptions',
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
// "node" is the legacy Node10 resolution — cannot resolve ESM exports maps
|
|
299
|
+
if (res === 'node') {
|
|
300
|
+
return {
|
|
301
|
+
name: 'tsconfig "moduleResolution"',
|
|
302
|
+
status: 'fail',
|
|
303
|
+
message: '"moduleResolution" is "node" (Node10) — cannot resolve ESM exports',
|
|
304
|
+
fix: 'Set "moduleResolution": "nodenext" or "bundler" in tsconfig.json',
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
name: 'tsconfig "moduleResolution"',
|
|
309
|
+
status: 'pass',
|
|
310
|
+
message: `"moduleResolution": "${compilerOptions.moduleResolution}"`,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
export function checkFlowWeaverInstalled(cwd) {
|
|
314
|
+
const pkgPath = path.join(cwd, 'node_modules', '@synergenius', 'flow-weaver', 'package.json');
|
|
315
|
+
if (fs.existsSync(pkgPath)) {
|
|
316
|
+
try {
|
|
317
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
318
|
+
return {
|
|
319
|
+
name: '@synergenius/flow-weaver installed',
|
|
320
|
+
status: 'pass',
|
|
321
|
+
message: `@synergenius/flow-weaver ${pkg.version} is installed`,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
// exists but unreadable — still pass
|
|
326
|
+
return {
|
|
327
|
+
name: '@synergenius/flow-weaver installed',
|
|
328
|
+
status: 'pass',
|
|
329
|
+
message: '@synergenius/flow-weaver is installed',
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
name: '@synergenius/flow-weaver installed',
|
|
335
|
+
status: 'fail',
|
|
336
|
+
message: '@synergenius/flow-weaver is not installed',
|
|
337
|
+
fix: 'npm install @synergenius/flow-weaver',
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
export function checkFlowWeaverVersion(cwd) {
|
|
341
|
+
const libraryPath = path.join(cwd, 'node_modules', '@synergenius', 'flow-weaver');
|
|
342
|
+
const pkgPath = path.join(libraryPath, 'package.json');
|
|
343
|
+
if (!fs.existsSync(pkgPath)) {
|
|
344
|
+
// Not installed — covered by checkFlowWeaverInstalled
|
|
345
|
+
return {
|
|
346
|
+
name: 'Library version',
|
|
347
|
+
status: 'pass',
|
|
348
|
+
message: 'Skipped (library not installed)',
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
// Check if this is a local file:/link:/workspace: dependency or symlink
|
|
352
|
+
try {
|
|
353
|
+
const projectPkgPath = path.join(cwd, 'package.json');
|
|
354
|
+
if (fs.existsSync(projectPkgPath)) {
|
|
355
|
+
const projectPkg = JSON.parse(fs.readFileSync(projectPkgPath, 'utf8'));
|
|
356
|
+
const depSpec = projectPkg.dependencies?.['@synergenius/flow-weaver'] ??
|
|
357
|
+
projectPkg.devDependencies?.['@synergenius/flow-weaver'];
|
|
358
|
+
if (typeof depSpec === 'string' &&
|
|
359
|
+
(depSpec.startsWith('file:') ||
|
|
360
|
+
depSpec.startsWith('link:') ||
|
|
361
|
+
depSpec.startsWith('workspace:'))) {
|
|
362
|
+
return {
|
|
363
|
+
name: 'Library version',
|
|
364
|
+
status: 'pass',
|
|
365
|
+
message: 'Local dependency (version check skipped)',
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (fs.lstatSync(libraryPath).isSymbolicLink()) {
|
|
370
|
+
return {
|
|
371
|
+
name: 'Library version',
|
|
372
|
+
status: 'pass',
|
|
373
|
+
message: 'Linked dependency (version check skipped)',
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
// Continue with registry check
|
|
379
|
+
}
|
|
380
|
+
// Check against npm registry
|
|
381
|
+
try {
|
|
382
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
383
|
+
const currentVersion = pkg.version;
|
|
384
|
+
const latestVersion = execSync('npm view @synergenius/flow-weaver version', {
|
|
385
|
+
timeout: 5000,
|
|
386
|
+
stdio: 'pipe',
|
|
387
|
+
})
|
|
388
|
+
.toString()
|
|
389
|
+
.trim();
|
|
390
|
+
if (currentVersion === latestVersion) {
|
|
391
|
+
return {
|
|
392
|
+
name: 'Library version',
|
|
393
|
+
status: 'pass',
|
|
394
|
+
message: `@synergenius/flow-weaver ${currentVersion} is up to date`,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
name: 'Library version',
|
|
399
|
+
status: 'warn',
|
|
400
|
+
message: `Library update available: ${currentVersion} → ${latestVersion}`,
|
|
401
|
+
fix: 'npm update @synergenius/flow-weaver',
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
catch {
|
|
405
|
+
return {
|
|
406
|
+
name: 'Library version',
|
|
407
|
+
status: 'pass',
|
|
408
|
+
message: 'Could not check for updates (registry unreachable)',
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
export function checkTypesNodeInstalled(cwd) {
|
|
413
|
+
const pkgPath = path.join(cwd, 'node_modules', '@types', 'node', 'package.json');
|
|
414
|
+
if (fs.existsSync(pkgPath)) {
|
|
415
|
+
return {
|
|
416
|
+
name: '@types/node installed',
|
|
417
|
+
status: 'pass',
|
|
418
|
+
message: '@types/node is installed',
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
name: '@types/node installed',
|
|
423
|
+
status: 'warn',
|
|
424
|
+
message: '@types/node is not installed (recommended)',
|
|
425
|
+
fix: 'npm install -D @types/node',
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
export function checkTsxAvailable(cwd) {
|
|
429
|
+
// Check local install first
|
|
430
|
+
const localBin = path.join(cwd, 'node_modules', '.bin', 'tsx');
|
|
431
|
+
if (fs.existsSync(localBin)) {
|
|
432
|
+
return {
|
|
433
|
+
name: 'tsx available',
|
|
434
|
+
status: 'pass',
|
|
435
|
+
message: 'tsx is available (local)',
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
// Check global
|
|
439
|
+
try {
|
|
440
|
+
execSync('tsx --version', { stdio: 'pipe', timeout: 5000 });
|
|
441
|
+
return {
|
|
442
|
+
name: 'tsx available',
|
|
443
|
+
status: 'pass',
|
|
444
|
+
message: 'tsx is available (global)',
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
return {
|
|
449
|
+
name: 'tsx available',
|
|
450
|
+
status: 'warn',
|
|
451
|
+
message: 'tsx is not installed (recommended for running .ts files)',
|
|
452
|
+
fix: 'npm install -D tsx',
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
// ── Config health checks ─────────────────────────────────────────────────────
|
|
457
|
+
const VALID_FILE_TYPES = ['ts', 'tsx', 'js', 'jsx'];
|
|
458
|
+
const VALID_TARGETS = ['lambda', 'vercel', 'cloudflare'];
|
|
459
|
+
function readYaml(filePath) {
|
|
460
|
+
try {
|
|
461
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
462
|
+
return { data: YAML.load(content) };
|
|
463
|
+
}
|
|
464
|
+
catch (e) {
|
|
465
|
+
return { data: null, error: e instanceof Error ? e.message : String(e) };
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
export function checkProjectConfig(cwd) {
|
|
469
|
+
const configPath = path.join(cwd, '.flowweaver', 'config.yaml');
|
|
470
|
+
if (!fs.existsSync(configPath)) {
|
|
471
|
+
return {
|
|
472
|
+
name: 'Project config',
|
|
473
|
+
status: 'warn',
|
|
474
|
+
message: '.flowweaver/config.yaml not found',
|
|
475
|
+
fix: 'Create .flowweaver/config.yaml with at least: defaultFileType: ts',
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
const { data, error } = readYaml(configPath);
|
|
479
|
+
if (error || data == null) {
|
|
480
|
+
return {
|
|
481
|
+
name: 'Project config',
|
|
482
|
+
status: 'fail',
|
|
483
|
+
message: `Could not parse .flowweaver/config.yaml: ${error}`,
|
|
484
|
+
fix: 'Fix YAML syntax in .flowweaver/config.yaml',
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
const config = data;
|
|
488
|
+
if (config.defaultFileType && !VALID_FILE_TYPES.includes(config.defaultFileType)) {
|
|
489
|
+
return {
|
|
490
|
+
name: 'Project config',
|
|
491
|
+
status: 'fail',
|
|
492
|
+
message: `Invalid defaultFileType "${config.defaultFileType}" — must be one of: ${VALID_FILE_TYPES.join(', ')}`,
|
|
493
|
+
fix: `Set defaultFileType to one of: ${VALID_FILE_TYPES.join(', ')}`,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
if (config.pluginsDir && typeof config.pluginsDir !== 'string') {
|
|
497
|
+
return {
|
|
498
|
+
name: 'Project config',
|
|
499
|
+
status: 'fail',
|
|
500
|
+
message: 'pluginsDir must be a string',
|
|
501
|
+
fix: 'Set pluginsDir to a valid directory path',
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
name: 'Project config',
|
|
506
|
+
status: 'pass',
|
|
507
|
+
message: `.flowweaver/config.yaml is valid`,
|
|
508
|
+
details: `defaultFileType: ${config.defaultFileType ?? 'not set'}`,
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
export function checkDeploymentManifest(cwd) {
|
|
512
|
+
const deployDir = path.join(cwd, '.flowweaver', 'deployment');
|
|
513
|
+
if (!fs.existsSync(deployDir)) {
|
|
514
|
+
return {
|
|
515
|
+
name: 'Deployment manifest',
|
|
516
|
+
status: 'pass',
|
|
517
|
+
message: 'No deployment directory (deployment profiles are optional)',
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
const manifestPath = path.join(deployDir, 'manifest.yaml');
|
|
521
|
+
if (!fs.existsSync(manifestPath)) {
|
|
522
|
+
return {
|
|
523
|
+
name: 'Deployment manifest',
|
|
524
|
+
status: 'fail',
|
|
525
|
+
message: '.flowweaver/deployment/ exists but manifest.yaml is missing',
|
|
526
|
+
fix: 'Create manifest.yaml with activeProfile and profiles list',
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
const { data, error } = readYaml(manifestPath);
|
|
530
|
+
if (error || data == null) {
|
|
531
|
+
return {
|
|
532
|
+
name: 'Deployment manifest',
|
|
533
|
+
status: 'fail',
|
|
534
|
+
message: `Could not parse manifest.yaml: ${error}`,
|
|
535
|
+
fix: 'Fix YAML syntax in .flowweaver/deployment/manifest.yaml',
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
const manifest = data;
|
|
539
|
+
if (typeof manifest.activeProfile !== 'string') {
|
|
540
|
+
return {
|
|
541
|
+
name: 'Deployment manifest',
|
|
542
|
+
status: 'fail',
|
|
543
|
+
message: 'manifest.yaml is missing required field: activeProfile',
|
|
544
|
+
fix: 'Add activeProfile: default to manifest.yaml',
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (!Array.isArray(manifest.profiles)) {
|
|
548
|
+
return {
|
|
549
|
+
name: 'Deployment manifest',
|
|
550
|
+
status: 'fail',
|
|
551
|
+
message: 'manifest.yaml is missing required field: profiles (must be an array)',
|
|
552
|
+
fix: 'Add profiles: [default] to manifest.yaml',
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
if (!manifest.profiles.includes(manifest.activeProfile)) {
|
|
556
|
+
return {
|
|
557
|
+
name: 'Deployment manifest',
|
|
558
|
+
status: 'warn',
|
|
559
|
+
message: `Active profile "${manifest.activeProfile}" is not in the profiles list`,
|
|
560
|
+
fix: `Add "${manifest.activeProfile}" to the profiles array or change activeProfile`,
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
name: 'Deployment manifest',
|
|
565
|
+
status: 'pass',
|
|
566
|
+
message: `Deployment manifest valid (${manifest.profiles.length} profile${manifest.profiles.length === 1 ? '' : 's'})`,
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
export function checkDeploymentProfiles(cwd) {
|
|
570
|
+
const deployDir = path.join(cwd, '.flowweaver', 'deployment');
|
|
571
|
+
if (!fs.existsSync(deployDir)) {
|
|
572
|
+
return {
|
|
573
|
+
name: 'Deployment profiles',
|
|
574
|
+
status: 'pass',
|
|
575
|
+
message: 'No deployment directory (profiles are optional)',
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
const manifestPath = path.join(deployDir, 'manifest.yaml');
|
|
579
|
+
if (!fs.existsSync(manifestPath)) {
|
|
580
|
+
return {
|
|
581
|
+
name: 'Deployment profiles',
|
|
582
|
+
status: 'pass',
|
|
583
|
+
message: 'No manifest to validate against',
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
const { data: manifestData } = readYaml(manifestPath);
|
|
587
|
+
if (!manifestData || !Array.isArray(manifestData.profiles)) {
|
|
588
|
+
return {
|
|
589
|
+
name: 'Deployment profiles',
|
|
590
|
+
status: 'pass',
|
|
591
|
+
message: 'Manifest invalid (checked separately)',
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
const profiles = manifestData.profiles;
|
|
595
|
+
const missing = [];
|
|
596
|
+
const invalid = [];
|
|
597
|
+
for (const profile of profiles) {
|
|
598
|
+
const profilePath = path.join(deployDir, `${profile}.yaml`);
|
|
599
|
+
if (!fs.existsSync(profilePath)) {
|
|
600
|
+
missing.push(profile);
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
const { data, error } = readYaml(profilePath);
|
|
604
|
+
if (error || data == null) {
|
|
605
|
+
invalid.push(`${profile} (parse error)`);
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
const config = data;
|
|
609
|
+
if (config.target && !VALID_TARGETS.includes(config.target)) {
|
|
610
|
+
invalid.push(`${profile} (invalid target "${config.target}" — must be: ${VALID_TARGETS.join(', ')})`);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (invalid.length > 0) {
|
|
614
|
+
return {
|
|
615
|
+
name: 'Deployment profiles',
|
|
616
|
+
status: 'fail',
|
|
617
|
+
message: `Invalid profiles: ${invalid.join(', ')}`,
|
|
618
|
+
fix: 'Fix the listed profile files in .flowweaver/deployment/',
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
if (missing.length > 0) {
|
|
622
|
+
return {
|
|
623
|
+
name: 'Deployment profiles',
|
|
624
|
+
status: 'warn',
|
|
625
|
+
message: `Missing profile files: ${missing.join(', ')}`,
|
|
626
|
+
fix: `Create the missing .yaml files in .flowweaver/deployment/`,
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
name: 'Deployment profiles',
|
|
631
|
+
status: 'pass',
|
|
632
|
+
message: `All ${profiles.length} deployment profiles are valid`,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
// ── Orchestrator ─────────────────────────────────────────────────────────────
|
|
636
|
+
export function runDoctorChecks(cwd) {
|
|
637
|
+
const moduleFormat = detectProjectModuleFormat(cwd);
|
|
638
|
+
const checks = [
|
|
639
|
+
checkNodeVersion(),
|
|
640
|
+
checkTypeScriptVersion(cwd),
|
|
641
|
+
checkPackageJsonType(cwd),
|
|
642
|
+
checkTsconfigModule(cwd),
|
|
643
|
+
checkTsconfigModuleResolution(cwd),
|
|
644
|
+
checkFlowWeaverInstalled(cwd),
|
|
645
|
+
checkFlowWeaverVersion(cwd),
|
|
646
|
+
checkTypesNodeInstalled(cwd),
|
|
647
|
+
checkTsxAvailable(cwd),
|
|
648
|
+
checkProjectConfig(cwd),
|
|
649
|
+
checkDeploymentManifest(cwd),
|
|
650
|
+
checkDeploymentProfiles(cwd),
|
|
651
|
+
];
|
|
652
|
+
const summary = { pass: 0, warn: 0, fail: 0 };
|
|
653
|
+
for (const check of checks) {
|
|
654
|
+
summary[check.status]++;
|
|
655
|
+
}
|
|
656
|
+
return {
|
|
657
|
+
ok: summary.fail === 0,
|
|
658
|
+
checks,
|
|
659
|
+
summary,
|
|
660
|
+
moduleFormat,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
// ── CLI entrypoint ───────────────────────────────────────────────────────────
|
|
664
|
+
export async function doctorCommand(options = {}) {
|
|
665
|
+
const cwd = process.cwd();
|
|
666
|
+
const report = runDoctorChecks(cwd);
|
|
667
|
+
if (options.json) {
|
|
668
|
+
console.log(JSON.stringify(report, null, 2));
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
logger.section('Flow Weaver Doctor');
|
|
672
|
+
logger.info(`Checking project at ${cwd}`);
|
|
673
|
+
logger.newline();
|
|
674
|
+
for (const check of report.checks) {
|
|
675
|
+
switch (check.status) {
|
|
676
|
+
case 'pass':
|
|
677
|
+
logger.success(check.message);
|
|
678
|
+
break;
|
|
679
|
+
case 'warn':
|
|
680
|
+
logger.warn(check.message);
|
|
681
|
+
if (check.fix) {
|
|
682
|
+
logger.log(` Fix: ${check.fix}`);
|
|
683
|
+
}
|
|
684
|
+
break;
|
|
685
|
+
case 'fail':
|
|
686
|
+
logger.error(check.message);
|
|
687
|
+
if (check.fix) {
|
|
688
|
+
logger.log(` Fix: ${check.fix}`);
|
|
689
|
+
}
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
logger.newline();
|
|
694
|
+
logger.section('Module Format');
|
|
695
|
+
logger.info(` Detected: ${report.moduleFormat.format.toUpperCase()} (${report.moduleFormat.details})`);
|
|
696
|
+
logger.newline();
|
|
697
|
+
logger.section('Summary');
|
|
698
|
+
const parts = [];
|
|
699
|
+
if (report.summary.pass > 0)
|
|
700
|
+
parts.push(`${report.summary.pass} passed`);
|
|
701
|
+
if (report.summary.warn > 0)
|
|
702
|
+
parts.push(`${report.summary.warn} warning(s)`);
|
|
703
|
+
if (report.summary.fail > 0)
|
|
704
|
+
parts.push(`${report.summary.fail} failed`);
|
|
705
|
+
logger.log(` ${parts.join(', ')}`);
|
|
706
|
+
if (report.ok) {
|
|
707
|
+
logger.newline();
|
|
708
|
+
logger.success('Environment is ready for flow-weaver!');
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
logger.newline();
|
|
712
|
+
logger.error('Some checks failed. Please fix the issues above.');
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (!report.ok) {
|
|
716
|
+
process.exit(1);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
//# sourceMappingURL=doctor.js.map
|