@syrin/cli 1.3.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 +15 -0
- package/README.md +302 -0
- package/dist/cli/commands/analyse.d.ts +16 -0
- package/dist/cli/commands/analyse.js +61 -0
- package/dist/cli/commands/dev.d.ts +23 -0
- package/dist/cli/commands/dev.js +419 -0
- package/dist/cli/commands/doctor.d.ts +10 -0
- package/dist/cli/commands/doctor.js +195 -0
- package/dist/cli/commands/index.d.ts +12 -0
- package/dist/cli/commands/index.js +12 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.js +90 -0
- package/dist/cli/commands/list.d.ts +15 -0
- package/dist/cli/commands/list.js +50 -0
- package/dist/cli/commands/rollback.d.ts +12 -0
- package/dist/cli/commands/rollback.js +101 -0
- package/dist/cli/commands/test.d.ts +31 -0
- package/dist/cli/commands/test.js +88 -0
- package/dist/cli/commands/update.d.ts +9 -0
- package/dist/cli/commands/update.js +76 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +342 -0
- package/dist/cli/prompts/index.d.ts +5 -0
- package/dist/cli/prompts/index.js +5 -0
- package/dist/cli/prompts/init-prompt.d.ts +17 -0
- package/dist/cli/prompts/init-prompt.js +263 -0
- package/dist/cli/utils/command-error-handler.d.ts +14 -0
- package/dist/cli/utils/command-error-handler.js +35 -0
- package/dist/cli/utils/common-types.d.ts +24 -0
- package/dist/cli/utils/common-types.js +6 -0
- package/dist/cli/utils/connection-handler.d.ts +37 -0
- package/dist/cli/utils/connection-handler.js +90 -0
- package/dist/cli/utils/index.d.ts +11 -0
- package/dist/cli/utils/index.js +11 -0
- package/dist/cli/utils/option-parsers.d.ts +41 -0
- package/dist/cli/utils/option-parsers.js +92 -0
- package/dist/cli/utils/output-utils.d.ts +12 -0
- package/dist/cli/utils/output-utils.js +21 -0
- package/dist/cli/utils/transport-resolver.d.ts +33 -0
- package/dist/cli/utils/transport-resolver.js +82 -0
- package/dist/cli/utils/version-banner.d.ts +10 -0
- package/dist/cli/utils/version-banner.js +26 -0
- package/dist/config/env-checker.d.ts +37 -0
- package/dist/config/env-checker.js +136 -0
- package/dist/config/generator.d.ts +19 -0
- package/dist/config/generator.js +196 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.js +9 -0
- package/dist/config/loader.d.ts +19 -0
- package/dist/config/loader.js +57 -0
- package/dist/config/schema.d.ts +42 -0
- package/dist/config/schema.js +181 -0
- package/dist/config/syrin.template.yaml +127 -0
- package/dist/config/types.d.ts +87 -0
- package/dist/config/types.js +6 -0
- package/dist/constants/app.d.ts +9 -0
- package/dist/constants/app.js +9 -0
- package/dist/constants/commands.d.ts +43 -0
- package/dist/constants/commands.js +43 -0
- package/dist/constants/defaults.d.ts +18 -0
- package/dist/constants/defaults.js +18 -0
- package/dist/constants/env-vars.d.ts +11 -0
- package/dist/constants/env-vars.js +11 -0
- package/dist/constants/icons.d.ts +23 -0
- package/dist/constants/icons.js +23 -0
- package/dist/constants/index.d.ts +17 -0
- package/dist/constants/index.js +17 -0
- package/dist/constants/labels.d.ts +38 -0
- package/dist/constants/labels.js +42 -0
- package/dist/constants/links.d.ts +10 -0
- package/dist/constants/links.js +11 -0
- package/dist/constants/list.d.ts +10 -0
- package/dist/constants/list.js +9 -0
- package/dist/constants/llm.d.ts +26 -0
- package/dist/constants/llm.js +25 -0
- package/dist/constants/messages.d.ts +107 -0
- package/dist/constants/messages.js +138 -0
- package/dist/constants/paths.d.ts +29 -0
- package/dist/constants/paths.js +29 -0
- package/dist/constants/transport.d.ts +9 -0
- package/dist/constants/transport.js +8 -0
- package/dist/events/emitter.d.ts +64 -0
- package/dist/events/emitter.js +142 -0
- package/dist/events/event-type.d.ts +66 -0
- package/dist/events/event-type.js +81 -0
- package/dist/events/payloads/diagnostics.d.ts +24 -0
- package/dist/events/payloads/diagnostics.js +5 -0
- package/dist/events/payloads/index.d.ts +15 -0
- package/dist/events/payloads/index.js +6 -0
- package/dist/events/payloads/llm.d.ts +58 -0
- package/dist/events/payloads/llm.js +6 -0
- package/dist/events/payloads/registry.d.ts +28 -0
- package/dist/events/payloads/registry.js +5 -0
- package/dist/events/payloads/session.d.ts +32 -0
- package/dist/events/payloads/session.js +5 -0
- package/dist/events/payloads/testing.d.ts +17 -0
- package/dist/events/payloads/testing.js +5 -0
- package/dist/events/payloads/tool.d.ts +29 -0
- package/dist/events/payloads/tool.js +5 -0
- package/dist/events/payloads/transport.d.ts +30 -0
- package/dist/events/payloads/transport.js +5 -0
- package/dist/events/payloads/validation.d.ts +37 -0
- package/dist/events/payloads/validation.js +5 -0
- package/dist/events/payloads/workflow.d.ts +45 -0
- package/dist/events/payloads/workflow.js +5 -0
- package/dist/events/store/file-store.d.ts +37 -0
- package/dist/events/store/file-store.js +113 -0
- package/dist/events/store/index.d.ts +7 -0
- package/dist/events/store/index.js +6 -0
- package/dist/events/store/memory-store.d.ts +26 -0
- package/dist/events/store/memory-store.js +39 -0
- package/dist/events/store.d.ts +11 -0
- package/dist/events/store.js +2 -0
- package/dist/events/types.d.ts +14 -0
- package/dist/events/types.js +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +30 -0
- package/dist/presentation/analysis-ui.d.ts +24 -0
- package/dist/presentation/analysis-ui.js +158 -0
- package/dist/presentation/dev/chat-ui-types.d.ts +68 -0
- package/dist/presentation/dev/chat-ui-types.js +5 -0
- package/dist/presentation/dev/chat-ui.d.ts +61 -0
- package/dist/presentation/dev/chat-ui.js +714 -0
- package/dist/presentation/dev/components/assistant-message.d.ts +19 -0
- package/dist/presentation/dev/components/assistant-message.js +36 -0
- package/dist/presentation/dev/components/header.d.ts +16 -0
- package/dist/presentation/dev/components/header.js +22 -0
- package/dist/presentation/dev/components/index.d.ts +13 -0
- package/dist/presentation/dev/components/index.js +13 -0
- package/dist/presentation/dev/components/input-panel.d.ts +22 -0
- package/dist/presentation/dev/components/input-panel.js +43 -0
- package/dist/presentation/dev/components/message-component.d.ts +16 -0
- package/dist/presentation/dev/components/message-component.js +51 -0
- package/dist/presentation/dev/components/messages-list.d.ts +24 -0
- package/dist/presentation/dev/components/messages-list.js +48 -0
- package/dist/presentation/dev/components/system-message.d.ts +16 -0
- package/dist/presentation/dev/components/system-message.js +26 -0
- package/dist/presentation/dev/components/user-message.d.ts +21 -0
- package/dist/presentation/dev/components/user-message.js +35 -0
- package/dist/presentation/dev/components/welcome-banner.d.ts +24 -0
- package/dist/presentation/dev/components/welcome-banner.js +146 -0
- package/dist/presentation/dev/goodbye-messages.d.ts +31 -0
- package/dist/presentation/dev/goodbye-messages.js +100 -0
- package/dist/presentation/dev/index.d.ts +5 -0
- package/dist/presentation/dev/index.js +5 -0
- package/dist/presentation/dev/text-wrapper.d.ts +30 -0
- package/dist/presentation/dev/text-wrapper.js +74 -0
- package/dist/presentation/dev-ui.d.ts +33 -0
- package/dist/presentation/dev-ui.js +246 -0
- package/dist/presentation/doctor-ui.d.ts +40 -0
- package/dist/presentation/doctor-ui.js +157 -0
- package/dist/presentation/init-ui.d.ts +14 -0
- package/dist/presentation/init-ui.js +41 -0
- package/dist/presentation/list-ui.d.ts +44 -0
- package/dist/presentation/list-ui.js +139 -0
- package/dist/presentation/test-ui.d.ts +49 -0
- package/dist/presentation/test-ui.js +358 -0
- package/dist/runtime/analysis/analyser.d.ts +14 -0
- package/dist/runtime/analysis/analyser.js +88 -0
- package/dist/runtime/analysis/dependencies.d.ts +10 -0
- package/dist/runtime/analysis/dependencies.js +140 -0
- package/dist/runtime/analysis/index.d.ts +10 -0
- package/dist/runtime/analysis/index.js +10 -0
- package/dist/runtime/analysis/indexer.d.ts +10 -0
- package/dist/runtime/analysis/indexer.js +62 -0
- package/dist/runtime/analysis/loader.d.ts +15 -0
- package/dist/runtime/analysis/loader.js +47 -0
- package/dist/runtime/analysis/normalizer.d.ts +14 -0
- package/dist/runtime/analysis/normalizer.js +184 -0
- package/dist/runtime/analysis/rules/__test-helpers__.d.ts +18 -0
- package/dist/runtime/analysis/rules/__test-helpers__.js +40 -0
- package/dist/runtime/analysis/rules/base.d.ts +38 -0
- package/dist/runtime/analysis/rules/base.js +23 -0
- package/dist/runtime/analysis/rules/error-codes.d.ts +64 -0
- package/dist/runtime/analysis/rules/error-codes.js +73 -0
- package/dist/runtime/analysis/rules/errors/e000-tool-not-found.d.ts +35 -0
- package/dist/runtime/analysis/rules/errors/e000-tool-not-found.js +32 -0
- package/dist/runtime/analysis/rules/errors/e001-missing-output-schema.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e001-missing-output-schema.js +30 -0
- package/dist/runtime/analysis/rules/errors/e002-underspecified-input.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e002-underspecified-input.js +52 -0
- package/dist/runtime/analysis/rules/errors/e003-type-mismatch.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e003-type-mismatch.js +73 -0
- package/dist/runtime/analysis/rules/errors/e004-free-text-propagation.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e004-free-text-propagation.js +47 -0
- package/dist/runtime/analysis/rules/errors/e005-tool-ambiguity.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e005-tool-ambiguity.js +73 -0
- package/dist/runtime/analysis/rules/errors/e006-param-not-in-description.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e006-param-not-in-description.js +57 -0
- package/dist/runtime/analysis/rules/errors/e007-output-not-guaranteed.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e007-output-not-guaranteed.js +56 -0
- package/dist/runtime/analysis/rules/errors/e008-circular-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e008-circular-dependency.js +84 -0
- package/dist/runtime/analysis/rules/errors/e009-implicit-user-input.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e009-implicit-user-input.js +89 -0
- package/dist/runtime/analysis/rules/errors/e010-non-serializable.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e010-non-serializable.js +46 -0
- package/dist/runtime/analysis/rules/errors/e011-missing-tool-description.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e011-missing-tool-description.js +33 -0
- package/dist/runtime/analysis/rules/errors/e012-side-effect-detected.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e012-side-effect-detected.js +40 -0
- package/dist/runtime/analysis/rules/errors/e013-non-deterministic-output.d.ts +37 -0
- package/dist/runtime/analysis/rules/errors/e013-non-deterministic-output.js +34 -0
- package/dist/runtime/analysis/rules/errors/e013-output-explosion.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e013-output-explosion.js +36 -0
- package/dist/runtime/analysis/rules/errors/e014-hidden-dependency.d.ts +42 -0
- package/dist/runtime/analysis/rules/errors/e014-hidden-dependency.js +46 -0
- package/dist/runtime/analysis/rules/errors/e014-output-explosion.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e014-output-explosion.js +36 -0
- package/dist/runtime/analysis/rules/errors/e015-hidden-dependency.d.ts +42 -0
- package/dist/runtime/analysis/rules/errors/e015-hidden-dependency.js +46 -0
- package/dist/runtime/analysis/rules/errors/e015-unbounded-execution.d.ts +44 -0
- package/dist/runtime/analysis/rules/errors/e015-unbounded-execution.js +66 -0
- package/dist/runtime/analysis/rules/errors/e016-output-validation-failed.d.ts +43 -0
- package/dist/runtime/analysis/rules/errors/e016-output-validation-failed.js +42 -0
- package/dist/runtime/analysis/rules/errors/e016-unbounded-execution.d.ts +44 -0
- package/dist/runtime/analysis/rules/errors/e016-unbounded-execution.js +66 -0
- package/dist/runtime/analysis/rules/errors/e017-input-validation-failed.d.ts +57 -0
- package/dist/runtime/analysis/rules/errors/e017-input-validation-failed.js +80 -0
- package/dist/runtime/analysis/rules/errors/e017-output-validation-failed.d.ts +43 -0
- package/dist/runtime/analysis/rules/errors/e017-output-validation-failed.js +42 -0
- package/dist/runtime/analysis/rules/errors/e018-input-validation-failed.d.ts +57 -0
- package/dist/runtime/analysis/rules/errors/e018-input-validation-failed.js +80 -0
- package/dist/runtime/analysis/rules/errors/e018-tool-execution-failed.d.ts +38 -0
- package/dist/runtime/analysis/rules/errors/e018-tool-execution-failed.js +37 -0
- package/dist/runtime/analysis/rules/errors/e019-tool-execution-failed.d.ts +38 -0
- package/dist/runtime/analysis/rules/errors/e019-tool-execution-failed.js +37 -0
- package/dist/runtime/analysis/rules/errors/e019-unexpected-test-result.d.ts +65 -0
- package/dist/runtime/analysis/rules/errors/e019-unexpected-test-result.js +109 -0
- package/dist/runtime/analysis/rules/errors/e020-unexpected-test-result.d.ts +65 -0
- package/dist/runtime/analysis/rules/errors/e020-unexpected-test-result.js +109 -0
- package/dist/runtime/analysis/rules/errors/e100-missing-output-schema.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e100-missing-output-schema.js +30 -0
- package/dist/runtime/analysis/rules/errors/e101-missing-tool-description.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e101-missing-tool-description.js +33 -0
- package/dist/runtime/analysis/rules/errors/e102-underspecified-input.d.ts +24 -0
- package/dist/runtime/analysis/rules/errors/e102-underspecified-input.js +52 -0
- package/dist/runtime/analysis/rules/errors/e103-type-mismatch.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e103-type-mismatch.js +72 -0
- package/dist/runtime/analysis/rules/errors/e104-param-not-in-description.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e104-param-not-in-description.js +57 -0
- package/dist/runtime/analysis/rules/errors/e105-free-text-propagation.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e105-free-text-propagation.js +47 -0
- package/dist/runtime/analysis/rules/errors/e106-output-not-guaranteed.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e106-output-not-guaranteed.js +58 -0
- package/dist/runtime/analysis/rules/errors/e107-circular-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/errors/e107-circular-dependency.js +84 -0
- package/dist/runtime/analysis/rules/errors/e108-implicit-user-input.d.ts +23 -0
- package/dist/runtime/analysis/rules/errors/e108-implicit-user-input.js +94 -0
- package/dist/runtime/analysis/rules/errors/e109-non-serializable.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e109-non-serializable.js +44 -0
- package/dist/runtime/analysis/rules/errors/e110-tool-ambiguity.d.ts +25 -0
- package/dist/runtime/analysis/rules/errors/e110-tool-ambiguity.js +73 -0
- package/dist/runtime/analysis/rules/errors/e200-input-validation-failed.d.ts +57 -0
- package/dist/runtime/analysis/rules/errors/e200-input-validation-failed.js +71 -0
- package/dist/runtime/analysis/rules/errors/e300-output-validation-failed.d.ts +43 -0
- package/dist/runtime/analysis/rules/errors/e300-output-validation-failed.js +44 -0
- package/dist/runtime/analysis/rules/errors/e301-output-explosion.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e301-output-explosion.js +36 -0
- package/dist/runtime/analysis/rules/errors/e400-tool-execution-failed.d.ts +38 -0
- package/dist/runtime/analysis/rules/errors/e400-tool-execution-failed.js +37 -0
- package/dist/runtime/analysis/rules/errors/e403-unbounded-execution.d.ts +44 -0
- package/dist/runtime/analysis/rules/errors/e403-unbounded-execution.js +66 -0
- package/dist/runtime/analysis/rules/errors/e500-side-effect-detected.d.ts +39 -0
- package/dist/runtime/analysis/rules/errors/e500-side-effect-detected.js +40 -0
- package/dist/runtime/analysis/rules/errors/e501-hidden-dependency.d.ts +47 -0
- package/dist/runtime/analysis/rules/errors/e501-hidden-dependency.js +46 -0
- package/dist/runtime/analysis/rules/errors/e600-unexpected-test-result.d.ts +65 -0
- package/dist/runtime/analysis/rules/errors/e600-unexpected-test-result.js +109 -0
- package/dist/runtime/analysis/rules/index.d.ts +18 -0
- package/dist/runtime/analysis/rules/index.js +94 -0
- package/dist/runtime/analysis/rules/warnings/w001-implicit-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w001-implicit-dependency.js +39 -0
- package/dist/runtime/analysis/rules/warnings/w002-free-text-without-normalization.d.ts +24 -0
- package/dist/runtime/analysis/rules/warnings/w002-free-text-without-normalization.js +40 -0
- package/dist/runtime/analysis/rules/warnings/w003-missing-examples.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w003-missing-examples.js +84 -0
- package/dist/runtime/analysis/rules/warnings/w004-overloaded-responsibility.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w004-overloaded-responsibility.js +96 -0
- package/dist/runtime/analysis/rules/warnings/w005-generic-description.d.ts +53 -0
- package/dist/runtime/analysis/rules/warnings/w005-generic-description.js +108 -0
- package/dist/runtime/analysis/rules/warnings/w006-optional-as-required.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w006-optional-as-required.js +44 -0
- package/dist/runtime/analysis/rules/warnings/w007-broad-output-schema.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w007-broad-output-schema.js +37 -0
- package/dist/runtime/analysis/rules/warnings/w008-multiple-entry-points.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w008-multiple-entry-points.js +97 -0
- package/dist/runtime/analysis/rules/warnings/w009-hidden-side-effects.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w009-hidden-side-effects.js +88 -0
- package/dist/runtime/analysis/rules/warnings/w010-output-not-reusable.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w010-output-not-reusable.js +81 -0
- package/dist/runtime/analysis/rules/warnings/w021-weak-schema.d.ts +40 -0
- package/dist/runtime/analysis/rules/warnings/w021-weak-schema.js +32 -0
- package/dist/runtime/analysis/rules/warnings/w022-high-entropy-output.d.ts +39 -0
- package/dist/runtime/analysis/rules/warnings/w022-high-entropy-output.js +36 -0
- package/dist/runtime/analysis/rules/warnings/w023-unstable-defaults.d.ts +38 -0
- package/dist/runtime/analysis/rules/warnings/w023-unstable-defaults.js +36 -0
- package/dist/runtime/analysis/rules/warnings/w100-implicit-dependency.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w100-implicit-dependency.js +89 -0
- package/dist/runtime/analysis/rules/warnings/w101-free-text-without-normalization.d.ts +24 -0
- package/dist/runtime/analysis/rules/warnings/w101-free-text-without-normalization.js +40 -0
- package/dist/runtime/analysis/rules/warnings/w102-missing-examples.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w102-missing-examples.js +76 -0
- package/dist/runtime/analysis/rules/warnings/w103-overloaded-responsibility.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w103-overloaded-responsibility.js +91 -0
- package/dist/runtime/analysis/rules/warnings/w104-generic-description.d.ts +53 -0
- package/dist/runtime/analysis/rules/warnings/w104-generic-description.js +108 -0
- package/dist/runtime/analysis/rules/warnings/w105-optional-as-required.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w105-optional-as-required.js +45 -0
- package/dist/runtime/analysis/rules/warnings/w106-broad-output-schema.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w106-broad-output-schema.js +37 -0
- package/dist/runtime/analysis/rules/warnings/w107-multiple-entry-points.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w107-multiple-entry-points.js +97 -0
- package/dist/runtime/analysis/rules/warnings/w108-hidden-side-effects.d.ts +23 -0
- package/dist/runtime/analysis/rules/warnings/w108-hidden-side-effects.js +94 -0
- package/dist/runtime/analysis/rules/warnings/w109-output-not-reusable.d.ts +22 -0
- package/dist/runtime/analysis/rules/warnings/w109-output-not-reusable.js +63 -0
- package/dist/runtime/analysis/rules/warnings/w110-weak-schema.d.ts +40 -0
- package/dist/runtime/analysis/rules/warnings/w110-weak-schema.js +32 -0
- package/dist/runtime/analysis/rules/warnings/w300-high-entropy-output.d.ts +39 -0
- package/dist/runtime/analysis/rules/warnings/w300-high-entropy-output.js +47 -0
- package/dist/runtime/analysis/rules/warnings/w301-unstable-defaults.d.ts +38 -0
- package/dist/runtime/analysis/rules/warnings/w301-unstable-defaults.js +36 -0
- package/dist/runtime/analysis/strict-mode.d.ts +21 -0
- package/dist/runtime/analysis/strict-mode.js +44 -0
- package/dist/runtime/analysis/types.d.ts +133 -0
- package/dist/runtime/analysis/types.js +6 -0
- package/dist/runtime/analysis/utils.d.ts +19 -0
- package/dist/runtime/analysis/utils.js +21 -0
- package/dist/runtime/dev/data-manager.d.ts +55 -0
- package/dist/runtime/dev/data-manager.js +87 -0
- package/dist/runtime/dev/event-mapper.d.ts +100 -0
- package/dist/runtime/dev/event-mapper.js +400 -0
- package/dist/runtime/dev/formatter.d.ts +94 -0
- package/dist/runtime/dev/formatter.js +236 -0
- package/dist/runtime/dev/index.d.ts +9 -0
- package/dist/runtime/dev/index.js +9 -0
- package/dist/runtime/dev/repl.d.ts +114 -0
- package/dist/runtime/dev/repl.js +310 -0
- package/dist/runtime/dev/session.d.ts +86 -0
- package/dist/runtime/dev/session.js +447 -0
- package/dist/runtime/dev/stack-trace.d.ts +77 -0
- package/dist/runtime/dev/stack-trace.js +286 -0
- package/dist/runtime/dev/types.d.ts +54 -0
- package/dist/runtime/dev/types.js +5 -0
- package/dist/runtime/llm/claude.d.ts +27 -0
- package/dist/runtime/llm/claude.js +150 -0
- package/dist/runtime/llm/factory.d.ts +30 -0
- package/dist/runtime/llm/factory.js +78 -0
- package/dist/runtime/llm/index.d.ts +10 -0
- package/dist/runtime/llm/index.js +10 -0
- package/dist/runtime/llm/ollama.d.ts +45 -0
- package/dist/runtime/llm/ollama.js +449 -0
- package/dist/runtime/llm/openai.d.ts +27 -0
- package/dist/runtime/llm/openai.js +170 -0
- package/dist/runtime/llm/provider.d.ts +32 -0
- package/dist/runtime/llm/provider.js +6 -0
- package/dist/runtime/llm/types.d.ts +55 -0
- package/dist/runtime/llm/types.js +6 -0
- package/dist/runtime/mcp/client/base.d.ts +40 -0
- package/dist/runtime/mcp/client/base.js +157 -0
- package/dist/runtime/mcp/client/manager.d.ts +91 -0
- package/dist/runtime/mcp/client/manager.js +248 -0
- package/dist/runtime/mcp/client/process.d.ts +31 -0
- package/dist/runtime/mcp/client/process.js +82 -0
- package/dist/runtime/mcp/connection.d.ts +63 -0
- package/dist/runtime/mcp/connection.js +449 -0
- package/dist/runtime/mcp/index.d.ts +9 -0
- package/dist/runtime/mcp/index.js +9 -0
- package/dist/runtime/mcp/list.d.ts +50 -0
- package/dist/runtime/mcp/list.js +65 -0
- package/dist/runtime/mcp/stdio-transport.d.ts +23 -0
- package/dist/runtime/mcp/stdio-transport.js +71 -0
- package/dist/runtime/mcp/types.d.ts +85 -0
- package/dist/runtime/mcp/types.js +6 -0
- package/dist/runtime/sandbox/executor.d.ts +102 -0
- package/dist/runtime/sandbox/executor.js +537 -0
- package/dist/runtime/sandbox/index.d.ts +9 -0
- package/dist/runtime/sandbox/index.js +9 -0
- package/dist/runtime/sandbox/io-monitor.d.ts +78 -0
- package/dist/runtime/sandbox/io-monitor.js +98 -0
- package/dist/runtime/sandbox/time-parser.d.ts +19 -0
- package/dist/runtime/sandbox/time-parser.js +67 -0
- package/dist/runtime/sandbox/types.d.ts +58 -0
- package/dist/runtime/sandbox/types.js +23 -0
- package/dist/runtime/test/behavior-observer.d.ts +61 -0
- package/dist/runtime/test/behavior-observer.js +140 -0
- package/dist/runtime/test/contract-loader.d.ts +41 -0
- package/dist/runtime/test/contract-loader.js +158 -0
- package/dist/runtime/test/contract-schema.d.ts +46 -0
- package/dist/runtime/test/contract-schema.js +107 -0
- package/dist/runtime/test/contract-types.d.ts +106 -0
- package/dist/runtime/test/contract-types.js +6 -0
- package/dist/runtime/test/dependency-tracker.d.ts +66 -0
- package/dist/runtime/test/dependency-tracker.js +80 -0
- package/dist/runtime/test/formatters.d.ts +18 -0
- package/dist/runtime/test/formatters.js +172 -0
- package/dist/runtime/test/index.d.ts +12 -0
- package/dist/runtime/test/index.js +13 -0
- package/dist/runtime/test/input-generator.d.ts +33 -0
- package/dist/runtime/test/input-generator.js +498 -0
- package/dist/runtime/test/mcp-root-detector.d.ts +31 -0
- package/dist/runtime/test/mcp-root-detector.js +105 -0
- package/dist/runtime/test/orchestrator.d.ts +131 -0
- package/dist/runtime/test/orchestrator.js +738 -0
- package/dist/runtime/test/output-validator.d.ts +44 -0
- package/dist/runtime/test/output-validator.js +262 -0
- package/dist/runtime/test/retry-tester.d.ts +44 -0
- package/dist/runtime/test/retry-tester.js +103 -0
- package/dist/runtime/test/runner.d.ts +28 -0
- package/dist/runtime/test/runner.js +55 -0
- package/dist/runtime/test/synthetic-input-generator.d.ts +11 -0
- package/dist/runtime/test/synthetic-input-generator.js +154 -0
- package/dist/runtime/test/test-runner.d.ts +28 -0
- package/dist/runtime/test/test-runner.js +55 -0
- package/dist/types/factories.d.ts +16 -0
- package/dist/types/factories.js +43 -0
- package/dist/types/ids.d.ts +16 -0
- package/dist/types/ids.js +2 -0
- package/dist/types/opaque.d.ts +4 -0
- package/dist/types/opaque.js +2 -0
- package/dist/utils/errors.d.ts +92 -0
- package/dist/utils/errors.js +97 -0
- package/dist/utils/gitignore.d.ts +11 -0
- package/dist/utils/gitignore.js +59 -0
- package/dist/utils/json-file-saver.d.ts +17 -0
- package/dist/utils/json-file-saver.js +81 -0
- package/dist/utils/json-formatter.d.ts +63 -0
- package/dist/utils/json-formatter.js +344 -0
- package/dist/utils/logger.d.ts +184 -0
- package/dist/utils/logger.js +330 -0
- package/dist/utils/package-manager.d.ts +30 -0
- package/dist/utils/package-manager.js +157 -0
- package/dist/utils/version-checker.d.ts +47 -0
- package/dist/utils/version-checker.js +167 -0
- package/dist/utils/version-display.d.ts +10 -0
- package/dist/utils/version-display.js +20 -0
- package/package.json +106 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W108: Hidden Side Effects
|
|
3
|
+
*
|
|
4
|
+
* Condition:
|
|
5
|
+
* - Tool name/description suggests mutation
|
|
6
|
+
* - But schema does not reflect it
|
|
7
|
+
*
|
|
8
|
+
* Why:
|
|
9
|
+
* - Execution surprises
|
|
10
|
+
* - Hard to reason
|
|
11
|
+
*/
|
|
12
|
+
import { BaseRule } from '../base.js';
|
|
13
|
+
/**
|
|
14
|
+
* Mutation verbs used to detect side effects.
|
|
15
|
+
*/
|
|
16
|
+
const mutationVerbs = [
|
|
17
|
+
'create',
|
|
18
|
+
'delete',
|
|
19
|
+
'remove',
|
|
20
|
+
'update',
|
|
21
|
+
'modify',
|
|
22
|
+
'change',
|
|
23
|
+
'set',
|
|
24
|
+
'save',
|
|
25
|
+
'write',
|
|
26
|
+
'add',
|
|
27
|
+
'insert',
|
|
28
|
+
'destroy',
|
|
29
|
+
'drop',
|
|
30
|
+
'clear',
|
|
31
|
+
'reset',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Compiled regex for mutation verb detection (compiled once at module load).
|
|
35
|
+
*/
|
|
36
|
+
const MUTATION_REGEX = new RegExp(mutationVerbs.map(verb => `\\b${verb}\\b`).join('|'), 'i');
|
|
37
|
+
/**
|
|
38
|
+
* Check if a tool name/description suggests mutation.
|
|
39
|
+
*/
|
|
40
|
+
function suggestsMutation(toolName, description) {
|
|
41
|
+
const combined = `${toolName} ${description}`.toLowerCase();
|
|
42
|
+
return MUTATION_REGEX.test(combined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if schema reflects mutation (has outputs that suggest state change).
|
|
46
|
+
*/
|
|
47
|
+
function schemaReflectsMutation(tool) {
|
|
48
|
+
// If no outputs, treat as void mutation (e.g., DELETE operations, ack-only operations).
|
|
49
|
+
// This intentionally returns true to avoid false positives for tools that perform
|
|
50
|
+
// side effects without returning data (such operations may mutate state but only
|
|
51
|
+
// return success/acknowledgment implicitly).
|
|
52
|
+
if (tool.outputs.length === 0) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
// Check if outputs suggest mutation confirmation
|
|
56
|
+
const mutationOutputs = [
|
|
57
|
+
'success',
|
|
58
|
+
'id',
|
|
59
|
+
'result',
|
|
60
|
+
'status',
|
|
61
|
+
'created',
|
|
62
|
+
'updated',
|
|
63
|
+
'deleted',
|
|
64
|
+
];
|
|
65
|
+
for (const output of tool.outputs) {
|
|
66
|
+
const name = output.name.toLowerCase();
|
|
67
|
+
const desc = (output.description || '').toLowerCase();
|
|
68
|
+
if (mutationOutputs.some(mo => name.includes(mo) || desc.includes(mo))) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
class W108HiddenSideEffectsRule extends BaseRule {
|
|
75
|
+
id = 'W108';
|
|
76
|
+
severity = 'warning';
|
|
77
|
+
ruleName = 'Hidden Side Effects';
|
|
78
|
+
description = 'Tool appears to have side effects not reflected in schema. Execution surprises.';
|
|
79
|
+
check(ctx) {
|
|
80
|
+
const diagnostics = [];
|
|
81
|
+
for (const tool of ctx.tools) {
|
|
82
|
+
const description = tool.description || '';
|
|
83
|
+
const suggestsMut = suggestsMutation(tool.name, description);
|
|
84
|
+
const reflectsMut = schemaReflectsMutation(tool);
|
|
85
|
+
// If it suggests mutation but schema doesn't reflect it
|
|
86
|
+
if (suggestsMut && !reflectsMut) {
|
|
87
|
+
diagnostics.push(this.createDiagnostic(`Tool "${tool.name}" appears to have side effects not reflected in schema.`, tool.name, undefined, `Update the output schema of "${tool.name}" to reflect state changes (e.g., add success status, created ID, etc.).`));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return diagnostics;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const W108HiddenSideEffects = new W108HiddenSideEffectsRule();
|
|
94
|
+
//# sourceMappingURL=w108-hidden-side-effects.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W109: Tool Output Not Reusable
|
|
3
|
+
*
|
|
4
|
+
* Condition:
|
|
5
|
+
* - Output tailored only for natural language
|
|
6
|
+
* - Not structured for reuse
|
|
7
|
+
*
|
|
8
|
+
* Why:
|
|
9
|
+
* - Limits composability
|
|
10
|
+
*/
|
|
11
|
+
import { BaseRule } from '../base.js';
|
|
12
|
+
import type { AnalysisContext, Diagnostic } from '../../types.js';
|
|
13
|
+
declare class W109OutputNotReusableRule extends BaseRule {
|
|
14
|
+
readonly id = "W109";
|
|
15
|
+
readonly severity: "warning";
|
|
16
|
+
readonly ruleName = "Tool Output Not Reusable";
|
|
17
|
+
readonly description = "Output of tool is not designed for reuse. Limits composability.";
|
|
18
|
+
check(ctx: AnalysisContext): Diagnostic[];
|
|
19
|
+
}
|
|
20
|
+
export declare const W109OutputNotReusable: W109OutputNotReusableRule;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=w109-output-not-reusable.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W109: Tool Output Not Reusable
|
|
3
|
+
*
|
|
4
|
+
* Condition:
|
|
5
|
+
* - Output tailored only for natural language
|
|
6
|
+
* - Not structured for reuse
|
|
7
|
+
*
|
|
8
|
+
* Why:
|
|
9
|
+
* - Limits composability
|
|
10
|
+
*/
|
|
11
|
+
import { BaseRule } from '../base.js';
|
|
12
|
+
/**
|
|
13
|
+
* Check if output appears to be only for natural language display.
|
|
14
|
+
*/
|
|
15
|
+
function isNaturalLanguageOnly(output) {
|
|
16
|
+
const name = output.name.toLowerCase();
|
|
17
|
+
const desc = (output.description || '').toLowerCase();
|
|
18
|
+
const combined = `${name} ${desc}`;
|
|
19
|
+
// Indicators that output is only for display
|
|
20
|
+
const displayOnlyIndicators = [
|
|
21
|
+
'message',
|
|
22
|
+
'response',
|
|
23
|
+
'reply',
|
|
24
|
+
'answer',
|
|
25
|
+
'text',
|
|
26
|
+
'description',
|
|
27
|
+
'summary',
|
|
28
|
+
'note',
|
|
29
|
+
'comment',
|
|
30
|
+
'info',
|
|
31
|
+
];
|
|
32
|
+
// If it's a string type and name suggests display-only
|
|
33
|
+
if (output.type === 'string') {
|
|
34
|
+
return displayOnlyIndicators.some(indicator => combined.includes(indicator));
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
class W109OutputNotReusableRule extends BaseRule {
|
|
39
|
+
id = 'W109';
|
|
40
|
+
severity = 'warning';
|
|
41
|
+
ruleName = 'Tool Output Not Reusable';
|
|
42
|
+
description = 'Output of tool is not designed for reuse. Limits composability.';
|
|
43
|
+
check(ctx) {
|
|
44
|
+
const diagnostics = [];
|
|
45
|
+
for (const tool of ctx.tools) {
|
|
46
|
+
// Only check tools that have outputs
|
|
47
|
+
if (tool.outputs.length === 0) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Check if all outputs are natural language only
|
|
51
|
+
// Note: isNaturalLanguageOnly and isStructured are mutually exclusive,
|
|
52
|
+
// so if allNaturalLanguage is true, hasStructured must be false
|
|
53
|
+
const allNaturalLanguage = tool.outputs.every(output => isNaturalLanguageOnly(output));
|
|
54
|
+
// If all outputs are natural language only (implies none are structured)
|
|
55
|
+
if (allNaturalLanguage) {
|
|
56
|
+
diagnostics.push(this.createDiagnostic(`Output of "${tool.name}" is not designed for reuse (only natural language output).`, tool.name, undefined, `Add structured output fields (objects/arrays) to "${tool.name}" to improve composability with other tools.`));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return diagnostics;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export const W109OutputNotReusable = new W109OutputNotReusableRule();
|
|
63
|
+
//# sourceMappingURL=w109-output-not-reusable.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W110: Weak Schema
|
|
3
|
+
*
|
|
4
|
+
* Condition: Contract schema is too loose or doesn't match MCP tool schema structure
|
|
5
|
+
*
|
|
6
|
+
* Why this is a warning:
|
|
7
|
+
* - Loose schemas make validation less effective
|
|
8
|
+
* - Mismatch between contract and actual tool schema indicates contract needs update
|
|
9
|
+
*/
|
|
10
|
+
import { BaseRule } from '../base.js';
|
|
11
|
+
import type { AnalysisContext, Diagnostic } from '../../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Context for weak schema detection.
|
|
14
|
+
*/
|
|
15
|
+
export interface WeakSchemaContext {
|
|
16
|
+
/** Tool name */
|
|
17
|
+
toolName: string;
|
|
18
|
+
/** Contract input schema name */
|
|
19
|
+
contractInputSchema: string;
|
|
20
|
+
/** Contract output schema name */
|
|
21
|
+
contractOutputSchema: string;
|
|
22
|
+
/** Whether schemas match actual MCP tool schemas */
|
|
23
|
+
schemasMatch: boolean;
|
|
24
|
+
/** Details about mismatch (if any) */
|
|
25
|
+
mismatchDetails?: string;
|
|
26
|
+
}
|
|
27
|
+
declare class W110WeakSchemaRule extends BaseRule {
|
|
28
|
+
readonly id = "W110";
|
|
29
|
+
readonly severity: "warning";
|
|
30
|
+
readonly ruleName = "Weak Schema";
|
|
31
|
+
readonly description = "Contract schema is too loose or does not match MCP tool schema structure.";
|
|
32
|
+
check(_ctx: AnalysisContext): Diagnostic[];
|
|
33
|
+
/**
|
|
34
|
+
* Check with behavioral context (called from test orchestrator).
|
|
35
|
+
*/
|
|
36
|
+
checkWithBehavioralContext(behavioralCtx: WeakSchemaContext): Diagnostic[];
|
|
37
|
+
}
|
|
38
|
+
export declare const W110WeakSchema: W110WeakSchemaRule;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=w110-weak-schema.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W110: Weak Schema
|
|
3
|
+
*
|
|
4
|
+
* Condition: Contract schema is too loose or doesn't match MCP tool schema structure
|
|
5
|
+
*
|
|
6
|
+
* Why this is a warning:
|
|
7
|
+
* - Loose schemas make validation less effective
|
|
8
|
+
* - Mismatch between contract and actual tool schema indicates contract needs update
|
|
9
|
+
*/
|
|
10
|
+
import { BaseRule } from '../base.js';
|
|
11
|
+
class W110WeakSchemaRule extends BaseRule {
|
|
12
|
+
id = 'W110';
|
|
13
|
+
severity = 'warning';
|
|
14
|
+
ruleName = 'Weak Schema';
|
|
15
|
+
description = 'Contract schema is too loose or does not match MCP tool schema structure.';
|
|
16
|
+
check(_ctx) {
|
|
17
|
+
// This rule requires behavioral context (schema comparison)
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check with behavioral context (called from test orchestrator).
|
|
22
|
+
*/
|
|
23
|
+
checkWithBehavioralContext(behavioralCtx) {
|
|
24
|
+
const diagnostics = [];
|
|
25
|
+
if (!behavioralCtx.schemasMatch) {
|
|
26
|
+
diagnostics.push(this.createDiagnostic(`Tool "${behavioralCtx.toolName}" contract schemas do not match actual MCP tool schemas.${behavioralCtx.mismatchDetails ? ` ${behavioralCtx.mismatchDetails}` : ''}`, behavioralCtx.toolName, undefined, 'Update contract to match actual tool schema structure. Ensure input_schema and output_schema names reference correct schemas.'));
|
|
27
|
+
}
|
|
28
|
+
return diagnostics;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const W110WeakSchema = new W110WeakSchemaRule();
|
|
32
|
+
//# sourceMappingURL=w110-weak-schema.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W300: High Entropy Output
|
|
3
|
+
*
|
|
4
|
+
* Condition: Tool output has high entropy (random, unpredictable structure)
|
|
5
|
+
*
|
|
6
|
+
* Why this is a warning:
|
|
7
|
+
* - High entropy makes it hard for LLM to reason about output
|
|
8
|
+
* - Indicates potential design issues
|
|
9
|
+
* - May indicate non-determinism
|
|
10
|
+
*/
|
|
11
|
+
import { BaseRule } from '../base.js';
|
|
12
|
+
import type { AnalysisContext, Diagnostic } from '../../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Context for high entropy detection.
|
|
15
|
+
*/
|
|
16
|
+
export interface HighEntropyContext {
|
|
17
|
+
/** Tool name */
|
|
18
|
+
toolName: string;
|
|
19
|
+
/** Entropy score (0-1, higher = more entropy) */
|
|
20
|
+
entropyScore: number;
|
|
21
|
+
/** Reason for high entropy */
|
|
22
|
+
reason?: string;
|
|
23
|
+
/** Optional custom entropy threshold (defaults to 0.7 if not provided) */
|
|
24
|
+
entropyThreshold?: number;
|
|
25
|
+
}
|
|
26
|
+
declare class W300HighEntropyOutputRule extends BaseRule {
|
|
27
|
+
readonly id = "W300";
|
|
28
|
+
readonly severity: "warning";
|
|
29
|
+
readonly ruleName = "High Entropy Output";
|
|
30
|
+
readonly description = "Tool output has high entropy, making it difficult for LLM to reason about.";
|
|
31
|
+
check(_ctx: AnalysisContext): Diagnostic[];
|
|
32
|
+
/**
|
|
33
|
+
* Check with behavioral context (called from test orchestrator).
|
|
34
|
+
*/
|
|
35
|
+
checkWithBehavioralContext(behavioralCtx: HighEntropyContext): Diagnostic[];
|
|
36
|
+
}
|
|
37
|
+
export declare const W300HighEntropyOutput: W300HighEntropyOutputRule;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=w300-high-entropy-output.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W300: High Entropy Output
|
|
3
|
+
*
|
|
4
|
+
* Condition: Tool output has high entropy (random, unpredictable structure)
|
|
5
|
+
*
|
|
6
|
+
* Why this is a warning:
|
|
7
|
+
* - High entropy makes it hard for LLM to reason about output
|
|
8
|
+
* - Indicates potential design issues
|
|
9
|
+
* - May indicate non-determinism
|
|
10
|
+
*/
|
|
11
|
+
import { BaseRule } from '../base.js';
|
|
12
|
+
class W300HighEntropyOutputRule extends BaseRule {
|
|
13
|
+
id = 'W300';
|
|
14
|
+
severity = 'warning';
|
|
15
|
+
ruleName = 'High Entropy Output';
|
|
16
|
+
description = 'Tool output has high entropy, making it difficult for LLM to reason about.';
|
|
17
|
+
check(_ctx) {
|
|
18
|
+
// This rule requires behavioral context
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check with behavioral context (called from test orchestrator).
|
|
23
|
+
*/
|
|
24
|
+
checkWithBehavioralContext(behavioralCtx) {
|
|
25
|
+
const diagnostics = [];
|
|
26
|
+
// Validate and clamp entropyScore to [0, 1]
|
|
27
|
+
const entropyScore = Math.max(0, Math.min(1, behavioralCtx.entropyScore));
|
|
28
|
+
if (entropyScore !== behavioralCtx.entropyScore) {
|
|
29
|
+
// Out of range - could log warning or error in production
|
|
30
|
+
// For now, we silently clamp to valid range
|
|
31
|
+
}
|
|
32
|
+
// Validate and clamp entropyThreshold to [0, 1], default to 0.7
|
|
33
|
+
let threshold = behavioralCtx.entropyThreshold ?? 0.7;
|
|
34
|
+
if (threshold < 0 || threshold > 1 || !Number.isFinite(threshold)) {
|
|
35
|
+
// Invalid threshold - use default
|
|
36
|
+
threshold = 0.7;
|
|
37
|
+
}
|
|
38
|
+
threshold = Math.max(0, Math.min(1, threshold));
|
|
39
|
+
// Threshold: entropy above configured value is considered high
|
|
40
|
+
if (entropyScore > threshold) {
|
|
41
|
+
diagnostics.push(this.createDiagnostic(`Tool "${behavioralCtx.toolName}" produces high entropy output (score: ${entropyScore.toFixed(2)}, threshold: ${threshold.toFixed(2)}).${behavioralCtx.reason ? ` ${behavioralCtx.reason}` : ''}`, behavioralCtx.toolName, undefined, 'Consider normalizing output structure, reducing randomness, or providing more predictable output format.'));
|
|
42
|
+
}
|
|
43
|
+
return diagnostics;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export const W300HighEntropyOutput = new W300HighEntropyOutputRule();
|
|
47
|
+
//# sourceMappingURL=w300-high-entropy-output.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W301: Unstable Defaults
|
|
3
|
+
*
|
|
4
|
+
* Condition: Tool behavior changes significantly with default values
|
|
5
|
+
*
|
|
6
|
+
* Why this is a warning:
|
|
7
|
+
* - Defaults should be stable and predictable
|
|
8
|
+
* - Changing defaults breaks agent expectations
|
|
9
|
+
* - Indicates design inconsistency
|
|
10
|
+
*/
|
|
11
|
+
import { BaseRule } from '../base.js';
|
|
12
|
+
import type { AnalysisContext, Diagnostic } from '../../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Context for unstable defaults detection.
|
|
15
|
+
*/
|
|
16
|
+
export interface UnstableDefaultsContext {
|
|
17
|
+
/** Tool name */
|
|
18
|
+
toolName: string;
|
|
19
|
+
/** Fields with unstable defaults */
|
|
20
|
+
unstableFields: Array<{
|
|
21
|
+
fieldName: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
declare class W301UnstableDefaultsRule extends BaseRule {
|
|
26
|
+
readonly id = "W301";
|
|
27
|
+
readonly severity: "warning";
|
|
28
|
+
readonly ruleName = "Unstable Defaults";
|
|
29
|
+
readonly description = "Tool behavior changes significantly with default values, breaking agent expectations.";
|
|
30
|
+
check(_ctx: AnalysisContext): Diagnostic[];
|
|
31
|
+
/**
|
|
32
|
+
* Check with behavioral context (called from test orchestrator).
|
|
33
|
+
*/
|
|
34
|
+
checkWithBehavioralContext(behavioralCtx: UnstableDefaultsContext): Diagnostic[];
|
|
35
|
+
}
|
|
36
|
+
export declare const W301UnstableDefaults: W301UnstableDefaultsRule;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=w301-unstable-defaults.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W301: Unstable Defaults
|
|
3
|
+
*
|
|
4
|
+
* Condition: Tool behavior changes significantly with default values
|
|
5
|
+
*
|
|
6
|
+
* Why this is a warning:
|
|
7
|
+
* - Defaults should be stable and predictable
|
|
8
|
+
* - Changing defaults breaks agent expectations
|
|
9
|
+
* - Indicates design inconsistency
|
|
10
|
+
*/
|
|
11
|
+
import { BaseRule } from '../base.js';
|
|
12
|
+
class W301UnstableDefaultsRule extends BaseRule {
|
|
13
|
+
id = 'W301';
|
|
14
|
+
severity = 'warning';
|
|
15
|
+
ruleName = 'Unstable Defaults';
|
|
16
|
+
description = 'Tool behavior changes significantly with default values, breaking agent expectations.';
|
|
17
|
+
check(_ctx) {
|
|
18
|
+
// This rule requires behavioral context
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check with behavioral context (called from test orchestrator).
|
|
23
|
+
*/
|
|
24
|
+
checkWithBehavioralContext(behavioralCtx) {
|
|
25
|
+
const diagnostics = [];
|
|
26
|
+
if (behavioralCtx.unstableFields.length > 0) {
|
|
27
|
+
const fieldList = behavioralCtx.unstableFields
|
|
28
|
+
.map(f => ` - ${f.fieldName}: ${f.reason}`)
|
|
29
|
+
.join('\n');
|
|
30
|
+
diagnostics.push(this.createDiagnostic(`Tool "${behavioralCtx.toolName}" has unstable default values:\n${fieldList}`, behavioralCtx.toolName, undefined, 'Ensure default values are stable and predictable. Avoid defaults that change behavior significantly.'));
|
|
31
|
+
}
|
|
32
|
+
return diagnostics;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const W301UnstableDefaults = new W301UnstableDefaultsRule();
|
|
36
|
+
//# sourceMappingURL=w301-unstable-defaults.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict mode utilities.
|
|
3
|
+
* Converts warnings to errors when strict mode is enabled.
|
|
4
|
+
*/
|
|
5
|
+
import type { Diagnostic } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Apply strict mode to diagnostics.
|
|
8
|
+
* In strict mode, warnings are treated as errors.
|
|
9
|
+
* @param diagnostics - Array of diagnostics
|
|
10
|
+
* @param strictMode - Whether strict mode is enabled
|
|
11
|
+
* @returns Diagnostics with warnings converted to errors (if strict mode)
|
|
12
|
+
*/
|
|
13
|
+
export declare function applyStrictMode(diagnostics: Diagnostic[], strictMode: boolean): Diagnostic[];
|
|
14
|
+
/**
|
|
15
|
+
* Compute verdict from diagnostics (with strict mode support).
|
|
16
|
+
* @param diagnostics - Array of diagnostics
|
|
17
|
+
* @param strictMode - Whether strict mode is enabled
|
|
18
|
+
* @returns Verdict: 'pass', 'fail', or 'pass-with-warnings'
|
|
19
|
+
*/
|
|
20
|
+
export declare function computeVerdict(diagnostics: Diagnostic[], strictMode?: boolean): 'pass' | 'fail' | 'pass-with-warnings';
|
|
21
|
+
//# sourceMappingURL=strict-mode.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict mode utilities.
|
|
3
|
+
* Converts warnings to errors when strict mode is enabled.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Apply strict mode to diagnostics.
|
|
7
|
+
* In strict mode, warnings are treated as errors.
|
|
8
|
+
* @param diagnostics - Array of diagnostics
|
|
9
|
+
* @param strictMode - Whether strict mode is enabled
|
|
10
|
+
* @returns Diagnostics with warnings converted to errors (if strict mode)
|
|
11
|
+
*/
|
|
12
|
+
export function applyStrictMode(diagnostics, strictMode) {
|
|
13
|
+
if (!strictMode) {
|
|
14
|
+
return diagnostics;
|
|
15
|
+
}
|
|
16
|
+
return diagnostics.map(diagnostic => {
|
|
17
|
+
if (diagnostic.severity === 'warning') {
|
|
18
|
+
return {
|
|
19
|
+
...diagnostic,
|
|
20
|
+
severity: 'error',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return diagnostic;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compute verdict from diagnostics (with strict mode support).
|
|
28
|
+
* @param diagnostics - Array of diagnostics
|
|
29
|
+
* @param strictMode - Whether strict mode is enabled
|
|
30
|
+
* @returns Verdict: 'pass', 'fail', or 'pass-with-warnings'
|
|
31
|
+
*/
|
|
32
|
+
export function computeVerdict(diagnostics, strictMode = false) {
|
|
33
|
+
const processedDiagnostics = applyStrictMode(diagnostics, strictMode);
|
|
34
|
+
const errors = processedDiagnostics.filter(d => d.severity === 'error');
|
|
35
|
+
const warnings = processedDiagnostics.filter(d => d.severity === 'warning');
|
|
36
|
+
if (errors.length > 0) {
|
|
37
|
+
return 'fail';
|
|
38
|
+
}
|
|
39
|
+
if (warnings.length > 0) {
|
|
40
|
+
return 'pass-with-warnings';
|
|
41
|
+
}
|
|
42
|
+
return 'pass';
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=strict-mode.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the analysis engine.
|
|
3
|
+
* Core types for static analysis of MCP tool contracts.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Raw tool data from MCP server (before normalization).
|
|
7
|
+
*/
|
|
8
|
+
export interface RawTool {
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
inputSchema?: unknown;
|
|
12
|
+
outputSchema?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Field specification extracted from JSON Schema.
|
|
16
|
+
*/
|
|
17
|
+
export interface FieldSpec {
|
|
18
|
+
/** Tool name this field belongs to */
|
|
19
|
+
tool: string;
|
|
20
|
+
/** Field name */
|
|
21
|
+
name: string;
|
|
22
|
+
/** JSON Schema type (string, number, object, array, etc.) */
|
|
23
|
+
type: string;
|
|
24
|
+
/** Whether this field is required */
|
|
25
|
+
required: boolean;
|
|
26
|
+
/** Field description */
|
|
27
|
+
description?: string;
|
|
28
|
+
/** Enum values if applicable */
|
|
29
|
+
enum?: string[];
|
|
30
|
+
/** Regex pattern if applicable */
|
|
31
|
+
pattern?: string;
|
|
32
|
+
/** Example value if provided */
|
|
33
|
+
example?: unknown;
|
|
34
|
+
/** Whether field is nullable */
|
|
35
|
+
nullable?: boolean;
|
|
36
|
+
/** Nested properties for object types */
|
|
37
|
+
properties?: FieldSpec[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalized tool specification.
|
|
41
|
+
*/
|
|
42
|
+
export interface ToolSpec {
|
|
43
|
+
/** Tool name */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Tool description */
|
|
46
|
+
description: string;
|
|
47
|
+
/** Input fields */
|
|
48
|
+
inputs: FieldSpec[];
|
|
49
|
+
/** Output fields */
|
|
50
|
+
outputs: FieldSpec[];
|
|
51
|
+
/** Extracted tokens from description (for similarity matching) */
|
|
52
|
+
descriptionTokens: Set<string>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Inferred dependency between tools.
|
|
56
|
+
*/
|
|
57
|
+
export interface Dependency {
|
|
58
|
+
/** Source tool name */
|
|
59
|
+
fromTool: string;
|
|
60
|
+
/** Source field name */
|
|
61
|
+
fromField: string;
|
|
62
|
+
/** Target tool name */
|
|
63
|
+
toTool: string;
|
|
64
|
+
/** Target field name */
|
|
65
|
+
toField: string;
|
|
66
|
+
/** Confidence score (0.0-1.0) */
|
|
67
|
+
confidence: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Analysis diagnostic (error or warning).
|
|
71
|
+
*/
|
|
72
|
+
export interface Diagnostic {
|
|
73
|
+
/** Diagnostic code (E001-E010 for errors, W001-W010 for warnings) */
|
|
74
|
+
code: string;
|
|
75
|
+
/** Severity level */
|
|
76
|
+
severity: 'error' | 'warning';
|
|
77
|
+
/** Human-readable message */
|
|
78
|
+
message: string;
|
|
79
|
+
/** Tool name (if applicable) */
|
|
80
|
+
tool?: string;
|
|
81
|
+
/** Field name (if applicable) */
|
|
82
|
+
field?: string;
|
|
83
|
+
/** Suggestion for fixing the issue */
|
|
84
|
+
suggestion?: string;
|
|
85
|
+
/** Additional context */
|
|
86
|
+
context?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Analysis verdict.
|
|
90
|
+
*/
|
|
91
|
+
export type Verdict = 'pass' | 'fail' | 'pass-with-warnings';
|
|
92
|
+
/**
|
|
93
|
+
* Indexes for fast lookups.
|
|
94
|
+
*/
|
|
95
|
+
export interface Indexes {
|
|
96
|
+
/** Map of tool name to ToolSpec */
|
|
97
|
+
toolIndex: Map<string, ToolSpec>;
|
|
98
|
+
/** Map of field name to FieldSpec[] (for inputs) */
|
|
99
|
+
inputIndex: Map<string, FieldSpec[]>;
|
|
100
|
+
/** Map of field name to FieldSpec[] (for outputs) */
|
|
101
|
+
outputIndex: Map<string, FieldSpec[]>;
|
|
102
|
+
/** Map of keyword to Set<tool names> */
|
|
103
|
+
keywordIndex: Map<string, Set<string>>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Analysis context passed to rules.
|
|
107
|
+
*/
|
|
108
|
+
export interface AnalysisContext {
|
|
109
|
+
/** All normalized tools */
|
|
110
|
+
tools: ToolSpec[];
|
|
111
|
+
/** Inferred dependencies */
|
|
112
|
+
dependencies: Dependency[];
|
|
113
|
+
/** Built indexes */
|
|
114
|
+
indexes: Indexes;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Analysis result.
|
|
118
|
+
*/
|
|
119
|
+
export interface AnalysisResult {
|
|
120
|
+
/** Final verdict */
|
|
121
|
+
verdict: Verdict;
|
|
122
|
+
/** All diagnostics */
|
|
123
|
+
diagnostics: Diagnostic[];
|
|
124
|
+
/** Error diagnostics only */
|
|
125
|
+
errors: Diagnostic[];
|
|
126
|
+
/** Warning diagnostics only */
|
|
127
|
+
warnings: Diagnostic[];
|
|
128
|
+
/** Inferred dependencies */
|
|
129
|
+
dependencies: Dependency[];
|
|
130
|
+
/** Number of tools analyzed */
|
|
131
|
+
toolCount: number;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility functions for analysis rules.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Escape regex metacharacters in a string to use it as a literal pattern.
|
|
6
|
+
* This prevents ReDoS attacks and regex injection vulnerabilities.
|
|
7
|
+
*
|
|
8
|
+
* @param str - The string to escape
|
|
9
|
+
* @returns The escaped string safe for use in RegExp constructor
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const keyword = "user.id";
|
|
14
|
+
* const escaped = escapeRegex(keyword); // "user\\.id"
|
|
15
|
+
* const regex = new RegExp(`\\b${escaped}\\b`, 'i');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function escapeRegex(str: string): string;
|
|
19
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility functions for analysis rules.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Escape regex metacharacters in a string to use it as a literal pattern.
|
|
6
|
+
* This prevents ReDoS attacks and regex injection vulnerabilities.
|
|
7
|
+
*
|
|
8
|
+
* @param str - The string to escape
|
|
9
|
+
* @returns The escaped string safe for use in RegExp constructor
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const keyword = "user.id";
|
|
14
|
+
* const escaped = escapeRegex(keyword); // "user\\.id"
|
|
15
|
+
* const regex = new RegExp(`\\b${escaped}\\b`, 'i');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function escapeRegex(str) {
|
|
19
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=utils.js.map
|