autosnippet 3.3.5 → 3.3.6
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-D1aVZYFW.js +1 -0
- package/dashboard/dist/assets/index-CxHOu8Hd.css +1 -0
- package/dashboard/dist/assets/index-DDdAOpYT.js +128 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/api-server.js +1 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +136 -9
- package/dist/lib/agent/AgentFactory.d.ts +0 -17
- package/dist/lib/agent/AgentFactory.js +1 -25
- package/dist/lib/agent/capabilities.d.ts +11 -0
- package/dist/lib/agent/capabilities.js +29 -5
- package/dist/lib/agent/context/ExplorationTracker.js +10 -1
- package/dist/lib/agent/context/exploration/ExplorationStrategies.d.ts +2 -0
- package/dist/lib/agent/context/exploration/ExplorationStrategies.js +2 -2
- package/dist/lib/agent/domain/insight-analyst.d.ts +47 -3
- package/dist/lib/agent/domain/insight-analyst.js +111 -11
- package/dist/lib/agent/domain/insight-evolver.d.ts +69 -0
- package/dist/lib/agent/domain/insight-evolver.js +230 -0
- package/dist/lib/agent/domain/insight-gate.d.ts +42 -0
- package/dist/lib/agent/domain/insight-gate.js +41 -0
- package/dist/lib/agent/domain/insight-producer.d.ts +27 -2
- package/dist/lib/agent/domain/insight-producer.js +60 -5
- package/dist/lib/agent/domain/scan-prompts.js +10 -7
- package/dist/lib/agent/memory/ActiveContext.d.ts +2 -28
- package/dist/lib/agent/memory/MemoryCoordinator.d.ts +2 -2
- package/dist/lib/agent/memory/SessionStore.d.ts +6 -12
- package/dist/lib/agent/memory/SessionStore.js +9 -15
- package/dist/lib/agent/memory/memory-flush-contract.d.ts +49 -0
- package/dist/lib/agent/memory/memory-flush-contract.js +16 -0
- package/dist/lib/agent/memory/session-store-schema.d.ts +20 -0
- package/dist/lib/agent/memory/session-store-schema.js +41 -0
- package/dist/lib/agent/presets.d.ts +89 -1
- package/dist/lib/agent/presets.js +53 -5
- package/dist/lib/agent/tools/_shared.d.ts +7 -15
- package/dist/lib/agent/tools/_shared.js +20 -21
- package/dist/lib/agent/tools/composite.d.ts +25 -22
- package/dist/lib/agent/tools/composite.js +108 -109
- package/dist/lib/agent/tools/evolution-tools.d.ts +145 -0
- package/dist/lib/agent/tools/evolution-tools.js +161 -0
- package/dist/lib/agent/tools/index.d.ts +163 -92
- package/dist/lib/agent/tools/index.js +9 -1
- package/dist/lib/agent/tools/lifecycle.d.ts +7 -1
- package/dist/lib/agent/tools/lifecycle.js +59 -75
- package/dist/lib/cli/AiScanService.js +1 -1
- package/dist/lib/cli/KnowledgeSyncService.js +1 -1
- package/dist/lib/core/AstAnalyzer.d.ts +1 -0
- package/dist/lib/{service/bootstrap/DimensionCopyRegistry.d.ts → domain/dimension/DimensionCopy.d.ts} +2 -2
- package/dist/lib/{service/bootstrap/DimensionCopyRegistry.js → domain/dimension/DimensionCopy.js} +22 -72
- package/dist/lib/domain/dimension/DimensionRegistry.d.ts +54 -0
- package/dist/lib/domain/dimension/DimensionRegistry.js +620 -0
- package/dist/lib/domain/dimension/DimensionSop.d.ts +55 -0
- package/dist/lib/domain/dimension/DimensionSop.js +1604 -0
- package/dist/lib/domain/dimension/UnifiedDimension.d.ts +61 -0
- package/dist/lib/domain/dimension/UnifiedDimension.js +53 -0
- package/dist/lib/domain/dimension/index.d.ts +10 -0
- package/dist/lib/domain/dimension/index.js +9 -0
- package/dist/lib/domain/knowledge/FieldSpec.d.ts +1 -1
- package/dist/lib/domain/knowledge/FieldSpec.js +29 -16
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +33 -111
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +27 -6
- package/dist/lib/domain/knowledge/KnowledgeRepository.d.ts +1 -0
- package/dist/lib/domain/knowledge/KnowledgeRepository.js +3 -0
- package/dist/lib/domain/knowledge/Lifecycle.js +1 -1
- package/dist/lib/domain/knowledge/StyleGuide.d.ts +1 -1
- package/dist/lib/domain/knowledge/StyleGuide.js +1 -1
- package/dist/lib/domain/knowledge/UnifiedValidator.js +15 -0
- package/dist/lib/external/mcp/McpServer.js +4 -0
- package/dist/lib/external/mcp/handlers/TargetClassifier.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.d.ts +8 -16
- package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +10 -10
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.d.ts +7 -0
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +20 -0
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +52 -132
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +204 -17
- package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.d.ts +11 -75
- package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.js +40 -191
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.d.ts +13 -78
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +30 -52
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.d.ts +0 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.d.ts +99 -12
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +172 -161
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
- package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.d.ts +46 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.js +58 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.d.ts +25 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.js +47 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +50 -12
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +30 -10
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-text.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.d.ts +24 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.js +14 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.d.ts +14 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.js +48 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.d.ts +21 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.js +45 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/skill-generator.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.d.ts +27 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.js +44 -0
- package/dist/lib/external/mcp/handlers/bootstrap-external.d.ts +14 -10
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +39 -51
- package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +115 -82
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
- package/dist/lib/external/mcp/handlers/consolidated.js +107 -332
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +69 -1
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +226 -0
- package/dist/lib/external/mcp/handlers/knowledge.js +26 -2
- package/dist/lib/external/mcp/handlers/rescan-external.d.ts +76 -0
- package/dist/lib/external/mcp/handlers/rescan-external.js +335 -0
- package/dist/lib/external/mcp/handlers/rescan-internal.d.ts +120 -0
- package/dist/lib/external/mcp/handlers/rescan-internal.js +359 -0
- package/dist/lib/external/mcp/handlers/search.d.ts +6 -5
- package/dist/lib/external/mcp/handlers/search.js +6 -5
- package/dist/lib/external/mcp/handlers/types.d.ts +2 -1
- package/dist/lib/external/mcp/handlers/wiki-external.js +2 -2
- package/dist/lib/external/mcp/tools.d.ts +8 -18
- package/dist/lib/external/mcp/tools.js +58 -2
- package/dist/lib/http/routes/knowledge.js +122 -1
- package/dist/lib/http/routes/modules.js +25 -3
- package/dist/lib/http/routes/panorama.js +16 -4
- package/dist/lib/infrastructure/cache/CacheCoordinator.d.ts +41 -0
- package/dist/lib/infrastructure/cache/CacheCoordinator.js +105 -0
- package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.d.ts +7 -0
- package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.js +28 -0
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +1 -1
- package/dist/lib/injection/ServiceContainer.js +55 -0
- package/dist/lib/injection/ServiceMap.d.ts +8 -1
- package/dist/lib/injection/modules/KnowledgeModule.js +15 -1
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +4 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +16 -1
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.d.ts +3 -2
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +1 -1
- package/dist/lib/service/bootstrap/DeliveryVerifier.d.ts +51 -0
- package/dist/lib/service/bootstrap/DeliveryVerifier.js +163 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +5 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +20 -0
- package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +54 -0
- package/dist/lib/service/bootstrap/bootstrap-event-types.js +10 -0
- package/dist/lib/service/cleanup/CleanupService.d.ts +85 -0
- package/dist/lib/service/cleanup/CleanupService.js +324 -0
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +39 -43
- package/dist/lib/service/delivery/FileProtection.d.ts +20 -0
- package/dist/lib/service/delivery/FileProtection.js +54 -0
- package/dist/lib/service/delivery/SkillsSyncer.js +16 -21
- package/dist/lib/service/evolution/ContentPatcher.d.ts +44 -0
- package/dist/lib/service/evolution/ContentPatcher.js +310 -0
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +4 -0
- package/dist/lib/service/evolution/ProposalExecutor.js +77 -13
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +64 -0
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +458 -0
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +89 -0
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +492 -0
- package/dist/lib/service/evolution/createSupersedeProposal.d.ts +44 -0
- package/dist/lib/service/evolution/createSupersedeProposal.js +81 -0
- package/dist/lib/service/guard/ComplianceReporter.d.ts +4 -0
- package/dist/lib/service/guard/ComplianceReporter.js +51 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +5 -4
- package/dist/lib/service/knowledge/ConfidenceRouter.js +1 -1
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +11 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +44 -4
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +3 -2
- package/dist/lib/service/panorama/DimensionAnalyzer.js +15 -140
- package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
- package/dist/lib/service/search/SearchEngine.d.ts +11 -10
- package/dist/lib/service/search/SearchEngine.js +38 -36
- package/dist/lib/service/search/SearchTypes.d.ts +14 -8
- package/dist/lib/service/search/SearchTypes.js +1 -1
- package/dist/lib/service/search/tokenizer.d.ts +1 -1
- package/dist/lib/service/search/tokenizer.js +2 -2
- package/dist/lib/shared/schemas/common.d.ts +4 -4
- package/dist/lib/shared/schemas/http-requests.d.ts +12 -1
- package/dist/lib/shared/schemas/http-requests.js +8 -0
- package/dist/lib/shared/schemas/mcp-tools.d.ts +32 -2
- package/dist/lib/shared/schemas/mcp-tools.js +38 -0
- package/dist/lib/types/evolution.d.ts +135 -0
- package/dist/lib/types/evolution.js +6 -0
- package/dist/lib/types/graph-shared.d.ts +25 -0
- package/dist/lib/types/graph-shared.js +7 -0
- package/dist/lib/types/knowledge-wire.d.ts +131 -0
- package/dist/lib/types/knowledge-wire.js +7 -0
- package/dist/lib/types/project-snapshot-builder.d.ts +19 -0
- package/dist/lib/types/project-snapshot-builder.js +189 -0
- package/dist/lib/types/project-snapshot.d.ts +399 -0
- package/dist/lib/types/project-snapshot.js +17 -0
- package/dist/lib/types/search-wire.d.ts +46 -0
- package/dist/lib/types/search-wire.js +7 -0
- package/dist/lib/types/snapshot-views.d.ts +58 -0
- package/dist/lib/types/snapshot-views.js +103 -0
- package/package.json +1 -1
- package/skills/autosnippet-recipes/SKILL.md +1 -1
- package/templates/instructions/agent-static.md +2 -0
- package/templates/instructions/conventions.md +3 -1
- package/templates/recipes-setup/README.md +2 -2
- package/dashboard/dist/assets/icons-BJ2mUBi8.js +0 -1
- package/dashboard/dist/assets/index-B659K9t5.js +0 -128
- package/dashboard/dist/assets/index-NCm40PMD.css +0 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.d.ts +0 -169
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +0 -727
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.d.ts +0 -370
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +0 -821
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module shared/BootstrapEventEmitter
|
|
8
8
|
*/
|
|
9
|
+
import type { DimensionCompletePayload, ProgressPayload } from './bootstrap-event-types.js';
|
|
9
10
|
export declare class BootstrapEventEmitter {
|
|
10
11
|
#private;
|
|
11
12
|
/** @param container DI Container */
|
|
@@ -23,7 +24,7 @@ export declare class BootstrapEventEmitter {
|
|
|
23
24
|
* @param [data.skillCreated] 是否生成了 Skill
|
|
24
25
|
* @param [data.recipesBound] 关联的 recipe 数量
|
|
25
26
|
*/
|
|
26
|
-
emitDimensionComplete(dimId: string, data
|
|
27
|
+
emitDimensionComplete(dimId: string, data: DimensionCompletePayload): void;
|
|
27
28
|
/**
|
|
28
29
|
* 推送全部维度完成事件
|
|
29
30
|
*
|
|
@@ -51,6 +52,6 @@ export declare class BootstrapEventEmitter {
|
|
|
51
52
|
* @param event 事件名
|
|
52
53
|
* @param data 事件数据
|
|
53
54
|
*/
|
|
54
|
-
emitProgress(event: string, data?:
|
|
55
|
+
emitProgress(event: string, data?: ProgressPayload): void;
|
|
55
56
|
}
|
|
56
57
|
export default BootstrapEventEmitter;
|
|
@@ -39,7 +39,7 @@ export class BootstrapEventEmitter {
|
|
|
39
39
|
* @param [data.skillCreated] 是否生成了 Skill
|
|
40
40
|
* @param [data.recipesBound] 关联的 recipe 数量
|
|
41
41
|
*/
|
|
42
|
-
emitDimensionComplete(dimId, data
|
|
42
|
+
emitDimensionComplete(dimId, data) {
|
|
43
43
|
// TaskManager 标记
|
|
44
44
|
try {
|
|
45
45
|
this.#taskManager?.markTaskCompleted?.(dimId, data);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliveryVerifier — Bootstrap/Rescan 完成后交付完整性检查
|
|
3
|
+
*
|
|
4
|
+
* 验证以下交付物是否正确生成:
|
|
5
|
+
* - Channel A: autosnippet-project-rules.mdc
|
|
6
|
+
* - Channel B: autosnippet-patterns 系列文件
|
|
7
|
+
* - Channel C: .cursor/skills/ 目录
|
|
8
|
+
* - Channel F: AGENTS.md, CLAUDE.md, copilot-instructions.md
|
|
9
|
+
* - Wiki: meta.json
|
|
10
|
+
* - Skills: project 级 Skill 目录
|
|
11
|
+
* - 向量索引: asvec 文件
|
|
12
|
+
*
|
|
13
|
+
* @module service/bootstrap/DeliveryVerifier
|
|
14
|
+
*/
|
|
15
|
+
/** §10.5 交付通道标识 */
|
|
16
|
+
export type DeliveryChannel = 'channelA' | 'channelB' | 'channelC' | 'channelF' | 'wiki' | 'skills' | 'vectorIndex';
|
|
17
|
+
/** 单通道验证结果 */
|
|
18
|
+
export interface ChannelVerification {
|
|
19
|
+
generated: boolean;
|
|
20
|
+
file?: string;
|
|
21
|
+
files?: string[];
|
|
22
|
+
count?: number;
|
|
23
|
+
size?: number;
|
|
24
|
+
skillCount?: number;
|
|
25
|
+
pageCount?: number;
|
|
26
|
+
documentCount?: number;
|
|
27
|
+
agentsMd?: boolean;
|
|
28
|
+
claudeMd?: boolean;
|
|
29
|
+
copilotInstructions?: boolean;
|
|
30
|
+
rebuilt?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** 完整验证结果 */
|
|
33
|
+
export interface DeliveryVerification {
|
|
34
|
+
channelA: ChannelVerification;
|
|
35
|
+
channelB: ChannelVerification;
|
|
36
|
+
channelC: ChannelVerification;
|
|
37
|
+
channelF: ChannelVerification;
|
|
38
|
+
wiki: ChannelVerification;
|
|
39
|
+
skills: ChannelVerification;
|
|
40
|
+
vectorIndex: ChannelVerification;
|
|
41
|
+
allPassed: boolean;
|
|
42
|
+
failures: string[];
|
|
43
|
+
}
|
|
44
|
+
export declare class DeliveryVerifier {
|
|
45
|
+
#private;
|
|
46
|
+
constructor(projectRoot: string);
|
|
47
|
+
/**
|
|
48
|
+
* 验证所有交付物是否正确生成
|
|
49
|
+
*/
|
|
50
|
+
verify(): DeliveryVerification;
|
|
51
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliveryVerifier — Bootstrap/Rescan 完成后交付完整性检查
|
|
3
|
+
*
|
|
4
|
+
* 验证以下交付物是否正确生成:
|
|
5
|
+
* - Channel A: autosnippet-project-rules.mdc
|
|
6
|
+
* - Channel B: autosnippet-patterns 系列文件
|
|
7
|
+
* - Channel C: .cursor/skills/ 目录
|
|
8
|
+
* - Channel F: AGENTS.md, CLAUDE.md, copilot-instructions.md
|
|
9
|
+
* - Wiki: meta.json
|
|
10
|
+
* - Skills: project 级 Skill 目录
|
|
11
|
+
* - 向量索引: asvec 文件
|
|
12
|
+
*
|
|
13
|
+
* @module service/bootstrap/DeliveryVerifier
|
|
14
|
+
*/
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { getContextIndexPath, getProjectKnowledgePath, getProjectSkillsPath, } from '#infra/config/Paths.js';
|
|
18
|
+
// ── DeliveryVerifier ────────────────────────────────────────
|
|
19
|
+
export class DeliveryVerifier {
|
|
20
|
+
#projectRoot;
|
|
21
|
+
constructor(projectRoot) {
|
|
22
|
+
this.#projectRoot = projectRoot;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 验证所有交付物是否正确生成
|
|
26
|
+
*/
|
|
27
|
+
verify() {
|
|
28
|
+
const failures = [];
|
|
29
|
+
// Channel A: .cursor/rules/autosnippet-project-rules.mdc
|
|
30
|
+
const channelA = this.#verifyChannelA();
|
|
31
|
+
if (!channelA.generated) {
|
|
32
|
+
failures.push('Channel A: autosnippet-project-rules.mdc missing or empty');
|
|
33
|
+
}
|
|
34
|
+
// Channel B: .cursor/rules/autosnippet-patterns-*.mdc
|
|
35
|
+
const channelB = this.#verifyChannelB();
|
|
36
|
+
if (!channelB.generated) {
|
|
37
|
+
failures.push('Channel B: no autosnippet-patterns-*.mdc files found');
|
|
38
|
+
}
|
|
39
|
+
// Channel C: .cursor/skills/
|
|
40
|
+
const channelC = this.#verifyChannelC();
|
|
41
|
+
if (!channelC.generated) {
|
|
42
|
+
failures.push('Channel C: .cursor/skills/ directory missing');
|
|
43
|
+
}
|
|
44
|
+
// Channel F: AGENTS.md, CLAUDE.md, copilot-instructions.md
|
|
45
|
+
const channelF = this.#verifyChannelF();
|
|
46
|
+
if (!channelF.generated) {
|
|
47
|
+
failures.push('Channel F: agent instruction files incomplete');
|
|
48
|
+
}
|
|
49
|
+
// Wiki
|
|
50
|
+
const wiki = this.#verifyWiki();
|
|
51
|
+
// Skills
|
|
52
|
+
const skills = this.#verifySkills();
|
|
53
|
+
// Vector Index
|
|
54
|
+
const vectorIndex = this.#verifyVectorIndex();
|
|
55
|
+
return {
|
|
56
|
+
channelA,
|
|
57
|
+
channelB,
|
|
58
|
+
channelC,
|
|
59
|
+
channelF,
|
|
60
|
+
wiki,
|
|
61
|
+
skills,
|
|
62
|
+
vectorIndex,
|
|
63
|
+
allPassed: failures.length === 0,
|
|
64
|
+
failures,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// ─── 各通道验证 ───────────────────────────────────────
|
|
68
|
+
#verifyChannelA() {
|
|
69
|
+
const filePath = path.join(this.#projectRoot, '.cursor', 'rules', 'autosnippet-project-rules.mdc');
|
|
70
|
+
if (fs.existsSync(filePath)) {
|
|
71
|
+
const size = fs.statSync(filePath).size;
|
|
72
|
+
return { generated: size > 0, file: 'autosnippet-project-rules.mdc', size };
|
|
73
|
+
}
|
|
74
|
+
return { generated: false };
|
|
75
|
+
}
|
|
76
|
+
#verifyChannelB() {
|
|
77
|
+
const rulesDir = path.join(this.#projectRoot, '.cursor', 'rules');
|
|
78
|
+
if (!fs.existsSync(rulesDir)) {
|
|
79
|
+
return { generated: false, files: [], count: 0 };
|
|
80
|
+
}
|
|
81
|
+
const files = fs
|
|
82
|
+
.readdirSync(rulesDir)
|
|
83
|
+
.filter((f) => f.startsWith('autosnippet-patterns-') && f.endsWith('.mdc'));
|
|
84
|
+
return {
|
|
85
|
+
generated: files.length > 0,
|
|
86
|
+
files,
|
|
87
|
+
count: files.length,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
#verifyChannelC() {
|
|
91
|
+
const skillsDir = path.join(this.#projectRoot, '.cursor', 'skills');
|
|
92
|
+
if (!fs.existsSync(skillsDir)) {
|
|
93
|
+
return { generated: false, skillCount: 0 };
|
|
94
|
+
}
|
|
95
|
+
const count = fs.readdirSync(skillsDir).length;
|
|
96
|
+
return { generated: true, skillCount: count };
|
|
97
|
+
}
|
|
98
|
+
#verifyChannelF() {
|
|
99
|
+
const agentsMd = this.#hasAutoSnippetSection(path.join(this.#projectRoot, 'AGENTS.md'));
|
|
100
|
+
const claudeMd = this.#hasAutoSnippetSection(path.join(this.#projectRoot, 'CLAUDE.md'));
|
|
101
|
+
const copilotInstructions = this.#hasAutoSnippetSection(path.join(this.#projectRoot, '.github', 'copilot-instructions.md'));
|
|
102
|
+
return {
|
|
103
|
+
generated: agentsMd || claudeMd || copilotInstructions,
|
|
104
|
+
agentsMd,
|
|
105
|
+
claudeMd,
|
|
106
|
+
copilotInstructions,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
#verifyWiki() {
|
|
110
|
+
const kbPath = getProjectKnowledgePath(this.#projectRoot);
|
|
111
|
+
const metaPath = path.join(kbPath, 'wiki', 'meta.json');
|
|
112
|
+
if (fs.existsSync(metaPath)) {
|
|
113
|
+
try {
|
|
114
|
+
const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
|
|
115
|
+
return {
|
|
116
|
+
generated: true,
|
|
117
|
+
pageCount: meta.pages?.length || 0,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return { generated: false };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { generated: false };
|
|
125
|
+
}
|
|
126
|
+
#verifySkills() {
|
|
127
|
+
const skillsDir = getProjectSkillsPath(this.#projectRoot);
|
|
128
|
+
if (!fs.existsSync(skillsDir)) {
|
|
129
|
+
return { generated: false, skillCount: 0 };
|
|
130
|
+
}
|
|
131
|
+
const dirs = fs
|
|
132
|
+
.readdirSync(skillsDir)
|
|
133
|
+
.filter((d) => d.startsWith('project-') && fs.statSync(path.join(skillsDir, d)).isDirectory());
|
|
134
|
+
return { generated: dirs.length > 0, skillCount: dirs.length };
|
|
135
|
+
}
|
|
136
|
+
#verifyVectorIndex() {
|
|
137
|
+
const indexDir = getContextIndexPath(this.#projectRoot);
|
|
138
|
+
if (!fs.existsSync(indexDir)) {
|
|
139
|
+
return { generated: false, rebuilt: false, documentCount: 0 };
|
|
140
|
+
}
|
|
141
|
+
const asvecFiles = fs
|
|
142
|
+
.readdirSync(indexDir)
|
|
143
|
+
.filter((f) => f.endsWith('.asvec') || f.endsWith('.json'));
|
|
144
|
+
return {
|
|
145
|
+
generated: asvecFiles.length > 0,
|
|
146
|
+
rebuilt: true,
|
|
147
|
+
documentCount: asvecFiles.length,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// ─── 辅助 ───────────────────────────────────────────
|
|
151
|
+
#hasAutoSnippetSection(filePath) {
|
|
152
|
+
try {
|
|
153
|
+
if (!fs.existsSync(filePath)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
157
|
+
return content.includes('autosnippet:begin');
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* 4. refreshIndex: BM25 增量刷新
|
|
9
9
|
* 5. proposalCheck: 到期 Proposal 检查 + 自动执行/拒绝
|
|
10
10
|
* 6. metabolismCycle: 知识新陈代谢(矛盾/冗余/衰退扫描 → 新 Proposal)
|
|
11
|
+
* 7. timeoutCheck: 中间态超时兜底(evolving/decaying 超时自动恢复)
|
|
11
12
|
*/
|
|
12
13
|
interface UiStartupContext {
|
|
13
14
|
projectRoot: string;
|
|
@@ -47,6 +48,10 @@ export interface UiStartupReport {
|
|
|
47
48
|
redundancies: number;
|
|
48
49
|
decaying: number;
|
|
49
50
|
};
|
|
51
|
+
timeoutCheck?: {
|
|
52
|
+
timedOut: number;
|
|
53
|
+
checked: number;
|
|
54
|
+
};
|
|
50
55
|
durationMs: number;
|
|
51
56
|
errors: string[];
|
|
52
57
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* 4. refreshIndex: BM25 增量刷新
|
|
9
9
|
* 5. proposalCheck: 到期 Proposal 检查 + 自动执行/拒绝
|
|
10
10
|
* 6. metabolismCycle: 知识新陈代谢(矛盾/冗余/衰退扫描 → 新 Proposal)
|
|
11
|
+
* 7. timeoutCheck: 中间态超时兜底(evolving/decaying 超时自动恢复)
|
|
11
12
|
*/
|
|
12
13
|
import Logger from '../../infrastructure/logging/Logger.js';
|
|
13
14
|
const logger = Logger.getInstance();
|
|
@@ -141,6 +142,25 @@ export async function runUiStartupTasks(ctx) {
|
|
|
141
142
|
report.errors.push(msg);
|
|
142
143
|
logger.warn(`[UiStartupTasks] ${msg}`);
|
|
143
144
|
}
|
|
145
|
+
// ── Stage 7: Supervisor — 中间态超时兜底 ──
|
|
146
|
+
try {
|
|
147
|
+
if (ctx.container.services.lifecycleSupervisor) {
|
|
148
|
+
const supervisor = ctx.container.get('lifecycleSupervisor');
|
|
149
|
+
const result = supervisor.checkTimeouts();
|
|
150
|
+
report.timeoutCheck = {
|
|
151
|
+
timedOut: result.timedOut.length,
|
|
152
|
+
checked: result.checked,
|
|
153
|
+
};
|
|
154
|
+
if (result.timedOut.length > 0) {
|
|
155
|
+
logger.info(`[UiStartupTasks] Stage 7: timeout check — ${result.timedOut.length} recipes timed out (checked: ${result.checked})`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
const msg = `timeout check failed: ${err.message}`;
|
|
161
|
+
report.errors.push(msg);
|
|
162
|
+
logger.warn(`[UiStartupTasks] ${msg}`);
|
|
163
|
+
}
|
|
144
164
|
report.durationMs = Date.now() - start;
|
|
145
165
|
logger.info(`[UiStartupTasks] All tasks completed in ${report.durationMs}ms`, {
|
|
146
166
|
errors: report.errors.length,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap Event Types — 事件 payload 类型化
|
|
3
|
+
*
|
|
4
|
+
* 替代 BootstrapEventEmitter 中所有 `Record<string, unknown>` payload,
|
|
5
|
+
* 通过 discriminated union(`type` 字段)实现编译期事件校验。
|
|
6
|
+
*
|
|
7
|
+
* @module service/bootstrap/bootstrap-event-types
|
|
8
|
+
* @see docs/copilot/unified-project-snapshot-design.md §11.3 H6
|
|
9
|
+
*/
|
|
10
|
+
export interface DimensionSkippedPayload {
|
|
11
|
+
type: 'skipped';
|
|
12
|
+
reason: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DimensionRestoredPayload {
|
|
15
|
+
type: 'incremental-restored';
|
|
16
|
+
reason: string;
|
|
17
|
+
}
|
|
18
|
+
export interface DimensionCheckpointRestoredPayload {
|
|
19
|
+
type: 'checkpoint-restored';
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface DimensionErrorPayload {
|
|
23
|
+
type: 'error';
|
|
24
|
+
reason: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DimensionPipelineCompletePayload {
|
|
27
|
+
type: 'candidate' | 'skill';
|
|
28
|
+
extracted: number;
|
|
29
|
+
created: number;
|
|
30
|
+
status: string;
|
|
31
|
+
degraded: boolean;
|
|
32
|
+
durationMs: number;
|
|
33
|
+
toolCallCount: number;
|
|
34
|
+
source: string;
|
|
35
|
+
}
|
|
36
|
+
export interface DimensionSkillPayload {
|
|
37
|
+
type: 'skill';
|
|
38
|
+
skillName: string;
|
|
39
|
+
sourceCount: number;
|
|
40
|
+
}
|
|
41
|
+
export interface DimensionExternalCompletePayload {
|
|
42
|
+
type: 'skill' | 'candidate';
|
|
43
|
+
extracted: number;
|
|
44
|
+
skillCreated: boolean;
|
|
45
|
+
recipesBound: number;
|
|
46
|
+
progress: string;
|
|
47
|
+
isBootstrapComplete: boolean;
|
|
48
|
+
source: string;
|
|
49
|
+
}
|
|
50
|
+
/** Discriminated union — 通过 `type` 字段区分 */
|
|
51
|
+
export type DimensionCompletePayload = DimensionSkippedPayload | DimensionRestoredPayload | DimensionCheckpointRestoredPayload | DimensionErrorPayload | DimensionPipelineCompletePayload | DimensionSkillPayload | DimensionExternalCompletePayload;
|
|
52
|
+
export interface ProgressPayload {
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap Event Types — 事件 payload 类型化
|
|
3
|
+
*
|
|
4
|
+
* 替代 BootstrapEventEmitter 中所有 `Record<string, unknown>` payload,
|
|
5
|
+
* 通过 discriminated union(`type` 字段)实现编译期事件校验。
|
|
6
|
+
*
|
|
7
|
+
* @module service/bootstrap/bootstrap-event-types
|
|
8
|
+
* @see docs/copilot/unified-project-snapshot-design.md §11.3 H6
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CleanupService — 统一数据清理策略
|
|
3
|
+
*
|
|
4
|
+
* 提供两种清理模式:
|
|
5
|
+
* - fullReset(): 全量清理(删除一切知识/缓存/衍生数据),用于 bootstrap 冷启动
|
|
6
|
+
* - rescanClean(): Rescan 清理(保留 Recipe,清除衍生缓存),用于增量知识更新
|
|
7
|
+
* - snapshotRecipes(): 快照当前活跃 Recipe 信息
|
|
8
|
+
*
|
|
9
|
+
* 设计原则:
|
|
10
|
+
* - 配置数据 (config.json, constitution.yaml, boxspec.json) 永不清理
|
|
11
|
+
* - IDE 集成配置 (.vscode/, .cursor/, .github/) 永不清理
|
|
12
|
+
* - 交付物 (.cursor/rules/autosnippet-*) 由 R4 重建,不在此清理
|
|
13
|
+
*
|
|
14
|
+
* @module service/cleanup/CleanupService
|
|
15
|
+
*/
|
|
16
|
+
/** Logger 接口 */
|
|
17
|
+
interface CleanupLogger {
|
|
18
|
+
info(msg: string, meta?: Record<string, unknown>): void;
|
|
19
|
+
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
20
|
+
}
|
|
21
|
+
/** 清理结果 */
|
|
22
|
+
export interface CleanupResult {
|
|
23
|
+
deletedFiles: number;
|
|
24
|
+
clearedTables: string[];
|
|
25
|
+
preservedRecipes: number;
|
|
26
|
+
errors: string[];
|
|
27
|
+
}
|
|
28
|
+
/** Recipe 快照条目 */
|
|
29
|
+
export interface RecipeSnapshotEntry {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
trigger: string;
|
|
33
|
+
category: string;
|
|
34
|
+
knowledgeType: string;
|
|
35
|
+
doClause: string;
|
|
36
|
+
sourceFile?: string;
|
|
37
|
+
lifecycle: string;
|
|
38
|
+
/** Recipe 完整内容 (JSON parsed) — Evolution Agent 需要 */
|
|
39
|
+
content?: {
|
|
40
|
+
markdown?: string;
|
|
41
|
+
rationale?: string;
|
|
42
|
+
coreCode?: string;
|
|
43
|
+
};
|
|
44
|
+
/** 源文件引用列表 (JSON parsed) — Evolution Agent 需要 */
|
|
45
|
+
sourceRefs?: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Recipe 快照 */
|
|
48
|
+
export interface RecipeSnapshot {
|
|
49
|
+
count: number;
|
|
50
|
+
entries: RecipeSnapshotEntry[];
|
|
51
|
+
coverageByDimension: Record<string, number>;
|
|
52
|
+
}
|
|
53
|
+
export declare class CleanupService {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(opts: {
|
|
56
|
+
projectRoot: string;
|
|
57
|
+
db?: unknown;
|
|
58
|
+
logger?: CleanupLogger;
|
|
59
|
+
});
|
|
60
|
+
/** 更新 DB 引用(fullReset 后重连时调用) */
|
|
61
|
+
setDb(db: unknown): void;
|
|
62
|
+
/**
|
|
63
|
+
* 全量清理 — 用于 bootstrap 冷启动
|
|
64
|
+
*
|
|
65
|
+
* 清除: DB 所有数据表、candidates/、recipes/、skills/、wiki/、
|
|
66
|
+
* 向量索引、bootstrap-report.json、logs/signals/
|
|
67
|
+
* 保留: config.json、constitution.yaml、boxspec.json、IDE 配置
|
|
68
|
+
*/
|
|
69
|
+
fullReset(): Promise<CleanupResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Rescan 清理 — 保留 Recipe,清除衍生缓存
|
|
72
|
+
*
|
|
73
|
+
* 清除: 衍生 DB 表、pending/rejected/deprecated 知识条目、
|
|
74
|
+
* candidates/、skills/、wiki/、向量索引、bootstrap-report
|
|
75
|
+
* 保留: recipes/、active/published/staging/evolving 知识条目、
|
|
76
|
+
* knowledge_edges、evolution_proposals
|
|
77
|
+
*/
|
|
78
|
+
rescanClean(): Promise<CleanupResult>;
|
|
79
|
+
/**
|
|
80
|
+
* 快照当前活跃 Recipe 信息
|
|
81
|
+
* 用于 rescan 前记录保留的知识条目
|
|
82
|
+
*/
|
|
83
|
+
snapshotRecipes(): Promise<RecipeSnapshot>;
|
|
84
|
+
}
|
|
85
|
+
export {};
|