bc-code-intelligence-mcp 1.1.1 → 1.2.0

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 (98) hide show
  1. package/README.md +99 -9
  2. package/dist/cli/bc-code-intel-cli.js +0 -1
  3. package/dist/cli/bc-code-intel-cli.js.map +1 -1
  4. package/dist/index.d.ts +8 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +82 -5
  7. package/dist/index.js.map +1 -1
  8. package/dist/layers/embedded-layer.d.ts +74 -0
  9. package/dist/layers/embedded-layer.d.ts.map +1 -1
  10. package/dist/layers/embedded-layer.js +287 -3
  11. package/dist/layers/embedded-layer.js.map +1 -1
  12. package/dist/layers/layer-service.d.ts +6 -0
  13. package/dist/layers/layer-service.d.ts.map +1 -1
  14. package/dist/layers/layer-service.js +13 -0
  15. package/dist/layers/layer-service.js.map +1 -1
  16. package/dist/services/agent-onboarding-service.d.ts +45 -0
  17. package/dist/services/agent-onboarding-service.d.ts.map +1 -0
  18. package/dist/services/agent-onboarding-service.js +372 -0
  19. package/dist/services/agent-onboarding-service.js.map +1 -0
  20. package/dist/services/enhanced-prompt-service.d.ts +60 -0
  21. package/dist/services/enhanced-prompt-service.d.ts.map +1 -0
  22. package/dist/services/enhanced-prompt-service.js +162 -0
  23. package/dist/services/enhanced-prompt-service.js.map +1 -0
  24. package/dist/services/multi-content-layer-service.d.ts +92 -0
  25. package/dist/services/multi-content-layer-service.d.ts.map +1 -0
  26. package/dist/services/multi-content-layer-service.js +407 -0
  27. package/dist/services/multi-content-layer-service.js.map +1 -0
  28. package/dist/services/roleplay-engine.d.ts +121 -0
  29. package/dist/services/roleplay-engine.d.ts.map +1 -0
  30. package/dist/services/roleplay-engine.js +672 -0
  31. package/dist/services/roleplay-engine.js.map +1 -0
  32. package/dist/services/session-storage/file-storage.d.ts +30 -0
  33. package/dist/services/session-storage/file-storage.d.ts.map +1 -0
  34. package/dist/services/session-storage/file-storage.js +229 -0
  35. package/dist/services/session-storage/file-storage.js.map +1 -0
  36. package/dist/services/session-storage/in-memory-storage.d.ts +31 -0
  37. package/dist/services/session-storage/in-memory-storage.d.ts.map +1 -0
  38. package/dist/services/session-storage/in-memory-storage.js +142 -0
  39. package/dist/services/session-storage/in-memory-storage.js.map +1 -0
  40. package/dist/services/specialist-discovery.d.ts +76 -0
  41. package/dist/services/specialist-discovery.d.ts.map +1 -0
  42. package/dist/services/specialist-discovery.js +270 -0
  43. package/dist/services/specialist-discovery.js.map +1 -0
  44. package/dist/services/specialist-handoff-service.d.ts +81 -0
  45. package/dist/services/specialist-handoff-service.d.ts.map +1 -0
  46. package/dist/services/specialist-handoff-service.js +470 -0
  47. package/dist/services/specialist-handoff-service.js.map +1 -0
  48. package/dist/services/specialist-loader.d.ts +101 -0
  49. package/dist/services/specialist-loader.d.ts.map +1 -0
  50. package/dist/services/specialist-loader.js +249 -0
  51. package/dist/services/specialist-loader.js.map +1 -0
  52. package/dist/services/specialist-session-manager.d.ts +76 -0
  53. package/dist/services/specialist-session-manager.d.ts.map +1 -0
  54. package/dist/services/specialist-session-manager.js +255 -0
  55. package/dist/services/specialist-session-manager.js.map +1 -0
  56. package/dist/tools/specialist-discovery-tools.d.ts +27 -0
  57. package/dist/tools/specialist-discovery-tools.d.ts.map +1 -0
  58. package/dist/tools/specialist-discovery-tools.js +287 -0
  59. package/dist/tools/specialist-discovery-tools.js.map +1 -0
  60. package/dist/tools/specialist-tools.d.ts +38 -0
  61. package/dist/tools/specialist-tools.d.ts.map +1 -0
  62. package/dist/tools/specialist-tools.js +322 -0
  63. package/dist/tools/specialist-tools.js.map +1 -0
  64. package/dist/types/config-types.d.ts +2 -0
  65. package/dist/types/config-types.d.ts.map +1 -1
  66. package/dist/types/config-types.js.map +1 -1
  67. package/dist/types/enhanced-layer-types.d.ts +193 -0
  68. package/dist/types/enhanced-layer-types.d.ts.map +1 -0
  69. package/dist/types/enhanced-layer-types.js +9 -0
  70. package/dist/types/enhanced-layer-types.js.map +1 -0
  71. package/dist/types/layer-types.d.ts +2 -0
  72. package/dist/types/layer-types.d.ts.map +1 -1
  73. package/dist/types/layer-types.js.map +1 -1
  74. package/dist/types/roleplay-types.d.ts +149 -0
  75. package/dist/types/roleplay-types.d.ts.map +1 -0
  76. package/dist/types/roleplay-types.js +8 -0
  77. package/dist/types/roleplay-types.js.map +1 -0
  78. package/dist/types/session-types.d.ts +111 -0
  79. package/dist/types/session-types.d.ts.map +1 -0
  80. package/dist/types/session-types.js +8 -0
  81. package/dist/types/session-types.js.map +1 -0
  82. package/embedded-knowledge/AGENTS.md +119 -10
  83. package/embedded-knowledge/README.md +20 -3
  84. package/embedded-knowledge/specialists/alex-architect.md +216 -0
  85. package/embedded-knowledge/specialists/casey-copilot.md +226 -0
  86. package/embedded-knowledge/specialists/dean-debug.md +222 -0
  87. package/embedded-knowledge/specialists/eva-errors.md +235 -0
  88. package/embedded-knowledge/specialists/jordan-bridge.md +235 -0
  89. package/embedded-knowledge/specialists/logan-legacy.md +209 -0
  90. package/embedded-knowledge/specialists/maya-mentor.md +211 -0
  91. package/embedded-knowledge/specialists/morgan-market.md +226 -0
  92. package/embedded-knowledge/specialists/quinn-tester.md +235 -0
  93. package/embedded-knowledge/specialists/roger-reviewer.md +234 -0
  94. package/embedded-knowledge/specialists/sam-coder.md +181 -0
  95. package/embedded-knowledge/specialists/seth-security.md +235 -0
  96. package/embedded-knowledge/specialists/taylor-docs.md +257 -0
  97. package/embedded-knowledge/specialists/uma-ux.md +235 -0
  98. package/package.json +3 -3
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Enhanced Multi-Content Layer Service
3
+ *
4
+ * Extends the existing layer system to support specialists alongside
5
+ * atomic topics, enabling companies/teams/projects to have custom specialists
6
+ * that override or supplement the base specialist personas.
7
+ */
8
+ import { MultiContentKnowledgeLayer, EnhancedLayerLoadResult, SpecialistQueryContext, MultiLayerSpecialistResult, SpecialistResolutionStrategy } from '../types/enhanced-layer-types.js';
9
+ import { SpecialistDefinition } from './specialist-loader.js';
10
+ export declare class MultiContentLayerService {
11
+ private readonly specialistResolutionStrategy;
12
+ private layers;
13
+ private layerPriorities;
14
+ private contentCache;
15
+ private initialized;
16
+ constructor(specialistResolutionStrategy?: SpecialistResolutionStrategy);
17
+ /**
18
+ * Add a layer to the service
19
+ */
20
+ addLayer(layer: MultiContentKnowledgeLayer): void;
21
+ /**
22
+ * Initialize all layers
23
+ */
24
+ initialize(): Promise<Map<string, EnhancedLayerLoadResult>>;
25
+ /**
26
+ * Get a specialist by ID with layer resolution
27
+ */
28
+ getSpecialist(specialistId: string): Promise<SpecialistDefinition | null>;
29
+ /**
30
+ * Get all specialists across all layers with resolution
31
+ */
32
+ getAllSpecialists(): Promise<SpecialistDefinition[]>;
33
+ /**
34
+ * Suggest specialists based on context across all layers
35
+ */
36
+ suggestSpecialists(context: string, queryContext?: SpecialistQueryContext, limit?: number): Promise<MultiLayerSpecialistResult>;
37
+ /**
38
+ * Get specialists from a specific layer
39
+ */
40
+ getSpecialistsByLayer(layerName: string): Promise<SpecialistDefinition[]>;
41
+ /**
42
+ * Get layer statistics including specialist counts
43
+ */
44
+ getLayerStatistics(): Record<string, any>;
45
+ /**
46
+ * Resolve specialist conflicts between layers
47
+ */
48
+ private resolveSpecialistConflict;
49
+ /**
50
+ * Merge two specialist definitions
51
+ */
52
+ private mergeSpecialists;
53
+ /**
54
+ * Extend specialist with additional capabilities
55
+ */
56
+ private extendSpecialist;
57
+ /**
58
+ * Calculate specialist relevance score
59
+ */
60
+ private calculateSpecialistScore;
61
+ /**
62
+ * Get match reasons for a specialist suggestion
63
+ */
64
+ private getMatchReasons;
65
+ /**
66
+ * Get collaboration options for a specialist
67
+ */
68
+ private getCollaborationOptions;
69
+ /**
70
+ * Get cross-layer collaboration opportunities
71
+ */
72
+ private getCrossLayerCollaboration;
73
+ /**
74
+ * Find which layer a specialist comes from
75
+ */
76
+ private findSpecialistSourceLayer;
77
+ /**
78
+ * Update layer priority ordering
79
+ */
80
+ private updateLayerPriorities;
81
+ /**
82
+ * Cache management
83
+ */
84
+ private getCachedContent;
85
+ private setCachedContent;
86
+ private clearCache;
87
+ /**
88
+ * Dispose of all layers
89
+ */
90
+ dispose(): Promise<void>;
91
+ }
92
+ //# sourceMappingURL=multi-content-layer-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-content-layer-service.d.ts","sourceRoot":"","sources":["../../src/services/multi-content-layer-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EAEvB,sBAAsB,EAEtB,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,qBAAa,wBAAwB;IAOjC,OAAO,CAAC,QAAQ,CAAC,4BAA4B;IAN/C,OAAO,CAAC,MAAM,CAAiD;IAC/D,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,WAAW,CAAS;gBAGT,4BAA4B,GAAE,4BAI9C;IAGH;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,0BAA0B,GAAG,IAAI;IAMjD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAuCjE;;OAEG;IACG,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA4B/E;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAqC1D;;OAEG;IACG,kBAAkB,CACtB,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,sBAAsB,EACrC,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC,0BAA0B,CAAC;IAkCtC;;OAEG;IACG,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAmB/E;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAUzC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAoBjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAuBxB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAwDhC;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;YACW,uBAAuB;IA0BrC;;OAEG;YACW,0BAA0B;IAkBxC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAUjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ/B"}
@@ -0,0 +1,407 @@
1
+ /**
2
+ * Enhanced Multi-Content Layer Service
3
+ *
4
+ * Extends the existing layer system to support specialists alongside
5
+ * atomic topics, enabling companies/teams/projects to have custom specialists
6
+ * that override or supplement the base specialist personas.
7
+ */
8
+ export class MultiContentLayerService {
9
+ specialistResolutionStrategy;
10
+ layers = new Map();
11
+ layerPriorities = []; // Ordered by priority (high to low)
12
+ contentCache = new Map();
13
+ initialized = false;
14
+ constructor(specialistResolutionStrategy = {
15
+ conflict_resolution: 'override',
16
+ inherit_collaborations: true,
17
+ merge_expertise: false
18
+ }) {
19
+ this.specialistResolutionStrategy = specialistResolutionStrategy;
20
+ }
21
+ /**
22
+ * Add a layer to the service
23
+ */
24
+ addLayer(layer) {
25
+ this.layers.set(layer.name, layer);
26
+ this.updateLayerPriorities();
27
+ this.clearCache();
28
+ }
29
+ /**
30
+ * Initialize all layers
31
+ */
32
+ async initialize() {
33
+ const results = new Map();
34
+ console.error('🚀 Initializing multi-content layer service...');
35
+ for (const [name, layer] of this.layers) {
36
+ try {
37
+ console.error(`📋 Initializing layer: ${name}`);
38
+ const result = await layer.initialize();
39
+ results.set(name, result);
40
+ if (result.success) {
41
+ const contentCounts = result.content_counts || {};
42
+ console.error(`✅ Layer ${name}: ${Object.entries(contentCounts)
43
+ .map(([type, count]) => `${count} ${type}`)
44
+ .join(', ')}`);
45
+ }
46
+ else {
47
+ console.error(`❌ Layer ${name} failed: ${result.error}`);
48
+ }
49
+ }
50
+ catch (error) {
51
+ console.error(`❌ Layer ${name} initialization error:`, error);
52
+ results.set(name, {
53
+ success: false,
54
+ layer_name: name,
55
+ load_time_ms: 0,
56
+ content_counts: { topics: 0, specialists: 0, methodologies: 0 },
57
+ topics_loaded: 0,
58
+ indexes_loaded: 0,
59
+ error: error instanceof Error ? error.message : String(error)
60
+ });
61
+ }
62
+ }
63
+ this.initialized = true;
64
+ console.error(`🎯 Multi-content layer service initialized with ${this.layers.size} layers`);
65
+ return results;
66
+ }
67
+ /**
68
+ * Get a specialist by ID with layer resolution
69
+ */
70
+ async getSpecialist(specialistId) {
71
+ if (!this.initialized) {
72
+ await this.initialize();
73
+ }
74
+ // Check cache first
75
+ const cached = this.getCachedContent('specialists', specialistId);
76
+ if (cached) {
77
+ return cached;
78
+ }
79
+ // Search layers in priority order (highest priority first)
80
+ for (const layerName of this.layerPriorities) {
81
+ const layer = this.layers.get(layerName);
82
+ if (!layer || !(layer.supported_content_types?.includes('specialists'))) {
83
+ continue;
84
+ }
85
+ const specialist = await layer.getContent('specialists', specialistId);
86
+ if (specialist) {
87
+ this.setCachedContent('specialists', specialistId, specialist);
88
+ return specialist;
89
+ }
90
+ }
91
+ return null;
92
+ }
93
+ /**
94
+ * Get all specialists across all layers with resolution
95
+ */
96
+ async getAllSpecialists() {
97
+ if (!this.initialized) {
98
+ await this.initialize();
99
+ }
100
+ const specialistMap = new Map();
101
+ // Process layers in reverse priority order (lowest priority first)
102
+ // so higher priority layers can override
103
+ const reversePriorities = [...this.layerPriorities].reverse();
104
+ for (const layerName of reversePriorities) {
105
+ const layer = this.layers.get(layerName);
106
+ if (!layer || !(layer.supported_content_types?.includes('specialists'))) {
107
+ continue;
108
+ }
109
+ const layerSpecialistIds = layer.getContentIds('specialists');
110
+ for (const specialistId of layerSpecialistIds) {
111
+ const specialist = await layer.getContent('specialists', specialistId);
112
+ if (specialist) {
113
+ if (specialistMap.has(specialistId)) {
114
+ // Apply resolution strategy
115
+ const existing = specialistMap.get(specialistId);
116
+ const resolved = this.resolveSpecialistConflict(existing, specialist, layerName);
117
+ specialistMap.set(specialistId, resolved);
118
+ }
119
+ else {
120
+ specialistMap.set(specialistId, specialist);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ return Array.from(specialistMap.values());
126
+ }
127
+ /**
128
+ * Suggest specialists based on context across all layers
129
+ */
130
+ async suggestSpecialists(context, queryContext, limit = 5) {
131
+ const allSpecialists = await this.getAllSpecialists();
132
+ const suggestions = [];
133
+ for (const specialist of allSpecialists) {
134
+ const score = this.calculateSpecialistScore(specialist, context, queryContext);
135
+ if (score > 0) {
136
+ const collaborationOptions = await this.getCollaborationOptions(specialist);
137
+ suggestions.push({
138
+ specialist,
139
+ source_layer: this.findSpecialistSourceLayer(specialist.specialist_id),
140
+ confidence_score: score,
141
+ match_reasons: this.getMatchReasons(specialist, context, queryContext),
142
+ collaboration_options: collaborationOptions
143
+ });
144
+ }
145
+ }
146
+ // Sort by confidence score
147
+ suggestions.sort((a, b) => b.confidence_score - a.confidence_score);
148
+ const primarySuggestions = suggestions.slice(0, limit);
149
+ const alternativeSuggestions = suggestions.slice(limit, limit * 2);
150
+ return {
151
+ primary_suggestions: primarySuggestions,
152
+ alternative_specialists: alternativeSuggestions,
153
+ cross_layer_collaboration: await this.getCrossLayerCollaboration(primarySuggestions),
154
+ resolution_strategy_used: this.specialistResolutionStrategy
155
+ };
156
+ }
157
+ /**
158
+ * Get specialists from a specific layer
159
+ */
160
+ async getSpecialistsByLayer(layerName) {
161
+ const layer = this.layers.get(layerName);
162
+ if (!layer || !layer.supported_content_types.includes('specialists')) {
163
+ return [];
164
+ }
165
+ const specialistIds = layer.getContentIds('specialists');
166
+ const specialists = [];
167
+ for (const id of specialistIds) {
168
+ const specialist = await layer.getContent('specialists', id);
169
+ if (specialist) {
170
+ specialists.push(specialist);
171
+ }
172
+ }
173
+ return specialists;
174
+ }
175
+ /**
176
+ * Get layer statistics including specialist counts
177
+ */
178
+ getLayerStatistics() {
179
+ const stats = {};
180
+ for (const [name, layer] of this.layers) {
181
+ stats[name] = layer.getEnhancedStatistics();
182
+ }
183
+ return stats;
184
+ }
185
+ /**
186
+ * Resolve specialist conflicts between layers
187
+ */
188
+ resolveSpecialistConflict(existing, incoming, incomingLayerName) {
189
+ switch (this.specialistResolutionStrategy.conflict_resolution) {
190
+ case 'override':
191
+ return incoming; // Higher priority layer wins
192
+ case 'merge':
193
+ return this.mergeSpecialists(existing, incoming);
194
+ case 'extend':
195
+ return this.extendSpecialist(existing, incoming);
196
+ default:
197
+ return incoming;
198
+ }
199
+ }
200
+ /**
201
+ * Merge two specialist definitions
202
+ */
203
+ mergeSpecialists(base, override) {
204
+ return {
205
+ ...base,
206
+ ...override,
207
+ persona: {
208
+ ...base.persona,
209
+ ...override.persona,
210
+ personality: [
211
+ ...new Set([...base.persona.personality, ...override.persona.personality])
212
+ ]
213
+ },
214
+ expertise: {
215
+ primary: [...new Set([...base.expertise.primary, ...override.expertise.primary])],
216
+ secondary: [...new Set([...base.expertise.secondary, ...override.expertise.secondary])]
217
+ },
218
+ domains: [...new Set([...base.domains, ...override.domains])],
219
+ when_to_use: [...new Set([...base.when_to_use, ...override.when_to_use])],
220
+ collaboration: {
221
+ natural_handoffs: this.specialistResolutionStrategy.inherit_collaborations
222
+ ? [...new Set([...base.collaboration.natural_handoffs, ...override.collaboration.natural_handoffs])]
223
+ : override.collaboration.natural_handoffs,
224
+ team_consultations: this.specialistResolutionStrategy.inherit_collaborations
225
+ ? [...new Set([...base.collaboration.team_consultations, ...override.collaboration.team_consultations])]
226
+ : override.collaboration.team_consultations
227
+ },
228
+ related_specialists: [...new Set([...base.related_specialists, ...override.related_specialists])]
229
+ };
230
+ }
231
+ /**
232
+ * Extend specialist with additional capabilities
233
+ */
234
+ extendSpecialist(base, extension) {
235
+ // Similar to merge but preserves base identity more strongly
236
+ return {
237
+ ...base,
238
+ // Only extend non-identity fields
239
+ expertise: {
240
+ primary: base.expertise.primary, // Keep base primary expertise
241
+ secondary: [...new Set([...base.expertise.secondary, ...extension.expertise.secondary])]
242
+ },
243
+ domains: [...new Set([...base.domains, ...extension.domains])],
244
+ when_to_use: [...new Set([...base.when_to_use, ...extension.when_to_use])],
245
+ collaboration: {
246
+ natural_handoffs: [...new Set([...base.collaboration.natural_handoffs, ...extension.collaboration.natural_handoffs])],
247
+ team_consultations: [...new Set([...base.collaboration.team_consultations, ...extension.collaboration.team_consultations])]
248
+ },
249
+ related_specialists: [...new Set([...base.related_specialists, ...extension.related_specialists])],
250
+ content: `${base.content}\n\n## Extended Capabilities\n${extension.content}`
251
+ };
252
+ }
253
+ /**
254
+ * Calculate specialist relevance score
255
+ */
256
+ calculateSpecialistScore(specialist, context, queryContext) {
257
+ let score = 0;
258
+ const contextLower = context.toLowerCase();
259
+ // Check when_to_use scenarios
260
+ for (const scenario of specialist.when_to_use) {
261
+ if (contextLower.includes(scenario.toLowerCase()) ||
262
+ scenario.toLowerCase().includes(contextLower)) {
263
+ score += 10;
264
+ }
265
+ }
266
+ // Check expertise areas
267
+ for (const expertise of specialist.expertise.primary) {
268
+ if (contextLower.includes(expertise.toLowerCase())) {
269
+ score += 8;
270
+ }
271
+ }
272
+ for (const expertise of specialist.expertise.secondary) {
273
+ if (contextLower.includes(expertise.toLowerCase())) {
274
+ score += 5;
275
+ }
276
+ }
277
+ // Check domains
278
+ for (const domain of specialist.domains) {
279
+ if (contextLower.includes(domain.toLowerCase())) {
280
+ score += 6;
281
+ }
282
+ }
283
+ // Apply query context modifiers
284
+ if (queryContext) {
285
+ if (queryContext.domain && specialist.domains.includes(queryContext.domain)) {
286
+ score += 15;
287
+ }
288
+ if (queryContext.urgency === 'high') {
289
+ // Prefer specialists with quick response traits
290
+ if (specialist.persona.personality.some(p => p.toLowerCase().includes('quick') ||
291
+ p.toLowerCase().includes('direct') ||
292
+ p.toLowerCase().includes('efficient'))) {
293
+ score += 5;
294
+ }
295
+ }
296
+ }
297
+ return score;
298
+ }
299
+ /**
300
+ * Get match reasons for a specialist suggestion
301
+ */
302
+ getMatchReasons(specialist, context, queryContext) {
303
+ const reasons = [];
304
+ const contextLower = context.toLowerCase();
305
+ // Check expertise matches
306
+ const primaryMatches = specialist.expertise.primary.filter(e => contextLower.includes(e.toLowerCase()));
307
+ if (primaryMatches.length > 0) {
308
+ reasons.push(`Primary expertise: ${primaryMatches.join(', ')}`);
309
+ }
310
+ // Check scenario matches
311
+ const scenarioMatches = specialist.when_to_use.filter(s => contextLower.includes(s.toLowerCase()) || s.toLowerCase().includes(contextLower));
312
+ if (scenarioMatches.length > 0) {
313
+ reasons.push(`Relevant scenarios: ${scenarioMatches.join(', ')}`);
314
+ }
315
+ // Check domain matches
316
+ const domainMatches = specialist.domains.filter(d => contextLower.includes(d.toLowerCase()));
317
+ if (domainMatches.length > 0) {
318
+ reasons.push(`Domain expertise: ${domainMatches.join(', ')}`);
319
+ }
320
+ return reasons;
321
+ }
322
+ /**
323
+ * Get collaboration options for a specialist
324
+ */
325
+ async getCollaborationOptions(specialist) {
326
+ const handoffs = [];
327
+ const consultations = [];
328
+ // Get handoff specialists
329
+ for (const handoffId of specialist.collaboration.natural_handoffs) {
330
+ const handoffSpecialist = await this.getSpecialist(handoffId);
331
+ if (handoffSpecialist) {
332
+ handoffs.push(handoffSpecialist);
333
+ }
334
+ }
335
+ // Get consultation specialists
336
+ for (const consultationId of specialist.collaboration.team_consultations) {
337
+ const consultationSpecialist = await this.getSpecialist(consultationId);
338
+ if (consultationSpecialist) {
339
+ consultations.push(consultationSpecialist);
340
+ }
341
+ }
342
+ return { available_handoffs: handoffs, recommended_consultations: consultations };
343
+ }
344
+ /**
345
+ * Get cross-layer collaboration opportunities
346
+ */
347
+ async getCrossLayerCollaboration(suggestions) {
348
+ const crossLayerCollab = [];
349
+ for (const [layerName] of this.layers) {
350
+ const layerSpecialists = await this.getSpecialistsByLayer(layerName);
351
+ if (layerSpecialists.length > 0) {
352
+ crossLayerCollab.push({
353
+ layer_name: layerName,
354
+ specialists: layerSpecialists
355
+ });
356
+ }
357
+ }
358
+ return crossLayerCollab;
359
+ }
360
+ /**
361
+ * Find which layer a specialist comes from
362
+ */
363
+ findSpecialistSourceLayer(specialistId) {
364
+ for (const layerName of this.layerPriorities) {
365
+ const layer = this.layers.get(layerName);
366
+ if (layer?.hasContent('specialists', specialistId)) {
367
+ return layerName;
368
+ }
369
+ }
370
+ return 'unknown';
371
+ }
372
+ /**
373
+ * Update layer priority ordering
374
+ */
375
+ updateLayerPriorities() {
376
+ this.layerPriorities = Array.from(this.layers.values())
377
+ .sort((a, b) => a.priority - b.priority) // Lower number = higher priority
378
+ .map(layer => layer.name);
379
+ }
380
+ /**
381
+ * Cache management
382
+ */
383
+ getCachedContent(type, id) {
384
+ return this.contentCache.get(type)?.get(id);
385
+ }
386
+ setCachedContent(type, id, content) {
387
+ if (!this.contentCache.has(type)) {
388
+ this.contentCache.set(type, new Map());
389
+ }
390
+ this.contentCache.get(type).set(id, content);
391
+ }
392
+ clearCache() {
393
+ this.contentCache.clear();
394
+ }
395
+ /**
396
+ * Dispose of all layers
397
+ */
398
+ async dispose() {
399
+ for (const layer of this.layers.values()) {
400
+ await layer.dispose();
401
+ }
402
+ this.layers.clear();
403
+ this.clearCache();
404
+ this.initialized = false;
405
+ }
406
+ }
407
+ //# sourceMappingURL=multi-content-layer-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-content-layer-service.js","sourceRoot":"","sources":["../../src/services/multi-content-layer-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,MAAM,OAAO,wBAAwB;IAO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IAAsB,EAAE,EAAU,EAAE,OAAY;QACvE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACzC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * BC Specialist Roleplay Engine
3
+ *
4
+ * Brings specialist personas to life through personality-driven responses,
5
+ * consistent character adoption, and context-aware knowledge integration.
6
+ */
7
+ import { RoleplayEngine, RoleplayContext, SpecialistResponse, PersonalityTraits, RoleplayConfig } from '../types/roleplay-types.js';
8
+ import { SpecialistDefinition } from './specialist-loader.js';
9
+ import { SessionContext } from '../types/session-types.js';
10
+ import { MultiContentLayerService } from './multi-content-layer-service.js';
11
+ import { KnowledgeService } from './knowledge-service.js';
12
+ export declare class BCSpecialistRoleplayEngine implements RoleplayEngine {
13
+ private readonly layerService;
14
+ private readonly knowledgeService;
15
+ private config;
16
+ private responseTemplates;
17
+ private knowledgeRetriever;
18
+ constructor(layerService: MultiContentLayerService, knowledgeService: KnowledgeService, config?: Partial<RoleplayConfig>);
19
+ /**
20
+ * Generate a personality-driven response from a specialist
21
+ */
22
+ generateResponse(context: RoleplayContext): Promise<SpecialistResponse>;
23
+ /**
24
+ * Analyze user message to suggest appropriate specialist
25
+ */
26
+ suggestSpecialist(userMessage: string, currentContext?: SessionContext): Promise<{
27
+ specialist_id: string;
28
+ confidence: number;
29
+ reasoning: string;
30
+ }[]>;
31
+ /**
32
+ * Generate a specialist greeting for session start
33
+ */
34
+ generateGreeting(specialist: SpecialistDefinition, context?: Partial<SessionContext>): Promise<SpecialistResponse>;
35
+ /**
36
+ * Generate handoff message when transferring between specialists
37
+ */
38
+ generateHandoff(fromSpecialist: SpecialistDefinition, toSpecialist: SpecialistDefinition, context: RoleplayContext): Promise<{
39
+ farewell: SpecialistResponse;
40
+ introduction: SpecialistResponse;
41
+ }>;
42
+ /**
43
+ * Update configuration
44
+ */
45
+ updateConfig(config: Partial<RoleplayConfig>): void;
46
+ /**
47
+ * Get personality analysis for a specialist
48
+ */
49
+ analyzePersonality(specialist: SpecialistDefinition): PersonalityTraits;
50
+ /**
51
+ * Build personality-driven response
52
+ */
53
+ private buildPersonalityResponse;
54
+ /**
55
+ * Generate personality-driven content
56
+ */
57
+ private generatePersonalityContent;
58
+ /**
59
+ * Generate a basic personality-driven response
60
+ */
61
+ private generateBasicPersonalityResponse;
62
+ /**
63
+ * Generate style-appropriate opening
64
+ */
65
+ private getStyleApproach;
66
+ /**
67
+ * Generate knowledge-based guidance
68
+ */
69
+ private generateKnowledgeBasedGuidance;
70
+ /**
71
+ * Get specialist-specific perspective on a topic
72
+ */
73
+ private getSpecialistPerspective;
74
+ /**
75
+ * Extract key guidance points from topic content
76
+ */
77
+ private extractKeyGuidancePoints;
78
+ /**
79
+ * Extract implementation focus from content
80
+ */
81
+ private extractImplementationFocus;
82
+ /**
83
+ * Extract best practices from content
84
+ */
85
+ private extractBestPractices;
86
+ /**
87
+ * Extract pitfalls from content
88
+ */
89
+ private extractPitfalls;
90
+ /**
91
+ * Summarize content into a concise phrase
92
+ */
93
+ private summarizeIntoPhrase;
94
+ /**
95
+ * Generate general guidance when no specific topics match
96
+ */
97
+ private generateGeneralGuidance;
98
+ private initializeResponseTemplates;
99
+ private getResponseTemplates;
100
+ private selectBestTemplate;
101
+ private fillTemplate;
102
+ private extractProblemApproach;
103
+ private extractCollaborationStyle;
104
+ private extractCharacteristicPhrases;
105
+ private buildGreeting;
106
+ private buildHandoffFarewell;
107
+ private buildHandoffIntroduction;
108
+ private calculateSpecialistConfidence;
109
+ private generateSuggestionReasoning;
110
+ private generateContextUpdates;
111
+ private suggestCollaborations;
112
+ private getApplicationContext;
113
+ /**
114
+ * Extract business entity or object from user message
115
+ */
116
+ private extractEntityFromMessage;
117
+ private generateRecommendations;
118
+ private determineResponseType;
119
+ private calculateConfidenceLevel;
120
+ }
121
+ //# sourceMappingURL=roleplay-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roleplay-engine.d.ts","sourceRoot":"","sources":["../../src/services/roleplay-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EAGf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,qBAAa,0BAA2B,YAAW,cAAc;IAM7D,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IANnC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,iBAAiB,CAA8C;IACvE,OAAO,CAAC,kBAAkB,CAAqB;gBAG5B,YAAY,EAAE,wBAAwB,EACtC,gBAAgB,EAAE,gBAAgB,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