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.
Files changed (221) hide show
  1. package/README.md +174 -83
  2. package/config/constitution.yaml +2 -0
  3. package/dashboard/dist/assets/icons-D1aVZYFW.js +1 -0
  4. package/dashboard/dist/assets/index-CxHOu8Hd.css +1 -0
  5. package/dashboard/dist/assets/index-DDdAOpYT.js +128 -0
  6. package/dashboard/dist/index.html +3 -3
  7. package/dist/bin/api-server.js +1 -0
  8. package/dist/bin/cli.d.ts +1 -0
  9. package/dist/bin/cli.js +136 -9
  10. package/dist/lib/agent/AgentFactory.d.ts +0 -17
  11. package/dist/lib/agent/AgentFactory.js +1 -25
  12. package/dist/lib/agent/capabilities.d.ts +11 -0
  13. package/dist/lib/agent/capabilities.js +29 -5
  14. package/dist/lib/agent/context/ExplorationTracker.js +10 -1
  15. package/dist/lib/agent/context/exploration/ExplorationStrategies.d.ts +2 -0
  16. package/dist/lib/agent/context/exploration/ExplorationStrategies.js +2 -2
  17. package/dist/lib/agent/domain/insight-analyst.d.ts +47 -3
  18. package/dist/lib/agent/domain/insight-analyst.js +111 -11
  19. package/dist/lib/agent/domain/insight-evolver.d.ts +69 -0
  20. package/dist/lib/agent/domain/insight-evolver.js +230 -0
  21. package/dist/lib/agent/domain/insight-gate.d.ts +42 -0
  22. package/dist/lib/agent/domain/insight-gate.js +41 -0
  23. package/dist/lib/agent/domain/insight-producer.d.ts +27 -2
  24. package/dist/lib/agent/domain/insight-producer.js +60 -5
  25. package/dist/lib/agent/domain/scan-prompts.js +10 -7
  26. package/dist/lib/agent/memory/ActiveContext.d.ts +2 -28
  27. package/dist/lib/agent/memory/MemoryCoordinator.d.ts +2 -2
  28. package/dist/lib/agent/memory/SessionStore.d.ts +6 -12
  29. package/dist/lib/agent/memory/SessionStore.js +9 -15
  30. package/dist/lib/agent/memory/memory-flush-contract.d.ts +49 -0
  31. package/dist/lib/agent/memory/memory-flush-contract.js +16 -0
  32. package/dist/lib/agent/memory/session-store-schema.d.ts +20 -0
  33. package/dist/lib/agent/memory/session-store-schema.js +41 -0
  34. package/dist/lib/agent/presets.d.ts +89 -1
  35. package/dist/lib/agent/presets.js +53 -5
  36. package/dist/lib/agent/tools/_shared.d.ts +7 -15
  37. package/dist/lib/agent/tools/_shared.js +20 -21
  38. package/dist/lib/agent/tools/composite.d.ts +25 -22
  39. package/dist/lib/agent/tools/composite.js +108 -109
  40. package/dist/lib/agent/tools/evolution-tools.d.ts +145 -0
  41. package/dist/lib/agent/tools/evolution-tools.js +161 -0
  42. package/dist/lib/agent/tools/index.d.ts +163 -92
  43. package/dist/lib/agent/tools/index.js +9 -1
  44. package/dist/lib/agent/tools/lifecycle.d.ts +7 -1
  45. package/dist/lib/agent/tools/lifecycle.js +59 -75
  46. package/dist/lib/cli/AiScanService.js +1 -1
  47. package/dist/lib/cli/KnowledgeSyncService.d.ts +5 -1
  48. package/dist/lib/cli/KnowledgeSyncService.js +6 -3
  49. package/dist/lib/core/AstAnalyzer.d.ts +1 -0
  50. package/dist/lib/{service/bootstrap/DimensionCopyRegistry.d.ts → domain/dimension/DimensionCopy.d.ts} +2 -2
  51. package/dist/lib/{service/bootstrap/DimensionCopyRegistry.js → domain/dimension/DimensionCopy.js} +22 -72
  52. package/dist/lib/domain/dimension/DimensionRegistry.d.ts +54 -0
  53. package/dist/lib/domain/dimension/DimensionRegistry.js +620 -0
  54. package/dist/lib/domain/dimension/DimensionSop.d.ts +55 -0
  55. package/dist/lib/domain/dimension/DimensionSop.js +1604 -0
  56. package/dist/lib/domain/dimension/UnifiedDimension.d.ts +61 -0
  57. package/dist/lib/domain/dimension/UnifiedDimension.js +53 -0
  58. package/dist/lib/domain/dimension/index.d.ts +10 -0
  59. package/dist/lib/domain/dimension/index.js +9 -0
  60. package/dist/lib/domain/knowledge/FieldSpec.d.ts +1 -1
  61. package/dist/lib/domain/knowledge/FieldSpec.js +29 -16
  62. package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +33 -111
  63. package/dist/lib/domain/knowledge/KnowledgeEntry.js +27 -6
  64. package/dist/lib/domain/knowledge/KnowledgeRepository.d.ts +1 -0
  65. package/dist/lib/domain/knowledge/KnowledgeRepository.js +3 -0
  66. package/dist/lib/domain/knowledge/Lifecycle.js +1 -1
  67. package/dist/lib/domain/knowledge/StyleGuide.d.ts +1 -1
  68. package/dist/lib/domain/knowledge/StyleGuide.js +1 -1
  69. package/dist/lib/domain/knowledge/UnifiedValidator.js +15 -0
  70. package/dist/lib/domain/knowledge/values/Stats.d.ts +1 -1
  71. package/dist/lib/domain/knowledge/values/Stats.js +2 -2
  72. package/dist/lib/external/mcp/McpServer.js +4 -0
  73. package/dist/lib/external/mcp/handlers/TargetClassifier.d.ts +1 -1
  74. package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.d.ts +8 -16
  75. package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +10 -10
  76. package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.d.ts +7 -0
  77. package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +20 -0
  78. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +52 -132
  79. package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +204 -17
  80. package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.d.ts +11 -75
  81. package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.js +40 -191
  82. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.d.ts +13 -78
  83. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +30 -52
  84. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.d.ts +0 -1
  85. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.d.ts +99 -12
  86. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +172 -161
  87. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
  88. package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.d.ts +46 -0
  89. package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.js +58 -0
  90. package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.d.ts +25 -0
  91. package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.js +47 -0
  92. package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +50 -12
  93. package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +30 -10
  94. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-text.js +1 -1
  95. package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.d.ts +24 -0
  96. package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.js +14 -0
  97. package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.d.ts +14 -0
  98. package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.js +48 -0
  99. package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.d.ts +21 -0
  100. package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.js +45 -0
  101. package/dist/lib/external/mcp/handlers/bootstrap/shared/skill-generator.d.ts +1 -1
  102. package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.d.ts +27 -0
  103. package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.js +44 -0
  104. package/dist/lib/external/mcp/handlers/bootstrap-external.d.ts +14 -10
  105. package/dist/lib/external/mcp/handlers/bootstrap-external.js +39 -51
  106. package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
  107. package/dist/lib/external/mcp/handlers/bootstrap-internal.js +115 -82
  108. package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
  109. package/dist/lib/external/mcp/handlers/consolidated.js +115 -162
  110. package/dist/lib/external/mcp/handlers/dimension-complete-external.js +69 -1
  111. package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
  112. package/dist/lib/external/mcp/handlers/evolve-external.js +226 -0
  113. package/dist/lib/external/mcp/handlers/knowledge.js +26 -2
  114. package/dist/lib/external/mcp/handlers/rescan-external.d.ts +76 -0
  115. package/dist/lib/external/mcp/handlers/rescan-external.js +335 -0
  116. package/dist/lib/external/mcp/handlers/rescan-internal.d.ts +120 -0
  117. package/dist/lib/external/mcp/handlers/rescan-internal.js +359 -0
  118. package/dist/lib/external/mcp/handlers/search.d.ts +6 -5
  119. package/dist/lib/external/mcp/handlers/search.js +6 -5
  120. package/dist/lib/external/mcp/handlers/types.d.ts +2 -1
  121. package/dist/lib/external/mcp/handlers/wiki-external.js +2 -2
  122. package/dist/lib/external/mcp/tools.d.ts +8 -18
  123. package/dist/lib/external/mcp/tools.js +60 -3
  124. package/dist/lib/http/routes/knowledge.js +122 -1
  125. package/dist/lib/http/routes/modules.js +25 -3
  126. package/dist/lib/http/routes/panorama.js +16 -4
  127. package/dist/lib/infrastructure/cache/CacheCoordinator.d.ts +41 -0
  128. package/dist/lib/infrastructure/cache/CacheCoordinator.js +105 -0
  129. package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.d.ts +7 -0
  130. package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.js +28 -0
  131. package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +1 -1
  132. package/dist/lib/injection/ServiceContainer.js +55 -0
  133. package/dist/lib/injection/ServiceMap.d.ts +8 -1
  134. package/dist/lib/injection/modules/InfraModule.js +4 -1
  135. package/dist/lib/injection/modules/KnowledgeModule.js +38 -1
  136. package/dist/lib/repository/evolution/ProposalRepository.d.ts +99 -0
  137. package/dist/lib/repository/evolution/ProposalRepository.js +255 -0
  138. package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +4 -0
  139. package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +16 -1
  140. package/dist/lib/service/bootstrap/BootstrapEventEmitter.d.ts +3 -2
  141. package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +1 -1
  142. package/dist/lib/service/bootstrap/DeliveryVerifier.d.ts +51 -0
  143. package/dist/lib/service/bootstrap/DeliveryVerifier.js +163 -0
  144. package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +22 -4
  145. package/dist/lib/service/bootstrap/UiStartupTasks.js +73 -5
  146. package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +54 -0
  147. package/dist/lib/service/bootstrap/bootstrap-event-types.js +10 -0
  148. package/dist/lib/service/cleanup/CleanupService.d.ts +85 -0
  149. package/dist/lib/service/cleanup/CleanupService.js +324 -0
  150. package/dist/lib/service/delivery/AgentInstructionsGenerator.js +39 -43
  151. package/dist/lib/service/delivery/FileProtection.d.ts +20 -0
  152. package/dist/lib/service/delivery/FileProtection.js +54 -0
  153. package/dist/lib/service/delivery/SkillsSyncer.js +16 -21
  154. package/dist/lib/service/evolution/ContentPatcher.d.ts +44 -0
  155. package/dist/lib/service/evolution/ContentPatcher.js +310 -0
  156. package/dist/lib/service/evolution/DecayDetector.d.ts +4 -3
  157. package/dist/lib/service/evolution/DecayDetector.js +97 -22
  158. package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +4 -2
  159. package/dist/lib/service/evolution/KnowledgeMetabolism.js +29 -2
  160. package/dist/lib/service/evolution/ProposalExecutor.d.ts +66 -0
  161. package/dist/lib/service/evolution/ProposalExecutor.js +424 -0
  162. package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +64 -0
  163. package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +458 -0
  164. package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +89 -0
  165. package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +492 -0
  166. package/dist/lib/service/evolution/StagingManager.js +5 -3
  167. package/dist/lib/service/evolution/createSupersedeProposal.d.ts +44 -0
  168. package/dist/lib/service/evolution/createSupersedeProposal.js +81 -0
  169. package/dist/lib/service/guard/ComplianceReporter.d.ts +4 -0
  170. package/dist/lib/service/guard/ComplianceReporter.js +51 -0
  171. package/dist/lib/service/guard/GuardCheckEngine.js +5 -4
  172. package/dist/lib/service/guard/GuardCrossFileChecks.js +2 -0
  173. package/dist/lib/service/guard/ReverseGuard.d.ts +1 -1
  174. package/dist/lib/service/guard/ReverseGuard.js +32 -2
  175. package/dist/lib/service/knowledge/ConfidenceRouter.js +1 -1
  176. package/dist/lib/service/knowledge/KnowledgeService.d.ts +11 -1
  177. package/dist/lib/service/knowledge/KnowledgeService.js +44 -4
  178. package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
  179. package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
  180. package/dist/lib/service/knowledge/SourceRefReconciler.d.ts +2 -0
  181. package/dist/lib/service/knowledge/SourceRefReconciler.js +48 -0
  182. package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +3 -2
  183. package/dist/lib/service/panorama/DimensionAnalyzer.js +15 -140
  184. package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
  185. package/dist/lib/service/search/SearchEngine.d.ts +11 -10
  186. package/dist/lib/service/search/SearchEngine.js +38 -36
  187. package/dist/lib/service/search/SearchTypes.d.ts +14 -8
  188. package/dist/lib/service/search/SearchTypes.js +1 -1
  189. package/dist/lib/service/search/tokenizer.d.ts +1 -1
  190. package/dist/lib/service/search/tokenizer.js +2 -2
  191. package/dist/lib/shared/schemas/common.d.ts +4 -4
  192. package/dist/lib/shared/schemas/http-requests.d.ts +12 -1
  193. package/dist/lib/shared/schemas/http-requests.js +8 -0
  194. package/dist/lib/shared/schemas/mcp-tools.d.ts +33 -2
  195. package/dist/lib/shared/schemas/mcp-tools.js +42 -0
  196. package/dist/lib/types/evolution.d.ts +135 -0
  197. package/dist/lib/types/evolution.js +6 -0
  198. package/dist/lib/types/graph-shared.d.ts +25 -0
  199. package/dist/lib/types/graph-shared.js +7 -0
  200. package/dist/lib/types/knowledge-wire.d.ts +131 -0
  201. package/dist/lib/types/knowledge-wire.js +7 -0
  202. package/dist/lib/types/project-snapshot-builder.d.ts +19 -0
  203. package/dist/lib/types/project-snapshot-builder.js +189 -0
  204. package/dist/lib/types/project-snapshot.d.ts +399 -0
  205. package/dist/lib/types/project-snapshot.js +17 -0
  206. package/dist/lib/types/search-wire.d.ts +46 -0
  207. package/dist/lib/types/search-wire.js +7 -0
  208. package/dist/lib/types/snapshot-views.d.ts +58 -0
  209. package/dist/lib/types/snapshot-views.js +103 -0
  210. package/package.json +1 -1
  211. package/skills/autosnippet-recipes/SKILL.md +1 -1
  212. package/templates/instructions/agent-static.md +2 -0
  213. package/templates/instructions/conventions.md +3 -1
  214. package/templates/recipes-setup/README.md +2 -2
  215. package/dashboard/dist/assets/icons-BJ2mUBi8.js +0 -1
  216. package/dashboard/dist/assets/index-B659K9t5.js +0 -128
  217. package/dashboard/dist/assets/index-NCm40PMD.css +0 -1
  218. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.d.ts +0 -169
  219. package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +0 -727
  220. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.d.ts +0 -370
  221. package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +0 -821
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Shared helpers for async AI-fill pipeline dispatch.
3
+ *
4
+ * Previously duplicated in:
5
+ * - bootstrap-internal.ts (Phase 5)
6
+ * - rescan-internal.ts (Step 6-7)
7
+ *
8
+ * @module bootstrap/shared/async-fill-helpers
9
+ */
10
+ import type { BootstrapSessionShape, DimensionDef } from '#types/project-snapshot.js';
11
+ import type { PipelineFillView } from '#types/snapshot-views.js';
12
+ import type { McpContext } from '../../types.js';
13
+ interface TaskDef {
14
+ id: string;
15
+ meta: {
16
+ type: string;
17
+ dimId: string;
18
+ label: string | undefined;
19
+ skillWorthy: boolean;
20
+ skillMeta: Record<string, unknown> | null;
21
+ };
22
+ }
23
+ /**
24
+ * Build task definitions from dimensions for BootstrapTaskManager.
25
+ */
26
+ export declare function buildTaskDefs(dimensions: DimensionDef[]): TaskDef[];
27
+ interface TaskManagerLogger {
28
+ warn(...args: unknown[]): void;
29
+ }
30
+ /**
31
+ * Start a BootstrapTaskManager session (graceful degradation if unavailable).
32
+ */
33
+ export declare function startTaskManagerSession(container: McpContext['container'], taskDefs: TaskDef[], logger: TaskManagerLogger, logPrefix: string): BootstrapSessionShape | null;
34
+ /**
35
+ * Dispatch fillDimensionsV3 from a PipelineFillView.
36
+ *
37
+ * Passes the view directly to orchestrator (no more flat-context expansion).
38
+ * Fires via setImmediate (fire-and-forget).
39
+ *
40
+ * @param view - Typed PipelineFillView from handler
41
+ * @param dimensions - Active dimensions for this run (may differ from snapshot.activeDimensions for rescan gap-only)
42
+ * @param fillDimensionsV3 - The pipeline function to invoke
43
+ * @param logPrefix - Log prefix (e.g. 'Bootstrap', 'Rescan-Internal')
44
+ */
45
+ export declare function dispatchPipelineFill(view: PipelineFillView, dimensions: DimensionDef[], fillDimensionsV3: (view: PipelineFillView, dimensions: DimensionDef[]) => Promise<void>, logPrefix: string): void;
46
+ export {};
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Shared helpers for async AI-fill pipeline dispatch.
3
+ *
4
+ * Previously duplicated in:
5
+ * - bootstrap-internal.ts (Phase 5)
6
+ * - rescan-internal.ts (Step 6-7)
7
+ *
8
+ * @module bootstrap/shared/async-fill-helpers
9
+ */
10
+ /**
11
+ * Build task definitions from dimensions for BootstrapTaskManager.
12
+ */
13
+ export function buildTaskDefs(dimensions) {
14
+ return dimensions.map((dim) => ({
15
+ id: dim.id,
16
+ meta: {
17
+ type: dim.skillWorthy ? 'skill' : 'candidate',
18
+ dimId: dim.id,
19
+ label: dim.label,
20
+ skillWorthy: !!dim.skillWorthy,
21
+ skillMeta: dim.skillMeta || null,
22
+ },
23
+ }));
24
+ }
25
+ /**
26
+ * Start a BootstrapTaskManager session (graceful degradation if unavailable).
27
+ */
28
+ export function startTaskManagerSession(container, taskDefs, logger, logPrefix) {
29
+ try {
30
+ const taskManager = container.get('bootstrapTaskManager');
31
+ return taskManager.startSession(taskDefs);
32
+ }
33
+ catch (e) {
34
+ logger.warn(`[${logPrefix}] BootstrapTaskManager init failed (graceful degradation): ${e instanceof Error ? e.message : String(e)}`);
35
+ return null;
36
+ }
37
+ }
38
+ // ── Pipeline Fill View dispatch (Phase D-2) ──────────────
39
+ /**
40
+ * Dispatch fillDimensionsV3 from a PipelineFillView.
41
+ *
42
+ * Passes the view directly to orchestrator (no more flat-context expansion).
43
+ * Fires via setImmediate (fire-and-forget).
44
+ *
45
+ * @param view - Typed PipelineFillView from handler
46
+ * @param dimensions - Active dimensions for this run (may differ from snapshot.activeDimensions for rescan gap-only)
47
+ * @param fillDimensionsV3 - The pipeline function to invoke
48
+ * @param logPrefix - Log prefix (e.g. 'Bootstrap', 'Rescan-Internal')
49
+ */
50
+ export function dispatchPipelineFill(view, dimensions, fillDimensionsV3, logPrefix) {
51
+ const ctxLogger = view.ctx.logger;
52
+ setImmediate(() => {
53
+ ctxLogger?.info(`[${logPrefix}] Dispatching v3 AI-First pipeline`);
54
+ fillDimensionsV3(view, dimensions).catch((e) => {
55
+ ctxLogger?.error(`[${logPrefix}] Async fill failed: ${e instanceof Error ? e.message : String(e)}`);
56
+ });
57
+ });
58
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shared helpers for recipe relevance audit.
3
+ *
4
+ * Previously duplicated in:
5
+ * - rescan-internal.ts (Step 4)
6
+ * - rescan-external.ts (Step 4)
7
+ *
8
+ * @module bootstrap/shared/audit-helpers
9
+ */
10
+ import type { AstSummary, DependencyGraph } from '#types/project-snapshot.js';
11
+ /**
12
+ * Extract code entities from AST project summary for audit evidence matching.
13
+ */
14
+ export declare function extractCodeEntities(astProjectSummary: AstSummary | null | undefined): Array<{
15
+ name: string;
16
+ kind?: string;
17
+ file?: string;
18
+ }>;
19
+ /**
20
+ * Extract dependency edges from the dependency graph for audit evidence matching.
21
+ */
22
+ export declare function extractDependencyEdges(depGraphData: DependencyGraph | null | undefined): Array<{
23
+ from: string;
24
+ to: string;
25
+ }>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Shared helpers for recipe relevance audit.
3
+ *
4
+ * Previously duplicated in:
5
+ * - rescan-internal.ts (Step 4)
6
+ * - rescan-external.ts (Step 4)
7
+ *
8
+ * @module bootstrap/shared/audit-helpers
9
+ */
10
+ // ── AST entity extraction ────────────────────────────────
11
+ /**
12
+ * Extract code entities from AST project summary for audit evidence matching.
13
+ */
14
+ export function extractCodeEntities(astProjectSummary) {
15
+ const entities = [];
16
+ if (!astProjectSummary) {
17
+ return entities;
18
+ }
19
+ for (const cls of astProjectSummary.classes || []) {
20
+ entities.push({ name: cls.name, kind: 'class', file: cls.relativePath || cls.file });
21
+ }
22
+ for (const proto of astProjectSummary.protocols || []) {
23
+ entities.push({ name: proto.name, kind: 'protocol', file: proto.relativePath || proto.file });
24
+ }
25
+ if (astProjectSummary.categories) {
26
+ for (const cat of astProjectSummary.categories) {
27
+ entities.push({ name: cat.name || '', kind: 'category', file: cat.relativePath || cat.file });
28
+ }
29
+ }
30
+ return entities;
31
+ }
32
+ // ── Dependency edge extraction ───────────────────────────
33
+ /**
34
+ * Extract dependency edges from the dependency graph for audit evidence matching.
35
+ */
36
+ export function extractDependencyEdges(depGraphData) {
37
+ const edges = [];
38
+ if (!depGraphData?.edges) {
39
+ return edges;
40
+ }
41
+ for (const edge of depGraphData.edges) {
42
+ if (edge.from && edge.to) {
43
+ edges.push({ from: edge.from, to: edge.to });
44
+ }
45
+ }
46
+ return edges;
47
+ }
@@ -17,6 +17,8 @@
17
17
  *
18
18
  * @module bootstrap/shared/bootstrap-phases
19
19
  */
20
+ import type { ProjectAnalysisResult } from '#core/AstAnalyzer.js';
21
+ import type { GuardAudit } from '#types/project-snapshot.js';
20
22
  import { type BaseDimension } from '../base-dimensions.js';
21
23
  /** Logger with required info/warn (compatible with Logger singleton) */
22
24
  interface PhaseLogger {
@@ -56,8 +58,8 @@ interface DepGraphData {
56
58
  }>;
57
59
  [key: string]: unknown;
58
60
  }
59
- type AstProjectSummaryLike = Record<string, any>;
60
- type GuardAuditLike = Record<string, any>;
61
+ type AstProjectSummaryLike = ProjectAnalysisResult;
62
+ type GuardAuditLike = GuardAudit;
61
63
  /** Minimal guard engine shape */
62
64
  interface GuardEngineLike {
63
65
  auditFiles(files: Array<{
@@ -163,7 +165,7 @@ export declare function runPhase1_FileCollection(projectRoot: string, logger: Ph
163
165
  * @returns >}
164
166
  */
165
167
  export declare function runPhase1_5_AstAnalysis(allFiles: BootstrapFileEntry[], langStats: Record<string, number>, logger: PhaseLogger, options?: AstAnalysisOptions): Promise<{
166
- astProjectSummary: AstProjectSummaryLike | null;
168
+ astProjectSummary: ProjectAnalysisResult | null;
167
169
  astContext: string;
168
170
  warnings: string[];
169
171
  }>;
@@ -175,7 +177,11 @@ export declare function runPhase1_5_AstAnalysis(allFiles: BootstrapFileEntry[],
175
177
  * @returns >}
176
178
  */
177
179
  export declare function runPhase1_6_EntityGraph(astProjectSummary: AstProjectSummaryLike | null, projectRoot: string, container: PhaseContainer, logger: PhaseLogger): Promise<{
178
- codeEntityResult: Record<string, any> | null;
180
+ codeEntityResult: {
181
+ entitiesUpserted: number;
182
+ edgesCreated: number;
183
+ durationMs: number;
184
+ } | null;
179
185
  warnings: string[];
180
186
  }>;
181
187
  /**
@@ -190,7 +196,11 @@ export declare function runPhase1_6_EntityGraph(astProjectSummary: AstProjectSum
190
196
  * @returns >}
191
197
  */
192
198
  export declare function runPhase1_7_CallGraph(astProjectSummary: AstProjectSummaryLike | null, projectRoot: string, container: PhaseContainer, logger: PhaseLogger, incrementalOpts?: IncrementalCallGraphOpts | null): Promise<{
193
- callGraphResult: Record<string, any> | null;
199
+ callGraphResult: {
200
+ entitiesUpserted: number;
201
+ edgesCreated: number;
202
+ durationMs: number;
203
+ } | null;
194
204
  warnings: string[];
195
205
  }>;
196
206
  /**
@@ -220,7 +230,7 @@ export declare function runPhase2_1_ModuleEntities(depGraphData: DepGraphData |
220
230
  * @returns >}
221
231
  */
222
232
  export declare function runPhase3_GuardAudit(allFiles: BootstrapFileEntry[], container: PhaseContainer, logger: PhaseLogger, options?: GuardAuditOptions): Promise<{
223
- guardAudit: GuardAuditLike | null;
233
+ guardAudit: GuardAudit | null;
224
234
  guardEngine: GuardEngineLike | null;
225
235
  warnings: string[];
226
236
  }>;
@@ -260,7 +270,7 @@ export declare function runPhase4_DimensionResolve(params: Phase4Params): Promis
260
270
  isMultiLang: boolean;
261
271
  };
262
272
  detectedFrameworks: string[];
263
- guardAudit: GuardAuditLike | null;
273
+ guardAudit: GuardAudit | null;
264
274
  }>;
265
275
  /**
266
276
  * runAllPhases — 一站式执行 Phase 1~4 全部数据收集
@@ -281,6 +291,7 @@ export declare function runAllPhases(projectRoot: string, ctx: AllPhasesContext,
281
291
  primaryLang: null;
282
292
  discoverer: DiscovererLike;
283
293
  allTargets: TargetItem[];
294
+ truncated: boolean;
284
295
  astProjectSummary: null;
285
296
  astContext: string;
286
297
  codeEntityResult: null;
@@ -295,6 +306,7 @@ export declare function runAllPhases(projectRoot: string, ctx: AllPhasesContext,
295
306
  enhancementGuardRules: never[];
296
307
  langProfile: {};
297
308
  targetsSummary: never[];
309
+ localPackageModules: never[];
298
310
  warnings: string[];
299
311
  report: {};
300
312
  incrementalPlan: null;
@@ -307,13 +319,22 @@ export declare function runAllPhases(projectRoot: string, ctx: AllPhasesContext,
307
319
  primaryLang: string;
308
320
  discoverer: DiscovererLike;
309
321
  allTargets: TargetItem[];
310
- astProjectSummary: AstProjectSummaryLike | null;
322
+ truncated: boolean;
323
+ astProjectSummary: ProjectAnalysisResult | null;
311
324
  astContext: string;
312
- codeEntityResult: Record<string, any> | null;
313
- callGraphResult: Record<string, any> | null;
325
+ codeEntityResult: {
326
+ entitiesUpserted: number;
327
+ edgesCreated: number;
328
+ durationMs: number;
329
+ } | null;
330
+ callGraphResult: {
331
+ entitiesUpserted: number;
332
+ edgesCreated: number;
333
+ durationMs: number;
334
+ } | null;
314
335
  depGraphData: DepGraphData | null;
315
336
  depEdgesWritten: number;
316
- guardAudit: GuardAuditLike | null;
337
+ guardAudit: GuardAudit | null;
317
338
  guardEngine: GuardEngineLike | null;
318
339
  activeDimensions: BaseDimension[];
319
340
  enhancementPackInfo: {
@@ -340,10 +361,27 @@ export declare function runAllPhases(projectRoot: string, ctx: AllPhasesContext,
340
361
  packageName: string | undefined;
341
362
  inferredRole: string;
342
363
  fileCount: number;
364
+ isLocalPackage: boolean | undefined;
365
+ }[];
366
+ localPackageModules: {
367
+ name: string;
368
+ packageName: string;
369
+ fileCount: number;
370
+ inferredRole: string;
371
+ keyFiles: string[];
343
372
  }[];
344
373
  warnings: string[];
345
374
  report: PhaseReport | null;
346
- incrementalPlan: Record<string, any> | null;
375
+ incrementalPlan: {
376
+ mode: string;
377
+ canIncremental: boolean;
378
+ affectedDimensions: string[];
379
+ skippedDimensions: string[];
380
+ reason: string;
381
+ diff?: unknown;
382
+ previousSnapshot?: unknown;
383
+ restoredEpisodic?: unknown;
384
+ } | null;
347
385
  panoramaResult: Record<string, unknown> | null;
348
386
  isEmpty: boolean;
349
387
  }>;
@@ -20,7 +20,7 @@
20
20
  import fs from 'node:fs';
21
21
  import path from 'node:path';
22
22
  import { analyzeProject, isAvailable as astIsAvailable, generateContextForAgent, } from '#core/AstAnalyzer.js';
23
- import { DimensionCopy } from '#service/bootstrap/DimensionCopyRegistry.js';
23
+ import { DimensionCopy } from '#domain/dimension/DimensionCopy.js';
24
24
  import { LanguageService } from '#shared/LanguageService.js';
25
25
  import pathGuard from '#shared/PathGuard.js';
26
26
  import { detectPrimaryLanguage } from '../../LanguageExtensions.js';
@@ -214,7 +214,6 @@ export async function runPhase1_5_AstAnalysis(allFiles, langStats, logger, optio
214
214
  */
215
215
  export async function runPhase1_6_EntityGraph(astProjectSummary, projectRoot, container, logger) {
216
216
  const warnings = [];
217
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- opaque result from CodeEntityGraph.populateFromAst
218
217
  let codeEntityResult = null;
219
218
  if (astProjectSummary) {
220
219
  try {
@@ -223,7 +222,7 @@ export async function runPhase1_6_EntityGraph(astProjectSummary, projectRoot, co
223
222
  if (db) {
224
223
  const ceg = new CodeEntityGraph(db, { projectRoot });
225
224
  ceg.clearProject();
226
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- AstProjectSummaryLike is structurally compatible at runtime
225
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- ProjectAnalysisResult structurally compatible at runtime
227
226
  codeEntityResult = ceg.populateFromAst(astProjectSummary);
228
227
  logger.info(`[Bootstrap] Entity Graph: ${codeEntityResult.entitiesUpserted} entities, ${codeEntityResult.edgesCreated} edges`);
229
228
  }
@@ -249,7 +248,6 @@ export async function runPhase1_6_EntityGraph(astProjectSummary, projectRoot, co
249
248
  */
250
249
  export async function runPhase1_7_CallGraph(astProjectSummary, projectRoot, container, logger, incrementalOpts = null) {
251
250
  const warnings = [];
252
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- opaque result from CodeEntityGraph.populateCallGraph
253
251
  let callGraphResult = null;
254
252
  if (!astProjectSummary?.fileSummaries?.length) {
255
253
  return { callGraphResult, warnings };
@@ -268,13 +266,13 @@ export async function runPhase1_7_CallGraph(astProjectSummary, projectRoot, cont
268
266
  const isIncremental = (changedFiles?.length ?? 0) > 0 && changedFiles.length <= 10;
269
267
  // Phase 5 分析 (带超时保护 + 渐进式 partial result)
270
268
  const result = isIncremental
271
- ? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- AstProjectSummaryLike structurally compatible
269
+ ? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- ProjectAnalysisResult structurally compatible with AstProjectSummary
272
270
  await analyzer.analyzeIncremental(astProjectSummary, changedFiles, {
273
271
  timeout: 15_000,
274
272
  maxCallSitesPerFile: 500,
275
273
  minConfidence: 0.5,
276
274
  })
277
- : // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- AstProjectSummaryLike structurally compatible
275
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- ProjectAnalysisResult structurally compatible with AstProjectSummary
278
276
  await analyzer.analyze(astProjectSummary, {
279
277
  timeout: 15_000,
280
278
  maxCallSitesPerFile: 500,
@@ -389,10 +387,11 @@ export async function runPhase3_GuardAudit(allFiles, container, logger, options
389
387
  const prefix = options.summaryPrefix || 'Bootstrap scan';
390
388
  for (const fileResult of guardAudit.files || []) {
391
389
  if (fileResult.violations.length > 0) {
390
+ const fileSummary = fileResult.summary;
392
391
  violationsStore.appendRun({
393
392
  filePath: fileResult.filePath,
394
393
  violations: fileResult.violations,
395
- summary: `${prefix}: ${fileResult.summary.errors}E ${fileResult.summary.warnings}W`,
394
+ summary: `${prefix}: ${fileSummary?.errors ?? 0}E ${fileSummary?.warnings ?? 0}W`,
396
395
  });
397
396
  }
398
397
  }
@@ -484,7 +483,7 @@ export async function runPhase4_DimensionResolve(params) {
484
483
  content: f.content,
485
484
  }));
486
485
  guardAudit = guardEngine.auditFiles(guardFiles, { scope: 'project' });
487
- logger.info(`[Bootstrap] Guard re-audit with ${guardEngine.getExternalRuleCount()} Enhancement Pack rules → ${guardAudit.summary.totalViolations} total violations`);
486
+ logger.info(`[Bootstrap] Guard re-audit with ${guardEngine.getExternalRuleCount()} Enhancement Pack rules → ${guardAudit.summary?.totalViolations ?? 0} total violations`);
488
487
  }
489
488
  catch (e) {
490
489
  logger.warn(`[Bootstrap] Enhancement Pack guard re-audit failed: ${e instanceof Error ? e.message : String(e)}`);
@@ -561,6 +560,7 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
561
560
  primaryLang: null,
562
561
  discoverer,
563
562
  allTargets,
563
+ truncated,
564
564
  astProjectSummary: null,
565
565
  astContext: '',
566
566
  codeEntityResult: null,
@@ -575,6 +575,7 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
575
575
  enhancementGuardRules: [],
576
576
  langProfile: {},
577
577
  targetsSummary: [],
578
+ localPackageModules: [],
578
579
  warnings,
579
580
  report: report || {},
580
581
  incrementalPlan: null,
@@ -584,7 +585,6 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
584
585
  };
585
586
  }
586
587
  // ── Incremental evaluation (Phase 1 后执行,需要 allFiles) ──
587
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- IncrementalBootstrap.evaluate returns opaque plan object
588
588
  let incrementalPlan = null;
589
589
  if (options.incremental) {
590
590
  try {
@@ -710,14 +710,32 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
710
710
  // Targets 摘要
711
711
  const targetsSummary = allTargets.map((t) => {
712
712
  const name = typeof t === 'string' ? t : t.name;
713
+ const pkgName = typeof t === 'object' ? t.packageName : undefined;
714
+ const targetPath = typeof t === 'object' ? t.path : undefined;
713
715
  return {
714
716
  name,
715
717
  type: (typeof t === 'object' ? t.type : undefined) || 'target',
716
- packageName: (typeof t === 'object' ? t.packageName : undefined) || undefined,
718
+ packageName: pkgName || undefined,
717
719
  inferredRole: inferTargetRole(name),
718
720
  fileCount: allFiles.filter((f) => f.targetName === name).length,
721
+ // 标记来自子包的 target(如 Packages/AOXNetworkKit)—— 语言无关
722
+ isLocalPackage: typeof targetPath === 'string' && targetPath !== projectRoot ? true : undefined,
719
723
  };
720
724
  });
725
+ // 本地子包汇总 — 供 MissionBriefing 构建 mustCoverModules
726
+ const localPackageModules = targetsSummary
727
+ .filter((t) => t.isLocalPackage && t.fileCount > 0)
728
+ .map((t) => ({
729
+ name: t.name,
730
+ packageName: t.packageName || t.name,
731
+ fileCount: t.fileCount,
732
+ inferredRole: t.inferredRole,
733
+ // 提取该模块的关键文件路径(前 8 个,用于 evidenceStarters)
734
+ keyFiles: allFiles
735
+ .filter((f) => f.targetName === t.name)
736
+ .slice(0, 8)
737
+ .map((f) => f.relativePath),
738
+ }));
721
739
  // 完成报告
722
740
  if (report) {
723
741
  report.totalMs = Date.now() - report.startTime;
@@ -728,6 +746,7 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
728
746
  primaryLang,
729
747
  discoverer,
730
748
  allTargets,
749
+ truncated,
731
750
  astProjectSummary: phase1_5.astProjectSummary,
732
751
  astContext: phase1_5.astContext,
733
752
  codeEntityResult: phase1_6.codeEntityResult,
@@ -743,6 +762,7 @@ export async function runAllPhases(projectRoot, ctx, options = {}) {
743
762
  langProfile: phase4.langProfile,
744
763
  detectedFrameworks: phase4.detectedFrameworks,
745
764
  targetsSummary,
765
+ localPackageModules, // 本地子包汇总(语言无关)
746
766
  warnings,
747
767
  report, // NEW: Phase 级报告 (null if generateReport=false)
748
768
  incrementalPlan, // NEW: 增量评估结果 (null if incremental=false)
@@ -42,7 +42,7 @@ export const SUBMISSION_SCHEMA = {
42
42
  'content.markdown ≥ 200 字符',
43
43
  '至少包含 1 个代码块 (```)',
44
44
  '包含来源标注 (来源: FileName:行号)',
45
- '标题使用项目真实类名',
45
+ '标题使用项目真实类名(不以项目名开头)',
46
46
  'trigger 必须唯一(同批次内不重复)',
47
47
  ],
48
48
  };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared type definitions for bootstrap & rescan handler modules.
3
+ *
4
+ * Consolidates interfaces previously duplicated across:
5
+ * - bootstrap-internal.ts
6
+ * - bootstrap-external.ts
7
+ * - rescan-internal.ts
8
+ * - rescan-external.ts
9
+ *
10
+ * v2: 类型统一到 project-snapshot.ts,本文件 re-export + 提供向后兼容别名。
11
+ *
12
+ * @module bootstrap/shared/handler-types
13
+ */
14
+ export type { BootstrapSessionShape, DimensionDef, GuardAuditFileEntry as GuardAuditFile, GuardViolation, MissionBriefingResult, } from '#types/project-snapshot.js';
15
+ /** Processed source file with language + priority metadata */
16
+ export interface TargetFile {
17
+ name: string;
18
+ relativePath: string;
19
+ language: string;
20
+ totalLines: number;
21
+ priority: string;
22
+ content: string;
23
+ truncated: boolean;
24
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared type definitions for bootstrap & rescan handler modules.
3
+ *
4
+ * Consolidates interfaces previously duplicated across:
5
+ * - bootstrap-internal.ts
6
+ * - bootstrap-external.ts
7
+ * - rescan-internal.ts
8
+ * - rescan-external.ts
9
+ *
10
+ * v2: 类型统一到 project-snapshot.ts,本文件 re-export + 提供向后兼容别名。
11
+ *
12
+ * @module bootstrap/shared/handler-types
13
+ */
14
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Panorama summarization helper for internal agent responses.
3
+ *
4
+ * Extracted from bootstrap-internal.ts.
5
+ * Note: MissionBriefingBuilder has its own typed version for the MissionBriefing interface.
6
+ *
7
+ * @module bootstrap/shared/panorama-utils
8
+ */
9
+ /**
10
+ * Summarize PanoramaResult into a compact internal-agent-friendly shape.
11
+ *
12
+ * Returns the top layers, coupling hotspots, cyclic dependencies, and knowledge gaps.
13
+ */
14
+ export declare function summarizePanorama(panoramaResult: unknown): Record<string, unknown> | null;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Panorama summarization helper for internal agent responses.
3
+ *
4
+ * Extracted from bootstrap-internal.ts.
5
+ * Note: MissionBriefingBuilder has its own typed version for the MissionBriefing interface.
6
+ *
7
+ * @module bootstrap/shared/panorama-utils
8
+ */
9
+ /**
10
+ * Summarize PanoramaResult into a compact internal-agent-friendly shape.
11
+ *
12
+ * Returns the top layers, coupling hotspots, cyclic dependencies, and knowledge gaps.
13
+ */
14
+ export function summarizePanorama(panoramaResult) {
15
+ if (!panoramaResult || typeof panoramaResult !== 'object') {
16
+ return null;
17
+ }
18
+ const pr = panoramaResult;
19
+ const moduleMap = pr.modules;
20
+ const layers = pr.layers;
21
+ const gaps = pr.gaps ?? [];
22
+ const cycles = pr.cycles ?? [];
23
+ // Coupling hotspots: fanIn >= 10 or fanOut >= 10
24
+ const couplingHotspots = [];
25
+ if (moduleMap) {
26
+ const entries = moduleMap instanceof Map
27
+ ? [...moduleMap.values()]
28
+ : Object.values(moduleMap);
29
+ for (const mod of entries) {
30
+ if ((mod.fanIn || 0) >= 10 || (mod.fanOut || 0) >= 10) {
31
+ couplingHotspots.push({
32
+ name: mod.name || '',
33
+ fanIn: mod.fanIn || 0,
34
+ fanOut: mod.fanOut || 0,
35
+ });
36
+ }
37
+ }
38
+ }
39
+ return {
40
+ layers: layers?.levels?.slice(0, 10) ?? [],
41
+ couplingHotspots: couplingHotspots.slice(0, 10),
42
+ cyclicDependencies: cycles.slice(0, 10).map((c) => c.modules),
43
+ knowledgeGaps: gaps.slice(0, 20).map((g) => ({
44
+ module: g.module,
45
+ suggestedFocus: g.suggestedFocus,
46
+ })),
47
+ };
48
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Shared BootstrapSessionManager singleton management.
3
+ *
4
+ * Previously duplicated (with identical logic) in:
5
+ * - bootstrap-internal.ts → getOrCreateSessionManager()
6
+ * - bootstrap-external.ts → getSessionManager()
7
+ * - rescan-external.ts → getSessionManager()
8
+ *
9
+ * @module bootstrap/shared/session-helpers
10
+ */
11
+ import type { McpContext } from '../../types.js';
12
+ import { BootstrapSessionManager } from '../BootstrapSession.js';
13
+ /**
14
+ * Get or create the process-level BootstrapSessionManager singleton.
15
+ *
16
+ * Resolution order:
17
+ * 1. Check container for registered instance
18
+ * 2. Fall back to module-level singleton
19
+ * 3. Register into container for cross-handler access
20
+ */
21
+ export declare function getOrCreateSessionManager(container: McpContext['container']): BootstrapSessionManager;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Shared BootstrapSessionManager singleton management.
3
+ *
4
+ * Previously duplicated (with identical logic) in:
5
+ * - bootstrap-internal.ts → getOrCreateSessionManager()
6
+ * - bootstrap-external.ts → getSessionManager()
7
+ * - rescan-external.ts → getSessionManager()
8
+ *
9
+ * @module bootstrap/shared/session-helpers
10
+ */
11
+ import { BootstrapSessionManager } from '../BootstrapSession.js';
12
+ // ── Process-level singleton ──────────────────────────────
13
+ let _sessionManager = null;
14
+ /**
15
+ * Get or create the process-level BootstrapSessionManager singleton.
16
+ *
17
+ * Resolution order:
18
+ * 1. Check container for registered instance
19
+ * 2. Fall back to module-level singleton
20
+ * 3. Register into container for cross-handler access
21
+ */
22
+ export function getOrCreateSessionManager(container) {
23
+ // Check container first
24
+ try {
25
+ const mgr = container.get('bootstrapSessionManager');
26
+ if (mgr) {
27
+ return mgr;
28
+ }
29
+ }
30
+ catch {
31
+ /* not registered yet */
32
+ }
33
+ // Fall back to module-level singleton
34
+ if (!_sessionManager) {
35
+ _sessionManager = new BootstrapSessionManager();
36
+ }
37
+ // Register into container for cross-handler access
38
+ try {
39
+ container.register?.('bootstrapSessionManager', () => _sessionManager);
40
+ }
41
+ catch {
42
+ /* already registered or container doesn't support register */
43
+ }
44
+ return _sessionManager;
45
+ }
@@ -19,7 +19,7 @@ interface SkillDimensionDef {
19
19
  skillMeta?: {
20
20
  name?: string;
21
21
  description?: string;
22
- };
22
+ } | null;
23
23
  }
24
24
  /**
25
25
  * generateSkill — 标准化 Skill 生成入口