mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 16:01:54 +00:00
109 lines
3.5 KiB
JavaScript
109 lines
3.5 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert';
|
|
import { parseArgs } from '../src/cli-parser.mjs';
|
|
import { DEFAULT_DASHBOARD_PORT } from '../src/constants.mjs';
|
|
|
|
test('parseArgs should parse basic command', () => {
|
|
const args = parseArgs(['check', '--cadence', 'daily']);
|
|
assert.strictEqual(args.command, 'check');
|
|
assert.strictEqual(args.cadence, 'daily');
|
|
});
|
|
|
|
test('parseArgs should parse agent and cadence', () => {
|
|
const args = parseArgs(['lock', '--agent', 'my-agent', '--cadence', 'weekly']);
|
|
assert.strictEqual(args.command, 'lock');
|
|
assert.strictEqual(args.agent, 'my-agent');
|
|
assert.strictEqual(args.cadence, 'weekly');
|
|
});
|
|
|
|
test('parseArgs should parse equals sign syntax', () => {
|
|
const args = parseArgs(['lock', '--agent=my-agent', '--cadence=weekly']);
|
|
assert.strictEqual(args.command, 'lock');
|
|
assert.strictEqual(args.agent, 'my-agent');
|
|
assert.strictEqual(args.cadence, 'weekly');
|
|
});
|
|
|
|
test('parseArgs should parse dry-run flag', () => {
|
|
const args = parseArgs(['lock', '--dry-run']);
|
|
assert.strictEqual(args.dryRun, true);
|
|
});
|
|
|
|
test('parseArgs should parse port with default', () => {
|
|
const args = parseArgs(['dashboard']);
|
|
assert.strictEqual(args.port, DEFAULT_DASHBOARD_PORT);
|
|
});
|
|
|
|
test('parseArgs should parse custom port', () => {
|
|
const args = parseArgs(['dashboard', '--port', '8080']);
|
|
assert.strictEqual(args.port, 8080);
|
|
});
|
|
|
|
test('parseArgs should parse ignore-logs flag', () => {
|
|
const args = parseArgs(['check', '--ignore-logs']);
|
|
assert.strictEqual(args.ignoreLogs, true);
|
|
});
|
|
|
|
test('parseArgs should parse memory flags', () => {
|
|
const args = parseArgs([
|
|
'list-memories',
|
|
'--id', '123',
|
|
'--type', 'retrieve',
|
|
'--tags', 'a,b',
|
|
'--pinned', 'true',
|
|
'--limit', '10',
|
|
'--offset', '5'
|
|
]);
|
|
assert.strictEqual(args.id, '123');
|
|
assert.strictEqual(args.type, 'retrieve');
|
|
assert.deepStrictEqual(args.tags, ['a', 'b']);
|
|
assert.strictEqual(args.pinned, true);
|
|
assert.strictEqual(args.limit, 10);
|
|
assert.strictEqual(args.offset, 5);
|
|
});
|
|
|
|
test('parseArgs should parse memory flags with equals', () => {
|
|
const args = parseArgs([
|
|
'list-memories',
|
|
'--id=123',
|
|
'--type=retrieve',
|
|
'--tags=a,b',
|
|
'--pinned=false',
|
|
'--limit=10',
|
|
'--offset=5'
|
|
]);
|
|
assert.strictEqual(args.id, '123');
|
|
assert.strictEqual(args.type, 'retrieve');
|
|
assert.deepStrictEqual(args.tags, ['a', 'b']);
|
|
assert.strictEqual(args.pinned, false);
|
|
assert.strictEqual(args.limit, 10);
|
|
assert.strictEqual(args.offset, 5);
|
|
});
|
|
|
|
test('parseArgs should parse memory subcommands and event contract flags', () => {
|
|
const args = parseArgs([
|
|
'memory',
|
|
'add',
|
|
'--agent', 'codex',
|
|
'--topic', 'memory',
|
|
'--message', 'hello',
|
|
'--run-id', 'run_1',
|
|
'--events-dir', 'memory/events',
|
|
'--schema-path', 'memory/schema/memory-event.schema.json',
|
|
'--created-at', '2026-03-01T15:20:11Z',
|
|
'--source', 'scheduler',
|
|
'--project', 'TORCH',
|
|
]);
|
|
|
|
assert.strictEqual(args.command, 'memory');
|
|
assert.strictEqual(args.subcommand, 'add');
|
|
assert.strictEqual(args.agent, 'codex');
|
|
assert.strictEqual(args.topic, 'memory');
|
|
assert.strictEqual(args.message, 'hello');
|
|
assert.strictEqual(args.runId, 'run_1');
|
|
assert.strictEqual(args.eventsDir, 'memory/events');
|
|
assert.strictEqual(args.schemaPath, 'memory/schema/memory-event.schema.json');
|
|
assert.strictEqual(args.createdAt, '2026-03-01T15:20:11Z');
|
|
assert.strictEqual(args.source, 'scheduler');
|
|
assert.strictEqual(args.project, 'TORCH');
|
|
});
|