@orchagent/cli 0.3.23 → 0.3.24
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/commands/test.js +27 -35
- package/package.json +3 -1
package/dist/commands/test.js
CHANGED
|
@@ -9,6 +9,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
const yaml_1 = __importDefault(require("yaml"));
|
|
12
|
+
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
13
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
12
14
|
const errors_1 = require("../lib/errors");
|
|
13
15
|
const config_1 = require("../lib/config");
|
|
14
16
|
const llm_1 = require("../lib/llm");
|
|
@@ -307,12 +309,9 @@ async function runFixtureTests(agentDir, fixtures, verbose, config) {
|
|
|
307
309
|
let testPassed = true;
|
|
308
310
|
const failures = [];
|
|
309
311
|
if (fixture.expected_output) {
|
|
310
|
-
|
|
311
|
-
const resultStr = JSON.stringify(result, Object.keys(result).sort());
|
|
312
|
-
const expectedStr = JSON.stringify(fixture.expected_output, Object.keys(fixture.expected_output).sort());
|
|
313
|
-
if (resultStr !== expectedStr) {
|
|
312
|
+
if (!(0, fast_deep_equal_1.default)(result, fixture.expected_output)) {
|
|
314
313
|
testPassed = false;
|
|
315
|
-
failures.push(`Expected: ${
|
|
314
|
+
failures.push(`Expected: ${JSON.stringify(fixture.expected_output, null, 2)}\nGot: ${JSON.stringify(result, null, 2)}`);
|
|
316
315
|
}
|
|
317
316
|
}
|
|
318
317
|
if (fixture.expected_contains) {
|
|
@@ -355,46 +354,39 @@ async function runFixtureTests(agentDir, fixtures, verbose, config) {
|
|
|
355
354
|
/**
|
|
356
355
|
* Watch mode: re-run tests on file changes
|
|
357
356
|
*/
|
|
358
|
-
async function watchTests(agentDir, agentType,
|
|
357
|
+
async function watchTests(agentDir, agentType, verbose, config) {
|
|
359
358
|
process.stderr.write(chalk_1.default.cyan('\nWatching for file changes... (press Ctrl+C to exit)\n\n'));
|
|
360
|
-
// Collect all files to watch
|
|
361
|
-
const watchPaths = [agentDir];
|
|
362
359
|
const runTests = async () => {
|
|
363
360
|
process.stderr.write(chalk_1.default.dim(`\n[${new Date().toLocaleTimeString()}] Running tests...\n`));
|
|
361
|
+
// Re-discover tests each time to pick up new files
|
|
362
|
+
const testFiles = await discoverTests(agentDir);
|
|
364
363
|
await executeTests(agentDir, agentType, testFiles, verbose, config);
|
|
365
364
|
};
|
|
366
365
|
// Initial run
|
|
367
366
|
await runTests();
|
|
368
|
-
// Set up
|
|
369
|
-
const watchers = [];
|
|
367
|
+
// Set up chokidar watcher
|
|
370
368
|
let debounceTimer = null;
|
|
371
|
-
const onChange = () => {
|
|
369
|
+
const onChange = (filePath) => {
|
|
372
370
|
if (debounceTimer)
|
|
373
371
|
clearTimeout(debounceTimer);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
for (const watchPath of watchPaths) {
|
|
377
|
-
try {
|
|
378
|
-
// Use recursive watch on the directory
|
|
379
|
-
const ac = new AbortController();
|
|
380
|
-
(async () => {
|
|
381
|
-
try {
|
|
382
|
-
const watcher = promises_1.default.watch(watchPath, { recursive: true, signal: ac.signal });
|
|
383
|
-
for await (const _event of watcher) {
|
|
384
|
-
onChange();
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
catch (err) {
|
|
388
|
-
if (err.name !== 'AbortError') {
|
|
389
|
-
// Watcher error, ignore
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
})();
|
|
393
|
-
}
|
|
394
|
-
catch {
|
|
395
|
-
// Watch not supported, fall back to polling
|
|
372
|
+
if (verbose) {
|
|
373
|
+
process.stderr.write(chalk_1.default.dim(` Changed: ${path_1.default.relative(agentDir, filePath)}\n`));
|
|
396
374
|
}
|
|
397
|
-
|
|
375
|
+
debounceTimer = setTimeout(runTests, 300);
|
|
376
|
+
};
|
|
377
|
+
const watcher = chokidar_1.default.watch(agentDir, {
|
|
378
|
+
ignored: /(node_modules|__pycache__|\.git|dist|build|\.venv|venv)/,
|
|
379
|
+
persistent: true,
|
|
380
|
+
ignoreInitial: true,
|
|
381
|
+
});
|
|
382
|
+
watcher
|
|
383
|
+
.on('change', onChange)
|
|
384
|
+
.on('add', onChange)
|
|
385
|
+
.on('unlink', onChange)
|
|
386
|
+
.on('error', (error) => {
|
|
387
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
388
|
+
process.stderr.write(chalk_1.default.red(`Watcher error: ${message}\n`));
|
|
389
|
+
});
|
|
398
390
|
// Keep process alive
|
|
399
391
|
await new Promise(() => { });
|
|
400
392
|
}
|
|
@@ -520,7 +512,7 @@ Fixture Format (tests/fixture-1.json):
|
|
|
520
512
|
}
|
|
521
513
|
// Watch mode
|
|
522
514
|
if (options.watch) {
|
|
523
|
-
await watchTests(agentDir, agentType,
|
|
515
|
+
await watchTests(agentDir, agentType, !!options.verbose, config);
|
|
524
516
|
return;
|
|
525
517
|
}
|
|
526
518
|
// Run tests
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orchagent/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"description": "Command-line interface for the orchagent AI agent marketplace",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "orchagent <hello@orchagent.io>",
|
|
@@ -46,8 +46,10 @@
|
|
|
46
46
|
"@sentry/node": "^9.3.0",
|
|
47
47
|
"archiver": "^7.0.0",
|
|
48
48
|
"chalk": "^4.1.2",
|
|
49
|
+
"chokidar": "^4.0.0",
|
|
49
50
|
"cli-table3": "^0.6.3",
|
|
50
51
|
"commander": "^11.1.0",
|
|
52
|
+
"fast-deep-equal": "^3.1.3",
|
|
51
53
|
"open": "^8.4.2",
|
|
52
54
|
"ora": "^9.1.0",
|
|
53
55
|
"posthog-node": "^4.0.0",
|