Upgrade CLI to v0.2.0: add validate, list commands, --version, --dry-run, --backup flags
- Fix npm test glob pattern for Node >= 21 compatibility - Add --version/-v flag to display package version - Add validate command: run 78 profile checks (files, skills, frontmatter, legacy patterns, AGENTS mapping) - Add list command: display all 13 bundled skills with descriptions - Add --dry-run/-n flag for init: preview files without copying - Add --backup/-b flag for init --force: backup existing .agent before overwrite - Add name field to workflow frontmatter (brainstorm, execute-plan, write-plan) - Expand smoke check to cover all 13 skills and new command files - Increase test coverage from 3 to 20 tests (cli, init, validate) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
73
tests/validate.test.mjs
Normal file
73
tests/validate.test.mjs
Normal file
@@ -0,0 +1,73 @@
|
||||
import { mkdtemp, mkdir, rm } from "node:fs/promises";
|
||||
import { join, resolve } from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { tmpdir } from "node:os";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
const cliPath = resolve(process.cwd(), "bin/antigravity-superpowers.js");
|
||||
|
||||
function runCli(args, cwd) {
|
||||
return spawnSync(process.execPath, [cliPath, ...args], {
|
||||
cwd,
|
||||
encoding: "utf8",
|
||||
});
|
||||
}
|
||||
|
||||
async function createTempProject(prefix) {
|
||||
return mkdtemp(join(tmpdir(), prefix));
|
||||
}
|
||||
|
||||
test("validate passes on freshly initialized project", async () => {
|
||||
const projectDir = await createTempProject("agsp-val-pass-");
|
||||
|
||||
try {
|
||||
runCli(["init"], projectDir);
|
||||
const result = runCli(["validate"], projectDir);
|
||||
assert.equal(result.status, 0);
|
||||
assert.match(result.stdout, /PASSED/);
|
||||
assert.match(result.stdout, /Failed: 0/);
|
||||
} finally {
|
||||
await rm(projectDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("validate fails when .agent is missing", async () => {
|
||||
const projectDir = await createTempProject("agsp-val-missing-");
|
||||
|
||||
try {
|
||||
const result = runCli(["validate"], projectDir);
|
||||
assert.equal(result.status, 1);
|
||||
assert.match(result.stderr, /No \.agent directory/);
|
||||
} finally {
|
||||
await rm(projectDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("validate fails when skills are missing", async () => {
|
||||
const projectDir = await createTempProject("agsp-val-incomplete-");
|
||||
|
||||
try {
|
||||
// Create partial .agent
|
||||
await mkdir(join(projectDir, ".agent"), { recursive: true });
|
||||
const result = runCli(["validate"], projectDir);
|
||||
assert.equal(result.status, 1);
|
||||
assert.match(result.stdout, /FAIL/);
|
||||
assert.match(result.stdout, /FAILED/);
|
||||
} finally {
|
||||
await rm(projectDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("validate accepts target directory argument", async () => {
|
||||
const projectDir = await createTempProject("agsp-val-target-");
|
||||
|
||||
try {
|
||||
runCli(["init"], projectDir);
|
||||
const result = runCli(["validate", projectDir]);
|
||||
assert.equal(result.status, 0);
|
||||
assert.match(result.stdout, /PASSED/);
|
||||
} finally {
|
||||
await rm(projectDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user