refactor(cli): rename ps to ls and add top-level agent commands

This commit is contained in:
Mohamed Boudra
2026-01-29 10:41:19 +07:00
parent 7d4636ecff
commit dfda6daeed
46 changed files with 4473 additions and 542 deletions
+56 -56
View File
@@ -1,23 +1,23 @@
#!/usr/bin/env npx tsx
/**
* Phase 4: Agent Run Command Tests
* Phase 4: Run Command Tests
*
* Tests the agent run command - creating and running agents with tasks.
* Tests the run command - creating and running agents with tasks (top-level command).
* Since daemon may not be running, we test both:
* - Help and argument parsing
* - Graceful error handling when daemon not running
* - All flags are accepted
*
* Tests:
* - agent run --help shows options
* - agent run requires prompt argument
* - agent run handles daemon not running
* - agent run -d flag is accepted
* - agent run --name flag is accepted
* - agent run --provider flag is accepted
* - agent run --mode flag is accepted
* - agent run --cwd flag is accepted
* - run --help shows options
* - run requires prompt argument
* - run handles daemon not running
* - run -d flag is accepted
* - run --name flag is accepted
* - run --provider flag is accepted
* - run --mode flag is accepted
* - run --cwd flag is accepted
*/
import assert from 'node:assert'
@@ -28,18 +28,18 @@ import { join } from 'path'
$.verbose = false
console.log('=== Agent Run Command Tests ===\n')
console.log('=== Run Command Tests ===\n')
// Get random port that's definitely not in use (never 6767)
const port = 10000 + Math.floor(Math.random() * 50000)
const paseoHome = await mkdtemp(join(tmpdir(), 'paseo-test-home-'))
try {
// Test 1: agent run --help shows options
// Test 1: run --help shows options
{
console.log('Test 1: agent run --help shows options')
const result = await $`npx paseo agent run --help`.nothrow()
assert.strictEqual(result.exitCode, 0, 'agent run --help should exit 0')
console.log('Test 1: run --help shows options')
const result = await $`npx paseo run --help`.nothrow()
assert.strictEqual(result.exitCode, 0, 'run --help should exit 0')
assert(result.stdout.includes('-d'), 'help should mention -d flag')
assert(result.stdout.includes('--detach'), 'help should mention --detach flag')
assert(result.stdout.includes('--name'), 'help should mention --name option')
@@ -48,14 +48,14 @@ try {
assert(result.stdout.includes('--cwd'), 'help should mention --cwd option')
assert(result.stdout.includes('--host'), 'help should mention --host option')
assert(result.stdout.includes('<prompt>'), 'help should mention prompt argument')
console.log('✓ agent run --help shows options\n')
console.log('✓ run --help shows options\n')
}
// Test 2: agent run requires prompt argument
// Test 2: run requires prompt argument
{
console.log('Test 2: agent run requires prompt argument')
console.log('Test 2: run requires prompt argument')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run`.nothrow()
assert.notStrictEqual(result.exitCode, 0, 'should fail without prompt')
const output = result.stdout + result.stderr
// Commander should complain about missing argument
@@ -64,14 +64,14 @@ try {
output.toLowerCase().includes('required') ||
output.toLowerCase().includes('argument')
assert(hasMissingArg, 'error should mention missing argument')
console.log('✓ agent run requires prompt argument\n')
console.log('✓ run requires prompt argument\n')
}
// Test 3: agent run handles daemon not running
// Test 3: run handles daemon not running
{
console.log('Test 3: agent run handles daemon not running')
console.log('Test 3: run handles daemon not running')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run "test prompt"`.nothrow()
// Should fail because daemon not running
assert.notStrictEqual(result.exitCode, 0, 'should fail when daemon not running')
const output = result.stdout + result.stderr
@@ -80,97 +80,97 @@ try {
output.toLowerCase().includes('connect') ||
output.toLowerCase().includes('cannot')
assert(hasError, 'error message should mention connection issue')
console.log('✓ agent run handles daemon not running\n')
console.log('✓ run handles daemon not running\n')
}
// Test 4: agent run -d flag is accepted
// Test 4: run -d flag is accepted
{
console.log('Test 4: agent run -d flag is accepted')
console.log('Test 4: run -d flag is accepted')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run -d "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run -d "test prompt"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept -d flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ agent run -d flag is accepted\n')
console.log('✓ run -d flag is accepted\n')
}
// Test 5: agent run --name flag is accepted
// Test 5: run --name flag is accepted
{
console.log('Test 5: agent run --name flag is accepted')
console.log('Test 5: run --name flag is accepted')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run --name "test-agent" "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run --name "test-agent" "test prompt"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept --name flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ agent run --name flag is accepted\n')
console.log('✓ run --name flag is accepted\n')
}
// Test 6: agent run --provider flag is accepted
// Test 6: run --provider flag is accepted
{
console.log('Test 6: agent run --provider flag is accepted')
console.log('Test 6: run --provider flag is accepted')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run --provider codex "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run --provider codex "test prompt"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept --provider flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ agent run --provider flag is accepted\n')
console.log('✓ run --provider flag is accepted\n')
}
// Test 7: agent run --mode flag is accepted
// Test 7: run --mode flag is accepted
{
console.log('Test 7: agent run --mode flag is accepted')
console.log('Test 7: run --mode flag is accepted')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run --mode bypass "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run --mode bypass "test prompt"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept --mode flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ agent run --mode flag is accepted\n')
console.log('✓ run --mode flag is accepted\n')
}
// Test 8: agent run --cwd flag is accepted
// Test 8: run --cwd flag is accepted
{
console.log('Test 8: agent run --cwd flag is accepted')
console.log('Test 8: run --cwd flag is accepted')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo agent run --cwd /tmp "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run --cwd /tmp "test prompt"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept --cwd flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ agent run --cwd flag is accepted\n')
console.log('✓ run --cwd flag is accepted\n')
}
// Test 9: -q (quiet) flag is accepted with agent run
// Test 9: -q (quiet) flag is accepted with run
{
console.log('Test 9: -q (quiet) flag is accepted with agent run')
console.log('Test 9: -q (quiet) flag is accepted with run')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo -q agent run -d "test prompt"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo -q run -d "test prompt"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept -q flag')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ -q (quiet) flag is accepted with agent run\n')
console.log('✓ -q (quiet) flag is accepted with run\n')
}
// Test 10: Combined flags work together
{
console.log('Test 10: Combined flags work together')
const result =
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo -q agent run -d --name "test-fixer" --provider claude --mode bypass --cwd /tmp "Fix the tests"`.nothrow()
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo -q run -d --name "test-fixer" --provider claude --mode bypass --cwd /tmp "Fix the tests"`.nothrow()
const output = result.stdout + result.stderr
assert(!output.includes('unknown option'), 'should accept all combined flags')
assert(!output.includes('error: option'), 'should not have option parsing error')
console.log('✓ Combined flags work together\n')
}
// Test 11: agent shows run in subcommands
// Test 11: paseo --help shows run command
{
console.log('Test 11: agent --help shows run subcommand')
const result = await $`npx paseo agent --help`.nothrow()
assert.strictEqual(result.exitCode, 0, 'agent --help should exit 0')
assert(result.stdout.includes('run'), 'help should mention run subcommand')
console.log('✓ agent --help shows run subcommand\n')
console.log('Test 11: paseo --help shows run command')
const result = await $`npx paseo --help`.nothrow()
assert.strictEqual(result.exitCode, 0, 'paseo --help should exit 0')
assert(result.stdout.includes('run'), 'help should mention run command')
console.log('✓ paseo --help shows run command\n')
}
} finally {
// Clean up temp directory
await rm(paseoHome, { recursive: true, force: true })
}
console.log('=== All agent run tests passed ===')
console.log('=== All run tests passed ===')