@pauly4010/evalai-sdk 1.8.0 → 1.9.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/CHANGELOG.md +54 -0
- package/dist/cli/ci.d.ts +45 -0
- package/dist/cli/ci.js +192 -0
- package/dist/cli/diff.d.ts +173 -0
- package/dist/cli/diff.js +680 -0
- package/dist/cli/discover.d.ts +84 -0
- package/dist/cli/discover.js +408 -0
- package/dist/cli/doctor.js +19 -10
- package/dist/cli/env.d.ts +21 -0
- package/dist/cli/env.js +42 -0
- package/dist/cli/explain.js +143 -37
- package/dist/cli/impact-analysis.d.ts +63 -0
- package/dist/cli/impact-analysis.js +251 -0
- package/dist/cli/index.js +173 -0
- package/dist/cli/manifest.d.ts +105 -0
- package/dist/cli/manifest.js +275 -0
- package/dist/cli/migrate.d.ts +41 -0
- package/dist/cli/migrate.js +349 -0
- package/dist/cli/print-config.js +18 -14
- package/dist/cli/run.d.ts +101 -0
- package/dist/cli/run.js +389 -0
- package/dist/cli/workspace.d.ts +28 -0
- package/dist/cli/workspace.js +58 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +30 -5
- package/dist/runtime/adapters/config-to-dsl.d.ts +33 -0
- package/dist/runtime/adapters/config-to-dsl.js +391 -0
- package/dist/runtime/adapters/testsuite-to-dsl.d.ts +63 -0
- package/dist/runtime/adapters/testsuite-to-dsl.js +271 -0
- package/dist/runtime/context.d.ts +26 -0
- package/dist/runtime/context.js +74 -0
- package/dist/runtime/eval.d.ts +46 -0
- package/dist/runtime/eval.js +237 -0
- package/dist/runtime/execution-mode.d.ts +80 -0
- package/dist/runtime/execution-mode.js +353 -0
- package/dist/runtime/executor.d.ts +16 -0
- package/dist/runtime/executor.js +152 -0
- package/dist/runtime/registry.d.ts +78 -0
- package/dist/runtime/registry.js +416 -0
- package/dist/runtime/run-report.d.ts +202 -0
- package/dist/runtime/run-report.js +220 -0
- package/dist/runtime/types.d.ts +356 -0
- package/dist/runtime/types.js +76 -0
- package/dist/testing.d.ts +65 -0
- package/dist/testing.js +42 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TICKET 1 — evalai discover
|
|
3
|
+
*
|
|
4
|
+
* Your first "holy shit" moment feature
|
|
5
|
+
*
|
|
6
|
+
* Goal:
|
|
7
|
+
* npm install
|
|
8
|
+
* evalai discover
|
|
9
|
+
*
|
|
10
|
+
* Output:
|
|
11
|
+
* Found 42 behavioral specifications
|
|
12
|
+
* Safety: 12
|
|
13
|
+
* Accuracy: 18
|
|
14
|
+
* Agents: 7
|
|
15
|
+
* Tools: 5
|
|
16
|
+
*
|
|
17
|
+
* Why this matters:
|
|
18
|
+
* - makes EvalAI feel alive
|
|
19
|
+
* - proves DSL works
|
|
20
|
+
* - enables intelligence layer
|
|
21
|
+
*
|
|
22
|
+
* This becomes your entry point command.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Discovered specification statistics
|
|
26
|
+
*/
|
|
27
|
+
export interface DiscoveryStats {
|
|
28
|
+
/** Total number of specifications found */
|
|
29
|
+
totalSpecs: number;
|
|
30
|
+
/** Specifications by category/tag */
|
|
31
|
+
categories: Record<string, number>;
|
|
32
|
+
/** Specifications by file */
|
|
33
|
+
files: Record<string, number>;
|
|
34
|
+
/** Execution mode information */
|
|
35
|
+
executionMode: {
|
|
36
|
+
mode: string;
|
|
37
|
+
hasSpecRuntime: boolean;
|
|
38
|
+
hasLegacyRuntime: boolean;
|
|
39
|
+
specFiles: string[];
|
|
40
|
+
legacyConfig?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Project metadata */
|
|
43
|
+
project: {
|
|
44
|
+
root: string;
|
|
45
|
+
name: string;
|
|
46
|
+
hasPackageJson: boolean;
|
|
47
|
+
hasGit: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Specification analysis result
|
|
52
|
+
*/
|
|
53
|
+
export interface SpecAnalysis {
|
|
54
|
+
/** Specification ID */
|
|
55
|
+
id: string;
|
|
56
|
+
/** Specification name */
|
|
57
|
+
name: string;
|
|
58
|
+
/** File path */
|
|
59
|
+
file: string;
|
|
60
|
+
/** Tags/categories */
|
|
61
|
+
tags: string[];
|
|
62
|
+
/** Has assertions */
|
|
63
|
+
hasAssertions: boolean;
|
|
64
|
+
/** Uses external models */
|
|
65
|
+
usesModels: boolean;
|
|
66
|
+
/** Uses tools */
|
|
67
|
+
usesTools: boolean;
|
|
68
|
+
/** Estimated complexity */
|
|
69
|
+
complexity: "simple" | "medium" | "complex";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Discover and analyze behavioral specifications in the current project
|
|
73
|
+
*/
|
|
74
|
+
export declare function discoverSpecs(options?: {
|
|
75
|
+
manifest?: boolean;
|
|
76
|
+
}): Promise<DiscoveryStats>;
|
|
77
|
+
/**
|
|
78
|
+
* Print discovery results in a beautiful format
|
|
79
|
+
*/
|
|
80
|
+
export declare function printDiscoveryResults(stats: DiscoveryStats): void;
|
|
81
|
+
/**
|
|
82
|
+
* Run discovery command
|
|
83
|
+
*/
|
|
84
|
+
export declare function runDiscover(): Promise<void>;
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TICKET 1 — evalai discover
|
|
4
|
+
*
|
|
5
|
+
* Your first "holy shit" moment feature
|
|
6
|
+
*
|
|
7
|
+
* Goal:
|
|
8
|
+
* npm install
|
|
9
|
+
* evalai discover
|
|
10
|
+
*
|
|
11
|
+
* Output:
|
|
12
|
+
* Found 42 behavioral specifications
|
|
13
|
+
* Safety: 12
|
|
14
|
+
* Accuracy: 18
|
|
15
|
+
* Agents: 7
|
|
16
|
+
* Tools: 5
|
|
17
|
+
*
|
|
18
|
+
* Why this matters:
|
|
19
|
+
* - makes EvalAI feel alive
|
|
20
|
+
* - proves DSL works
|
|
21
|
+
* - enables intelligence layer
|
|
22
|
+
*
|
|
23
|
+
* This becomes your entry point command.
|
|
24
|
+
*/
|
|
25
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(o, k2, desc);
|
|
32
|
+
}) : (function(o, m, k, k2) {
|
|
33
|
+
if (k2 === undefined) k2 = k;
|
|
34
|
+
o[k2] = m[k];
|
|
35
|
+
}));
|
|
36
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
37
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38
|
+
}) : function(o, v) {
|
|
39
|
+
o["default"] = v;
|
|
40
|
+
});
|
|
41
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
42
|
+
var ownKeys = function(o) {
|
|
43
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
44
|
+
var ar = [];
|
|
45
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
46
|
+
return ar;
|
|
47
|
+
};
|
|
48
|
+
return ownKeys(o);
|
|
49
|
+
};
|
|
50
|
+
return function (mod) {
|
|
51
|
+
if (mod && mod.__esModule) return mod;
|
|
52
|
+
var result = {};
|
|
53
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
54
|
+
__setModuleDefault(result, mod);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.discoverSpecs = discoverSpecs;
|
|
60
|
+
exports.printDiscoveryResults = printDiscoveryResults;
|
|
61
|
+
exports.runDiscover = runDiscover;
|
|
62
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
63
|
+
const path = __importStar(require("node:path"));
|
|
64
|
+
const execution_mode_1 = require("../runtime/execution-mode");
|
|
65
|
+
const manifest_1 = require("./manifest");
|
|
66
|
+
/**
|
|
67
|
+
* Discover and analyze behavioral specifications in the current project
|
|
68
|
+
*/
|
|
69
|
+
async function discoverSpecs(options = {}) {
|
|
70
|
+
try {
|
|
71
|
+
const projectRoot = process.cwd();
|
|
72
|
+
const executionMode = await (0, execution_mode_1.getExecutionMode)(projectRoot);
|
|
73
|
+
// Get project metadata
|
|
74
|
+
const project = await getProjectMetadata(projectRoot);
|
|
75
|
+
if (executionMode.specFiles.length === 0) {
|
|
76
|
+
console.log("\n✨ No behavioral specifications found.");
|
|
77
|
+
console.log("💡 Create files with defineEval() calls to get started.");
|
|
78
|
+
return {
|
|
79
|
+
totalSpecs: 0,
|
|
80
|
+
categories: {},
|
|
81
|
+
files: {},
|
|
82
|
+
executionMode: {
|
|
83
|
+
mode: executionMode.mode,
|
|
84
|
+
hasSpecRuntime: executionMode.hasSpecRuntime,
|
|
85
|
+
hasLegacyRuntime: executionMode.hasLegacyRuntime,
|
|
86
|
+
specFiles: executionMode.specFiles,
|
|
87
|
+
legacyConfig: executionMode.legacyConfig,
|
|
88
|
+
},
|
|
89
|
+
project,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Analyze specifications
|
|
93
|
+
const specs = await analyzeSpecifications(executionMode.specFiles);
|
|
94
|
+
// Generate manifest if requested
|
|
95
|
+
if (options.manifest) {
|
|
96
|
+
console.log("🔧 Generating evaluation manifest...");
|
|
97
|
+
const manifest = await (0, manifest_1.generateManifest)(specs, projectRoot, project.name, executionMode);
|
|
98
|
+
await (0, manifest_1.writeManifest)(manifest, projectRoot);
|
|
99
|
+
console.log(`✅ Manifest written to .evalai/manifest.json`);
|
|
100
|
+
console.log(`✅ Lock file written to .evalai/manifest.lock.json`);
|
|
101
|
+
}
|
|
102
|
+
// Calculate statistics
|
|
103
|
+
const stats = calculateStats(specs, executionMode, project);
|
|
104
|
+
printDiscoveryResults(stats);
|
|
105
|
+
return stats;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error("❌ Discovery failed:", error instanceof Error ? error.message : String(error));
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get project metadata
|
|
114
|
+
*/
|
|
115
|
+
async function getProjectMetadata(projectRoot) {
|
|
116
|
+
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
117
|
+
const gitPath = path.join(projectRoot, ".git");
|
|
118
|
+
let hasPackageJson = false;
|
|
119
|
+
let projectName = "unknown";
|
|
120
|
+
try {
|
|
121
|
+
const packageJson = await fs.readFile(packageJsonPath, "utf-8");
|
|
122
|
+
const parsed = JSON.parse(packageJson);
|
|
123
|
+
hasPackageJson = true;
|
|
124
|
+
projectName = parsed.name || "unknown";
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
// No package.json
|
|
128
|
+
}
|
|
129
|
+
const hasGit = await fs
|
|
130
|
+
.access(gitPath)
|
|
131
|
+
.then(() => true)
|
|
132
|
+
.catch(() => false);
|
|
133
|
+
return {
|
|
134
|
+
root: projectRoot,
|
|
135
|
+
name: projectName,
|
|
136
|
+
hasPackageJson,
|
|
137
|
+
hasGit,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Analyze specification files
|
|
142
|
+
*/
|
|
143
|
+
async function analyzeSpecifications(specFiles) {
|
|
144
|
+
const specs = [];
|
|
145
|
+
for (const filePath of specFiles) {
|
|
146
|
+
try {
|
|
147
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
148
|
+
const analysis = analyzeSpecFile(filePath, content);
|
|
149
|
+
specs.push(analysis);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.warn(`Warning: Could not analyze ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return specs;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Analyze a single specification file
|
|
159
|
+
*/
|
|
160
|
+
function analyzeSpecFile(filePath, content) {
|
|
161
|
+
// Extract defineEval calls
|
|
162
|
+
const defineEvalMatches = content.match(/defineEval\s*\([^)]+\)/g) || [];
|
|
163
|
+
const specNames = defineEvalMatches.map((match) => {
|
|
164
|
+
const nameMatch = match.match(/["'`](.+?)["'`](?:\s*,|\s*\))/);
|
|
165
|
+
return nameMatch ? nameMatch[1] : "unnamed";
|
|
166
|
+
});
|
|
167
|
+
// Extract tags
|
|
168
|
+
const tags = extractTags(content);
|
|
169
|
+
// Analyze complexity
|
|
170
|
+
const complexity = analyzeComplexity(content);
|
|
171
|
+
// Check for models and tools
|
|
172
|
+
const usesModels = content.includes("model:") ||
|
|
173
|
+
content.includes("model=") ||
|
|
174
|
+
content.includes("openai") ||
|
|
175
|
+
content.includes("anthropic");
|
|
176
|
+
const usesTools = content.includes("tool:") || content.includes("function.") || content.includes("call(");
|
|
177
|
+
// Check for assertions
|
|
178
|
+
const hasAssertions = content.includes("assert") || content.includes("expect") || content.includes("should");
|
|
179
|
+
// Generate ID from file path
|
|
180
|
+
const id = generateSpecId(filePath);
|
|
181
|
+
return {
|
|
182
|
+
id,
|
|
183
|
+
name: specNames[0] || path.basename(filePath, ".ts"),
|
|
184
|
+
file: path.relative(process.cwd(), filePath),
|
|
185
|
+
tags,
|
|
186
|
+
hasAssertions,
|
|
187
|
+
usesModels,
|
|
188
|
+
usesTools,
|
|
189
|
+
complexity,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Extract tags from specification content
|
|
194
|
+
*/
|
|
195
|
+
function extractTags(content) {
|
|
196
|
+
const tags = [];
|
|
197
|
+
// Extract tags parameter
|
|
198
|
+
const tagsMatch = content.match(/tags\s*:\s*\[([^\]]+)\]/);
|
|
199
|
+
if (tagsMatch) {
|
|
200
|
+
const tagContent = tagsMatch[1];
|
|
201
|
+
const tagStrings = tagContent.match(/["'`](.+?)["'`](?:\s*,|\s*)/g) || [];
|
|
202
|
+
tags.push(...tagStrings.map((tag) => tag.replace(/["'`](.+?)["'`](?:\s*,|\s*)/, "$1")));
|
|
203
|
+
}
|
|
204
|
+
// Extract from description and metadata
|
|
205
|
+
const descriptionMatch = content.match(/description\s*:\s*["'`](.+?)["'`](?:\s*,|\s*)/);
|
|
206
|
+
if (descriptionMatch) {
|
|
207
|
+
const description = descriptionMatch[1].toLowerCase();
|
|
208
|
+
// Auto-categorize based on description
|
|
209
|
+
if (description.includes("safety") || description.includes("security"))
|
|
210
|
+
tags.push("safety");
|
|
211
|
+
if (description.includes("accuracy") || description.includes("precision"))
|
|
212
|
+
tags.push("accuracy");
|
|
213
|
+
if (description.includes("agent") || description.includes("autonomous"))
|
|
214
|
+
tags.push("agents");
|
|
215
|
+
if (description.includes("tool") || description.includes("function"))
|
|
216
|
+
tags.push("tools");
|
|
217
|
+
if (description.includes("latency") || description.includes("speed"))
|
|
218
|
+
tags.push("performance");
|
|
219
|
+
if (description.includes("hallucination") || description.includes("fact"))
|
|
220
|
+
tags.push("factual");
|
|
221
|
+
if (description.includes("bias") || description.includes("fairness"))
|
|
222
|
+
tags.push("bias");
|
|
223
|
+
if (description.includes("privacy") || description.includes("pii"))
|
|
224
|
+
tags.push("privacy");
|
|
225
|
+
}
|
|
226
|
+
return [...new Set(tags)]; // Remove duplicates
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Analyze specification complexity
|
|
230
|
+
*/
|
|
231
|
+
function analyzeComplexity(content) {
|
|
232
|
+
const lines = content.split("\n").length;
|
|
233
|
+
const hasAsync = content.includes("async") || content.includes("await");
|
|
234
|
+
const hasLoops = content.includes("for") || content.includes("while");
|
|
235
|
+
const hasConditionals = content.includes("if") || content.includes("switch");
|
|
236
|
+
const hasTryCatch = content.includes("try") || content.includes("catch");
|
|
237
|
+
const hasExternalCalls = content.includes("fetch") || content.includes("http") || content.includes("api");
|
|
238
|
+
let complexityScore = 0;
|
|
239
|
+
if (lines > 50)
|
|
240
|
+
complexityScore += 2;
|
|
241
|
+
if (lines > 100)
|
|
242
|
+
complexityScore += 3;
|
|
243
|
+
if (hasAsync)
|
|
244
|
+
complexityScore += 2;
|
|
245
|
+
if (hasLoops)
|
|
246
|
+
complexityScore += 1;
|
|
247
|
+
if (hasConditionals)
|
|
248
|
+
complexityScore += 1;
|
|
249
|
+
if (hasTryCatch)
|
|
250
|
+
complexityScore += 1;
|
|
251
|
+
if (hasExternalCalls)
|
|
252
|
+
complexityScore += 2;
|
|
253
|
+
if (complexityScore <= 2)
|
|
254
|
+
return "simple";
|
|
255
|
+
if (complexityScore <= 5)
|
|
256
|
+
return "medium";
|
|
257
|
+
return "complex";
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Generate specification ID from file path
|
|
261
|
+
*/
|
|
262
|
+
function generateSpecId(filePath) {
|
|
263
|
+
const relativePath = path.relative(process.cwd(), filePath);
|
|
264
|
+
const hash = Buffer.from(relativePath).toString("base64").replace(/[+/=]/g, "").slice(0, 8);
|
|
265
|
+
return hash;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Calculate discovery statistics
|
|
269
|
+
*/
|
|
270
|
+
function calculateStats(specs, executionMode, project) {
|
|
271
|
+
const categories = {};
|
|
272
|
+
const files = {};
|
|
273
|
+
// Count by categories
|
|
274
|
+
for (const spec of specs) {
|
|
275
|
+
for (const tag of spec.tags) {
|
|
276
|
+
categories[tag] = (categories[tag] || 0) + 1;
|
|
277
|
+
}
|
|
278
|
+
// Count by files
|
|
279
|
+
files[spec.file] = (files[spec.file] || 0) + 1;
|
|
280
|
+
}
|
|
281
|
+
// Add default categories if none found
|
|
282
|
+
if (Object.keys(categories).length === 0) {
|
|
283
|
+
categories.general = specs.length;
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
totalSpecs: specs.length,
|
|
287
|
+
categories,
|
|
288
|
+
files,
|
|
289
|
+
executionMode: {
|
|
290
|
+
mode: executionMode.mode,
|
|
291
|
+
hasSpecRuntime: executionMode.hasSpecRuntime,
|
|
292
|
+
hasLegacyRuntime: executionMode.hasLegacyRuntime,
|
|
293
|
+
specFiles: executionMode.specFiles,
|
|
294
|
+
legacyConfig: executionMode.legacyConfig,
|
|
295
|
+
},
|
|
296
|
+
project,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Print discovery results in a beautiful format
|
|
301
|
+
*/
|
|
302
|
+
function printDiscoveryResults(stats) {
|
|
303
|
+
console.log(`🔍 EvalAI Discovery Results`);
|
|
304
|
+
console.log(``);
|
|
305
|
+
console.log(`📊 Found ${stats.totalSpecs} behavioral specifications`);
|
|
306
|
+
console.log(``);
|
|
307
|
+
// Print categories
|
|
308
|
+
if (Object.keys(stats.categories).length > 0) {
|
|
309
|
+
console.log(`📋 Categories:`);
|
|
310
|
+
const sortedCategories = Object.entries(stats.categories)
|
|
311
|
+
.sort(([, a], [, b]) => b - a)
|
|
312
|
+
.slice(0, 10); // Top 10 categories
|
|
313
|
+
for (const [category, count] of sortedCategories) {
|
|
314
|
+
const icon = getCategoryIcon(category);
|
|
315
|
+
console.log(` ${icon} ${category}: ${count}`);
|
|
316
|
+
}
|
|
317
|
+
console.log(``);
|
|
318
|
+
}
|
|
319
|
+
// Print execution mode
|
|
320
|
+
console.log(`⚙️ Execution Mode: ${stats.executionMode.mode.toUpperCase()}`);
|
|
321
|
+
if (stats.executionMode.hasSpecRuntime) {
|
|
322
|
+
console.log(` ✅ Spec runtime: ${stats.executionMode.specFiles.length} files`);
|
|
323
|
+
}
|
|
324
|
+
if (stats.executionMode.hasLegacyRuntime) {
|
|
325
|
+
console.log(` ✅ Legacy runtime: ${stats.executionMode.legacyConfig ? path.basename(stats.executionMode.legacyConfig) : "config"}`);
|
|
326
|
+
}
|
|
327
|
+
console.log(``);
|
|
328
|
+
// Print project info
|
|
329
|
+
console.log(`📁 Project: ${stats.project.name}`);
|
|
330
|
+
console.log(` 📍 Root: ${stats.project.root}`);
|
|
331
|
+
console.log(` 📦 Package.json: ${stats.project.hasPackageJson ? "✅" : "❌"}`);
|
|
332
|
+
console.log(` 🔄 Git: ${stats.project.hasGit ? "✅" : "❌"}`);
|
|
333
|
+
console.log(``);
|
|
334
|
+
// Print recommendations
|
|
335
|
+
printRecommendations(stats);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get icon for category
|
|
339
|
+
*/
|
|
340
|
+
function getCategoryIcon(category) {
|
|
341
|
+
const icons = {
|
|
342
|
+
safety: "🛡️",
|
|
343
|
+
security: "🔒",
|
|
344
|
+
accuracy: "🎯",
|
|
345
|
+
precision: "🎯",
|
|
346
|
+
agents: "🤖",
|
|
347
|
+
autonomous: "🤖",
|
|
348
|
+
tools: "🔧",
|
|
349
|
+
functions: "🔧",
|
|
350
|
+
performance: "⚡",
|
|
351
|
+
latency: "⚡",
|
|
352
|
+
speed: "⚡",
|
|
353
|
+
factual: "📊",
|
|
354
|
+
hallucination: "📊",
|
|
355
|
+
bias: "⚖️",
|
|
356
|
+
fairness: "⚖️",
|
|
357
|
+
privacy: "🔐",
|
|
358
|
+
pii: "🔐",
|
|
359
|
+
general: "📝",
|
|
360
|
+
};
|
|
361
|
+
return icons[category.toLowerCase()] || "📝";
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Print recommendations based on discovery results
|
|
365
|
+
*/
|
|
366
|
+
function printRecommendations(stats) {
|
|
367
|
+
console.log(`💡 Recommendations:`);
|
|
368
|
+
if (stats.totalSpecs === 0) {
|
|
369
|
+
console.log(` 🚀 No specifications found. Create your first eval with:
|
|
370
|
+
echo 'import { defineEval } from "@pauly4010/evalai-sdk";
|
|
371
|
+
defineEval("hello-world", async (context) => {
|
|
372
|
+
return { pass: true, score: 100 };
|
|
373
|
+
});' > eval/hello.spec.ts`);
|
|
374
|
+
}
|
|
375
|
+
else if (stats.totalSpecs < 5) {
|
|
376
|
+
console.log(` 📈 Add more specifications to improve coverage`);
|
|
377
|
+
}
|
|
378
|
+
else if (stats.totalSpecs < 20) {
|
|
379
|
+
console.log(` 🎯 Good start! Consider organizing by categories`);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
console.log(` 🏆 Excellent coverage! Consider running evalai run`);
|
|
383
|
+
}
|
|
384
|
+
if (!stats.executionMode.hasSpecRuntime && !stats.executionMode.hasLegacyRuntime) {
|
|
385
|
+
console.log(` 🆕 New project? Try 'evalai init' to get started`);
|
|
386
|
+
}
|
|
387
|
+
if (stats.executionMode.hasLegacyRuntime && !stats.executionMode.hasSpecRuntime) {
|
|
388
|
+
console.log(` 🔄 Legacy project detected. Try 'evalai migrate config' to upgrade`);
|
|
389
|
+
}
|
|
390
|
+
if (stats.executionMode.hasSpecRuntime) {
|
|
391
|
+
console.log(` 🚀 Ready to run! Use 'evalai run' to execute specifications`);
|
|
392
|
+
}
|
|
393
|
+
console.log(``);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Run discovery command
|
|
397
|
+
*/
|
|
398
|
+
async function runDiscover() {
|
|
399
|
+
try {
|
|
400
|
+
const stats = await discoverSpecs();
|
|
401
|
+
printDiscoveryResults(stats);
|
|
402
|
+
process.exit(0);
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
console.error(`❌ Discovery failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
406
|
+
process.exit(1);
|
|
407
|
+
}
|
|
408
|
+
}
|
package/dist/cli/doctor.js
CHANGED
|
@@ -96,8 +96,10 @@ function parseFlags(argv) {
|
|
|
96
96
|
const baseUrl = raw.baseUrl || process.env.EVALAI_BASE_URL || "http://localhost:3000";
|
|
97
97
|
const apiKey = raw.apiKey || process.env.EVALAI_API_KEY || "";
|
|
98
98
|
let evaluationId = raw.evaluationId || "";
|
|
99
|
-
const baseline = (raw.baseline === "previous"
|
|
100
|
-
|
|
99
|
+
const baseline = (raw.baseline === "previous"
|
|
100
|
+
? "previous"
|
|
101
|
+
: raw.baseline === "production"
|
|
102
|
+
? "production"
|
|
101
103
|
: "published");
|
|
102
104
|
// Try to fill evaluationId from config
|
|
103
105
|
if (!evaluationId) {
|
|
@@ -269,9 +271,7 @@ function checkAuth(apiKey) {
|
|
|
269
271
|
};
|
|
270
272
|
}
|
|
271
273
|
// Redact key for display
|
|
272
|
-
const redacted = apiKey.length > 8
|
|
273
|
-
? `${apiKey.slice(0, 4)}...${apiKey.slice(-4)}`
|
|
274
|
-
: "****";
|
|
274
|
+
const redacted = apiKey.length > 8 ? `${apiKey.slice(0, 4)}...${apiKey.slice(-4)}` : "****";
|
|
275
275
|
return {
|
|
276
276
|
id: "auth",
|
|
277
277
|
label: "Authentication",
|
|
@@ -480,10 +480,14 @@ function checkProviderEnv() {
|
|
|
480
480
|
// ── Output formatting ──
|
|
481
481
|
function icon(status) {
|
|
482
482
|
switch (status) {
|
|
483
|
-
case "pass":
|
|
484
|
-
|
|
485
|
-
case "
|
|
486
|
-
|
|
483
|
+
case "pass":
|
|
484
|
+
return "\u2705"; // ✅
|
|
485
|
+
case "fail":
|
|
486
|
+
return "\u274C"; // ❌
|
|
487
|
+
case "warn":
|
|
488
|
+
return "\u26A0\uFE0F"; // ⚠️
|
|
489
|
+
case "skip":
|
|
490
|
+
return "\u23ED\uFE0F"; // ⏭️
|
|
487
491
|
}
|
|
488
492
|
}
|
|
489
493
|
function printHuman(checks, overall) {
|
|
@@ -539,7 +543,12 @@ async function runDoctor(argv) {
|
|
|
539
543
|
message: "Infrastructure error during connectivity check",
|
|
540
544
|
});
|
|
541
545
|
infraError = true;
|
|
542
|
-
connectivityResult = {
|
|
546
|
+
connectivityResult = {
|
|
547
|
+
id: "connectivity",
|
|
548
|
+
label: "API connectivity",
|
|
549
|
+
status: "fail",
|
|
550
|
+
message: "",
|
|
551
|
+
};
|
|
543
552
|
}
|
|
544
553
|
// 7. Eval access (async, depends on auth + connectivity)
|
|
545
554
|
if (flags.apiKey && flags.evaluationId && connectivityResult.status !== "fail") {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CORE-401: Centralized environment detection
|
|
3
|
+
*
|
|
4
|
+
* Provides unified environment detection for all EvalAI CLI commands
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check if running in CI environment
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCI(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check if running in GitHub Actions
|
|
12
|
+
*/
|
|
13
|
+
export declare function isGitHubActions(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Get GitHub Step Summary path if available
|
|
16
|
+
*/
|
|
17
|
+
export declare function getGitHubStepSummaryPath(): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Check if string looks like a git reference
|
|
20
|
+
*/
|
|
21
|
+
export declare function isGitRef(ref: string): boolean;
|
package/dist/cli/env.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CORE-401: Centralized environment detection
|
|
4
|
+
*
|
|
5
|
+
* Provides unified environment detection for all EvalAI CLI commands
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isCI = isCI;
|
|
9
|
+
exports.isGitHubActions = isGitHubActions;
|
|
10
|
+
exports.getGitHubStepSummaryPath = getGitHubStepSummaryPath;
|
|
11
|
+
exports.isGitRef = isGitRef;
|
|
12
|
+
/**
|
|
13
|
+
* Check if running in CI environment
|
|
14
|
+
*/
|
|
15
|
+
function isCI() {
|
|
16
|
+
return !!(process.env.GITHUB_ACTIONS ||
|
|
17
|
+
process.env.CI ||
|
|
18
|
+
process.env.CONTINUOUS_INTEGRATION ||
|
|
19
|
+
process.env.BUILDKITE ||
|
|
20
|
+
process.env.CIRCLECI ||
|
|
21
|
+
process.env.TRAVIS ||
|
|
22
|
+
process.env.JENKINS_URL);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if running in GitHub Actions
|
|
26
|
+
*/
|
|
27
|
+
function isGitHubActions() {
|
|
28
|
+
return !!process.env.GITHUB_ACTIONS;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get GitHub Step Summary path if available
|
|
32
|
+
*/
|
|
33
|
+
function getGitHubStepSummaryPath() {
|
|
34
|
+
return process.env.GITHUB_STEP_SUMMARY;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if string looks like a git reference
|
|
38
|
+
*/
|
|
39
|
+
function isGitRef(ref) {
|
|
40
|
+
// Common git ref patterns
|
|
41
|
+
return /^(main|master|develop|dev|origin\/|remotes\/|feature\/|hotfix\/|release\/|v\d+\.\d+\.\d+|.*\.\.\..*|nonexistent-branch|test-branch|ci-branch)/.test(ref);
|
|
42
|
+
}
|