mm_workflow 1.0.1 → 1.0.10
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/README.md +144 -37
- package/common/mod/calculator/average/calculator.json +60 -0
- package/common/mod/calculator/average/index.js +48 -0
- package/common/mod/calculator/count/calculator.json +78 -0
- package/common/mod/calculator/count/index.js +58 -0
- package/common/mod/calculator/formula/calculator.json +48 -0
- package/common/mod/calculator/formula/index.js +40 -0
- package/common/mod/calculator/indicator/calculator.json +67 -0
- package/common/mod/calculator/indicator/index.js +280 -0
- package/common/mod/calculator/kline/calculator.json +72 -0
- package/common/mod/calculator/kline/index.js +148 -0
- package/common/mod/calculator/percent/calculator.json +55 -0
- package/common/mod/calculator/percent/index.js +18 -0
- package/common/mod/calculator/probability/calculator.json +61 -0
- package/common/mod/calculator/probability/index.js +132 -0
- package/common/mod/calculator/random/calculator.json +57 -0
- package/common/mod/calculator/random/index.js +85 -0
- package/common/mod/calculator/round/calculator.json +65 -0
- package/common/mod/calculator/round/index.js +36 -0
- package/common/mod/calculator/snowflake/calculator.json +67 -0
- package/common/mod/calculator/snowflake/index.js +115 -0
- package/common/mod/calculator/sum/calculator.json +56 -0
- package/common/mod/calculator/sum/index.js +62 -0
- package/common/mod/converter/case/converter.json +54 -0
- package/common/mod/converter/case/index.js +26 -0
- package/common/mod/converter/color/converter.json +60 -0
- package/common/mod/converter/color/index.js +182 -0
- package/common/mod/converter/compress/converter.json +66 -0
- package/common/mod/converter/compress/index.js +53 -0
- package/common/mod/converter/constants/converter.json +80 -0
- package/common/mod/converter/constants/index.js +97 -0
- package/common/mod/converter/date/converter.json +60 -0
- package/common/mod/converter/date/index.js +155 -0
- package/common/mod/converter/encoding/converter.json +78 -0
- package/common/mod/converter/encoding/index.js +76 -0
- package/common/mod/converter/excel/converter.json +79 -0
- package/common/mod/converter/excel/index.js +241 -0
- package/common/mod/converter/format/converter.json +75 -0
- package/common/mod/converter/format/index.js +203 -0
- package/common/mod/converter/image/converter.json +133 -0
- package/common/mod/converter/image/index.js +324 -0
- package/common/mod/converter/password/converter.json +73 -0
- package/common/mod/converter/password/index.js +103 -0
- package/common/mod/converter/pdf/converter.json +87 -0
- package/common/mod/converter/pdf/index.js +288 -0
- package/common/mod/converter/type/converter.json +63 -0
- package/common/mod/converter/type/index.js +32 -0
- package/common/mod/converter/unit/converter.json +63 -0
- package/common/mod/converter/unit/index.js +56 -0
- package/common/mod/converter/util/converter.json +85 -0
- package/common/mod/converter/util/index.js +124 -0
- package/common/mod/converter/video/converter.json +71 -0
- package/common/mod/converter/video/index.js +124 -0
- package/common/mod/converter/word/converter.json +79 -0
- package/common/mod/converter/word/index.js +134 -0
- package/common/mod/designer/bpmn/designer.json +48 -0
- package/common/mod/designer/bpmn/index.js +47 -0
- package/common/mod/designer/form/designer.json +52 -0
- package/common/mod/designer/form/index.js +47 -0
- package/common/mod/designer/layout/designer.json +57 -0
- package/common/mod/designer/layout/index.js +52 -0
- package/common/mod/designer/layout_tpl/designer.json +56 -0
- package/common/mod/designer/layout_tpl/index.js +53 -0
- package/common/mod/designer/module/designer.json +79 -0
- package/common/mod/designer/module/index.js +57 -0
- package/common/mod/designer/schema/designer.json +57 -0
- package/common/mod/designer/schema/index.js +35 -0
- package/common/mod/designer/workflow/designer.json +104 -0
- package/common/mod/designer/workflow/index.js +183 -0
- package/common/mod/dialoguer/ask/dialoguer.json +107 -0
- package/common/mod/dialoguer/ask/index.js +28 -0
- package/common/mod/dialoguer/end/dialoguer.json +58 -0
- package/common/mod/dialoguer/end/index.js +20 -0
- package/common/mod/dialoguer/input/dialoguer.json +120 -0
- package/common/mod/dialoguer/input/index.js +37 -0
- package/common/mod/dialoguer/menu/dialoguer.json +106 -0
- package/common/mod/dialoguer/menu/index.js +33 -0
- package/common/mod/dialoguer/modal/dialoguer.json +75 -0
- package/common/mod/dialoguer/modal/index.js +22 -0
- package/common/mod/dialoguer/notify/dialoguer.json +98 -0
- package/common/mod/dialoguer/notify/index.js +24 -0
- package/common/mod/dialoguer/paging/dialoguer.json +132 -0
- package/common/mod/dialoguer/paging/index.js +33 -0
- package/common/mod/dialoguer/say/dialoguer.json +82 -0
- package/common/mod/dialoguer/say/index.js +22 -0
- package/common/mod/dialoguer/style/dialoguer.json +104 -0
- package/common/mod/dialoguer/style/index.js +34 -0
- package/common/mod/dispatcher/condition/dispatcher.json +86 -0
- package/common/mod/dispatcher/condition/index.js +103 -0
- package/common/mod/dispatcher/label_jump/dispatcher.json +54 -0
- package/common/mod/dispatcher/label_jump/index.js +30 -0
- package/common/mod/dispatcher/load_balance/dispatcher.json +43 -0
- package/common/mod/dispatcher/load_balance/index.js +73 -0
- package/common/mod/dispatcher/parallel/dispatcher.json +46 -0
- package/common/mod/dispatcher/parallel/index.js +240 -0
- package/common/mod/dispatcher/priority/dispatcher.json +51 -0
- package/common/mod/dispatcher/priority/index.js +32 -0
- package/common/mod/dispatcher/retry/dispatcher.json +41 -0
- package/common/mod/dispatcher/retry/index.js +66 -0
- package/common/mod/dispatcher/route/dispatcher.json +43 -0
- package/common/mod/dispatcher/route/index.js +42 -0
- package/common/mod/dispatcher/state_machine/dispatcher.json +80 -0
- package/common/mod/dispatcher/state_machine/index.js +172 -0
- package/common/mod/dispatcher/subflow/dispatcher.json +47 -0
- package/common/mod/dispatcher/subflow/index.js +91 -0
- package/common/mod/dispatcher/switch_case/dispatcher.json +74 -0
- package/common/mod/dispatcher/switch_case/index.js +77 -0
- package/common/mod/executor/ai/executor.json +120 -0
- package/common/mod/executor/ai/index.js +224 -0
- package/common/mod/executor/ai_vision/executor.json +76 -0
- package/common/mod/executor/ai_vision/index.js +76 -0
- package/common/mod/executor/command/executor.json +74 -0
- package/common/mod/executor/command/index.js +40 -0
- package/common/mod/executor/custom/executor.json +62 -0
- package/common/mod/executor/custom/index.js +219 -0
- package/common/mod/executor/function/executor.json +51 -0
- package/common/mod/executor/function/index.js +41 -0
- package/common/mod/executor/http/executor.json +81 -0
- package/common/mod/executor/http/index.js +76 -0
- package/common/mod/executor/llm/executor.json +152 -0
- package/common/mod/executor/llm/index.js +231 -0
- package/common/mod/executor/mcp/executor.json +97 -0
- package/common/mod/executor/mcp/index.js +198 -0
- package/common/mod/executor/notify/executor.json +58 -0
- package/common/mod/executor/notify/index.js +30 -0
- package/common/mod/executor/rpc/executor.json +87 -0
- package/common/mod/executor/rpc/index.js +144 -0
- package/common/mod/executor/script/executor.json +55 -0
- package/common/mod/executor/script/index.js +22 -0
- package/common/mod/filter/circuit_breaker/filter.json +86 -0
- package/common/mod/filter/circuit_breaker/index.js +164 -0
- package/common/mod/filter/ip_block/filter.json +49 -0
- package/common/mod/filter/ip_block/index.js +20 -0
- package/common/mod/filter/rate_limit/filter.json +60 -0
- package/common/mod/filter/rate_limit/index.js +49 -0
- package/common/mod/filter/sensitive/filter.json +38 -0
- package/common/mod/filter/sensitive/index.js +29 -0
- package/common/mod/filter/spam/filter.json +48 -0
- package/common/mod/filter/spam/index.js +30 -0
- package/common/mod/filter/sql_inject/filter.json +48 -0
- package/common/mod/filter/sql_inject/index.js +35 -0
- package/common/mod/gateway/alipay/gateway.json +76 -0
- package/common/mod/gateway/alipay/index.js +132 -0
- package/common/mod/gateway/dingtalk/gateway.json +68 -0
- package/common/mod/gateway/dingtalk/index.js +92 -0
- package/common/mod/gateway/email/gateway.json +73 -0
- package/common/mod/gateway/email/index.js +42 -0
- package/common/mod/gateway/push/gateway.json +65 -0
- package/common/mod/gateway/push/index.js +96 -0
- package/common/mod/gateway/sms/gateway.json +72 -0
- package/common/mod/gateway/sms/index.js +109 -0
- package/common/mod/gateway/stripe/gateway.json +64 -0
- package/common/mod/gateway/stripe/index.js +107 -0
- package/common/mod/gateway/wechat/gateway.json +68 -0
- package/common/mod/gateway/wechat/index.js +73 -0
- package/common/mod/gateway/wechat_pay/gateway.json +92 -0
- package/common/mod/gateway/wechat_pay/index.js +200 -0
- package/common/mod/generator/api/generator.json +61 -0
- package/common/mod/generator/api/index.js +41 -0
- package/common/mod/generator/code/generator.json +60 -0
- package/common/mod/generator/code/index.js +81 -0
- package/common/mod/generator/config/generator.json +62 -0
- package/common/mod/generator/config/index.js +51 -0
- package/common/mod/generator/datetime/generator.json +67 -0
- package/common/mod/generator/datetime/index.js +93 -0
- package/common/mod/generator/llm_gen_workflow/generator.json +197 -0
- package/common/mod/generator/llm_gen_workflow/index.js +1066 -0
- package/common/mod/generator/llm_gen_workflow/workflow_prompt.md +162 -0
- package/common/mod/generator/report/generator.json +64 -0
- package/common/mod/generator/report/index.js +51 -0
- package/common/mod/generator/script/generator.json +65 -0
- package/common/mod/generator/script/index.js +53 -0
- package/common/mod/generator/test_data/generator.json +101 -0
- package/common/mod/generator/test_data/index.js +193 -0
- package/common/mod/looper/batch/index.js +24 -0
- package/common/mod/looper/batch/looper.json +45 -0
- package/common/mod/looper/loop/index.js +140 -0
- package/common/mod/looper/loop/looper.json +72 -0
- package/common/mod/looper/loop_retry/index.js +37 -0
- package/common/mod/looper/loop_retry/looper.json +67 -0
- package/common/mod/looper/pagination/index.js +31 -0
- package/common/mod/looper/pagination/looper.json +60 -0
- package/common/mod/looper/schedule/index.js +110 -0
- package/common/mod/looper/schedule/looper.json +74 -0
- package/common/mod/looper/watchdog/index.js +28 -0
- package/common/mod/looper/watchdog/looper.json +53 -0
- package/common/mod/manager/artifact/index.js +161 -0
- package/common/mod/manager/artifact/manager.json +96 -0
- package/common/mod/manager/cache/index.js +62 -0
- package/common/mod/manager/cache/manager.json +72 -0
- package/common/mod/manager/call_log/index.js +145 -0
- package/common/mod/manager/call_log/manager.json +84 -0
- package/common/mod/manager/config/index.js +100 -0
- package/common/mod/manager/config/manager.json +79 -0
- package/common/mod/manager/data/index.js +478 -0
- package/common/mod/manager/data/manager.json +88 -0
- package/common/mod/manager/database/index.js +91 -0
- package/common/mod/manager/database/manager.json +90 -0
- package/common/mod/manager/discovery/index.js +248 -0
- package/common/mod/manager/discovery/manager.json +95 -0
- package/common/mod/manager/file/index.js +56 -0
- package/common/mod/manager/file/manager.json +59 -0
- package/common/mod/manager/git/index.js +133 -0
- package/common/mod/manager/git/manager.json +103 -0
- package/common/mod/manager/json/index.js +133 -0
- package/common/mod/manager/json/manager.json +88 -0
- package/common/mod/manager/json_util.js +121 -0
- package/common/mod/manager/log/index.js +301 -0
- package/common/mod/manager/log/manager.json +108 -0
- package/common/mod/manager/migration/index.js +367 -0
- package/common/mod/manager/migration/manager.json +149 -0
- package/common/mod/manager/module/index.js +70 -0
- package/common/mod/manager/module/manager.json +62 -0
- package/common/mod/manager/mongodb/index.js +80 -0
- package/common/mod/manager/mongodb/manager.json +164 -0
- package/common/mod/manager/mysql/index.js +213 -0
- package/common/mod/manager/mysql/manager.json +117 -0
- package/common/mod/manager/mysql_rw/index.js +239 -0
- package/common/mod/manager/mysql_rw/manager.json +104 -0
- package/common/mod/manager/oss/index.js +261 -0
- package/common/mod/manager/oss/manager.json +111 -0
- package/common/mod/manager/queue/index.js +396 -0
- package/common/mod/manager/queue/manager.json +128 -0
- package/common/mod/manager/redis/index.js +62 -0
- package/common/mod/manager/redis/manager.json +132 -0
- package/common/mod/manager/redis_lock/index.js +211 -0
- package/common/mod/manager/redis_lock/manager.json +90 -0
- package/common/mod/manager/repository/index.js +270 -0
- package/common/mod/manager/repository/manager.json +102 -0
- package/common/mod/manager/sql_dump/index.js +185 -0
- package/common/mod/manager/sql_dump/manager.json +82 -0
- package/common/mod/manager/sqlite/index.js +130 -0
- package/common/mod/manager/sqlite/manager.json +81 -0
- package/common/mod/manager/text/index.js +75 -0
- package/common/mod/manager/text/manager.json +77 -0
- package/common/mod/manager/variables/index.js +73 -0
- package/common/mod/manager/variables/manager.json +67 -0
- package/common/mod/matcher/exact/index.js +21 -0
- package/common/mod/matcher/exact/matcher.json +38 -0
- package/common/mod/matcher/fuzzy/index.js +22 -0
- package/common/mod/matcher/fuzzy/matcher.json +42 -0
- package/common/mod/matcher/mqtt_topic/index.js +88 -0
- package/common/mod/matcher/mqtt_topic/matcher.json +42 -0
- package/common/mod/matcher/prefix/index.js +21 -0
- package/common/mod/matcher/prefix/matcher.json +42 -0
- package/common/mod/matcher/recommend/index.js +85 -0
- package/common/mod/matcher/recommend/matcher.json +54 -0
- package/common/mod/matcher/regex/index.js +31 -0
- package/common/mod/matcher/regex/matcher.json +42 -0
- package/common/mod/matcher/route/index.js +35 -0
- package/common/mod/matcher/route/matcher.json +46 -0
- package/common/mod/matcher/rule_engine/index.js +152 -0
- package/common/mod/matcher/rule_engine/matcher.json +171 -0
- package/common/mod/matcher/similarity/index.js +53 -0
- package/common/mod/matcher/similarity/matcher.json +50 -0
- package/common/mod/matcher/wildcard/index.js +25 -0
- package/common/mod/matcher/wildcard/matcher.json +42 -0
- package/common/mod/observer/audit/index.js +34 -0
- package/common/mod/observer/audit/observer.json +62 -0
- package/common/mod/observer/audit_persist/index.js +86 -0
- package/common/mod/observer/audit_persist/observer.json +82 -0
- package/common/mod/observer/counter/index.js +79 -0
- package/common/mod/observer/counter/observer.json +57 -0
- package/common/mod/observer/event_listen/index.js +131 -0
- package/common/mod/observer/event_listen/observer.json +58 -0
- package/common/mod/observer/health/index.js +99 -0
- package/common/mod/observer/health/observer.json +45 -0
- package/common/mod/observer/log_watch/index.js +24 -0
- package/common/mod/observer/log_watch/observer.json +77 -0
- package/common/mod/observer/metric/index.js +25 -0
- package/common/mod/observer/metric/observer.json +75 -0
- package/common/mod/observer/performance/index.js +45 -0
- package/common/mod/observer/performance/observer.json +66 -0
- package/common/mod/observer/prometheus/index.js +182 -0
- package/common/mod/observer/prometheus/observer.json +108 -0
- package/common/mod/parser/bpmn/index.js +53 -0
- package/common/mod/parser/bpmn/parser.json +49 -0
- package/common/mod/parser/csv/index.js +36 -0
- package/common/mod/parser/csv/parser.json +62 -0
- package/common/mod/parser/form/index.js +24 -0
- package/common/mod/parser/form/parser.json +51 -0
- package/common/mod/parser/json/index.js +28 -0
- package/common/mod/parser/json/parser.json +44 -0
- package/common/mod/parser/protobuf/index.js +47 -0
- package/common/mod/parser/protobuf/parser.json +49 -0
- package/common/mod/parser/protocol/index.js +151 -0
- package/common/mod/parser/protocol/parser.json +67 -0
- package/common/mod/parser/xml/index.js +37 -0
- package/common/mod/parser/xml/parser.json +44 -0
- package/common/mod/parser/yaml/index.js +94 -0
- package/common/mod/parser/yaml/parser.json +44 -0
- package/common/mod/querier/aggregate/index.js +116 -0
- package/common/mod/querier/aggregate/querier.json +62 -0
- package/common/mod/querier/condition/index.js +72 -0
- package/common/mod/querier/condition/querier.json +83 -0
- package/common/mod/querier/module_search/index.js +275 -0
- package/common/mod/querier/module_search/querier.json +83 -0
- package/common/mod/querier/paginate/index.js +24 -0
- package/common/mod/querier/paginate/querier.json +50 -0
- package/common/mod/querier/path/index.js +131 -0
- package/common/mod/querier/path/querier.json +98 -0
- package/common/mod/querier/random/index.js +172 -0
- package/common/mod/querier/random/querier.json +90 -0
- package/common/mod/querier/search/index.js +61 -0
- package/common/mod/querier/search/querier.json +64 -0
- package/common/mod/querier/set/index.js +161 -0
- package/common/mod/querier/set/querier.json +64 -0
- package/common/mod/querier/sort/index.js +41 -0
- package/common/mod/querier/sort/querier.json +69 -0
- package/common/mod/receiver/download/index.js +237 -0
- package/common/mod/receiver/download/receiver.json +92 -0
- package/common/mod/receiver/file/index.js +23 -0
- package/common/mod/receiver/file/receiver.json +91 -0
- package/common/mod/receiver/http/index.js +46 -0
- package/common/mod/receiver/http/receiver.json +77 -0
- package/common/mod/receiver/mqtt/index.js +29 -0
- package/common/mod/receiver/mqtt/receiver.json +68 -0
- package/common/mod/receiver/stream/index.js +20 -0
- package/common/mod/receiver/stream/receiver.json +66 -0
- package/common/mod/receiver/upload/index.js +170 -0
- package/common/mod/receiver/upload/receiver.json +96 -0
- package/common/mod/receiver/webhook/index.js +107 -0
- package/common/mod/receiver/webhook/receiver.json +81 -0
- package/common/mod/receiver/ws/index.js +33 -0
- package/common/mod/receiver/ws/receiver.json +68 -0
- package/common/mod/renderer/component/css_values.json +178 -0
- package/common/mod/renderer/component/index.js +621 -0
- package/common/mod/renderer/component/renderer.json +499 -0
- package/common/mod/renderer/component/var_prefix.json +17 -0
- package/common/mod/renderer/html/index.js +48 -0
- package/common/mod/renderer/html/renderer.json +73 -0
- package/common/mod/renderer/json/index.js +44 -0
- package/common/mod/renderer/json/renderer.json +77 -0
- package/common/mod/renderer/markdown/index.js +48 -0
- package/common/mod/renderer/markdown/renderer.json +73 -0
- package/common/mod/renderer/template/index.js +55 -0
- package/common/mod/renderer/template/renderer.json +82 -0
- package/common/mod/renderer/text/index.js +61 -0
- package/common/mod/renderer/text/renderer.json +78 -0
- package/common/mod/renderer/webpage/index.js +125 -0
- package/common/mod/renderer/webpage/renderer.json +125 -0
- package/common/mod/reviewer/code_review/index.js +96 -0
- package/common/mod/reviewer/code_review/reviewer.json +71 -0
- package/common/mod/reviewer/compliance/index.js +103 -0
- package/common/mod/reviewer/compliance/reviewer.json +59 -0
- package/common/mod/reviewer/image/index.js +61 -0
- package/common/mod/reviewer/image/reviewer.json +59 -0
- package/common/mod/reviewer/logic_verify/index.js +111 -0
- package/common/mod/reviewer/logic_verify/reviewer.json +33 -0
- package/common/mod/reviewer/mock/index.js +228 -0
- package/common/mod/reviewer/mock/reviewer.json +93 -0
- package/common/mod/reviewer/module_check/index.js +395 -0
- package/common/mod/reviewer/module_check/reviewer.json +84 -0
- package/common/mod/reviewer/perf_review/index.js +42 -0
- package/common/mod/reviewer/perf_review/reviewer.json +54 -0
- package/common/mod/reviewer/quality/index.js +66 -0
- package/common/mod/reviewer/quality/reviewer.json +66 -0
- package/common/mod/reviewer/security/index.js +95 -0
- package/common/mod/reviewer/security/reviewer.json +58 -0
- package/common/mod/reviewer/text/index.js +100 -0
- package/common/mod/reviewer/text/reviewer.json +77 -0
- package/common/mod/reviewer/unit_test/index.js +134 -0
- package/common/mod/reviewer/unit_test/reviewer.json +57 -0
- package/common/mod/reviewer/video/index.js +61 -0
- package/common/mod/reviewer/video/reviewer.json +59 -0
- package/common/mod/sender/console/index.js +20 -0
- package/common/mod/sender/console/sender.json +62 -0
- package/common/mod/sender/download/index.js +97 -0
- package/common/mod/sender/download/sender.json +69 -0
- package/common/mod/sender/event_emit/index.js +69 -0
- package/common/mod/sender/event_emit/sender.json +60 -0
- package/common/mod/sender/gateway/index.js +37 -0
- package/common/mod/sender/gateway/sender.json +67 -0
- package/common/mod/sender/http_reply/index.js +57 -0
- package/common/mod/sender/http_reply/sender.json +73 -0
- package/common/mod/sender/log/index.js +18 -0
- package/common/mod/sender/log/sender.json +62 -0
- package/common/mod/sender/mqtt/index.js +62 -0
- package/common/mod/sender/mqtt/sender.json +76 -0
- package/common/mod/sender/push/index.js +36 -0
- package/common/mod/sender/push/sender.json +62 -0
- package/common/mod/sender/push_queue/index.js +116 -0
- package/common/mod/sender/push_queue/sender.json +55 -0
- package/common/mod/sender/upload/index.js +258 -0
- package/common/mod/sender/upload/sender.json +75 -0
- package/common/mod/solidifier/backup/index.js +114 -0
- package/common/mod/solidifier/backup/solidifier.json +61 -0
- package/common/mod/solidifier/compile/index.js +55 -0
- package/common/mod/solidifier/compile/solidifier.json +65 -0
- package/common/mod/solidifier/deploy/index.js +138 -0
- package/common/mod/solidifier/deploy/solidifier.json +107 -0
- package/common/mod/solidifier/encrypt/index.js +133 -0
- package/common/mod/solidifier/encrypt/solidifier.json +59 -0
- package/common/mod/solidifier/firmware/index.js +122 -0
- package/common/mod/solidifier/firmware/solidifier.json +110 -0
- package/common/mod/solidifier/mod_loader/index.js +115 -0
- package/common/mod/solidifier/mod_loader/solidifier.json +45 -0
- package/common/mod/solidifier/package/index.js +109 -0
- package/common/mod/solidifier/package/solidifier.json +63 -0
- package/common/mod/validator/abac/index.js +80 -0
- package/common/mod/validator/abac/validator.json +75 -0
- package/common/mod/validator/basic/index.js +73 -0
- package/common/mod/validator/basic/validator.json +68 -0
- package/common/mod/validator/code/index.js +462 -0
- package/common/mod/validator/code/validator.json +68 -0
- package/common/mod/validator/enum/index.js +22 -0
- package/common/mod/validator/enum/validator.json +50 -0
- package/common/mod/validator/json/index.js +181 -0
- package/common/mod/validator/json/validator.json +64 -0
- package/common/mod/validator/jwt/index.js +109 -0
- package/common/mod/validator/jwt/validator.json +90 -0
- package/common/mod/validator/length/index.js +61 -0
- package/common/mod/validator/length/validator.json +52 -0
- package/common/mod/validator/oauth/index.js +170 -0
- package/common/mod/validator/oauth/validator.json +85 -0
- package/common/mod/validator/params/index.js +99 -0
- package/common/mod/validator/params/validator.json +91 -0
- package/common/mod/validator/pattern/index.js +58 -0
- package/common/mod/validator/pattern/validator.json +51 -0
- package/common/mod/validator/range/index.js +112 -0
- package/common/mod/validator/range/validator.json +78 -0
- package/common/mod/validator/rbac/index.js +92 -0
- package/common/mod/validator/rbac/validator.json +73 -0
- package/common/mod/validator/required/index.js +37 -0
- package/common/mod/validator/required/validator.json +45 -0
- package/common/mod/validator/sanitize/index.js +124 -0
- package/common/mod/validator/sanitize/validator.json +82 -0
- package/common/mod/validator/string/index.js +75 -0
- package/common/mod/validator/string/validator.json +61 -0
- package/common/mod/validator/type/index.js +21 -0
- package/common/mod/validator/type/validator.json +53 -0
- package/common/workflow/wftest_1789472356864/ok_wf.json +20 -0
- package/common/workflow/wftest_1789472356864/suggest_h.json +14 -0
- package/common/workflow/wftest_1789472528456/ok_wf.json +20 -0
- package/common/workflow/wftest_1789472528456/suggest_h.json +14 -0
- package/common/workflow/wftest_1789472914308/ok_wf.json +20 -0
- package/common/workflow/wftest_1789472914308/suggest_h.json +14 -0
- package/common/workflow/wftest_1789472926735/ok_wf.json +20 -0
- package/common/workflow/wftest_1789472926735/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473005165/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473005165/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473128440/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473128440/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473140984/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473140984/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473444205/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473444205/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473632028/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473632028/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473735755/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473735755/suggest_h.json +14 -0
- package/common/workflow/wftest_1789473793373/ok_wf.json +20 -0
- package/common/workflow/wftest_1789473793373/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474054650/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474054650/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474139961/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474139961/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474522109/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474522109/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474695647/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474695647/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474822920/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474822920/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474863955/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474863955/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474920642/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474920642/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474948523/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474948523/suggest_h.json +14 -0
- package/common/workflow/wftest_1789474977320/ok_wf.json +20 -0
- package/common/workflow/wftest_1789474977320/suggest_h.json +14 -0
- package/common/workflow/wftest_1789475013956/ok_wf.json +20 -0
- package/common/workflow/wftest_1789475013956/suggest_h.json +14 -0
- package/common/workflow/wftest_1789476776624/ok_wf.json +20 -0
- package/common/workflow/wftest_1789476776624/suggest_h.json +14 -0
- package/common/workflow/wftest_1789477074699/ok_wf.json +20 -0
- package/common/workflow/wftest_1789477074699/suggest_h.json +14 -0
- package/common/workflow/wftest_1789478655100/ok_wf.json +20 -0
- package/common/workflow/wftest_1789478655100/suggest_h.json +14 -0
- package/common/workflow/wftest_1789499010987/ok_wf.json +20 -0
- package/common/workflow/wftest_1789499010987/suggest_h.json +14 -0
- package/common/workflow/wftest_1789519488954/ok_wf.json +20 -0
- package/common/workflow/wftest_1789519488954/suggest_h.json +14 -0
- package/docs/API/345/217/202/350/200/203.md +146 -0
- package/docs/Blockly/346/230/240/345/260/204/346/226/271/346/241/210.md +213 -0
- package/docs/LLM/351/233/206/346/210/220/346/214/207/345/215/227.md +29 -0
- package/docs/Workflow/347/274/226/345/206/231/346/214/207/345/215/227.md +194 -0
- package/docs/ctx/344/270/212/344/270/213/346/226/207/350/257/246/350/247/243.md +256 -0
- package/docs//344/272/214/346/254/241/345/274/200/345/217/221/346/214/207/345/215/227.md +151 -0
- package/docs//345/244/232/345/215/217/350/256/256/350/247/246/345/217/221/346/214/207/345/215/227.md +272 -0
- package/docs//345/256/236/346/210/230/346/241/210/344/276/213.md +392 -0
- package/docs//345/267/245/344/275/234/346/265/201/350/246/206/347/233/226/345/210/206/346/236/220.md +585 -0
- package/docs//345/274/200/345/217/221/346/226/207/346/241/243.md +200 -0
- package/docs//345/277/253/351/200/237/345/274/200/345/247/213.md +66 -0
- package/docs//346/234/200/344/275/263/345/256/236/350/267/265.md +265 -0
- package/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +29 -0
- package/docs//346/240/270/345/277/203/346/246/202/345/277/265.md +194 -0
- package/docs//346/250/241/345/235/227/344/275/223/347/263/273/350/257/264/346/230/216.md +111 -0
- package/docs//346/250/241/345/235/227/346/270/205/345/215/225.md +288 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/AI/345/267/245/344/275/234/346/265/201/347/224/237/346/210/220/346/210/220/346/234/254/345/210/206/346/236/220.md +234 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/CM/345/207/275/346/225/260/345/244/247/345/205/250.md +93 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/RPG_Maker_/344/272/213/344/273/266/350/204/232/346/234/254/345/257/271/346/257/224/345/210/206/346/236/220.md +734 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/270/211/345/233/275/346/235/200/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +379 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/277/256/344/273/231/345/206/263/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +256 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/277/256/344/273/231/347/211/210/345/215/241/347/211/214/346/270/270/346/210/217.md +355 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/206/222/351/231/251/345/262/233CM/345/207/275/346/225/260/345/210/206/346/236/220.md +81 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/206/222/351/231/251/345/262/233NPC/350/204/232/346/234/254/346/224/257/346/214/201/345/210/206/346/236/220.md +365 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/244/247/351/203/250/345/210/206/351/200/232/347/224/250/346/250/241/345/235/227/345/210/206/346/236/220.md +33 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/260/217/345/225/206/345/272/227/351/234/200/346/261/202/350/247/204/346/240/274.md +577 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/250/241/346/213/237/344/272/272/347/224/237/346/201/213/347/210/261/345/205/273/346/210/220RPG/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +314 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/255/243/345/274/217/345/217/257/347/224/250/345/267/256/350/267/235/345/210/206/346/236/220.md +463 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/270/270/346/210/217/347/216/213/345/215/241/347/211/214/346/270/270/346/210/217/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +673 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//350/264/252/345/251/252/344/271/213/345/262/233/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +405 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//350/264/252/345/251/252/344/271/213/345/262/233/347/262/276/347/256/200/347/211/210/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +289 -0
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//351/207/215/350/243/205/346/234/272/345/205/265/346/226/207/345/255/227/347/211/210/346/270/270/346/210/217.md +417 -0
- package/docs//350/260/203/350/257/225/344/270/216/346/216/222/351/224/231.md +255 -0
- package/example/common/mod/executor/effect/executor.json +58 -0
- package/example/common/mod/executor/effect/index.js +93 -0
- package/example/common/mod/executor/warp/executor.json +57 -0
- package/example/common/mod/executor/warp/index.js +73 -0
- package/example/common/mod/manager/inventory/index.js +205 -0
- package/example/common/mod/manager/inventory/manager.json +70 -0
- package/example/common/mod/manager/persistence/index.js +176 -0
- package/example/common/mod/manager/persistence/manager.json +67 -0
- package/example/common/mod/manager/player/index.js +187 -0
- package/example/common/mod/manager/player/manager.json +102 -0
- package/example/common/mod/manager/quest/index.js +196 -0
- package/example/common/mod/manager/quest/manager.json +50 -0
- package/example/common/mod/manager/shop/index.js +66 -0
- package/example/common/mod/manager/shop/manager.json +44 -0
- package/example/common/mod/manager/skill/index.js +143 -0
- package/example/common/mod/manager/skill/manager.json +82 -0
- package/example/common/script/demo/index.js +16 -0
- package/example/common/script/demo/script.json +21 -0
- package/example/common/workflow/admin/dashboard.json +87 -0
- package/example/common/workflow/admin/order_deliver.json +99 -0
- package/example/common/workflow/admin/order_list.json +79 -0
- package/example/common/workflow/admin/product_off.json +85 -0
- package/example/common/workflow/admin/product_on.json +85 -0
- package/example/common/workflow/admin/user_list.json +68 -0
- package/example/common/workflow/cart/add.json +86 -0
- package/example/common/workflow/cart/checkout.json +120 -0
- package/example/common/workflow/cart/del.json +47 -0
- package/example/common/workflow/cart/list.json +55 -0
- package/example/common/workflow/cart/set.json +106 -0
- package/example/common/workflow/db/create_table.json +57 -0
- package/example/common/workflow/db/mysql_query.json +47 -0
- package/example/common/workflow/db/sqlite_crud.json +48 -0
- package/example/common/workflow/npc/blacksmith.json +91 -0
- package/example/common/workflow/npc/quest_giver.json +136 -0
- package/example/common/workflow/order/create.json +76 -0
- package/example/common/workflow/order/create_bpmn.json +105 -0
- package/example/common/workflow/order/history.json +69 -0
- package/example/common/workflow/payment/process.json +74 -0
- package/example/common/workflow/product/add.json +72 -0
- package/example/common/workflow/product/categories.json +41 -0
- package/example/common/workflow/product/count.json +65 -0
- package/example/common/workflow/product/del.json +84 -0
- package/example/common/workflow/product/get.json +59 -0
- package/example/common/workflow/product/list.json +80 -0
- package/example/common/workflow/product/search.json +59 -0
- package/example/common/workflow/product/set.json +87 -0
- package/example/common/workflow/shop/create.json +70 -0
- package/example/common/workflow/shop/del.json +84 -0
- package/example/common/workflow/shop/get.json +43 -0
- package/example/common/workflow/shop/list.json +80 -0
- package/example/common/workflow/shop/products.json +69 -0
- package/example/common/workflow/shop/set.json +64 -0
- package/example/common/workflow/system/monitor.json +62 -0
- package/example/common/workflow/user/address_add.json +49 -0
- package/example/common/workflow/user/address_list.json +44 -0
- package/example/common/workflow/user/change_password.json +87 -0
- package/example/common/workflow/user/login.json +83 -0
- package/example/common/workflow/user/profile.json +71 -0
- package/example/common/workflow/user/register.json +77 -0
- package/example/config +122 -0
- package/example/config.json +94 -0
- package/example/data/model/bag.json +28 -0
- package/example/data/model/character.json +38 -0
- package/example/data/model/quest.json +14 -0
- package/example/data/model/save.json +10 -0
- package/example/data/model/shop.json +14 -0
- package/example/data/model/skill.json +28 -0
- package/example/data/test.js +376 -0
- package/example/db/mm.db +0 -0
- package/example/db/mm.db-shm +0 -0
- package/example/db/mm.db-wal +0 -0
- package/example/db/sql/ecommerce.sql +84 -0
- package/example/db/sql/game.sql +72 -0
- package/example/ecom_out.txt +0 -0
- package/example/ecommerce.js +450 -0
- package/example/index.js +262 -0
- package/example/npc_demo.js +361 -0
- package/index.js +176 -7
- package/kernel/blockly_converter.js +905 -0
- package/kernel/blockly_defs.js +324 -0
- package/kernel/bpmn_engine.js +100 -0
- package/kernel/bpmn_mapper.js +535 -0
- package/kernel/bpmn_parser.js +306 -0
- package/kernel/kernel.js +490 -0
- package/kernel/kernel_catalog.js +312 -0
- package/kernel/kernel_config.js +100 -0
- package/kernel/kernel_graph.js +583 -0
- package/kernel/kernel_validator.js +460 -0
- package/kernel/limiter.js +71 -0
- package/kernel/metrics.js +59 -0
- package/kernel/protocol_adapter.js +40 -0
- package/kernel/require_util.js +152 -0
- package/kernel/workflow_engine.js +1398 -0
- package/kernel/workflow_loader.js +165 -0
- package/kernel/workflow_normalizer.js +31 -0
- package/kernel/workflow_state.js +243 -0
- package/llm.js +257 -0
- package/package.json +27 -14
- package/runtime.js +163 -0
- package/scan_modules.js +124 -0
- package/scripts/add_type_field.js +153 -0
- package/scripts/create_project.js +276 -0
- package/scripts/generate_mod.js +229 -0
- package/templates/db/backup_table.json +52 -0
- package/templates/db/create_table.json +68 -0
- package/templates/db/crud_sqlite.json +98 -0
- package/templates/db/db_sqlite.json +52 -0
- package/templates/db/ecommerce.sql +87 -0
- package/templates/db/export_table.json +51 -0
- package/templates/demo/hello.json +47 -0
- package/templates/demo/http_demo.json +48 -0
- package/templates/demo/llm_chat.json +44 -0
- package/templates/demo/render_demo.json +46 -0
- package/templates/demo/validator_demo.json +64 -0
- package/templates/order/create.json +113 -0
- package/templates/user_account/add.json +92 -0
- package/templates/user_account/count.json +24 -0
- package/templates/user_account/del.json +38 -0
- package/templates/user_account/get.json +48 -0
- package/templates/user_account/init.json +76 -0
- package/templates/user_account/list.json +48 -0
- package/templates/user_account/set.json +65 -0
- package/templates/user_account/user_account.sql +21 -0
- package/test.js +213 -0
- package/README.en.md +0 -36
- package/demo/index.js +0 -38
- package/demo/test_data.json +0 -32
- package/lib/compiler.js +0 -259
- package/lib/editor.js +0 -66
- package/lib/engine.js +0 -217
- package/lib/javascript.js +0 -29
- package/lib/python.js +0 -30
- package/lib/workflow.js +0 -9
- package/lib/workflow.json +0 -421
- package/test_function_call.js +0 -40
- package/test_var_extraction.js +0 -11
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 代码格式验证器
|
|
3
|
+
* 验证代码语法和格式规范,返回问题列表
|
|
4
|
+
* @param {object} ctx 上下文对象
|
|
5
|
+
* @param {object} params 步骤参数
|
|
6
|
+
*/
|
|
7
|
+
async function main(params, ctx, options) {
|
|
8
|
+
var code = params.code || '';
|
|
9
|
+
var language = params.language || 'javascript';
|
|
10
|
+
var rules =
|
|
11
|
+
params.rules ||
|
|
12
|
+
[
|
|
13
|
+
'naming',
|
|
14
|
+
'semicolon',
|
|
15
|
+
'jsdoc',
|
|
16
|
+
'boolean_name',
|
|
17
|
+
'long_function',
|
|
18
|
+
'event_handler',
|
|
19
|
+
'try_catch',
|
|
20
|
+
'tab_indent',
|
|
21
|
+
'double_quote',
|
|
22
|
+
'var_decl',
|
|
23
|
+
'line_length'
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
if (!code) {
|
|
27
|
+
ctx.output = {
|
|
28
|
+
error: { code: 'VAL_CODE_PARAM', message: '缺少代码内容(code)' }
|
|
29
|
+
};
|
|
30
|
+
return ctx.output;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var errors = [];
|
|
34
|
+
var lines = code.split(/\r?\n/);
|
|
35
|
+
|
|
36
|
+
// 语法检查
|
|
37
|
+
if (language === 'javascript' || language === 'js') {
|
|
38
|
+
try {
|
|
39
|
+
new Function(code);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
errors.push({
|
|
42
|
+
rule: 'syntax',
|
|
43
|
+
severity: 'error',
|
|
44
|
+
line: 0,
|
|
45
|
+
message: '语法错误: ' + e.message
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 检查 Tab 缩进
|
|
51
|
+
if (rules.indexOf('tab_indent') !== -1) {
|
|
52
|
+
for (var i = 0; i < lines.length; i++) {
|
|
53
|
+
if (lines[i].indexOf('\t') !== -1) {
|
|
54
|
+
errors.push({
|
|
55
|
+
rule: 'tab_indent',
|
|
56
|
+
severity: 'warning',
|
|
57
|
+
line: i + 1,
|
|
58
|
+
message: '使用了 Tab 缩进,应使用 2 个空格'
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 检查双引号字符串
|
|
65
|
+
if (rules.indexOf('double_quote') !== -1) {
|
|
66
|
+
var dq_re = /"([^"\\\n]|\\.)*"/g;
|
|
67
|
+
var dq_match;
|
|
68
|
+
while ((dq_match = dq_re.exec(code)) !== null) {
|
|
69
|
+
errors.push({
|
|
70
|
+
rule: 'double_quote',
|
|
71
|
+
severity: 'warning',
|
|
72
|
+
line: _findLine(lines, dq_match.index),
|
|
73
|
+
message: '使用了双引号字符串,应使用单引号'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 检查 var 声明
|
|
79
|
+
if (rules.indexOf('var_decl') !== -1) {
|
|
80
|
+
var var_re = /\bvar\s+[a-zA-Z_$]/g;
|
|
81
|
+
var var_match;
|
|
82
|
+
while ((var_match = var_re.exec(code)) !== null) {
|
|
83
|
+
errors.push({
|
|
84
|
+
rule: 'var_decl',
|
|
85
|
+
severity: 'warning',
|
|
86
|
+
line: _findLine(lines, var_match.index),
|
|
87
|
+
message: '使用了 var 声明,应使用 let 或 const'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 检查命名规范
|
|
93
|
+
if (rules.indexOf('naming') !== -1) {
|
|
94
|
+
_checkNaming(code, lines, errors);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 检查分号
|
|
98
|
+
if (rules.indexOf('semicolon') !== -1) {
|
|
99
|
+
_checkSemicolon(lines, errors);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 检查 JSDoc 注释
|
|
103
|
+
if (rules.indexOf('jsdoc') !== -1) {
|
|
104
|
+
_checkJsdoc(lines, errors);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 检查布尔变量命名
|
|
108
|
+
if (rules.indexOf('boolean_name') !== -1) {
|
|
109
|
+
_checkBooleanName(code, lines, errors);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 检查函数长度
|
|
113
|
+
if (rules.indexOf('long_function') !== -1) {
|
|
114
|
+
_checkLongFunction(lines, errors);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 检查事件处理函数命名
|
|
118
|
+
if (rules.indexOf('event_handler') !== -1) {
|
|
119
|
+
_checkEventHandler(code, lines, errors);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 检查错误处理
|
|
123
|
+
if (rules.indexOf('try_catch') !== -1) {
|
|
124
|
+
_checkTryCatch(lines, errors);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 检查行长度
|
|
128
|
+
if (rules.indexOf('line_length') !== -1) {
|
|
129
|
+
for (var j = 0; j < lines.length; j++) {
|
|
130
|
+
if (lines[j].length > 120) {
|
|
131
|
+
errors.push({
|
|
132
|
+
rule: 'line_length',
|
|
133
|
+
severity: 'warning',
|
|
134
|
+
line: j + 1,
|
|
135
|
+
message: '行长度超过 120 个字符'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var valid = errors.length === 0;
|
|
142
|
+
ctx.output = {
|
|
143
|
+
valid: valid,
|
|
144
|
+
tip: valid ? '代码验证通过' : '发现 ' + errors.length + ' 个问题',
|
|
145
|
+
detail: _stringifyErrors(errors),
|
|
146
|
+
errors: errors,
|
|
147
|
+
error_count: errors.length,
|
|
148
|
+
line_count: lines.length
|
|
149
|
+
};
|
|
150
|
+
return ctx.output;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 将问题列表字符串化,供 LLM 精准修复时反馈
|
|
155
|
+
* @param {Array} errors 问题列表
|
|
156
|
+
* @returns {string} 字符串化的问题详情,无问题时返回空字符串
|
|
157
|
+
*/
|
|
158
|
+
function _stringifyErrors(errors) {
|
|
159
|
+
if (!errors || errors.length === 0) return '';
|
|
160
|
+
var list = [];
|
|
161
|
+
for (var i = 0; i < errors.length; i++) {
|
|
162
|
+
var e = errors[i];
|
|
163
|
+
var loc = e.line > 0 ? '第' + e.line + '行 ' : '';
|
|
164
|
+
list.push(loc + '[' + e.rule + '] ' + e.message);
|
|
165
|
+
}
|
|
166
|
+
return list.join('\n');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 检查命名规范
|
|
171
|
+
* @param {string} code 代码内容
|
|
172
|
+
* @param {Array} lines 行数组
|
|
173
|
+
* @param {Array} errors 问题列表
|
|
174
|
+
*/
|
|
175
|
+
function _checkNaming(code, lines, errors) {
|
|
176
|
+
// 函数名:小驼峰(检测蛇形或大写开头)
|
|
177
|
+
var fn_re = /(?:async\s+)?function\s+([a-zA-Z_$][\w$]*)\s*\(/g;
|
|
178
|
+
var fn_match;
|
|
179
|
+
while ((fn_match = fn_re.exec(code)) !== null) {
|
|
180
|
+
var fn_name = fn_match[1];
|
|
181
|
+
if (fn_name.indexOf('_') !== -1 || /^[A-Z]/.test(fn_name)) {
|
|
182
|
+
errors.push({
|
|
183
|
+
rule: 'naming',
|
|
184
|
+
severity: 'warning',
|
|
185
|
+
line: _findLine(lines, fn_match.index),
|
|
186
|
+
message: '函数名 "' + fn_name + '" 应使用小驼峰命名'
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 变量名:小写蛇形(检测含大写字母)
|
|
192
|
+
var lv_re = /\b(?:let|var)\s+([a-zA-Z_$][\w$]*)\s*=/g;
|
|
193
|
+
var lv_match;
|
|
194
|
+
while ((lv_match = lv_re.exec(code)) !== null) {
|
|
195
|
+
var lv_name = lv_match[1];
|
|
196
|
+
if (/[A-Z]/.test(lv_name)) {
|
|
197
|
+
errors.push({
|
|
198
|
+
rule: 'naming',
|
|
199
|
+
severity: 'warning',
|
|
200
|
+
line: _findLine(lines, lv_match.index),
|
|
201
|
+
message: '变量名 "' + lv_name + '" 应使用小写蛇形命名'
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 类名:大驼峰(检测小写开头或蛇形)
|
|
207
|
+
var cls_re = /class\s+([a-zA-Z_$][\w$]*)/g;
|
|
208
|
+
var cls_match;
|
|
209
|
+
while ((cls_match = cls_re.exec(code)) !== null) {
|
|
210
|
+
var cls_name = cls_match[1];
|
|
211
|
+
if (/^[a-z]/.test(cls_name) || cls_name.indexOf('_') !== -1) {
|
|
212
|
+
errors.push({
|
|
213
|
+
rule: 'naming',
|
|
214
|
+
severity: 'warning',
|
|
215
|
+
line: _findLine(lines, cls_match.index),
|
|
216
|
+
message: '类名 "' + cls_name + '" 应使用大驼峰命名'
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 常量名:大写蛇形(检测 const 小写开头且赋值为基本字面量)
|
|
222
|
+
var const_re = /const\s+([a-z][\w$]*)\s*=\s*(?:"[^"]*"|'[^']*'|\d+\.?\d*|true|false|null)\b/g;
|
|
223
|
+
var const_match;
|
|
224
|
+
while ((const_match = const_re.exec(code)) !== null) {
|
|
225
|
+
var const_name = const_match[1];
|
|
226
|
+
errors.push({
|
|
227
|
+
rule: 'naming',
|
|
228
|
+
severity: 'warning',
|
|
229
|
+
line: _findLine(lines, const_match.index),
|
|
230
|
+
message: '常量名 "' + const_name + '" 应使用大写蛇形命名'
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 检查分号
|
|
237
|
+
* @param {Array} lines 行数组
|
|
238
|
+
* @param {Array} errors 问题列表
|
|
239
|
+
*/
|
|
240
|
+
function _checkSemicolon(lines, errors) {
|
|
241
|
+
var cont_re = /[\(\)\,\[\]\.\:\+\-\*\/\=\<\>\!\?\&\|\}]$/;
|
|
242
|
+
var stmt_re = /^(let|const|var)\s+[a-zA-Z_$][\w$]*\s*=|^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*\s*[=(]/;
|
|
243
|
+
|
|
244
|
+
for (var i = 0; i < lines.length; i++) {
|
|
245
|
+
var line = lines[i].trim();
|
|
246
|
+
if (!line) continue;
|
|
247
|
+
if (line.startsWith('//') || line.startsWith('/*') || line.startsWith('*')) continue;
|
|
248
|
+
if (line.endsWith(';') || line.endsWith('{') || line.endsWith('}')) continue;
|
|
249
|
+
if (cont_re.test(line)) continue;
|
|
250
|
+
|
|
251
|
+
if (stmt_re.test(line) || /^return\s+\S/.test(line) || /^throw\s+\S/.test(line)) {
|
|
252
|
+
errors.push({
|
|
253
|
+
rule: 'semicolon',
|
|
254
|
+
severity: 'warning',
|
|
255
|
+
line: i + 1,
|
|
256
|
+
message: '语句末尾缺少分号'
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 检查 JSDoc 注释
|
|
264
|
+
* @param {Array} lines 行数组
|
|
265
|
+
* @param {Array} errors 问题列表
|
|
266
|
+
*/
|
|
267
|
+
function _checkJsdoc(lines, errors) {
|
|
268
|
+
var fn_re = /(?:async\s+)?function\s+[a-zA-Z_$][\w$]*\s*\(/;
|
|
269
|
+
for (var i = 0; i < lines.length; i++) {
|
|
270
|
+
var line = lines[i].trim();
|
|
271
|
+
if (!fn_re.test(line)) continue;
|
|
272
|
+
|
|
273
|
+
var has_jsdoc = false;
|
|
274
|
+
for (var j = i - 1; j >= 0; j--) {
|
|
275
|
+
var prev = lines[j].trim();
|
|
276
|
+
if (!prev) continue;
|
|
277
|
+
if (prev.startsWith('/**')) {
|
|
278
|
+
has_jsdoc = true;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
if (prev.startsWith('*')) continue;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (!has_jsdoc) {
|
|
286
|
+
errors.push({
|
|
287
|
+
rule: 'jsdoc',
|
|
288
|
+
severity: 'warning',
|
|
289
|
+
line: i + 1,
|
|
290
|
+
message: '函数缺少 JSDoc 注释'
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 检查布尔变量命名
|
|
298
|
+
* @param {string} code 代码内容
|
|
299
|
+
* @param {Array} lines 行数组
|
|
300
|
+
* @param {Array} errors 问题列表
|
|
301
|
+
*/
|
|
302
|
+
function _checkBooleanName(code, lines, errors) {
|
|
303
|
+
var bool_re = /\b(?:let|const|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:true|false)\b/g;
|
|
304
|
+
var bool_match;
|
|
305
|
+
while ((bool_match = bool_re.exec(code)) !== null) {
|
|
306
|
+
var bool_name = bool_match[1];
|
|
307
|
+
if (!/^(is|has|can)([A-Z_]|$)/.test(bool_name)) {
|
|
308
|
+
errors.push({
|
|
309
|
+
rule: 'boolean_name',
|
|
310
|
+
severity: 'warning',
|
|
311
|
+
line: _findLine(lines, bool_match.index),
|
|
312
|
+
message: '布尔变量名 "' + bool_name + '" 应以 is/has/can 开头'
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 检查函数长度
|
|
320
|
+
* @param {Array} lines 行数组
|
|
321
|
+
* @param {Array} errors 问题列表
|
|
322
|
+
*/
|
|
323
|
+
function _checkLongFunction(lines, errors) {
|
|
324
|
+
var fn_re = /(?:async\s+)?function\s+[a-zA-Z_$][\w$]*\s*\([^)]*\)\s*\{/;
|
|
325
|
+
for (var i = 0; i < lines.length; i++) {
|
|
326
|
+
var line = lines[i].trim();
|
|
327
|
+
if (!fn_re.test(line)) continue;
|
|
328
|
+
|
|
329
|
+
var depth = _countBraces(line);
|
|
330
|
+
var end_idx = i;
|
|
331
|
+
if (depth > 0) {
|
|
332
|
+
for (var j = i + 1; j < lines.length; j++) {
|
|
333
|
+
depth += _countBraces(lines[j]);
|
|
334
|
+
end_idx = j;
|
|
335
|
+
if (depth <= 0) break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
var fn_lines = end_idx - i + 1;
|
|
340
|
+
if (fn_lines > 50) {
|
|
341
|
+
errors.push({
|
|
342
|
+
rule: 'long_function',
|
|
343
|
+
severity: 'warning',
|
|
344
|
+
line: i + 1,
|
|
345
|
+
message: '函数体 ' + fn_lines + ' 行,超过 50 行限制'
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 检查事件处理函数命名
|
|
353
|
+
* @param {string} code 代码内容
|
|
354
|
+
* @param {Array} lines 行数组
|
|
355
|
+
* @param {Array} errors 问题列表
|
|
356
|
+
*/
|
|
357
|
+
function _checkEventHandler(code, lines, errors) {
|
|
358
|
+
var add_re = /addEventListener\s*\(\s*['"][^'"]*['"]\s*,\s*([a-zA-Z_$][\w$]*)/g;
|
|
359
|
+
var add_match;
|
|
360
|
+
while ((add_match = add_re.exec(code)) !== null) {
|
|
361
|
+
_checkHandlerName(add_match[1], add_match.index, lines, errors);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
var on_re = /\.on[a-zA-Z]+\s*=\s*([a-zA-Z_$][\w$]*)/g;
|
|
365
|
+
var on_match;
|
|
366
|
+
while ((on_match = on_re.exec(code)) !== null) {
|
|
367
|
+
_checkHandlerName(on_match[1], on_match.index, lines, errors);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* 检查单个事件处理函数名是否以 handle 开头
|
|
373
|
+
* @param {string} handler 处理函数名
|
|
374
|
+
* @param {number} offset 字符偏移
|
|
375
|
+
* @param {Array} lines 行数组
|
|
376
|
+
* @param {Array} errors 问题列表
|
|
377
|
+
*/
|
|
378
|
+
function _checkHandlerName(handler, offset, lines, errors) {
|
|
379
|
+
if (handler === 'function' || handler === 'async') return;
|
|
380
|
+
if (!/^handle/.test(handler)) {
|
|
381
|
+
errors.push({
|
|
382
|
+
rule: 'event_handler',
|
|
383
|
+
severity: 'warning',
|
|
384
|
+
line: _findLine(lines, offset),
|
|
385
|
+
message: '事件处理函数 "' + handler + '" 应以 handle 开头'
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* 检查错误处理
|
|
392
|
+
* @param {Array} lines 行数组
|
|
393
|
+
* @param {Array} errors 问题列表
|
|
394
|
+
*/
|
|
395
|
+
function _checkTryCatch(lines, errors) {
|
|
396
|
+
var await_re = /await\s+(?:fetch|axios)/;
|
|
397
|
+
for (var i = 0; i < lines.length; i++) {
|
|
398
|
+
var line = lines[i].trim();
|
|
399
|
+
if (!await_re.test(line)) continue;
|
|
400
|
+
|
|
401
|
+
var in_try = false;
|
|
402
|
+
for (var j = i - 1; j >= 0; j--) {
|
|
403
|
+
var prev = lines[j].trim();
|
|
404
|
+
if (!prev || prev.startsWith('//')) continue;
|
|
405
|
+
if (prev.endsWith('{')) {
|
|
406
|
+
if (prev.startsWith('try')) in_try = true;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
if (prev.endsWith('}')) break;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (!in_try) {
|
|
413
|
+
errors.push({
|
|
414
|
+
rule: 'try_catch',
|
|
415
|
+
severity: 'warning',
|
|
416
|
+
line: i + 1,
|
|
417
|
+
message: '异步 API 调用未使用 try...catch 包裹'
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* 计算一行中大括号的净增量,跳过字符串内容
|
|
425
|
+
* @param {string} line 行内容
|
|
426
|
+
* @returns {number} 大括号净增量
|
|
427
|
+
*/
|
|
428
|
+
function _countBraces(line) {
|
|
429
|
+
var depth = 0;
|
|
430
|
+
var in_str = null;
|
|
431
|
+
for (var i = 0; i < line.length; i++) {
|
|
432
|
+
var ch = line[i];
|
|
433
|
+
if (in_str) {
|
|
434
|
+
if (ch === in_str && line[i - 1] !== '\\') in_str = null;
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (ch === "'" || ch === '"' || ch === '`') {
|
|
438
|
+
in_str = ch;
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (ch === '{') depth++;
|
|
442
|
+
else if (ch === '}') depth--;
|
|
443
|
+
}
|
|
444
|
+
return depth;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 根据字符偏移计算所在行号
|
|
449
|
+
* @param {Array} lines 行数组
|
|
450
|
+
* @param {number} offset 字符偏移
|
|
451
|
+
* @returns {number} 行号(从1开始)
|
|
452
|
+
*/
|
|
453
|
+
function _findLine(lines, offset) {
|
|
454
|
+
var pos = 0;
|
|
455
|
+
for (var i = 0; i < lines.length; i++) {
|
|
456
|
+
pos += lines[i].length + 1;
|
|
457
|
+
if (pos > offset) return i + 1;
|
|
458
|
+
}
|
|
459
|
+
return 1;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
module.exports = { main };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "code",
|
|
3
|
+
"title": "代码格式验证器",
|
|
4
|
+
"description": "验证代码语法与格式规范,返回问题列表与修复详情。适用场景:LLM 生成代码后质量把关、提交前静态检查时。工作流提示:code 填待检代码、language 指定语言(默认 javascript)、rules 传检查规则(命名/语法/缩进/引号等),结果看 valid、errors、error_count。",
|
|
5
|
+
"type": "core",
|
|
6
|
+
"params": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"code": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "待验证的代码内容"
|
|
12
|
+
},
|
|
13
|
+
"language": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "编程语言,默认 javascript"
|
|
16
|
+
},
|
|
17
|
+
"rules": {
|
|
18
|
+
"type": "array",
|
|
19
|
+
"description": "检查规则列表: naming/semicolon/jsdoc/boolean_name/long_function/event_handler/try_catch/tab_indent/double_quote/var_decl/line_length"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": [
|
|
23
|
+
"code"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"returns": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"description": "验证结果,正常时包含 valid/tip/errors/error_count/line_count,异常时包含 error",
|
|
29
|
+
"properties": {
|
|
30
|
+
"valid": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"description": "是否通过验证"
|
|
33
|
+
},
|
|
34
|
+
"tip": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "验证提示信息"
|
|
37
|
+
},
|
|
38
|
+
"errors": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"description": "发现的问题列表"
|
|
41
|
+
},
|
|
42
|
+
"error_count": {
|
|
43
|
+
"type": "number",
|
|
44
|
+
"description": "问题数量"
|
|
45
|
+
},
|
|
46
|
+
"line_count": {
|
|
47
|
+
"type": "number",
|
|
48
|
+
"description": "代码行数"
|
|
49
|
+
},
|
|
50
|
+
"error": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"description": "错误信息,仅调用出错时返回",
|
|
53
|
+
"properties": {
|
|
54
|
+
"code": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "错误码"
|
|
57
|
+
},
|
|
58
|
+
"message": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "错误描述"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"options": {},
|
|
67
|
+
"group": "code"
|
|
68
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 枚举验证器
|
|
3
|
+
* 验证值是否在允许的枚举列表中
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
async function main(params, ctx, options) {
|
|
7
|
+
var errors = [];
|
|
8
|
+
var value = params.value;
|
|
9
|
+
var options = params.options || [];
|
|
10
|
+
|
|
11
|
+
if (!Array.isArray(options)) {
|
|
12
|
+
errors.push('options 必须是数组');
|
|
13
|
+
} else if (options.indexOf(value) === -1) {
|
|
14
|
+
errors.push(params.field + ' 的值不在允许范围内: ' + options.join(', '));
|
|
15
|
+
}
|
|
16
|
+
var valid = errors.length === 0;
|
|
17
|
+
var tip = valid ? '参数校验通过' : errors.length + '个参数校验失败: ' + errors.join('; ');
|
|
18
|
+
ctx.output = { valid: valid, tip: tip, errors: errors, allowed_values: options };
|
|
19
|
+
return ctx.output;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { main };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "enum",
|
|
3
|
+
"title": "枚举验证器",
|
|
4
|
+
"description": "校验字段值是否属于指定枚举集合。适用场景:状态机取值校验、白名单检查、选项合法性判断时。工作流提示:field 填字段名、value 填待校验值、options 填允许的枚举数组,结果看 valid(boolean) 与 errors,通过时返回 allowed_values 枚举列表。",
|
|
5
|
+
"type": "core",
|
|
6
|
+
"params": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"field": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "字段名称"
|
|
12
|
+
},
|
|
13
|
+
"value": {
|
|
14
|
+
"description": "待验证的值"
|
|
15
|
+
},
|
|
16
|
+
"options": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"description": "允许的枚举列表"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": [
|
|
22
|
+
"field",
|
|
23
|
+
"value",
|
|
24
|
+
"options"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"returns": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"valid": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"description": "验证是否通过"
|
|
33
|
+
},
|
|
34
|
+
"tip": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
37
|
+
},
|
|
38
|
+
"errors": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"description": "错误信息列表"
|
|
41
|
+
},
|
|
42
|
+
"allowed_values": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"description": "允许的枚举值列表"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"options": {},
|
|
49
|
+
"group": "check"
|
|
50
|
+
}
|