@vfarcic/dot-ai 1.23.1 → 1.24.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.
- package/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -11
- package/dist/core/knowledge-migration.d.ts +30 -0
- package/dist/core/knowledge-migration.d.ts.map +1 -0
- package/dist/core/knowledge-migration.js +289 -0
- package/dist/core/knowledge-service.d.ts +46 -0
- package/dist/core/knowledge-service.d.ts.map +1 -0
- package/dist/core/knowledge-service.js +185 -0
- package/dist/core/knowledge-types.d.ts +14 -0
- package/dist/core/knowledge-types.d.ts.map +1 -1
- package/dist/core/schema.d.ts +13 -12
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +105 -170
- package/dist/core/user-prompts-loader.d.ts.map +1 -1
- package/dist/core/user-prompts-loader.js +13 -6
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +7 -6
- package/dist/mcp/server.js +12 -0
- package/dist/tools/manage-knowledge.d.ts +0 -22
- package/dist/tools/manage-knowledge.d.ts.map +1 -1
- package/dist/tools/manage-knowledge.js +71 -131
- package/dist/tools/operate-analysis.d.ts.map +1 -1
- package/dist/tools/operate-analysis.js +7 -6
- package/dist/tools/operate.d.ts +23 -11
- package/dist/tools/operate.d.ts.map +1 -1
- package/dist/tools/operate.js +40 -58
- package/dist/tools/organizational-data.d.ts +5 -8
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +19 -74
- package/dist/tools/query.d.ts +17 -0
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +36 -1
- package/dist/tools/version.d.ts +1 -12
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +10 -19
- package/package.json +2 -2
- package/prompts/knowledge-classification.md +24 -0
- package/prompts/operate-user.md +7 -8
- package/dist/core/organizational-types.d.ts +0 -43
- package/dist/core/organizational-types.d.ts.map +0 -1
- package/dist/core/organizational-types.js +0 -8
- package/dist/core/pattern-operations.d.ts +0 -50
- package/dist/core/pattern-operations.d.ts.map +0 -1
- package/dist/core/pattern-operations.js +0 -445
- package/dist/core/pattern-types.d.ts +0 -8
- package/dist/core/pattern-types.d.ts.map +0 -1
- package/dist/core/pattern-types.js +0 -8
- package/dist/core/pattern-vector-service.d.ts +0 -27
- package/dist/core/pattern-vector-service.d.ts.map +0 -1
- package/dist/core/pattern-vector-service.js +0 -65
- package/dist/core/policy-operations.d.ts +0 -136
- package/dist/core/policy-operations.d.ts.map +0 -1
- package/dist/core/policy-operations.js +0 -623
- package/dist/core/policy-vector-service.d.ts +0 -27
- package/dist/core/policy-vector-service.d.ts.map +0 -1
- package/dist/core/policy-vector-service.js +0 -64
- package/dist/core/unified-creation-session.d.ts +0 -88
- package/dist/core/unified-creation-session.d.ts.map +0 -1
- package/dist/core/unified-creation-session.js +0 -948
- package/dist/core/unified-creation-types.d.ts +0 -68
- package/dist/core/unified-creation-types.d.ts.map +0 -1
- package/dist/core/unified-creation-types.js +0 -61
package/dist/core/schema.d.ts
CHANGED
|
@@ -170,12 +170,11 @@ export declare class ManifestValidator {
|
|
|
170
170
|
/**
|
|
171
171
|
* ResourceRecommender determines which resources best meet user needs using AI
|
|
172
172
|
* PRD #359: Uses unified plugin registry for kubectl operations
|
|
173
|
+
* PRD #375: Uses unified knowledge-base collection instead of separate pattern/policy collections
|
|
173
174
|
*/
|
|
174
175
|
export declare class ResourceRecommender {
|
|
175
176
|
private aiProvider;
|
|
176
|
-
private patternService?;
|
|
177
177
|
private capabilityService?;
|
|
178
|
-
private policyService?;
|
|
179
178
|
constructor(aiProvider?: AIProvider);
|
|
180
179
|
/**
|
|
181
180
|
* Execute kubectl via plugin system
|
|
@@ -188,6 +187,7 @@ export declare class ResourceRecommender {
|
|
|
188
187
|
findBestSolutions(intent: string, _explainResource: (resource: string) => Promise<string>, interaction_id?: string): Promise<SolutionResult>;
|
|
189
188
|
/**
|
|
190
189
|
* Phase 2: AI assembles and ranks complete solutions (replaces separate selection + ranking)
|
|
190
|
+
* PRD #375: Uses unified knowledge chunks (policy + pattern + general) instead of structured patterns.
|
|
191
191
|
*/
|
|
192
192
|
private assembleAndRankSolutions;
|
|
193
193
|
/**
|
|
@@ -195,15 +195,12 @@ export declare class ResourceRecommender {
|
|
|
195
195
|
*/
|
|
196
196
|
private parseSimpleSolutionResponse;
|
|
197
197
|
/**
|
|
198
|
-
* Load and format solution assembly prompt from file
|
|
198
|
+
* Load and format solution assembly prompt from file.
|
|
199
|
+
* PRD #375: Uses unified knowledge chunks instead of structured OrganizationalPattern objects.
|
|
199
200
|
*/
|
|
200
201
|
private loadSolutionAssemblyPrompt;
|
|
201
202
|
/**
|
|
202
|
-
*
|
|
203
|
-
*/
|
|
204
|
-
private addMissingPatternResources;
|
|
205
|
-
/**
|
|
206
|
-
* Infer cloud providers from resource name
|
|
203
|
+
* PRD #375: Infer cloud providers from resource name (kept for use in capability processing)
|
|
207
204
|
*/
|
|
208
205
|
private inferProvidersFromResourceName;
|
|
209
206
|
/**
|
|
@@ -215,10 +212,13 @@ export declare class ResourceRecommender {
|
|
|
215
212
|
*/
|
|
216
213
|
private extractGroupFromResourceName;
|
|
217
214
|
/**
|
|
218
|
-
* Phase 0: Search for relevant organizational
|
|
219
|
-
* Returns empty array if
|
|
215
|
+
* Phase 0: Search unified knowledge base for relevant organizational knowledge.
|
|
216
|
+
* Returns empty array if knowledge base is empty or unavailable (non-blocking).
|
|
217
|
+
*
|
|
218
|
+
* PRD #375: Replaces separate searchRelevantPatterns() + policy search.
|
|
219
|
+
* Results include tags so AI can distinguish policy vs pattern vs general content.
|
|
220
220
|
*/
|
|
221
|
-
private
|
|
221
|
+
private searchRelevantKnowledge;
|
|
222
222
|
/**
|
|
223
223
|
* Phase 2: Fetch detailed schemas for selected candidates
|
|
224
224
|
*/
|
|
@@ -233,7 +233,8 @@ export declare class ResourceRecommender {
|
|
|
233
233
|
*/
|
|
234
234
|
private formatClusterOptionsText;
|
|
235
235
|
/**
|
|
236
|
-
* Generate contextual questions using AI based on user intent and solution resources
|
|
236
|
+
* Generate contextual questions using AI based on user intent and solution resources.
|
|
237
|
+
* PRD #375: Uses unified knowledge base instead of separate policy service.
|
|
237
238
|
*/
|
|
238
239
|
private generateQuestionsWithAI;
|
|
239
240
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/core/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA+B7C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,MAAM,EAAE,GAAG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AGG;YACW,wBAAwB;IAwBtC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IA4EnC;;;OAGG;YACW,0BAA0B;IAiDxC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAQtC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAanC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAYpC;;;;;;OAMG;YACW,uBAAuB;IA4BrC;;OAEG;YACW,oBAAoB;IAsElC;;;OAGG;YACW,sBAAsB;IAuGpC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAchC;;;OAGG;YACW,uBAAuB;IAkOrC;;OAEG;IACG,6BAA6B,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC;IA2IzB;;OAEG;IACG,qBAAqB,CACzB,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CA4CnD"}
|
package/dist/core/schema.js
CHANGED
|
@@ -41,12 +41,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = exports.OUTPUT_PATH_QUESTION = exports.OUTPUT_FORMAT_QUESTION = void 0;
|
|
43
43
|
const plugin_registry_1 = require("./plugin-registry");
|
|
44
|
-
const pattern_vector_service_1 = require("./pattern-vector-service");
|
|
45
44
|
const capability_vector_service_1 = require("./capability-vector-service");
|
|
46
|
-
const policy_vector_service_1 = require("./policy-vector-service");
|
|
47
45
|
const shared_prompt_loader_1 = require("./shared-prompt-loader");
|
|
48
46
|
const platform_utils_1 = require("./platform-utils");
|
|
49
47
|
const constants_1 = require("./constants");
|
|
48
|
+
const knowledge_service_1 = require("./knowledge-service");
|
|
50
49
|
// PRD #343: Inline sanitization (helm-utils.ts removed)
|
|
51
50
|
function sanitizeShellArg(arg, fieldName = 'argument') {
|
|
52
51
|
if (!/^[a-zA-Z0-9\-_./:\\@]+$/.test(arg)) {
|
|
@@ -381,12 +380,11 @@ exports.ManifestValidator = ManifestValidator;
|
|
|
381
380
|
/**
|
|
382
381
|
* ResourceRecommender determines which resources best meet user needs using AI
|
|
383
382
|
* PRD #359: Uses unified plugin registry for kubectl operations
|
|
383
|
+
* PRD #375: Uses unified knowledge-base collection instead of separate pattern/policy collections
|
|
384
384
|
*/
|
|
385
385
|
class ResourceRecommender {
|
|
386
386
|
aiProvider;
|
|
387
|
-
patternService;
|
|
388
387
|
capabilityService;
|
|
389
|
-
policyService;
|
|
390
388
|
constructor(aiProvider) {
|
|
391
389
|
// Use provided AI provider or create from environment
|
|
392
390
|
this.aiProvider =
|
|
@@ -408,24 +406,8 @@ class ResourceRecommender {
|
|
|
408
406
|
console.warn('⚠️ Vector service initialization failed, capabilities disabled:', error);
|
|
409
407
|
this.capabilityService = undefined;
|
|
410
408
|
}
|
|
411
|
-
//
|
|
412
|
-
|
|
413
|
-
this.patternService = new pattern_vector_service_1.PatternVectorService('patterns');
|
|
414
|
-
console.log('✅ Pattern service initialized');
|
|
415
|
-
}
|
|
416
|
-
catch (error) {
|
|
417
|
-
console.warn('⚠️ Vector service initialization failed, patterns disabled:', error);
|
|
418
|
-
this.patternService = undefined;
|
|
419
|
-
}
|
|
420
|
-
// Initialize policy service
|
|
421
|
-
try {
|
|
422
|
-
this.policyService = new policy_vector_service_1.PolicyVectorService();
|
|
423
|
-
console.log('✅ Policy service initialized');
|
|
424
|
-
}
|
|
425
|
-
catch (error) {
|
|
426
|
-
console.warn('⚠️ Vector service initialization failed, policies disabled:', error);
|
|
427
|
-
this.policyService = undefined;
|
|
428
|
-
}
|
|
409
|
+
// PRD #375: Pattern and policy services removed — use unified knowledge-base collection
|
|
410
|
+
// searchKnowledgeBase() is called directly when needed
|
|
429
411
|
}
|
|
430
412
|
/**
|
|
431
413
|
* Execute kubectl via plugin system
|
|
@@ -466,8 +448,9 @@ class ResourceRecommender {
|
|
|
466
448
|
throw new Error(constants_1.AI_SERVICE_ERROR_TEMPLATES.PROVIDER_NOT_INITIALIZED('AI-powered resource ranking'));
|
|
467
449
|
}
|
|
468
450
|
try {
|
|
469
|
-
// Phase 0: Search for relevant organizational
|
|
470
|
-
|
|
451
|
+
// Phase 0: Search unified knowledge base for relevant organizational knowledge
|
|
452
|
+
// PRD #375: Single search replaces separate pattern + policy searches
|
|
453
|
+
const relevantKnowledge = await this.searchRelevantKnowledge(intent);
|
|
471
454
|
// Phase 1a: Replace mass resource discovery with capability-based pre-filtering
|
|
472
455
|
if (!this.capabilityService) {
|
|
473
456
|
// Capability service not available - fail fast with clear guidance
|
|
@@ -509,10 +492,9 @@ class ResourceRecommender {
|
|
|
509
492
|
resourceName: cap.data.resourceName,
|
|
510
493
|
capabilities: cap.data, // Include capability data for AI decision-making (includes namespaced, etc.)
|
|
511
494
|
}));
|
|
512
|
-
// Phase
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
const solutionResult = await this.assembleAndRankSolutions(intent, enhancedResources, relevantPatterns, interaction_id);
|
|
495
|
+
// Phase 2: AI assembles and ranks complete solutions
|
|
496
|
+
// PRD #375: Pass unified knowledge chunks (includes policy+pattern+general) to AI context
|
|
497
|
+
const solutionResult = await this.assembleAndRankSolutions(intent, capabilityFilteredResources, relevantKnowledge, interaction_id);
|
|
516
498
|
// If Helm is recommended, return early - questions will be generated from Helm chart values later
|
|
517
499
|
if (solutionResult.helmRecommendation) {
|
|
518
500
|
console.log(`🎯 Helm installation recommended for "${intent}": ${solutionResult.helmRecommendation.suggestedTool}`);
|
|
@@ -530,9 +512,10 @@ class ResourceRecommender {
|
|
|
530
512
|
}
|
|
531
513
|
/**
|
|
532
514
|
* Phase 2: AI assembles and ranks complete solutions (replaces separate selection + ranking)
|
|
515
|
+
* PRD #375: Uses unified knowledge chunks (policy + pattern + general) instead of structured patterns.
|
|
533
516
|
*/
|
|
534
|
-
async assembleAndRankSolutions(intent, availableResources,
|
|
535
|
-
const prompt = await this.loadSolutionAssemblyPrompt(intent, availableResources,
|
|
517
|
+
async assembleAndRankSolutions(intent, availableResources, knowledgeChunks, interaction_id) {
|
|
518
|
+
const prompt = await this.loadSolutionAssemblyPrompt(intent, availableResources, knowledgeChunks);
|
|
536
519
|
const response = await this.aiProvider.sendMessage(prompt, 'recommend-solution-assembly', {
|
|
537
520
|
user_intent: intent
|
|
538
521
|
? `Kubernetes solution assembly for: ${intent}`
|
|
@@ -603,9 +586,10 @@ class ResourceRecommender {
|
|
|
603
586
|
}
|
|
604
587
|
}
|
|
605
588
|
/**
|
|
606
|
-
* Load and format solution assembly prompt from file
|
|
589
|
+
* Load and format solution assembly prompt from file.
|
|
590
|
+
* PRD #375: Uses unified knowledge chunks instead of structured OrganizationalPattern objects.
|
|
607
591
|
*/
|
|
608
|
-
async loadSolutionAssemblyPrompt(intent, resources,
|
|
592
|
+
async loadSolutionAssemblyPrompt(intent, resources, knowledgeChunks) {
|
|
609
593
|
// Format resources for the prompt with capability information
|
|
610
594
|
const resourcesText = resources
|
|
611
595
|
.map((resource, index) => {
|
|
@@ -621,83 +605,30 @@ class ResourceRecommender {
|
|
|
621
605
|
Confidence: ${resource.capabilities.confidence || 1.0}`;
|
|
622
606
|
})
|
|
623
607
|
.join('\n\n');
|
|
624
|
-
// Format
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
.
|
|
633
|
-
:
|
|
608
|
+
// Format unified knowledge context for AI (replaces structured patterns)
|
|
609
|
+
// Tags indicate content type: "policy" = enforcement rule, "pattern" = reusable architecture
|
|
610
|
+
const patternsContext = knowledgeChunks.length > 0
|
|
611
|
+
? knowledgeChunks
|
|
612
|
+
.map(chunk => {
|
|
613
|
+
const typeLabel = chunk.tags.length > 0
|
|
614
|
+
? `[${chunk.tags.join(', ')}]`
|
|
615
|
+
: '[general]';
|
|
616
|
+
return `- ${typeLabel} ${chunk.content.substring(0, 300)}${chunk.content.length > 300 ? '...' : ''}
|
|
617
|
+
Source: ${chunk.uri}`;
|
|
618
|
+
})
|
|
619
|
+
.join('\n\n')
|
|
620
|
+
: 'No organizational knowledge found for this request.';
|
|
634
621
|
return (0, shared_prompt_loader_1.loadPrompt)('resource-selection', {
|
|
635
622
|
intent,
|
|
636
623
|
resources: resourcesText,
|
|
637
|
-
patterns: patternsContext,
|
|
624
|
+
patterns: patternsContext, // Template variable name kept for backward compat
|
|
638
625
|
});
|
|
639
626
|
}
|
|
627
|
+
// PRD #375: addMissingPatternResources() removed — structured OrganizationalPattern.suggestedResources
|
|
628
|
+
// no longer exist. Knowledge is stored as text chunks with tags in the unified knowledge-base.
|
|
629
|
+
// The AI reasoning layer interprets knowledge chunk content directly.
|
|
640
630
|
/**
|
|
641
|
-
*
|
|
642
|
-
*/
|
|
643
|
-
async addMissingPatternResources(capabilityResources, patterns) {
|
|
644
|
-
if (!patterns.length) {
|
|
645
|
-
return capabilityResources;
|
|
646
|
-
}
|
|
647
|
-
// Extract all resource names already in capability results
|
|
648
|
-
const existingResourceNames = new Set(capabilityResources.map(r => r.resourceName));
|
|
649
|
-
// Collect missing pattern resources
|
|
650
|
-
const missingPatternResources = [];
|
|
651
|
-
for (const pattern of patterns) {
|
|
652
|
-
if (pattern.suggestedResources) {
|
|
653
|
-
for (const suggestedResource of pattern.suggestedResources) {
|
|
654
|
-
// Skip null/undefined resources
|
|
655
|
-
if (!suggestedResource || typeof suggestedResource !== 'string') {
|
|
656
|
-
continue;
|
|
657
|
-
}
|
|
658
|
-
// Convert pattern resource format to resource name (e.g., "resourcegroups.azure.upbound.io" -> resourceName)
|
|
659
|
-
const resourceName = suggestedResource.includes('.')
|
|
660
|
-
? suggestedResource
|
|
661
|
-
: `${suggestedResource}.core`;
|
|
662
|
-
// Only add if not already present in capability results
|
|
663
|
-
if (!existingResourceNames.has(resourceName)) {
|
|
664
|
-
try {
|
|
665
|
-
// Parse resource components
|
|
666
|
-
const parts = suggestedResource.split('.');
|
|
667
|
-
const kind = parts[0]; // Use resource name as-is: resourcegroups, servicemonitors, etc.
|
|
668
|
-
const group = parts.length > 1 ? parts.slice(1).join('.') : '';
|
|
669
|
-
missingPatternResources.push({
|
|
670
|
-
kind,
|
|
671
|
-
group,
|
|
672
|
-
resourceName,
|
|
673
|
-
capabilities: {
|
|
674
|
-
resourceName,
|
|
675
|
-
description: `Resource suggested by organizational pattern: ${pattern.description}`,
|
|
676
|
-
capabilities: [
|
|
677
|
-
`organizational pattern`,
|
|
678
|
-
pattern.description.toLowerCase(),
|
|
679
|
-
],
|
|
680
|
-
providers: this.inferProvidersFromResourceName(suggestedResource),
|
|
681
|
-
complexity: 'medium',
|
|
682
|
-
useCase: `Pattern-suggested resource for: ${pattern.rationale}`,
|
|
683
|
-
confidence: 1.0, // High confidence since it's from organizational pattern
|
|
684
|
-
source: 'organizational-pattern',
|
|
685
|
-
patternId: pattern.id,
|
|
686
|
-
},
|
|
687
|
-
});
|
|
688
|
-
existingResourceNames.add(resourceName);
|
|
689
|
-
}
|
|
690
|
-
catch (error) {
|
|
691
|
-
console.warn(`Failed to parse pattern resource ${suggestedResource}:`, error);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
return [...capabilityResources, ...missingPatternResources];
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Infer cloud providers from resource name
|
|
631
|
+
* PRD #375: Infer cloud providers from resource name (kept for use in capability processing)
|
|
701
632
|
*/
|
|
702
633
|
inferProvidersFromResourceName(resourceName) {
|
|
703
634
|
if (resourceName.includes('azure'))
|
|
@@ -735,25 +666,25 @@ class ResourceRecommender {
|
|
|
735
666
|
// Note: constructApiVersionFromResourceName method removed - no longer needed
|
|
736
667
|
// API versions are extracted from kubectl explain schema content during manifest generation
|
|
737
668
|
/**
|
|
738
|
-
* Phase 0: Search for relevant organizational
|
|
739
|
-
* Returns empty array if
|
|
669
|
+
* Phase 0: Search unified knowledge base for relevant organizational knowledge.
|
|
670
|
+
* Returns empty array if knowledge base is empty or unavailable (non-blocking).
|
|
671
|
+
*
|
|
672
|
+
* PRD #375: Replaces separate searchRelevantPatterns() + policy search.
|
|
673
|
+
* Results include tags so AI can distinguish policy vs pattern vs general content.
|
|
740
674
|
*/
|
|
741
|
-
async
|
|
742
|
-
// If pattern service is not available, skip pattern search entirely
|
|
743
|
-
if (!this.patternService) {
|
|
744
|
-
console.log('📋 Pattern service unavailable, skipping pattern search - using pure AI recommendations');
|
|
745
|
-
return [];
|
|
746
|
-
}
|
|
675
|
+
async searchRelevantKnowledge(intent) {
|
|
747
676
|
try {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
677
|
+
const result = await (0, knowledge_service_1.searchKnowledgeBase)({ query: intent, limit: 10 });
|
|
678
|
+
if (result.success && result.chunks.length > 0) {
|
|
679
|
+
console.log(`📋 Found ${result.chunks.length} relevant knowledge chunks for recommend (unified KB)`);
|
|
680
|
+
return result.chunks;
|
|
681
|
+
}
|
|
682
|
+
console.log('📋 No relevant knowledge found in knowledge base - using pure AI recommendations');
|
|
683
|
+
return [];
|
|
753
684
|
}
|
|
754
685
|
catch (error) {
|
|
755
|
-
//
|
|
756
|
-
console.warn('❌
|
|
686
|
+
// Knowledge search is non-blocking - if it fails, continue without context
|
|
687
|
+
console.warn('❌ Knowledge base search failed, continuing without organizational context:', error);
|
|
757
688
|
return [];
|
|
758
689
|
}
|
|
759
690
|
}
|
|
@@ -920,33 +851,31 @@ Available Ingress Classes: ${formatResourceList(clusterOptions.ingressClasses)}
|
|
|
920
851
|
Available Node Labels: ${clusterOptions.nodeLabels.length > 0 ? clusterOptions.nodeLabels.slice(0, 10).join(', ') : 'None discovered'}`;
|
|
921
852
|
}
|
|
922
853
|
/**
|
|
923
|
-
* Generate contextual questions using AI based on user intent and solution resources
|
|
854
|
+
* Generate contextual questions using AI based on user intent and solution resources.
|
|
855
|
+
* PRD #375: Uses unified knowledge base instead of separate policy service.
|
|
924
856
|
*/
|
|
925
857
|
async generateQuestionsWithAI(intent, solution, _explainResource, interaction_id) {
|
|
926
858
|
try {
|
|
927
859
|
// Discover cluster options for dynamic questions
|
|
928
860
|
const clusterOptions = await this.discoverClusterOptions();
|
|
929
|
-
// Search for relevant policy
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
console.log(`🛡️ Found ${
|
|
943
|
-
}
|
|
944
|
-
catch (error) {
|
|
945
|
-
console.warn('⚠️ Policy search failed during question generation, proceeding without policies:', error);
|
|
861
|
+
// Search unified knowledge base for relevant policy/pattern guidance
|
|
862
|
+
// PRD #375: Replaces separate policyService.searchPolicyIntents() call
|
|
863
|
+
let knowledgeChunks = [];
|
|
864
|
+
try {
|
|
865
|
+
const resourceContext = solution.resources
|
|
866
|
+
.map(r => `${r.kind} ${r.description}`)
|
|
867
|
+
.join(' ');
|
|
868
|
+
const knowledgeResult = await (0, knowledge_service_1.searchKnowledgeBase)({
|
|
869
|
+
query: `${intent} ${resourceContext}`,
|
|
870
|
+
limit: 10,
|
|
871
|
+
});
|
|
872
|
+
if (knowledgeResult.success) {
|
|
873
|
+
knowledgeChunks = knowledgeResult.chunks;
|
|
874
|
+
console.log(`🛡️ Found ${knowledgeChunks.length} relevant knowledge chunks for question generation (unified KB)`);
|
|
946
875
|
}
|
|
947
876
|
}
|
|
948
|
-
|
|
949
|
-
console.
|
|
877
|
+
catch (error) {
|
|
878
|
+
console.warn('⚠️ Knowledge base search failed during question generation, proceeding without context:', error);
|
|
950
879
|
}
|
|
951
880
|
// Fetch resource schemas for each resource in the solution
|
|
952
881
|
const resourcesWithSchemas = await Promise.all(solution.resources.map(async (resource) => {
|
|
@@ -998,16 +927,19 @@ ${properties}`;
|
|
|
998
927
|
.join('\n\n');
|
|
999
928
|
// Format cluster options for the prompt
|
|
1000
929
|
const clusterOptionsText = this.formatClusterOptionsText(clusterOptions);
|
|
1001
|
-
// Format
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
930
|
+
// Format unified knowledge context for AI (replaces separate policy formatting)
|
|
931
|
+
// PRD #375: Tags distinguish policy, pattern, and general content
|
|
932
|
+
const policyContextText = knowledgeChunks.length > 0
|
|
933
|
+
? knowledgeChunks
|
|
934
|
+
.map(chunk => {
|
|
935
|
+
const typeLabel = chunk.tags.length > 0
|
|
936
|
+
? `[${chunk.tags.join(', ')}]`
|
|
937
|
+
: '[general]';
|
|
938
|
+
return `- ${typeLabel} ${chunk.content.substring(0, 200)}${chunk.content.length > 200 ? '...' : ''}
|
|
939
|
+
Source: ${chunk.uri}`;
|
|
940
|
+
})
|
|
1009
941
|
.join('\n')
|
|
1010
|
-
: 'No organizational
|
|
942
|
+
: 'No organizational knowledge found for this request.';
|
|
1011
943
|
// Build source_material for capabilities (Kubernetes resource-based solutions)
|
|
1012
944
|
const sourceMaterial = `## Source Material
|
|
1013
945
|
You are generating questions for Kubernetes resources. The schemas below define the available configuration options.
|
|
@@ -1107,22 +1039,22 @@ ${resourceDetails}`;
|
|
|
1107
1039
|
const { valuesYaml, readme } = await this.fetchHelmChartContent(chart);
|
|
1108
1040
|
// Discover cluster options for dynamic questions
|
|
1109
1041
|
const clusterOptions = await this.discoverClusterOptions();
|
|
1110
|
-
// Search for relevant policy
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
console.log(`🛡️ Found ${
|
|
1121
|
-
}
|
|
1122
|
-
catch (error) {
|
|
1123
|
-
console.warn('⚠️ Policy search failed during Helm question generation:', error);
|
|
1042
|
+
// Search unified knowledge base for relevant policy/pattern guidance
|
|
1043
|
+
// PRD #375: Replaces separate policyService.searchPolicyIntents() call
|
|
1044
|
+
let helmKnowledgeChunks = [];
|
|
1045
|
+
try {
|
|
1046
|
+
const helmKnowledgeResult = await (0, knowledge_service_1.searchKnowledgeBase)({
|
|
1047
|
+
query: `${intent} ${chart.chartName} helm chart installation`,
|
|
1048
|
+
limit: 10,
|
|
1049
|
+
});
|
|
1050
|
+
if (helmKnowledgeResult.success) {
|
|
1051
|
+
helmKnowledgeChunks = helmKnowledgeResult.chunks;
|
|
1052
|
+
console.log(`🛡️ Found ${helmKnowledgeChunks.length} relevant knowledge chunks for Helm question generation (unified KB)`);
|
|
1124
1053
|
}
|
|
1125
1054
|
}
|
|
1055
|
+
catch (error) {
|
|
1056
|
+
console.warn('⚠️ Knowledge base search failed during Helm question generation:', error);
|
|
1057
|
+
}
|
|
1126
1058
|
// Build source_material for Helm chart
|
|
1127
1059
|
const sourceMaterial = `## Source Material
|
|
1128
1060
|
You are generating questions for a Helm chart installation. The values.yaml and README below define the available configuration options.
|
|
@@ -1139,16 +1071,19 @@ ${valuesYaml || '# No values.yaml available'}
|
|
|
1139
1071
|
|
|
1140
1072
|
## README
|
|
1141
1073
|
${readme || 'No README available'}`;
|
|
1142
|
-
// Format
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1074
|
+
// Format unified knowledge context (replaces policy formatting)
|
|
1075
|
+
// PRD #375: Tags distinguish policy, pattern, and general content
|
|
1076
|
+
const policyContextText = helmKnowledgeChunks.length > 0
|
|
1077
|
+
? helmKnowledgeChunks
|
|
1078
|
+
.map(chunk => {
|
|
1079
|
+
const typeLabel = chunk.tags.length > 0
|
|
1080
|
+
? `[${chunk.tags.join(', ')}]`
|
|
1081
|
+
: '[general]';
|
|
1082
|
+
return `- ${typeLabel} ${chunk.content.substring(0, 200)}${chunk.content.length > 200 ? '...' : ''}
|
|
1083
|
+
Source: ${chunk.uri}`;
|
|
1084
|
+
})
|
|
1150
1085
|
.join('\n')
|
|
1151
|
-
: 'No organizational
|
|
1086
|
+
: 'No organizational knowledge found for this request.';
|
|
1152
1087
|
// Format cluster options for the prompt
|
|
1153
1088
|
const clusterOptionsText = this.formatClusterOptionsText(clusterOptions);
|
|
1154
1089
|
// Generate questions using the shared prompt
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-prompts-loader.d.ts","sourceRoot":"","sources":["../../src/core/user-prompts-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAO1C,OAAO,EAAE,MAAM,EAA8B,MAAM,kBAAkB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,UAAU,UAAU;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AA0CD;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;GAQG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAY5D;AAgBD,mFAAmF;AACnF,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,kEAAkE;AAClE,MAAM,WAAW,yBAAyB;IACxC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;CAClC;
|
|
1
|
+
{"version":3,"file":"user-prompts-loader.d.ts","sourceRoot":"","sources":["../../src/core/user-prompts-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAO1C,OAAO,EAAE,MAAM,EAA8B,MAAM,kBAAkB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;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mBAAmB,GAAG,MAAM,CAS3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,mBAAmB,GAC5B,iBAAiB,CAqDnB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAwB1C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUzD;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoBlD;AA0aD;;;;;;;;;GASG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,OAAe,EAC7B,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,OAAO,CAAC,MAAM,EAAE,CAAC,CA2HnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAEpD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,UAAU,GAAG,IAAI,CAE5D"}
|
|
@@ -165,8 +165,7 @@ function getIngestedCacheRoot() {
|
|
|
165
165
|
* writeFileSync calls to follow (TOCTOU) — the same hardening the token-bearing
|
|
166
166
|
* clone path uses in createIsolatedCloneRoot.
|
|
167
167
|
*/
|
|
168
|
-
function createIngestedStagingDir() {
|
|
169
|
-
const root = getIngestedCacheRoot();
|
|
168
|
+
function createIngestedStagingDir(root) {
|
|
170
169
|
fs.mkdirSync(root, { recursive: true });
|
|
171
170
|
const dir = fs.mkdtempSync(path.join(root, `staging-${crypto.randomUUID()}-`));
|
|
172
171
|
try {
|
|
@@ -333,8 +332,13 @@ function ingestPromptsSource(input, logger) {
|
|
|
333
332
|
// EISDIR, disk full, …) NEVER destroys the previously-cached entry — the old
|
|
334
333
|
// slot is removed only on the success path, and the in-memory registry is
|
|
335
334
|
// updated last.
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
// PRD #647 F3 — resolve the cache root ONCE so the staging dir and the final
|
|
336
|
+
// slot are guaranteed to live on the same filesystem. getIngestedCacheRoot()
|
|
337
|
+
// can otherwise resolve to a different device between calls (project tmp vs the
|
|
338
|
+
// os.tmpdir() fallback), which made the promote rename fail with EXDEV.
|
|
339
|
+
const cacheRoot = getIngestedCacheRoot();
|
|
340
|
+
const finalDir = path.join(cacheRoot, crypto.createHash('sha256').update(identifier).digest('hex'));
|
|
341
|
+
const stagingDir = createIngestedStagingDir(cacheRoot);
|
|
338
342
|
// PRD #647 N3 — count DISTINCT written paths: two manifest entries that
|
|
339
343
|
// sanitize to the same path collapse to one file on disk, so fileCount must
|
|
340
344
|
// not double-count them.
|
|
@@ -573,8 +577,11 @@ function getCacheDirectory() {
|
|
|
573
577
|
if (!fs.existsSync(parentTmp)) {
|
|
574
578
|
fs.mkdirSync(parentTmp, { recursive: true });
|
|
575
579
|
}
|
|
576
|
-
// Test if we can write to it
|
|
577
|
-
|
|
580
|
+
// Test if we can write to it. Use a unique probe name so concurrent callers
|
|
581
|
+
// never unlink each other's probe — a shared name races (one caller's unlink
|
|
582
|
+
// makes another's write/unlink throw), wrongly forcing the os.tmpdir()
|
|
583
|
+
// fallback and splitting a single ingest's writes across filesystems.
|
|
584
|
+
const testFile = path.join(parentTmp, `.write-test-${process.pid}-${crypto.randomUUID()}`);
|
|
578
585
|
fs.writeFileSync(testFile, 'test');
|
|
579
586
|
fs.unlinkSync(testFile);
|
|
580
587
|
return projectTmp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,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G;YACW,eAAe;IAwW7B;;;;OAIG;YACW,kBAAkB;IAkHhC;;;OAGG;YACW,oBAAoB;IAiDlC;;;;OAIG;YACW,sBAAsB;IAuEpC;;;;OAIG;YACW,2BAA2B;IAyQzC;;;;OAIG;YACW,kBAAkB;IA6PhC;;OAEG;YACW,+BAA+B;IA8D7C;;OAEG;YACW,gBAAgB;IAwG9B;;OAEG;YACW,eAAe;IAkD7B;;OAEG;YACW,gBAAgB;IA6E9B;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;YACW,gBAAgB;IAS9B;;OAEG;YACW,iBAAiB;IAyB/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMvC;;OAEG;IACH,SAAS,IAAI,aAAa;IAI1B;;;OAGG;IACH,gBAAgB,IAAI,iBAAiB;CAGtC"}
|
|
@@ -61,7 +61,7 @@ const capability_tools_1 = require("../core/capability-tools");
|
|
|
61
61
|
const resource_tools_1 = require("../core/resource-tools");
|
|
62
62
|
const mermaid_tools_1 = require("../core/mermaid-tools");
|
|
63
63
|
const plugin_registry_1 = require("../core/plugin-registry");
|
|
64
|
-
const
|
|
64
|
+
const knowledge_service_1 = require("../core/knowledge-service");
|
|
65
65
|
const user_management_1 = require("./oauth/user-management");
|
|
66
66
|
const request_context_1 = require("./request-context");
|
|
67
67
|
const rbac_1 = require("../core/rbac");
|
|
@@ -106,13 +106,14 @@ function sanitizeRequestUrlForLogging(url) {
|
|
|
106
106
|
try {
|
|
107
107
|
// req.url is path-relative; provide a dummy base for URL parsing.
|
|
108
108
|
const parsed = new node_url_1.URL(url, 'http://internal.invalid');
|
|
109
|
+
// Both `?repo=` and `?source=` are scrubbed with the deep helper (userinfo +
|
|
110
|
+
// credential-bearing query params) so a token embedded anywhere in the URL —
|
|
111
|
+
// e.g. `?repo=https://user:tok@host` or `?source=...?token=...` — never
|
|
112
|
+
// appears unscrubbed in the log.
|
|
109
113
|
const repo = parsed.searchParams.get('repo');
|
|
110
114
|
if (repo) {
|
|
111
|
-
parsed.searchParams.set('repo', (0, user_prompts_loader_1.
|
|
115
|
+
parsed.searchParams.set('repo', (0, user_prompts_loader_1.scrubSourceUrl)(repo));
|
|
112
116
|
}
|
|
113
|
-
// PRD #647 M5 (F2): `?source=` is scrubbed with the same deep helper used
|
|
114
|
-
// for the echoed `source` (userinfo + credential-bearing query params), so
|
|
115
|
-
// `?source=https://user:tok@host` never appears unscrubbed in the log.
|
|
116
117
|
const source = parsed.searchParams.get('source');
|
|
117
118
|
if (source) {
|
|
118
119
|
parsed.searchParams.set('source', (0, user_prompts_loader_1.scrubSourceUrl)(source));
|
|
@@ -2136,7 +2137,7 @@ class RestApiRouter {
|
|
|
2136
2137
|
};
|
|
2137
2138
|
}
|
|
2138
2139
|
const searchInput = input;
|
|
2139
|
-
const result = await (0,
|
|
2140
|
+
const result = await (0, knowledge_service_1.searchKnowledgeBase)({
|
|
2140
2141
|
query: searchInput.query,
|
|
2141
2142
|
limit,
|
|
2142
2143
|
uriFilter,
|