@vfarcic/dot-ai 0.104.0 → 0.106.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/README.md +6 -1
- package/dist/core/ai-provider-factory.d.ts +90 -0
- package/dist/core/ai-provider-factory.d.ts.map +1 -0
- package/dist/core/ai-provider-factory.js +187 -0
- package/dist/core/ai-provider.interface.d.ts +208 -0
- package/dist/core/ai-provider.interface.d.ts.map +1 -0
- package/dist/core/ai-provider.interface.js +14 -0
- package/dist/core/capabilities.d.ts +3 -3
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +4 -4
- package/dist/core/capability-scan-workflow.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.js +29 -14
- package/dist/core/doc-testing-session.d.ts +1 -1
- package/dist/core/doc-testing-session.js +1 -1
- package/dist/core/error-handling.js +2 -2
- package/dist/core/index.d.ts +4 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -22
- package/dist/core/platform-operations.d.ts +9 -15
- package/dist/core/platform-operations.d.ts.map +1 -1
- package/dist/core/platform-operations.js +28 -49
- package/dist/core/platform-utils.d.ts +16 -0
- package/dist/core/platform-utils.d.ts.map +1 -0
- package/dist/core/platform-utils.js +68 -0
- package/dist/core/providers/anthropic-provider.d.ts +44 -0
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/core/providers/anthropic-provider.js +281 -0
- package/dist/core/providers/provider-debug-utils.d.ts +27 -0
- package/dist/core/providers/provider-debug-utils.d.ts.map +1 -0
- package/dist/core/providers/provider-debug-utils.js +122 -0
- package/dist/core/providers/vercel-provider.d.ts +47 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -0
- package/dist/core/providers/vercel-provider.js +152 -0
- package/dist/core/schema.d.ts +4 -7
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +13 -11
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +13 -14
- package/dist/interfaces/mcp.d.ts +1 -1
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +29 -8
- package/dist/interfaces/rest-api.js +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +8 -10
- package/dist/tools/build-platform.js +3 -3
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +7 -8
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +3 -2
- package/dist/tools/platform/discover-operations.tool.d.ts +35 -0
- package/dist/tools/platform/discover-operations.tool.d.ts.map +1 -0
- package/dist/tools/platform/discover-operations.tool.js +88 -0
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +50 -30
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +23 -39
- package/dist/tools/version.d.ts +3 -2
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +35 -23
- package/package.json +5 -2
- package/prompts/{parse-script-operations.md → platform-operations-parse-script-help.md} +4 -8
- package/prompts/question-generation.md +31 -3
- package/dist/core/claude.d.ts +0 -88
- package/dist/core/claude.d.ts.map +0 -1
- package/dist/core/claude.js +0 -414
|
@@ -40,7 +40,7 @@ export declare class DocTestingSessionManager {
|
|
|
40
40
|
getActiveSessions(args: any): ValidationSession[];
|
|
41
41
|
private generateSessionId;
|
|
42
42
|
/**
|
|
43
|
-
* Load phase prompt from file
|
|
43
|
+
* Load phase prompt from file
|
|
44
44
|
*/
|
|
45
45
|
private loadPhasePrompt;
|
|
46
46
|
private getNextPhase;
|
|
@@ -271,7 +271,7 @@ The system manages session state and workflow progression automatically.`;
|
|
|
271
271
|
return `${timestamp}-${random}`;
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
|
-
* Load phase prompt from file
|
|
274
|
+
* Load phase prompt from file
|
|
275
275
|
*/
|
|
276
276
|
loadPhasePrompt(phase, session) {
|
|
277
277
|
// Prepare template variables for all phases
|
|
@@ -325,7 +325,7 @@ class ErrorHandler {
|
|
|
325
325
|
if (message.includes('authentication') || message.includes('unauthorized')) {
|
|
326
326
|
return ErrorCategory.AUTHENTICATION;
|
|
327
327
|
}
|
|
328
|
-
if (message.includes('
|
|
328
|
+
if (message.includes('ai') || message.includes('api key invalid') || message.includes('model')) {
|
|
329
329
|
return ErrorCategory.AI_SERVICE;
|
|
330
330
|
}
|
|
331
331
|
if (message.includes('validation') || message.includes('invalid')) {
|
|
@@ -376,7 +376,7 @@ class ErrorHandler {
|
|
|
376
376
|
];
|
|
377
377
|
case ErrorCategory.AI_SERVICE:
|
|
378
378
|
return [
|
|
379
|
-
'Check
|
|
379
|
+
'Check AI provider API key environment variable is set',
|
|
380
380
|
'Verify API key is valid and has sufficient credits',
|
|
381
381
|
'Try again after a short delay'
|
|
382
382
|
];
|
package/dist/core/index.d.ts
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
import { KubernetesDiscovery } from './discovery';
|
|
7
7
|
import { MemorySystem } from './memory';
|
|
8
8
|
import { WorkflowEngine } from './workflow';
|
|
9
|
-
import {
|
|
9
|
+
import { AIProvider } from './ai-provider.interface';
|
|
10
10
|
import { SchemaParser, ManifestValidator, ResourceRecommender } from './schema';
|
|
11
11
|
export interface CoreConfig {
|
|
12
12
|
kubernetesConfig?: string;
|
|
13
|
-
anthropicApiKey?: string;
|
|
14
13
|
}
|
|
15
14
|
export declare class DotAI {
|
|
16
15
|
private config;
|
|
@@ -18,7 +17,7 @@ export declare class DotAI {
|
|
|
18
17
|
readonly discovery: KubernetesDiscovery;
|
|
19
18
|
readonly memory: MemorySystem;
|
|
20
19
|
readonly workflow: WorkflowEngine;
|
|
21
|
-
readonly
|
|
20
|
+
readonly ai: AIProvider;
|
|
22
21
|
readonly schema: {
|
|
23
22
|
parser: SchemaParser;
|
|
24
23
|
validator: ManifestValidator;
|
|
@@ -27,17 +26,16 @@ export declare class DotAI {
|
|
|
27
26
|
rankResources: (intent: string) => Promise<any>;
|
|
28
27
|
};
|
|
29
28
|
constructor(config?: CoreConfig);
|
|
30
|
-
private validateConfig;
|
|
31
29
|
initialize(): Promise<void>;
|
|
32
30
|
initializeWithoutCluster(): Promise<void>;
|
|
33
31
|
isInitialized(): boolean;
|
|
34
32
|
getVersion(): string;
|
|
35
|
-
getAnthropicApiKey(): string | undefined;
|
|
36
33
|
}
|
|
37
34
|
export { KubernetesDiscovery } from './discovery';
|
|
38
35
|
export { MemorySystem } from './memory';
|
|
39
36
|
export { WorkflowEngine } from './workflow';
|
|
40
|
-
export {
|
|
37
|
+
export { AIProvider, AIResponse, IntentAnalysisResult, AIProviderConfig } from './ai-provider.interface';
|
|
38
|
+
export { createAIProvider, AIProviderFactory } from './ai-provider-factory';
|
|
41
39
|
export { SchemaParser, ManifestValidator, ResourceRecommender } from './schema';
|
|
42
40
|
export { OrganizationalPattern, CreatePatternRequest } from './pattern-types';
|
|
43
41
|
export { BaseOrganizationalEntity, PolicyIntent, CreatePolicyIntentRequest, DeployedPolicyReference } from './organizational-types';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cA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BAAuB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACpI,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE5G,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC3G,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGpH,eAAe,KAAK,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Shared intelligence for both CLI and MCP interfaces
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.OpenAIEmbeddingProvider = exports.EmbeddingService = exports.CapabilityVectorService = exports.PolicyVectorService = exports.PatternVectorService = exports.BaseVectorService = exports.VectorDBService = exports.deserializePattern = exports.serializePattern = exports.createPattern = exports.validatePattern = exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = exports.
|
|
8
|
+
exports.OpenAIEmbeddingProvider = exports.EmbeddingService = exports.CapabilityVectorService = exports.PolicyVectorService = exports.PatternVectorService = exports.BaseVectorService = exports.VectorDBService = exports.deserializePattern = exports.serializePattern = exports.createPattern = exports.validatePattern = exports.ResourceRecommender = exports.ManifestValidator = exports.SchemaParser = exports.AIProviderFactory = exports.createAIProvider = exports.WorkflowEngine = exports.MemorySystem = exports.KubernetesDiscovery = exports.DotAI = void 0;
|
|
9
9
|
const discovery_1 = require("./discovery");
|
|
10
10
|
const memory_1 = require("./memory");
|
|
11
11
|
const workflow_1 = require("./workflow");
|
|
12
|
-
const
|
|
12
|
+
const ai_provider_factory_1 = require("./ai-provider-factory");
|
|
13
13
|
const schema_1 = require("./schema");
|
|
14
14
|
class DotAI {
|
|
15
15
|
config;
|
|
@@ -17,14 +17,11 @@ class DotAI {
|
|
|
17
17
|
discovery;
|
|
18
18
|
memory;
|
|
19
19
|
workflow;
|
|
20
|
-
|
|
20
|
+
ai;
|
|
21
21
|
schema;
|
|
22
22
|
constructor(config = {}) {
|
|
23
|
-
this.validateConfig(config);
|
|
24
|
-
// Centralize environment variable reading
|
|
25
23
|
this.config = {
|
|
26
|
-
kubernetesConfig: config.kubernetesConfig || process.env.KUBECONFIG
|
|
27
|
-
anthropicApiKey: config.anthropicApiKey || process.env.ANTHROPIC_API_KEY
|
|
24
|
+
kubernetesConfig: config.kubernetesConfig || process.env.KUBECONFIG
|
|
28
25
|
};
|
|
29
26
|
// Initialize modules
|
|
30
27
|
this.discovery = new discovery_1.KubernetesDiscovery({
|
|
@@ -32,13 +29,12 @@ class DotAI {
|
|
|
32
29
|
});
|
|
33
30
|
this.memory = new memory_1.MemorySystem();
|
|
34
31
|
this.workflow = new workflow_1.WorkflowEngine();
|
|
35
|
-
this.
|
|
32
|
+
this.ai = (0, ai_provider_factory_1.createAIProvider)();
|
|
36
33
|
// Initialize schema components
|
|
37
34
|
const parser = new schema_1.SchemaParser();
|
|
38
35
|
const validator = new schema_1.ManifestValidator();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
null;
|
|
36
|
+
// ResourceRecommender uses the AI provider directly
|
|
37
|
+
const ranker = new schema_1.ResourceRecommender(this.ai);
|
|
42
38
|
this.schema = {
|
|
43
39
|
parser,
|
|
44
40
|
validator,
|
|
@@ -68,7 +64,7 @@ class DotAI {
|
|
|
68
64
|
},
|
|
69
65
|
rankResources: async (intent) => {
|
|
70
66
|
if (!ranker) {
|
|
71
|
-
throw new Error('ResourceRanker not available.
|
|
67
|
+
throw new Error('ResourceRanker not available. AI provider API key is required for AI-powered ranking.');
|
|
72
68
|
}
|
|
73
69
|
// Create discovery function with proper binding
|
|
74
70
|
const explainResourceFn = async (resource) => await this.discovery.explainResource(resource);
|
|
@@ -76,11 +72,6 @@ class DotAI {
|
|
|
76
72
|
}
|
|
77
73
|
};
|
|
78
74
|
}
|
|
79
|
-
validateConfig(config) {
|
|
80
|
-
if (config.anthropicApiKey === '') {
|
|
81
|
-
throw new Error('Invalid configuration: Empty API key provided');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
75
|
async initialize() {
|
|
85
76
|
try {
|
|
86
77
|
// Initialize all modules
|
|
@@ -112,9 +103,6 @@ class DotAI {
|
|
|
112
103
|
getVersion() {
|
|
113
104
|
return '0.1.0';
|
|
114
105
|
}
|
|
115
|
-
getAnthropicApiKey() {
|
|
116
|
-
return this.config.anthropicApiKey;
|
|
117
|
-
}
|
|
118
106
|
}
|
|
119
107
|
exports.DotAI = DotAI;
|
|
120
108
|
// Re-export all modules for convenience
|
|
@@ -124,8 +112,9 @@ var memory_2 = require("./memory");
|
|
|
124
112
|
Object.defineProperty(exports, "MemorySystem", { enumerable: true, get: function () { return memory_2.MemorySystem; } });
|
|
125
113
|
var workflow_2 = require("./workflow");
|
|
126
114
|
Object.defineProperty(exports, "WorkflowEngine", { enumerable: true, get: function () { return workflow_2.WorkflowEngine; } });
|
|
127
|
-
var
|
|
128
|
-
Object.defineProperty(exports, "
|
|
115
|
+
var ai_provider_factory_2 = require("./ai-provider-factory");
|
|
116
|
+
Object.defineProperty(exports, "createAIProvider", { enumerable: true, get: function () { return ai_provider_factory_2.createAIProvider; } });
|
|
117
|
+
Object.defineProperty(exports, "AIProviderFactory", { enumerable: true, get: function () { return ai_provider_factory_2.AIProviderFactory; } });
|
|
129
118
|
var schema_2 = require("./schema");
|
|
130
119
|
Object.defineProperty(exports, "SchemaParser", { enumerable: true, get: function () { return schema_2.SchemaParser; } });
|
|
131
120
|
Object.defineProperty(exports, "ManifestValidator", { enumerable: true, get: function () { return schema_2.ManifestValidator; } });
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Operations Discovery
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Orchestrates tool-based discovery and mapping of Nu shell script operations.
|
|
5
|
+
* All data fetching logic lives in tools, this module handles orchestration.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { AIProvider } from './ai-provider.interface';
|
|
8
8
|
import { Logger } from './error-handling';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
command: string[];
|
|
12
|
-
}
|
|
13
|
-
export interface Operation {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
operations: OperationCommand[];
|
|
17
|
-
}
|
|
9
|
+
export { Operation, OperationCommand } from '../tools/platform/discover-operations.tool';
|
|
10
|
+
import { Operation } from '../tools/platform/discover-operations.tool';
|
|
18
11
|
export interface MatchedOperation {
|
|
19
12
|
tool: string;
|
|
20
13
|
operation: string;
|
|
@@ -45,13 +38,14 @@ export interface PlatformSession {
|
|
|
45
38
|
updatedAt: string;
|
|
46
39
|
}
|
|
47
40
|
/**
|
|
48
|
-
* Discover available operations from Nu shell scripts
|
|
41
|
+
* Discover available operations from Nu shell scripts
|
|
42
|
+
* Uses tool for data fetching and prompt injection for AI parsing
|
|
49
43
|
*/
|
|
50
|
-
export declare function discoverOperations(
|
|
44
|
+
export declare function discoverOperations(aiProvider: AIProvider, logger: Logger): Promise<Operation[]>;
|
|
51
45
|
/**
|
|
52
46
|
* Map user intent to a specific operation using AI
|
|
53
47
|
*/
|
|
54
|
-
export declare function mapIntentToOperation(intent: string, operations: Operation[],
|
|
48
|
+
export declare function mapIntentToOperation(intent: string, operations: Operation[], aiProvider: AIProvider, logger: Logger): Promise<IntentMapping>;
|
|
55
49
|
/**
|
|
56
50
|
* Get parameters for a specific operation using Nushell's structured JSON output
|
|
57
51
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-operations.d.ts","sourceRoot":"","sources":["../../src/core/platform-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"platform-operations.d.ts","sourceRoot":"","sources":["../../src/core/platform-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAGzF,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EA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ACpC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAkE/F"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Platform Operations Discovery
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Orchestrates tool-based discovery and mapping of Nu shell script operations.
|
|
6
|
+
* All data fetching logic lives in tools, this module handles orchestration.
|
|
7
7
|
*/
|
|
8
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
@@ -45,52 +45,31 @@ exports.getOperationParameters = getOperationParameters;
|
|
|
45
45
|
exports.createSession = createSession;
|
|
46
46
|
exports.loadSession = loadSession;
|
|
47
47
|
exports.executeOperation = executeOperation;
|
|
48
|
-
const child_process_1 = require("child_process");
|
|
49
|
-
const util_1 = require("util");
|
|
50
48
|
const fs = __importStar(require("fs"));
|
|
51
49
|
const path = __importStar(require("path"));
|
|
52
|
-
const
|
|
50
|
+
const platform_utils_1 = require("./platform-utils");
|
|
53
51
|
/**
|
|
54
|
-
*
|
|
52
|
+
* Discover available operations from Nu shell scripts
|
|
53
|
+
* Uses tool for data fetching and prompt injection for AI parsing
|
|
55
54
|
*/
|
|
56
|
-
function
|
|
57
|
-
// In CommonJS (after TypeScript compilation), __dirname is available
|
|
58
|
-
// Go up from dist/core/ to project root, then into scripts/
|
|
59
|
-
return path.join(__dirname, '..', '..', 'scripts');
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Strip markdown code blocks from AI response
|
|
63
|
-
*/
|
|
64
|
-
function stripMarkdownCodeBlocks(content) {
|
|
65
|
-
let jsonContent = content.trim();
|
|
66
|
-
if (jsonContent.startsWith('```json')) {
|
|
67
|
-
jsonContent = jsonContent.replace(/^```json\s*/, '').replace(/\s*```$/, '');
|
|
68
|
-
}
|
|
69
|
-
else if (jsonContent.startsWith('```')) {
|
|
70
|
-
jsonContent = jsonContent.replace(/^```\s*/, '').replace(/\s*```$/, '');
|
|
71
|
-
}
|
|
72
|
-
return jsonContent;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Discover available operations from Nu shell scripts using AI parsing
|
|
76
|
-
*/
|
|
77
|
-
async function discoverOperations(claudeIntegration, logger) {
|
|
55
|
+
async function discoverOperations(aiProvider, logger) {
|
|
78
56
|
try {
|
|
79
|
-
//
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
// Import the tool execution function
|
|
58
|
+
const { executeDiscoverOperations } = await Promise.resolve().then(() => __importStar(require('../tools/platform/discover-operations.tool')));
|
|
59
|
+
// Execute tool directly to get help output
|
|
60
|
+
const toolResult = await executeDiscoverOperations({}, aiProvider, logger);
|
|
61
|
+
if (!toolResult.success || !toolResult.helpOutput) {
|
|
62
|
+
throw new Error(toolResult.error || 'Failed to get Nu script help output');
|
|
84
63
|
}
|
|
85
|
-
// Load
|
|
86
|
-
const promptPath = path.join(process.cwd(), 'prompts', 'parse-script-
|
|
64
|
+
// Load the parsing prompt template
|
|
65
|
+
const promptPath = path.join(process.cwd(), 'prompts', 'platform-operations-parse-script-help.md');
|
|
87
66
|
const promptTemplate = fs.readFileSync(promptPath, 'utf8');
|
|
88
|
-
//
|
|
89
|
-
const prompt = promptTemplate.replace('{helpOutput}',
|
|
90
|
-
//
|
|
91
|
-
const response = await
|
|
92
|
-
//
|
|
93
|
-
const jsonContent = stripMarkdownCodeBlocks(response.content);
|
|
67
|
+
// Inject help output into prompt
|
|
68
|
+
const prompt = promptTemplate.replace('{helpOutput}', toolResult.helpOutput);
|
|
69
|
+
// Single AI call with injected data
|
|
70
|
+
const response = await aiProvider.sendMessage(prompt, 'platform-discover-operations');
|
|
71
|
+
// Parse operations from AI response
|
|
72
|
+
const jsonContent = (0, platform_utils_1.stripMarkdownCodeBlocks)(response.content);
|
|
94
73
|
const operations = JSON.parse(jsonContent);
|
|
95
74
|
logger.info?.('Discovered operations from Nu scripts', {
|
|
96
75
|
count: operations.length
|
|
@@ -105,7 +84,7 @@ async function discoverOperations(claudeIntegration, logger) {
|
|
|
105
84
|
/**
|
|
106
85
|
* Map user intent to a specific operation using AI
|
|
107
86
|
*/
|
|
108
|
-
async function mapIntentToOperation(intent, operations,
|
|
87
|
+
async function mapIntentToOperation(intent, operations, aiProvider, logger) {
|
|
109
88
|
try {
|
|
110
89
|
// Load AI prompt template for intent mapping
|
|
111
90
|
const promptPath = path.join(process.cwd(), 'prompts', 'map-intent-to-operation.md');
|
|
@@ -114,10 +93,10 @@ async function mapIntentToOperation(intent, operations, claudeIntegration, logge
|
|
|
114
93
|
const prompt = promptTemplate
|
|
115
94
|
.replace('{intent}', intent)
|
|
116
95
|
.replace('{operations}', JSON.stringify(operations, null, 2));
|
|
117
|
-
// Send to
|
|
118
|
-
const response = await
|
|
96
|
+
// Send to AI provider for AI-powered intent matching
|
|
97
|
+
const response = await aiProvider.sendMessage(prompt, 'platform-map-intent');
|
|
119
98
|
// Strip markdown code blocks and parse JSON
|
|
120
|
-
const jsonContent = stripMarkdownCodeBlocks(response.content);
|
|
99
|
+
const jsonContent = (0, platform_utils_1.stripMarkdownCodeBlocks)(response.content);
|
|
121
100
|
const mapping = JSON.parse(jsonContent);
|
|
122
101
|
// Validate that AI returned required fields
|
|
123
102
|
if (mapping.matched && mapping.operation) {
|
|
@@ -146,9 +125,9 @@ async function getOperationParameters(command, logger) {
|
|
|
146
125
|
// Build the full command name that Nushell expects
|
|
147
126
|
const commandName = `main ${command.join(' ')}`;
|
|
148
127
|
// Execute Nu script to get structured command metadata
|
|
149
|
-
const scriptPath = path.join(getScriptsDir(), 'dot.nu');
|
|
128
|
+
const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
|
|
150
129
|
const nuCommand = `source ${scriptPath}; scope commands | where name == "${commandName}" | to json`;
|
|
151
|
-
const { stdout, stderr } = await execAsync(`nu -c '${nuCommand}'`);
|
|
130
|
+
const { stdout, stderr } = await (0, platform_utils_1.execAsync)(`nu -c '${nuCommand}'`);
|
|
152
131
|
if (stderr) {
|
|
153
132
|
logger.warn?.('Nu scope commands produced stderr', { stderr });
|
|
154
133
|
}
|
|
@@ -278,7 +257,7 @@ async function executeOperation(session, answers, logger) {
|
|
|
278
257
|
}
|
|
279
258
|
}
|
|
280
259
|
// Build Nu script command
|
|
281
|
-
const scriptPath = path.join(getScriptsDir(), 'dot.nu');
|
|
260
|
+
const scriptPath = path.join((0, platform_utils_1.getScriptsDir)(), 'dot.nu');
|
|
282
261
|
const command = session.matchedOperation.command;
|
|
283
262
|
// Build command arguments
|
|
284
263
|
const args = [];
|
|
@@ -294,7 +273,7 @@ async function executeOperation(session, answers, logger) {
|
|
|
294
273
|
sessionId: session.sessionId,
|
|
295
274
|
command: fullCommand
|
|
296
275
|
});
|
|
297
|
-
const { stdout, stderr } = await execAsync(fullCommand);
|
|
276
|
+
const { stdout, stderr } = await (0, platform_utils_1.execAsync)(fullCommand);
|
|
298
277
|
if (stderr) {
|
|
299
278
|
logger.warn?.('Operation produced stderr', { stderr });
|
|
300
279
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utility functions for platform operations and tools.
|
|
5
|
+
*/
|
|
6
|
+
import { exec } from 'child_process';
|
|
7
|
+
export declare const execAsync: typeof exec.__promisify__;
|
|
8
|
+
/**
|
|
9
|
+
* Get the scripts directory path, works in both development and installed npm package
|
|
10
|
+
*/
|
|
11
|
+
export declare function getScriptsDir(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Strip markdown code blocks from AI response
|
|
14
|
+
*/
|
|
15
|
+
export declare function stripMarkdownCodeBlocks(content: string): string;
|
|
16
|
+
//# sourceMappingURL=platform-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-utils.d.ts","sourceRoot":"","sources":["../../src/core/platform-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,eAAO,MAAM,SAAS,2BAAkB,CAAC;AAEzC;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ/D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Platform Utilities
|
|
4
|
+
*
|
|
5
|
+
* Shared utility functions for platform operations and tools.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.execAsync = void 0;
|
|
42
|
+
exports.getScriptsDir = getScriptsDir;
|
|
43
|
+
exports.stripMarkdownCodeBlocks = stripMarkdownCodeBlocks;
|
|
44
|
+
const child_process_1 = require("child_process");
|
|
45
|
+
const util_1 = require("util");
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
exports.execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
48
|
+
/**
|
|
49
|
+
* Get the scripts directory path, works in both development and installed npm package
|
|
50
|
+
*/
|
|
51
|
+
function getScriptsDir() {
|
|
52
|
+
// In CommonJS (after TypeScript compilation), __dirname is available
|
|
53
|
+
// Go up from dist/core/ to project root, then into scripts/
|
|
54
|
+
return path.join(__dirname, '..', '..', 'scripts');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Strip markdown code blocks from AI response
|
|
58
|
+
*/
|
|
59
|
+
function stripMarkdownCodeBlocks(content) {
|
|
60
|
+
let jsonContent = content.trim();
|
|
61
|
+
if (jsonContent.startsWith('```json')) {
|
|
62
|
+
jsonContent = jsonContent.replace(/^```json\s*/, '').replace(/\s*```$/, '');
|
|
63
|
+
}
|
|
64
|
+
else if (jsonContent.startsWith('```')) {
|
|
65
|
+
jsonContent = jsonContent.replace(/^```\s*/, '').replace(/\s*```$/, '');
|
|
66
|
+
}
|
|
67
|
+
return jsonContent;
|
|
68
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic AI Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements AIProvider interface using Anthropic SDK directly.
|
|
5
|
+
* Supports streaming for long operations and debug logging.
|
|
6
|
+
*/
|
|
7
|
+
import { AIProvider, AIResponse, AIProviderConfig, AITool, ToolExecutor, ToolLoopConfig, AgenticResult } from '../ai-provider.interface';
|
|
8
|
+
export declare class AnthropicProvider implements AIProvider {
|
|
9
|
+
private client;
|
|
10
|
+
private apiKey;
|
|
11
|
+
private model;
|
|
12
|
+
private debugMode;
|
|
13
|
+
constructor(config: AIProviderConfig);
|
|
14
|
+
private validateApiKey;
|
|
15
|
+
getProviderType(): string;
|
|
16
|
+
getDefaultModel(): string;
|
|
17
|
+
isInitialized(): boolean;
|
|
18
|
+
sendMessage(message: string, operation?: string): Promise<AIResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Agentic tool loop implementation
|
|
21
|
+
*
|
|
22
|
+
* NOTE: This method is currently NOT USED in the codebase (as of PRD #136 completion).
|
|
23
|
+
*
|
|
24
|
+
* Analysis showed that SDK-based tool loops and JSON-based agentic loops are functionally
|
|
25
|
+
* equivalent - both allow AI to decide which tools to call and when to stop. The JSON-based
|
|
26
|
+
* approach we already use provides the same capabilities without the token overhead of
|
|
27
|
+
* tool schemas in every request.
|
|
28
|
+
*
|
|
29
|
+
* This implementation is kept for potential future use cases where SDK-managed tool loops
|
|
30
|
+
* might provide advantages (e.g., better provider-specific optimizations, simpler code for
|
|
31
|
+
* highly exploratory workflows).
|
|
32
|
+
*
|
|
33
|
+
* ONLY IMPLEMENTED IN ANTHROPIC PROVIDER - VercelAIProvider does not implement this method
|
|
34
|
+
* as it's not needed for current workflows. If you need toolLoop for other providers, you'll
|
|
35
|
+
* need to implement it there as well.
|
|
36
|
+
*
|
|
37
|
+
* See PRD #136 for full architecture analysis and decision rationale.
|
|
38
|
+
*/
|
|
39
|
+
toolLoop(config: ToolLoopConfig): Promise<AgenticResult>;
|
|
40
|
+
sendMessageWithTools(message: string, tools: AITool[], toolExecutor: ToolExecutor, operation?: string): Promise<AIResponse & {
|
|
41
|
+
toolCalls?: any[];
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=anthropic-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/anthropic-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AAGlC,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAU;gBAEf,MAAM,EAAE,gBAAgB;IAWpC,OAAO,CAAC,cAAc;IAStB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,aAAa,IAAI,OAAO;IAIlB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IAwDtF;;;;;;;;;;;;;;;;;;;OAmBG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAgIxD,oBAAoB,CACxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,YAAY,EAC1B,SAAS,GAAE,MAAoB,GAC9B,OAAO,CAAC,UAAU,GAAG;QAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;CAqE/C"}
|