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,140 +0,0 @@
|
|
|
1
|
-
export interface TaskProps {
|
|
2
|
-
id?: string | null;
|
|
3
|
-
parentId?: string | null;
|
|
4
|
-
childSeq?: number;
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
design?: string;
|
|
8
|
-
acceptance?: string;
|
|
9
|
-
notes?: string;
|
|
10
|
-
status?: string;
|
|
11
|
-
priority?: number;
|
|
12
|
-
taskType?: string;
|
|
13
|
-
closeReason?: string;
|
|
14
|
-
failCount?: number;
|
|
15
|
-
lastFailReason?: string;
|
|
16
|
-
contentHash?: string | null;
|
|
17
|
-
assignee?: string;
|
|
18
|
-
createdBy?: string;
|
|
19
|
-
createdAt?: number;
|
|
20
|
-
updatedAt?: number;
|
|
21
|
-
closedAt?: number | null;
|
|
22
|
-
knowledgeContext?: Record<string, unknown> | null;
|
|
23
|
-
metadata?: Record<string, unknown>;
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}
|
|
26
|
-
interface TaskRow {
|
|
27
|
-
id?: unknown;
|
|
28
|
-
parent_id?: unknown;
|
|
29
|
-
child_seq?: unknown;
|
|
30
|
-
title?: unknown;
|
|
31
|
-
description?: unknown;
|
|
32
|
-
design?: unknown;
|
|
33
|
-
acceptance?: unknown;
|
|
34
|
-
notes?: unknown;
|
|
35
|
-
status?: unknown;
|
|
36
|
-
priority?: unknown;
|
|
37
|
-
task_type?: unknown;
|
|
38
|
-
close_reason?: unknown;
|
|
39
|
-
content_hash?: unknown;
|
|
40
|
-
fail_count?: unknown;
|
|
41
|
-
last_fail_reason?: unknown;
|
|
42
|
-
assignee?: unknown;
|
|
43
|
-
created_by?: unknown;
|
|
44
|
-
created_at?: unknown;
|
|
45
|
-
updated_at?: unknown;
|
|
46
|
-
closed_at?: unknown;
|
|
47
|
-
metadata?: unknown;
|
|
48
|
-
parentId?: unknown;
|
|
49
|
-
childSeq?: unknown;
|
|
50
|
-
taskType?: unknown;
|
|
51
|
-
closeReason?: unknown;
|
|
52
|
-
contentHash?: unknown;
|
|
53
|
-
failCount?: unknown;
|
|
54
|
-
lastFailReason?: unknown;
|
|
55
|
-
createdBy?: unknown;
|
|
56
|
-
createdAt?: unknown;
|
|
57
|
-
updatedAt?: unknown;
|
|
58
|
-
closedAt?: unknown;
|
|
59
|
-
[key: string]: unknown;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Task — 任务实体
|
|
63
|
-
*
|
|
64
|
-
* 参考 Beads Issue 结构,裁剪为 AutoSnippet 所需的核心字段。
|
|
65
|
-
*
|
|
66
|
-
* 字段分组:
|
|
67
|
-
* Core Identification → id, parentId, contentHash
|
|
68
|
-
* Content → title, description, design, acceptance
|
|
69
|
-
* Status & Workflow → status, priority, taskType
|
|
70
|
-
* Assignment → assignee, claimedAt
|
|
71
|
-
* Timestamps → createdAt, updatedAt, closedAt
|
|
72
|
-
* Knowledge Bridge → knowledgeContext (运行时,不持久化)
|
|
73
|
-
*/
|
|
74
|
-
export declare class Task {
|
|
75
|
-
acceptance: string;
|
|
76
|
-
assignee: string;
|
|
77
|
-
childSeq: number;
|
|
78
|
-
closeReason: string;
|
|
79
|
-
closedAt: number | null;
|
|
80
|
-
contentHash: string | null;
|
|
81
|
-
createdAt: number;
|
|
82
|
-
createdBy: string;
|
|
83
|
-
description: string;
|
|
84
|
-
design: string;
|
|
85
|
-
failCount: number;
|
|
86
|
-
id: string | null;
|
|
87
|
-
lastFailReason: string;
|
|
88
|
-
metadata: Record<string, unknown>;
|
|
89
|
-
notes: string;
|
|
90
|
-
parentId: string | null;
|
|
91
|
-
priority: number;
|
|
92
|
-
status: string;
|
|
93
|
-
taskType: string;
|
|
94
|
-
title: string;
|
|
95
|
-
updatedAt: number;
|
|
96
|
-
knowledgeContext: Record<string, unknown> | null;
|
|
97
|
-
constructor(props?: TaskProps);
|
|
98
|
-
claim(assignee?: string): void;
|
|
99
|
-
close(reason?: string): void;
|
|
100
|
-
reopen(): void;
|
|
101
|
-
pin(): void;
|
|
102
|
-
unpin(reason?: string): void;
|
|
103
|
-
defer(reason?: string): void;
|
|
104
|
-
fail(reason: string): void;
|
|
105
|
-
/**
|
|
106
|
-
* 计算内容哈希(用于去重检测)
|
|
107
|
-
* 相同标题+描述+类型 = 重复任务
|
|
108
|
-
*/
|
|
109
|
-
computeContentHash(): string;
|
|
110
|
-
validate(): boolean;
|
|
111
|
-
/** 是否有效(快捷校验) */
|
|
112
|
-
isValid(): boolean;
|
|
113
|
-
toJSON(): {
|
|
114
|
-
knowledgeContext?: Record<string, unknown> | undefined;
|
|
115
|
-
id: string | null;
|
|
116
|
-
parentId: string | null;
|
|
117
|
-
title: string;
|
|
118
|
-
description: string;
|
|
119
|
-
design: string;
|
|
120
|
-
acceptance: string;
|
|
121
|
-
notes: string;
|
|
122
|
-
status: string;
|
|
123
|
-
priority: number;
|
|
124
|
-
taskType: string;
|
|
125
|
-
closeReason: string;
|
|
126
|
-
assignee: string;
|
|
127
|
-
createdBy: string;
|
|
128
|
-
createdAt: number;
|
|
129
|
-
updatedAt: number;
|
|
130
|
-
closedAt: number | null;
|
|
131
|
-
contentHash: string | null;
|
|
132
|
-
failCount: number;
|
|
133
|
-
lastFailReason: string;
|
|
134
|
-
metadata: Record<string, unknown>;
|
|
135
|
-
};
|
|
136
|
-
static fromJSON(data: unknown): Task;
|
|
137
|
-
/** 从数据库行构造 Task(snake_case → camelCase) */
|
|
138
|
-
static fromRow(row: TaskRow | null): Task | null;
|
|
139
|
-
}
|
|
140
|
-
export default Task;
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
/**
|
|
3
|
-
* Task — 任务实体
|
|
4
|
-
*
|
|
5
|
-
* 参考 Beads Issue 结构,裁剪为 AutoSnippet 所需的核心字段。
|
|
6
|
-
*
|
|
7
|
-
* 字段分组:
|
|
8
|
-
* Core Identification → id, parentId, contentHash
|
|
9
|
-
* Content → title, description, design, acceptance
|
|
10
|
-
* Status & Workflow → status, priority, taskType
|
|
11
|
-
* Assignment → assignee, claimedAt
|
|
12
|
-
* Timestamps → createdAt, updatedAt, closedAt
|
|
13
|
-
* Knowledge Bridge → knowledgeContext (运行时,不持久化)
|
|
14
|
-
*/
|
|
15
|
-
export class Task {
|
|
16
|
-
acceptance;
|
|
17
|
-
assignee;
|
|
18
|
-
childSeq;
|
|
19
|
-
closeReason;
|
|
20
|
-
closedAt;
|
|
21
|
-
contentHash;
|
|
22
|
-
createdAt;
|
|
23
|
-
createdBy;
|
|
24
|
-
description;
|
|
25
|
-
design;
|
|
26
|
-
failCount;
|
|
27
|
-
id;
|
|
28
|
-
lastFailReason;
|
|
29
|
-
metadata;
|
|
30
|
-
notes;
|
|
31
|
-
parentId;
|
|
32
|
-
priority;
|
|
33
|
-
status;
|
|
34
|
-
taskType;
|
|
35
|
-
title;
|
|
36
|
-
updatedAt;
|
|
37
|
-
knowledgeContext;
|
|
38
|
-
constructor(props = {}) {
|
|
39
|
-
// ── Core Identification ──
|
|
40
|
-
this.id = props.id || null;
|
|
41
|
-
this.parentId = props.parentId || null;
|
|
42
|
-
this.childSeq = props.childSeq || 0;
|
|
43
|
-
// ── Content ──
|
|
44
|
-
this.title = props.title || '';
|
|
45
|
-
this.description = props.description || '';
|
|
46
|
-
this.design = props.design || '';
|
|
47
|
-
this.acceptance = props.acceptance || '';
|
|
48
|
-
this.notes = props.notes || '';
|
|
49
|
-
// ── Status & Workflow ──
|
|
50
|
-
this.status = props.status || 'open';
|
|
51
|
-
this.priority = props.priority ?? 2;
|
|
52
|
-
this.taskType = props.taskType || 'task';
|
|
53
|
-
this.closeReason = props.closeReason || '';
|
|
54
|
-
this.failCount = props.failCount || 0;
|
|
55
|
-
this.lastFailReason = props.lastFailReason || '';
|
|
56
|
-
// ── Content Hash (去重) ──
|
|
57
|
-
this.contentHash = props.contentHash || null;
|
|
58
|
-
// ── Assignment ──
|
|
59
|
-
this.assignee = props.assignee || '';
|
|
60
|
-
this.createdBy = props.createdBy || 'agent';
|
|
61
|
-
// ── Timestamps ──
|
|
62
|
-
this.createdAt = props.createdAt || Math.floor(Date.now() / 1000);
|
|
63
|
-
this.updatedAt = props.updatedAt || Math.floor(Date.now() / 1000);
|
|
64
|
-
this.closedAt = props.closedAt || null;
|
|
65
|
-
// ── Knowledge Bridge (运行时填充, 不持久化) ──
|
|
66
|
-
this.knowledgeContext = props.knowledgeContext || null;
|
|
67
|
-
// ── Metadata (可扩展 JSON) ──
|
|
68
|
-
this.metadata = props.metadata || {};
|
|
69
|
-
}
|
|
70
|
-
// ── 生命周期方法 ──
|
|
71
|
-
claim(assignee = 'agent') {
|
|
72
|
-
if (this.status === 'closed') {
|
|
73
|
-
throw new Error('Cannot claim a closed task');
|
|
74
|
-
}
|
|
75
|
-
if (this.status === 'pinned') {
|
|
76
|
-
throw new Error('Cannot claim a pinned decision. Use unpin_decision or revise_decision instead.');
|
|
77
|
-
}
|
|
78
|
-
this.status = 'in_progress';
|
|
79
|
-
this.assignee = assignee;
|
|
80
|
-
this.updatedAt = Math.floor(Date.now() / 1000);
|
|
81
|
-
}
|
|
82
|
-
close(reason = 'Completed') {
|
|
83
|
-
if (this.status === 'pinned') {
|
|
84
|
-
throw new Error('Cannot close a pinned decision directly. Use unpin_decision or revise_decision instead.');
|
|
85
|
-
}
|
|
86
|
-
this.status = 'closed';
|
|
87
|
-
this.closeReason = reason;
|
|
88
|
-
this.closedAt = Math.floor(Date.now() / 1000);
|
|
89
|
-
this.updatedAt = this.closedAt;
|
|
90
|
-
}
|
|
91
|
-
reopen() {
|
|
92
|
-
this.status = 'open';
|
|
93
|
-
this.closedAt = null;
|
|
94
|
-
this.closeReason = '';
|
|
95
|
-
this.updatedAt = Math.floor(Date.now() / 1000);
|
|
96
|
-
}
|
|
97
|
-
pin() {
|
|
98
|
-
if (this.status === 'closed') {
|
|
99
|
-
throw new Error('Cannot pin a closed task');
|
|
100
|
-
}
|
|
101
|
-
this.status = 'pinned';
|
|
102
|
-
this.updatedAt = Math.floor(Date.now() / 1000);
|
|
103
|
-
}
|
|
104
|
-
unpin(reason = '') {
|
|
105
|
-
if (this.status !== 'pinned') {
|
|
106
|
-
throw new Error('Can only unpin a pinned task');
|
|
107
|
-
}
|
|
108
|
-
this.status = 'closed';
|
|
109
|
-
this.closeReason = reason || 'Unpinned by user';
|
|
110
|
-
this.closedAt = Math.floor(Date.now() / 1000);
|
|
111
|
-
this.updatedAt = this.closedAt;
|
|
112
|
-
}
|
|
113
|
-
defer(reason = '') {
|
|
114
|
-
if (this.status === 'pinned') {
|
|
115
|
-
throw new Error('Cannot defer a pinned decision. Use unpin_decision or revise_decision instead.');
|
|
116
|
-
}
|
|
117
|
-
this.status = 'deferred';
|
|
118
|
-
if (reason) {
|
|
119
|
-
this.notes = `[deferred] ${reason}`;
|
|
120
|
-
}
|
|
121
|
-
this.updatedAt = Math.floor(Date.now() / 1000);
|
|
122
|
-
}
|
|
123
|
-
fail(reason) {
|
|
124
|
-
if (this.status === 'closed') {
|
|
125
|
-
throw new Error('Cannot fail a closed task');
|
|
126
|
-
}
|
|
127
|
-
if (this.status === 'pinned') {
|
|
128
|
-
throw new Error('Cannot fail a pinned decision. Use unpin_decision or revise_decision instead.');
|
|
129
|
-
}
|
|
130
|
-
this.status = 'open';
|
|
131
|
-
this.failCount += 1;
|
|
132
|
-
this.lastFailReason = reason || 'Unknown failure';
|
|
133
|
-
this.assignee = '';
|
|
134
|
-
this.updatedAt = Math.floor(Date.now() / 1000);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* 计算内容哈希(用于去重检测)
|
|
138
|
-
* 相同标题+描述+类型 = 重复任务
|
|
139
|
-
*/
|
|
140
|
-
computeContentHash() {
|
|
141
|
-
const content = `${this.title}|${this.description}|${this.taskType}`;
|
|
142
|
-
this.contentHash = createHash('sha256').update(content).digest('hex').substring(0, 12);
|
|
143
|
-
return this.contentHash;
|
|
144
|
-
}
|
|
145
|
-
// ── 校验 ──
|
|
146
|
-
validate() {
|
|
147
|
-
if (!this.title || this.title.length === 0) {
|
|
148
|
-
throw new Error('title is required');
|
|
149
|
-
}
|
|
150
|
-
if (this.title.length > 500) {
|
|
151
|
-
throw new Error(`title must be 500 characters or less (got ${this.title.length})`);
|
|
152
|
-
}
|
|
153
|
-
if (typeof this.priority !== 'number' ||
|
|
154
|
-
!Number.isInteger(this.priority) ||
|
|
155
|
-
this.priority < 0 ||
|
|
156
|
-
this.priority > 4) {
|
|
157
|
-
throw new Error(`priority must be an integer between 0 and 4 (got ${this.priority})`);
|
|
158
|
-
}
|
|
159
|
-
const validStatuses = ['open', 'in_progress', 'deferred', 'closed', 'pinned'];
|
|
160
|
-
if (!validStatuses.includes(this.status)) {
|
|
161
|
-
throw new Error(`invalid status: ${this.status}`);
|
|
162
|
-
}
|
|
163
|
-
const validTypes = ['epic', 'task', 'bug', 'chore', 'decision'];
|
|
164
|
-
if (!validTypes.includes(this.taskType)) {
|
|
165
|
-
throw new Error(`invalid task type: ${this.taskType}`);
|
|
166
|
-
}
|
|
167
|
-
if (this.status === 'closed' && !this.closedAt) {
|
|
168
|
-
throw new Error('closed tasks must have closedAt timestamp');
|
|
169
|
-
}
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
/** 是否有效(快捷校验) */
|
|
173
|
-
isValid() {
|
|
174
|
-
try {
|
|
175
|
-
this.validate();
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
toJSON() {
|
|
183
|
-
return {
|
|
184
|
-
id: this.id,
|
|
185
|
-
parentId: this.parentId,
|
|
186
|
-
title: this.title,
|
|
187
|
-
description: this.description,
|
|
188
|
-
design: this.design,
|
|
189
|
-
acceptance: this.acceptance,
|
|
190
|
-
notes: this.notes,
|
|
191
|
-
status: this.status,
|
|
192
|
-
priority: this.priority,
|
|
193
|
-
taskType: this.taskType,
|
|
194
|
-
closeReason: this.closeReason,
|
|
195
|
-
assignee: this.assignee,
|
|
196
|
-
createdBy: this.createdBy,
|
|
197
|
-
createdAt: this.createdAt,
|
|
198
|
-
updatedAt: this.updatedAt,
|
|
199
|
-
closedAt: this.closedAt,
|
|
200
|
-
contentHash: this.contentHash,
|
|
201
|
-
failCount: this.failCount,
|
|
202
|
-
lastFailReason: this.lastFailReason,
|
|
203
|
-
metadata: this.metadata,
|
|
204
|
-
...(this.knowledgeContext ? { knowledgeContext: this.knowledgeContext } : {}),
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
static fromJSON(data) {
|
|
208
|
-
if (!data) {
|
|
209
|
-
return new Task();
|
|
210
|
-
}
|
|
211
|
-
return new Task(data);
|
|
212
|
-
}
|
|
213
|
-
/** 从数据库行构造 Task(snake_case → camelCase) */
|
|
214
|
-
static fromRow(row) {
|
|
215
|
-
if (!row) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
// 兼容 raw SQL 返回的 snake_case 和 Drizzle 返回的 camelCase
|
|
219
|
-
return new Task({
|
|
220
|
-
id: row.id,
|
|
221
|
-
parentId: (row.parent_id ?? row.parentId),
|
|
222
|
-
childSeq: (row.child_seq ?? row.childSeq),
|
|
223
|
-
title: row.title,
|
|
224
|
-
description: row.description,
|
|
225
|
-
design: row.design,
|
|
226
|
-
acceptance: row.acceptance,
|
|
227
|
-
notes: row.notes,
|
|
228
|
-
status: row.status,
|
|
229
|
-
priority: row.priority,
|
|
230
|
-
taskType: (row.task_type ?? row.taskType),
|
|
231
|
-
closeReason: (row.close_reason ?? row.closeReason),
|
|
232
|
-
contentHash: (row.content_hash ?? row.contentHash),
|
|
233
|
-
failCount: (row.fail_count ?? row.failCount),
|
|
234
|
-
lastFailReason: (row.last_fail_reason ?? row.lastFailReason),
|
|
235
|
-
assignee: row.assignee,
|
|
236
|
-
createdBy: (row.created_by ?? row.createdBy),
|
|
237
|
-
createdAt: (row.created_at ?? row.createdAt),
|
|
238
|
-
updatedAt: (row.updated_at ?? row.updatedAt),
|
|
239
|
-
closedAt: (row.closed_at ?? row.closedAt),
|
|
240
|
-
metadata: (() => {
|
|
241
|
-
if (typeof row.metadata !== 'string') {
|
|
242
|
-
return row.metadata || {};
|
|
243
|
-
}
|
|
244
|
-
try {
|
|
245
|
-
return JSON.parse(row.metadata);
|
|
246
|
-
}
|
|
247
|
-
catch {
|
|
248
|
-
return {};
|
|
249
|
-
}
|
|
250
|
-
})(),
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
export default Task;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 任务依赖类型
|
|
3
|
-
*
|
|
4
|
-
* Phase 1 引入 6 种核心依赖类型,按 "是否影响就绪" 分为两组。
|
|
5
|
-
*
|
|
6
|
-
* 阻塞型: blocks, waits-for → 影响 ready 计算
|
|
7
|
-
* 结构型: parent-child → 仅层次关系
|
|
8
|
-
* 关联型: discovered-from, related, knowledge-ref → 不影响 ready
|
|
9
|
-
*/
|
|
10
|
-
export declare const DepType: Readonly<{
|
|
11
|
-
BLOCKS: "blocks";
|
|
12
|
-
WAITS_FOR: "waits-for";
|
|
13
|
-
PARENT_CHILD: "parent-child";
|
|
14
|
-
DISCOVERED_FROM: "discovered-from";
|
|
15
|
-
RELATED: "related";
|
|
16
|
-
KNOWLEDGE_REF: "knowledge-ref";
|
|
17
|
-
SUPERSEDES: "supersedes";
|
|
18
|
-
}>;
|
|
19
|
-
/** 判断依赖类型是否影响就绪计算 */
|
|
20
|
-
export declare function affectsReadyWork(depType: string): boolean;
|
|
21
|
-
/** 判断依赖类型是否合法 */
|
|
22
|
-
export declare function isValidDepType(depType: string): boolean;
|
|
23
|
-
export default DepType;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 任务依赖类型
|
|
3
|
-
*
|
|
4
|
-
* Phase 1 引入 6 种核心依赖类型,按 "是否影响就绪" 分为两组。
|
|
5
|
-
*
|
|
6
|
-
* 阻塞型: blocks, waits-for → 影响 ready 计算
|
|
7
|
-
* 结构型: parent-child → 仅层次关系
|
|
8
|
-
* 关联型: discovered-from, related, knowledge-ref → 不影响 ready
|
|
9
|
-
*/
|
|
10
|
-
export const DepType = Object.freeze({
|
|
11
|
-
// ── 阻塞型(影响 ready 计算)──
|
|
12
|
-
BLOCKS: 'blocks',
|
|
13
|
-
WAITS_FOR: 'waits-for',
|
|
14
|
-
// ── 结构型(建立层次,不影响 ready)──
|
|
15
|
-
PARENT_CHILD: 'parent-child',
|
|
16
|
-
// ── 关联型(不影响 ready,构建知识/因果图谱)──
|
|
17
|
-
DISCOVERED_FROM: 'discovered-from',
|
|
18
|
-
RELATED: 'related',
|
|
19
|
-
KNOWLEDGE_REF: 'knowledge-ref', // AutoSnippet 独有:关联知识条目
|
|
20
|
-
SUPERSEDES: 'supersedes', // 决策演化链:新决策取代旧决策
|
|
21
|
-
});
|
|
22
|
-
/** 所有合法的依赖类型值列表 */
|
|
23
|
-
const ALL_DEP_TYPES = Object.values(DepType);
|
|
24
|
-
/** 影响就绪计算的依赖类型集合 */
|
|
25
|
-
const BLOCKING_TYPES = new Set([DepType.BLOCKS, DepType.WAITS_FOR]);
|
|
26
|
-
/** 判断依赖类型是否影响就绪计算 */
|
|
27
|
-
export function affectsReadyWork(depType) {
|
|
28
|
-
return BLOCKING_TYPES.has(depType);
|
|
29
|
-
}
|
|
30
|
-
/** 判断依赖类型是否合法 */
|
|
31
|
-
export function isValidDepType(depType) {
|
|
32
|
-
return ALL_DEP_TYPES.includes(depType);
|
|
33
|
-
}
|
|
34
|
-
export default DepType;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { DrizzleDB } from '../../infrastructure/database/drizzle/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* TaskIdGenerator — 短 Hash ID 生成器
|
|
4
|
-
*
|
|
5
|
-
* 渐进式长度扩展(随任务数增长自动加长):
|
|
6
|
-
* 0-500 tasks → 4 字符 (16^4 = 65,536 组合)
|
|
7
|
-
* 500-1500 → 5 字符 (16^5 = 1,048,576)
|
|
8
|
-
* 1500+ → 6 字符 (16^6 = 16,777,216)
|
|
9
|
-
*
|
|
10
|
-
* 前缀 'asd-',与 Beads 的 'bd-' 区分。
|
|
11
|
-
*/
|
|
12
|
-
interface DbHandle {
|
|
13
|
-
prepare(sql: string): {
|
|
14
|
-
get(...params: unknown[]): Record<string, unknown> | undefined;
|
|
15
|
-
run(...params: unknown[]): unknown;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export declare class TaskIdGenerator {
|
|
19
|
-
#private;
|
|
20
|
-
_db: DbHandle;
|
|
21
|
-
_prefix: string;
|
|
22
|
-
/** @param db raw SQLite handle */
|
|
23
|
-
constructor(db: DbHandle, drizzle?: DrizzleDB);
|
|
24
|
-
/**
|
|
25
|
-
* 生成新的短 Hash ID
|
|
26
|
-
* @returns 如 'asd-a1b2'
|
|
27
|
-
*/
|
|
28
|
-
generate(): string;
|
|
29
|
-
/**
|
|
30
|
-
* 生成子任务 ID
|
|
31
|
-
* asd-a3f8 → asd-a3f8.1, asd-a3f8.2, ...
|
|
32
|
-
* ★ Drizzle 类型安全 SELECT + UPDATE
|
|
33
|
-
*/
|
|
34
|
-
generateChild(parentId: string): string;
|
|
35
|
-
/** ★ Drizzle 类型安全 COUNT */
|
|
36
|
-
private _getTaskCount;
|
|
37
|
-
/** ★ Drizzle 类型安全 EXISTS */
|
|
38
|
-
private _exists;
|
|
39
|
-
}
|
|
40
|
-
export default TaskIdGenerator;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { eq, sql } from 'drizzle-orm';
|
|
3
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import { getDrizzle } from '../../infrastructure/database/drizzle/index.js';
|
|
5
|
-
import { tasks } from '../../infrastructure/database/drizzle/schema.js';
|
|
6
|
-
export class TaskIdGenerator {
|
|
7
|
-
_db;
|
|
8
|
-
_prefix;
|
|
9
|
-
#drizzle;
|
|
10
|
-
/** @param db raw SQLite handle */
|
|
11
|
-
constructor(db, drizzle) {
|
|
12
|
-
this._db = db;
|
|
13
|
-
this._prefix = 'asd';
|
|
14
|
-
this.#drizzle = drizzle ?? getDrizzle();
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 生成新的短 Hash ID
|
|
18
|
-
* @returns 如 'asd-a1b2'
|
|
19
|
-
*/
|
|
20
|
-
generate() {
|
|
21
|
-
const taskCount = this._getTaskCount();
|
|
22
|
-
const hashLen = taskCount < 500 ? 4 : taskCount < 1500 ? 5 : 6;
|
|
23
|
-
// 尝试生成无冲突 ID(最多 10 次)
|
|
24
|
-
for (let attempt = 0; attempt < 10; attempt++) {
|
|
25
|
-
const uuid = uuidv4();
|
|
26
|
-
const hash = createHash('sha256').update(uuid).digest('hex');
|
|
27
|
-
const shortHash = hash.substring(0, hashLen);
|
|
28
|
-
const id = `${this._prefix}-${shortHash}`;
|
|
29
|
-
if (!this._exists(id)) {
|
|
30
|
-
return id;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// 回退到 6 位 + 冲突检查 + 终极 8 位兜底
|
|
34
|
-
const uuid = uuidv4();
|
|
35
|
-
const hash = createHash('sha256').update(uuid).digest('hex');
|
|
36
|
-
const fallbackId = `${this._prefix}-${hash.substring(0, 6)}`;
|
|
37
|
-
if (!this._exists(fallbackId)) {
|
|
38
|
-
return fallbackId;
|
|
39
|
-
}
|
|
40
|
-
return `${this._prefix}-${hash.substring(0, 8)}`;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 生成子任务 ID
|
|
44
|
-
* asd-a3f8 → asd-a3f8.1, asd-a3f8.2, ...
|
|
45
|
-
* ★ Drizzle 类型安全 SELECT + UPDATE
|
|
46
|
-
*/
|
|
47
|
-
generateChild(parentId) {
|
|
48
|
-
const parent = this.#drizzle
|
|
49
|
-
.select({ childSeq: tasks.childSeq })
|
|
50
|
-
.from(tasks)
|
|
51
|
-
.where(eq(tasks.id, parentId))
|
|
52
|
-
.get();
|
|
53
|
-
if (!parent) {
|
|
54
|
-
throw new Error(`Parent task not found: ${parentId}`);
|
|
55
|
-
}
|
|
56
|
-
const nextSeq = (parent.childSeq || 0) + 1;
|
|
57
|
-
this.#drizzle.update(tasks).set({ childSeq: nextSeq }).where(eq(tasks.id, parentId)).run();
|
|
58
|
-
return `${parentId}.${nextSeq}`;
|
|
59
|
-
}
|
|
60
|
-
/** ★ Drizzle 类型安全 COUNT */
|
|
61
|
-
_getTaskCount() {
|
|
62
|
-
const row = this.#drizzle.select({ cnt: sql `COUNT(*)` }).from(tasks).get();
|
|
63
|
-
return row?.cnt || 0;
|
|
64
|
-
}
|
|
65
|
-
/** ★ Drizzle 类型安全 EXISTS */
|
|
66
|
-
_exists(id) {
|
|
67
|
-
const row = this.#drizzle
|
|
68
|
-
.select({ x: sql `1` })
|
|
69
|
-
.from(tasks)
|
|
70
|
-
.where(eq(tasks.id, id))
|
|
71
|
-
.get();
|
|
72
|
-
return !!row;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export default TaskIdGenerator;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snippets API 路由
|
|
3
|
-
* Snippet = Recipe 的附属产物,从 Recipe 实时生成,不存 DB
|
|
4
|
-
*/
|
|
5
|
-
import express from 'express';
|
|
6
|
-
import { getServiceContainer } from '../../injection/ServiceContainer.js';
|
|
7
|
-
import { NotFoundError } from '../../shared/errors/index.js';
|
|
8
|
-
const router = express.Router();
|
|
9
|
-
/**
|
|
10
|
-
* GET /api/v1/snippets
|
|
11
|
-
* 从 Recipe 实时生成 Snippet 列表
|
|
12
|
-
*/
|
|
13
|
-
router.get('/', async (req, res) => {
|
|
14
|
-
const container = getServiceContainer();
|
|
15
|
-
const snippetFactory = container.get('snippetFactory');
|
|
16
|
-
const { language, category, keyword } = req.query;
|
|
17
|
-
const filters = {};
|
|
18
|
-
if (language) {
|
|
19
|
-
filters.language = String(language);
|
|
20
|
-
}
|
|
21
|
-
if (category) {
|
|
22
|
-
filters.category = String(category);
|
|
23
|
-
}
|
|
24
|
-
if (keyword) {
|
|
25
|
-
filters.keyword = String(keyword);
|
|
26
|
-
}
|
|
27
|
-
const snippets = await snippetFactory.listSnippets(filters);
|
|
28
|
-
res.json({
|
|
29
|
-
success: true,
|
|
30
|
-
data: {
|
|
31
|
-
snippets,
|
|
32
|
-
total: snippets.length,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* GET /api/v1/snippets/:id
|
|
38
|
-
* 从单个 Recipe 实时生成 Snippet
|
|
39
|
-
*/
|
|
40
|
-
router.get('/:id', async (req, res) => {
|
|
41
|
-
const container = getServiceContainer();
|
|
42
|
-
const snippetFactory = container.get('snippetFactory');
|
|
43
|
-
const snippet = await snippetFactory.getSnippet(String(req.params.id));
|
|
44
|
-
if (!snippet) {
|
|
45
|
-
throw new NotFoundError('Snippet (recipe)', String(req.params.id));
|
|
46
|
-
}
|
|
47
|
-
res.json({ success: true, data: snippet });
|
|
48
|
-
});
|
|
49
|
-
export default router;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Migration 002: TaskGraph 任务表
|
|
3
|
-
*
|
|
4
|
-
* 新增 tasks 表 + task_dependencies 表 + task_events 表。
|
|
5
|
-
*
|
|
6
|
-
* 设计决策 D1: 独立 task_dependencies 表(不复用 knowledge_edges)
|
|
7
|
-
* - 语义不同(任务依赖 vs 知识关系)
|
|
8
|
-
* - 需要专门的索引优化就绪检测查询
|
|
9
|
-
* - 避免与知识图谱互相污染
|
|
10
|
-
*/
|
|
11
|
-
export default function migrate(db: import('better-sqlite3').Database): void;
|