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,347 +0,0 @@
|
|
|
1
|
-
import { and, asc, eq, sql } from 'drizzle-orm';
|
|
2
|
-
import { Task } from '../../domain/task/Task.js';
|
|
3
|
-
import { getDrizzle } from '../../infrastructure/database/drizzle/index.js';
|
|
4
|
-
import { taskDependencies, taskEvents, tasks, } from '../../infrastructure/database/drizzle/schema.js';
|
|
5
|
-
import Logger from '../../infrastructure/logging/Logger.js';
|
|
6
|
-
/**
|
|
7
|
-
* TaskRepositoryImpl — 任务实体 SQLite 持久化 (Drizzle ORM)
|
|
8
|
-
*
|
|
9
|
-
* DB 列名 snake_case,实体属性 camelCase—— Task.fromRow() / _entityToRow() 负责映射。
|
|
10
|
-
*
|
|
11
|
-
* Drizzle 迁移策略:
|
|
12
|
-
* - CRUD (create/findById/update/delete) → drizzle 类型安全 API
|
|
13
|
-
* - 依赖管理 (add/remove/get) → drizzle 类型安全 API
|
|
14
|
-
* - 事件审计 / 统计 → drizzle 类型安全 API
|
|
15
|
-
* - 环检测 (递归 CTE) / 复杂动态查询 (findAll) → 保留 raw SQL
|
|
16
|
-
*/
|
|
17
|
-
export class TaskRepositoryImpl {
|
|
18
|
-
_reachableStmt;
|
|
19
|
-
#drizzle;
|
|
20
|
-
db;
|
|
21
|
-
logger;
|
|
22
|
-
constructor(database, drizzle) {
|
|
23
|
-
this.db = database.getDb();
|
|
24
|
-
this.logger = Logger.getInstance();
|
|
25
|
-
this.#drizzle = drizzle ?? getDrizzle();
|
|
26
|
-
this._prepareStatements();
|
|
27
|
-
}
|
|
28
|
-
/** 预编译复杂查询(仅保留 drizzle 无法表达的递归 CTE) */
|
|
29
|
-
_prepareStatements() {
|
|
30
|
-
// ── 环检测 (递归 CTE) — drizzle 不支持递归 CTE ──
|
|
31
|
-
this._reachableStmt = this.db.prepare(`
|
|
32
|
-
WITH RECURSIVE reachable(id, depth) AS (
|
|
33
|
-
SELECT depends_on_id, 1
|
|
34
|
-
FROM task_dependencies
|
|
35
|
-
WHERE task_id = ?
|
|
36
|
-
AND dep_type IN ('blocks', 'waits-for')
|
|
37
|
-
|
|
38
|
-
UNION ALL
|
|
39
|
-
|
|
40
|
-
SELECT td.depends_on_id, r.depth + 1
|
|
41
|
-
FROM task_dependencies td
|
|
42
|
-
JOIN reachable r ON td.task_id = r.id
|
|
43
|
-
WHERE td.dep_type IN ('blocks', 'waits-for')
|
|
44
|
-
AND r.depth < 50
|
|
45
|
-
)
|
|
46
|
-
SELECT 1 FROM reachable WHERE id = ? LIMIT 1
|
|
47
|
-
`);
|
|
48
|
-
}
|
|
49
|
-
// ═══ CRUD ═══════════════════════════════════════════
|
|
50
|
-
/**
|
|
51
|
-
* 创建任务
|
|
52
|
-
* ★ Drizzle 类型安全 INSERT
|
|
53
|
-
*/
|
|
54
|
-
create(task) {
|
|
55
|
-
const row = this._entityToRow(task);
|
|
56
|
-
this.#drizzle.insert(tasks).values(row).run();
|
|
57
|
-
return this.findById(task.id);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 按 ID 查询
|
|
61
|
-
* ★ Drizzle 类型安全 SELECT
|
|
62
|
-
*/
|
|
63
|
-
findById(id) {
|
|
64
|
-
const row = this.#drizzle.select().from(tasks).where(eq(tasks.id, id)).get();
|
|
65
|
-
return row ? Task.fromRow(row) : null;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 按内容哈希查询(去重用)
|
|
69
|
-
* ★ Drizzle 类型安全 SELECT
|
|
70
|
-
*/
|
|
71
|
-
findByContentHash(hash) {
|
|
72
|
-
if (!hash) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const row = this.#drizzle
|
|
76
|
-
.select()
|
|
77
|
-
.from(tasks)
|
|
78
|
-
.where(and(eq(tasks.contentHash, hash), sql `${tasks.status} != 'closed'`))
|
|
79
|
-
.get();
|
|
80
|
-
return row ? Task.fromRow(row) : null;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 更新任务字段
|
|
84
|
-
* ★ Drizzle 类型安全 UPDATE
|
|
85
|
-
*/
|
|
86
|
-
update(id, fields) {
|
|
87
|
-
const setObj = {};
|
|
88
|
-
const columnMap = {
|
|
89
|
-
status: 'status',
|
|
90
|
-
priority: 'priority',
|
|
91
|
-
assignee: 'assignee',
|
|
92
|
-
notes: 'notes',
|
|
93
|
-
description: 'description',
|
|
94
|
-
design: 'design',
|
|
95
|
-
acceptance: 'acceptance',
|
|
96
|
-
closeReason: 'closeReason',
|
|
97
|
-
closedAt: 'closedAt',
|
|
98
|
-
updatedAt: 'updatedAt',
|
|
99
|
-
failCount: 'failCount',
|
|
100
|
-
lastFailReason: 'lastFailReason',
|
|
101
|
-
childSeq: 'childSeq',
|
|
102
|
-
metadata: 'metadata',
|
|
103
|
-
};
|
|
104
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
105
|
-
const schemaKey = columnMap[key];
|
|
106
|
-
if (!schemaKey) {
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
setObj[schemaKey] = key === 'metadata' ? JSON.stringify(value) : value;
|
|
110
|
-
}
|
|
111
|
-
if (Object.keys(setObj).length === 0) {
|
|
112
|
-
return this.findById(id);
|
|
113
|
-
}
|
|
114
|
-
// 始终更新 updatedAt
|
|
115
|
-
if (!fields.updatedAt) {
|
|
116
|
-
setObj.updatedAt = Math.floor(Date.now() / 1000);
|
|
117
|
-
}
|
|
118
|
-
this.#drizzle.update(tasks).set(setObj).where(eq(tasks.id, id)).run();
|
|
119
|
-
return this.findById(id);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* 删除任务
|
|
123
|
-
* ★ Drizzle 类型安全 DELETE
|
|
124
|
-
*/
|
|
125
|
-
delete(id) {
|
|
126
|
-
const result = this.#drizzle.delete(tasks).where(eq(tasks.id, id)).run();
|
|
127
|
-
return result.changes > 0;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* 列表查询
|
|
131
|
-
* @param filters { status, taskType, assignee, parentId }
|
|
132
|
-
* @param options { limit, offset, orderBy }
|
|
133
|
-
*/
|
|
134
|
-
findAll(filters = {}, options = {}) {
|
|
135
|
-
const conditions = [];
|
|
136
|
-
const params = [];
|
|
137
|
-
if (filters.status) {
|
|
138
|
-
conditions.push('status = ?');
|
|
139
|
-
params.push(filters.status);
|
|
140
|
-
}
|
|
141
|
-
if (filters.taskType) {
|
|
142
|
-
conditions.push('task_type = ?');
|
|
143
|
-
params.push(filters.taskType);
|
|
144
|
-
}
|
|
145
|
-
if (filters.assignee) {
|
|
146
|
-
conditions.push('assignee = ?');
|
|
147
|
-
params.push(filters.assignee);
|
|
148
|
-
}
|
|
149
|
-
if (filters.parentId) {
|
|
150
|
-
conditions.push('parent_id = ?');
|
|
151
|
-
params.push(filters.parentId);
|
|
152
|
-
}
|
|
153
|
-
const where = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
154
|
-
const limit = Math.max(1, Math.min(options.limit || 50, 500));
|
|
155
|
-
const offset = Math.max(0, options.offset || 0);
|
|
156
|
-
const orderBy = _sanitizeOrderBy(options.orderBy);
|
|
157
|
-
const sql = `SELECT * FROM tasks ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`;
|
|
158
|
-
params.push(limit, offset);
|
|
159
|
-
const rows = this.db.prepare(sql).all(...params);
|
|
160
|
-
return rows.map((r) => Task.fromRow(r));
|
|
161
|
-
}
|
|
162
|
-
// ═══ 依赖管理 ═══════════════════════════════════════
|
|
163
|
-
/**
|
|
164
|
-
* 添加依赖
|
|
165
|
-
* ★ Drizzle 类型安全 INSERT OR IGNORE
|
|
166
|
-
*/
|
|
167
|
-
addDependency(taskId, dependsOnId, depType) {
|
|
168
|
-
this.#drizzle
|
|
169
|
-
.insert(taskDependencies)
|
|
170
|
-
.values({
|
|
171
|
-
taskId,
|
|
172
|
-
dependsOnId,
|
|
173
|
-
depType,
|
|
174
|
-
createdAt: Math.floor(Date.now() / 1000),
|
|
175
|
-
createdBy: 'agent',
|
|
176
|
-
})
|
|
177
|
-
.onConflictDoNothing()
|
|
178
|
-
.run();
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* 删除依赖
|
|
182
|
-
* ★ Drizzle 类型安全 DELETE
|
|
183
|
-
*/
|
|
184
|
-
removeDependency(taskId, dependsOnId, depType) {
|
|
185
|
-
this.#drizzle
|
|
186
|
-
.delete(taskDependencies)
|
|
187
|
-
.where(and(eq(taskDependencies.taskId, taskId), eq(taskDependencies.dependsOnId, dependsOnId), eq(taskDependencies.depType, depType)))
|
|
188
|
-
.run();
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* 获取任务的所有依赖
|
|
192
|
-
* ★ Drizzle 类型安全 SELECT
|
|
193
|
-
*/
|
|
194
|
-
getDependencies(taskId) {
|
|
195
|
-
return this.#drizzle
|
|
196
|
-
.select()
|
|
197
|
-
.from(taskDependencies)
|
|
198
|
-
.where(eq(taskDependencies.taskId, taskId))
|
|
199
|
-
.orderBy(asc(taskDependencies.createdAt))
|
|
200
|
-
.all();
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 获取依赖此任务的所有任务
|
|
204
|
-
* ★ Drizzle 类型安全 SELECT
|
|
205
|
-
*/
|
|
206
|
-
getDependents(dependsOnId) {
|
|
207
|
-
return this.#drizzle
|
|
208
|
-
.select()
|
|
209
|
-
.from(taskDependencies)
|
|
210
|
-
.where(eq(taskDependencies.dependsOnId, dependsOnId))
|
|
211
|
-
.all();
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* 获取阻塞某任务的所有任务(含任务详情)
|
|
215
|
-
* 保留 raw SQL — JOIN 查询
|
|
216
|
-
*/
|
|
217
|
-
getBlockers(taskId) {
|
|
218
|
-
const rows = this.db
|
|
219
|
-
.prepare(`
|
|
220
|
-
SELECT t.*
|
|
221
|
-
FROM task_dependencies td
|
|
222
|
-
JOIN tasks t ON td.depends_on_id = t.id
|
|
223
|
-
WHERE td.task_id = ?
|
|
224
|
-
AND td.dep_type IN ('blocks', 'waits-for')
|
|
225
|
-
AND t.status != 'closed'
|
|
226
|
-
`)
|
|
227
|
-
.all(taskId);
|
|
228
|
-
return rows.map((r) => Task.fromRow(r));
|
|
229
|
-
}
|
|
230
|
-
/** 环检测:检查 fromId → toId 是否已有可达路径 */
|
|
231
|
-
hasReachablePath(fromId, toId) {
|
|
232
|
-
const row = this._reachableStmt.get(fromId, toId);
|
|
233
|
-
return !!row;
|
|
234
|
-
}
|
|
235
|
-
// ═══ 事务支持 ═══════════════════════════════════════
|
|
236
|
-
/** 在事务中执行操作 */
|
|
237
|
-
inTransaction(fn) {
|
|
238
|
-
const txn = this.db.transaction(fn);
|
|
239
|
-
return txn();
|
|
240
|
-
}
|
|
241
|
-
// ═══ 统计 ═══════════════════════════════════════════
|
|
242
|
-
/**
|
|
243
|
-
* 获取任务统计
|
|
244
|
-
* 保留 raw SQL — SUM(CASE WHEN) 聚合在 drizzle 中不如直写清晰
|
|
245
|
-
*/
|
|
246
|
-
getStatistics() {
|
|
247
|
-
const row = this.db
|
|
248
|
-
.prepare(`
|
|
249
|
-
SELECT
|
|
250
|
-
COUNT(*) as total,
|
|
251
|
-
SUM(CASE WHEN status = 'open' THEN 1 ELSE 0 END) as open,
|
|
252
|
-
SUM(CASE WHEN status = 'in_progress' THEN 1 ELSE 0 END) as in_progress,
|
|
253
|
-
SUM(CASE WHEN status = 'closed' THEN 1 ELSE 0 END) as closed,
|
|
254
|
-
SUM(CASE WHEN status = 'deferred' THEN 1 ELSE 0 END) as deferred,
|
|
255
|
-
SUM(CASE WHEN status = 'pinned' THEN 1 ELSE 0 END) as pinned
|
|
256
|
-
FROM tasks
|
|
257
|
-
`)
|
|
258
|
-
.get();
|
|
259
|
-
return {
|
|
260
|
-
total: row.total || 0,
|
|
261
|
-
open: row.open || 0,
|
|
262
|
-
in_progress: row.in_progress || 0,
|
|
263
|
-
closed: row.closed || 0,
|
|
264
|
-
deferred: row.deferred || 0,
|
|
265
|
-
pinned: row.pinned || 0,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
// ═══ 事件审计 ═══════════════════════════════════════
|
|
269
|
-
/**
|
|
270
|
-
* 记录任务事件
|
|
271
|
-
* ★ Drizzle 类型安全 INSERT
|
|
272
|
-
*/
|
|
273
|
-
logEvent(taskId, eventType, oldValue = null, newValue = null, comment = null, actor = 'agent') {
|
|
274
|
-
this.#drizzle
|
|
275
|
-
.insert(taskEvents)
|
|
276
|
-
.values({
|
|
277
|
-
taskId,
|
|
278
|
-
eventType,
|
|
279
|
-
actor,
|
|
280
|
-
oldValue,
|
|
281
|
-
newValue,
|
|
282
|
-
comment,
|
|
283
|
-
createdAt: Math.floor(Date.now() / 1000),
|
|
284
|
-
})
|
|
285
|
-
.run();
|
|
286
|
-
}
|
|
287
|
-
// ═══ 私有方法 ═══════════════════════════════════════
|
|
288
|
-
/** 实体 → DB 行 (camelCase → snake_case) */
|
|
289
|
-
_entityToRow(task) {
|
|
290
|
-
return {
|
|
291
|
-
id: task.id,
|
|
292
|
-
parentId: task.parentId || null,
|
|
293
|
-
childSeq: task.childSeq || 0,
|
|
294
|
-
title: task.title,
|
|
295
|
-
description: task.description || '',
|
|
296
|
-
design: task.design || '',
|
|
297
|
-
acceptance: task.acceptance || '',
|
|
298
|
-
notes: task.notes || '',
|
|
299
|
-
status: task.status,
|
|
300
|
-
priority: task.priority ?? 2,
|
|
301
|
-
taskType: task.taskType || 'task',
|
|
302
|
-
closeReason: task.closeReason || '',
|
|
303
|
-
contentHash: task.contentHash || '',
|
|
304
|
-
failCount: task.failCount || 0,
|
|
305
|
-
lastFailReason: task.lastFailReason || '',
|
|
306
|
-
assignee: task.assignee || '',
|
|
307
|
-
createdBy: task.createdBy || 'agent',
|
|
308
|
-
createdAt: task.createdAt,
|
|
309
|
-
updatedAt: task.updatedAt,
|
|
310
|
-
closedAt: task.closedAt || null,
|
|
311
|
-
metadata: JSON.stringify(task.metadata || {}),
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
// ═══ 内部工具 ═══════════════════════════════════════
|
|
316
|
-
const ALLOWED_ORDER_FIELDS = new Set([
|
|
317
|
-
'priority',
|
|
318
|
-
'created_at',
|
|
319
|
-
'updated_at',
|
|
320
|
-
'status',
|
|
321
|
-
'title',
|
|
322
|
-
'task_type',
|
|
323
|
-
'closed_at',
|
|
324
|
-
]);
|
|
325
|
-
const ALLOWED_DIRECTIONS = new Set(['ASC', 'DESC']);
|
|
326
|
-
/** orderBy 白名单校验,防止 SQL 注入 */
|
|
327
|
-
function _sanitizeOrderBy(orderBy) {
|
|
328
|
-
if (!orderBy) {
|
|
329
|
-
return 'priority ASC, created_at ASC';
|
|
330
|
-
}
|
|
331
|
-
return (orderBy
|
|
332
|
-
.split(',')
|
|
333
|
-
.map((clause) => {
|
|
334
|
-
const parts = clause.trim().split(/\s+/);
|
|
335
|
-
const field = parts[0];
|
|
336
|
-
if (!ALLOWED_ORDER_FIELDS.has(field)) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
const dir = ALLOWED_DIRECTIONS.has(parts[1]?.toUpperCase())
|
|
340
|
-
? parts[1].toUpperCase()
|
|
341
|
-
: 'ASC';
|
|
342
|
-
return `${field} ${dir}`;
|
|
343
|
-
})
|
|
344
|
-
.filter(Boolean)
|
|
345
|
-
.join(', ') || 'priority ASC, created_at ASC');
|
|
346
|
-
}
|
|
347
|
-
export default TaskRepositoryImpl;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ActionPipeline — 自动化动作管线
|
|
3
|
-
* 按顺序执行注册的 action handlers
|
|
4
|
-
*/
|
|
5
|
-
export declare class ActionPipeline {
|
|
6
|
-
#private;
|
|
7
|
-
constructor();
|
|
8
|
-
/**
|
|
9
|
-
* 注册动作处理器
|
|
10
|
-
* @param type 触发类型
|
|
11
|
-
* @param handler async (trigger, context) => result
|
|
12
|
-
*/
|
|
13
|
-
register(type: string, handler: (trigger: Record<string, unknown>, context: Record<string, unknown>) => Promise<unknown>): void;
|
|
14
|
-
/**
|
|
15
|
-
* 执行管线
|
|
16
|
-
* @param trigger
|
|
17
|
-
* @returns >}
|
|
18
|
-
*/
|
|
19
|
-
execute(trigger: {
|
|
20
|
-
type: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
params?: Record<string, unknown>;
|
|
23
|
-
}, context: Record<string, unknown>): Promise<{
|
|
24
|
-
success: boolean;
|
|
25
|
-
result: unknown;
|
|
26
|
-
error?: undefined;
|
|
27
|
-
} | {
|
|
28
|
-
success: boolean;
|
|
29
|
-
error: string;
|
|
30
|
-
result?: undefined;
|
|
31
|
-
}>;
|
|
32
|
-
/** 获取已注册的动作类型 */
|
|
33
|
-
getRegisteredTypes(): any[];
|
|
34
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ActionPipeline — 自动化动作管线
|
|
3
|
-
* 按顺序执行注册的 action handlers
|
|
4
|
-
*/
|
|
5
|
-
import Logger from '../../infrastructure/logging/Logger.js';
|
|
6
|
-
export class ActionPipeline {
|
|
7
|
-
#actions; // Map<type, handler>
|
|
8
|
-
#logger;
|
|
9
|
-
constructor() {
|
|
10
|
-
this.#actions = new Map();
|
|
11
|
-
this.#logger = Logger.getInstance();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* 注册动作处理器
|
|
15
|
-
* @param type 触发类型
|
|
16
|
-
* @param handler async (trigger, context) => result
|
|
17
|
-
*/
|
|
18
|
-
register(type, handler) {
|
|
19
|
-
this.#actions.set(type, handler);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* 执行管线
|
|
23
|
-
* @param trigger
|
|
24
|
-
* @returns >}
|
|
25
|
-
*/
|
|
26
|
-
async execute(trigger, context) {
|
|
27
|
-
const handler = this.#actions.get(trigger.type);
|
|
28
|
-
if (!handler) {
|
|
29
|
-
// 尝试通用 handler
|
|
30
|
-
const fallback = this.#actions.get('*');
|
|
31
|
-
if (fallback) {
|
|
32
|
-
return this.#runHandler(fallback, trigger, context);
|
|
33
|
-
}
|
|
34
|
-
this.#logger.warn(`[ActionPipeline] 未找到 handler: ${trigger.type}`);
|
|
35
|
-
return { success: false, error: `未知触发类型: ${trigger.type}` };
|
|
36
|
-
}
|
|
37
|
-
return this.#runHandler(handler, trigger, context);
|
|
38
|
-
}
|
|
39
|
-
/** 获取已注册的动作类型 */
|
|
40
|
-
getRegisteredTypes() {
|
|
41
|
-
return [...this.#actions.keys()];
|
|
42
|
-
}
|
|
43
|
-
async #runHandler(handler, trigger, context) {
|
|
44
|
-
try {
|
|
45
|
-
const result = await handler(trigger, context);
|
|
46
|
-
return { success: true, result };
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
this.#logger.error(`[ActionPipeline] handler 异常:`, err.message);
|
|
50
|
-
return { success: false, error: err.message };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AutomationOrchestrator — 自动化编排器
|
|
3
|
-
* 整合 TriggerResolver + ContextCollector + ActionPipeline
|
|
4
|
-
*/
|
|
5
|
-
import { ActionPipeline } from './ActionPipeline.js';
|
|
6
|
-
import { ContextCollector } from './ContextCollector.js';
|
|
7
|
-
import { TriggerResolver } from './TriggerResolver.js';
|
|
8
|
-
export declare class AutomationOrchestrator {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(options?: {
|
|
11
|
-
triggerResolver?: TriggerResolver;
|
|
12
|
-
contextCollector?: ContextCollector;
|
|
13
|
-
pipeline?: ActionPipeline;
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* 执行自动化流程
|
|
17
|
-
* @param trigger 原始触发
|
|
18
|
-
* @param context 原始上下文
|
|
19
|
-
* @returns >}
|
|
20
|
-
*/
|
|
21
|
-
run(trigger: string | Record<string, unknown>, context?: Record<string, unknown>): Promise<{
|
|
22
|
-
resolvedTrigger: {
|
|
23
|
-
type: string;
|
|
24
|
-
name: string;
|
|
25
|
-
params: {
|
|
26
|
-
option: string;
|
|
27
|
-
};
|
|
28
|
-
raw: string;
|
|
29
|
-
} | {
|
|
30
|
-
type: string;
|
|
31
|
-
name: string;
|
|
32
|
-
params: {
|
|
33
|
-
option?: undefined;
|
|
34
|
-
};
|
|
35
|
-
raw: string;
|
|
36
|
-
} | {
|
|
37
|
-
type: string;
|
|
38
|
-
name: string;
|
|
39
|
-
params: Record<string, unknown>;
|
|
40
|
-
raw: Record<string, unknown>;
|
|
41
|
-
} | {
|
|
42
|
-
type: string;
|
|
43
|
-
raw: never;
|
|
44
|
-
name?: undefined;
|
|
45
|
-
params?: undefined;
|
|
46
|
-
};
|
|
47
|
-
success: boolean;
|
|
48
|
-
result: unknown;
|
|
49
|
-
error?: undefined;
|
|
50
|
-
} | {
|
|
51
|
-
resolvedTrigger: {
|
|
52
|
-
type: string;
|
|
53
|
-
name: string;
|
|
54
|
-
params: {
|
|
55
|
-
option: string;
|
|
56
|
-
};
|
|
57
|
-
raw: string;
|
|
58
|
-
} | {
|
|
59
|
-
type: string;
|
|
60
|
-
name: string;
|
|
61
|
-
params: {
|
|
62
|
-
option?: undefined;
|
|
63
|
-
};
|
|
64
|
-
raw: string;
|
|
65
|
-
} | {
|
|
66
|
-
type: string;
|
|
67
|
-
name: string;
|
|
68
|
-
params: Record<string, unknown>;
|
|
69
|
-
raw: Record<string, unknown>;
|
|
70
|
-
} | {
|
|
71
|
-
type: string;
|
|
72
|
-
raw: never;
|
|
73
|
-
name?: undefined;
|
|
74
|
-
params?: undefined;
|
|
75
|
-
};
|
|
76
|
-
success: boolean;
|
|
77
|
-
error: string;
|
|
78
|
-
result?: undefined;
|
|
79
|
-
}>;
|
|
80
|
-
/** 注册动作处理器 */
|
|
81
|
-
registerAction(type: string, handler: (trigger: Record<string, unknown>, context: Record<string, unknown>) => Promise<unknown>): void;
|
|
82
|
-
/** 获取执行历史 */
|
|
83
|
-
getHistory(): Record<string, unknown>[];
|
|
84
|
-
/** 获取管线 */
|
|
85
|
-
getPipeline(): ActionPipeline;
|
|
86
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AutomationOrchestrator — 自动化编排器
|
|
3
|
-
* 整合 TriggerResolver + ContextCollector + ActionPipeline
|
|
4
|
-
*/
|
|
5
|
-
import Logger from '../../infrastructure/logging/Logger.js';
|
|
6
|
-
import { ActionPipeline } from './ActionPipeline.js';
|
|
7
|
-
import { ContextCollector } from './ContextCollector.js';
|
|
8
|
-
import { TriggerResolver } from './TriggerResolver.js';
|
|
9
|
-
export class AutomationOrchestrator {
|
|
10
|
-
#triggerResolver;
|
|
11
|
-
#contextCollector;
|
|
12
|
-
#pipeline;
|
|
13
|
-
#logger;
|
|
14
|
-
#history;
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
this.#triggerResolver = options.triggerResolver || new TriggerResolver();
|
|
17
|
-
this.#contextCollector = options.contextCollector || new ContextCollector();
|
|
18
|
-
this.#pipeline = options.pipeline || new ActionPipeline();
|
|
19
|
-
this.#logger = Logger.getInstance();
|
|
20
|
-
this.#history = [];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 执行自动化流程
|
|
24
|
-
* @param trigger 原始触发
|
|
25
|
-
* @param context 原始上下文
|
|
26
|
-
* @returns >}
|
|
27
|
-
*/
|
|
28
|
-
async run(trigger, context = {}) {
|
|
29
|
-
const resolvedTrigger = this.#triggerResolver.resolve(trigger);
|
|
30
|
-
const collectedContext = this.#contextCollector.collect(context);
|
|
31
|
-
this.#logger.info(`[AutomationOrchestrator] run type=${resolvedTrigger.type} name=${resolvedTrigger.name || ''}`);
|
|
32
|
-
const pipelineResult = await this.#pipeline.execute(resolvedTrigger, collectedContext);
|
|
33
|
-
const record = {
|
|
34
|
-
trigger: resolvedTrigger,
|
|
35
|
-
context: { filePath: collectedContext.filePath, language: collectedContext.language },
|
|
36
|
-
result: pipelineResult,
|
|
37
|
-
timestamp: new Date().toISOString(),
|
|
38
|
-
};
|
|
39
|
-
this.#history.push(record);
|
|
40
|
-
if (this.#history.length > 200) {
|
|
41
|
-
this.#history = this.#history.slice(-200);
|
|
42
|
-
}
|
|
43
|
-
return { ...pipelineResult, resolvedTrigger };
|
|
44
|
-
}
|
|
45
|
-
/** 注册动作处理器 */
|
|
46
|
-
registerAction(type, handler) {
|
|
47
|
-
this.#pipeline.register(type, handler);
|
|
48
|
-
}
|
|
49
|
-
/** 获取执行历史 */
|
|
50
|
-
getHistory() {
|
|
51
|
-
return [...this.#history];
|
|
52
|
-
}
|
|
53
|
-
/** 获取管线 */
|
|
54
|
-
getPipeline() {
|
|
55
|
-
return this.#pipeline;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContextCollector — 自动化上下文收集器
|
|
3
|
-
* 收集并规范化自动化执行所需的上下文信息
|
|
4
|
-
*/
|
|
5
|
-
export declare class ContextCollector {
|
|
6
|
-
#private;
|
|
7
|
-
/**
|
|
8
|
-
* 收集上下文
|
|
9
|
-
* @param rawContext 原始上下文
|
|
10
|
-
* @returns 规范化的上下文
|
|
11
|
-
*/
|
|
12
|
-
collect(rawContext?: Record<string, unknown>): {
|
|
13
|
-
filePath: {} | null;
|
|
14
|
-
content: {} | null;
|
|
15
|
-
language: {} | null;
|
|
16
|
-
projectRoot: {} | null;
|
|
17
|
-
user: {};
|
|
18
|
-
timestamp: string;
|
|
19
|
-
environment: {
|
|
20
|
-
platform: NodeJS.Platform;
|
|
21
|
-
nodeVersion: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ContextCollector — 自动化上下文收集器
|
|
3
|
-
* 收集并规范化自动化执行所需的上下文信息
|
|
4
|
-
*/
|
|
5
|
-
import { LanguageService } from '../../shared/LanguageService.js';
|
|
6
|
-
export class ContextCollector {
|
|
7
|
-
/**
|
|
8
|
-
* 收集上下文
|
|
9
|
-
* @param rawContext 原始上下文
|
|
10
|
-
* @returns 规范化的上下文
|
|
11
|
-
*/
|
|
12
|
-
collect(rawContext = {}) {
|
|
13
|
-
return {
|
|
14
|
-
...rawContext,
|
|
15
|
-
filePath: rawContext.filePath || null,
|
|
16
|
-
content: rawContext.content || null,
|
|
17
|
-
language: rawContext.language ||
|
|
18
|
-
this.#detectLanguage(rawContext.filePath),
|
|
19
|
-
projectRoot: rawContext.projectRoot || null,
|
|
20
|
-
user: rawContext.user || 'default',
|
|
21
|
-
timestamp: new Date().toISOString(),
|
|
22
|
-
environment: {
|
|
23
|
-
platform: process.platform,
|
|
24
|
-
nodeVersion: process.version,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
#detectLanguage(filePath) {
|
|
29
|
-
if (!filePath) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const lang = LanguageService.inferLang(filePath);
|
|
33
|
-
return lang === 'unknown' ? null : lang;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DirectiveDetector - 文件内指令检测器
|
|
3
|
-
*
|
|
4
|
-
* 检测 // as:c(创建)、// as:s(搜索)、// as:a(审计)等指令
|
|
5
|
-
* V2 ESM 版本,对应 V1 DirectiveDetector.js
|
|
6
|
-
*/
|
|
7
|
-
/** 指令标记常量 */
|
|
8
|
-
export declare const MARKS: {
|
|
9
|
-
HEADER_INCLUDE: string;
|
|
10
|
-
HEADER_IMPORT: string;
|
|
11
|
-
HEADER_INCLUDE_SHORT: string;
|
|
12
|
-
HEADER_IMPORT_SHORT: string;
|
|
13
|
-
CREATE_SHORT: string;
|
|
14
|
-
CREATE_ALIAS: string;
|
|
15
|
-
AUDIT_SHORT: string;
|
|
16
|
-
AUDIT_ALIAS: string;
|
|
17
|
-
SEARCH_SHORT: string;
|
|
18
|
-
SEARCH_LONG: string;
|
|
19
|
-
SEARCH_ALIAS: string;
|
|
20
|
-
ALINK: string;
|
|
21
|
-
};
|
|
22
|
-
/** 正则表达式 */
|
|
23
|
-
export declare const REGEX: {
|
|
24
|
-
CREATE_LINE: RegExp;
|
|
25
|
-
CREATE_REMOVE: RegExp;
|
|
26
|
-
HEADER_OBJC: RegExp;
|
|
27
|
-
HEADER_SWIFT: RegExp;
|
|
28
|
-
IMPORT_OBJC: RegExp;
|
|
29
|
-
IMPORT_SWIFT: RegExp;
|
|
30
|
-
SEARCH_MARK: RegExp;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* 检测文件内容中的所有触发指令
|
|
34
|
-
*
|
|
35
|
-
* @param data 文件内容
|
|
36
|
-
* @param filename 文件名
|
|
37
|
-
* @returns {{ importArray: string[], headerLine: string|null, alinkLine: string|null,
|
|
38
|
-
* createLine: string|null, createOption: string|null,
|
|
39
|
-
* guardLine: string|null, searchLine: string|null, isSwift: boolean, language: string }}
|
|
40
|
-
*/
|
|
41
|
-
export declare function detectTriggers(data: string, filename: string): {
|
|
42
|
-
importArray: string[];
|
|
43
|
-
headerLine: string | null;
|
|
44
|
-
alinkLine: string | null;
|
|
45
|
-
createLine: string | null;
|
|
46
|
-
createOption: string | null;
|
|
47
|
-
guardLine: string | null;
|
|
48
|
-
searchLine: string | null;
|
|
49
|
-
isSwift: boolean;
|
|
50
|
-
language: string;
|
|
51
|
-
};
|