feat(cli): help --skill <topic> — context-specific docs for agents

- help --skill (no args) → lists available topics
- help --skill cli → full CLI reference (was: help --skill)
- help --skill develop → thread ID, CAS, meta output guide for roles
- help --skill author → bundle structure, descriptor, role definition
- Role prompts updated: planner/coder reference 'help --skill develop'
- Legacy formatSkillDoc() preserved for compat
- 234 tests (15 new), build clean

Closes #81

小橘 🍊
This commit is contained in:
2026-05-07 15:03:08 +00:00
parent 309af39447
commit 66bca9ef03
5 changed files with 293 additions and 10 deletions
+97 -3
View File
@@ -1,6 +1,11 @@
import { describe, expect, test } from "bun:test";
import { runCli } from "../src/cli-dispatch.js";
import { formatSkillDoc } from "../src/cmd-help.js";
import {
formatSkillDoc,
formatSkillIndex,
formatSkillTopic,
getSkillTopics,
} from "../src/cmd-help.js";
const STORAGE_ROOT = "/tmp/help-test-storage";
@@ -10,13 +15,53 @@ describe("help command", () => {
expect(code).toBe(0);
});
test("help --skill returns 0", async () => {
test("help --skill (no topic) returns 0 and lists topics", async () => {
const code = await runCli(STORAGE_ROOT, ["help", "--skill"]);
expect(code).toBe(0);
});
test("help --skill cli returns 0", async () => {
const code = await runCli(STORAGE_ROOT, ["help", "--skill", "cli"]);
expect(code).toBe(0);
});
test("help --skill develop returns 0", async () => {
const code = await runCli(STORAGE_ROOT, ["help", "--skill", "develop"]);
expect(code).toBe(0);
});
test("help --skill author returns 0", async () => {
const code = await runCli(STORAGE_ROOT, ["help", "--skill", "author"]);
expect(code).toBe(0);
});
test("help --skill unknown returns 1", async () => {
const code = await runCli(STORAGE_ROOT, ["help", "--skill", "unknown"]);
expect(code).toBe(1);
});
});
describe("formatSkillDoc", () => {
describe("getSkillTopics", () => {
test("returns all topics", () => {
const topics = getSkillTopics();
const names = topics.map((t) => t.name);
expect(names).toContain("cli");
expect(names).toContain("develop");
expect(names).toContain("author");
});
});
describe("formatSkillIndex", () => {
test("lists all topics", () => {
const idx = formatSkillIndex();
expect(idx).toContain("cli");
expect(idx).toContain("develop");
expect(idx).toContain("author");
expect(idx).toContain("help --skill <topic>");
});
});
describe("formatSkillTopic('cli') — legacy formatSkillDoc", () => {
const doc = formatSkillDoc();
test("contains title", () => {
@@ -82,3 +127,52 @@ describe("formatSkillDoc", () => {
expect(doc).toContain("## Typical Workflow");
});
});
describe("formatSkillTopic('develop')", () => {
const doc = formatSkillTopic("develop");
test("returns non-null", () => {
expect(doc).not.toBeNull();
});
test("contains thread ID info", () => {
expect(doc).toContain("Thread ID");
expect(doc).toContain("Crockford Base32");
});
test("contains CAS commands", () => {
expect(doc).toContain("cas put");
expect(doc).toContain("cas get");
});
test("contains meta output section", () => {
expect(doc).toContain("Meta Output");
});
});
describe("formatSkillTopic('author')", () => {
const doc = formatSkillTopic("author");
test("returns non-null", () => {
expect(doc).not.toBeNull();
});
test("contains bundle structure", () => {
expect(doc).toContain("Bundle Structure");
expect(doc).toContain(".esm.js");
});
test("contains descriptor info", () => {
expect(doc).toContain("WorkflowDescriptor");
});
test("contains role definition", () => {
expect(doc).toContain("Role Definition");
});
});
describe("formatSkillTopic unknown", () => {
test("returns null for unknown topic", () => {
expect(formatSkillTopic("nonexistent")).toBeNull();
});
});