autosnippet 3.3.7 → 3.3.8
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-DHJ1Dj7u.css +1 -0
- package/dashboard/dist/assets/index-DV8biUkH.js +112 -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 +2 -1
- 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/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/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/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/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 +6 -8
- 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/constants.d.ts +19 -19
- package/dist/lib/shared/constants.js +10 -10
- 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
|
@@ -49,7 +49,8 @@ const MAX_INTERVAL_MS = 24 * 60 * 60 * 1000; // 最长 24 小时
|
|
|
49
49
|
const SNAPSHOT_FILE = 'signal-snapshot.json';
|
|
50
50
|
export class SignalCollector {
|
|
51
51
|
#projectRoot;
|
|
52
|
-
#
|
|
52
|
+
#knowledgeRepo;
|
|
53
|
+
#auditRepo;
|
|
53
54
|
#agentFactory;
|
|
54
55
|
#container;
|
|
55
56
|
#mode;
|
|
@@ -74,9 +75,10 @@ export class SignalCollector {
|
|
|
74
75
|
* @param [opts.intervalMs] 初始收集间隔(毫秒),后续由 AI 动态调整
|
|
75
76
|
* @param [opts.onSuggestions] 新建议回调 (suggestions[]) => void
|
|
76
77
|
*/
|
|
77
|
-
constructor({ projectRoot,
|
|
78
|
+
constructor({ projectRoot, knowledgeRepo = null, auditRepo = null, agentFactory = null, container = null, signalBus = null, mode = 'auto', intervalMs = DEFAULT_INTERVAL_MS, onSuggestions = null, }) {
|
|
78
79
|
this.#projectRoot = projectRoot;
|
|
79
|
-
this.#
|
|
80
|
+
this.#knowledgeRepo = knowledgeRepo;
|
|
81
|
+
this.#auditRepo = auditRepo;
|
|
80
82
|
this.#agentFactory = agentFactory;
|
|
81
83
|
this.#container = container;
|
|
82
84
|
this.#mode = ['off', 'suggest', 'auto'].includes(mode) ? mode : 'auto';
|
|
@@ -209,11 +211,11 @@ export class SignalCollector {
|
|
|
209
211
|
try {
|
|
210
212
|
// 1. 多维度收集信号
|
|
211
213
|
const signals = {
|
|
212
|
-
guard: this.#collectGuardSignals(),
|
|
214
|
+
guard: await this.#collectGuardSignals(),
|
|
213
215
|
memory: this.#collectMemorySignals(),
|
|
214
|
-
recipes: this.#collectRecipeSignals(),
|
|
215
|
-
candidates: this.#collectCandidateSignals(),
|
|
216
|
-
actions: this.#collectRecentActions(),
|
|
216
|
+
recipes: await this.#collectRecipeSignals(),
|
|
217
|
+
candidates: await this.#collectCandidateSignals(),
|
|
218
|
+
actions: await this.#collectRecentActions(),
|
|
217
219
|
codeChanges: this.#collectCodeChangeSignals(),
|
|
218
220
|
};
|
|
219
221
|
// ── 离线 Fallback: 当 AI 不可用时,降级到 SkillAdvisor 规则引擎 ──
|
|
@@ -221,7 +223,7 @@ export class SignalCollector {
|
|
|
221
223
|
?.isMock ?? true;
|
|
222
224
|
if (!this.#agentFactory || isMock) {
|
|
223
225
|
this.#logger.info('[SignalCollector] AI unavailable, falling back to rule-based analysis');
|
|
224
|
-
return this.#ruleFallback();
|
|
226
|
+
return await this.#ruleFallback();
|
|
225
227
|
}
|
|
226
228
|
// 2. 构造分析 prompt
|
|
227
229
|
const prompt = this.#buildAnalysisPrompt(signals);
|
|
@@ -330,10 +332,13 @@ export class SignalCollector {
|
|
|
330
332
|
*
|
|
331
333
|
* 零延迟、零 token 消耗 — 确保推荐系统始终有输出
|
|
332
334
|
*/
|
|
333
|
-
#ruleFallback() {
|
|
335
|
+
async #ruleFallback() {
|
|
334
336
|
try {
|
|
335
|
-
const advisor = new SkillAdvisor(this.#projectRoot, {
|
|
336
|
-
|
|
337
|
+
const advisor = new SkillAdvisor(this.#projectRoot, {
|
|
338
|
+
knowledgeRepo: this.#knowledgeRepo,
|
|
339
|
+
auditRepo: this.#auditRepo,
|
|
340
|
+
});
|
|
341
|
+
const result = await advisor.suggest();
|
|
337
342
|
const newSuggestions = result.suggestions.filter((s) => !this.#snapshot.pushedNames.includes(s.name));
|
|
338
343
|
// 更新快照
|
|
339
344
|
this.#snapshot.lastRun = new Date().toISOString();
|
|
@@ -389,23 +394,12 @@ export class SignalCollector {
|
|
|
389
394
|
// ═══════════════════════════════════════════════════════
|
|
390
395
|
// 信号收集器(6 维度)
|
|
391
396
|
// ═══════════════════════════════════════════════════════
|
|
392
|
-
#collectGuardSignals() {
|
|
397
|
+
async #collectGuardSignals() {
|
|
393
398
|
try {
|
|
394
|
-
if (!this.#
|
|
399
|
+
if (!this.#auditRepo) {
|
|
395
400
|
return [];
|
|
396
401
|
}
|
|
397
|
-
|
|
398
|
-
const rows = this.#db
|
|
399
|
-
.prepare(`SELECT json_extract(operation_data, '$.ruleName') as ruleName,
|
|
400
|
-
COUNT(*) as cnt,
|
|
401
|
-
MAX(timestamp) as last_at
|
|
402
|
-
FROM audit_logs
|
|
403
|
-
WHERE action LIKE 'guard%'
|
|
404
|
-
AND result = 'violation'
|
|
405
|
-
GROUP BY ruleName
|
|
406
|
-
HAVING cnt > 0
|
|
407
|
-
ORDER BY cnt DESC LIMIT 20`)
|
|
408
|
-
.all();
|
|
402
|
+
const rows = await this.#auditRepo.findGuardViolationSignals(20);
|
|
409
403
|
return rows;
|
|
410
404
|
}
|
|
411
405
|
catch {
|
|
@@ -435,61 +429,40 @@ export class SignalCollector {
|
|
|
435
429
|
return [];
|
|
436
430
|
}
|
|
437
431
|
}
|
|
438
|
-
#collectRecipeSignals() {
|
|
432
|
+
async #collectRecipeSignals() {
|
|
439
433
|
try {
|
|
440
|
-
if (!this.#
|
|
434
|
+
if (!this.#knowledgeRepo) {
|
|
441
435
|
return [];
|
|
442
436
|
}
|
|
443
|
-
|
|
444
|
-
const rows = this.#db
|
|
445
|
-
.prepare(`SELECT id, title, knowledgeType, category, language,
|
|
446
|
-
json_extract(stats, '$.adoptions') as adoption_count,
|
|
447
|
-
json_extract(stats, '$.applications') as application_count,
|
|
448
|
-
json_extract(quality, '$.overall') as quality_overall,
|
|
449
|
-
updatedAt
|
|
450
|
-
FROM knowledge_entries
|
|
451
|
-
WHERE lifecycle = 'active'
|
|
452
|
-
ORDER BY updatedAt DESC LIMIT 30`)
|
|
453
|
-
.all();
|
|
437
|
+
const rows = await this.#knowledgeRepo.findActiveRecipeSignals(30);
|
|
454
438
|
return rows;
|
|
455
439
|
}
|
|
456
440
|
catch {
|
|
457
441
|
return [];
|
|
458
442
|
}
|
|
459
443
|
}
|
|
460
|
-
#collectCandidateSignals() {
|
|
444
|
+
async #collectCandidateSignals() {
|
|
461
445
|
try {
|
|
462
|
-
if (!this.#
|
|
446
|
+
if (!this.#knowledgeRepo) {
|
|
463
447
|
return [];
|
|
464
448
|
}
|
|
465
|
-
|
|
466
|
-
const rows = this.#db
|
|
467
|
-
.prepare(`SELECT id, source, lifecycle as status, language, category,
|
|
468
|
-
title, createdAt
|
|
469
|
-
FROM knowledge_entries WHERE lifecycle = 'pending'
|
|
470
|
-
ORDER BY createdAt DESC LIMIT 30`)
|
|
471
|
-
.all();
|
|
449
|
+
const rows = await this.#knowledgeRepo.findPendingCandidates(30);
|
|
472
450
|
return rows;
|
|
473
451
|
}
|
|
474
452
|
catch {
|
|
475
453
|
return [];
|
|
476
454
|
}
|
|
477
455
|
}
|
|
478
|
-
#collectRecentActions() {
|
|
456
|
+
async #collectRecentActions() {
|
|
479
457
|
try {
|
|
480
|
-
if (!this.#
|
|
458
|
+
if (!this.#auditRepo) {
|
|
481
459
|
return [];
|
|
482
460
|
}
|
|
483
|
-
// audit_logs.timestamp 是 INTEGER (epoch seconds)
|
|
484
461
|
const sinceStr = this.#snapshot.lastRun;
|
|
485
462
|
const sinceTs = sinceStr
|
|
486
463
|
? Math.floor(new Date(sinceStr).getTime() / 1000)
|
|
487
464
|
: Math.floor((Date.now() - 24 * 3600 * 1000) / 1000);
|
|
488
|
-
const rows = this.#
|
|
489
|
-
.prepare(`SELECT actor, action, resource, result, timestamp
|
|
490
|
-
FROM audit_logs WHERE timestamp > ?
|
|
491
|
-
ORDER BY timestamp DESC LIMIT 50`)
|
|
492
|
-
.all(sinceTs);
|
|
465
|
+
const rows = await this.#auditRepo.findRecentActions(sinceTs, 50);
|
|
493
466
|
return rows;
|
|
494
467
|
}
|
|
495
468
|
catch {
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* - 推荐结果包含 draft 草稿(name + description + rationale),
|
|
15
15
|
* Agent 可直接调用 create_skill 创建
|
|
16
16
|
*/
|
|
17
|
+
import type { AuditRepositoryImpl } from '../../repository/audit/AuditRepository.js';
|
|
18
|
+
import type { KnowledgeRepositoryImpl } from '../../repository/knowledge/KnowledgeRepository.impl.js';
|
|
17
19
|
export interface SkillSuggestion {
|
|
18
20
|
name: string;
|
|
19
21
|
description: string;
|
|
@@ -23,20 +25,12 @@ export interface SkillSuggestion {
|
|
|
23
25
|
signals: Record<string, unknown>;
|
|
24
26
|
}
|
|
25
27
|
interface SkillAdvisorOpts {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
all(...args: unknown[]): Record<string, unknown>[];
|
|
29
|
-
get(...args: unknown[]): Record<string, unknown> | undefined;
|
|
30
|
-
};
|
|
31
|
-
} | null;
|
|
28
|
+
knowledgeRepo?: KnowledgeRepositoryImpl | null;
|
|
29
|
+
auditRepo?: AuditRepositoryImpl | null;
|
|
32
30
|
}
|
|
33
31
|
export declare class SkillAdvisor {
|
|
34
32
|
#private;
|
|
35
|
-
|
|
36
|
-
* @param projectRoot 用户项目根目录
|
|
37
|
-
* @param [opts.database] better-sqlite3 实例(可选)
|
|
38
|
-
*/
|
|
39
|
-
constructor(projectRoot: string, { database }?: SkillAdvisorOpts);
|
|
33
|
+
constructor(projectRoot: string, { knowledgeRepo, auditRepo }?: SkillAdvisorOpts);
|
|
40
34
|
/**
|
|
41
35
|
* 生成 Skill 推荐列表
|
|
42
36
|
*
|
|
@@ -52,11 +46,11 @@ export declare class SkillAdvisor {
|
|
|
52
46
|
* analysisContext: object
|
|
53
47
|
* }}
|
|
54
48
|
*/
|
|
55
|
-
suggest(): {
|
|
49
|
+
suggest(): Promise<{
|
|
56
50
|
suggestions: SkillSuggestion[];
|
|
57
51
|
existingProjectSkills: unknown[];
|
|
58
52
|
analysisContext: Record<string, unknown>;
|
|
59
53
|
hint: string;
|
|
60
|
-
}
|
|
54
|
+
}>;
|
|
61
55
|
}
|
|
62
56
|
export default SkillAdvisor;
|
|
@@ -19,14 +19,12 @@ import path from 'node:path';
|
|
|
19
19
|
import { getProjectSkillsPath } from '../../infrastructure/config/Paths.js';
|
|
20
20
|
export class SkillAdvisor {
|
|
21
21
|
#projectRoot;
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* @param [opts.database] better-sqlite3 实例(可选)
|
|
26
|
-
*/
|
|
27
|
-
constructor(projectRoot, { database } = {}) {
|
|
22
|
+
#knowledgeRepo;
|
|
23
|
+
#auditRepo;
|
|
24
|
+
constructor(projectRoot, { knowledgeRepo, auditRepo } = {}) {
|
|
28
25
|
this.#projectRoot = projectRoot;
|
|
29
|
-
this.#
|
|
26
|
+
this.#knowledgeRepo = knowledgeRepo || null;
|
|
27
|
+
this.#auditRepo = auditRepo || null;
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* 生成 Skill 推荐列表
|
|
@@ -43,13 +41,13 @@ export class SkillAdvisor {
|
|
|
43
41
|
* analysisContext: object
|
|
44
42
|
* }}
|
|
45
43
|
*/
|
|
46
|
-
suggest() {
|
|
44
|
+
async suggest() {
|
|
47
45
|
const existingSkills = this.#listExistingProjectSkills();
|
|
48
46
|
const suggestions = [];
|
|
49
47
|
const analysisContext = {};
|
|
50
48
|
// ── 维度 1: Guard 违规模式 ──
|
|
51
49
|
try {
|
|
52
|
-
const guardInsights = this.#analyzeGuardPatterns();
|
|
50
|
+
const guardInsights = await this.#analyzeGuardPatterns();
|
|
53
51
|
analysisContext.guard = guardInsights.summary;
|
|
54
52
|
suggestions.push(...guardInsights.suggestions.filter((s) => !existingSkills.has(s.name)));
|
|
55
53
|
}
|
|
@@ -67,7 +65,7 @@ export class SkillAdvisor {
|
|
|
67
65
|
}
|
|
68
66
|
// ── 维度 3: Recipe 分布与使用 ──
|
|
69
67
|
try {
|
|
70
|
-
const recipeInsights = this.#analyzeRecipePatterns();
|
|
68
|
+
const recipeInsights = await this.#analyzeRecipePatterns();
|
|
71
69
|
analysisContext.recipes = recipeInsights.summary;
|
|
72
70
|
suggestions.push(...recipeInsights.suggestions.filter((s) => !existingSkills.has(s.name)));
|
|
73
71
|
}
|
|
@@ -76,7 +74,7 @@ export class SkillAdvisor {
|
|
|
76
74
|
}
|
|
77
75
|
// ── 维度 4: 候选积压 ──
|
|
78
76
|
try {
|
|
79
|
-
const candidateInsights = this.#analyzeCandidatePatterns();
|
|
77
|
+
const candidateInsights = await this.#analyzeCandidatePatterns();
|
|
80
78
|
analysisContext.candidates = candidateInsights.summary;
|
|
81
79
|
suggestions.push(...candidateInsights.suggestions.filter((s) => !existingSkills.has(s.name)));
|
|
82
80
|
}
|
|
@@ -99,26 +97,13 @@ export class SkillAdvisor {
|
|
|
99
97
|
// ═══════════════════════════════════════════════════════
|
|
100
98
|
// 维度 1: Guard 违规模式分析
|
|
101
99
|
// ═══════════════════════════════════════════════════════
|
|
102
|
-
#analyzeGuardPatterns() {
|
|
100
|
+
async #analyzeGuardPatterns() {
|
|
103
101
|
const suggestions = [];
|
|
104
|
-
if (!this.#
|
|
105
|
-
return { summary: '
|
|
102
|
+
if (!this.#auditRepo) {
|
|
103
|
+
return { summary: 'AuditRepo 不可用', suggestions };
|
|
106
104
|
}
|
|
107
105
|
try {
|
|
108
|
-
|
|
109
|
-
const rows = this.#db
|
|
110
|
-
.prepare(`
|
|
111
|
-
SELECT json_extract(operation_data, '$.ruleName') as ruleName,
|
|
112
|
-
COUNT(*) as cnt
|
|
113
|
-
FROM audit_logs
|
|
114
|
-
WHERE action LIKE 'guard%'
|
|
115
|
-
AND result = 'violation'
|
|
116
|
-
GROUP BY ruleName
|
|
117
|
-
HAVING cnt >= 3
|
|
118
|
-
ORDER BY cnt DESC
|
|
119
|
-
LIMIT 5
|
|
120
|
-
`)
|
|
121
|
-
.all();
|
|
106
|
+
const rows = await this.#auditRepo.findTopGuardViolationRules(3, 5);
|
|
122
107
|
if (rows.length > 0) {
|
|
123
108
|
const topRule = rows[0];
|
|
124
109
|
suggestions.push({
|
|
@@ -192,32 +177,16 @@ export class SkillAdvisor {
|
|
|
192
177
|
// ═══════════════════════════════════════════════════════
|
|
193
178
|
// 维度 3: Recipe 分布与使用热度
|
|
194
179
|
// ═══════════════════════════════════════════════════════
|
|
195
|
-
#analyzeRecipePatterns() {
|
|
180
|
+
async #analyzeRecipePatterns() {
|
|
196
181
|
const suggestions = [];
|
|
197
|
-
if (!this.#
|
|
198
|
-
return { summary: '
|
|
182
|
+
if (!this.#knowledgeRepo) {
|
|
183
|
+
return { summary: 'KnowledgeRepo 不可用', suggestions };
|
|
199
184
|
}
|
|
200
185
|
try {
|
|
201
186
|
// 按 category 分布
|
|
202
|
-
const categories = this.#
|
|
203
|
-
.prepare(`
|
|
204
|
-
SELECT category, COUNT(*) as cnt
|
|
205
|
-
FROM knowledge_entries
|
|
206
|
-
WHERE lifecycle = 'active' AND category IS NOT NULL AND category != ''
|
|
207
|
-
GROUP BY category
|
|
208
|
-
ORDER BY cnt DESC
|
|
209
|
-
`)
|
|
210
|
-
.all();
|
|
187
|
+
const categories = await this.#knowledgeRepo.countGroupByCategory();
|
|
211
188
|
// 按 language 分布
|
|
212
|
-
const languages = this.#
|
|
213
|
-
.prepare(`
|
|
214
|
-
SELECT language, COUNT(*) as cnt
|
|
215
|
-
FROM knowledge_entries
|
|
216
|
-
WHERE lifecycle = 'active' AND language IS NOT NULL AND language != ''
|
|
217
|
-
GROUP BY language
|
|
218
|
-
ORDER BY cnt DESC
|
|
219
|
-
`)
|
|
220
|
-
.all();
|
|
189
|
+
const languages = await this.#knowledgeRepo.countGroupByLanguage();
|
|
221
190
|
// 高频使用但无自定义 Skill 的 category
|
|
222
191
|
const topCategory = categories[0];
|
|
223
192
|
if (topCategory && topCategory.cnt >= 10) {
|
|
@@ -235,20 +204,10 @@ export class SkillAdvisor {
|
|
|
235
204
|
},
|
|
236
205
|
});
|
|
237
206
|
}
|
|
238
|
-
// 高使用量 Recipe
|
|
207
|
+
// 高使用量 Recipe 统计
|
|
239
208
|
let hotRecipes = [];
|
|
240
209
|
try {
|
|
241
|
-
hotRecipes = this.#
|
|
242
|
-
.prepare(`
|
|
243
|
-
SELECT title, category,
|
|
244
|
-
(COALESCE(json_extract(stats, '$.adoptions'), 0) + COALESCE(json_extract(stats, '$.applications'), 0)) as total_usage
|
|
245
|
-
FROM knowledge_entries
|
|
246
|
-
WHERE lifecycle = 'active'
|
|
247
|
-
AND (COALESCE(json_extract(stats, '$.adoptions'), 0) + COALESCE(json_extract(stats, '$.applications'), 0)) >= 5
|
|
248
|
-
ORDER BY total_usage DESC
|
|
249
|
-
LIMIT 10
|
|
250
|
-
`)
|
|
251
|
-
.all();
|
|
210
|
+
hotRecipes = await this.#knowledgeRepo.findHotRecipesByUsage(5, 10);
|
|
252
211
|
}
|
|
253
212
|
catch {
|
|
254
213
|
/* 查询失败时降级为空 */
|
|
@@ -265,31 +224,23 @@ export class SkillAdvisor {
|
|
|
265
224
|
// ═══════════════════════════════════════════════════════
|
|
266
225
|
// 维度 4: 候选积压分析
|
|
267
226
|
// ═══════════════════════════════════════════════════════
|
|
268
|
-
#analyzeCandidatePatterns() {
|
|
227
|
+
async #analyzeCandidatePatterns() {
|
|
269
228
|
const suggestions = [];
|
|
270
|
-
if (!this.#
|
|
271
|
-
return { summary: '
|
|
229
|
+
if (!this.#knowledgeRepo) {
|
|
230
|
+
return { summary: 'KnowledgeRepo 不可用', suggestions };
|
|
272
231
|
}
|
|
273
232
|
try {
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
.prepare(`
|
|
277
|
-
SELECT
|
|
278
|
-
COUNT(*) as total,
|
|
279
|
-
SUM(CASE WHEN lifecycle='pending' THEN 1 ELSE 0 END) as pending,
|
|
280
|
-
SUM(CASE WHEN lifecycle='deprecated' THEN 1 ELSE 0 END) as rejected
|
|
281
|
-
FROM knowledge_entries
|
|
282
|
-
`)
|
|
283
|
-
.get();
|
|
233
|
+
const stats = await this.#knowledgeRepo.getLifecycleCounts();
|
|
234
|
+
const rejected = stats?.deprecated ?? 0;
|
|
284
235
|
// 大量被拒绝 → 提示候选质量 Skill
|
|
285
|
-
if (
|
|
236
|
+
if (rejected >= 10) {
|
|
286
237
|
suggestions.push({
|
|
287
238
|
name: 'project-candidate-quality',
|
|
288
|
-
description: `候选提交质量指南 — ${
|
|
289
|
-
rationale: `已有 ${
|
|
239
|
+
description: `候选提交质量指南 — ${rejected} 条候选被拒,建议创建提交标准 Skill`,
|
|
240
|
+
rationale: `已有 ${rejected} 条候选被驳回(总计 ${stats?.total ?? 0} 条)。创建一个 Skill 明确项目的候选提交标准(哪些代码值得提取、必填字段要求、质量标杆),可以减少返工。`,
|
|
290
241
|
source: 'candidate_rejection',
|
|
291
|
-
priority:
|
|
292
|
-
signals: { total: stats
|
|
242
|
+
priority: rejected >= 20 ? 'high' : 'medium',
|
|
243
|
+
signals: { total: stats?.total ?? 0, pending: stats?.pending ?? 0, rejected },
|
|
293
244
|
});
|
|
294
245
|
}
|
|
295
246
|
return {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module service/vector/SyncCoordinator
|
|
13
13
|
*/
|
|
14
|
+
import type { DrizzleDB } from '../../infrastructure/database/drizzle/index.js';
|
|
14
15
|
import type { EventBus } from '../../infrastructure/event/EventBus.js';
|
|
15
16
|
import type { VectorStore } from '../../infrastructure/vector/VectorStore.js';
|
|
16
17
|
import type { ContextualEnricher } from './ContextualEnricher.js';
|
|
@@ -21,6 +22,7 @@ export interface SyncCoordinatorConfig {
|
|
|
21
22
|
contextualEnricher: ContextualEnricher | null;
|
|
22
23
|
debounceMs: number;
|
|
23
24
|
maxBatchSize?: number;
|
|
25
|
+
drizzle?: DrizzleDB;
|
|
24
26
|
}
|
|
25
27
|
export declare class SyncCoordinator {
|
|
26
28
|
#private;
|
|
@@ -37,7 +39,7 @@ export declare class SyncCoordinator {
|
|
|
37
39
|
* @param db - 数据库连接 (better-sqlite3 style)
|
|
38
40
|
* @returns 对账结果
|
|
39
41
|
*/
|
|
40
|
-
reconcile(db
|
|
42
|
+
reconcile(db?: {
|
|
41
43
|
prepare(sql: string): {
|
|
42
44
|
all(...args: unknown[]): Array<{
|
|
43
45
|
id: string;
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module service/vector/SyncCoordinator
|
|
13
13
|
*/
|
|
14
|
+
import { ne } from 'drizzle-orm';
|
|
15
|
+
import { knowledgeEntries } from '../../infrastructure/database/drizzle/schema.js';
|
|
14
16
|
import Logger from '../../infrastructure/logging/Logger.js';
|
|
17
|
+
import { queryNonDeprecatedEntries } from '../../repository/search/SearchRepoAdapter.js';
|
|
15
18
|
// ── Coordinator ──
|
|
16
19
|
export class SyncCoordinator {
|
|
17
20
|
#vectorStore;
|
|
@@ -19,6 +22,7 @@ export class SyncCoordinator {
|
|
|
19
22
|
#contextualEnricher;
|
|
20
23
|
#debounceMs;
|
|
21
24
|
#maxBatchSize;
|
|
25
|
+
#drizzle;
|
|
22
26
|
#pendingChanges = new Map();
|
|
23
27
|
#debounceTimer = null;
|
|
24
28
|
#processing = false;
|
|
@@ -31,6 +35,7 @@ export class SyncCoordinator {
|
|
|
31
35
|
this.#contextualEnricher = config.contextualEnricher;
|
|
32
36
|
this.#debounceMs = config.debounceMs;
|
|
33
37
|
this.#maxBatchSize = config.maxBatchSize ?? 20;
|
|
38
|
+
this.#drizzle = config.drizzle ?? null;
|
|
34
39
|
}
|
|
35
40
|
/** 绑定 EventBus,开始监听知识变更事件 */
|
|
36
41
|
bindEventBus(eventBus) {
|
|
@@ -76,9 +81,26 @@ export class SyncCoordinator {
|
|
|
76
81
|
// 2. 获取 DB 中所有 active 知识条目 ID
|
|
77
82
|
let dbEntries = [];
|
|
78
83
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
if (this.#drizzle) {
|
|
85
|
+
// Drizzle 类型安全查询
|
|
86
|
+
dbEntries = this.#drizzle
|
|
87
|
+
.select({
|
|
88
|
+
id: knowledgeEntries.id,
|
|
89
|
+
title: knowledgeEntries.title,
|
|
90
|
+
content: knowledgeEntries.content,
|
|
91
|
+
kind: knowledgeEntries.kind,
|
|
92
|
+
})
|
|
93
|
+
.from(knowledgeEntries)
|
|
94
|
+
.where(ne(knowledgeEntries.lifecycle, 'deprecated'))
|
|
95
|
+
.all();
|
|
96
|
+
}
|
|
97
|
+
else if (db) {
|
|
98
|
+
// 向后兼容: 测试时可传入 mock db
|
|
99
|
+
dbEntries = queryNonDeprecatedEntries(db);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
82
104
|
}
|
|
83
105
|
catch {
|
|
84
106
|
// 表可能不存在
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module service/vector/VectorService
|
|
14
14
|
*/
|
|
15
|
+
import type { DrizzleDB } from '../../infrastructure/database/drizzle/index.js';
|
|
15
16
|
import type { EventBus } from '../../infrastructure/event/EventBus.js';
|
|
16
17
|
import type { IndexingPipeline } from '../../infrastructure/vector/IndexingPipeline.js';
|
|
17
18
|
import type { VectorStore } from '../../infrastructure/vector/VectorStore.js';
|
|
@@ -29,6 +30,7 @@ export interface VectorServiceConfig {
|
|
|
29
30
|
contextualEnricher: ContextualEnricher | null;
|
|
30
31
|
autoSyncOnCrud: boolean;
|
|
31
32
|
syncDebounceMs: number;
|
|
33
|
+
drizzle?: DrizzleDB;
|
|
32
34
|
}
|
|
33
35
|
export interface BuildResult {
|
|
34
36
|
scanned: number;
|
|
@@ -24,6 +24,7 @@ export class VectorService {
|
|
|
24
24
|
#syncCoordinator = null;
|
|
25
25
|
#autoSyncOnCrud;
|
|
26
26
|
#syncDebounceMs;
|
|
27
|
+
#drizzle;
|
|
27
28
|
#logger = Logger.getInstance();
|
|
28
29
|
#initialized = false;
|
|
29
30
|
// ── Embed circuit breaker ──
|
|
@@ -40,6 +41,7 @@ export class VectorService {
|
|
|
40
41
|
this.#contextualEnricher = config.contextualEnricher;
|
|
41
42
|
this.#autoSyncOnCrud = config.autoSyncOnCrud;
|
|
42
43
|
this.#syncDebounceMs = config.syncDebounceMs;
|
|
44
|
+
this.#drizzle = config.drizzle ?? null;
|
|
43
45
|
}
|
|
44
46
|
// ═══ Lifecycle ═══
|
|
45
47
|
/** 初始化: 绑定 EventBus 事件监听 */
|
|
@@ -55,6 +57,7 @@ export class VectorService {
|
|
|
55
57
|
embedProvider: this.#embedProvider,
|
|
56
58
|
contextualEnricher: this.#contextualEnricher,
|
|
57
59
|
debounceMs: this.#syncDebounceMs,
|
|
60
|
+
drizzle: this.#drizzle ?? undefined,
|
|
58
61
|
});
|
|
59
62
|
this.#syncCoordinator.bindEventBus(this.#eventBus);
|
|
60
63
|
this.#logger.info('[VectorService] SyncCoordinator bound to EventBus');
|
|
@@ -291,7 +291,7 @@ export class WikiGenerator {
|
|
|
291
291
|
/** AST 分析 — 利用已有 ProjectGraph 或重新构建 */
|
|
292
292
|
async _analyzeAST() {
|
|
293
293
|
if (this.projectGraph) {
|
|
294
|
-
const overview = this.projectGraph.getOverview();
|
|
294
|
+
const overview = await this.projectGraph.getOverview();
|
|
295
295
|
const allClasses = this.projectGraph.getAllClassNames();
|
|
296
296
|
const allProtocols = this.projectGraph.getAllProtocolNames();
|
|
297
297
|
// 按模块分组类名和协议名 (通过 filePath 推断所属模块)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LanguageProfiles — 全景分析多语言统一注册中心
|
|
3
|
+
*
|
|
4
|
+
* 设计原则:
|
|
5
|
+
* 1. **语言族 (LanguageFamily)** 是核心抽象 — 同族语言共享 import 语法、框架类体系、生态库
|
|
6
|
+
* 2. **单一数据源** — 新增语言只需添加一条 FamilyProfile,所有消费者自动生效
|
|
7
|
+
* 3. **与 LanguageService 互补** — LanguageService 管理基础映射 (ext→lang),
|
|
8
|
+
* LanguageProfiles 管理分析知识 (import 解析、角色推断、技术栈分类)
|
|
9
|
+
* 4. **按关注点暴露 API** — 消费者调用自己需要的访问器,无需了解内部数据结构
|
|
10
|
+
*
|
|
11
|
+
* 消费者:
|
|
12
|
+
* - CouplingAnalyzer → importPatterns, sourceExts
|
|
13
|
+
* - RoleRefiner → familyOf, superclassRoles, protocolRoles, importRolePatterns
|
|
14
|
+
* - TechStackProfiler → knownLibraries, keywordCategories
|
|
15
|
+
* - ModuleDiscoverer → skipDirs, artifactSuffixes, vendorDirs, sourceExts
|
|
16
|
+
*
|
|
17
|
+
* @module LanguageProfiles
|
|
18
|
+
*/
|
|
19
|
+
/** 模块在软件架构中扮演的角色 */
|
|
20
|
+
export type ModuleRole = 'core' | 'service' | 'ui' | 'networking' | 'storage' | 'test' | 'app' | 'routing' | 'utility' | 'model' | 'auth' | 'config' | 'feature';
|
|
21
|
+
export type LanguageFamily = 'apple' | 'jvm' | 'dart' | 'python' | 'web' | 'go' | 'rust' | 'dotnet';
|
|
22
|
+
/** import 语句解析模式 — 用于依赖边提取 */
|
|
23
|
+
export interface ImportPattern {
|
|
24
|
+
/** 匹配 import 语句的正则 (对 trimmed 行执行) */
|
|
25
|
+
regex: RegExp;
|
|
26
|
+
/** 从匹配结果提取模块名候选列表 */
|
|
27
|
+
extract: (m: RegExpExecArray) => string[];
|
|
28
|
+
}
|
|
29
|
+
/** import 关键词 → 角色推断模式 */
|
|
30
|
+
export interface RolePattern {
|
|
31
|
+
regex: RegExp;
|
|
32
|
+
role: ModuleRole;
|
|
33
|
+
}
|
|
34
|
+
export declare class LanguageProfiles {
|
|
35
|
+
/** 将规范化语言 ID 映射到语言族 */
|
|
36
|
+
static familyOf(langId: string): LanguageFamily | undefined;
|
|
37
|
+
/** 返回所有已注册的语言族 ID */
|
|
38
|
+
static allFamilies(): LanguageFamily[];
|
|
39
|
+
/** 根据主语言解析项目涉及的语言族 */
|
|
40
|
+
static resolveFamilies(primaryLang: string | null): LanguageFamily[];
|
|
41
|
+
/**
|
|
42
|
+
* 获取所有 import 解析模式 (合并全部语言族 + C/C++)
|
|
43
|
+
*
|
|
44
|
+
* CouplingAnalyzer 对每行代码尝试所有模式,
|
|
45
|
+
* 按「特异性递减」排列:最特殊的模式在前。
|
|
46
|
+
*/
|
|
47
|
+
static get importPatterns(): readonly ImportPattern[];
|
|
48
|
+
/**
|
|
49
|
+
* 源代码文件扩展名集合 — 委托 LanguageService
|
|
50
|
+
*
|
|
51
|
+
* 消除 CouplingAnalyzer / ModuleDiscoverer 自建 SOURCE_EXTS 的重复。
|
|
52
|
+
*/
|
|
53
|
+
static get sourceExts(): ReadonlySet<string>;
|
|
54
|
+
/**
|
|
55
|
+
* 合并指定语言族的超类→角色映射
|
|
56
|
+
* @param families 项目检测到的语言族
|
|
57
|
+
*/
|
|
58
|
+
static superclassRoles(families: LanguageFamily[]): Record<string, ModuleRole>;
|
|
59
|
+
/**
|
|
60
|
+
* 合并指定语言族的协议/接口→角色映射
|
|
61
|
+
* @param families 项目检测到的语言族
|
|
62
|
+
*/
|
|
63
|
+
static protocolRoles(families: LanguageFamily[]): Record<string, ModuleRole>;
|
|
64
|
+
/**
|
|
65
|
+
* 合并指定语言族的 import→角色模式 + 通用模式
|
|
66
|
+
* @param families 项目检测到的语言族
|
|
67
|
+
*/
|
|
68
|
+
static importRolePatterns(families: LanguageFamily[]): RolePattern[];
|
|
69
|
+
/**
|
|
70
|
+
* 获取全量已知库→分类映射 (合并所有族 + 跨平台库)
|
|
71
|
+
*
|
|
72
|
+
* TechStackProfiler 不按族过滤 — 外部依赖可能跨生态
|
|
73
|
+
*/
|
|
74
|
+
static get knownLibraries(): Readonly<Record<string, string>>;
|
|
75
|
+
/** 关键词启发式分类 — KNOWN_LIBRARIES 未命中时的 fallback */
|
|
76
|
+
static get keywordCategories(): ReadonlyArray<[RegExp, string]>;
|
|
77
|
+
/**
|
|
78
|
+
* 应跳过的目录名集合 (合并 LanguageService.scanSkipDirs + 各族额外目录)
|
|
79
|
+
*/
|
|
80
|
+
static get skipDirs(): ReadonlySet<string>;
|
|
81
|
+
/** 构建产物后缀 (合并全部族) */
|
|
82
|
+
static get artifactSuffixes(): readonly string[];
|
|
83
|
+
/** Vendor / 第三方目录名集合 (合并通用 + 各族) */
|
|
84
|
+
static get vendorDirs(): ReadonlySet<string>;
|
|
85
|
+
/**
|
|
86
|
+
* 三方库路径正则 — 匹配路径中的 vendor 目录名或已知库名
|
|
87
|
+
*
|
|
88
|
+
* 组成:
|
|
89
|
+
* 1. vendorDirs + 常见 skip 目录 (Pods, Carthage, DerivedData, …)
|
|
90
|
+
* 2. knownLibraries 中所有库名 (首字母大写形式)
|
|
91
|
+
*
|
|
92
|
+
* 用于 Agent 工具层对搜索结果做三方库过滤。
|
|
93
|
+
*/
|
|
94
|
+
static get thirdPartyPathRegex(): RegExp;
|
|
95
|
+
/**
|
|
96
|
+
* 多语言基类/根类型排除集 — 合并所有族的 superclassRoles + protocolRoles + 额外基础类型。
|
|
97
|
+
*
|
|
98
|
+
* 用于 getHotNodes() 等入度统计,排除高入度但无信息量的语言根类型。
|
|
99
|
+
* 新增语言族时自动生效,无需手动维护排除列表。
|
|
100
|
+
*/
|
|
101
|
+
static get baseClassExclusions(): ReadonlySet<string>;
|
|
102
|
+
/**
|
|
103
|
+
* 合法代码语言集合 — 合并 LanguageService.knownLangs + 常见别名。
|
|
104
|
+
*
|
|
105
|
+
* QualityScorer 格式评分使用,判断 recipe 的 language 字段是否合法。
|
|
106
|
+
* 新增语言时只需在 LanguageService 添加,此处自动生效。
|
|
107
|
+
*/
|
|
108
|
+
static get validCodeLanguages(): ReadonlySet<string>;
|
|
109
|
+
}
|