@ohos-cpf/3rdloop 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +425 -0
- package/bin/3rdloop.mjs +48 -0
- package/lib/cli.js +741 -0
- package/lib/config.js +318 -0
- package/lib/doctor.js +114 -0
- package/lib/exit-codes.js +31 -0
- package/lib/opencode.js +156 -0
- package/lib/orch.js +427 -0
- package/lib/queries.js +264 -0
- package/lib/runner.js +979 -0
- package/lib/step.js +326 -0
- package/lib/ui.js +223 -0
- package/lib/workflow.js +291 -0
- package/lib/workflows.js +132 -0
- package/package.json +50 -0
- package/vendor/Server/Agent/SkillSelector/README.md +344 -0
- package/vendor/Server/Agent/SkillSelector/core/Agent.js +207 -0
- package/vendor/Server/Agent/SkillSelector/index.js +14 -0
- package/vendor/Server/Agent/SkillSelector/llm/llmClient.js +313 -0
- package/vendor/Server/Agent/SkillSelector/llm/prompts.js +161 -0
- package/vendor/Server/Agent/SkillSelector/llm/reactSteps.js +144 -0
- package/vendor/Server/Agent/SkillSelector/matcher/fuzzyMatcher.js +433 -0
- package/vendor/Server/Agent/SkillSelector/scanner/skillScanner.js +382 -0
- package/vendor/Server/Agent/SkillSelector/types.js +63 -0
- package/vendor/Server/Agent/SkillSelector/utils/actionWords.js +60 -0
- package/vendor/Server/Brain/AnalysisStrategies.js +422 -0
- package/vendor/Server/Brain/Brain.js +686 -0
- package/vendor/Server/Brain/DecompositionStrategies.js +621 -0
- package/vendor/Server/Brain/PlanPersistence.js +196 -0
- package/vendor/Server/Brain/SkillExecutor.js +251 -0
- package/vendor/Server/Brain/index.js +11 -0
- package/vendor/Server/CLI/cli.js +243 -0
- package/vendor/Server/CLI/opencode/index.js +804 -0
- package/vendor/Server/CLI/opencode.js +5 -0
- package/vendor/Server/DbUse/MessageArchive.js +61 -0
- package/vendor/Server/DbUse/StorageManager.js +107 -0
- package/vendor/Server/DbUse/adapters/BaseAdapter.js +94 -0
- package/vendor/Server/DbUse/adapters/FileAdapter.js +138 -0
- package/vendor/Server/DbUse/adapters/JsonAdapter.js +138 -0
- package/vendor/Server/DbUse/adapters/JsonlAdapter.js +114 -0
- package/vendor/Server/DbUse/adapters/SqliteAdapter.js +157 -0
- package/vendor/Server/DbUse/index.js +160 -0
- package/vendor/Server/DbUse/stores/SessionStore.js +279 -0
- package/vendor/Server/DbUse/stores/TaskExecutionStore.js +133 -0
- package/vendor/Server/DbUse/stores/TaskRegistryStore.js +262 -0
- package/vendor/Server/DbUse/stores/TaskStepStore.js +279 -0
- package/vendor/Server/FlexRunner/FlexRunner.js +1759 -0
- package/vendor/Server/FlexRunner/index.js +12 -0
- package/vendor/Server/Knowledge/KnowledgeImporter.js +523 -0
- package/vendor/Server/Knowledge/KnowledgeManager.js +341 -0
- package/vendor/Server/Knowledge/index.js +33 -0
- package/vendor/Server/LoopEngine/LoopEngine.js +1133 -0
- package/vendor/Server/LoopEngine/index.js +11 -0
- package/vendor/Server/Orchestrator/Orchestrator.js +1425 -0
- package/vendor/Server/Orchestrator/StepNode.js +312 -0
- package/vendor/Server/Orchestrator/index.js +13 -0
- package/vendor/Server/Routes/controllers/BrainController.js +241 -0
- package/vendor/Server/Routes/controllers/FlexRunnerController.js +1125 -0
- package/vendor/Server/Routes/controllers/HealthController.js +44 -0
- package/vendor/Server/Routes/controllers/KnowledgeImportController.js +355 -0
- package/vendor/Server/Routes/controllers/LoopEngineController.js +788 -0
- package/vendor/Server/Routes/controllers/OrchestratorController.js +911 -0
- package/vendor/Server/Routes/controllers/StatsController.js +57 -0
- package/vendor/Server/Routes/controllers/StreamController.js +67 -0
- package/vendor/Server/Routes/library/logger.js +179 -0
- package/vendor/Server/Routes/library/zipArchive.js +172 -0
- package/vendor/Server/Routes/router/Router.js +204 -0
- package/vendor/Server/Routes/routes/brain.js +47 -0
- package/vendor/Server/Routes/routes/flexrunner.js +72 -0
- package/vendor/Server/Routes/routes/health.js +28 -0
- package/vendor/Server/Routes/routes/index.js +57 -0
- package/vendor/Server/Routes/routes/knowledge.js +55 -0
- package/vendor/Server/Routes/routes/loopengine.js +58 -0
- package/vendor/Server/Routes/routes/orchestrator.js +61 -0
- package/vendor/Server/Routes/routes/registry.js +98 -0
- package/vendor/Server/Routes/routes/stats.js +23 -0
- package/vendor/Server/Routes/routes/stream.js +30 -0
- package/vendor/Server/Routes/server.js +202 -0
- package/vendor/Server/Routes/sse/SseHub.js +308 -0
- package/vendor/Server/Skills/acceptance-check/SKILL.md +174 -0
- package/vendor/Server/Skills/acceptance-check/references/PHASE1_ARTIFACT_COLLECTION.md +52 -0
- package/vendor/Server/Skills/acceptance-check/references/PHASE2_CRITERIA_EVALUATION.md +77 -0
- package/vendor/Server/Skills/arkts-code-check/SKILL.md +314 -0
- package/vendor/Server/Skills/arkts-code-check/references/CODE_CHECK_GUIDE.md +160 -0
- package/vendor/Server/Skills/arkts-code-check/references/FILE_TYPE_GUIDE.md +29 -0
- package/vendor/Server/Skills/arkts-code-check/references/PHASE1_INFO_COLLECTION.md +222 -0
- package/vendor/Server/Skills/arkts-code-check/references/REPORT_TEMPLATE.md +220 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/SKILL.md +329 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/arkts-library-demo-code/SKILL.md +291 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/API_SIGNATURE_CHECKS.md +68 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/BUILD_VALIDATION.md +184 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/CODE_STANDARDS.md +337 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/EXAMPLES.md +400 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/SYSTEM_API_LOOKUP.md +99 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/TEMPLATE.md +544 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/arkts-library-demo-coverage/SKILL.md +174 -0
- package/vendor/Server/Skills/arkts-library-demo-scenario/SKILL.md +321 -0
- package/vendor/Server/Skills/arkts-library-demo-scenario/references/EXAMPLES.md +100 -0
- package/vendor/Server/Skills/arkts-library-demo-scenario/references/TEMPLATE.md +185 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/SKILL.md +234 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/assets/REPORT_TEMPLATE.md +103 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/CHECK_DIMENSIONS.md +89 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/COMPLIANCE_CHECKLIST.md +62 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/KB_QUERY_GUIDE.md +108 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/MCP_TOOL_DISCOVERY.md +124 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/REPORT_TEMPLATE.md +90 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/SCORING_FORMULA.md +57 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/scripts/validate-skill.cjs +259 -0
- package/vendor/Server/Skills/arkts-library-interface-spec/SKILL.md +97 -0
- package/vendor/Server/Skills/arkts-library-memory-leak-check/SKILL.md +392 -0
- package/vendor/Server/Skills/arkts-library-source-clone/SKILL.md +113 -0
- package/vendor/Server/Skills/arkts-library-stability-check/SKILL.md +313 -0
- package/vendor/Server/Skills/arkts-library-stability-check/assets/REPORT_TEMPLATE.md +154 -0
- package/vendor/Server/Skills/arkts-library-stability-check/references/CHECKLIST.md +166 -0
- package/vendor/Server/Skills/arkts-library-stability-check/references/CODE_EXAMPLES.md +309 -0
- package/vendor/Server/Skills/arkts-library-stability-check/references/SCORING_RULES.md +90 -0
- package/vendor/Server/Skills/arkts-library-stability-check/scripts/validate-skill.cjs +282 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/SKILL.md +361 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/assets/REPORT_TEMPLATE.md +146 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/CHECKLIST.md +253 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +115 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/scripts/validate-skill.cjs +263 -0
- package/vendor/Server/Skills/arkts-library-xts-code/SKILL.md +455 -0
- package/vendor/Server/Skills/arkts-library-xts-code/assets/report-template.md +60 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/ACCESS_MODIFIER_PRECHECK.md +76 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/BUILD_VERIFICATION.md +200 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/CODE_STANDARDS.md +519 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/SUBAGENT_PROMPT_TEMPLATE.md +276 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/SYSTEM_API_LOOKUP.md +93 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/XTS_TEMPLATE.md +767 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/precheck-access-modifiers.cjs +221 -0
- package/vendor/Server/Skills/arkts-library-xts-code-fix/SKILL.md +229 -0
- package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +97 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/SKILL.md +194 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/references/EXAMPLES.md +576 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/references/TEMPLATE.md +575 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/references/TESTABILITY_GUIDE.md +182 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/SKILL.md +491 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/references/error-fixing-examples.md +217 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/flutter-code-check/SKILL.md +299 -0
- package/vendor/Server/Skills/flutter-code-check/assets/OUTPUT_TEMPLATE.md +312 -0
- package/vendor/Server/Skills/flutter-code-check/references/CHECKLIST.md +190 -0
- package/vendor/Server/Skills/flutter-code-check/references/PLATFORMS.md +134 -0
- package/vendor/Server/Skills/flutter-code-check/scripts/validate-skill.cjs +259 -0
- package/vendor/Server/Skills/flutter-interface/README.md +75 -0
- package/vendor/Server/Skills/flutter-interface/SKILL.md +291 -0
- package/vendor/Server/Skills/flutter-interface/references/EXAMPLES.md +336 -0
- package/vendor/Server/Skills/flutter-interface/references/GIT_CLONE_GUIDE.md +190 -0
- package/vendor/Server/Skills/flutter-interface/references/SCRIPT_REFERENCE.md +258 -0
- package/vendor/Server/Skills/flutter-interface/references/TEMPLATE.md +254 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/SKILL.md +518 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/references/CHECKLIST.md +382 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/references/FUNCTION_COMPARISON_GUIDE.md +342 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/references/PLATFORM_LIMITATION_GUIDE.md +71 -0
- package/vendor/Server/Skills/flutter-library-documentation-quality-check/SKILL.md +519 -0
- package/vendor/Server/Skills/flutter-library-documentation-quality-check/references/CHECKLIST.md +407 -0
- package/vendor/Server/Skills/flutter-library-memory-leak-check/SKILL.md +653 -0
- package/vendor/Server/Skills/flutter-library-memory-leak-check/references/CHECKLIST.md +397 -0
- package/vendor/Server/Skills/flutter-library-stability-check/SKILL.md +745 -0
- package/vendor/Server/Skills/flutter-library-stability-check/references/CHECKLIST.md +721 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/SKILL.md +414 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/assets/REPORT_TEMPLATE.md +150 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/CHECKLIST.md +304 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/SCORING_RULES.md +265 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/SCRIPT_USAGE.md +286 -0
- package/vendor/Server/Skills/knowledge-import/SKILL.md +383 -0
- package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +165 -0
- package/vendor/Server/Skills/knowledge-import/references/SKILL_LOCATOR_GUIDE.md +91 -0
- package/vendor/Server/Skills/knowledge-import/references/SKILL_OPTIMIZATION_GUIDE.md +127 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +301 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/assets/PR_ISSUE_TEMPLATE.md +105 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/references/GITCODE_API.md +127 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/scripts/gitcode-api.cjs +208 -0
- package/vendor/Server/Skills/rn-code-check/SKILL.md +321 -0
- package/vendor/Server/Skills/rn-code-check/references/API-GUIDE.md +235 -0
- package/vendor/Server/Skills/rn-code-check/references/CHECKLIST.md +189 -0
- package/vendor/Server/Skills/rn-code-check/references/REPORT-TEMPLATE.md +247 -0
- package/vendor/Server/Skills/rn-lib-add-example/SKILL.md +198 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/APP_RENAME_GUIDE.md +40 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/SHELL_ADAPTATION_CHECKLIST.md +78 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/TEMPLATE_REPO_GUIDE.md +70 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/VERIFICATION_GUIDE.md +47 -0
- package/vendor/Server/Skills/rn-lib-add-example/scripts/create-example.cjs +252 -0
- package/vendor/Server/Skills/rn-lib-update-doc/SKILL.md +176 -0
- package/vendor/Server/Skills/rn-lib-update-doc/config.json +5 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/changelog-template.md +35 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/format-diff.md +137 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/link-registry.json +33 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/model-0.4.2-overview.md +40 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/model-0.4.2.md +429 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/detect-readme-format.cjs +105 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/find-usage-doc.cjs +90 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/link-verify.cjs +213 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-changelog.cjs +73 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-package-meta.cjs +258 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-readme-links.cjs +341 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/resolve-usage-docs.cjs +67 -0
- package/vendor/Server/Skills/rn-library-consistency-check/SKILL.md +299 -0
- package/vendor/Server/Skills/rn-library-consistency-check/assets/REPORT_TEMPLATE.md +293 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/ARKTS_COMPONENT_CHECK_GUIDE.md +857 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/ARKTS_TURBOMODULE_CHECK_GUIDE.md +856 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/CHECKLIST.md +157 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/CPP_COMPONENT_CHECK_GUIDE.md +801 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/CPP_TURBOMODULE_CHECK_GUIDE.md +684 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/FUNCTION_COMPARISON_GUIDE.md +233 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/NATIVE_COMPONENT_IDENTIFICATION.md +1373 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/SCORING_STANDARD.md +220 -0
- package/vendor/Server/Skills/rn-library-consistency-check/scripts/validate-skill.py +245 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/SKILL.md +263 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/MODEL.md +414 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/MODEL_en.md +413 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/REPORT_TEMPLATE.md +311 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/CHECK_CHECKLIST.md +355 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/CROSS_VALIDATION_GUIDE.md +115 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/DOC_COLLECTION_GUIDE.md +139 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/EXAMPLES.md +586 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/GOTCHAS.md +57 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/scripts/validate-skill.py +259 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/SKILL.md +301 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/assets/REPORT_TEMPLATE.md +148 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/DOC_ANNOTATION_GUIDE.md +118 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/SCRIPT_USAGE_GUIDE.md +168 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/URL_PARSING_RULES.md +176 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +274 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/assets/case-template.md +45 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/assets/rule-template.md +25 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/references/PR_FETCH_GUIDE.md +61 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/references/RULE_TEMPLATE_GUIDE.md +165 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/scripts/fetch-pr-info.py +239 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +263 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/assets/REPORT_TEMPLATE.md +96 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/COMPLIANCE_CHECKLIST.md +58 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/INSPECTION_GUIDE.md +99 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/PRESCREEN_GUIDE.md +64 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/SOURCE_PREP_GUIDE.md +75 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/scripts/validate-known-issue-report.py +164 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/SKILL.md +339 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/assets/REPORT_TEMPLATE.md +83 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/references/CHECKLIST.md +859 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/references/HARMONY_CODE_PATTERNS.md +122 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/scripts/scan_harmony_code.py +279 -0
- package/vendor/Server/Skills/rn-library-stability-check/SKILL.md +273 -0
- package/vendor/Server/Skills/rn-library-stability-check/assets/REPORT_TEMPLATE.md +129 -0
- package/vendor/Server/Skills/rn-library-stability-check/references/CHECKLIST.md +581 -0
- package/vendor/Server/Skills/rn-library-stability-check/references/SCORING_RULES.md +138 -0
- package/vendor/Server/Skills/rn-library-stability-check/scripts/scan-harmony-code.py +168 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/SKILL.md +506 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/CHECKLIST.md +280 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/DEMO_LOCATION.md +221 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/REPORT_TEMPLATE.md +209 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/SCRIPT_USAGE.md +325 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/SKILL.md +279 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/assets/TEST_FILE_TEMPLATES.md +404 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/BUILD_TROUBLESHOOTING.md +185 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/BUILD_WORKFLOW.md +265 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/COMMON_CONFIG.md +189 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/CONFIG_GUIDE.md +203 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/COVERAGE_ANALYZER.md +147 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/DESIGN_DOC_GUIDE.md +148 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/GENERATION_FLOW.md +165 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/GENERATION_STRATEGY.md +195 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/HARMONY_SCANNER.md +249 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/JEST_FRAMEWORK.md +235 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/PLATFORM_COMPAT.md +161 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/RN_TEST_PATTERNS.md +413 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/SOURCE_PARSER.md +235 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/TEST_CONVENTIONS.md +245 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/TROUBLESHOOTING.md +282 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/USAGE_GUIDE.md +251 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/SKILL.md +469 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/assets/CPTF_TEST_TEMPLATE.md +310 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/assets/DEMO_PAGE_TEMPLATE.md +303 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/CPTF_TEST_GENERATION_GUIDE.md +421 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/DEMO_GENERATION_GUIDE.md +358 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/QUALITY_CHECKLIST.md +114 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/SPEC_PARSING_GUIDE.md +274 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/scripts/validate-rnoh-cptf-api-test.sh +185 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/SKILL.md +191 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/assets/TEST_TEMPLATE.md +216 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/references/CPTF_SETUP.md +107 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/references/DEMO_ANALYSIS.md +120 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/scripts/validate-rnoh-cptf-test.sh +108 -0
- package/vendor/Server/Skills/rnoh-cptf-test-run/SKILL.md +237 -0
- package/vendor/Server/Skills/rnoh-cptf-test-run/references/DEBUG_PLAYBOOK.md +261 -0
- package/vendor/Server/Skills/rnoh-cptf-test-run/scripts/validate-run-env.sh +112 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/SKILL.md +498 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/adapt-checklist.md +270 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/api-migration-checklist.md +164 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/common-compile-errors.md +556 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/deveco-cli-tools.md +459 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/edge-cases.md +65 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/har-tgz-build.md +512 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/version-compat-matrix.md +132 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/scripts/auto-integrate.sh +424 -0
- package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +137 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/SKILL.md +306 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/assets/DEMO_PAGE_TEMPLATE.md +485 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/assets/INDEX_TEMPLATE.md +172 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/DEMO_CODE_RULES.md +422 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/QUALITY_CHECKLIST.md +95 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/SOURCE_EXPLORATION.md +169 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/SKILL.md +554 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/assets/DEMO_DOC_TEMPLATE.md +106 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/COVERAGE_INCREMENTAL.md +216 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/DEMO_DESIGN_RULES.md +413 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/OUTPUT_FORMAT.md +269 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/QUALITY_CHECKLIST.md +98 -0
- package/vendor/Server/Skills/rnoh-lib-func-test/SKILL.md +337 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/SKILL.md +722 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/assets/PORT_REPORT_TEMPLATE.md +219 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/DEMO_PORTING_GUIDE.md +345 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/PORT_VERIFICATION.md +269 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/RNT_PROJECT_STRUCTURE.md +173 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/analyze-demo-deps.cjs +267 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/detect-rnoh-version.cjs +174 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/find-rnt-demo.sh +111 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/port-demo.sh +186 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/read-lib-meta.cjs +150 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/SKILL.md +296 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/jest-troubleshooting.md +371 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +212 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/runtime-troubleshooting.md +345 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/unit-test-template.md +223 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/scripts/port-test-demo.sh +1053 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/SKILL.md +255 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/OHOS_ADAPTATION.md +77 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/OHOS_API_LOOKUP.md +224 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/script-reference.md +174 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/detect-upstream-version.js +967 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/generate-diff.js +1798 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/package.json +5 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/templates/report-template.md +137 -0
- package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +145 -0
- package/vendor/Server/Skills/skill-generator/SKILL.md +365 -0
- package/vendor/Server/Skills/skill-generator/assets/SKILL_TEMPLATE.md +183 -0
- package/vendor/Server/Skills/skill-generator/references/COMPLIANCE_CHECKLIST.md +82 -0
- package/vendor/Server/Skills/skill-generator/references/KB_QUERY_GUIDE.md +110 -0
- package/vendor/Server/Skills/skill-generator/references/MCP_TOOL_DISCOVERY.md +122 -0
- package/vendor/Server/Skills/skill-generator/references/SKILL_SPEC.md +121 -0
- package/vendor/Server/Skills/skill-generator/scripts/validate-skill.cjs +259 -0
- package/vendor/Server/Skills/task-analysis/SKILL.md +234 -0
- package/vendor/Server/Skills/task-analysis/assets/OUTPUT_EXAMPLES.md +160 -0
- package/vendor/Server/Skills/task-analysis/references/ACCEPTANCE_CRITERIA_GUIDE.md +190 -0
- package/vendor/Server/Skills/task-analysis/references/ANALYSIS_SCHEMA.md +224 -0
- package/vendor/Server/Skills/task-analysis/references/INTEGRATION_CONTEXT.md +162 -0
- package/vendor/Server/Skills/task-analysis/references/LESSONS_LEARNED.md +55 -0
- package/vendor/Server/Skills/task-analysis/references/REPLAN_CONTEXT_GUIDE.md +126 -0
- package/vendor/Server/Skills/task-analysis/scripts/validate-analysis-output.sh +256 -0
- package/vendor/Server/Skills/task-decomposition/SKILL.md +529 -0
- package/vendor/Server/Skills/task-decomposition/assets/OUTPUT_EXAMPLES.md +451 -0
- package/vendor/Server/Skills/task-decomposition/references/ACCEPTANCE_CRITERIA_GUIDE.md +179 -0
- package/vendor/Server/Skills/task-decomposition/references/DEPENDENCY_GRAPH_GUIDE.md +152 -0
- package/vendor/Server/Skills/task-decomposition/references/INTEGRATION_CONTEXT.md +175 -0
- package/vendor/Server/Skills/task-decomposition/references/REPLAN_CONTEXT_GUIDE.md +195 -0
- package/vendor/Server/Skills/task-decomposition/references/TASK_DECOMPOSITION_TEMPLATES.md +226 -0
- package/vendor/Server/Skills/task-decomposition/scripts/list-available-skills.cjs +263 -0
- package/vendor/Server/Skills/task-decomposition/scripts/skill-blacklist.json +29 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-decomposition-output.cjs +376 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-param-consistency.cjs +259 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-specified-skills.cjs +216 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-step-graph.cjs +425 -0
- package/vendor/Server/Skills/tpc-cpp-check/SKILL.md +427 -0
- package/vendor/Server/Skills/tpc-cpp-check/references/CHECKLIST.md +214 -0
- package/vendor/Server/Skills/tpc-cpp-check/references/HPKBUILD_GUIDE.md +235 -0
- package/vendor/Server/Skills/tpc-cpp-check/references/REPORT_TEMPLATE.md +250 -0
- package/vendor/Server/TestCheck/TestCheck.js +775 -0
- package/vendor/Server/TestCheck/index.js +11 -0
- package/vendor/Server/library/McpToolGuide.js +280 -0
- package/vendor/Server/library/StatsService.js +127 -0
- package/vendor/Server/library/cstTime.js +16 -0
- package/vendor/Server/package.json +17 -0
- package/vendor/VERSION +3 -0
- package/workflows/pr-check.mjs +106 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { nowCST } from '../../library/cstTime.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TaskExecutionStore —— 任务步骤执行记录持久化(JSON 文件)
|
|
5
|
+
*
|
|
6
|
+
* 用途:在任务执行过程中,将每个步骤的执行状态、时间、会话 ID 等关键信息
|
|
7
|
+
* 以 JSON 文件形式持久化到 db/task/{taskId}/ 目录下,方便后续追踪和分析。
|
|
8
|
+
*
|
|
9
|
+
* 文件布局:
|
|
10
|
+
* db/
|
|
11
|
+
* └── task/
|
|
12
|
+
* └── {taskId}/
|
|
13
|
+
* ├── stepid_{stepId}.json ← 单个步骤的执行记录
|
|
14
|
+
* └── stepid_{stepId}.json
|
|
15
|
+
*
|
|
16
|
+
* 单个步骤记录字段:
|
|
17
|
+
* {
|
|
18
|
+
* taskId, stepId, dependId, nextStepId,
|
|
19
|
+
* taskDescription, skillDirectory, inputReport,
|
|
20
|
+
* matchedSkillDir, sessionId,
|
|
21
|
+
* status, retryTimes, maxRetries,
|
|
22
|
+
* startTime, endTime, updatedAt,
|
|
23
|
+
* error
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* 依赖 JsonAdapter(subDir='task'),整文件读写,幂等覆盖。
|
|
27
|
+
*
|
|
28
|
+
* 分层关系:与 SessionStore / TaskStepStore 平级,只依赖适配器接口。
|
|
29
|
+
*/
|
|
30
|
+
class TaskExecutionStore {
|
|
31
|
+
/**
|
|
32
|
+
* @param {object} options
|
|
33
|
+
* @param {import('../adapters/JsonAdapter.js').default} options.json - JSON 适配器(subDir='task')
|
|
34
|
+
*/
|
|
35
|
+
constructor(options = {}) {
|
|
36
|
+
this.json = options.json;
|
|
37
|
+
if (!this.json) {
|
|
38
|
+
throw new Error('TaskExecutionStore 需要 json 适配器');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ─── 路径约定 ──────────────────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 生成步骤记录的存储 key。
|
|
46
|
+
* JsonAdapter 会在 key 后追加 .json,最终文件为:
|
|
47
|
+
* - 有 loopCount: {rootDir}/{taskId}/stepid_{stepId}_loop{L}.json
|
|
48
|
+
* - 无 loopCount: {rootDir}/{taskId}/stepid_{stepId}.json(向后兼容)
|
|
49
|
+
*
|
|
50
|
+
* @param {string} taskId
|
|
51
|
+
* @param {string} stepId
|
|
52
|
+
* @param {number} [loopCount] - 大循环索引(可选)
|
|
53
|
+
* @returns {string} storage key
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
_key(taskId, stepId, loopCount) {
|
|
57
|
+
const base = `${taskId}/stepid_${stepId}`;
|
|
58
|
+
if (loopCount != null && Number.isFinite(Number(loopCount))) {
|
|
59
|
+
return `${base}_loop${loopCount}`;
|
|
60
|
+
}
|
|
61
|
+
return base;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ─── 读写 ──────────────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 写入(覆盖)步骤执行记录。
|
|
68
|
+
* @param {string} taskId
|
|
69
|
+
* @param {string} stepId
|
|
70
|
+
* @param {object} data - 步骤记录
|
|
71
|
+
* @param {number} [loopCount] - 大循环索引(可选,传入时按轮次独立存储)
|
|
72
|
+
* @returns {Promise<object>} 写入的数据
|
|
73
|
+
*/
|
|
74
|
+
async writeStep(taskId, stepId, data, loopCount) {
|
|
75
|
+
return this.json.write(this._key(taskId, stepId, loopCount), {
|
|
76
|
+
...data,
|
|
77
|
+
taskId,
|
|
78
|
+
stepId,
|
|
79
|
+
updatedAt: nowCST()
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 读取步骤执行记录。
|
|
85
|
+
* @param {string} taskId
|
|
86
|
+
* @param {string} stepId
|
|
87
|
+
* @param {number} [loopCount] - 大循环索引(可选)
|
|
88
|
+
* @returns {Promise<object|null>} 步骤记录,不存在时返回 null
|
|
89
|
+
*/
|
|
90
|
+
async readStep(taskId, stepId, loopCount) {
|
|
91
|
+
return this.json.read(this._key(taskId, stepId, loopCount));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 增量更新步骤记录(合并已有字段)。
|
|
96
|
+
* 不存在时以 patch 为初始数据创建。
|
|
97
|
+
*
|
|
98
|
+
* @param {string} taskId
|
|
99
|
+
* @param {string} stepId
|
|
100
|
+
* @param {object} patch - 要合并的字段
|
|
101
|
+
* @param {number} [loopCount] - 大循环索引(可选,传入时按轮次独立存储)
|
|
102
|
+
* @returns {Promise<object>} 合并后的完整记录
|
|
103
|
+
*/
|
|
104
|
+
async patchStep(taskId, stepId, patch, loopCount) {
|
|
105
|
+
const existing = await this.readStep(taskId, stepId, loopCount) ?? {};
|
|
106
|
+
const next = { ...existing, ...patch };
|
|
107
|
+
return this.writeStep(taskId, stepId, next, loopCount);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 列出某个 Task 下所有步骤记录。
|
|
112
|
+
* 依赖 JsonAdapter.list() 按目录前缀过滤。
|
|
113
|
+
*
|
|
114
|
+
* @param {string} taskId
|
|
115
|
+
* @returns {Promise<object[]>} 步骤记录数组(按 startTime 排序)
|
|
116
|
+
*/
|
|
117
|
+
async listSteps(taskId) {
|
|
118
|
+
const pattern = `${taskId}/stepid_`;
|
|
119
|
+
const entries = await this.json.list(pattern).catch(() => []);
|
|
120
|
+
// JsonAdapter.list() 返回 [{ key, data }] 格式
|
|
121
|
+
const results = entries
|
|
122
|
+
.map(e => (e != null && typeof e === 'object' ? (e.data ?? e) : null))
|
|
123
|
+
.filter(Boolean);
|
|
124
|
+
results.sort((a, b) => {
|
|
125
|
+
const ta = a.startTime || '';
|
|
126
|
+
const tb = b.startTime || '';
|
|
127
|
+
return ta.localeCompare(tb);
|
|
128
|
+
});
|
|
129
|
+
return results;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default TaskExecutionStore;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TaskRegistryStore —— 任务注册表(SQLite)
|
|
3
|
+
*
|
|
4
|
+
* 用途:为"历史任务列表"提供高性能分页查询。
|
|
5
|
+
*
|
|
6
|
+
* 背景:
|
|
7
|
+
* 任务详情数据(loop.json / orchestration.json / stepid_*.json)以 JSON 文件
|
|
8
|
+
* 存储在 db/task/{taskId}/ 下,单任务读写 O(1),简单可靠。
|
|
9
|
+
* 但历史列表若逐个扫描 JSON 文件,任务数超过数百后会出现明显卡顿
|
|
10
|
+
* (N 次 readFile + JSON.parse + 全量返回)。
|
|
11
|
+
*
|
|
12
|
+
* 方案:
|
|
13
|
+
* 新增一张 SQLite 注册表,仅记录任务的"摘要信息"(taskId / 类型 / 状态 /
|
|
14
|
+
* 时间 / 描述 / 摘要元数据),供列表查询使用:
|
|
15
|
+
* - 列表查询走 SQL 分页(LIMIT/OFFSET),不读任何 JSON 文件
|
|
16
|
+
* - COUNT 用 SELECT COUNT(*),不加载全部数据
|
|
17
|
+
* - 任务详情仍从 JSON 文件读取(单文件 O(1))
|
|
18
|
+
*
|
|
19
|
+
* 表结构 (task_registry):
|
|
20
|
+
* task_id TEXT PRIMARY KEY - 任务 ID
|
|
21
|
+
* task_type TEXT NOT NULL - 任务类型('loop' | 'orchestrator' | 'flexrunner' | ...)
|
|
22
|
+
* status TEXT NOT NULL - 状态(running / completed / failed / aborted / ...)
|
|
23
|
+
* title TEXT - 任务标题/描述(截断)
|
|
24
|
+
* description TEXT - 完整描述(可选)
|
|
25
|
+
* created_at TEXT NOT NULL - 创建时间(ISO)
|
|
26
|
+
* updated_at TEXT - 最后更新时间(ISO)
|
|
27
|
+
* metadata TEXT - 扩展摘要元数据(JSON 字符串,如评分、轮次等)
|
|
28
|
+
*
|
|
29
|
+
* 索引:created_at(列表排序)、status(状态过滤)
|
|
30
|
+
*
|
|
31
|
+
* 依赖 SqliteAdapter(better-sqlite3)。
|
|
32
|
+
*/
|
|
33
|
+
const DDL = `
|
|
34
|
+
CREATE TABLE IF NOT EXISTS task_registry (
|
|
35
|
+
task_id TEXT PRIMARY KEY,
|
|
36
|
+
task_type TEXT NOT NULL,
|
|
37
|
+
status TEXT NOT NULL,
|
|
38
|
+
title TEXT,
|
|
39
|
+
description TEXT,
|
|
40
|
+
created_at TEXT NOT NULL,
|
|
41
|
+
updated_at TEXT,
|
|
42
|
+
metadata TEXT
|
|
43
|
+
);
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_task_registry_created_at ON task_registry(created_at DESC);
|
|
45
|
+
CREATE INDEX IF NOT EXISTS idx_task_registry_status ON task_registry(status);
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
class TaskRegistryStore {
|
|
49
|
+
/**
|
|
50
|
+
* @param {object} options
|
|
51
|
+
* @param {import('../adapters/SqliteAdapter.js').default} options.sqlite - SQLite 适配器
|
|
52
|
+
*/
|
|
53
|
+
constructor(options = {}) {
|
|
54
|
+
this.sqlite = options.sqlite;
|
|
55
|
+
if (!this.sqlite) {
|
|
56
|
+
throw new Error('TaskRegistryStore 需要 sqlite 适配器');
|
|
57
|
+
}
|
|
58
|
+
this._initialized = false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 幂等建表 */
|
|
62
|
+
async _init() {
|
|
63
|
+
if (this._initialized) return;
|
|
64
|
+
await this.sqlite.exec(DDL);
|
|
65
|
+
this._initialized = true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 注册(插入或更新)一条任务摘要。
|
|
70
|
+
* 幂等:同一 taskId 重复调用会覆盖。
|
|
71
|
+
*
|
|
72
|
+
* @param {object} entry
|
|
73
|
+
* @param {string} entry.taskId
|
|
74
|
+
* @param {string} [entry.taskType='loop'] - 任务类型
|
|
75
|
+
* @param {string} [entry.status='running'] - 状态
|
|
76
|
+
* @param {string} [entry.title=''] - 标题/描述(截断到 200 字符)
|
|
77
|
+
* @param {string} [entry.description=''] - 完整描述
|
|
78
|
+
* @param {string} [entry.createdAt] - 创建时间(默认 now)
|
|
79
|
+
* @param {object} [entry.metadata] - 扩展摘要元数据(会 JSON 序列化)
|
|
80
|
+
* @returns {Promise<object>} 写入的条目
|
|
81
|
+
*/
|
|
82
|
+
async upsert(entry) {
|
|
83
|
+
await this._init();
|
|
84
|
+
const now = new Date().toISOString();
|
|
85
|
+
const row = {
|
|
86
|
+
task_id: entry.taskId,
|
|
87
|
+
task_type: entry.taskType || 'loop',
|
|
88
|
+
status: entry.status || 'running',
|
|
89
|
+
title: entry.title ? String(entry.title).slice(0, 200) : '',
|
|
90
|
+
description: entry.description || '',
|
|
91
|
+
created_at: entry.createdAt || now,
|
|
92
|
+
updated_at: now,
|
|
93
|
+
metadata: entry.metadata ? JSON.stringify(entry.metadata) : null
|
|
94
|
+
};
|
|
95
|
+
await this.sqlite.upsert('task_registry', row);
|
|
96
|
+
return row;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 更新任务状态(保留其他字段)。
|
|
101
|
+
* @param {string} taskId
|
|
102
|
+
* @param {object} patch - { status?, title?, description?, metadata? }
|
|
103
|
+
* @returns {Promise<object|null>} 更新后的条目,不存在返回 null
|
|
104
|
+
*/
|
|
105
|
+
async patch(taskId, patch) {
|
|
106
|
+
await this._init();
|
|
107
|
+
const existing = await this.get(taskId);
|
|
108
|
+
if (!existing) return null;
|
|
109
|
+
|
|
110
|
+
const next = {
|
|
111
|
+
...existing,
|
|
112
|
+
...patch,
|
|
113
|
+
task_id: taskId,
|
|
114
|
+
updated_at: new Date().toISOString()
|
|
115
|
+
};
|
|
116
|
+
if (next.metadata && typeof next.metadata === 'object') {
|
|
117
|
+
next.metadata = JSON.stringify(next.metadata);
|
|
118
|
+
}
|
|
119
|
+
await this.sqlite.upsert('task_registry', next);
|
|
120
|
+
return next;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 按 taskId 查询单条摘要。
|
|
125
|
+
* @param {string} taskId
|
|
126
|
+
* @returns {Promise<object|null>}
|
|
127
|
+
*/
|
|
128
|
+
async get(taskId) {
|
|
129
|
+
await this._init();
|
|
130
|
+
const row = await this.sqlite.get(
|
|
131
|
+
'SELECT * FROM task_registry WHERE task_id = ?',
|
|
132
|
+
[taskId]
|
|
133
|
+
);
|
|
134
|
+
return row ? this._deserialize(row) : null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 分页查询任务列表(按 created_at 降序)。
|
|
139
|
+
* @param {object} [opts]
|
|
140
|
+
* @param {number} [opts.page=1] - 页码,从 1 开始
|
|
141
|
+
* @param {number} [opts.pageSize=20] - 每页条数
|
|
142
|
+
* @param {string} [opts.status] - 可选,按状态过滤
|
|
143
|
+
* @param {string} [opts.taskType] - 可选,按任务类型过滤
|
|
144
|
+
* @param {string} [opts.taskIdPrefix] - 可选,按 taskId 前缀过滤(如 'fluttercheck_' / 'codecheck_')
|
|
145
|
+
* @returns {Promise<{ tasks: object[], total: number, page: number, pageSize: number, totalPages: number }>}
|
|
146
|
+
*/
|
|
147
|
+
async listPage(opts = {}) {
|
|
148
|
+
await this._init();
|
|
149
|
+
const page = Math.max(1, opts.page || 1);
|
|
150
|
+
const pageSize = Math.min(100, Math.max(1, opts.pageSize || 20));
|
|
151
|
+
const offset = (page - 1) * pageSize;
|
|
152
|
+
|
|
153
|
+
const where = [];
|
|
154
|
+
const params = [];
|
|
155
|
+
if (opts.status) {
|
|
156
|
+
where.push('status = ?');
|
|
157
|
+
params.push(opts.status);
|
|
158
|
+
}
|
|
159
|
+
if (opts.taskType) {
|
|
160
|
+
where.push('task_type = ?');
|
|
161
|
+
params.push(opts.taskType);
|
|
162
|
+
}
|
|
163
|
+
if (opts.taskIdPrefix) {
|
|
164
|
+
where.push("task_id LIKE ? ESCAPE '\\'");
|
|
165
|
+
// LIKE 通配符转义:前缀中的 %/_ 按字面匹配
|
|
166
|
+
params.push(String(opts.taskIdPrefix).replace(/([%_\\])/g, '\\$1') + '%');
|
|
167
|
+
}
|
|
168
|
+
const whereSql = where.length ? `WHERE ${where.join(' AND ')}` : '';
|
|
169
|
+
|
|
170
|
+
const countRow = await this.sqlite.get(
|
|
171
|
+
`SELECT COUNT(*) AS total FROM task_registry ${whereSql}`,
|
|
172
|
+
params
|
|
173
|
+
);
|
|
174
|
+
const total = countRow?.total ?? 0;
|
|
175
|
+
|
|
176
|
+
const rows = await this.sqlite.all(
|
|
177
|
+
`SELECT * FROM task_registry ${whereSql} ORDER BY created_at DESC LIMIT ? OFFSET ?`,
|
|
178
|
+
[...params, pageSize, offset]
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
tasks: rows.map(r => this._deserialize(r)),
|
|
183
|
+
total,
|
|
184
|
+
page,
|
|
185
|
+
pageSize,
|
|
186
|
+
totalPages: Math.max(1, Math.ceil(total / pageSize))
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 查询符合条件的全部 task_id(不分页),供跨页去重判断使用。
|
|
192
|
+
*
|
|
193
|
+
* listPage 只返回当前页的 ID,无法判断某 taskId 是否出现在其他页,
|
|
194
|
+
* 因此提供本方法返回全量 ID 集合(与 listPage 使用相同的 where 过滤条件)。
|
|
195
|
+
*
|
|
196
|
+
* @param {object} [opts]
|
|
197
|
+
* @param {string} [opts.status]
|
|
198
|
+
* @param {string} [opts.taskType]
|
|
199
|
+
* @param {string} [opts.taskIdPrefix]
|
|
200
|
+
* @returns {Promise<string[]>}
|
|
201
|
+
*/
|
|
202
|
+
async listIds(opts = {}) {
|
|
203
|
+
await this._init();
|
|
204
|
+
const where = [];
|
|
205
|
+
const params = [];
|
|
206
|
+
if (opts.status) {
|
|
207
|
+
where.push('status = ?');
|
|
208
|
+
params.push(opts.status);
|
|
209
|
+
}
|
|
210
|
+
if (opts.taskType) {
|
|
211
|
+
where.push('task_type = ?');
|
|
212
|
+
params.push(opts.taskType);
|
|
213
|
+
}
|
|
214
|
+
if (opts.taskIdPrefix) {
|
|
215
|
+
where.push("task_id LIKE ? ESCAPE '\\'");
|
|
216
|
+
params.push(String(opts.taskIdPrefix).replace(/([%_\\])/g, '\\$1') + '%');
|
|
217
|
+
}
|
|
218
|
+
const whereSql = where.length ? `WHERE ${where.join(' AND ')}` : '';
|
|
219
|
+
const rows = await this.sqlite.all(
|
|
220
|
+
`SELECT task_id FROM task_registry ${whereSql}`,
|
|
221
|
+
params
|
|
222
|
+
);
|
|
223
|
+
return rows.map(r => r.task_id);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 删除一条任务摘要。
|
|
228
|
+
* @param {string} taskId
|
|
229
|
+
* @returns {Promise<boolean>}
|
|
230
|
+
*/
|
|
231
|
+
async delete(taskId) {
|
|
232
|
+
await this._init();
|
|
233
|
+
await this.sqlite.exec('DELETE FROM task_registry WHERE task_id = ?', [taskId]);
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 获取任务总数(仅 COUNT,不加载数据)。
|
|
239
|
+
* @returns {Promise<number>}
|
|
240
|
+
*/
|
|
241
|
+
async count() {
|
|
242
|
+
await this._init();
|
|
243
|
+
const row = await this.sqlite.get('SELECT COUNT(*) AS total FROM task_registry');
|
|
244
|
+
return row?.total ?? 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** 反序列化:metadata JSON 字符串 → 对象 */
|
|
248
|
+
_deserialize(row) {
|
|
249
|
+
if (!row) return null;
|
|
250
|
+
const out = { ...row };
|
|
251
|
+
if (out.metadata) {
|
|
252
|
+
try {
|
|
253
|
+
out.metadata = JSON.parse(out.metadata);
|
|
254
|
+
} catch {
|
|
255
|
+
out.metadata = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export default TaskRegistryStore;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TaskStepStore —— 任务步骤持久化存储(SQLite)
|
|
5
|
+
*
|
|
6
|
+
* 用途:记录任务执行过程中的各个步骤信息,支持查询、状态流转、耗时统计。
|
|
7
|
+
*
|
|
8
|
+
* 表结构 (task_steps):
|
|
9
|
+
* id TEXT PRIMARY KEY - 步骤唯一 ID(自动生成)
|
|
10
|
+
* task_id TEXT NOT NULL - 所属任务 ID
|
|
11
|
+
* seq INTEGER NOT NULL - 步骤序号(同任务内递增)
|
|
12
|
+
* name TEXT - 步骤名称
|
|
13
|
+
* type TEXT - 步骤类型(如 'cli'/'db'/'file'/'custom')
|
|
14
|
+
* status TEXT NOT NULL DEFAULT 'pending' - pending/running/completed/error/skipped
|
|
15
|
+
* input TEXT - 输入(JSON 字符串)
|
|
16
|
+
* output TEXT - 输出(JSON 字符串)
|
|
17
|
+
* error TEXT - 错误信息
|
|
18
|
+
* started_at TEXT - 开始时间 ISO
|
|
19
|
+
* finished_at TEXT - 结束时间 ISO
|
|
20
|
+
* duration_ms INTEGER - 耗时毫秒
|
|
21
|
+
* created_at TEXT NOT NULL - 创建时间 ISO
|
|
22
|
+
* updated_at TEXT - 更新时间 ISO
|
|
23
|
+
* meta TEXT - 扩展元信息(JSON 字符串)
|
|
24
|
+
*
|
|
25
|
+
* 索引:task_id、(task_id, seq)、status
|
|
26
|
+
*
|
|
27
|
+
* 依赖 SqliteAdapter(better-sqlite3)。
|
|
28
|
+
*/
|
|
29
|
+
const DDL = `
|
|
30
|
+
CREATE TABLE IF NOT EXISTS task_steps (
|
|
31
|
+
id TEXT PRIMARY KEY,
|
|
32
|
+
task_id TEXT NOT NULL,
|
|
33
|
+
seq INTEGER NOT NULL,
|
|
34
|
+
name TEXT,
|
|
35
|
+
type TEXT,
|
|
36
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
37
|
+
input TEXT,
|
|
38
|
+
output TEXT,
|
|
39
|
+
error TEXT,
|
|
40
|
+
started_at TEXT,
|
|
41
|
+
finished_at TEXT,
|
|
42
|
+
duration_ms INTEGER,
|
|
43
|
+
created_at TEXT NOT NULL,
|
|
44
|
+
updated_at TEXT,
|
|
45
|
+
meta TEXT
|
|
46
|
+
);
|
|
47
|
+
CREATE INDEX IF NOT EXISTS idx_task_steps_task_id ON task_steps(task_id);
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_task_steps_task_seq ON task_steps(task_id, seq);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_task_steps_status ON task_steps(status);
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
class TaskStepStore {
|
|
53
|
+
/**
|
|
54
|
+
* @param {object} options
|
|
55
|
+
* @param {import('../adapters/SqliteAdapter.js').default} options.sqlite - SQLite 适配器
|
|
56
|
+
*/
|
|
57
|
+
constructor(options = {}) {
|
|
58
|
+
this.sqlite = options.sqlite;
|
|
59
|
+
if (!this.sqlite) {
|
|
60
|
+
throw new Error('TaskStepStore 需要 sqlite 适配器');
|
|
61
|
+
}
|
|
62
|
+
this._initialized = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 幂等建表 */
|
|
66
|
+
async _init() {
|
|
67
|
+
if (this._initialized) return;
|
|
68
|
+
await this.sqlite.exec(DDL);
|
|
69
|
+
this._initialized = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 创建一个任务步骤。
|
|
74
|
+
* @param {object} step
|
|
75
|
+
* @param {string} step.taskId
|
|
76
|
+
* @param {string} [step.id] - 指定记录 ID(默认 randomUUID)。传入后幂等 upsert。
|
|
77
|
+
* @param {string} [step.name]
|
|
78
|
+
* @param {string} [step.type]
|
|
79
|
+
* @param {string} [step.status='pending']
|
|
80
|
+
* @param {object} [step.input]
|
|
81
|
+
* @param {object} [step.output] - 已知输出(如终态补录场景)
|
|
82
|
+
* @param {string} [step.startedAt] - 开始时间 ISO(如 running 落库场景)
|
|
83
|
+
* @param {object} [step.meta]
|
|
84
|
+
* @returns {Promise<object>} 创建后的步骤记录
|
|
85
|
+
*/
|
|
86
|
+
async create(step) {
|
|
87
|
+
await this._init();
|
|
88
|
+
const now = new Date().toISOString();
|
|
89
|
+
const id = step.id || randomUUID();
|
|
90
|
+
const seq = await this._nextSeq(step.taskId);
|
|
91
|
+
const row = {
|
|
92
|
+
id,
|
|
93
|
+
task_id: step.taskId,
|
|
94
|
+
seq,
|
|
95
|
+
name: step.name ?? null,
|
|
96
|
+
type: step.type ?? null,
|
|
97
|
+
status: step.status ?? 'pending',
|
|
98
|
+
input: step.input != null ? JSON.stringify(step.input) : null,
|
|
99
|
+
output: step.output != null ? JSON.stringify(step.output) : null,
|
|
100
|
+
error: null,
|
|
101
|
+
started_at: step.startedAt ?? null,
|
|
102
|
+
finished_at: null,
|
|
103
|
+
duration_ms: null,
|
|
104
|
+
created_at: now,
|
|
105
|
+
updated_at: now,
|
|
106
|
+
meta: step.meta != null ? JSON.stringify(step.meta) : null
|
|
107
|
+
};
|
|
108
|
+
await this.sqlite.upsert('task_steps', row);
|
|
109
|
+
return this._rowToObj(row);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** 获取同任务内下一个 seq */
|
|
113
|
+
async _nextSeq(taskId) {
|
|
114
|
+
const row = await this.sqlite.get(
|
|
115
|
+
'SELECT MAX(seq) AS max_seq FROM task_steps WHERE task_id = ?',
|
|
116
|
+
[taskId]
|
|
117
|
+
);
|
|
118
|
+
return (row?.max_seq ?? 0) + 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 按 ID 获取步骤。
|
|
123
|
+
* @param {string} id
|
|
124
|
+
* @returns {Promise<object|null>}
|
|
125
|
+
*/
|
|
126
|
+
async get(id) {
|
|
127
|
+
await this._init();
|
|
128
|
+
const row = await this.sqlite.get('SELECT * FROM task_steps WHERE id = ?', [id]);
|
|
129
|
+
return row ? this._rowToObj(row) : null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 列出某任务的所有步骤(按 seq 升序)。
|
|
134
|
+
* @param {string} taskId
|
|
135
|
+
* @returns {Promise<Array<object>>}
|
|
136
|
+
*/
|
|
137
|
+
async listByTask(taskId) {
|
|
138
|
+
await this._init();
|
|
139
|
+
const rows = await this.sqlite.all(
|
|
140
|
+
'SELECT * FROM task_steps WHERE task_id = ? ORDER BY seq ASC',
|
|
141
|
+
[taskId]
|
|
142
|
+
);
|
|
143
|
+
return rows.map(r => this._rowToObj(r));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 按状态查询步骤。
|
|
148
|
+
* @param {string} status
|
|
149
|
+
* @returns {Promise<Array<object>>}
|
|
150
|
+
*/
|
|
151
|
+
async listByStatus(status) {
|
|
152
|
+
await this._init();
|
|
153
|
+
const rows = await this.sqlite.all(
|
|
154
|
+
'SELECT * FROM task_steps WHERE status = ? ORDER BY created_at ASC',
|
|
155
|
+
[status]
|
|
156
|
+
);
|
|
157
|
+
return rows.map(r => this._rowToObj(r));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 更新步骤状态(状态流转 + 时间戳 + 耗时)。
|
|
162
|
+
* @param {string} id
|
|
163
|
+
* @param {object} patch
|
|
164
|
+
* @param {string} [patch.status]
|
|
165
|
+
* @param {object} [patch.output]
|
|
166
|
+
* @param {string} [patch.error]
|
|
167
|
+
* @param {object} [patch.meta]
|
|
168
|
+
* @returns {Promise<object|null>} 更新后的步骤
|
|
169
|
+
*/
|
|
170
|
+
async update(id, patch) {
|
|
171
|
+
await this._init();
|
|
172
|
+
const now = new Date().toISOString();
|
|
173
|
+
const updates = [];
|
|
174
|
+
const params = [];
|
|
175
|
+
|
|
176
|
+
if (patch.status) {
|
|
177
|
+
updates.push('status = ?'); params.push(patch.status);
|
|
178
|
+
// 状态流转时自动维护时间戳
|
|
179
|
+
if (patch.status === 'running' && !patch.started_at) {
|
|
180
|
+
updates.push('started_at = ?'); params.push(now);
|
|
181
|
+
}
|
|
182
|
+
if (['completed', 'error', 'skipped'].includes(patch.status) && !patch.finished_at) {
|
|
183
|
+
updates.push('finished_at = ?'); params.push(now);
|
|
184
|
+
// 计算耗时
|
|
185
|
+
const cur = await this.get(id);
|
|
186
|
+
if (cur?.startedAt) {
|
|
187
|
+
const dur = Date.parse(now) - Date.parse(cur.startedAt);
|
|
188
|
+
updates.push('duration_ms = ?'); params.push(dur);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (patch.output != null) {
|
|
193
|
+
updates.push('output = ?'); params.push(JSON.stringify(patch.output));
|
|
194
|
+
}
|
|
195
|
+
if (patch.error != null) {
|
|
196
|
+
updates.push('error = ?'); params.push(patch.error);
|
|
197
|
+
}
|
|
198
|
+
if (patch.meta != null) {
|
|
199
|
+
updates.push('meta = ?'); params.push(JSON.stringify(patch.meta));
|
|
200
|
+
}
|
|
201
|
+
if (updates.length === 0) return this.get(id);
|
|
202
|
+
|
|
203
|
+
updates.push('updated_at = ?'); params.push(now);
|
|
204
|
+
params.push(id);
|
|
205
|
+
await this.sqlite.exec(
|
|
206
|
+
`UPDATE task_steps SET ${updates.join(', ')} WHERE id = ?`,
|
|
207
|
+
params
|
|
208
|
+
);
|
|
209
|
+
return this.get(id);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 删除步骤。
|
|
214
|
+
* @param {string} id
|
|
215
|
+
*/
|
|
216
|
+
async delete(id) {
|
|
217
|
+
await this._init();
|
|
218
|
+
await this.sqlite.exec('DELETE FROM task_steps WHERE id = ?', [id]);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 删除某任务的所有步骤。
|
|
224
|
+
* @param {string} taskId
|
|
225
|
+
*/
|
|
226
|
+
async deleteByTask(taskId) {
|
|
227
|
+
await this._init();
|
|
228
|
+
await this.sqlite.exec('DELETE FROM task_steps WHERE task_id = ?', [taskId]);
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 任务步骤统计(各状态数量)。
|
|
234
|
+
* @param {string} taskId
|
|
235
|
+
* @returns {Promise<object>} { total, pending, running, completed, error, skipped }
|
|
236
|
+
*/
|
|
237
|
+
async stats(taskId) {
|
|
238
|
+
await this._init();
|
|
239
|
+
const rows = await this.sqlite.all(
|
|
240
|
+
`SELECT status, COUNT(*) AS cnt FROM task_steps WHERE task_id = ? GROUP BY status`,
|
|
241
|
+
[taskId]
|
|
242
|
+
);
|
|
243
|
+
const result = { total: 0, pending: 0, running: 0, completed: 0, error: 0, skipped: 0 };
|
|
244
|
+
for (const r of rows) {
|
|
245
|
+
result[r.status] = r.cnt;
|
|
246
|
+
result.total += r.cnt;
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ─── 内部:行 → 业务对象(解包 JSON 字段,转驼峰)──────────────────────────
|
|
252
|
+
|
|
253
|
+
_rowToObj(row) {
|
|
254
|
+
return {
|
|
255
|
+
id: row.id,
|
|
256
|
+
taskId: row.task_id,
|
|
257
|
+
seq: row.seq,
|
|
258
|
+
name: row.name,
|
|
259
|
+
type: row.type,
|
|
260
|
+
status: row.status,
|
|
261
|
+
input: this._parseJson(row.input),
|
|
262
|
+
output: this._parseJson(row.output),
|
|
263
|
+
error: row.error,
|
|
264
|
+
startedAt: row.started_at,
|
|
265
|
+
finishedAt: row.finished_at,
|
|
266
|
+
durationMs: row.duration_ms,
|
|
267
|
+
createdAt: row.created_at,
|
|
268
|
+
updatedAt: row.updated_at,
|
|
269
|
+
meta: this._parseJson(row.meta)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
_parseJson(s) {
|
|
274
|
+
if (!s) return null;
|
|
275
|
+
try { return JSON.parse(s); } catch { return s; }
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export default TaskStepStore;
|