autosnippet 3.3.4 → 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/README.md +174 -83
- package/config/constitution.yaml +2 -0
- 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.d.ts +5 -1
- package/dist/lib/cli/KnowledgeSyncService.js +6 -3
- 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/domain/knowledge/values/Stats.d.ts +1 -1
- package/dist/lib/domain/knowledge/values/Stats.js +2 -2
- 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 +115 -162
- 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 +60 -3
- 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/InfraModule.js +4 -1
- package/dist/lib/injection/modules/KnowledgeModule.js +38 -1
- package/dist/lib/repository/evolution/ProposalRepository.d.ts +99 -0
- package/dist/lib/repository/evolution/ProposalRepository.js +255 -0
- 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 +22 -4
- package/dist/lib/service/bootstrap/UiStartupTasks.js +73 -5
- 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/DecayDetector.d.ts +4 -3
- package/dist/lib/service/evolution/DecayDetector.js +97 -22
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +4 -2
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +29 -2
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +66 -0
- package/dist/lib/service/evolution/ProposalExecutor.js +424 -0
- 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/StagingManager.js +5 -3
- 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/guard/GuardCrossFileChecks.js +2 -0
- package/dist/lib/service/guard/ReverseGuard.d.ts +1 -1
- package/dist/lib/service/guard/ReverseGuard.js +32 -2
- 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/knowledge/SourceRefReconciler.d.ts +2 -0
- package/dist/lib/service/knowledge/SourceRefReconciler.js +48 -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 +33 -2
- package/dist/lib/shared/schemas/mcp-tools.js +42 -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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build targetFileMap from collected source files.
|
|
3
|
+
*
|
|
4
|
+
* Previously duplicated in:
|
|
5
|
+
* - bootstrap-internal.ts (Phase 4.5)
|
|
6
|
+
* - rescan-internal.ts (Step 6)
|
|
7
|
+
*
|
|
8
|
+
* @module bootstrap/shared/target-file-map
|
|
9
|
+
*/
|
|
10
|
+
import type { TargetFile } from './handler-types.js';
|
|
11
|
+
/** Minimal file shape required by buildTargetFileMap */
|
|
12
|
+
interface SourceFile {
|
|
13
|
+
name: string;
|
|
14
|
+
relativePath: string;
|
|
15
|
+
targetName: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build a map of target → TargetFile[] from collected source files.
|
|
20
|
+
*
|
|
21
|
+
* @param allFiles - Collected source files from Phase 1
|
|
22
|
+
* @param contentMaxLines - Max lines to include in content (default: 120)
|
|
23
|
+
* @param sort - Whether to sort files by priority within each target (default: false)
|
|
24
|
+
* @returns Record<targetName, TargetFile[]>
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTargetFileMap(allFiles: SourceFile[], contentMaxLines: number, sort?: boolean): Record<string, TargetFile[]>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build targetFileMap from collected source files.
|
|
3
|
+
*
|
|
4
|
+
* Previously duplicated in:
|
|
5
|
+
* - bootstrap-internal.ts (Phase 4.5)
|
|
6
|
+
* - rescan-internal.ts (Step 6)
|
|
7
|
+
*
|
|
8
|
+
* @module bootstrap/shared/target-file-map
|
|
9
|
+
*/
|
|
10
|
+
import { inferLang } from '../../LanguageExtensions.js';
|
|
11
|
+
import { inferFilePriority } from '../../TargetClassifier.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build a map of target → TargetFile[] from collected source files.
|
|
14
|
+
*
|
|
15
|
+
* @param allFiles - Collected source files from Phase 1
|
|
16
|
+
* @param contentMaxLines - Max lines to include in content (default: 120)
|
|
17
|
+
* @param sort - Whether to sort files by priority within each target (default: false)
|
|
18
|
+
* @returns Record<targetName, TargetFile[]>
|
|
19
|
+
*/
|
|
20
|
+
export function buildTargetFileMap(allFiles, contentMaxLines, sort = false) {
|
|
21
|
+
const targetFileMap = {};
|
|
22
|
+
for (const f of allFiles) {
|
|
23
|
+
if (!targetFileMap[f.targetName]) {
|
|
24
|
+
targetFileMap[f.targetName] = [];
|
|
25
|
+
}
|
|
26
|
+
const lines = f.content.split('\n');
|
|
27
|
+
targetFileMap[f.targetName].push({
|
|
28
|
+
name: f.name,
|
|
29
|
+
relativePath: f.relativePath,
|
|
30
|
+
language: inferLang(f.name),
|
|
31
|
+
totalLines: lines.length,
|
|
32
|
+
priority: inferFilePriority(f.name),
|
|
33
|
+
content: lines.slice(0, contentMaxLines).join('\n'),
|
|
34
|
+
truncated: lines.length > contentMaxLines,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (sort) {
|
|
38
|
+
const prio = { high: 0, medium: 1, low: 2 };
|
|
39
|
+
for (const tName of Object.keys(targetFileMap)) {
|
|
40
|
+
targetFileMap[tName].sort((a, b) => (prio[a.priority] ?? 1) - (prio[b.priority] ?? 1));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return targetFileMap;
|
|
44
|
+
}
|
|
@@ -20,19 +20,11 @@ interface McpContext {
|
|
|
20
20
|
container: ServiceContainer;
|
|
21
21
|
logger: {
|
|
22
22
|
info(msg: string, meta?: Record<string, unknown>): void;
|
|
23
|
+
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
23
24
|
};
|
|
24
25
|
startedAt?: number;
|
|
25
26
|
[key: string]: unknown;
|
|
26
27
|
}
|
|
27
|
-
/** Shape of the mission briefing returned by buildMissionBriefing */
|
|
28
|
-
interface MissionBriefingResult {
|
|
29
|
-
meta?: {
|
|
30
|
-
warnings?: string[];
|
|
31
|
-
responseSizeKB?: number;
|
|
32
|
-
[key: string]: unknown;
|
|
33
|
-
};
|
|
34
|
-
[key: string]: unknown;
|
|
35
|
-
}
|
|
36
28
|
/**
|
|
37
29
|
* bootstrapExternal — 外部 Agent 驱动的一键冷启动
|
|
38
30
|
*
|
|
@@ -59,7 +51,19 @@ export declare function bootstrapExternal(ctx: McpContext): Promise<{
|
|
|
59
51
|
success: boolean;
|
|
60
52
|
errorCode: string | null;
|
|
61
53
|
message: string;
|
|
62
|
-
data:
|
|
54
|
+
data: {
|
|
55
|
+
meta?: {
|
|
56
|
+
warnings?: string[];
|
|
57
|
+
responseSizeKB?: number;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
cleanup: {
|
|
61
|
+
deletedRecipes: number;
|
|
62
|
+
clearedTables: number;
|
|
63
|
+
dbCleared: boolean;
|
|
64
|
+
errors: string[];
|
|
65
|
+
};
|
|
66
|
+
} | null;
|
|
63
67
|
meta: {
|
|
64
68
|
source?: string | undefined;
|
|
65
69
|
responseTimeMs?: number | undefined;
|
|
@@ -15,42 +15,15 @@
|
|
|
15
15
|
* @module handlers/bootstrap-external
|
|
16
16
|
*/
|
|
17
17
|
import path from 'node:path';
|
|
18
|
+
import { CleanupService } from '#service/cleanup/CleanupService.js';
|
|
18
19
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
20
|
+
import { buildProjectSnapshot } from '#types/project-snapshot-builder.js';
|
|
21
|
+
import { toSessionCache } from '#types/snapshot-views.js';
|
|
19
22
|
import { envelope } from '../envelope.js';
|
|
20
|
-
import { BootstrapSessionManager } from './bootstrap/BootstrapSession.js';
|
|
21
23
|
import { buildMissionBriefing } from './bootstrap/MissionBriefingBuilder.js';
|
|
22
24
|
import { runAllPhases } from './bootstrap/shared/bootstrap-phases.js';
|
|
25
|
+
import { getOrCreateSessionManager } from './bootstrap/shared/session-helpers.js';
|
|
23
26
|
import { buildLanguageExtension } from './LanguageExtensions.js';
|
|
24
|
-
// ── 进程级 Session 管理器 ─────────────────────────────────
|
|
25
|
-
let _sessionManager = null;
|
|
26
|
-
/**
|
|
27
|
-
* 获取或创建 BootstrapSessionManager
|
|
28
|
-
* @param container ServiceContainer
|
|
29
|
-
*/
|
|
30
|
-
function getSessionManager(container) {
|
|
31
|
-
// 优先使用容器注册的 (如果已注册)
|
|
32
|
-
try {
|
|
33
|
-
const mgr = container.get('bootstrapSessionManager');
|
|
34
|
-
if (mgr) {
|
|
35
|
-
return mgr;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
/* not registered yet */
|
|
40
|
-
}
|
|
41
|
-
// 降级为模块级单例
|
|
42
|
-
if (!_sessionManager) {
|
|
43
|
-
_sessionManager = new BootstrapSessionManager();
|
|
44
|
-
}
|
|
45
|
-
// 注册到容器,让 submitKnowledgeBatch / consolidated 等 handler 也能访问
|
|
46
|
-
try {
|
|
47
|
-
container.register('bootstrapSessionManager', () => _sessionManager);
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
/* already registered or container doesn't support register */
|
|
51
|
-
}
|
|
52
|
-
return _sessionManager;
|
|
53
|
-
}
|
|
54
27
|
// ── 主入口 ─────────────────────────────────────────────────────
|
|
55
28
|
/**
|
|
56
29
|
* bootstrapExternal — 外部 Agent 驱动的一键冷启动
|
|
@@ -65,7 +38,17 @@ export async function bootstrapExternal(ctx) {
|
|
|
65
38
|
const t0 = Date.now();
|
|
66
39
|
const projectRoot = resolveProjectRoot(ctx.container);
|
|
67
40
|
// ═══════════════════════════════════════════════════════════
|
|
68
|
-
//
|
|
41
|
+
// Step 1: 全量清理 (CleanupService.fullReset)
|
|
42
|
+
// ═══════════════════════════════════════════════════════════
|
|
43
|
+
const db = ctx.container.get('database');
|
|
44
|
+
const cleanupService = new CleanupService({
|
|
45
|
+
projectRoot,
|
|
46
|
+
db,
|
|
47
|
+
logger: ctx.logger,
|
|
48
|
+
});
|
|
49
|
+
const cleanupResult = await cleanupService.fullReset();
|
|
50
|
+
// ═══════════════════════════════════════════════════════════
|
|
51
|
+
// Phase 1-4: 共享数据收集管线(永远全量,无增量检测)
|
|
69
52
|
// ═══════════════════════════════════════════════════════════
|
|
70
53
|
const phaseResults = await runAllPhases(projectRoot, ctx, {
|
|
71
54
|
maxFiles: 500,
|
|
@@ -74,7 +57,7 @@ export async function bootstrapExternal(ctx) {
|
|
|
74
57
|
summaryPrefix: 'Bootstrap-external scan',
|
|
75
58
|
clearOldData: true,
|
|
76
59
|
generateReport: true,
|
|
77
|
-
incremental:
|
|
60
|
+
incremental: false,
|
|
78
61
|
});
|
|
79
62
|
// 空项目 fast-path
|
|
80
63
|
if (phaseResults.isEmpty) {
|
|
@@ -84,12 +67,19 @@ export async function bootstrapExternal(ctx) {
|
|
|
84
67
|
meta: { tool: 'autosnippet_bootstrap', responseTimeMs: Date.now() - t0 },
|
|
85
68
|
});
|
|
86
69
|
}
|
|
87
|
-
const { allFiles, primaryLang, depGraphData, langStats, astProjectSummary, codeEntityResult, callGraphResult, guardAudit, activeDimensions: dimensions, targetsSummary,
|
|
70
|
+
const { allFiles, primaryLang, depGraphData, langStats, astProjectSummary, codeEntityResult, callGraphResult, guardAudit, activeDimensions: dimensions, targetsSummary, localPackageModules, langProfile, } = phaseResults;
|
|
71
|
+
// ── Build immutable ProjectSnapshot ──
|
|
72
|
+
const snapshot = buildProjectSnapshot({
|
|
73
|
+
projectRoot,
|
|
74
|
+
sourceTag: 'bootstrap-external',
|
|
75
|
+
...phaseResults,
|
|
76
|
+
report: phaseResults.report,
|
|
77
|
+
});
|
|
88
78
|
// ═══════════════════════════════════════════════════════════
|
|
89
79
|
// Phase 4: 构建 Mission Briefing
|
|
90
80
|
// ═══════════════════════════════════════════════════════════
|
|
91
81
|
// 创建 BootstrapSession
|
|
92
|
-
const sessionManager =
|
|
82
|
+
const sessionManager = getOrCreateSessionManager(ctx.container);
|
|
93
83
|
const session = sessionManager.createSession({
|
|
94
84
|
projectRoot,
|
|
95
85
|
dimensions,
|
|
@@ -101,17 +91,7 @@ export async function bootstrapExternal(ctx) {
|
|
|
101
91
|
},
|
|
102
92
|
});
|
|
103
93
|
// 缓存 Phase 结果供 wiki_plan 复用
|
|
104
|
-
session.
|
|
105
|
-
allFiles,
|
|
106
|
-
astProjectSummary,
|
|
107
|
-
codeEntityResult,
|
|
108
|
-
callGraphResult,
|
|
109
|
-
depGraphData,
|
|
110
|
-
guardAudit,
|
|
111
|
-
langStats,
|
|
112
|
-
primaryLang,
|
|
113
|
-
targetsSummary,
|
|
114
|
-
});
|
|
94
|
+
session.setSnapshotCache(toSessionCache(snapshot));
|
|
115
95
|
// 构建 projectMeta
|
|
116
96
|
const projectMeta = {
|
|
117
97
|
name: path.basename(projectRoot),
|
|
@@ -119,7 +99,7 @@ export async function bootstrapExternal(ctx) {
|
|
|
119
99
|
secondaryLanguages: langProfile.secondary || [],
|
|
120
100
|
isMultiLang: langProfile.isMultiLang || false,
|
|
121
101
|
fileCount: allFiles.length,
|
|
122
|
-
projectType:
|
|
102
|
+
projectType: snapshot.discoverer.id,
|
|
123
103
|
projectRoot,
|
|
124
104
|
};
|
|
125
105
|
// 构建 Mission Briefing
|
|
@@ -134,9 +114,9 @@ export async function bootstrapExternal(ctx) {
|
|
|
134
114
|
activeDimensions: dimensions,
|
|
135
115
|
session,
|
|
136
116
|
languageExtension: buildLanguageExtension(primaryLang), // §7.1
|
|
137
|
-
incrementalPlan,
|
|
138
117
|
languageStats: langStats,
|
|
139
|
-
panoramaResult:
|
|
118
|
+
panoramaResult: snapshot.panorama, // §M1: Phase 1.8 全景数据
|
|
119
|
+
localPackageModules, // 本地子包模块信息
|
|
140
120
|
});
|
|
141
121
|
// 附加 warnings
|
|
142
122
|
if (phaseResults.warnings.length > 0) {
|
|
@@ -147,7 +127,15 @@ export async function bootstrapExternal(ctx) {
|
|
|
147
127
|
`${briefing.meta?.responseSizeKB || '?'}KB — session ${session.id}`);
|
|
148
128
|
return envelope({
|
|
149
129
|
success: true,
|
|
150
|
-
data:
|
|
130
|
+
data: {
|
|
131
|
+
cleanup: {
|
|
132
|
+
deletedRecipes: cleanupResult.deletedFiles,
|
|
133
|
+
clearedTables: cleanupResult.clearedTables.length,
|
|
134
|
+
dbCleared: true,
|
|
135
|
+
errors: cleanupResult.errors,
|
|
136
|
+
},
|
|
137
|
+
...briefing,
|
|
138
|
+
},
|
|
151
139
|
message: `⚠️ Bootstrap 仅完成第一步(项目扫描),你必须继续完成全部 ${dimensions.length} 个维度的分析。` +
|
|
152
140
|
`请立即按 executionPlan.tiers 的顺序,对每个维度执行:` +
|
|
153
141
|
`(1) 用你的代码阅读能力分析该维度相关文件 → ` +
|
|
@@ -164,7 +152,7 @@ export async function bootstrapExternal(ctx) {
|
|
|
164
152
|
* 仍然返回该 session(支持新 bootstrap 创建后旧 session 的 dimension_complete 继续工作)。
|
|
165
153
|
*/
|
|
166
154
|
export function getActiveSession(container, sessionId) {
|
|
167
|
-
const mgr =
|
|
155
|
+
const mgr = getOrCreateSessionManager(container);
|
|
168
156
|
const session = mgr.getSession(sessionId);
|
|
169
157
|
if (session) {
|
|
170
158
|
return session;
|
|
@@ -46,15 +46,23 @@
|
|
|
46
46
|
* bootstrap/dimensions.js ← 7 维度知识提取器(内部 Agent 专用)
|
|
47
47
|
* bootstrap/projectSkills.js ← Phase 5.5 Project Skill 生成(内部 Agent 专用)
|
|
48
48
|
*/
|
|
49
|
+
import path from 'node:path';
|
|
49
50
|
import { getInternalAgentRequiredFields } from '#domain/knowledge/FieldSpec.js';
|
|
51
|
+
import { CleanupService } from '#service/cleanup/CleanupService.js';
|
|
50
52
|
import { resolveProjectRoot } from '#shared/resolveProjectRoot.js';
|
|
53
|
+
import { buildProjectSnapshot } from '#types/project-snapshot-builder.js';
|
|
54
|
+
import { toSessionCache } from '#types/snapshot-views.js';
|
|
51
55
|
import { envelope } from '../envelope.js';
|
|
52
56
|
import { fillDimensionsV3 } from './bootstrap/pipeline/orchestrator.js';
|
|
53
57
|
import { bootstrapRefine } from './bootstrap/refine.js';
|
|
58
|
+
import { buildTaskDefs, dispatchPipelineFill, startTaskManagerSession, } from './bootstrap/shared/async-fill-helpers.js';
|
|
54
59
|
import { runAllPhases } from './bootstrap/shared/bootstrap-phases.js';
|
|
55
60
|
import { buildInternalNextSteps } from './bootstrap/shared/dimension-text.js';
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
61
|
+
import { summarizePanorama } from './bootstrap/shared/panorama-utils.js';
|
|
62
|
+
import { getOrCreateSessionManager } from './bootstrap/shared/session-helpers.js';
|
|
63
|
+
import { buildTargetFileMap } from './bootstrap/shared/target-file-map.js';
|
|
64
|
+
import { buildLanguageExtension } from './LanguageExtensions.js';
|
|
65
|
+
import { inferTargetRole } from './TargetClassifier.js';
|
|
58
66
|
export { bootstrapRefine };
|
|
59
67
|
/**
|
|
60
68
|
* bootstrapKnowledge — 一键初始化知识库 (Skill-aware)
|
|
@@ -81,6 +89,22 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
81
89
|
const contentMaxLines = args.contentMaxLines || 120;
|
|
82
90
|
const skipAsyncFill = args.skipAsyncFill || false;
|
|
83
91
|
// ═══════════════════════════════════════════════════════════
|
|
92
|
+
// Step 0: 全量清理 (与 bootstrap-external 对齐)
|
|
93
|
+
// 冷启动需要干净的初始状态:清除 DB + 文件系统缓存
|
|
94
|
+
// ═══════════════════════════════════════════════════════════
|
|
95
|
+
const db = ctx.container.get('database');
|
|
96
|
+
const cleanupService = new CleanupService({
|
|
97
|
+
projectRoot,
|
|
98
|
+
db,
|
|
99
|
+
logger: ctx.logger,
|
|
100
|
+
});
|
|
101
|
+
const cleanupResult = await cleanupService.fullReset();
|
|
102
|
+
ctx.logger.info('[Bootstrap-Internal] fullReset complete', {
|
|
103
|
+
tables: cleanupResult.clearedTables.length,
|
|
104
|
+
files: cleanupResult.deletedFiles,
|
|
105
|
+
errors: cleanupResult.errors.length,
|
|
106
|
+
});
|
|
107
|
+
// ═══════════════════════════════════════════════════════════
|
|
84
108
|
// Phase 1-4: 共享管线(文件收集→AST→依赖→Guard→维度解析)
|
|
85
109
|
// ═══════════════════════════════════════════════════════════
|
|
86
110
|
const phaseResults = await runAllPhases(projectRoot, ctx, {
|
|
@@ -99,7 +123,20 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
99
123
|
meta: { tool: 'autosnippet_bootstrap', responseTimeMs: Date.now() - t0 },
|
|
100
124
|
});
|
|
101
125
|
}
|
|
102
|
-
|
|
126
|
+
// ═══════════════════════════════════════════════════════════
|
|
127
|
+
// 构建 ProjectSnapshot — 统一数据来源
|
|
128
|
+
// ═══════════════════════════════════════════════════════════
|
|
129
|
+
const snapshot = buildProjectSnapshot({
|
|
130
|
+
projectRoot,
|
|
131
|
+
sourceTag: 'bootstrap',
|
|
132
|
+
...phaseResults,
|
|
133
|
+
report: phaseResults.report,
|
|
134
|
+
});
|
|
135
|
+
// 从 snapshot 派生局部别名(兼容既有 responseData 构建逻辑)
|
|
136
|
+
const { allFiles, allTargets, discoverer, ast: astProjectSummary, astContext, dependencyGraph: depGraphData, depEdgesWritten, guardAudit, activeDimensions, enhancementPackInfo, enhancementPatterns, enhancementGuardRules, language, targetsSummary, incrementalPlan, codeEntityGraph: codeEntityResult, callGraph: callGraphResult, localPackageModules, warnings: phaseWarnings, phaseReport, } = snapshot;
|
|
137
|
+
const langStats = language.stats;
|
|
138
|
+
const primaryLang = language.primaryLang;
|
|
139
|
+
const langProfile = language;
|
|
103
140
|
// 构建兼容的 report 对象(保持原有 API 格式)
|
|
104
141
|
const report = {
|
|
105
142
|
phases: {
|
|
@@ -141,8 +178,10 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
141
178
|
},
|
|
142
179
|
callGraph: phaseReport?.phases?.callGraph
|
|
143
180
|
? {
|
|
144
|
-
entities: phaseReport.phases.callGraph.result
|
|
145
|
-
|
|
181
|
+
entities: phaseReport.phases.callGraph.result
|
|
182
|
+
?.entitiesUpserted || 0,
|
|
183
|
+
edges: phaseReport.phases.callGraph.result
|
|
184
|
+
?.edgesCreated || 0,
|
|
146
185
|
ms: phaseReport.phases.callGraph.ms || 0,
|
|
147
186
|
}
|
|
148
187
|
: { entities: 0, edges: 0, ms: 0 },
|
|
@@ -169,32 +208,22 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
169
208
|
// ═══════════════════════════════════════════════════════════
|
|
170
209
|
// Phase 4.5: 构建响应 — filesByTarget + analysisFramework
|
|
171
210
|
// ═══════════════════════════════════════════════════════════
|
|
172
|
-
const targetFileMap =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
name: f.name,
|
|
180
|
-
relativePath: f.relativePath,
|
|
181
|
-
language: inferLang(f.name),
|
|
182
|
-
totalLines: lines.length,
|
|
183
|
-
priority: inferFilePriority(f.name),
|
|
184
|
-
// content 仅保留在内存中供 Phase 5 异步 pipeline 使用
|
|
185
|
-
// MCP 响应不包含文件内容(避免 1MB+ 响应导致 Cursor 无法处理)
|
|
186
|
-
content: lines.slice(0, contentMaxLines).join('\n'),
|
|
187
|
-
truncated: lines.length > contentMaxLines,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
// 每个 target 内按 priority 排序
|
|
191
|
-
for (const tName of Object.keys(targetFileMap)) {
|
|
192
|
-
const prio = { high: 0, medium: 1, low: 2 };
|
|
193
|
-
targetFileMap[tName].sort((a, b) => (prio[a.priority] || 1) -
|
|
194
|
-
(prio[b.priority] || 1));
|
|
211
|
+
const targetFileMap = buildTargetFileMap(allFiles, contentMaxLines, true);
|
|
212
|
+
let dimensions = activeDimensions;
|
|
213
|
+
// 如果调用方指定了维度子集,只保留匹配的维度
|
|
214
|
+
if (args.dimensions?.length) {
|
|
215
|
+
const requestedIds = new Set(args.dimensions);
|
|
216
|
+
dimensions = dimensions.filter((d) => requestedIds.has(d.id));
|
|
217
|
+
ctx.logger.info(`[Bootstrap] Dimension filter: ${dimensions.map((d) => d.id).join(', ')}`);
|
|
195
218
|
}
|
|
196
|
-
const dimensions = activeDimensions;
|
|
197
219
|
const responseData = {
|
|
220
|
+
// Step 0 清理信息(与 bootstrap-external 对齐)
|
|
221
|
+
cleanup: {
|
|
222
|
+
deletedRecipes: cleanupResult.deletedFiles,
|
|
223
|
+
clearedTables: cleanupResult.clearedTables.length,
|
|
224
|
+
dbCleared: true,
|
|
225
|
+
errors: cleanupResult.errors,
|
|
226
|
+
},
|
|
198
227
|
report,
|
|
199
228
|
targets: targetsSummary ||
|
|
200
229
|
allTargets.map((t) => {
|
|
@@ -269,9 +298,9 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
269
298
|
astContext: astContext || null,
|
|
270
299
|
astSummary: astProjectSummary
|
|
271
300
|
? {
|
|
272
|
-
classes: astProjectSummary.classes
|
|
273
|
-
protocols: astProjectSummary.protocols
|
|
274
|
-
categories: astProjectSummary.categories
|
|
301
|
+
classes: astProjectSummary.classes?.length || 0,
|
|
302
|
+
protocols: astProjectSummary.protocols?.length || 0,
|
|
303
|
+
categories: astProjectSummary.categories?.length || 0,
|
|
275
304
|
patterns: Object.keys(astProjectSummary.patternStats || {}),
|
|
276
305
|
metrics: astProjectSummary.projectMetrics
|
|
277
306
|
? {
|
|
@@ -292,10 +321,55 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
292
321
|
guardRules: enhancementGuardRules.length,
|
|
293
322
|
}
|
|
294
323
|
: null,
|
|
324
|
+
// 代码实体图谱摘要(与 bootstrap-external 对齐)
|
|
325
|
+
codeEntityGraph: codeEntityResult
|
|
326
|
+
? {
|
|
327
|
+
totalEntities: codeEntityResult.entityCount || 0,
|
|
328
|
+
totalEdges: codeEntityResult.edgeCount || 0,
|
|
329
|
+
}
|
|
330
|
+
: null,
|
|
331
|
+
// 调用图谱摘要(与 bootstrap-external 对齐)
|
|
332
|
+
callGraph: callGraphResult
|
|
333
|
+
? {
|
|
334
|
+
entitiesUpserted: callGraphResult.entitiesUpserted || 0,
|
|
335
|
+
edgesCreated: callGraphResult.edgesCreated || 0,
|
|
336
|
+
}
|
|
337
|
+
: null,
|
|
338
|
+
// 全景分析摘要(与 bootstrap-external 对齐)
|
|
339
|
+
panorama: snapshot.panorama ? summarizePanorama(snapshot.panorama) : null,
|
|
340
|
+
// 本地子包模块(与 bootstrap-external mustCoverModules 对齐)
|
|
341
|
+
localPackageModules: localPackageModules.length > 0 ? localPackageModules : null,
|
|
342
|
+
// Phase 1-4 警告(与 bootstrap-external 对齐)
|
|
343
|
+
warnings: phaseWarnings.length > 0 ? phaseWarnings : undefined,
|
|
295
344
|
// 引导 Agent 下一步操作(共享文本层)
|
|
296
345
|
nextSteps: buildInternalNextSteps(dimensions),
|
|
297
346
|
};
|
|
298
347
|
// ═══════════════════════════════════════════════════════════
|
|
348
|
+
// Phase 4.6: BootstrapSessionManager — 缓存 Phase 结果供 wiki_plan 复用
|
|
349
|
+
// (与 bootstrap-external 对齐)
|
|
350
|
+
// ═══════════════════════════════════════════════════════════
|
|
351
|
+
try {
|
|
352
|
+
const sessionManager = getOrCreateSessionManager(ctx.container);
|
|
353
|
+
const bsSession = sessionManager.createSession({
|
|
354
|
+
projectRoot,
|
|
355
|
+
dimensions: dimensions.map((d) => ({
|
|
356
|
+
...d,
|
|
357
|
+
skillMeta: d.skillMeta ?? undefined,
|
|
358
|
+
})),
|
|
359
|
+
projectContext: {
|
|
360
|
+
projectName: path.basename(projectRoot),
|
|
361
|
+
primaryLang,
|
|
362
|
+
fileCount: allFiles.length,
|
|
363
|
+
modules: depGraphData?.nodes?.length || 0,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
bsSession.setSnapshotCache(toSessionCache(snapshot));
|
|
367
|
+
responseData.sessionId = bsSession.id;
|
|
368
|
+
}
|
|
369
|
+
catch (e) {
|
|
370
|
+
ctx.logger.warn(`[Bootstrap-Internal] BootstrapSessionManager setup failed (non-blocking): ${e instanceof Error ? e.message : String(e)}`);
|
|
371
|
+
}
|
|
372
|
+
// ═══════════════════════════════════════════════════════════
|
|
299
373
|
// Phase 5: 创建异步任务 — 骨架先返回,内容后填充
|
|
300
374
|
//
|
|
301
375
|
// 策略变更(v5):
|
|
@@ -304,65 +378,24 @@ export async function bootstrapKnowledge(ctx, args) {
|
|
|
304
378
|
// 前端通过 Socket.io 接收进度更新,卡片 loading → 完成
|
|
305
379
|
// ═══════════════════════════════════════════════════════════
|
|
306
380
|
// 构建任务定义列表
|
|
307
|
-
const taskDefs = dimensions
|
|
308
|
-
id: dim.id,
|
|
309
|
-
meta: {
|
|
310
|
-
type: dim.skillWorthy ? 'skill' : 'candidate',
|
|
311
|
-
dimId: dim.id,
|
|
312
|
-
label: dim.label,
|
|
313
|
-
skillWorthy: !!dim.skillWorthy,
|
|
314
|
-
skillMeta: dim.skillMeta || null,
|
|
315
|
-
},
|
|
316
|
-
}));
|
|
381
|
+
const taskDefs = buildTaskDefs(dimensions);
|
|
317
382
|
// 启动 BootstrapTaskManager 会话(通过正式 DI 获取单例)
|
|
318
|
-
|
|
319
|
-
try {
|
|
320
|
-
const taskManager = ctx.container.get('bootstrapTaskManager');
|
|
321
|
-
bootstrapSession = taskManager.startSession(taskDefs);
|
|
322
|
-
}
|
|
323
|
-
catch (e) {
|
|
324
|
-
ctx.logger.warn(`[Bootstrap] BootstrapTaskManager init failed (graceful degradation): ${e instanceof Error ? e.message : String(e)}`);
|
|
325
|
-
}
|
|
383
|
+
const bootstrapSession = startTaskManagerSession(ctx.container, taskDefs, ctx.logger, 'Bootstrap');
|
|
326
384
|
// 立即构建骨架响应
|
|
327
385
|
responseData.bootstrapSession = bootstrapSession ? bootstrapSession.toJSON() : null;
|
|
328
386
|
responseData.bootstrapCandidates = { created: 0, failed: 0, errors: [], status: 'filling' };
|
|
329
387
|
responseData.autoSkills = { created: 0, failed: 0, skills: [], errors: [], status: 'filling' };
|
|
330
388
|
responseData.message = `Bootstrap 骨架已创建: ${allFiles.length} files, ${allTargets.length} targets, ${taskDefs.length} 个维度任务已排队,正在后台逐一填充...`;
|
|
331
389
|
// ── 异步后台填充(fire-and-forget)──
|
|
332
|
-
const fillContext = {
|
|
333
|
-
ctx,
|
|
334
|
-
dimensions,
|
|
335
|
-
allFiles,
|
|
336
|
-
targetFileMap,
|
|
337
|
-
depGraphData,
|
|
338
|
-
guardAudit,
|
|
339
|
-
langStats,
|
|
340
|
-
primaryLang,
|
|
341
|
-
astProjectSummary,
|
|
342
|
-
taskManager: (() => {
|
|
343
|
-
try {
|
|
344
|
-
return ctx.container.get('bootstrapTaskManager');
|
|
345
|
-
}
|
|
346
|
-
catch {
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
})(),
|
|
350
|
-
sessionId: bootstrapSession?.id || null,
|
|
351
|
-
projectRoot,
|
|
352
|
-
// v5.0: 增量 Bootstrap 计划
|
|
353
|
-
incrementalPlan,
|
|
354
|
-
// M1: Phase 1.8 全景数据 → strategyContext.panorama
|
|
355
|
-
panoramaResult: phaseResults.panoramaResult,
|
|
356
|
-
};
|
|
357
|
-
// 使用 setImmediate 避免阻塞 HTTP 响应
|
|
358
390
|
// skipAsyncFill: CLI 非 --wait 模式跳过异步填充,避免进程退出后 DB 断连
|
|
359
391
|
if (!skipAsyncFill) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
392
|
+
dispatchPipelineFill({
|
|
393
|
+
snapshot,
|
|
394
|
+
ctx: ctx,
|
|
395
|
+
bootstrapSession,
|
|
396
|
+
targetFileMap,
|
|
397
|
+
projectRoot,
|
|
398
|
+
}, dimensions, fillDimensionsV3, 'Bootstrap');
|
|
366
399
|
}
|
|
367
400
|
else {
|
|
368
401
|
ctx.logger.info(`[Bootstrap] Async fill skipped (skipAsyncFill=true)`);
|
|
@@ -526,10 +526,10 @@ export declare function consolidatedSkill(ctx: McpContext, args: ConsolidatedSki
|
|
|
526
526
|
* 统一提交管线:单条与批量走同一代码路径。
|
|
527
527
|
*
|
|
528
528
|
* 流程:
|
|
529
|
-
* 1.
|
|
530
|
-
* 2.
|
|
531
|
-
* 3.
|
|
532
|
-
* 4.
|
|
529
|
+
* 1. 限流
|
|
530
|
+
* 2. V3 字段增强(MCP 特有预处理)
|
|
531
|
+
* 3. RecipeProductionGateway.create() — 统一管道
|
|
532
|
+
* 4. Bootstrap session 追踪
|
|
533
533
|
* 5. 返回统一结果
|
|
534
534
|
*
|
|
535
535
|
* 设计原则:
|