autosnippet 3.2.21 → 3.3.2
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/dashboard/dist/assets/icons-BJ2mUBi8.js +1 -0
- package/dashboard/dist/assets/index-B659K9t5.js +128 -0
- package/dashboard/dist/assets/index-NCm40PMD.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +244 -261
- package/dist/lib/agent/context/ExplorationTracker.d.ts +2 -0
- package/dist/lib/agent/context/ExplorationTracker.js +21 -3
- package/dist/lib/agent/core/ToolExecutionPipeline.d.ts +3 -1
- package/dist/lib/agent/core/ToolExecutionPipeline.js +8 -1
- package/dist/lib/agent/forge/DynamicComposer.d.ts +58 -0
- package/dist/lib/agent/forge/DynamicComposer.js +99 -0
- package/dist/lib/agent/forge/SandboxRunner.d.ts +60 -0
- package/dist/lib/agent/forge/SandboxRunner.js +251 -0
- package/dist/lib/agent/forge/TemporaryToolRegistry.d.ts +76 -0
- package/dist/lib/agent/forge/TemporaryToolRegistry.js +154 -0
- package/dist/lib/agent/forge/ToolForge.d.ts +92 -0
- package/dist/lib/agent/forge/ToolForge.js +239 -0
- package/dist/lib/agent/forge/ToolRequirementAnalyzer.d.ts +44 -0
- package/dist/lib/agent/forge/ToolRequirementAnalyzer.js +119 -0
- package/dist/lib/agent/tools/ToolRegistry.d.ts +2 -0
- package/dist/lib/agent/tools/ToolRegistry.js +4 -0
- package/dist/lib/agent/tools/composite.js +0 -1
- package/dist/lib/agent/tools/index.d.ts +2 -50
- package/dist/lib/agent/tools/index.js +2 -3
- package/dist/lib/agent/tools/lifecycle.d.ts +1 -58
- package/dist/lib/agent/tools/lifecycle.js +2 -75
- package/dist/lib/cli/SetupService.d.ts +46 -2
- package/dist/lib/cli/SetupService.js +2 -27
- package/dist/lib/cli/deploy/FileManifest.d.ts +0 -21
- package/dist/lib/cli/deploy/FileManifest.js +0 -11
- package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.d.ts +2 -5
- package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.js +159 -44
- package/dist/lib/core/discovery/index.d.ts +1 -1
- package/dist/lib/core/discovery/index.js +2 -2
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +10 -0
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +2 -0
- package/dist/lib/domain/knowledge/Lifecycle.d.ts +19 -2
- package/dist/lib/domain/knowledge/Lifecycle.js +32 -6
- package/dist/lib/domain/knowledge/UnifiedValidator.d.ts +1 -5
- package/dist/lib/domain/knowledge/UnifiedValidator.js +7 -44
- package/dist/lib/domain/knowledge/values/Stats.d.ts +29 -0
- package/dist/lib/domain/knowledge/values/Stats.js +41 -0
- package/dist/lib/external/mcp/McpServer.d.ts +19 -38
- package/dist/lib/external/mcp/McpServer.js +145 -117
- package/dist/lib/external/mcp/autoApproveInjector.js +0 -2
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +26 -1
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +41 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +49 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +3 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +27 -0
- package/dist/lib/external/mcp/handlers/bootstrap/skills.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +1 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +2 -0
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +116 -6
- package/dist/lib/external/mcp/handlers/consolidated.js +251 -71
- package/dist/lib/external/mcp/handlers/guard.d.ts +150 -0
- package/dist/lib/external/mcp/handlers/guard.js +245 -8
- package/dist/lib/external/mcp/handlers/knowledge.d.ts +0 -29
- package/dist/lib/external/mcp/handlers/knowledge.js +1 -76
- package/dist/lib/external/mcp/handlers/panorama.d.ts +36 -0
- package/dist/lib/external/mcp/handlers/panorama.js +156 -0
- package/dist/lib/external/mcp/handlers/system.d.ts +2 -54
- package/dist/lib/external/mcp/handlers/system.js +3 -113
- package/dist/lib/external/mcp/handlers/task.d.ts +13 -24
- package/dist/lib/external/mcp/handlers/task.js +217 -557
- package/dist/lib/external/mcp/handlers/types.d.ts +91 -8
- package/dist/lib/external/mcp/handlers/types.js +18 -1
- package/dist/lib/external/mcp/handlers/wiki-external.d.ts +18 -1
- package/dist/lib/external/mcp/handlers/wiki-external.js +16 -1
- package/dist/lib/external/mcp/tools.d.ts +14 -20
- package/dist/lib/external/mcp/tools.js +62 -91
- package/dist/lib/http/HttpServer.js +52 -6
- package/dist/lib/http/routes/{snippets.d.ts → audit.d.ts} +4 -2
- package/dist/lib/http/routes/audit.js +51 -0
- package/dist/lib/http/routes/commands.d.ts +1 -1
- package/dist/lib/http/routes/commands.js +1 -66
- package/dist/lib/http/routes/guardReport.d.ts +10 -0
- package/dist/lib/http/routes/guardReport.js +143 -0
- package/dist/lib/http/routes/knowledge.js +32 -1
- package/dist/lib/http/routes/panorama.d.ts +11 -0
- package/dist/lib/http/routes/panorama.js +322 -0
- package/dist/lib/http/routes/remote.js +0 -5
- package/dist/lib/http/routes/signals.d.ts +10 -0
- package/dist/lib/http/routes/signals.js +104 -0
- package/dist/lib/http/routes/task.d.ts +2 -3
- package/dist/lib/http/routes/task.js +17 -347
- package/dist/lib/http/routes/violations.js +1 -1
- package/dist/lib/infrastructure/audit/AuditLogger.d.ts +6 -1
- package/dist/lib/infrastructure/audit/AuditLogger.js +14 -1
- package/dist/lib/infrastructure/database/drizzle/schema.d.ts +181 -583
- package/dist/lib/infrastructure/database/drizzle/schema.js +28 -69
- package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.d.ts +8 -0
- package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.js +43 -0
- package/dist/lib/infrastructure/logging/Logger.d.ts +2 -0
- package/dist/lib/infrastructure/logging/Logger.js +34 -7
- package/dist/lib/infrastructure/monitoring/ErrorTracker.js +3 -1
- package/dist/lib/infrastructure/monitoring/PerformanceMonitor.d.ts +2 -2
- package/dist/lib/infrastructure/monitoring/PerformanceMonitor.js +12 -10
- package/dist/lib/infrastructure/notification/LarkNotifier.d.ts +24 -0
- package/dist/lib/infrastructure/notification/LarkNotifier.js +97 -0
- package/dist/lib/infrastructure/report/ReportStore.d.ts +45 -0
- package/dist/lib/infrastructure/report/ReportStore.js +133 -0
- package/dist/lib/infrastructure/signal/SignalAggregator.d.ts +18 -0
- package/dist/lib/infrastructure/signal/SignalAggregator.js +84 -0
- package/dist/lib/infrastructure/signal/SignalBridge.d.ts +13 -0
- package/dist/lib/infrastructure/signal/SignalBridge.js +20 -0
- package/dist/lib/infrastructure/signal/SignalBus.d.ts +63 -0
- package/dist/lib/infrastructure/signal/SignalBus.js +106 -0
- package/dist/lib/infrastructure/signal/SignalTraceWriter.d.ts +36 -0
- package/dist/lib/infrastructure/signal/SignalTraceWriter.js +130 -0
- package/dist/lib/injection/ServiceContainer.js +6 -0
- package/dist/lib/injection/ServiceMap.d.ts +16 -19
- package/dist/lib/injection/modules/AgentModule.d.ts +1 -1
- package/dist/lib/injection/modules/AgentModule.js +7 -1
- package/dist/lib/injection/modules/AppModule.d.ts +3 -4
- package/dist/lib/injection/modules/AppModule.js +7 -43
- package/dist/lib/injection/modules/GuardModule.js +59 -2
- package/dist/lib/injection/modules/InfraModule.d.ts +0 -1
- package/dist/lib/injection/modules/InfraModule.js +9 -7
- package/dist/lib/injection/modules/KnowledgeModule.js +51 -0
- package/dist/lib/injection/modules/PanoramaModule.d.ts +18 -0
- package/dist/lib/injection/modules/PanoramaModule.js +76 -0
- package/dist/lib/injection/modules/SignalModule.d.ts +10 -0
- package/dist/lib/injection/modules/SignalModule.js +84 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +1 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +6 -0
- package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +3 -1
- package/dist/lib/service/bootstrap/BootstrapTaskManager.js +20 -1
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +4 -5
- package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +3 -1
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +13 -10
- package/dist/lib/service/delivery/RulesGenerator.js +3 -2
- package/dist/lib/service/evolution/ConsolidationAdvisor.d.ts +114 -0
- package/dist/lib/service/evolution/ConsolidationAdvisor.js +542 -0
- package/dist/lib/service/evolution/ContradictionDetector.d.ts +54 -0
- package/dist/lib/service/evolution/ContradictionDetector.js +253 -0
- package/dist/lib/service/evolution/DecayDetector.d.ts +71 -0
- package/dist/lib/service/evolution/DecayDetector.js +244 -0
- package/dist/lib/service/evolution/EnhancementSuggester.d.ts +38 -0
- package/dist/lib/service/evolution/EnhancementSuggester.js +220 -0
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +82 -0
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +167 -0
- package/dist/lib/service/evolution/RedundancyAnalyzer.d.ts +53 -0
- package/dist/lib/service/evolution/RedundancyAnalyzer.js +210 -0
- package/dist/lib/service/evolution/StagingManager.d.ts +57 -0
- package/dist/lib/service/evolution/StagingManager.js +201 -0
- package/dist/lib/service/guard/ComplianceReporter.d.ts +42 -2
- package/dist/lib/service/guard/ComplianceReporter.js +43 -5
- package/dist/lib/service/guard/CoverageAnalyzer.d.ts +54 -0
- package/dist/lib/service/guard/CoverageAnalyzer.js +149 -0
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +55 -1
- package/dist/lib/service/guard/GuardCheckEngine.js +508 -15
- package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -0
- package/dist/lib/service/guard/GuardFeedbackLoop.js +9 -0
- package/dist/lib/service/guard/ReverseGuard.d.ts +73 -0
- package/dist/lib/service/guard/ReverseGuard.js +256 -0
- package/dist/lib/service/guard/RuleLearner.d.ts +12 -0
- package/dist/lib/service/guard/RuleLearner.js +38 -0
- package/dist/lib/service/guard/UncertaintyCollector.d.ts +83 -0
- package/dist/lib/service/guard/UncertaintyCollector.js +149 -0
- package/dist/lib/service/guard/ViolationsStore.d.ts +1 -0
- package/dist/lib/service/guard/ViolationsStore.js +33 -3
- package/dist/lib/service/knowledge/ConfidenceRouter.d.ts +13 -0
- package/dist/lib/service/knowledge/ConfidenceRouter.js +14 -0
- package/dist/lib/service/knowledge/KnowledgeService.js +22 -4
- package/dist/lib/service/module/ModuleService.js +3 -13
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +27 -0
- package/dist/lib/service/panorama/CouplingAnalyzer.js +192 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +28 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.js +320 -0
- package/dist/lib/service/panorama/LayerInferrer.d.ts +19 -0
- package/dist/lib/service/panorama/LayerInferrer.js +182 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +24 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.js +185 -0
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +29 -0
- package/dist/lib/service/panorama/PanoramaAggregator.js +228 -0
- package/dist/lib/service/panorama/PanoramaScanner.d.ts +52 -0
- package/dist/lib/service/panorama/PanoramaScanner.js +188 -0
- package/dist/lib/service/panorama/PanoramaService.d.ts +108 -0
- package/dist/lib/service/panorama/PanoramaService.js +220 -0
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +134 -0
- package/dist/lib/service/panorama/PanoramaTypes.js +6 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +48 -0
- package/dist/lib/service/panorama/RoleRefiner.js +535 -0
- package/dist/lib/service/search/MultiSignalRanker.d.ts +1 -0
- package/dist/lib/service/search/MultiSignalRanker.js +16 -0
- package/dist/lib/service/search/SearchEngine.d.ts +1 -0
- package/dist/lib/service/search/SearchEngine.js +9 -1
- package/dist/lib/service/search/SearchTypes.d.ts +2 -0
- package/dist/lib/service/signal/HitRecorder.d.ts +68 -0
- package/dist/lib/service/signal/HitRecorder.js +173 -0
- package/dist/lib/service/skills/SignalCollector.d.ts +3 -1
- package/dist/lib/service/skills/SignalCollector.js +31 -1
- package/dist/lib/service/task/IntentExtractor.d.ts +58 -0
- package/dist/lib/service/task/IntentExtractor.js +142 -0
- package/dist/lib/service/task/PrimeSearchPipeline.d.ts +54 -0
- package/dist/lib/service/task/PrimeSearchPipeline.js +98 -0
- package/dist/lib/shared/constants.d.ts +0 -15
- package/dist/lib/shared/constants.js +0 -10
- package/dist/lib/shared/schemas/config.d.ts +4 -1
- package/dist/lib/shared/schemas/config.js +8 -1
- package/dist/lib/shared/schemas/mcp-tools.d.ts +41 -96
- package/dist/lib/shared/schemas/mcp-tools.js +59 -119
- package/dist/scripts/analyze-signals.d.ts +20 -0
- package/dist/scripts/analyze-signals.js +155 -0
- package/dist/scripts/diagnose-mcp.js +1 -1
- package/dist/scripts/release.js +2 -10
- package/package.json +4 -19
- package/skills/autosnippet-devdocs/SKILL.md +11 -8
- package/templates/claude-code/hooks/autosnippet-session.sh +10 -15
- package/templates/cursor-hooks/hooks/session-start.sh +1 -1
- package/templates/instructions/agent-static.md +2 -1
- package/templates/instructions/conventions.md +5 -6
- package/templates/recipes-setup/README.md +1 -2
- package/dashboard/dist/assets/icons-C1dUryS-.js +0 -1
- package/dashboard/dist/assets/index-D0whuycy.css +0 -1
- package/dashboard/dist/assets/index-DdvZE4Yd.js +0 -128
- package/dist/lib/domain/task/Task.d.ts +0 -140
- package/dist/lib/domain/task/Task.js +0 -254
- package/dist/lib/domain/task/TaskDependency.d.ts +0 -23
- package/dist/lib/domain/task/TaskDependency.js +0 -34
- package/dist/lib/domain/task/TaskIdGenerator.d.ts +0 -40
- package/dist/lib/domain/task/TaskIdGenerator.js +0 -75
- package/dist/lib/domain/task/index.d.ts +0 -4
- package/dist/lib/domain/task/index.js +0 -4
- package/dist/lib/http/routes/snippets.js +0 -49
- package/dist/lib/infrastructure/database/migrations/002_add_tasks.d.ts +0 -11
- package/dist/lib/infrastructure/database/migrations/002_add_tasks.js +0 -86
- package/dist/lib/platform/ClipboardManager.d.ts +0 -24
- package/dist/lib/platform/ClipboardManager.js +0 -142
- package/dist/lib/platform/NativeUi.d.ts +0 -53
- package/dist/lib/platform/NativeUi.js +0 -284
- package/dist/lib/platform/ios/index.d.ts +0 -38
- package/dist/lib/platform/ios/index.js +0 -42
- package/dist/lib/platform/ios/routes/spm.d.ts +0 -9
- package/dist/lib/platform/ios/routes/spm.js +0 -371
- package/dist/lib/platform/ios/snippet/PlaceholderConverter.d.ts +0 -21
- package/dist/lib/platform/ios/snippet/PlaceholderConverter.js +0 -48
- package/dist/lib/platform/ios/snippet/XcodeCodec.d.ts +0 -23
- package/dist/lib/platform/ios/snippet/XcodeCodec.js +0 -96
- package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +0 -56
- package/dist/lib/platform/ios/spm/DependencyGraph.js +0 -195
- package/dist/lib/platform/ios/spm/PackageSwiftParser.d.ts +0 -69
- package/dist/lib/platform/ios/spm/PackageSwiftParser.js +0 -231
- package/dist/lib/platform/ios/spm/PathFinder.d.ts +0 -28
- package/dist/lib/platform/ios/spm/PathFinder.js +0 -117
- package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +0 -44
- package/dist/lib/platform/ios/spm/PolicyEngine.js +0 -79
- package/dist/lib/platform/ios/spm/SpmHelper.d.ts +0 -102
- package/dist/lib/platform/ios/spm/SpmHelper.js +0 -464
- package/dist/lib/platform/ios/xcode/HeaderResolver.d.ts +0 -33
- package/dist/lib/platform/ios/xcode/HeaderResolver.js +0 -90
- package/dist/lib/platform/ios/xcode/SaveEventFilter.d.ts +0 -66
- package/dist/lib/platform/ios/xcode/SaveEventFilter.js +0 -142
- package/dist/lib/platform/ios/xcode/XcodeAutomation.d.ts +0 -71
- package/dist/lib/platform/ios/xcode/XcodeAutomation.js +0 -327
- package/dist/lib/platform/ios/xcode/XcodeImportResolver.d.ts +0 -130
- package/dist/lib/platform/ios/xcode/XcodeImportResolver.js +0 -404
- package/dist/lib/platform/ios/xcode/XcodeIntegration.d.ts +0 -89
- package/dist/lib/platform/ios/xcode/XcodeIntegration.js +0 -588
- package/dist/lib/platform/ios/xcode/XcodeWriteUtils.d.ts +0 -99
- package/dist/lib/platform/ios/xcode/XcodeWriteUtils.js +0 -190
- package/dist/lib/repository/task/TaskRepository.impl.d.ts +0 -171
- package/dist/lib/repository/task/TaskRepository.impl.js +0 -347
- package/dist/lib/service/automation/ActionPipeline.d.ts +0 -34
- package/dist/lib/service/automation/ActionPipeline.js +0 -53
- package/dist/lib/service/automation/AutomationOrchestrator.d.ts +0 -86
- package/dist/lib/service/automation/AutomationOrchestrator.js +0 -57
- package/dist/lib/service/automation/ContextCollector.d.ts +0 -24
- package/dist/lib/service/automation/ContextCollector.js +0 -35
- package/dist/lib/service/automation/DirectiveDetector.d.ts +0 -51
- package/dist/lib/service/automation/DirectiveDetector.js +0 -112
- package/dist/lib/service/automation/FileWatcher.d.ts +0 -51
- package/dist/lib/service/automation/FileWatcher.js +0 -366
- package/dist/lib/service/automation/TriggerResolver.d.ts +0 -36
- package/dist/lib/service/automation/TriggerResolver.js +0 -62
- package/dist/lib/service/automation/handlers/AlinkHandler.d.ts +0 -7
- package/dist/lib/service/automation/handlers/AlinkHandler.js +0 -80
- package/dist/lib/service/automation/handlers/CreateHandler.d.ts +0 -11
- package/dist/lib/service/automation/handlers/CreateHandler.js +0 -170
- package/dist/lib/service/automation/handlers/GuardHandler.d.ts +0 -17
- package/dist/lib/service/automation/handlers/GuardHandler.js +0 -218
- package/dist/lib/service/automation/handlers/HeaderHandler.d.ts +0 -2
- package/dist/lib/service/automation/handlers/HeaderHandler.js +0 -32
- package/dist/lib/service/automation/handlers/SearchHandler.d.ts +0 -11
- package/dist/lib/service/automation/handlers/SearchHandler.js +0 -278
- package/dist/lib/service/snippet/SnippetFactory.d.ts +0 -101
- package/dist/lib/service/snippet/SnippetFactory.js +0 -145
- package/dist/lib/service/snippet/SnippetInstaller.d.ts +0 -91
- package/dist/lib/service/snippet/SnippetInstaller.js +0 -276
- package/dist/lib/service/snippet/codecs/SnippetCodec.d.ts +0 -44
- package/dist/lib/service/snippet/codecs/SnippetCodec.js +0 -35
- package/dist/lib/service/snippet/codecs/VSCodeCodec.d.ts +0 -27
- package/dist/lib/service/snippet/codecs/VSCodeCodec.js +0 -82
- package/dist/lib/service/task/TaskGraphService.d.ts +0 -222
- package/dist/lib/service/task/TaskGraphService.js +0 -597
- package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +0 -95
- package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -298
- package/dist/lib/service/task/TaskReadyEngine.d.ts +0 -84
- package/dist/lib/service/task/TaskReadyEngine.js +0 -115
- package/dist/scripts/build-native-ui.d.ts +0 -3
- package/dist/scripts/build-native-ui.js +0 -62
- package/dist/scripts/init-snippets.d.ts +0 -30
- package/dist/scripts/init-snippets.js +0 -298
- package/dist/scripts/install-full.d.ts +0 -7
- package/dist/scripts/install-full.js +0 -38
- package/resources/native-ui/README.md +0 -29
- package/resources/native-ui/combined-window.swift +0 -494
- package/resources/native-ui/main.swift +0 -598
- package/scripts/postinstall-safe.mjs +0 -89
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { slimSearchResult } from '#service/search/SearchTypes.js';
|
|
2
|
-
import { ioLimit } from '#shared/concurrency.js';
|
|
3
|
-
import Logger from '../../infrastructure/logging/Logger.js';
|
|
4
|
-
// ─── Constants ──────────────────────────────────────────
|
|
5
|
-
/**
|
|
6
|
-
* 搜索结果相关性阈值 — 低于此分数的结果不注入
|
|
7
|
-
*
|
|
8
|
-
* 真实分数分布 (BiliDemo, auto 模式 RRF+Ranking):
|
|
9
|
-
* min=0.434 P10=0.453 P25=0.460 median=0.479 P75=0.495 P90=0.505 max=0.534
|
|
10
|
-
* 所有结果集中在 [0.43, 0.54],0.15 无法过滤任何噪声。
|
|
11
|
-
*
|
|
12
|
-
* 阈值设定依据:
|
|
13
|
-
* 0.44 — 过滤掉最边缘的低质量尾部结果(约过滤 P5 以下)
|
|
14
|
-
*/
|
|
15
|
-
const RELEVANCE_THRESHOLD = 0.44;
|
|
16
|
-
/** 缓存 TTL (ms) — 5 分钟 */
|
|
17
|
-
const CACHE_TTL_MS = 300_000;
|
|
18
|
-
/** 技术术语提取正则 */
|
|
19
|
-
const TECH_TERM_PATTERNS = [
|
|
20
|
-
// CamelCase 类名 — 含常见 iOS/Android/Web 后缀
|
|
21
|
-
/\b[A-Z][a-zA-Z]+(?:Controller|ViewController|Service|Manager|Handler|View|Model|Request|Response|Provider|Repository|Factory|Builder|Delegate|Protocol|Router|Coordinator|Cell|Layout|Adapter|Module|Plugin|Monitor|Loader|Store|Cache|Config|Helper|Util|Extension|Category)\b/g,
|
|
22
|
-
// BD / UI / NS 前缀类名 (常见 iOS 项目)
|
|
23
|
-
/\b(?:BD|UI|NS|CG|CA|MK|AV|WK|SK|CL)[A-Z][a-zA-Z]{2,}\b/g,
|
|
24
|
-
// 反引号包裹的代码引用
|
|
25
|
-
/`([^`]+)`/g,
|
|
26
|
-
// 文件名引用 (xxx.swift / xxx.ts / xxx.json 等)
|
|
27
|
-
/\b[\w.-]+\.(?:swift|ts|tsx|js|jsx|py|java|kt|go|rs|rb|cpp|h|m|mm|json|yaml|yml|xml|gradle|plist|xib|storyboard)\b/g,
|
|
28
|
-
];
|
|
29
|
-
/**
|
|
30
|
-
* TaskKnowledgeBridge — 任务 ↔ 知识桥接服务
|
|
31
|
-
*
|
|
32
|
-
* AutoSnippet 独有能力:返回「带知识上下文的任务」,而非裸任务。
|
|
33
|
-
*
|
|
34
|
-
* 桥接策略(v2 — 用户输入感知 + Multi-Query + 上下文透传 + 缓存):
|
|
35
|
-
* 1. 任务标题/描述 + 用户输入(userQuery) → Multi-Query 搜索知识库
|
|
36
|
-
* 2. 传递 language / intent 上下文信号 → SearchEngine ContextBoost 生效
|
|
37
|
-
* 3. 关联的 Guard 规则 → 优先嵌入任务上下文
|
|
38
|
-
* 4. 任务级缓存 → 避免重复搜索
|
|
39
|
-
*/
|
|
40
|
-
export class TaskKnowledgeBridge {
|
|
41
|
-
_search;
|
|
42
|
-
logger;
|
|
43
|
-
/** 任务级知识缓存 (taskId → CacheEntry) */
|
|
44
|
-
_cache = new Map();
|
|
45
|
-
constructor(searchEngine) {
|
|
46
|
-
this._search = searchEngine;
|
|
47
|
-
this.logger = Logger.getInstance();
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 为就绪任务附加知识上下文
|
|
51
|
-
* 并行搜索,不阻塞主流程
|
|
52
|
-
*
|
|
53
|
-
* @param tasks 需要注入知识的任务列表
|
|
54
|
-
* @param options 上下文选项(userQuery / activeFile / language)
|
|
55
|
-
*/
|
|
56
|
-
async enrichWithKnowledge(tasks, options) {
|
|
57
|
-
if (!tasks || tasks.length === 0) {
|
|
58
|
-
return tasks;
|
|
59
|
-
}
|
|
60
|
-
if (!this._search) {
|
|
61
|
-
return tasks;
|
|
62
|
-
}
|
|
63
|
-
const results = await Promise.allSettled(tasks.map((task) => ioLimit(() => this._buildContext(task, options))));
|
|
64
|
-
return tasks.map((task, i) => {
|
|
65
|
-
if (results[i].status === 'fulfilled' && results[i].value) {
|
|
66
|
-
task.knowledgeContext = results[i].value;
|
|
67
|
-
}
|
|
68
|
-
return task;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* 独立搜索 — 仅基于 userQuery 搜索知识(不依赖任何 Task)
|
|
73
|
-
*
|
|
74
|
-
* 场景: prime() 时没有 ready tasks 但有用户输入,直接搜索知识库。
|
|
75
|
-
*
|
|
76
|
-
* @param userQuery 用户输入的原始文本
|
|
77
|
-
* @param options 可选的 language
|
|
78
|
-
*/
|
|
79
|
-
async searchForQuery(userQuery, options) {
|
|
80
|
-
if (!this._search || !userQuery?.trim()) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const searchResult = await this._search.search(userQuery.trim(), {
|
|
85
|
-
mode: 'auto',
|
|
86
|
-
limit: 8,
|
|
87
|
-
rank: true,
|
|
88
|
-
context: {
|
|
89
|
-
language: options?.language,
|
|
90
|
-
intent: 'user-query-knowledge',
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
const allResults = (searchResult?.items || searchResult?.results || []).filter((r) => this._aboveThreshold(r));
|
|
94
|
-
if (allResults.length === 0) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
const knowledge = allResults.filter((r) => r.kind !== 'rule').slice(0, 5);
|
|
98
|
-
const guardRules = allResults.filter((r) => r.kind === 'rule').slice(0, 3);
|
|
99
|
-
return {
|
|
100
|
-
relatedKnowledge: knowledge.map((k) => this._projectItem(k)),
|
|
101
|
-
guardRules: guardRules.map((r) => this._projectItem(r)),
|
|
102
|
-
searchQuery: userQuery.trim(),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
this.logger.debug('TaskKnowledgeBridge.searchForQuery error', {
|
|
107
|
-
error: err.message,
|
|
108
|
-
});
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// ═══ 私有方法 ═══════════════════════════════════════
|
|
113
|
-
/**
|
|
114
|
-
* 为单个任务构建知识上下文(v2 — multi-query + 上下文 + 缓存)
|
|
115
|
-
*/
|
|
116
|
-
async _buildContext(task, options) {
|
|
117
|
-
const taskQuery = `${task.title} ${task.description}`.trim();
|
|
118
|
-
if (!taskQuery && !options?.userQuery) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
// ── P6: 缓存检查 ──
|
|
122
|
-
const contentKey = this._contentKey(taskQuery, options?.userQuery);
|
|
123
|
-
if (task.id) {
|
|
124
|
-
const cached = this._cache.get(task.id);
|
|
125
|
-
if (cached &&
|
|
126
|
-
cached.contentKey === contentKey &&
|
|
127
|
-
Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
128
|
-
return cached.context;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
// ── P2: Multi-Query 策略 ──
|
|
133
|
-
const queries = this._buildSearchQueries(task, options?.userQuery);
|
|
134
|
-
const allResults = await this._multiQuerySearch(queries, {
|
|
135
|
-
language: options?.language,
|
|
136
|
-
});
|
|
137
|
-
// ── P4: 相关性阈值过滤 ──
|
|
138
|
-
const filtered = allResults.filter((r) => this._aboveThreshold(r));
|
|
139
|
-
// ── P4: 分类 & 增强投影 ──
|
|
140
|
-
const knowledge = filtered.filter((r) => r.kind !== 'rule').slice(0, 5);
|
|
141
|
-
const guardRules = filtered.filter((r) => r.kind === 'rule').slice(0, 3);
|
|
142
|
-
const context = {
|
|
143
|
-
relatedKnowledge: knowledge.map((k) => this._projectItem(k)),
|
|
144
|
-
guardRules: guardRules.map((r) => this._projectItem(r)),
|
|
145
|
-
searchQuery: queries.join(' | '),
|
|
146
|
-
};
|
|
147
|
-
// ── P6: 写入缓存 ──
|
|
148
|
-
if (task.id) {
|
|
149
|
-
this._cache.set(task.id, { context, contentKey, timestamp: Date.now() });
|
|
150
|
-
// 限制缓存大小 — 超出 100 条时淘汰最旧的
|
|
151
|
-
if (this._cache.size > 100) {
|
|
152
|
-
const firstKey = this._cache.keys().next().value;
|
|
153
|
-
if (firstKey !== undefined) {
|
|
154
|
-
this._cache.delete(firstKey);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return context;
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
this.logger.debug('TaskKnowledgeBridge._buildContext error', {
|
|
162
|
-
taskId: task.id,
|
|
163
|
-
error: err.message,
|
|
164
|
-
});
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* P2: 构建多条互补搜索查询
|
|
170
|
-
*
|
|
171
|
-
* 策略:
|
|
172
|
-
* Q1 (精确): 任务标题 — 通常最精练
|
|
173
|
-
* Q2 (语义): 用户输入 — 包含更丰富的自然语义
|
|
174
|
-
* Q3 (关键词): 从描述/用户输入提取技术术语
|
|
175
|
-
*
|
|
176
|
-
*/
|
|
177
|
-
_buildSearchQueries(task, userQuery) {
|
|
178
|
-
const queries = [];
|
|
179
|
-
// Q1: 任务标题(最精练)
|
|
180
|
-
const title = task.title?.trim();
|
|
181
|
-
if (title) {
|
|
182
|
-
queries.push(title);
|
|
183
|
-
}
|
|
184
|
-
// Q2: 用户原始输入(与标题不同才添加)
|
|
185
|
-
const uq = userQuery?.trim();
|
|
186
|
-
if (uq && uq !== title) {
|
|
187
|
-
queries.push(uq);
|
|
188
|
-
}
|
|
189
|
-
// Q3: 技术术语提取 — 从描述 + 用户输入中提取
|
|
190
|
-
const corpus = [task.description, userQuery].filter(Boolean).join(' ');
|
|
191
|
-
const techTerms = this._extractTechTerms(corpus);
|
|
192
|
-
if (techTerms.length > 0) {
|
|
193
|
-
const termQuery = techTerms.join(' ');
|
|
194
|
-
// 避免与已有查询重复
|
|
195
|
-
if (!queries.includes(termQuery)) {
|
|
196
|
-
queries.push(termQuery);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
// 兜底: 若上述都为空,用 title + description
|
|
200
|
-
if (queries.length === 0) {
|
|
201
|
-
const fallback = `${task.title} ${task.description}`.trim();
|
|
202
|
-
if (fallback) {
|
|
203
|
-
queries.push(fallback);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return queries;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* P2: 从文本中提取技术术语(类名、文件名、API 名等)
|
|
210
|
-
*/
|
|
211
|
-
_extractTechTerms(text) {
|
|
212
|
-
if (!text) {
|
|
213
|
-
return [];
|
|
214
|
-
}
|
|
215
|
-
const terms = new Set();
|
|
216
|
-
for (const pattern of TECH_TERM_PATTERNS) {
|
|
217
|
-
// 重置 lastIndex(全局正则复用安全)
|
|
218
|
-
pattern.lastIndex = 0;
|
|
219
|
-
let match;
|
|
220
|
-
while ((match = pattern.exec(text)) !== null) {
|
|
221
|
-
// 优先取捕获组(反引号中的内容),否则取整个匹配
|
|
222
|
-
const term = (match[1] || match[0]).trim();
|
|
223
|
-
if (term.length >= 2) {
|
|
224
|
-
terms.add(term);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return [...terms].slice(0, 8); // 最多 8 个术语
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* P2 + P3: Multi-Query 搜索 + 合并去重
|
|
232
|
-
*
|
|
233
|
-
* 对每个 query 执行搜索(并行),合并结果并按 score 去重保留最高分。
|
|
234
|
-
*/
|
|
235
|
-
async _multiQuerySearch(queries, options) {
|
|
236
|
-
if (queries.length === 0) {
|
|
237
|
-
return [];
|
|
238
|
-
}
|
|
239
|
-
// 单 query 直接搜索(优化常见情况)
|
|
240
|
-
if (queries.length === 1) {
|
|
241
|
-
return this._singleSearch(queries[0], options);
|
|
242
|
-
}
|
|
243
|
-
// 多 query 并行搜索
|
|
244
|
-
const searchPromises = queries.map((q) => this._singleSearch(q, options).catch(() => []));
|
|
245
|
-
const resultSets = await Promise.all(searchPromises);
|
|
246
|
-
// 合并去重 — 按 id 保留最高 score
|
|
247
|
-
const merged = new Map();
|
|
248
|
-
for (const results of resultSets) {
|
|
249
|
-
for (const item of results) {
|
|
250
|
-
const existing = merged.get(item.id);
|
|
251
|
-
if (!existing || item.score > existing.score) {
|
|
252
|
-
merged.set(item.id, item);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// 按 score 降序排序
|
|
257
|
-
return [...merged.values()].sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* 执行单次搜索(含 P3 上下文透传)
|
|
261
|
-
*/
|
|
262
|
-
async _singleSearch(query, options) {
|
|
263
|
-
const searchResult = await this._search.search(query, {
|
|
264
|
-
mode: 'auto',
|
|
265
|
-
limit: 8,
|
|
266
|
-
rank: true,
|
|
267
|
-
context: {
|
|
268
|
-
language: options.language,
|
|
269
|
-
intent: 'task-knowledge',
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
return (searchResult?.items || searchResult?.results || []).slice(0, 8);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* P4: 相关性阈值判断
|
|
276
|
-
*/
|
|
277
|
-
_aboveThreshold(item) {
|
|
278
|
-
const score = item.score || 0;
|
|
279
|
-
return score >= RELEVANCE_THRESHOLD;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* P4: 增强投影 — 使用统一 slimSearchResult() 投影函数
|
|
283
|
-
*/
|
|
284
|
-
_projectItem(item) {
|
|
285
|
-
return slimSearchResult(item);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* P6: 缓存键 — 基于 taskQuery + userQuery 的内容指纹
|
|
289
|
-
*/
|
|
290
|
-
_contentKey(taskQuery, userQuery) {
|
|
291
|
-
return `${taskQuery}||${userQuery || ''}`;
|
|
292
|
-
}
|
|
293
|
-
/** 清除全部缓存(测试 / 索引重建后使用) */
|
|
294
|
-
clearCache() {
|
|
295
|
-
this._cache.clear();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
export default TaskKnowledgeBridge;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Task } from '../../domain/task/Task.js';
|
|
2
|
-
/**
|
|
3
|
-
* TaskReadyEngine — 就绪检测引擎
|
|
4
|
-
*
|
|
5
|
-
* 核心能力:通过递归 CTE 计算传递性阻塞,返回所有无阻塞依赖的就绪任务。
|
|
6
|
-
*
|
|
7
|
-
* 排序策略 (默认 hybrid):
|
|
8
|
-
* priority ASC → 高优先级优先
|
|
9
|
-
* created_at ASC → 同优先级先创建优先(防止 starvation)
|
|
10
|
-
*/
|
|
11
|
-
export declare class TaskReadyEngine {
|
|
12
|
-
_blockedStmt: ReturnType<import('better-sqlite3').Database['prepare']>;
|
|
13
|
-
_db: import('better-sqlite3').Database;
|
|
14
|
-
_depTreeStmt: ReturnType<import('better-sqlite3').Database['prepare']>;
|
|
15
|
-
_readyStmt: ReturnType<import('better-sqlite3').Database['prepare']>;
|
|
16
|
-
/** @param db raw SQLite handle */
|
|
17
|
-
constructor(db: import('better-sqlite3').Database);
|
|
18
|
-
private _prepareStatements;
|
|
19
|
-
/**
|
|
20
|
-
* 获取就绪任务(核心方法)
|
|
21
|
-
*
|
|
22
|
-
* 就绪 = status='open' 且无未完成的阻塞型依赖(传递性检测)
|
|
23
|
-
*/
|
|
24
|
-
getReadyWork(options?: {
|
|
25
|
-
limit?: number;
|
|
26
|
-
}): Task[];
|
|
27
|
-
/**
|
|
28
|
-
* 获取被阻塞的任务列表
|
|
29
|
-
* @returns 带 blocked_by 字段的任务列表
|
|
30
|
-
*/
|
|
31
|
-
getBlockedWork(): {
|
|
32
|
-
blockedBy: string[];
|
|
33
|
-
knowledgeContext?: Record<string, unknown> | undefined;
|
|
34
|
-
id?: string | null | undefined;
|
|
35
|
-
parentId?: string | null | undefined;
|
|
36
|
-
title?: string | undefined;
|
|
37
|
-
description?: string | undefined;
|
|
38
|
-
design?: string | undefined;
|
|
39
|
-
acceptance?: string | undefined;
|
|
40
|
-
notes?: string | undefined;
|
|
41
|
-
status?: string | undefined;
|
|
42
|
-
priority?: number | undefined;
|
|
43
|
-
taskType?: string | undefined;
|
|
44
|
-
closeReason?: string | undefined;
|
|
45
|
-
assignee?: string | undefined;
|
|
46
|
-
createdBy?: string | undefined;
|
|
47
|
-
createdAt?: number | undefined;
|
|
48
|
-
updatedAt?: number | undefined;
|
|
49
|
-
closedAt?: number | null | undefined;
|
|
50
|
-
contentHash?: string | null | undefined;
|
|
51
|
-
failCount?: number | undefined;
|
|
52
|
-
lastFailReason?: string | undefined;
|
|
53
|
-
metadata?: Record<string, unknown> | undefined;
|
|
54
|
-
}[];
|
|
55
|
-
/**
|
|
56
|
-
* 获取依赖树
|
|
57
|
-
* @returns 带 depth 的任务列表
|
|
58
|
-
*/
|
|
59
|
-
getDependencyTree(taskId: string): {
|
|
60
|
-
depth: unknown;
|
|
61
|
-
knowledgeContext?: Record<string, unknown> | undefined;
|
|
62
|
-
id?: string | null | undefined;
|
|
63
|
-
parentId?: string | null | undefined;
|
|
64
|
-
title?: string | undefined;
|
|
65
|
-
description?: string | undefined;
|
|
66
|
-
design?: string | undefined;
|
|
67
|
-
acceptance?: string | undefined;
|
|
68
|
-
notes?: string | undefined;
|
|
69
|
-
status?: string | undefined;
|
|
70
|
-
priority?: number | undefined;
|
|
71
|
-
taskType?: string | undefined;
|
|
72
|
-
closeReason?: string | undefined;
|
|
73
|
-
assignee?: string | undefined;
|
|
74
|
-
createdBy?: string | undefined;
|
|
75
|
-
createdAt?: number | undefined;
|
|
76
|
-
updatedAt?: number | undefined;
|
|
77
|
-
closedAt?: number | null | undefined;
|
|
78
|
-
contentHash?: string | null | undefined;
|
|
79
|
-
failCount?: number | undefined;
|
|
80
|
-
lastFailReason?: string | undefined;
|
|
81
|
-
metadata?: Record<string, unknown> | undefined;
|
|
82
|
-
}[];
|
|
83
|
-
}
|
|
84
|
-
export default TaskReadyEngine;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { Task } from '../../domain/task/Task.js';
|
|
2
|
-
/**
|
|
3
|
-
* TaskReadyEngine — 就绪检测引擎
|
|
4
|
-
*
|
|
5
|
-
* 核心能力:通过递归 CTE 计算传递性阻塞,返回所有无阻塞依赖的就绪任务。
|
|
6
|
-
*
|
|
7
|
-
* 排序策略 (默认 hybrid):
|
|
8
|
-
* priority ASC → 高优先级优先
|
|
9
|
-
* created_at ASC → 同优先级先创建优先(防止 starvation)
|
|
10
|
-
*/
|
|
11
|
-
export class TaskReadyEngine {
|
|
12
|
-
_blockedStmt;
|
|
13
|
-
_db;
|
|
14
|
-
_depTreeStmt;
|
|
15
|
-
_readyStmt;
|
|
16
|
-
/** @param db raw SQLite handle */
|
|
17
|
-
constructor(db) {
|
|
18
|
-
this._db = db;
|
|
19
|
-
this._prepareStatements();
|
|
20
|
-
}
|
|
21
|
-
_prepareStatements() {
|
|
22
|
-
// ── 核心: 递归 CTE 计算传递性阻塞 ──
|
|
23
|
-
this._readyStmt = this._db.prepare(`
|
|
24
|
-
WITH RECURSIVE blocked_tasks(id, depth) AS (
|
|
25
|
-
-- Base case: 直接被阻塞的任务
|
|
26
|
-
SELECT td.task_id, 1
|
|
27
|
-
FROM task_dependencies td
|
|
28
|
-
JOIN tasks blocker ON td.depends_on_id = blocker.id
|
|
29
|
-
WHERE td.dep_type IN ('blocks', 'waits-for')
|
|
30
|
-
AND blocker.status != 'closed'
|
|
31
|
-
|
|
32
|
-
UNION
|
|
33
|
-
|
|
34
|
-
-- Recursive case: 传递性阻塞(深度保护 ≤ 50 层)
|
|
35
|
-
SELECT td.task_id, bt.depth + 1
|
|
36
|
-
FROM task_dependencies td
|
|
37
|
-
JOIN blocked_tasks bt ON td.depends_on_id = bt.id
|
|
38
|
-
WHERE td.dep_type IN ('blocks', 'waits-for')
|
|
39
|
-
AND bt.depth < 50
|
|
40
|
-
)
|
|
41
|
-
SELECT t.*
|
|
42
|
-
FROM tasks t
|
|
43
|
-
WHERE t.status = 'open'
|
|
44
|
-
AND t.id NOT IN (SELECT id FROM blocked_tasks)
|
|
45
|
-
ORDER BY t.priority ASC, t.created_at ASC
|
|
46
|
-
LIMIT ?
|
|
47
|
-
`);
|
|
48
|
-
// ── 查询被阻塞的任务 ──
|
|
49
|
-
this._blockedStmt = this._db.prepare(`
|
|
50
|
-
SELECT t.*, GROUP_CONCAT(td.depends_on_id) as blocked_by
|
|
51
|
-
FROM tasks t
|
|
52
|
-
JOIN task_dependencies td ON t.id = td.task_id
|
|
53
|
-
JOIN tasks blocker ON td.depends_on_id = blocker.id
|
|
54
|
-
WHERE t.status IN ('open', 'in_progress')
|
|
55
|
-
AND td.dep_type IN ('blocks', 'waits-for')
|
|
56
|
-
AND blocker.status != 'closed'
|
|
57
|
-
GROUP BY t.id
|
|
58
|
-
ORDER BY t.priority ASC
|
|
59
|
-
`);
|
|
60
|
-
// ── 依赖树查询 ──
|
|
61
|
-
this._depTreeStmt = this._db.prepare(`
|
|
62
|
-
WITH RECURSIVE dep_tree(id, depth, path) AS (
|
|
63
|
-
SELECT depends_on_id, 1, depends_on_id
|
|
64
|
-
FROM task_dependencies
|
|
65
|
-
WHERE task_id = ?
|
|
66
|
-
AND dep_type IN ('blocks', 'waits-for')
|
|
67
|
-
|
|
68
|
-
UNION ALL
|
|
69
|
-
|
|
70
|
-
SELECT td.depends_on_id, dt.depth + 1, dt.path || '>' || td.depends_on_id
|
|
71
|
-
FROM task_dependencies td
|
|
72
|
-
JOIN dep_tree dt ON td.task_id = dt.id
|
|
73
|
-
WHERE td.dep_type IN ('blocks', 'waits-for')
|
|
74
|
-
AND dt.depth < 10
|
|
75
|
-
)
|
|
76
|
-
SELECT t.*, dt.depth
|
|
77
|
-
FROM dep_tree dt
|
|
78
|
-
JOIN tasks t ON t.id = dt.id
|
|
79
|
-
ORDER BY dt.depth ASC
|
|
80
|
-
`);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 获取就绪任务(核心方法)
|
|
84
|
-
*
|
|
85
|
-
* 就绪 = status='open' 且无未完成的阻塞型依赖(传递性检测)
|
|
86
|
-
*/
|
|
87
|
-
getReadyWork(options = {}) {
|
|
88
|
-
const limit = Math.max(1, Math.min(options.limit || 10, 200));
|
|
89
|
-
const rows = this._readyStmt.all(limit);
|
|
90
|
-
return rows.map((r) => Task.fromRow(r)).filter((t) => t !== null);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* 获取被阻塞的任务列表
|
|
94
|
-
* @returns 带 blocked_by 字段的任务列表
|
|
95
|
-
*/
|
|
96
|
-
getBlockedWork() {
|
|
97
|
-
const rows = this._blockedStmt.all();
|
|
98
|
-
return rows.map((r) => ({
|
|
99
|
-
...Task.fromRow(r)?.toJSON(),
|
|
100
|
-
blockedBy: r.blocked_by ? r.blocked_by.split(',') : [],
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 获取依赖树
|
|
105
|
-
* @returns 带 depth 的任务列表
|
|
106
|
-
*/
|
|
107
|
-
getDependencyTree(taskId) {
|
|
108
|
-
const rows = this._depTreeStmt.all(taskId);
|
|
109
|
-
return rows.map((r) => ({
|
|
110
|
-
...Task.fromRow(r)?.toJSON(),
|
|
111
|
-
depth: r.depth,
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export default TaskReadyEngine;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/** 在 macOS 上构建 native-ui 辅助程序(可选) */
|
|
3
|
-
const __dirname = import.meta.dirname;
|
|
4
|
-
import { execSync } from 'node:child_process';
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { PACKAGE_ROOT } from '../lib/shared/package-root.js';
|
|
8
|
-
if (process.platform !== 'darwin') {
|
|
9
|
-
process.exit(0);
|
|
10
|
-
}
|
|
11
|
-
const root = PACKAGE_ROOT;
|
|
12
|
-
const src = path.join(root, 'resources', 'native-ui', 'main.swift');
|
|
13
|
-
const combinedSrc = path.join(root, 'resources', 'native-ui', 'combined-window.swift');
|
|
14
|
-
const out = path.join(root, 'resources', 'native-ui', 'native-ui');
|
|
15
|
-
// 检查是否在发布流程中(npm publish 会设置 npm_lifecycle_event)
|
|
16
|
-
const isPublishing = process.env.npm_lifecycle_event === 'prepublishOnly';
|
|
17
|
-
try {
|
|
18
|
-
// 编译 native-ui(包含所有源文件)
|
|
19
|
-
execSync(`swiftc "${src}" "${combinedSrc}" -o "${out}" -framework AppKit`, {
|
|
20
|
-
cwd: root,
|
|
21
|
-
stdio: 'pipe',
|
|
22
|
-
});
|
|
23
|
-
// 验证构建结果
|
|
24
|
-
if (fs.existsSync(out)) {
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (_err) {
|
|
28
|
-
// 如果在发布流程中构建失败,应该报错
|
|
29
|
-
if (isPublishing) {
|
|
30
|
-
console.error('❌ Native UI 构建失败(发布流程中)');
|
|
31
|
-
console.error('请确保:');
|
|
32
|
-
console.error(' 1. 当前系统是 macOS');
|
|
33
|
-
console.error(' 2. 已安装 Xcode Command Line Tools: xcode-select --install');
|
|
34
|
-
console.error(' 3. Swift 编译器可用: which swiftc');
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
// 在用户安装时,如果已有预编译的二进制文件,静默跳过
|
|
38
|
-
if (fs.existsSync(out)) {
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// ── 发布流程:最终校验二进制必须存在 ──
|
|
44
|
-
if (isPublishing) {
|
|
45
|
-
if (!fs.existsSync(out)) {
|
|
46
|
-
console.error('❌ 发布中止:native-ui 二进制不存在于', out);
|
|
47
|
-
console.error(' prepublishOnly 编译步骤可能被跳过或失败');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
const stat = fs.statSync(out);
|
|
51
|
-
if (stat.size < 10_000) {
|
|
52
|
-
console.error('❌ 发布中止:native-ui 二进制异常(仅', stat.size, '字节)');
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
// 确保有执行权限
|
|
56
|
-
try {
|
|
57
|
-
fs.chmodSync(out, 0o755);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
/* ignore */
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Snippet 统一初始化脚本
|
|
4
|
-
*
|
|
5
|
-
* 为 AutoSnippet 生成快速触发 Snippet(ass/asc/asa)到目标 IDE:
|
|
6
|
-
* - Xcode: ~/Library/Developer/Xcode/UserData/CodeSnippets/*.codesnippet
|
|
7
|
-
* - VSCode: .vscode/autosnippet-triggers.code-snippets (项目级)
|
|
8
|
-
*
|
|
9
|
-
* 用法:
|
|
10
|
-
* node scripts/init-snippets.js [init|list|remove] [--target xcode|vscode|all]
|
|
11
|
-
* npm run init:snippets
|
|
12
|
-
*/
|
|
13
|
-
export declare class SnippetInitializer {
|
|
14
|
-
vscode: any;
|
|
15
|
-
xcode: any;
|
|
16
|
-
constructor(projectRoot: any);
|
|
17
|
-
/**
|
|
18
|
-
* 初始化 snippet 到指定目标
|
|
19
|
-
* @param target — 'xcode' | 'vscode' | 'all'
|
|
20
|
-
* @returns }
|
|
21
|
-
*/
|
|
22
|
-
initialize(target?: string): Promise<any>;
|
|
23
|
-
list(target?: string): any;
|
|
24
|
-
remove(target?: string): any;
|
|
25
|
-
}
|
|
26
|
-
declare const _default: {
|
|
27
|
-
SnippetInitializer: typeof SnippetInitializer;
|
|
28
|
-
initialize: (projectRoot: any, target: any) => Promise<any>;
|
|
29
|
-
};
|
|
30
|
-
export default _default;
|