@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,775 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestCheck —— 任务准出校验引擎
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* - 在 Orchestrator 所有步骤执行完成后,对最终产物进行验收审核
|
|
6
|
+
* - 通过 Agent 选择合适的 SKILL,执行准出检查
|
|
7
|
+
* - 对比 Brain 生成的任务级验收标准,判断是否满足准出条件
|
|
8
|
+
* - 产出结构化的审核结论(通过/未通过 + 逐条标准评估 + 改进建议)
|
|
9
|
+
* - 支持审核结果持久化,供 LoopEngine 决定是否触发大循环
|
|
10
|
+
*
|
|
11
|
+
* 架构角色(Loop Engineering 大循环):
|
|
12
|
+
* Brain(拆解/重规划)→ Orchestrator(编排)→ FlexRunner(执行)→ TestCheck(准出审核)
|
|
13
|
+
* │
|
|
14
|
+
* 未通过 ──→ 回到 Brain 重新生成目标
|
|
15
|
+
*
|
|
16
|
+
* 设计原则:
|
|
17
|
+
* - 高内聚:所有准出审核逻辑集中于此,不感知 HTTP 层和编排细节
|
|
18
|
+
* - 低耦合:依赖注入 LLMClient / SkillSelector / CLIController / Storage
|
|
19
|
+
* - 可扩展:审核策略通过 Skill 调用实现,新增审核能力只需新增 Skill
|
|
20
|
+
* - 复用 FlexRunner 的执行模式(matchSkill → invokeSkill → checkResult)
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
import fs from 'node:fs/promises';
|
|
26
|
+
|
|
27
|
+
import { LLMClient } from '../Agent/SkillSelector/llm/llmClient.js';
|
|
28
|
+
import { nowCST } from '../library/cstTime.js';
|
|
29
|
+
import { createStorage } from '../DbUse/index.js';
|
|
30
|
+
|
|
31
|
+
// 惰性加载 FlexRunner 的依赖(CLIController / SkillSelectorAgent),
|
|
32
|
+
// 与 FlexRunner 同样的惰性加载策略,避免测试时拉入重依赖。
|
|
33
|
+
let _CLIController = null;
|
|
34
|
+
let _SkillSelectorAgent = null;
|
|
35
|
+
|
|
36
|
+
async function _loadCLIController() {
|
|
37
|
+
if (!_CLIController) {
|
|
38
|
+
const mod = await import('../CLI/cli.js');
|
|
39
|
+
_CLIController = mod.CLIController;
|
|
40
|
+
}
|
|
41
|
+
return _CLIController;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function _loadSkillSelectorAgent() {
|
|
45
|
+
if (!_SkillSelectorAgent) {
|
|
46
|
+
const mod = await import('../Agent/SkillSelector/index.js');
|
|
47
|
+
_SkillSelectorAgent = mod.Agent;
|
|
48
|
+
}
|
|
49
|
+
return _SkillSelectorAgent;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ─── 常量 ────────────────────────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
/** TestCheck 审核状态 */
|
|
55
|
+
export const CheckStatus = Object.freeze({
|
|
56
|
+
IDLE: 'idle',
|
|
57
|
+
MATCHING: 'matching', // 正在匹配审核 Skill
|
|
58
|
+
EXECUTING: 'executing', // 正在执行审核
|
|
59
|
+
EVALUATING: 'evaluating', // 正在评估准出条件
|
|
60
|
+
PASSED: 'passed', // 准出通过
|
|
61
|
+
FAILED: 'failed', // 准出未通过
|
|
62
|
+
ERROR: 'error' // 审核过程出错
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** SSE 事件类型 */
|
|
66
|
+
const SSE_EVENT = Object.freeze({
|
|
67
|
+
CHECK_START: 'testcheck:start',
|
|
68
|
+
CHECK_MATCH: 'testcheck:match',
|
|
69
|
+
CHECK_EXECUTE: 'testcheck:execute',
|
|
70
|
+
CHECK_EVALUATE: 'testcheck:evaluate',
|
|
71
|
+
CHECK_RESULT: 'testcheck:result',
|
|
72
|
+
CHECK_ERROR: 'testcheck:error'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/** 轮询间隔(ms),等待审核 Skill 执行完成 */
|
|
76
|
+
const POLL_INTERVAL_MS = 3000;
|
|
77
|
+
|
|
78
|
+
/** 轮询超时(ms),审核最多等待 30 分钟 */
|
|
79
|
+
const POLL_TIMEOUT_MS = 30 * 60 * 1000;
|
|
80
|
+
|
|
81
|
+
// ─── TestCheck 类 ────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* TestCheck —— 准出审核引擎
|
|
85
|
+
*/
|
|
86
|
+
class TestCheck {
|
|
87
|
+
/**
|
|
88
|
+
* @param {object} [deps] - 依赖注入
|
|
89
|
+
* @param {LLMClient} [deps.llm] - LLM 客户端(复用 SkillSelector 的 LLMClient)
|
|
90
|
+
* @param {object} [deps.storage] - 存储门面(createStorage() 返回值)
|
|
91
|
+
* @param {object} [deps.sseHub] - SseHub 实例(可选,用于推送审核进度)
|
|
92
|
+
* @param {object} [deps.cli] - CLIController 实例(可选,用于执行 Skill)
|
|
93
|
+
* @param {object} [deps.skillSelector] - SkillSelectorAgent 实例(可选,用于匹配 Skill)
|
|
94
|
+
* @param {string} [deps.skillDirectory] - SKILL 目录路径(默认 Server/Skills)
|
|
95
|
+
*/
|
|
96
|
+
constructor(deps = {}) {
|
|
97
|
+
this.llm = deps.llm || new LLMClient();
|
|
98
|
+
this.storage = deps.storage || createStorage();
|
|
99
|
+
this.sseHub = deps.sseHub || null;
|
|
100
|
+
this.cli = deps.cli || null;
|
|
101
|
+
this.skillSelector = deps.skillSelector || null;
|
|
102
|
+
|
|
103
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
104
|
+
this.skillDirectory = deps.skillDirectory ||
|
|
105
|
+
path.resolve(__dirname, '..', 'Skills');
|
|
106
|
+
|
|
107
|
+
/** @type {CheckStatus} */
|
|
108
|
+
this._status = CheckStatus.IDLE;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ─── 属性访问 ──────────────────────────────────────────────────────
|
|
112
|
+
|
|
113
|
+
/** @returns {CheckStatus} */
|
|
114
|
+
get status() {
|
|
115
|
+
return this._status;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ─── SSE 推送辅助 ──────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 推送审核进度事件。
|
|
122
|
+
* @param {string} channel - SSE 频道(通常为 taskId)
|
|
123
|
+
* @param {string} eventType - 事件类型
|
|
124
|
+
* @param {object} data - 事件数据
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
_emit(channel, eventType, data) {
|
|
128
|
+
if (this.sseHub) {
|
|
129
|
+
this.sseHub.emit(channel, eventType, data);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ─── 惰性加载依赖 ──────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 获取 CLIController 实例(懒加载)。
|
|
137
|
+
* @returns {Promise<object>}
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
async _getCli() {
|
|
141
|
+
if (!this.cli) {
|
|
142
|
+
const CLIController = await _loadCLIController();
|
|
143
|
+
this.cli = new CLIController('opencode', {});
|
|
144
|
+
}
|
|
145
|
+
return this.cli;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 获取 SkillSelectorAgent 实例(懒加载)。
|
|
150
|
+
* @returns {Promise<object>}
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
async _getSkillSelector() {
|
|
154
|
+
if (!this.skillSelector) {
|
|
155
|
+
const SkillSelectorAgent = await _loadSkillSelectorAgent();
|
|
156
|
+
this.skillSelector = new SkillSelectorAgent();
|
|
157
|
+
}
|
|
158
|
+
return this.skillSelector;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ─── 核心方法 ──────────────────────────────────────────────────────
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 执行准出审核 — 对任务最终产物进行验收检查。
|
|
165
|
+
*
|
|
166
|
+
* 流程:
|
|
167
|
+
* 1. MATCHING — 基于"准出审核"语义匹配最佳审核 Skill
|
|
168
|
+
* 2. EXECUTING — 通过 CLI 执行审核 Skill,生成审核报告文件
|
|
169
|
+
* 3. EVALUATING — LLM 评估审核报告,逐条判断验收标准是否满足
|
|
170
|
+
* 4. 产出 CheckResult(通过/未通过 + 逐条评估 + 改进建议)
|
|
171
|
+
*
|
|
172
|
+
* @param {object} params - 审核参数
|
|
173
|
+
* @param {string} params.taskId - 任务 ID(必填)
|
|
174
|
+
* @param {string} params.taskDir - 工作目录
|
|
175
|
+
* @param {string} [params.taskDescription] - 原始任务描述
|
|
176
|
+
* @param {Array} [params.acceptanceCriteria] - 任务级验收标准(Brain 生成)
|
|
177
|
+
* @param {object} [params.orchestratorResult] - Orchestrator 执行结果摘要
|
|
178
|
+
* @param {number} [params.loopCount=0] - 当前大循环次数
|
|
179
|
+
* @param {string} [params.skillDirectory] - 覆盖 SKILL 目录
|
|
180
|
+
* @param {() => boolean} [params.isAborted] - 终止信号回调(返回 true 时审核轮询抛终止退出)
|
|
181
|
+
* @param {(sessionId: string) => void} [params.onSessionCreated] - Session 创建回调(供上层登记远程中止)
|
|
182
|
+
* @returns {Promise<CheckResult>}
|
|
183
|
+
*/
|
|
184
|
+
async runCheck(params = {}) {
|
|
185
|
+
const {
|
|
186
|
+
taskId,
|
|
187
|
+
taskDir,
|
|
188
|
+
taskDescription = '',
|
|
189
|
+
acceptanceCriteria = [],
|
|
190
|
+
orchestratorResult = null,
|
|
191
|
+
loopCount = 0,
|
|
192
|
+
isAborted = null,
|
|
193
|
+
onSessionCreated = null
|
|
194
|
+
} = params;
|
|
195
|
+
|
|
196
|
+
// 终止信号:审核过程中各环节检查,置位时抛终止退出
|
|
197
|
+
const abortSignal = {
|
|
198
|
+
isAborted: typeof isAborted === 'function' ? isAborted : null,
|
|
199
|
+
onSessionCreated: typeof onSessionCreated === 'function' ? onSessionCreated : null
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
if (!taskId) {
|
|
203
|
+
throw new Error('TestCheck.runCheck: taskId 为必填项');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const skillDir = params.skillDirectory || this.skillDirectory;
|
|
207
|
+
const workDir = taskDir || path.resolve(this.storage.manager.rootDir, 'task', taskId);
|
|
208
|
+
|
|
209
|
+
const channel = taskId;
|
|
210
|
+
const checkId = _generateCheckId(taskId, loopCount);
|
|
211
|
+
const startTime = nowCST();
|
|
212
|
+
|
|
213
|
+
this._status = CheckStatus.MATCHING;
|
|
214
|
+
this._emit(channel, SSE_EVENT.CHECK_START, {
|
|
215
|
+
checkId, taskId, loopCount, startTime,
|
|
216
|
+
acceptanceCriteriaCount: acceptanceCriteria.length
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
/** @type {CheckResult} */
|
|
220
|
+
const result = {
|
|
221
|
+
checkId,
|
|
222
|
+
taskId,
|
|
223
|
+
loopCount,
|
|
224
|
+
taskDescription,
|
|
225
|
+
acceptanceCriteria,
|
|
226
|
+
orchestratorResult,
|
|
227
|
+
startTime,
|
|
228
|
+
endTime: null,
|
|
229
|
+
status: CheckStatus.IDLE,
|
|
230
|
+
passed: false,
|
|
231
|
+
matchedSkillDir: '',
|
|
232
|
+
checkReportPath: '',
|
|
233
|
+
sessionId: '',
|
|
234
|
+
criteriaResults: [],
|
|
235
|
+
summary: '',
|
|
236
|
+
improvementSuggestions: [],
|
|
237
|
+
error: null
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
// ─── 步骤 1:匹配审核 Skill ───
|
|
242
|
+
const checkTaskDescription = this._buildCheckTaskDescription(
|
|
243
|
+
taskDescription, acceptanceCriteria, orchestratorResult
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
this._status = CheckStatus.MATCHING;
|
|
247
|
+
const matchedSkillDir = await this._matchSkill(checkTaskDescription, skillDir);
|
|
248
|
+
result.matchedSkillDir = matchedSkillDir;
|
|
249
|
+
this._emit(channel, SSE_EVENT.CHECK_MATCH, { checkId, matchedSkillDir });
|
|
250
|
+
|
|
251
|
+
// ─── 步骤 2:执行审核 Skill ───
|
|
252
|
+
this._status = CheckStatus.EXECUTING;
|
|
253
|
+
const reportPath = path.join(workDir, `testcheck_loop${loopCount}_result.md`);
|
|
254
|
+
const summaryPath = path.join(workDir, `testcheck_loop${loopCount}_Summary.md`);
|
|
255
|
+
|
|
256
|
+
const { sessionId, executed } = await this._invokeSkill({
|
|
257
|
+
taskDescription: checkTaskDescription,
|
|
258
|
+
skillDir: matchedSkillDir,
|
|
259
|
+
reportPath,
|
|
260
|
+
summaryPath,
|
|
261
|
+
workDir,
|
|
262
|
+
loopCount,
|
|
263
|
+
abortSignal
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
result.sessionId = sessionId;
|
|
267
|
+
result.checkReportPath = reportPath;
|
|
268
|
+
this._emit(channel, SSE_EVENT.CHECK_EXECUTE, { checkId, sessionId, reportPath, executed });
|
|
269
|
+
|
|
270
|
+
if (!executed) {
|
|
271
|
+
throw new Error('审核 Skill 执行失败,未生成审核报告');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ─── 步骤 3:评估准出条件 ───
|
|
275
|
+
this._status = CheckStatus.EVALUATING;
|
|
276
|
+
const evaluation = await this._evaluateAcceptance({
|
|
277
|
+
reportPath,
|
|
278
|
+
acceptanceCriteria,
|
|
279
|
+
taskDescription,
|
|
280
|
+
orchestratorResult,
|
|
281
|
+
loopCount
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
result.criteriaResults = evaluation.criteriaResults;
|
|
285
|
+
result.passed = evaluation.passed;
|
|
286
|
+
result.summary = evaluation.summary;
|
|
287
|
+
result.improvementSuggestions = evaluation.improvementSuggestions;
|
|
288
|
+
result.status = evaluation.passed ? CheckStatus.PASSED : CheckStatus.FAILED;
|
|
289
|
+
|
|
290
|
+
this._emit(channel, SSE_EVENT.CHECK_EVALUATE, {
|
|
291
|
+
checkId,
|
|
292
|
+
passed: result.passed,
|
|
293
|
+
criteriaResults: result.criteriaResults
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
} catch (err) {
|
|
297
|
+
result.status = CheckStatus.ERROR;
|
|
298
|
+
result.error = err.message;
|
|
299
|
+
this._status = CheckStatus.ERROR;
|
|
300
|
+
this._emit(channel, SSE_EVENT.CHECK_ERROR, { checkId, error: err.message });
|
|
301
|
+
this._log('error', `审核异常: ${err.message}`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
result.endTime = nowCST();
|
|
305
|
+
this._status = result.status;
|
|
306
|
+
|
|
307
|
+
// ─── 持久化审核结果 ───
|
|
308
|
+
await this._persistCheckResult(taskId, result);
|
|
309
|
+
|
|
310
|
+
this._emit(channel, SSE_EVENT.CHECK_RESULT, {
|
|
311
|
+
checkId,
|
|
312
|
+
passed: result.passed,
|
|
313
|
+
status: result.status,
|
|
314
|
+
summary: result.summary
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
this._log('info', `── 准出审核结束: passed=${result.passed}, loop=${loopCount} ──`);
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// ─── 内部:Skill 匹配 ──────────────────────────────────────────────
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 匹配审核 Skill — 基于准出审核语义选择最佳 Skill。
|
|
325
|
+
*
|
|
326
|
+
* @param {string} checkTaskDescription - 审核任务描述
|
|
327
|
+
* @param {string} skillDirectory - SKILL 目录
|
|
328
|
+
* @returns {Promise<string>} 匹配到的 SKILL 目录绝对路径
|
|
329
|
+
* @private
|
|
330
|
+
*/
|
|
331
|
+
async _matchSkill(checkTaskDescription, skillDirectory) {
|
|
332
|
+
if (!checkTaskDescription) {
|
|
333
|
+
throw new Error('TestCheck._matchSkill: 审核任务描述不能为空');
|
|
334
|
+
}
|
|
335
|
+
if (!skillDirectory) {
|
|
336
|
+
throw new Error('TestCheck._matchSkill: skillDirectory 不能为空');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
this._log('info', `matchSkill 开始 — 审核任务: "${checkTaskDescription.slice(0, 80)}…"`);
|
|
340
|
+
|
|
341
|
+
const selector = await this._getSkillSelector();
|
|
342
|
+
const selection = await selector.selectSkill(checkTaskDescription, skillDirectory);
|
|
343
|
+
|
|
344
|
+
if (!selection || !selection.best) {
|
|
345
|
+
throw new Error('TestCheck._matchSkill: 未匹配到任何合适的审核 Skill');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const bestDir = selection.skillPath || selection.best.skillPath;
|
|
349
|
+
if (!bestDir) {
|
|
350
|
+
throw new Error('TestCheck._matchSkill: 匹配结果缺少 Skill 目录路径');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
this._log('info', `matchSkill 完成 — 最佳审核 Skill: ${selection.best.name} (${bestDir})`);
|
|
354
|
+
return bestDir;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* 构建准出审核的任务描述 — 供 Skill 匹配器使用。
|
|
359
|
+
*
|
|
360
|
+
* @param {string} taskDescription - 原始任务描述
|
|
361
|
+
* @param {Array} acceptanceCriteria - 验收标准
|
|
362
|
+
* @param {object} orchestratorResult - 编排结果
|
|
363
|
+
* @returns {string}
|
|
364
|
+
* @private
|
|
365
|
+
*/
|
|
366
|
+
_buildCheckTaskDescription(taskDescription, acceptanceCriteria, orchestratorResult) {
|
|
367
|
+
const parts = [
|
|
368
|
+
'对任务执行结果进行准出审核(验收测试)',
|
|
369
|
+
`原始任务: ${taskDescription}`
|
|
370
|
+
];
|
|
371
|
+
|
|
372
|
+
if (acceptanceCriteria && acceptanceCriteria.length > 0) {
|
|
373
|
+
const criteriaText = acceptanceCriteria
|
|
374
|
+
.map(c => `- [${c.id}] (${c.type}) ${c.criterion}`)
|
|
375
|
+
.join('\n');
|
|
376
|
+
parts.push(`验收标准:\n${criteriaText}`);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (orchestratorResult) {
|
|
380
|
+
parts.push(`编排状态: ${orchestratorResult.status || 'unknown'}`);
|
|
381
|
+
if (orchestratorResult.stats) {
|
|
382
|
+
parts.push(`步骤统计: ${JSON.stringify(orchestratorResult.stats)}`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
parts.push('检查任务产物是否满足所有验收标准,生成准出审核报告');
|
|
387
|
+
return parts.join('\n');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// ─── 内部:Skill 执行 ──────────────────────────────────────────────
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 调用 CLI 执行审核 Skill。
|
|
394
|
+
*
|
|
395
|
+
* 流程:
|
|
396
|
+
* 1. 健康检查
|
|
397
|
+
* 2. 构建 prompt(任务描述 + 验收标准 + 产物路径 + 报告路径)
|
|
398
|
+
* 3. 创建 Session 并发送 prompt
|
|
399
|
+
* 4. 轮询等待完成
|
|
400
|
+
*
|
|
401
|
+
* @param {object} opts
|
|
402
|
+
* @param {string} opts.taskDescription
|
|
403
|
+
* @param {string} opts.skillDir
|
|
404
|
+
* @param {string} opts.reportPath
|
|
405
|
+
* @param {string} opts.summaryPath
|
|
406
|
+
* @param {string} opts.workDir
|
|
407
|
+
* @param {number} opts.loopCount
|
|
408
|
+
* @param {object} [opts.abortSignal] - 终止信号 { isAborted, onSessionCreated }(LoopEngine 注入)
|
|
409
|
+
* @returns {Promise<{sessionId: string, executed: boolean}>}
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
async _invokeSkill({ taskDescription, skillDir, reportPath, summaryPath, workDir, loopCount, abortSignal }) {
|
|
413
|
+
const cli = await this._getCli();
|
|
414
|
+
|
|
415
|
+
this._log('info', `invokeSkill 开始 — skillDir: ${skillDir}`);
|
|
416
|
+
|
|
417
|
+
// 健康检查
|
|
418
|
+
const health = await cli.checkHealth();
|
|
419
|
+
if (health.status !== 'ok') {
|
|
420
|
+
this._log('error', `opencode 服务不可用: ${health.message}`);
|
|
421
|
+
return { sessionId: '', executed: false };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// 构建 prompt
|
|
425
|
+
const title = `testcheck|task=${workDir.split('/').pop()}|loop=${loopCount}`;
|
|
426
|
+
const prompt = this._buildPrompt(taskDescription, skillDir, reportPath, summaryPath, workDir);
|
|
427
|
+
|
|
428
|
+
// 创建 Session(指定工作目录为 workDir,确保 opencode session 的文件操作在任务目录下执行)
|
|
429
|
+
// const { sessionId } = await cli.startSession(title, prompt, { cwd: workDir });
|
|
430
|
+
const { sessionId } = await cli.startSession(title, prompt);
|
|
431
|
+
this._log('info', `审核 Session 已创建: ${sessionId}`);
|
|
432
|
+
|
|
433
|
+
// 通知上层登记 sessionId(abortLoop 可据此远程中止)
|
|
434
|
+
if (abortSignal && typeof abortSignal.onSessionCreated === 'function') {
|
|
435
|
+
try {
|
|
436
|
+
abortSignal.onSessionCreated(sessionId);
|
|
437
|
+
} catch { /* 回调异常不影响主流程 */ }
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Session 创建后终止标志已置位 → 立即中止并退出
|
|
441
|
+
if (abortSignal && typeof abortSignal.isAborted === 'function' && abortSignal.isAborted()) {
|
|
442
|
+
try {
|
|
443
|
+
await cli.abortSession(sessionId);
|
|
444
|
+
} catch { /* 已自然结束 */ }
|
|
445
|
+
throw new Error('审核被终止(Session 创建后即中止)');
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// 轮询等待完成
|
|
449
|
+
const completed = await this._pollSession(cli, sessionId, abortSignal);
|
|
450
|
+
if (!completed) {
|
|
451
|
+
this._log('warn', `审核 Session ${sessionId} 未在超时时间内完成`);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
this._log('info', `invokeSkill 完成 — sessionId: ${sessionId}, completed: ${completed}`);
|
|
455
|
+
return { sessionId, executed: completed };
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* 构建审核 prompt。
|
|
460
|
+
*
|
|
461
|
+
* @param {string} taskDescription
|
|
462
|
+
* @param {string} skillDir
|
|
463
|
+
* @param {string} reportPath
|
|
464
|
+
* @param {string} summaryPath
|
|
465
|
+
* @param {string} workDir
|
|
466
|
+
* @returns {string}
|
|
467
|
+
* @private
|
|
468
|
+
*/
|
|
469
|
+
_buildPrompt(taskDescription, skillDir, reportPath, summaryPath, workDir) {
|
|
470
|
+
const parts = [
|
|
471
|
+
`## 审核任务描述\n${taskDescription}`,
|
|
472
|
+
`## SKILL 目录\n${skillDir}`,
|
|
473
|
+
`## 工作目录\n${workDir}`,
|
|
474
|
+
`## 审核报告输出路径\n${reportPath}`,
|
|
475
|
+
`## 审核摘要输出路径\n${summaryPath}`,
|
|
476
|
+
'请按照 SKILL 中的指令执行准出审核任务。',
|
|
477
|
+
'审核完成后,请将审核结果写入上述"审核报告输出路径",并在"审核摘要输出路径"写入摘要。',
|
|
478
|
+
'审核报告需包含 `## 准出结论` 字段(值为 `通过` 或 `未通过`),用于判断审核结果。',
|
|
479
|
+
'审核报告需逐条列出每个验收标准的评估结论(满足/未满足)及证据。'
|
|
480
|
+
];
|
|
481
|
+
return parts.join('\n\n');
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* 轮询 Session 状态直到完成或超时。
|
|
486
|
+
*
|
|
487
|
+
* @param {object} cli - CLIController 实例
|
|
488
|
+
* @param {string} sessionId - 会话 ID
|
|
489
|
+
* @param {object} [abortSignal] - 终止信号 { isAborted: () => boolean };
|
|
490
|
+
* 置位时在下一轮询周期远程中止 session 并抛终止退出
|
|
491
|
+
* @returns {Promise<boolean>}
|
|
492
|
+
* @private
|
|
493
|
+
*/
|
|
494
|
+
async _pollSession(cli, sessionId, abortSignal = null) {
|
|
495
|
+
const deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
496
|
+
|
|
497
|
+
while (Date.now() < deadline) {
|
|
498
|
+
// 终止检查:比超时检查优先,确保终止请求即时生效
|
|
499
|
+
if (abortSignal && typeof abortSignal.isAborted === 'function' && abortSignal.isAborted()) {
|
|
500
|
+
try {
|
|
501
|
+
await cli.abortSession(sessionId);
|
|
502
|
+
} catch { /* 已自然结束 */ }
|
|
503
|
+
this._log('warn', `审核 Session ${sessionId} 被终止`);
|
|
504
|
+
throw new Error('审核被终止');
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
await this._sleep(POLL_INTERVAL_MS);
|
|
508
|
+
try {
|
|
509
|
+
const { status } = await cli.checkSessionStatus(sessionId);
|
|
510
|
+
if (status === 'completed') {
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
513
|
+
} catch (err) {
|
|
514
|
+
this._log('warn', `轮询审核 Session 状态失败: ${err.message}`);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// ─── 内部:准出评估 ────────────────────────────────────────────────
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* 评估准出条件 — LLM 审核报告对照验收标准逐条判断。
|
|
524
|
+
*
|
|
525
|
+
* 读取审核报告文件,调用 LLM 对照任务级验收标准进行结构化评估:
|
|
526
|
+
* - 逐条判断每个验收标准是否满足
|
|
527
|
+
* - 汇总结论(全部满足=通过,任一未满足=未通过)
|
|
528
|
+
* - 生成改进建议(未通过时)
|
|
529
|
+
*
|
|
530
|
+
* @param {object} opts
|
|
531
|
+
* @param {string} opts.reportPath - 审核报告文件路径
|
|
532
|
+
* @param {Array} opts.acceptanceCriteria - 任务级验收标准
|
|
533
|
+
* @param {string} opts.taskDescription - 原始任务描述
|
|
534
|
+
* @param {object} opts.orchestratorResult - 编排结果
|
|
535
|
+
* @param {number} opts.loopCount - 当前循环次数
|
|
536
|
+
* @returns {Promise<{passed: boolean, criteriaResults: Array, summary: string, improvementSuggestions: Array}>}
|
|
537
|
+
* @private
|
|
538
|
+
*/
|
|
539
|
+
async _evaluateAcceptance({ reportPath, acceptanceCriteria, taskDescription, loopCount }) {
|
|
540
|
+
// 读取审核报告
|
|
541
|
+
let reportContent = '';
|
|
542
|
+
try {
|
|
543
|
+
reportContent = await fs.readFile(reportPath, 'utf-8');
|
|
544
|
+
} catch (err) {
|
|
545
|
+
this._log('warn', `读取审核报告失败: ${reportPath} — ${err.message}`);
|
|
546
|
+
// 报告不存在时,仍尝试基于验收标准做基本评估
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// 快速检查:报告中是否包含明确的准出结论
|
|
550
|
+
const quickMatch = reportContent.match(/##\s*准出结论\s*\n\s*(通过|未通过)/i);
|
|
551
|
+
if (quickMatch) {
|
|
552
|
+
const quickPassed = quickMatch[1] === '通过';
|
|
553
|
+
this._log('info', `快速判断准出结论: ${quickMatch[1]}`);
|
|
554
|
+
// 仍调用 LLM 做详细评估,但快速结论作为 fallback
|
|
555
|
+
const fallback = {
|
|
556
|
+
passed: quickPassed,
|
|
557
|
+
criteriaResults: acceptanceCriteria.map(c => ({
|
|
558
|
+
id: c.id,
|
|
559
|
+
criterion: c.criterion,
|
|
560
|
+
satisfied: quickPassed,
|
|
561
|
+
evidence: '基于审核报告准出结论',
|
|
562
|
+
note: quickPassed ? '满足' : '未满足'
|
|
563
|
+
})),
|
|
564
|
+
summary: quickPassed ? '所有验收标准已满足' : '存在未满足的验收标准',
|
|
565
|
+
improvementSuggestions: quickPassed ? [] : ['请根据审核报告中的问题进行修复']
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// 尝试 LLM 详细评估,失败则用 fallback
|
|
569
|
+
try {
|
|
570
|
+
return await this._llmEvaluate(reportContent, acceptanceCriteria, taskDescription, loopCount);
|
|
571
|
+
} catch (err) {
|
|
572
|
+
this._log('warn', `LLM 评估失败,使用快速判断 fallback: ${err.message}`);
|
|
573
|
+
return fallback;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// 无快速结论时,直接调用 LLM 评估
|
|
578
|
+
return await this._llmEvaluate(reportContent, acceptanceCriteria, taskDescription, loopCount);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* 调用 LLM 进行结构化准出评估。
|
|
583
|
+
*
|
|
584
|
+
* @param {string} reportContent - 审核报告内容
|
|
585
|
+
* @param {Array} acceptanceCriteria - 验收标准
|
|
586
|
+
* @param {string} taskDescription - 任务描述
|
|
587
|
+
* @param {number} loopCount - 循环次数
|
|
588
|
+
* @returns {Promise<{passed: boolean, criteriaResults: Array, summary: string, improvementSuggestions: Array}>}
|
|
589
|
+
* @private
|
|
590
|
+
*/
|
|
591
|
+
async _llmEvaluate(reportContent, acceptanceCriteria, taskDescription, loopCount) {
|
|
592
|
+
const criteriaText = (acceptanceCriteria || [])
|
|
593
|
+
.map(c => `- [${c.id}] (${c.type}) ${c.criterion}\n 验证方式: ${c.verification}`)
|
|
594
|
+
.join('\n');
|
|
595
|
+
|
|
596
|
+
const prompt = `你是一个准出审核专家。请根据审核报告内容,逐条评估任务级验收标准是否满足。
|
|
597
|
+
|
|
598
|
+
## 原始任务描述
|
|
599
|
+
${taskDescription || '(未提供)'}
|
|
600
|
+
|
|
601
|
+
## 任务级验收标准
|
|
602
|
+
${criteriaText || '(未提供验收标准,请根据审核报告整体判断)'}
|
|
603
|
+
|
|
604
|
+
## 审核报告内容
|
|
605
|
+
${reportContent || '(审核报告为空,无法判断)'}
|
|
606
|
+
|
|
607
|
+
## 当前循环次数
|
|
608
|
+
第 ${loopCount + 1} 次循环
|
|
609
|
+
|
|
610
|
+
## 输出要求
|
|
611
|
+
请以 JSON 格式返回,包含以下字段:
|
|
612
|
+
{
|
|
613
|
+
"passed": true/false,
|
|
614
|
+
"criteriaResults": [
|
|
615
|
+
{
|
|
616
|
+
"id": "ac1",
|
|
617
|
+
"criterion": "验收标准描述",
|
|
618
|
+
"satisfied": true/false,
|
|
619
|
+
"evidence": "审核报告中支持该结论的证据或分析",
|
|
620
|
+
"note": "补充说明"
|
|
621
|
+
}
|
|
622
|
+
],
|
|
623
|
+
"summary": "整体审核结论摘要(一段话)",
|
|
624
|
+
"improvementSuggestions": [
|
|
625
|
+
"针对未满足标准的改进建议(仅在未通过时提供)"
|
|
626
|
+
]
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
### 评估规则
|
|
630
|
+
1. 如果审核报告为空或无法获取有效信息,passed 应为 false
|
|
631
|
+
2. criteriaResults 必须覆盖所有任务级验收标准
|
|
632
|
+
3. 每条标准的 satisfied 字段必须基于审核报告中的证据
|
|
633
|
+
4. 如果所有标准都 satisfied=true,则 passed=true
|
|
634
|
+
5. 如果任一标准 satisfied=false,则 passed=false
|
|
635
|
+
6. improvementSuggestions 仅在 passed=false 时提供,针对未满足的标准给出具体改进建议
|
|
636
|
+
7. summary 应概括整体审核结论,包括通过/未通过的原因
|
|
637
|
+
|
|
638
|
+
注意:只返回 JSON,不要包含其他文字。`;
|
|
639
|
+
|
|
640
|
+
const result = await this.llm.chatJSON(prompt, { maxTokens: 4096 });
|
|
641
|
+
|
|
642
|
+
return {
|
|
643
|
+
passed: Boolean(result.passed),
|
|
644
|
+
criteriaResults: Array.isArray(result.criteriaResults)
|
|
645
|
+
? result.criteriaResults.map((c, idx) => ({
|
|
646
|
+
id: c.id || (acceptanceCriteria[idx] ? acceptanceCriteria[idx].id : `ac${idx + 1}`),
|
|
647
|
+
criterion: c.criterion || (acceptanceCriteria[idx] ? acceptanceCriteria[idx].criterion : ''),
|
|
648
|
+
satisfied: Boolean(c.satisfied),
|
|
649
|
+
evidence: c.evidence || '',
|
|
650
|
+
note: c.note || ''
|
|
651
|
+
}))
|
|
652
|
+
: [],
|
|
653
|
+
summary: result.summary || (result.passed ? '审核通过' : '审核未通过'),
|
|
654
|
+
improvementSuggestions: Array.isArray(result.improvementSuggestions)
|
|
655
|
+
? result.improvementSuggestions
|
|
656
|
+
: []
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// ─── 内部:持久化 ──────────────────────────────────────────────────
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* 持久化审核结果到文件系统。
|
|
664
|
+
*
|
|
665
|
+
* 文件路径:db/task/{taskId}/testcheck_loop{loopCount}.json
|
|
666
|
+
*
|
|
667
|
+
* 与 Brain / Orchestrator 的持久化目录结构保持一致:
|
|
668
|
+
* db/task/{taskId}/
|
|
669
|
+
* ├── brain.json ← Brain 拆解计划(最新快照)
|
|
670
|
+
* ├── brain_loop0.json ← 各轮 Brain 计划
|
|
671
|
+
* ├── orchestration.json ← Orchestrator 编排状态(最新快照)
|
|
672
|
+
* ├── orchestration_loop0.json ← 各轮编排状态
|
|
673
|
+
* ├── stepid_1_loop0.json ← 各轮步骤执行记录
|
|
674
|
+
* ├── testcheck_loop0.json ← 第 0 次循环准出审核(本方法写入)
|
|
675
|
+
* ├── testcheck_loop1.json ← 第 1 次循环准出审核
|
|
676
|
+
* └── ...
|
|
677
|
+
*
|
|
678
|
+
* @param {string} taskId
|
|
679
|
+
* @param {CheckResult} result
|
|
680
|
+
* @private
|
|
681
|
+
*/
|
|
682
|
+
async _persistCheckResult(taskId, result) {
|
|
683
|
+
try {
|
|
684
|
+
const json = this.storage.json('task');
|
|
685
|
+
await json.write(`${taskId}/testcheck_loop${result.loopCount}`, result);
|
|
686
|
+
this._log('info', `审核结果已持久化: db/task/${taskId}/testcheck_loop${result.loopCount}.json`);
|
|
687
|
+
} catch (err) {
|
|
688
|
+
this._log('warn', `持久化审核结果失败: ${err.message}`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* 从文件系统加载历史审核结果。
|
|
694
|
+
*
|
|
695
|
+
* @param {string} taskId
|
|
696
|
+
* @param {number} loopCount
|
|
697
|
+
* @returns {Promise<CheckResult|null>}
|
|
698
|
+
*/
|
|
699
|
+
async loadCheckResult(taskId, loopCount) {
|
|
700
|
+
try {
|
|
701
|
+
const json = this.storage.json('task');
|
|
702
|
+
return await json.read(`${taskId}/testcheck_loop${loopCount}`);
|
|
703
|
+
} catch {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* 列出某个 Task 下所有审核结果。
|
|
710
|
+
*
|
|
711
|
+
* @param {string} taskId
|
|
712
|
+
* @returns {Promise<Array>}
|
|
713
|
+
*/
|
|
714
|
+
async listCheckResults(taskId) {
|
|
715
|
+
try {
|
|
716
|
+
const json = this.storage.json('task');
|
|
717
|
+
const entries = await json.list(`${taskId}/testcheck_loop`);
|
|
718
|
+
return entries
|
|
719
|
+
.filter(e => e && e.data)
|
|
720
|
+
.map(e => e.data)
|
|
721
|
+
.sort((a, b) => (a.loopCount || 0) - (b.loopCount || 0));
|
|
722
|
+
} catch {
|
|
723
|
+
return [];
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// ─── 内部工具 ──────────────────────────────────────────────────────
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Promise 版 sleep。
|
|
731
|
+
* @param {number} ms
|
|
732
|
+
* @returns {Promise<void>}
|
|
733
|
+
* @private
|
|
734
|
+
*/
|
|
735
|
+
_sleep(ms) {
|
|
736
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* 统一日志输出。
|
|
741
|
+
* @param {'info'|'warn'|'error'} level
|
|
742
|
+
* @param {string} message
|
|
743
|
+
* @private
|
|
744
|
+
*/
|
|
745
|
+
_log(level, message) {
|
|
746
|
+
const prefix = '[TestCheck]';
|
|
747
|
+
const ts = nowCST();
|
|
748
|
+
switch (level) {
|
|
749
|
+
case 'error':
|
|
750
|
+
console.error(`${ts} ${prefix} ❌ ${message}`);
|
|
751
|
+
break;
|
|
752
|
+
case 'warn':
|
|
753
|
+
console.warn(`${ts} ${prefix} ⚠ ${message}`);
|
|
754
|
+
break;
|
|
755
|
+
default:
|
|
756
|
+
console.info(`${ts} ${prefix} ℹ ${message}`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// ─── 辅助函数 ──────────────────────────────────────────────────────────────
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* 生成 checkId。
|
|
765
|
+
* @param {string} taskId
|
|
766
|
+
* @param {number} loopCount
|
|
767
|
+
* @returns {string}
|
|
768
|
+
*/
|
|
769
|
+
function _generateCheckId(taskId, loopCount) {
|
|
770
|
+
const ts = Date.now().toString(36);
|
|
771
|
+
return `check_${taskId}_loop${loopCount}_${ts}`;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export { TestCheck };
|
|
775
|
+
export default TestCheck;
|