autosnippet 3.3.7 → 3.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dashboard/dist/assets/icons-BMNb0V6L.js +1 -0
- package/dashboard/dist/assets/index-DEU4tJtP.js +112 -0
- package/dashboard/dist/assets/index-DHJ1Dj7u.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/cli.js +7 -4
- package/dist/lib/agent/core/ChatAgentPrompts.js +57 -21
- package/dist/lib/agent/core/LoopContext.d.ts +1 -0
- package/dist/lib/agent/core/ToolExecutionPipeline.js +13 -0
- package/dist/lib/agent/memory/ActiveContext.d.ts +0 -2
- package/dist/lib/agent/memory/ActiveContext.js +0 -2
- package/dist/lib/agent/memory/MemoryEmbeddingStore.d.ts +49 -0
- package/dist/lib/agent/memory/MemoryEmbeddingStore.js +159 -0
- package/dist/lib/agent/memory/MemoryRetriever.d.ts +2 -0
- package/dist/lib/agent/memory/MemoryRetriever.js +25 -11
- package/dist/lib/agent/memory/MemoryStore.d.ts +8 -41
- package/dist/lib/agent/memory/MemoryStore.js +196 -261
- package/dist/lib/agent/memory/PersistentMemory.d.ts +2 -0
- package/dist/lib/agent/memory/PersistentMemory.js +4 -5
- package/dist/lib/agent/memory/SessionStore.d.ts +0 -2
- package/dist/lib/agent/memory/SessionStore.js +0 -2
- package/dist/lib/agent/tools/ast-graph.js +21 -19
- package/dist/lib/agent/tools/infrastructure.js +3 -2
- package/dist/lib/agent/tools/project-access.d.ts +2 -2
- package/dist/lib/agent/tools/project-access.js +5 -4
- package/dist/lib/bootstrap.js +8 -2
- package/dist/lib/cli/AiScanService.js +4 -17
- package/dist/lib/cli/KnowledgeSyncService.d.ts +7 -37
- package/dist/lib/cli/KnowledgeSyncService.js +23 -51
- package/dist/lib/cli/SetupService.js +5 -4
- package/dist/lib/core/ast/ProjectGraph.js +5 -27
- package/dist/lib/core/discovery/CustomConfigDiscoverer.d.ts +0 -2
- package/dist/lib/core/discovery/CustomConfigDiscoverer.js +0 -2
- package/dist/lib/domain/dimension/DimensionRegistry.d.ts +0 -2
- package/dist/lib/domain/dimension/DimensionRegistry.js +0 -2
- package/dist/lib/domain/dimension/DimensionSop.js +44 -33
- package/dist/lib/domain/dimension/UnifiedDimension.d.ts +0 -2
- package/dist/lib/domain/dimension/UnifiedDimension.js +0 -2
- package/dist/lib/domain/knowledge/Lifecycle.d.ts +26 -0
- package/dist/lib/domain/knowledge/Lifecycle.js +42 -0
- package/dist/lib/domain/knowledge/index.d.ts +2 -1
- package/dist/lib/domain/knowledge/index.js +1 -1
- package/dist/lib/external/mcp/McpServer.js +19 -2
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.d.ts +2 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +102 -153
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.js +10 -29
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +33 -16
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +41 -37
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +1 -1
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +7 -3
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +1 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +13 -16
- package/dist/lib/external/mcp/handlers/guard.js +15 -24
- package/dist/lib/external/mcp/handlers/panorama.js +9 -9
- package/dist/lib/external/mcp/handlers/rescan-external.js +7 -6
- package/dist/lib/external/mcp/handlers/rescan-internal.js +9 -5
- package/dist/lib/external/mcp/handlers/search.js +3 -1
- package/dist/lib/external/mcp/handlers/skill.js +4 -4
- package/dist/lib/external/mcp/handlers/structure.js +8 -12
- package/dist/lib/external/mcp/handlers/system.js +10 -34
- package/dist/lib/http/routes/ai.js +11 -13
- package/dist/lib/http/routes/guardReport.js +3 -5
- package/dist/lib/http/routes/panorama.js +12 -12
- package/dist/lib/http/routes/recipes.js +59 -8
- package/dist/lib/http/routes/remote.js +3 -13
- package/dist/lib/http/routes/search.js +11 -8
- package/dist/lib/infrastructure/audit/AuditLogger.d.ts +20 -3
- package/dist/lib/infrastructure/audit/AuditStore.d.ts +28 -29
- package/dist/lib/infrastructure/audit/AuditStore.js +81 -88
- package/dist/lib/infrastructure/database/DatabaseConnection.js +7 -6
- package/dist/lib/infrastructure/database/drizzle/schema.d.ts +180 -2
- package/dist/lib/infrastructure/database/drizzle/schema.js +23 -3
- package/dist/lib/injection/ServiceContainer.js +7 -4
- package/dist/lib/injection/ServiceMap.d.ts +20 -0
- package/dist/lib/injection/modules/AppModule.js +2 -1
- package/dist/lib/injection/modules/GuardModule.js +5 -5
- package/dist/lib/injection/modules/InfraModule.js +60 -0
- package/dist/lib/injection/modules/KnowledgeModule.js +86 -51
- package/dist/lib/injection/modules/PanoramaModule.js +16 -10
- package/dist/lib/injection/modules/VectorModule.js +3 -0
- package/dist/lib/repository/audit/AuditRepository.d.ts +107 -0
- package/dist/lib/repository/audit/AuditRepository.js +272 -0
- package/dist/lib/repository/base/RepositoryBase.d.ts +46 -0
- package/dist/lib/repository/base/RepositoryBase.js +32 -0
- package/dist/lib/repository/bootstrap/BootstrapRepository.d.ts +94 -0
- package/dist/lib/repository/bootstrap/BootstrapRepository.js +246 -0
- package/dist/lib/repository/code/CodeEntityRepository.d.ts +91 -0
- package/dist/lib/repository/code/CodeEntityRepository.js +361 -0
- package/dist/lib/repository/delivery/DeliveryRepoAdapter.d.ts +39 -0
- package/dist/lib/repository/delivery/DeliveryRepoAdapter.js +23 -0
- package/dist/lib/repository/evolution/LifecycleEventRepository.d.ts +51 -0
- package/dist/lib/repository/evolution/LifecycleEventRepository.js +119 -0
- package/dist/lib/repository/evolution/ProposalRepository.d.ts +9 -12
- package/dist/lib/repository/evolution/ProposalRepository.js +114 -57
- package/dist/lib/repository/guard/GuardViolationRepository.d.ts +104 -0
- package/dist/lib/repository/guard/GuardViolationRepository.js +217 -0
- package/dist/lib/repository/knowledge/KnowledgeEdgeRepository.d.ts +129 -0
- package/dist/lib/repository/knowledge/KnowledgeEdgeRepository.js +475 -0
- package/dist/lib/repository/knowledge/KnowledgeFileStore.d.ts +39 -0
- package/dist/lib/repository/knowledge/KnowledgeFileStore.js +12 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +295 -11
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +608 -13
- package/dist/lib/repository/knowledge/KnowledgeUnitOfWork.d.ts +61 -0
- package/dist/lib/repository/knowledge/KnowledgeUnitOfWork.js +156 -0
- package/dist/lib/repository/memory/MemoryRepository.d.ts +90 -0
- package/dist/lib/repository/memory/MemoryRepository.js +260 -0
- package/dist/lib/repository/search/SearchRepoAdapter.d.ts +92 -0
- package/dist/lib/repository/search/SearchRepoAdapter.js +124 -0
- package/dist/lib/repository/session/SessionRepository.d.ts +46 -0
- package/dist/lib/repository/session/SessionRepository.js +110 -0
- package/dist/lib/repository/sourceref/RecipeSourceRefRepository.d.ts +66 -0
- package/dist/lib/repository/sourceref/RecipeSourceRefRepository.js +182 -0
- package/dist/lib/repository/sync/SyncRepoAdapter.d.ts +58 -0
- package/dist/lib/repository/sync/SyncRepoAdapter.js +58 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +5 -6
- package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +0 -1
- package/dist/lib/service/bootstrap/bootstrap-event-types.js +0 -1
- package/dist/lib/service/cleanup/CleanupService.js +8 -4
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +21 -9
- package/dist/lib/service/evolution/ConsolidationAdvisor.d.ts +4 -9
- package/dist/lib/service/evolution/ConsolidationAdvisor.js +34 -70
- package/dist/lib/service/evolution/ContentPatcher.d.ts +4 -12
- package/dist/lib/service/evolution/ContentPatcher.js +48 -19
- package/dist/lib/service/evolution/ContradictionDetector.d.ts +3 -7
- package/dist/lib/service/evolution/ContradictionDetector.js +17 -24
- package/dist/lib/service/evolution/DecayDetector.d.ts +10 -9
- package/dist/lib/service/evolution/DecayDetector.js +63 -57
- package/dist/lib/service/evolution/EnhancementSuggester.d.ts +3 -9
- package/dist/lib/service/evolution/EnhancementSuggester.js +42 -86
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +4 -4
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +102 -71
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +5 -12
- package/dist/lib/service/evolution/ProposalExecutor.js +64 -69
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +9 -14
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +94 -155
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +4 -1
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +50 -49
- package/dist/lib/service/evolution/RedundancyAnalyzer.d.ts +3 -7
- package/dist/lib/service/evolution/RedundancyAnalyzer.js +15 -22
- package/dist/lib/service/evolution/StagingManager.d.ts +6 -15
- package/dist/lib/service/evolution/StagingManager.js +37 -95
- package/dist/lib/service/evolution/createSupersedeProposal.d.ts +1 -1
- package/dist/lib/service/evolution/createSupersedeProposal.js +7 -8
- package/dist/lib/service/guard/CoverageAnalyzer.d.ts +3 -7
- package/dist/lib/service/guard/CoverageAnalyzer.js +9 -11
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +3 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +14 -22
- package/dist/lib/service/guard/ReverseGuard.d.ts +4 -7
- package/dist/lib/service/guard/ReverseGuard.js +21 -31
- package/dist/lib/service/guard/ViolationsStore.d.ts +15 -21
- package/dist/lib/service/guard/ViolationsStore.js +75 -69
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +39 -63
- package/dist/lib/service/knowledge/CodeEntityGraph.js +418 -512
- package/dist/lib/service/knowledge/ConfidenceRouter.js +18 -9
- package/dist/lib/service/knowledge/KnowledgeFileWriter.d.ts +2 -1
- package/dist/lib/service/knowledge/KnowledgeGraphService.d.ts +18 -60
- package/dist/lib/service/knowledge/KnowledgeGraphService.js +58 -109
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +15 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +76 -38
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +0 -2
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +0 -2
- package/dist/lib/service/knowledge/SourceRefReconciler.d.ts +5 -13
- package/dist/lib/service/knowledge/SourceRefReconciler.js +58 -78
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +5 -3
- package/dist/lib/service/panorama/CouplingAnalyzer.js +102 -39
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +7 -4
- package/dist/lib/service/panorama/DimensionAnalyzer.js +72 -25
- package/dist/lib/service/panorama/LayerInferrer.js +1 -1
- package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +7 -6
- package/dist/lib/service/panorama/ModuleDiscoverer.js +174 -82
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +10 -3
- package/dist/lib/service/panorama/PanoramaAggregator.js +67 -79
- package/dist/lib/service/panorama/PanoramaScanner.d.ts +5 -1
- package/dist/lib/service/panorama/PanoramaScanner.js +32 -31
- package/dist/lib/service/panorama/PanoramaService.d.ts +11 -8
- package/dist/lib/service/panorama/PanoramaService.js +41 -66
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +3 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +8 -5
- package/dist/lib/service/panorama/RoleRefiner.js +52 -283
- package/dist/lib/service/panorama/TechStackProfiler.js +7 -119
- package/dist/lib/service/quality/QualityScorer.d.ts +45 -26
- package/dist/lib/service/quality/QualityScorer.js +157 -83
- package/dist/lib/service/search/SearchEngine.d.ts +1 -0
- package/dist/lib/service/search/SearchEngine.js +32 -37
- package/dist/lib/service/signal/HitRecorder.js +5 -5
- package/dist/lib/service/skills/RuleRecallStrategy.js +7 -3
- package/dist/lib/service/skills/SignalCollector.d.ts +5 -8
- package/dist/lib/service/skills/SignalCollector.js +28 -55
- package/dist/lib/service/skills/SkillAdvisor.d.ts +7 -13
- package/dist/lib/service/skills/SkillAdvisor.js +30 -79
- package/dist/lib/service/vector/SyncCoordinator.d.ts +3 -1
- package/dist/lib/service/vector/SyncCoordinator.js +25 -3
- package/dist/lib/service/vector/VectorService.d.ts +2 -0
- package/dist/lib/service/vector/VectorService.js +3 -0
- package/dist/lib/service/wiki/WikiGenerator.js +1 -1
- package/dist/lib/shared/LanguageProfiles.d.ts +109 -0
- package/dist/lib/shared/LanguageProfiles.js +939 -0
- package/dist/lib/shared/LanguageService.d.ts +6 -0
- package/dist/lib/shared/LanguageService.js +16 -0
- package/dist/lib/shared/PathGuard.js +16 -10
- package/dist/lib/shared/constants.d.ts +19 -19
- package/dist/lib/shared/constants.js +10 -10
- package/dist/lib/shared/isOwnDevRepo.d.ts +29 -4
- package/dist/lib/shared/isOwnDevRepo.js +64 -4
- package/dist/lib/shared/schemas/mcp-tools.d.ts +1 -1
- package/dist/lib/types/project-snapshot-builder.d.ts +0 -1
- package/dist/lib/types/project-snapshot-builder.js +0 -1
- package/dist/lib/types/project-snapshot.d.ts +0 -1
- package/dist/lib/types/project-snapshot.js +0 -1
- package/dist/lib/types/snapshot-views.d.ts +0 -2
- package/dist/lib/types/snapshot-views.js +0 -1
- package/package.json +2 -1
- package/dashboard/dist/assets/icons-FHns2ypa.js +0 -1
- package/dashboard/dist/assets/index-BRJv5Y3r.js +0 -135
- package/dashboard/dist/assets/index-DzoB7kxK.css +0 -1
- package/dist/lib/repository/base/BaseRepository.d.ts +0 -53
- package/dist/lib/repository/base/BaseRepository.js +0 -226
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
/** AuditStore -
|
|
2
|
-
import { desc, eq, sql } from 'drizzle-orm';
|
|
1
|
+
/** AuditStore - 审计日志存储(全 Drizzle 类型安全) */
|
|
2
|
+
import { and, avg, count, desc, eq, gte, lte, sql } from 'drizzle-orm';
|
|
3
3
|
import { getDrizzle } from '../database/drizzle/index.js';
|
|
4
4
|
import { auditLogs } from '../database/drizzle/schema.js';
|
|
5
5
|
export class AuditStore {
|
|
6
|
-
db;
|
|
7
6
|
#drizzle;
|
|
8
7
|
constructor(db, drizzle) {
|
|
9
|
-
this.db = db.getDb();
|
|
10
8
|
this.#drizzle = drizzle ?? getDrizzle();
|
|
11
9
|
}
|
|
12
|
-
/**
|
|
13
|
-
* 保存审计日志
|
|
14
|
-
* ★ Drizzle 类型安全 INSERT
|
|
15
|
-
*/
|
|
10
|
+
/** 保存审计日志 */
|
|
16
11
|
async save(entry) {
|
|
17
12
|
this.#drizzle
|
|
18
13
|
.insert(auditLogs)
|
|
@@ -30,49 +25,40 @@ export class AuditStore {
|
|
|
30
25
|
})
|
|
31
26
|
.run();
|
|
32
27
|
}
|
|
33
|
-
/**
|
|
28
|
+
/** 查询审计日志(动态多条件,全 Drizzle) */
|
|
34
29
|
query(filters = {}) {
|
|
35
|
-
|
|
36
|
-
const params = [];
|
|
30
|
+
const conditions = [];
|
|
37
31
|
if (filters.actor) {
|
|
38
|
-
|
|
39
|
-
params.push(filters.actor);
|
|
32
|
+
conditions.push(eq(auditLogs.actor, filters.actor));
|
|
40
33
|
}
|
|
41
34
|
if (filters.action) {
|
|
42
|
-
|
|
43
|
-
params.push(filters.action);
|
|
35
|
+
conditions.push(eq(auditLogs.action, filters.action));
|
|
44
36
|
}
|
|
45
37
|
if (filters.result) {
|
|
46
|
-
|
|
47
|
-
params.push(filters.result);
|
|
38
|
+
conditions.push(eq(auditLogs.result, filters.result));
|
|
48
39
|
}
|
|
49
40
|
if (filters.startDate) {
|
|
50
|
-
|
|
51
|
-
params.push(filters.startDate);
|
|
41
|
+
conditions.push(gte(auditLogs.timestamp, filters.startDate));
|
|
52
42
|
}
|
|
53
43
|
if (filters.endDate) {
|
|
54
|
-
|
|
55
|
-
params.push(filters.endDate);
|
|
44
|
+
conditions.push(lte(auditLogs.timestamp, filters.endDate));
|
|
56
45
|
}
|
|
57
|
-
|
|
46
|
+
const condition = conditions.length > 0 ? and(...conditions) : undefined;
|
|
47
|
+
let query = this.#drizzle
|
|
48
|
+
.select()
|
|
49
|
+
.from(auditLogs)
|
|
50
|
+
.where(condition)
|
|
51
|
+
.orderBy(desc(auditLogs.timestamp));
|
|
58
52
|
if (filters.limit) {
|
|
59
|
-
|
|
60
|
-
params.push(filters.limit);
|
|
53
|
+
query = query.limit(filters.limit);
|
|
61
54
|
}
|
|
62
|
-
|
|
63
|
-
return stmt.all(...params);
|
|
55
|
+
return query.all();
|
|
64
56
|
}
|
|
65
|
-
/**
|
|
66
|
-
* 根据请求 ID 查询
|
|
67
|
-
* ★ Drizzle 类型安全 SELECT
|
|
68
|
-
*/
|
|
57
|
+
/** 根据请求 ID 查询 */
|
|
69
58
|
findByRequestId(requestId) {
|
|
70
59
|
return this.#drizzle.select().from(auditLogs).where(eq(auditLogs.id, requestId)).get();
|
|
71
60
|
}
|
|
72
|
-
/**
|
|
73
|
-
* 根据角色查询
|
|
74
|
-
* ★ Drizzle 类型安全 SELECT
|
|
75
|
-
*/
|
|
61
|
+
/** 根据角色查询 */
|
|
76
62
|
findByActor(actor, limit = 100) {
|
|
77
63
|
return this.#drizzle
|
|
78
64
|
.select()
|
|
@@ -82,10 +68,7 @@ export class AuditStore {
|
|
|
82
68
|
.limit(limit)
|
|
83
69
|
.all();
|
|
84
70
|
}
|
|
85
|
-
/**
|
|
86
|
-
* 根据操作查询
|
|
87
|
-
* ★ Drizzle 类型安全 SELECT
|
|
88
|
-
*/
|
|
71
|
+
/** 根据操作查询 */
|
|
89
72
|
findByAction(action, limit = 100) {
|
|
90
73
|
return this.#drizzle
|
|
91
74
|
.select()
|
|
@@ -95,10 +78,7 @@ export class AuditStore {
|
|
|
95
78
|
.limit(limit)
|
|
96
79
|
.all();
|
|
97
80
|
}
|
|
98
|
-
/**
|
|
99
|
-
* 根据结果查询
|
|
100
|
-
* ★ Drizzle 类型安全 SELECT
|
|
101
|
-
*/
|
|
81
|
+
/** 根据结果查询 */
|
|
102
82
|
findByResult(result, limit = 100) {
|
|
103
83
|
return this.#drizzle
|
|
104
84
|
.select()
|
|
@@ -108,66 +88,79 @@ export class AuditStore {
|
|
|
108
88
|
.limit(limit)
|
|
109
89
|
.all();
|
|
110
90
|
}
|
|
111
|
-
/**
|
|
91
|
+
/** 获取统计数据(全 Drizzle) */
|
|
112
92
|
getStats(timeRange = '24h') {
|
|
113
|
-
// 计算时间范围
|
|
114
93
|
const hours = timeRange === '24h' ? 24 : timeRange === '7d' ? 168 : 720; // 30d
|
|
115
94
|
const startTime = Date.now() - hours * 60 * 60 * 1000;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
.
|
|
95
|
+
const startCondition = gte(auditLogs.timestamp, startTime);
|
|
96
|
+
// 总数
|
|
97
|
+
const [totalRow] = this.#drizzle
|
|
98
|
+
.select({ count: count() })
|
|
99
|
+
.from(auditLogs)
|
|
100
|
+
.where(startCondition)
|
|
101
|
+
.all();
|
|
102
|
+
const total = totalRow?.count ?? 0;
|
|
103
|
+
// 成功数
|
|
104
|
+
const [successRow] = this.#drizzle
|
|
105
|
+
.select({ count: count() })
|
|
106
|
+
.from(auditLogs)
|
|
107
|
+
.where(and(startCondition, eq(auditLogs.result, 'success')))
|
|
108
|
+
.all();
|
|
109
|
+
const successCount = successRow?.count ?? 0;
|
|
110
|
+
// 失败数
|
|
111
|
+
const [failureRow] = this.#drizzle
|
|
112
|
+
.select({ count: count() })
|
|
113
|
+
.from(auditLogs)
|
|
114
|
+
.where(and(startCondition, eq(auditLogs.result, 'failure')))
|
|
115
|
+
.all();
|
|
116
|
+
const failureCount = failureRow?.count ?? 0;
|
|
127
117
|
// 按角色统计
|
|
128
|
-
const byActor = this
|
|
129
|
-
.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.
|
|
118
|
+
const byActor = this.#drizzle
|
|
119
|
+
.select({
|
|
120
|
+
actor: auditLogs.actor,
|
|
121
|
+
count: count(),
|
|
122
|
+
})
|
|
123
|
+
.from(auditLogs)
|
|
124
|
+
.where(startCondition)
|
|
125
|
+
.groupBy(auditLogs.actor)
|
|
126
|
+
.orderBy(desc(count()))
|
|
127
|
+
.all();
|
|
137
128
|
// 按操作统计
|
|
138
|
-
const byAction = this
|
|
139
|
-
.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.
|
|
129
|
+
const byAction = this.#drizzle
|
|
130
|
+
.select({
|
|
131
|
+
action: auditLogs.action,
|
|
132
|
+
count: count(),
|
|
133
|
+
})
|
|
134
|
+
.from(auditLogs)
|
|
135
|
+
.where(startCondition)
|
|
136
|
+
.groupBy(auditLogs.action)
|
|
137
|
+
.orderBy(desc(count()))
|
|
138
|
+
.all();
|
|
147
139
|
// 平均响应时间
|
|
148
|
-
const
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.
|
|
140
|
+
const [avgRow] = this.#drizzle
|
|
141
|
+
.select({
|
|
142
|
+
avg_duration: avg(auditLogs.duration),
|
|
143
|
+
})
|
|
144
|
+
.from(auditLogs)
|
|
145
|
+
.where(and(startCondition, sql `${auditLogs.duration} IS NOT NULL`))
|
|
146
|
+
.all();
|
|
147
|
+
const avgDuration = avgRow?.avg_duration
|
|
148
|
+
? `${Math.round(Number(avgRow.avg_duration))}ms`
|
|
149
|
+
: 'N/A';
|
|
155
150
|
return {
|
|
156
151
|
timeRange,
|
|
157
|
-
total
|
|
158
|
-
success: successCount
|
|
159
|
-
failure: failureCount
|
|
160
|
-
successRate: total
|
|
161
|
-
avgDuration
|
|
152
|
+
total,
|
|
153
|
+
success: successCount,
|
|
154
|
+
failure: failureCount,
|
|
155
|
+
successRate: total > 0 ? `${((successCount / total) * 100).toFixed(2)}%` : '0%',
|
|
156
|
+
avgDuration,
|
|
162
157
|
byActor,
|
|
163
158
|
byAction,
|
|
164
159
|
};
|
|
165
160
|
}
|
|
166
161
|
/**
|
|
167
162
|
* 清理过期审计日志
|
|
168
|
-
*
|
|
169
|
-
* @param [opts.maxAgeDays=90] 保留天数,超过此天数的记录将被删除
|
|
170
|
-
* @returns }
|
|
163
|
+
* @param [opts.maxAgeDays=90] 保留天数
|
|
171
164
|
*/
|
|
172
165
|
cleanup({ maxAgeDays = 90 } = {}) {
|
|
173
166
|
try {
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
|
-
import {
|
|
5
|
+
import { isExcludedProject } from '../../shared/isOwnDevRepo.js';
|
|
6
6
|
import pathGuard from '../../shared/PathGuard.js';
|
|
7
7
|
import { initDrizzle } from './drizzle/index.js';
|
|
8
8
|
const __dirname = import.meta.dirname;
|
|
@@ -30,17 +30,18 @@ export class DatabaseConnection {
|
|
|
30
30
|
let resolvedDbPath = projectRoot && !path.isAbsolute(dbPath)
|
|
31
31
|
? path.resolve(projectRoot, dbPath)
|
|
32
32
|
: path.resolve(dbPath);
|
|
33
|
-
// ──
|
|
34
|
-
// 检测 DB
|
|
35
|
-
//
|
|
33
|
+
// ── 排除项目保护 ──────────────────────────────────────────
|
|
34
|
+
// 检测 DB 即将落地到不适合创建知识库的项目 → 重定向到临时目录
|
|
35
|
+
// 包括:AutoSnippet 源码仓库、生态项目(autosnippet-book 等)、.autosnippet-skip 标记项目
|
|
36
36
|
const effectiveRoot = projectRoot || path.resolve('.');
|
|
37
|
-
|
|
37
|
+
const exclusion = isExcludedProject(effectiveRoot);
|
|
38
|
+
if (exclusion.excluded) {
|
|
38
39
|
const devDbDir = path.join(os.tmpdir(), 'autosnippet-dev');
|
|
39
40
|
if (!fs.existsSync(devDbDir)) {
|
|
40
41
|
fs.mkdirSync(devDbDir, { recursive: true });
|
|
41
42
|
}
|
|
42
43
|
resolvedDbPath = path.join(devDbDir, 'autosnippet.db');
|
|
43
|
-
process.stderr.write(`[AutoSnippet]
|
|
44
|
+
process.stderr.write(`[AutoSnippet] Excluded project detected (${exclusion.reason}) — DB redirected to ${resolvedDbPath}\n`);
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
47
|
// 路径安全检查 — 防止 DB 文件创建到项目允许范围外
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
* 所有表定义从 migration 001-003 忠实翻译。
|
|
5
5
|
* DB 列名与 migration 保持一致;实体映射由 repository 层处理。
|
|
6
6
|
*
|
|
7
|
-
* 表清单 (
|
|
7
|
+
* 表清单 (15):
|
|
8
8
|
* 001: knowledge_entries, knowledge_edges, guard_violations, audit_logs,
|
|
9
9
|
* sessions, token_usage, semantic_memories, bootstrap_snapshots,
|
|
10
10
|
* bootstrap_dim_files, code_entities
|
|
11
|
-
* 002: tasks, task_dependencies, task_events
|
|
12
11
|
* 003: remote_commands
|
|
13
12
|
* 004: evolution_proposals (+ knowledge_entries.staging_deadline)
|
|
13
|
+
* 005: recipe_source_refs
|
|
14
14
|
* 内联: remote_state
|
|
15
15
|
* 内部: schema_migrations
|
|
16
|
+
*
|
|
17
|
+
* 注: Task 系统为纯内存 + JSONL 信号架构,不使用数据库表。
|
|
16
18
|
*/
|
|
17
19
|
export declare const schemaMigrations: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
18
20
|
name: "schema_migrations";
|
|
@@ -3411,3 +3413,179 @@ export declare const recipeSourceRefs: import("drizzle-orm/sqlite-core").SQLiteT
|
|
|
3411
3413
|
};
|
|
3412
3414
|
dialect: "sqlite";
|
|
3413
3415
|
}>;
|
|
3416
|
+
export declare const lifecycleTransitionEvents: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
3417
|
+
name: "lifecycle_transition_events";
|
|
3418
|
+
schema: undefined;
|
|
3419
|
+
columns: {
|
|
3420
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3421
|
+
name: "id";
|
|
3422
|
+
tableName: "lifecycle_transition_events";
|
|
3423
|
+
dataType: "string";
|
|
3424
|
+
columnType: "SQLiteText";
|
|
3425
|
+
data: string;
|
|
3426
|
+
driverParam: string;
|
|
3427
|
+
notNull: true;
|
|
3428
|
+
hasDefault: false;
|
|
3429
|
+
isPrimaryKey: true;
|
|
3430
|
+
isAutoincrement: false;
|
|
3431
|
+
hasRuntimeDefault: false;
|
|
3432
|
+
enumValues: [string, ...string[]];
|
|
3433
|
+
baseColumn: never;
|
|
3434
|
+
identity: undefined;
|
|
3435
|
+
generated: undefined;
|
|
3436
|
+
}, {}, {
|
|
3437
|
+
length: number | undefined;
|
|
3438
|
+
}>;
|
|
3439
|
+
recipeId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3440
|
+
name: "recipe_id";
|
|
3441
|
+
tableName: "lifecycle_transition_events";
|
|
3442
|
+
dataType: "string";
|
|
3443
|
+
columnType: "SQLiteText";
|
|
3444
|
+
data: string;
|
|
3445
|
+
driverParam: string;
|
|
3446
|
+
notNull: true;
|
|
3447
|
+
hasDefault: false;
|
|
3448
|
+
isPrimaryKey: false;
|
|
3449
|
+
isAutoincrement: false;
|
|
3450
|
+
hasRuntimeDefault: false;
|
|
3451
|
+
enumValues: [string, ...string[]];
|
|
3452
|
+
baseColumn: never;
|
|
3453
|
+
identity: undefined;
|
|
3454
|
+
generated: undefined;
|
|
3455
|
+
}, {}, {
|
|
3456
|
+
length: number | undefined;
|
|
3457
|
+
}>;
|
|
3458
|
+
fromState: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3459
|
+
name: "from_state";
|
|
3460
|
+
tableName: "lifecycle_transition_events";
|
|
3461
|
+
dataType: "string";
|
|
3462
|
+
columnType: "SQLiteText";
|
|
3463
|
+
data: string;
|
|
3464
|
+
driverParam: string;
|
|
3465
|
+
notNull: true;
|
|
3466
|
+
hasDefault: false;
|
|
3467
|
+
isPrimaryKey: false;
|
|
3468
|
+
isAutoincrement: false;
|
|
3469
|
+
hasRuntimeDefault: false;
|
|
3470
|
+
enumValues: [string, ...string[]];
|
|
3471
|
+
baseColumn: never;
|
|
3472
|
+
identity: undefined;
|
|
3473
|
+
generated: undefined;
|
|
3474
|
+
}, {}, {
|
|
3475
|
+
length: number | undefined;
|
|
3476
|
+
}>;
|
|
3477
|
+
toState: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3478
|
+
name: "to_state";
|
|
3479
|
+
tableName: "lifecycle_transition_events";
|
|
3480
|
+
dataType: "string";
|
|
3481
|
+
columnType: "SQLiteText";
|
|
3482
|
+
data: string;
|
|
3483
|
+
driverParam: string;
|
|
3484
|
+
notNull: true;
|
|
3485
|
+
hasDefault: false;
|
|
3486
|
+
isPrimaryKey: false;
|
|
3487
|
+
isAutoincrement: false;
|
|
3488
|
+
hasRuntimeDefault: false;
|
|
3489
|
+
enumValues: [string, ...string[]];
|
|
3490
|
+
baseColumn: never;
|
|
3491
|
+
identity: undefined;
|
|
3492
|
+
generated: undefined;
|
|
3493
|
+
}, {}, {
|
|
3494
|
+
length: number | undefined;
|
|
3495
|
+
}>;
|
|
3496
|
+
trigger: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3497
|
+
name: "trigger";
|
|
3498
|
+
tableName: "lifecycle_transition_events";
|
|
3499
|
+
dataType: "string";
|
|
3500
|
+
columnType: "SQLiteText";
|
|
3501
|
+
data: string;
|
|
3502
|
+
driverParam: string;
|
|
3503
|
+
notNull: true;
|
|
3504
|
+
hasDefault: false;
|
|
3505
|
+
isPrimaryKey: false;
|
|
3506
|
+
isAutoincrement: false;
|
|
3507
|
+
hasRuntimeDefault: false;
|
|
3508
|
+
enumValues: [string, ...string[]];
|
|
3509
|
+
baseColumn: never;
|
|
3510
|
+
identity: undefined;
|
|
3511
|
+
generated: undefined;
|
|
3512
|
+
}, {}, {
|
|
3513
|
+
length: number | undefined;
|
|
3514
|
+
}>;
|
|
3515
|
+
operatorId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3516
|
+
name: "operator_id";
|
|
3517
|
+
tableName: "lifecycle_transition_events";
|
|
3518
|
+
dataType: "string";
|
|
3519
|
+
columnType: "SQLiteText";
|
|
3520
|
+
data: string;
|
|
3521
|
+
driverParam: string;
|
|
3522
|
+
notNull: true;
|
|
3523
|
+
hasDefault: true;
|
|
3524
|
+
isPrimaryKey: false;
|
|
3525
|
+
isAutoincrement: false;
|
|
3526
|
+
hasRuntimeDefault: false;
|
|
3527
|
+
enumValues: [string, ...string[]];
|
|
3528
|
+
baseColumn: never;
|
|
3529
|
+
identity: undefined;
|
|
3530
|
+
generated: undefined;
|
|
3531
|
+
}, {}, {
|
|
3532
|
+
length: number | undefined;
|
|
3533
|
+
}>;
|
|
3534
|
+
evidenceJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3535
|
+
name: "evidence_json";
|
|
3536
|
+
tableName: "lifecycle_transition_events";
|
|
3537
|
+
dataType: "string";
|
|
3538
|
+
columnType: "SQLiteText";
|
|
3539
|
+
data: string;
|
|
3540
|
+
driverParam: string;
|
|
3541
|
+
notNull: false;
|
|
3542
|
+
hasDefault: false;
|
|
3543
|
+
isPrimaryKey: false;
|
|
3544
|
+
isAutoincrement: false;
|
|
3545
|
+
hasRuntimeDefault: false;
|
|
3546
|
+
enumValues: [string, ...string[]];
|
|
3547
|
+
baseColumn: never;
|
|
3548
|
+
identity: undefined;
|
|
3549
|
+
generated: undefined;
|
|
3550
|
+
}, {}, {
|
|
3551
|
+
length: number | undefined;
|
|
3552
|
+
}>;
|
|
3553
|
+
proposalId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3554
|
+
name: "proposal_id";
|
|
3555
|
+
tableName: "lifecycle_transition_events";
|
|
3556
|
+
dataType: "string";
|
|
3557
|
+
columnType: "SQLiteText";
|
|
3558
|
+
data: string;
|
|
3559
|
+
driverParam: string;
|
|
3560
|
+
notNull: false;
|
|
3561
|
+
hasDefault: false;
|
|
3562
|
+
isPrimaryKey: false;
|
|
3563
|
+
isAutoincrement: false;
|
|
3564
|
+
hasRuntimeDefault: false;
|
|
3565
|
+
enumValues: [string, ...string[]];
|
|
3566
|
+
baseColumn: never;
|
|
3567
|
+
identity: undefined;
|
|
3568
|
+
generated: undefined;
|
|
3569
|
+
}, {}, {
|
|
3570
|
+
length: number | undefined;
|
|
3571
|
+
}>;
|
|
3572
|
+
createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
3573
|
+
name: "created_at";
|
|
3574
|
+
tableName: "lifecycle_transition_events";
|
|
3575
|
+
dataType: "number";
|
|
3576
|
+
columnType: "SQLiteInteger";
|
|
3577
|
+
data: number;
|
|
3578
|
+
driverParam: number;
|
|
3579
|
+
notNull: true;
|
|
3580
|
+
hasDefault: false;
|
|
3581
|
+
isPrimaryKey: false;
|
|
3582
|
+
isAutoincrement: false;
|
|
3583
|
+
hasRuntimeDefault: false;
|
|
3584
|
+
enumValues: undefined;
|
|
3585
|
+
baseColumn: never;
|
|
3586
|
+
identity: undefined;
|
|
3587
|
+
generated: undefined;
|
|
3588
|
+
}, {}, {}>;
|
|
3589
|
+
};
|
|
3590
|
+
dialect: "sqlite";
|
|
3591
|
+
}>;
|
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
* 所有表定义从 migration 001-003 忠实翻译。
|
|
5
5
|
* DB 列名与 migration 保持一致;实体映射由 repository 层处理。
|
|
6
6
|
*
|
|
7
|
-
* 表清单 (
|
|
7
|
+
* 表清单 (15):
|
|
8
8
|
* 001: knowledge_entries, knowledge_edges, guard_violations, audit_logs,
|
|
9
9
|
* sessions, token_usage, semantic_memories, bootstrap_snapshots,
|
|
10
10
|
* bootstrap_dim_files, code_entities
|
|
11
|
-
* 002: tasks, task_dependencies, task_events
|
|
12
11
|
* 003: remote_commands
|
|
13
12
|
* 004: evolution_proposals (+ knowledge_entries.staging_deadline)
|
|
13
|
+
* 005: recipe_source_refs
|
|
14
14
|
* 内联: remote_state
|
|
15
15
|
* 内部: schema_migrations
|
|
16
|
+
*
|
|
17
|
+
* 注: Task 系统为纯内存 + JSONL 信号架构,不使用数据库表。
|
|
16
18
|
*/
|
|
17
|
-
import { index, integer, real, sqliteTable, text, uniqueIndex } from 'drizzle-orm/sqlite-core';
|
|
19
|
+
import { index, integer, real, sqliteTable, text, uniqueIndex, } from 'drizzle-orm/sqlite-core';
|
|
18
20
|
// ═══════════════════════════════════════════════════════════════
|
|
19
21
|
// 内部 — schema_migrations
|
|
20
22
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -339,3 +341,21 @@ export const recipeSourceRefs = sqliteTable('recipe_source_refs', {
|
|
|
339
341
|
newPath: text('new_path'),
|
|
340
342
|
verifiedAt: integer('verified_at').notNull(),
|
|
341
343
|
}, (table) => [index('idx_rsr_path').on(table.sourcePath), index('idx_rsr_status').on(table.status)]);
|
|
344
|
+
// ═══════════════════════════════════════════════════════════════
|
|
345
|
+
// 18. lifecycle_transition_events — Recipe 生命周期转移事件 (migration 006)
|
|
346
|
+
// ═══════════════════════════════════════════════════════════════
|
|
347
|
+
export const lifecycleTransitionEvents = sqliteTable('lifecycle_transition_events', {
|
|
348
|
+
id: text('id').primaryKey(),
|
|
349
|
+
recipeId: text('recipe_id').notNull(),
|
|
350
|
+
fromState: text('from_state').notNull(),
|
|
351
|
+
toState: text('to_state').notNull(),
|
|
352
|
+
trigger: text('trigger').notNull(),
|
|
353
|
+
operatorId: text('operator_id').notNull().default('system'),
|
|
354
|
+
evidenceJson: text('evidence_json'),
|
|
355
|
+
proposalId: text('proposal_id'),
|
|
356
|
+
createdAt: integer('created_at').notNull(),
|
|
357
|
+
}, (table) => [
|
|
358
|
+
index('idx_lte_recipe_id').on(table.recipeId),
|
|
359
|
+
index('idx_lte_created_at').on(table.createdAt),
|
|
360
|
+
index('idx_lte_trigger').on(table.trigger),
|
|
361
|
+
]);
|
|
@@ -9,6 +9,7 @@ import { CacheCoordinator } from '../infrastructure/cache/CacheCoordinator.js';
|
|
|
9
9
|
import { GraphCache } from '../infrastructure/cache/GraphCache.js';
|
|
10
10
|
// ─── P3: Infrastructure ──────────────────────────────
|
|
11
11
|
import Logger from '../infrastructure/logging/Logger.js';
|
|
12
|
+
import { unwrapRawDb } from '../repository/search/SearchRepoAdapter.js';
|
|
12
13
|
import * as AgentModule from './modules/AgentModule.js';
|
|
13
14
|
import * as AiModule from './modules/AiModule.js';
|
|
14
15
|
import * as AppModule from './modules/AppModule.js';
|
|
@@ -177,7 +178,9 @@ export class ServiceContainer {
|
|
|
177
178
|
#initCacheCoordinator() {
|
|
178
179
|
try {
|
|
179
180
|
const db = this.singletons.database;
|
|
180
|
-
const rawDb = db
|
|
181
|
+
const rawDb = db
|
|
182
|
+
? unwrapRawDb(db)
|
|
183
|
+
: null;
|
|
181
184
|
if (!rawDb) {
|
|
182
185
|
return;
|
|
183
186
|
}
|
|
@@ -300,7 +303,7 @@ export class ServiceContainer {
|
|
|
300
303
|
if (changedPaths.length === 0 && deletedPaths.length === 0) {
|
|
301
304
|
// 完全命中
|
|
302
305
|
this.singletons.projectGraph = graph;
|
|
303
|
-
this.logger.info(`[ServiceContainer] ProjectGraph ⚡ 缓存命中 (${graph.getOverview()?.totalClasses} classes, ` +
|
|
306
|
+
this.logger.info(`[ServiceContainer] ProjectGraph ⚡ 缓存命中 (${(await graph.getOverview())?.totalClasses} classes, ` +
|
|
304
307
|
`${Date.now() - startTime}ms)`);
|
|
305
308
|
return graph;
|
|
306
309
|
}
|
|
@@ -309,7 +312,7 @@ export class ServiceContainer {
|
|
|
309
312
|
this.singletons.projectGraph = graph;
|
|
310
313
|
// 写回缓存
|
|
311
314
|
cache.save('project-graph', graph.toJSON(), { fileHashes: newHashes });
|
|
312
|
-
const overview = graph.getOverview();
|
|
315
|
+
const overview = (await graph.getOverview());
|
|
313
316
|
this.logger.info(`[ServiceContainer] ProjectGraph 增量更新: +${diff.added} ~${diff.updated} -${diff.deleted} ` +
|
|
314
317
|
`(${overview.totalClasses} classes, ${Date.now() - startTime}ms)`);
|
|
315
318
|
return graph;
|
|
@@ -317,7 +320,7 @@ export class ServiceContainer {
|
|
|
317
320
|
// ── 无缓存,全量构建 ──
|
|
318
321
|
const graph = await ProjectGraph.build(projectRoot, options);
|
|
319
322
|
this.singletons.projectGraph = graph;
|
|
320
|
-
const overview = graph.getOverview();
|
|
323
|
+
const overview = (await graph.getOverview());
|
|
321
324
|
// 计算文件 hash 并写入缓存
|
|
322
325
|
const currentFiles = this.#collectSourceFilePaths(projectRoot, options);
|
|
323
326
|
const fileHashes = cache.computeFileHashes(currentFiles, projectRoot);
|
|
@@ -24,7 +24,17 @@ import type Logger from '../infrastructure/logging/Logger.js';
|
|
|
24
24
|
import type { SignalBus } from '../infrastructure/signal/SignalBus.js';
|
|
25
25
|
import type { IndexingPipeline } from '../infrastructure/vector/IndexingPipeline.js';
|
|
26
26
|
import type { VectorStore } from '../infrastructure/vector/VectorStore.js';
|
|
27
|
+
import type { AuditRepositoryImpl } from '../repository/audit/AuditRepository.js';
|
|
28
|
+
import type { BootstrapRepositoryImpl } from '../repository/bootstrap/BootstrapRepository.js';
|
|
29
|
+
import type { CodeEntityRepositoryImpl } from '../repository/code/CodeEntityRepository.js';
|
|
30
|
+
import type { ProposalRepository } from '../repository/evolution/ProposalRepository.js';
|
|
31
|
+
import type { GuardViolationRepositoryImpl } from '../repository/guard/GuardViolationRepository.js';
|
|
32
|
+
import type { KnowledgeEdgeRepositoryImpl } from '../repository/knowledge/KnowledgeEdgeRepository.js';
|
|
27
33
|
import type { KnowledgeRepositoryImpl } from '../repository/knowledge/KnowledgeRepository.impl.js';
|
|
34
|
+
import type { MemoryRepositoryImpl } from '../repository/memory/MemoryRepository.js';
|
|
35
|
+
import type { RemoteCommandRepository } from '../repository/remote/RemoteCommandRepository.js';
|
|
36
|
+
import type { SessionRepositoryImpl } from '../repository/session/SessionRepository.js';
|
|
37
|
+
import type { RecipeSourceRefRepositoryImpl } from '../repository/sourceref/RecipeSourceRefRepository.js';
|
|
28
38
|
import type { TokenUsageStore } from '../repository/token/TokenUsageStore.js';
|
|
29
39
|
import type { BootstrapTaskManager } from '../service/bootstrap/BootstrapTaskManager.js';
|
|
30
40
|
import type { CursorDeliveryPipeline } from '../service/delivery/CursorDeliveryPipeline.js';
|
|
@@ -74,6 +84,16 @@ export interface ServiceMap {
|
|
|
74
84
|
eventBus: EventBus;
|
|
75
85
|
bootstrapTaskManager: BootstrapTaskManager;
|
|
76
86
|
knowledgeRepository: KnowledgeRepositoryImpl;
|
|
87
|
+
knowledgeEdgeRepository: KnowledgeEdgeRepositoryImpl;
|
|
88
|
+
codeEntityRepository: CodeEntityRepositoryImpl;
|
|
89
|
+
bootstrapRepository: BootstrapRepositoryImpl;
|
|
90
|
+
guardViolationRepository: GuardViolationRepositoryImpl;
|
|
91
|
+
auditRepository: AuditRepositoryImpl;
|
|
92
|
+
memoryRepository: MemoryRepositoryImpl;
|
|
93
|
+
sessionRepository: SessionRepositoryImpl;
|
|
94
|
+
proposalRepository: ProposalRepository;
|
|
95
|
+
remoteCommandRepository: RemoteCommandRepository;
|
|
96
|
+
recipeSourceRefRepository: RecipeSourceRefRepositoryImpl;
|
|
77
97
|
knowledgeFileWriter: KnowledgeFileWriter;
|
|
78
98
|
knowledgeSyncService: KnowledgeSyncService;
|
|
79
99
|
qualityScorer: QualityScorer;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - primeSearchPipeline (for prime multi-query search — no DB dependency)
|
|
9
9
|
*/
|
|
10
10
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
11
|
+
import { unwrapRawDb } from '../../repository/search/SearchRepoAdapter.js';
|
|
11
12
|
import { TokenUsageStore } from '../../repository/token/TokenUsageStore.js';
|
|
12
13
|
import { CursorDeliveryPipeline } from '../../service/delivery/CursorDeliveryPipeline.js';
|
|
13
14
|
import { RecipeExtractor } from '../../service/knowledge/RecipeExtractor.js';
|
|
@@ -29,7 +30,7 @@ export function register(c) {
|
|
|
29
30
|
});
|
|
30
31
|
c.singleton('tokenUsageStore', (ct) => {
|
|
31
32
|
const db = ct.get('database');
|
|
32
|
-
return new TokenUsageStore(db
|
|
33
|
+
return new TokenUsageStore(unwrapRawDb(db), db.getDrizzle());
|
|
33
34
|
});
|
|
34
35
|
// ═══ Module ═══
|
|
35
36
|
c.singleton('moduleService', (ct) => {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
12
|
+
import { unwrapRawDb } from '../../repository/search/SearchRepoAdapter.js';
|
|
12
13
|
import { ComplianceReporter } from '../../service/guard/ComplianceReporter.js';
|
|
13
14
|
import { CoverageAnalyzer } from '../../service/guard/CoverageAnalyzer.js';
|
|
14
15
|
import { ExclusionManager } from '../../service/guard/ExclusionManager.js';
|
|
@@ -66,6 +67,7 @@ export function register(c) {
|
|
|
66
67
|
return new GuardCheckEngine(ct.get('database'), {
|
|
67
68
|
guardConfig: merged,
|
|
68
69
|
signalBus: ct.singletons.signalBus || undefined,
|
|
70
|
+
knowledgeRepo: ct.get('knowledgeRepository'),
|
|
69
71
|
});
|
|
70
72
|
});
|
|
71
73
|
c.singleton('exclusionManager', (ct) => {
|
|
@@ -80,7 +82,7 @@ export function register(c) {
|
|
|
80
82
|
});
|
|
81
83
|
c.singleton('violationsStore', (ct) => {
|
|
82
84
|
const db = ct.get('database');
|
|
83
|
-
return new ViolationsStore(db
|
|
85
|
+
return new ViolationsStore(unwrapRawDb(db), db.getDrizzle());
|
|
84
86
|
});
|
|
85
87
|
c.singleton('complianceReporter', (ct) => {
|
|
86
88
|
const config = ct.singletons._config || {};
|
|
@@ -91,13 +93,11 @@ export function register(c) {
|
|
|
91
93
|
signalBus: ct.singletons.signalBus || undefined,
|
|
92
94
|
}));
|
|
93
95
|
c.singleton('reverseGuard', (ct) => {
|
|
94
|
-
|
|
95
|
-
return new ReverseGuard(db.getDb(), {
|
|
96
|
+
return new ReverseGuard(ct.get('knowledgeRepository'), ct.get('codeEntityRepository'), ct.get('recipeSourceRefRepository'), {
|
|
96
97
|
signalBus: ct.singletons.signalBus || undefined,
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
100
|
c.singleton('coverageAnalyzer', (ct) => {
|
|
100
|
-
const db = ct.get('database');
|
|
101
101
|
let ruleLearner;
|
|
102
102
|
try {
|
|
103
103
|
ruleLearner = { ruleLearner: ct.get('ruleLearner') };
|
|
@@ -105,6 +105,6 @@ export function register(c) {
|
|
|
105
105
|
catch {
|
|
106
106
|
/* ruleLearner not yet available */
|
|
107
107
|
}
|
|
108
|
-
return new CoverageAnalyzer(
|
|
108
|
+
return new CoverageAnalyzer(ct.get('knowledgeRepository'), ct.get('guardViolationRepository'), ruleLearner);
|
|
109
109
|
});
|
|
110
110
|
}
|