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,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* XcodeWriteUtils — Xcode 写入与插入工具函数
|
|
3
|
-
*
|
|
4
|
-
* 从 XcodeIntegration.js 拆分,负责:
|
|
5
|
-
* - 通用工具函数(sleep, withAutoSnippetNote)
|
|
6
|
-
* - SPM 依赖决策逻辑
|
|
7
|
-
* - Xcode osascript 写入
|
|
8
|
-
* - 文件写入回退
|
|
9
|
-
* - 粘贴行号偏移计算
|
|
10
|
-
*/
|
|
11
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
-
import { saveEventFilter } from './SaveEventFilter.js';
|
|
13
|
-
export function sleep(ms) {
|
|
14
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
-
}
|
|
16
|
-
/** 在 import 行末尾附加来源标记注释 */
|
|
17
|
-
export function withAutoSnippetNote(importLine) {
|
|
18
|
-
if (!importLine) {
|
|
19
|
-
return importLine;
|
|
20
|
-
}
|
|
21
|
-
const note = '// AutoSnippet: 自动插入';
|
|
22
|
-
if (importLine.includes(note)) {
|
|
23
|
-
return importLine;
|
|
24
|
-
}
|
|
25
|
-
return `${importLine} ${note}`;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* 将 SpmHelper.ensureDependency 返回值映射为三种动作:
|
|
29
|
-
* continue — 依赖已存在
|
|
30
|
-
* block — 循环/反向依赖,禁止插入
|
|
31
|
-
* review — 依赖缺失但可添加,需用户确认
|
|
32
|
-
*/
|
|
33
|
-
export function evaluateDepResult(ensureResult, from, to) {
|
|
34
|
-
if (ensureResult.exists) {
|
|
35
|
-
return { action: 'continue' };
|
|
36
|
-
}
|
|
37
|
-
if (!ensureResult.canAdd) {
|
|
38
|
-
return { action: 'block', reason: ensureResult.reason || 'cycleBlocked', from, to };
|
|
39
|
-
}
|
|
40
|
-
return { action: 'review', reason: ensureResult.reason || 'missingDependency', from, to };
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 公共依赖审查弹窗逻辑(insertHeaders 和 _preflightDeps 共享)
|
|
44
|
-
*
|
|
45
|
-
* @param ctx { spmService, currentTarget, mod, ensureResult, NU, depWarnings, label }
|
|
46
|
-
* @returns }
|
|
47
|
-
*/
|
|
48
|
-
export function handleDepReview(ctx) {
|
|
49
|
-
const { spmService, currentTarget, mod, ensureResult, NU, depWarnings, label = '' } = ctx;
|
|
50
|
-
const fixMode = spmService.getFixMode();
|
|
51
|
-
const buttons = fixMode === 'fix'
|
|
52
|
-
? ['直接插入(信任架构)', '提示操作插入', '自动修复依赖', '取消操作']
|
|
53
|
-
: ['直接插入(信任架构)', '提示操作插入', '取消操作'];
|
|
54
|
-
const crossTag = ensureResult.crossPackage ? ' (跨包)' : '';
|
|
55
|
-
const prefix = label ? `[${label}] ` : '';
|
|
56
|
-
const userChoice = NU.promptWithButtons(`检测到依赖缺失:${currentTarget} -> ${mod}${crossTag}\n\n请选择处理方式:`, buttons, 'AutoSnippet SPM 依赖决策');
|
|
57
|
-
if (userChoice === '取消操作' ||
|
|
58
|
-
(!userChoice && !['直接插入(信任架构)', '提示操作插入', '自动修复依赖'].includes(userChoice))) {
|
|
59
|
-
return { blocked: true };
|
|
60
|
-
}
|
|
61
|
-
if (userChoice === '提示操作插入') {
|
|
62
|
-
depWarnings.set(mod, `${currentTarget} -> ${mod}`);
|
|
63
|
-
}
|
|
64
|
-
if (userChoice === '自动修复依赖') {
|
|
65
|
-
const fixResult = spmService.addDependency(currentTarget, mod);
|
|
66
|
-
if (fixResult.ok) {
|
|
67
|
-
NU.notify(`已补齐依赖:${currentTarget} -> ${mod}`, 'AutoSnippet SPM');
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
console.warn(` ⚠️ ${prefix}自动修复失败: ${fixResult.error},继续插入`);
|
|
71
|
-
depWarnings.set(mod, `${currentTarget} -> ${mod}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return { blocked: false };
|
|
75
|
-
}
|
|
76
|
-
// ═══════════════════════════════════════════════════════════════
|
|
77
|
-
// Xcode osascript 单条 import 写入
|
|
78
|
-
// ═══════════════════════════════════════════════════════════════
|
|
79
|
-
/**
|
|
80
|
-
* 通过 Xcode 自动化插入一条 import,保持 Xcode Undo 可用。
|
|
81
|
-
*
|
|
82
|
-
* 流程:保存剪贴板 → 写入 import 内容 → osascript 跳转+粘贴 → 恢复剪贴板
|
|
83
|
-
*
|
|
84
|
-
* @param importLine 完整的 import 文本
|
|
85
|
-
* @param insertLine 1-based 行号
|
|
86
|
-
* @param XA XcodeAutomation 模块
|
|
87
|
-
* @param CM ClipboardManager 模块
|
|
88
|
-
*/
|
|
89
|
-
export function writeImportLineXcode(importLine, insertLine, XA, CM) {
|
|
90
|
-
if (!XA.isXcodeRunning()) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const contentToWrite = `${String(importLine).trim()}\n`;
|
|
95
|
-
const previousClipboard = CM.read();
|
|
96
|
-
CM.write(contentToWrite);
|
|
97
|
-
const ok = XA.insertAtLineStartInXcode(insertLine);
|
|
98
|
-
// 始终恢复剪贴板
|
|
99
|
-
if (typeof previousClipboard === 'string') {
|
|
100
|
-
CM.write(previousClipboard);
|
|
101
|
-
}
|
|
102
|
-
return ok;
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// ═══════════════════════════════════════════════════════════════
|
|
109
|
-
// 文件写入回退
|
|
110
|
-
// ═══════════════════════════════════════════════════════════════
|
|
111
|
-
/**
|
|
112
|
-
* 纯文件写入插入单条 import。
|
|
113
|
-
* Xcode 会因文件变更而自动 reload。
|
|
114
|
-
*/
|
|
115
|
-
export function writeImportLineFile(filePath, importLine, isSwift) {
|
|
116
|
-
try {
|
|
117
|
-
const content = readFileSync(filePath, 'utf8');
|
|
118
|
-
const lines = content.split('\n');
|
|
119
|
-
let lastImportIdx = -1;
|
|
120
|
-
for (let i = 0; i < lines.length; i++) {
|
|
121
|
-
const t = lines[i].trim();
|
|
122
|
-
if (isSwift) {
|
|
123
|
-
if (t.startsWith('import ') && !t.startsWith('import (')) {
|
|
124
|
-
lastImportIdx = i;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
if (t.startsWith('#import ') || t.startsWith('#include ') || t.startsWith('@import ')) {
|
|
129
|
-
lastImportIdx = i;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const insertAt = lastImportIdx >= 0 ? lastImportIdx + 1 : 0;
|
|
134
|
-
lines.splice(insertAt, 0, importLine);
|
|
135
|
-
const newContent = lines.join('\n');
|
|
136
|
-
saveEventFilter.markWrite(filePath, newContent);
|
|
137
|
-
writeFileSync(filePath, newContent, 'utf8');
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// ═══════════════════════════════════════════════════════════════
|
|
145
|
-
// 粘贴行号偏移计算
|
|
146
|
-
// ═══════════════════════════════════════════════════════════════
|
|
147
|
-
/** 查找文件中最后一个 import 行的行号(1-based,0 表示无 import) */
|
|
148
|
-
export function getLastImportLine(filePath) {
|
|
149
|
-
try {
|
|
150
|
-
if (!existsSync(filePath)) {
|
|
151
|
-
return 0;
|
|
152
|
-
}
|
|
153
|
-
const content = readFileSync(filePath, 'utf8');
|
|
154
|
-
const lines = content.split(/\r?\n/);
|
|
155
|
-
let lastIdx = -1;
|
|
156
|
-
for (let i = 0; i < lines.length; i++) {
|
|
157
|
-
const t = lines[i].trim();
|
|
158
|
-
if (t.startsWith('#import ') ||
|
|
159
|
-
t.startsWith('@import ') ||
|
|
160
|
-
t.startsWith('#include ') ||
|
|
161
|
-
t.startsWith('import ')) {
|
|
162
|
-
lastIdx = i;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return lastIdx >= 0 ? lastIdx + 1 : 0;
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
return 0;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* 计算代码粘贴行号
|
|
173
|
-
*
|
|
174
|
-
* 如果 headers 插入在 trigger 行之前(import 区),trigger 行号需要向下偏移。
|
|
175
|
-
*/
|
|
176
|
-
export function computePasteLineNumber(triggerLineNumber, headerInsertCount, filePath, options = {}) {
|
|
177
|
-
const expectedCount = Number.isFinite(options.expectedHeaderCount)
|
|
178
|
-
? options.expectedHeaderCount
|
|
179
|
-
: headerInsertCount;
|
|
180
|
-
if (expectedCount > 0) {
|
|
181
|
-
if (options.forceOffset) {
|
|
182
|
-
return triggerLineNumber + expectedCount;
|
|
183
|
-
}
|
|
184
|
-
const headerInsertPosition = getLastImportLine(filePath);
|
|
185
|
-
if (headerInsertPosition > 0 && headerInsertPosition < triggerLineNumber) {
|
|
186
|
-
return triggerLineNumber + expectedCount;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return triggerLineNumber;
|
|
190
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import type { Database, Statement } from 'better-sqlite3';
|
|
2
|
-
import type { Logger as WinstonLogger } from 'winston';
|
|
3
|
-
import { Task } from '../../domain/task/Task.js';
|
|
4
|
-
import type { DrizzleDB } from '../../infrastructure/database/drizzle/index.js';
|
|
5
|
-
/** Row shape returned by task_dependencies queries (camelCase — matches Drizzle schema) */
|
|
6
|
-
interface TaskDependencyRow {
|
|
7
|
-
id: number;
|
|
8
|
-
taskId: string;
|
|
9
|
-
dependsOnId: string;
|
|
10
|
-
depType: string;
|
|
11
|
-
metadata: string | null;
|
|
12
|
-
createdAt: number;
|
|
13
|
-
createdBy: string | null;
|
|
14
|
-
}
|
|
15
|
-
/** Filters accepted by findAll */
|
|
16
|
-
interface TaskFilters {
|
|
17
|
-
status?: string;
|
|
18
|
-
taskType?: string;
|
|
19
|
-
assignee?: string;
|
|
20
|
-
parentId?: string;
|
|
21
|
-
}
|
|
22
|
-
/** Options accepted by findAll */
|
|
23
|
-
interface TaskFindOptions {
|
|
24
|
-
limit?: number;
|
|
25
|
-
offset?: number;
|
|
26
|
-
orderBy?: string;
|
|
27
|
-
}
|
|
28
|
-
/** Column mapping for update fields */
|
|
29
|
-
interface TaskUpdateFields {
|
|
30
|
-
status?: string;
|
|
31
|
-
priority?: number;
|
|
32
|
-
assignee?: string;
|
|
33
|
-
notes?: string;
|
|
34
|
-
description?: string;
|
|
35
|
-
design?: string;
|
|
36
|
-
acceptance?: string;
|
|
37
|
-
closeReason?: string;
|
|
38
|
-
closedAt?: number | null;
|
|
39
|
-
updatedAt?: number;
|
|
40
|
-
failCount?: number;
|
|
41
|
-
lastFailReason?: string;
|
|
42
|
-
childSeq?: number;
|
|
43
|
-
metadata?: Record<string, unknown>;
|
|
44
|
-
[key: string]: unknown;
|
|
45
|
-
}
|
|
46
|
-
/** Database connection wrapper interface */
|
|
47
|
-
interface DatabaseWrapper {
|
|
48
|
-
getDb(): Database;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* TaskRepositoryImpl — 任务实体 SQLite 持久化 (Drizzle ORM)
|
|
52
|
-
*
|
|
53
|
-
* DB 列名 snake_case,实体属性 camelCase—— Task.fromRow() / _entityToRow() 负责映射。
|
|
54
|
-
*
|
|
55
|
-
* Drizzle 迁移策略:
|
|
56
|
-
* - CRUD (create/findById/update/delete) → drizzle 类型安全 API
|
|
57
|
-
* - 依赖管理 (add/remove/get) → drizzle 类型安全 API
|
|
58
|
-
* - 事件审计 / 统计 → drizzle 类型安全 API
|
|
59
|
-
* - 环检测 (递归 CTE) / 复杂动态查询 (findAll) → 保留 raw SQL
|
|
60
|
-
*/
|
|
61
|
-
export declare class TaskRepositoryImpl {
|
|
62
|
-
#private;
|
|
63
|
-
_reachableStmt: Statement;
|
|
64
|
-
db: Database;
|
|
65
|
-
logger: WinstonLogger;
|
|
66
|
-
constructor(database: DatabaseWrapper, drizzle?: DrizzleDB);
|
|
67
|
-
/** 预编译复杂查询(仅保留 drizzle 无法表达的递归 CTE) */
|
|
68
|
-
private _prepareStatements;
|
|
69
|
-
/**
|
|
70
|
-
* 创建任务
|
|
71
|
-
* ★ Drizzle 类型安全 INSERT
|
|
72
|
-
*/
|
|
73
|
-
create(task: Task): Task | null;
|
|
74
|
-
/**
|
|
75
|
-
* 按 ID 查询
|
|
76
|
-
* ★ Drizzle 类型安全 SELECT
|
|
77
|
-
*/
|
|
78
|
-
findById(id: string): Task | null;
|
|
79
|
-
/**
|
|
80
|
-
* 按内容哈希查询(去重用)
|
|
81
|
-
* ★ Drizzle 类型安全 SELECT
|
|
82
|
-
*/
|
|
83
|
-
findByContentHash(hash: string | null): Task | null;
|
|
84
|
-
/**
|
|
85
|
-
* 更新任务字段
|
|
86
|
-
* ★ Drizzle 类型安全 UPDATE
|
|
87
|
-
*/
|
|
88
|
-
update(id: string, fields: TaskUpdateFields): Task | null;
|
|
89
|
-
/**
|
|
90
|
-
* 删除任务
|
|
91
|
-
* ★ Drizzle 类型安全 DELETE
|
|
92
|
-
*/
|
|
93
|
-
delete(id: string): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* 列表查询
|
|
96
|
-
* @param filters { status, taskType, assignee, parentId }
|
|
97
|
-
* @param options { limit, offset, orderBy }
|
|
98
|
-
*/
|
|
99
|
-
findAll(filters?: TaskFilters, options?: TaskFindOptions): (Task | null)[];
|
|
100
|
-
/**
|
|
101
|
-
* 添加依赖
|
|
102
|
-
* ★ Drizzle 类型安全 INSERT OR IGNORE
|
|
103
|
-
*/
|
|
104
|
-
addDependency(taskId: string, dependsOnId: string, depType: string): void;
|
|
105
|
-
/**
|
|
106
|
-
* 删除依赖
|
|
107
|
-
* ★ Drizzle 类型安全 DELETE
|
|
108
|
-
*/
|
|
109
|
-
removeDependency(taskId: string, dependsOnId: string, depType: string): void;
|
|
110
|
-
/**
|
|
111
|
-
* 获取任务的所有依赖
|
|
112
|
-
* ★ Drizzle 类型安全 SELECT
|
|
113
|
-
*/
|
|
114
|
-
getDependencies(taskId: string): TaskDependencyRow[];
|
|
115
|
-
/**
|
|
116
|
-
* 获取依赖此任务的所有任务
|
|
117
|
-
* ★ Drizzle 类型安全 SELECT
|
|
118
|
-
*/
|
|
119
|
-
getDependents(dependsOnId: string): TaskDependencyRow[];
|
|
120
|
-
/**
|
|
121
|
-
* 获取阻塞某任务的所有任务(含任务详情)
|
|
122
|
-
* 保留 raw SQL — JOIN 查询
|
|
123
|
-
*/
|
|
124
|
-
getBlockers(taskId: string): (Task | null)[];
|
|
125
|
-
/** 环检测:检查 fromId → toId 是否已有可达路径 */
|
|
126
|
-
hasReachablePath(fromId: string, toId: string): boolean;
|
|
127
|
-
/** 在事务中执行操作 */
|
|
128
|
-
inTransaction<T>(fn: () => T): T;
|
|
129
|
-
/**
|
|
130
|
-
* 获取任务统计
|
|
131
|
-
* 保留 raw SQL — SUM(CASE WHEN) 聚合在 drizzle 中不如直写清晰
|
|
132
|
-
*/
|
|
133
|
-
getStatistics(): {
|
|
134
|
-
total: number;
|
|
135
|
-
open: number;
|
|
136
|
-
in_progress: number;
|
|
137
|
-
closed: number;
|
|
138
|
-
deferred: number;
|
|
139
|
-
pinned: number;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* 记录任务事件
|
|
143
|
-
* ★ Drizzle 类型安全 INSERT
|
|
144
|
-
*/
|
|
145
|
-
logEvent(taskId: string, eventType: string, oldValue?: string | null, newValue?: string | null, comment?: string | null, actor?: string): void;
|
|
146
|
-
/** 实体 → DB 行 (camelCase → snake_case) */
|
|
147
|
-
_entityToRow(task: Task): {
|
|
148
|
-
id: string;
|
|
149
|
-
parentId: string | null;
|
|
150
|
-
childSeq: number;
|
|
151
|
-
title: string;
|
|
152
|
-
description: string;
|
|
153
|
-
design: string;
|
|
154
|
-
acceptance: string;
|
|
155
|
-
notes: string;
|
|
156
|
-
status: string;
|
|
157
|
-
priority: number;
|
|
158
|
-
taskType: string;
|
|
159
|
-
closeReason: string;
|
|
160
|
-
contentHash: string;
|
|
161
|
-
failCount: number;
|
|
162
|
-
lastFailReason: string;
|
|
163
|
-
assignee: string;
|
|
164
|
-
createdBy: string;
|
|
165
|
-
createdAt: number;
|
|
166
|
-
updatedAt: number;
|
|
167
|
-
closedAt: number | null;
|
|
168
|
-
metadata: string;
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
export default TaskRepositoryImpl;
|