fix: simplify prompt subcommands, framework-agnostic bootstrap
CI / check (pull_request) Successful in 3m24s

- `uwf prompt usage` now outputs only the usage skill (was three combined)
- `uwf prompt bootstrap` replaces `setup` with framework-agnostic instructions
- Remove `usage-reference` and `setup` subcommands
- Remove `generateBootstrapReference` from util (moved to cli)

Fixes #99

小橘 🍊(NEKO Team)
This commit is contained in:
2026-06-05 08:52:35 +00:00
parent 9260d81084
commit a536efee00
5 changed files with 45 additions and 148 deletions
+19 -46
View File
@@ -9,31 +9,25 @@ import {
cmdPromptAdapterDeveloping, cmdPromptAdapterDeveloping,
cmdPromptBootstrap, cmdPromptBootstrap,
cmdPromptList, cmdPromptList,
cmdPromptSetup,
cmdPromptUsage, cmdPromptUsage,
cmdPromptUsageReference,
cmdPromptWorkflowAuthoring, cmdPromptWorkflowAuthoring,
} from "../commands/prompt.js"; } from "../commands/prompt.js";
describe("prompt commands", () => { describe("prompt commands", () => {
test("prompt list returns new prompt names", () => { test("prompt list returns prompt names (no bootstrap)", () => {
const result = cmdPromptList(); const result = cmdPromptList();
expect(result).toBeInstanceOf(Array); expect(result).toBeInstanceOf(Array);
expect(result).toContain("usage"); expect(result).toContain("usage");
expect(result).toContain("workflow-authoring"); expect(result).toContain("workflow-authoring");
expect(result).toContain("adapter-developing"); expect(result).toContain("adapter-developing");
expect(result).toContain("bootstrap"); expect(result).not.toContain("bootstrap");
expect(result).not.toContain("user");
expect(result).not.toContain("author");
expect(result).not.toContain("developer");
expect(result).not.toContain("adapter");
for (const name of result) { for (const name of result) {
expect(name).toMatch(/^\S+$/); expect(name).toMatch(/^\S+$/);
} }
}); });
test("prompt usage-reference returns non-empty markdown string with frontmatter", () => { test("prompt usage returns only the usage reference with frontmatter", () => {
const result = cmdPromptUsageReference(); const result = cmdPromptUsage();
expect(typeof result).toBe("string"); expect(typeof result).toBe("string");
expect(result).toContain("uwf"); expect(result).toContain("uwf");
expect(result).toContain("thread"); expect(result).toContain("thread");
@@ -42,6 +36,9 @@ describe("prompt commands", () => {
expect(result).toContain("---"); expect(result).toContain("---");
expect(result).toContain("name:"); expect(result).toContain("name:");
expect(result).toContain("version:"); expect(result).toContain("version:");
// Should NOT contain other references
expect(result).not.toContain("Workflow Authoring Reference");
expect(result).not.toContain("Adapter Developing Reference");
expect(result.length).toBeGreaterThan(500); expect(result.length).toBeGreaterThan(500);
}); });
@@ -71,44 +68,19 @@ describe("prompt commands", () => {
expect(result.length).toBeGreaterThan(500); expect(result.length).toBeGreaterThan(500);
}); });
test("prompt bootstrap returns non-empty skill with frontmatter", () => { test("prompt bootstrap returns framework-agnostic setup instructions", () => {
const result = cmdPromptBootstrap(); const result = cmdPromptBootstrap();
expect(typeof result).toBe("string"); expect(typeof result).toBe("string");
expect(result).toContain("uwf");
expect(result).toContain("---");
expect(result.length).toBeGreaterThan(100);
});
test("prompt usage combines remaining references (no developer)", () => {
const result = cmdPromptUsage();
expect(typeof result).toBe("string");
expect(result).toContain("Usage Reference");
expect(result).toContain("Workflow Authoring Reference");
expect(result).toContain("Adapter Developing Reference");
expect(result).not.toContain("Developer Reference");
expect(result).toContain("---");
expect(result.length).toBeGreaterThan(2000);
});
test("prompt setup returns simplified setup instructions", () => {
const result = cmdPromptSetup();
expect(typeof result).toBe("string");
expect(result).toContain("uwf Skill Setup");
expect(result).toContain("uwf prompt bootstrap");
expect(result).toContain("SKILL.md");
expect(result).toContain("version");
expect(result).not.toMatch(/\bbun (install|run|test|changeset|version|release)\b/);
});
test("prompt setup references new subcommand names", () => {
const result = cmdPromptSetup();
expect(result).toContain("uwf prompt usage"); expect(result).toContain("uwf prompt usage");
expect(result).toContain("uwf prompt workflow-authoring"); expect(result).toContain("uwf prompt workflow-authoring");
expect(result).toContain("uwf prompt adapter-developing"); expect(result).toContain("uwf prompt adapter-developing");
expect(result).not.toContain("uwf prompt user"); expect(result).toContain("uwf-usage");
expect(result).not.toContain("uwf prompt author"); expect(result).toContain("uwf-workflow-authoring");
expect(result).not.toContain("uwf prompt developer"); expect(result).toContain("uwf-adapter-developing");
expect(result).not.toMatch(/uwf prompt adapter\b(?!-developing)/); // Should NOT contain Hermes-specific paths
expect(result).not.toContain("~/.hermes/skills/");
expect(result).not.toContain("> ~/.hermes/");
expect(result.length).toBeGreaterThan(100);
}); });
test("prompt help subcommand is suppressed", { timeout: 30_000 }, () => { test("prompt help subcommand is suppressed", { timeout: 30_000 }, () => {
@@ -119,11 +91,12 @@ describe("prompt commands", () => {
}); });
expect(output).not.toMatch(/help\s+\[command\]/i); expect(output).not.toMatch(/help\s+\[command\]/i);
expect(output).toContain("usage"); expect(output).toContain("usage");
expect(output).toContain("setup"); expect(output).toContain("bootstrap");
expect(output).toContain("workflow-authoring"); expect(output).toContain("workflow-authoring");
expect(output).toContain("adapter-developing"); expect(output).toContain("adapter-developing");
expect(output).toContain("bootstrap");
expect(output).toContain("list"); expect(output).toContain("list");
expect(output).not.toContain("developer"); // Removed subcommands should not appear as command names
expect(output).not.toMatch(/^\s+setup\s/m);
expect(output).not.toContain("usage-reference");
}); });
}); });
+4 -20
View File
@@ -8,9 +8,7 @@ import {
cmdPromptAdapterDeveloping, cmdPromptAdapterDeveloping,
cmdPromptBootstrap, cmdPromptBootstrap,
cmdPromptList, cmdPromptList,
cmdPromptSetup,
cmdPromptUsage, cmdPromptUsage,
cmdPromptUsageReference,
cmdPromptWorkflowAuthoring, cmdPromptWorkflowAuthoring,
} from "./commands/prompt.js"; } from "./commands/prompt.js";
import { cmdSetup, cmdSetupInteractive } from "./commands/setup.js"; import { cmdSetup, cmdSetupInteractive } from "./commands/setup.js";
@@ -509,23 +507,16 @@ prompt.addHelpCommand(false);
prompt prompt
.command("usage") .command("usage")
.description("Print the complete skill content (all references combined)") .description("Print the usage reference (CLI guide + typical workflows)")
.action(() => { .action(() => {
console.log(cmdPromptUsage()); console.log(cmdPromptUsage());
}); });
prompt prompt
.command("setup") .command("bootstrap")
.description("Print setup instructions for installing the uwf skill") .description("Print setup instructions for installing uwf skills")
.action(() => { .action(() => {
console.log(cmdPromptSetup()); console.log(cmdPromptBootstrap());
});
prompt
.command("usage-reference")
.description("Print the usage reference (CLI guide + typical workflows)")
.action(() => {
console.log(cmdPromptUsageReference());
}); });
prompt prompt
@@ -542,13 +533,6 @@ prompt
console.log(cmdPromptAdapterDeveloping()); console.log(cmdPromptAdapterDeveloping());
}); });
prompt
.command("bootstrap")
.description("Print the bootstrap skill YAML for Hermes agents")
.action(() => {
console.log(cmdPromptBootstrap());
});
prompt prompt
.command("list") .command("list")
.description("List all available prompt names") .description("List all available prompt names")
+21 -40
View File
@@ -1,14 +1,13 @@
import { import {
generateAdapterDevelopingReference, generateAdapterDevelopingReference,
generateBootstrapReference,
generateUsageReference, generateUsageReference,
generateWorkflowAuthoringReference, generateWorkflowAuthoringReference,
VERSION,
} from "@united-workforce/util"; } from "@united-workforce/util";
export { export {
generateAdapterDevelopingReference as cmdPromptAdapterDeveloping, generateAdapterDevelopingReference as cmdPromptAdapterDeveloping,
generateBootstrapReference as cmdPromptBootstrap, generateUsageReference as cmdPromptUsage,
generateUsageReference as cmdPromptUsageReference,
generateWorkflowAuthoringReference as cmdPromptWorkflowAuthoring, generateWorkflowAuthoringReference as cmdPromptWorkflowAuthoring,
}; };
@@ -16,24 +15,16 @@ const PROMPT_ENTRIES: ReadonlyArray<{ name: string; generate: () => string }> =
{ name: "usage", generate: generateUsageReference }, { name: "usage", generate: generateUsageReference },
{ name: "workflow-authoring", generate: generateWorkflowAuthoringReference }, { name: "workflow-authoring", generate: generateWorkflowAuthoringReference },
{ name: "adapter-developing", generate: generateAdapterDevelopingReference }, { name: "adapter-developing", generate: generateAdapterDevelopingReference },
{ name: "bootstrap", generate: generateBootstrapReference },
]; ];
export function cmdPromptList(): ReadonlyArray<string> { export function cmdPromptList(): ReadonlyArray<string> {
return PROMPT_ENTRIES.map((e) => e.name); return PROMPT_ENTRIES.map((e) => e.name);
} }
export function cmdPromptUsage(): string { export function cmdPromptBootstrap(): string {
return PROMPT_ENTRIES.filter((e) => e.name !== "bootstrap") return `# uwf Skill Bootstrap
.map((e) => e.generate())
.join("\n\n---\n\n");
}
export function cmdPromptSetup(): string { Install or update the uwf (United Workforce) skills for your agent.
return `# uwf Skill Setup
You are being asked to install or update the uwf (United Workforce) skill
so that you know how to use the \`uwf\` CLI for workflow orchestration.
## Steps ## Steps
@@ -42,40 +33,30 @@ so that you know how to use the \`uwf\` CLI for workflow orchestration.
uwf --help uwf --help
\`\`\` \`\`\`
If not installed: \`npm install -g @united-workforce/cli\` If not installed: \`npm install -g @united-workforce/cli\`
Current version: ${VERSION}
2. **Clean up old versions of the skill** (if any exist): 2. **Install the skills** by running each command below and creating a skill from its output:
- Look for any existing uwf/workflow skill files in your skill directories - Run \`uwf prompt usage\` → create a skill named \`uwf-usage\`
(e.g. \`~/.hermes/skills/uwf/SKILL.md\` or similar paths). - Run \`uwf prompt workflow-authoring\` → create a skill named \`uwf-workflow-authoring\`
- If a skill exists, read its \`version\` from the YAML frontmatter. - Run \`uwf prompt adapter-developing\` → create a skill named \`uwf-adapter-developing\`
- If the version matches the current CLI version (\`uwf --version\`), you're done — no update needed.
- If the version is older, **delete the old skill file** before proceeding.
3. **Install the bootstrap skill:** Each command outputs a complete SKILL.md with YAML frontmatter — use your agent framework's skill creation API to save them.
\`\`\`bash
uwf prompt bootstrap > ~/.hermes/skills/uwf/SKILL.md
\`\`\`
The bootstrap prompt already includes complete YAML frontmatter — no editing needed.
4. **Verify** the skill is loadable by your agent framework. 3. **Verify** the skills are loadable by your agent framework.
## Individual prompts ## Updating
Each prompt outputs a complete SKILL.md with frontmatter — pipe directly to a file: When \`uwf\` is upgraded, re-run \`uwf prompt bootstrap\` and follow the steps again.
The skill content is bundled with the CLI — always use \`uwf prompt <name>\` to get
content matching your installed version.
## Available prompts
\`\`\`bash \`\`\`bash
uwf prompt list # list available prompt names uwf prompt list # list available prompt names
uwf prompt usage > ~/.hermes/skills/uwf-usage/SKILL.md # CLI usage guide uwf prompt usage # CLI usage guide
uwf prompt workflow-authoring > ~/.hermes/skills/uwf-workflow-authoring/SKILL.md uwf prompt workflow-authoring # workflow YAML design guide
uwf prompt adapter-developing > ~/.hermes/skills/uwf-adapter-developing/SKILL.md uwf prompt adapter-developing # building agent adapters
uwf prompt bootstrap > ~/.hermes/skills/uwf/SKILL.md # bootstrap skill
\`\`\` \`\`\`
## Notes
- The skill content is bundled with the CLI and versioned with it — always use
\`uwf prompt usage\` to get the content matching your installed version.
- Do NOT hand-edit the skill body. If the CLI is updated, re-run \`uwf prompt setup\`
and follow the steps again.
- When upgrading, always delete the old skill first to avoid stale instructions.
`; `;
} }
-40
View File
@@ -1,40 +0,0 @@
export function generateBootstrapReference(): string {
return `---
name: uwf
description: "United Workforce (uwf) — YAML 状态机工作流引擎。任务涉及 workflow 时加载此 skill。"
tags: [workflow, uwf]
triggers:
- uwf
- workflow
- 工作流
---
# uwf (United Workforce)
YAML 状态机工作流引擎。当用户提到「workflow」「工作流」时,指的是 **uwf workflow**(YAML 定义的状态机),不是 Hermes skill。用 \`uwf\` CLI 操作,不要混淆。
## 首次使用
运行以下命令获取完整用法:
\`\`\`bash
uwf prompt usage # 完整用法文档(所有引用合并)
uwf prompt workflow-authoring # workflow 编写指南(role 定义、graph 路由、schema)
uwf prompt adapter-developing # adapter 开发指南(构建新的 agent adapter)
\`\`\`
## 快速参考
\`\`\`bash
uwf workflow list # 查看已注册 workflow
uwf workflow add <file.yaml> # 注册 workflow
uwf thread start <workflow> -p "prompt" # 创建 thread
uwf thread exec <thread-id> -c 10 # 执行最多 10 步
uwf thread list # 查看所有 thread
\`\`\`
## 示例 workflow
参考项目 \`examples/\` 目录下的 YAML 文件(analyze-topic、debate、solve-issue)。
`;
}
-1
View File
@@ -2,7 +2,6 @@ export { generateActorReference } from "./actor-reference.js";
export { generateAdapterDevelopingReference } from "./adapter-developing-reference.js"; export { generateAdapterDevelopingReference } from "./adapter-developing-reference.js";
export { generateArchitectureReference } from "./architecture-reference.js"; export { generateArchitectureReference } from "./architecture-reference.js";
export { encodeUint64AsCrockford } from "./base32.js"; export { encodeUint64AsCrockford } from "./base32.js";
export { generateBootstrapReference } from "./bootstrap-reference.js";
export { generateCliReference } from "./cli-reference.js"; export { generateCliReference } from "./cli-reference.js";
export { env } from "./env.js"; export { env } from "./env.js";
export type { export type {