refactor(prompt): rename subcommands and add frontmatter output
CI / check (pull_request) Successful in 3m1s

- Rename: user→usage-reference, author→workflow-authoring, adapter→adapter-developing
- Remove: developer (content lives in CLAUDE.md)
- All prompts output complete SKILL.md with YAML frontmatter
- Setup instructions simplified: uwf prompt bootstrap > SKILL.md
- Remove all bun references, use pnpm/npm
- Fix CLAUDE.md: fixed→independent versioning
- Delete old reference files (user/author/developer/adapter)

Closes #66
This commit is contained in:
2026-06-04 22:46:11 +08:00
parent 17f7f44c43
commit 83bcda60ff
11 changed files with 141 additions and 257 deletions
@@ -1,5 +1,14 @@
export function generateAdapterReference(): string {
return `# Adapter Reference
import { VERSION } from "./version.js";
export function generateAdapterDevelopingReference(): string {
return `---
name: uwf-adapter-developing
description: "Guide for building a new agent adapter (CLI binary) for the workflow engine."
version: ${VERSION}
tags: [uwf, adapter, agent, development]
---
# Adapter Developing Reference
Guide for building a new agent adapter (CLI binary) for the workflow engine.
+3 -2
View File
@@ -18,8 +18,9 @@ YAML 状态机工作流引擎。当用户提到「workflow」「工作流」时
运行以下命令获取完整用法:
\`\`\`bash
uwf skill user # 用户使用手册(CLI 命令、thread 生命周期
uwf skill author # workflow 编写指南(role 定义、graph 路由、schema)
uwf prompt usage # 完整用法文档(所有引用合并
uwf prompt workflow-authoring # workflow 编写指南(role 定义、graph 路由、schema)
uwf prompt adapter-developing # adapter 开发指南(构建新的 agent adapter)
\`\`\`
## 快速参考
-140
View File
@@ -1,140 +0,0 @@
export function generateDeveloperReference(): string {
return `# Developer Reference
Guide for contributing to the workflow engine codebase.
## Monorepo Structure
\`\`\`
packages/
protocol/ # Shared types (WorkflowPayload, StepNodePayload, etc.)
util/ # Base32, ULID, logger, frontmatter parsing, skill references
util-agent/ # createAgent factory, context builder, extract pipeline
agent-hermes/ # uwf-hermes CLI (spawns Hermes chat sessions)
agent-builtin/ # uwf-builtin CLI (direct LLM calls via OpenAI API)
cli/ # uwf CLI (moderator, thread/step/cas/config commands)
\`\`\`
Dependency layers (each only imports from packages above it):
\`\`\`
protocol → util → util-agent → agent-hermes / agent-builtin / cli
\`\`\`
External CAS: \`@ocas/core\` (store API, hashing, schema validation) + \`@ocas/fs\` (filesystem backend).
## Coding Conventions
### Functional-first
| Rule | Description |
|------|-------------|
| \`type\` over \`interface\` | All type definitions use \`type\` |
| \`function\` over \`class\` | Pure functions + closures, no class |
| No \`this\` | Functions must not depend on \`this\` context |
| No inheritance | No \`extends\`, \`implements\`, \`abstract\` |
| No optional properties | Use \`T \\| null\` instead of \`?:\` |
| Immutability first | Use \`Readonly<T>\`, \`as const\`, avoid mutation |
Classes allowed only when required by third-party libraries or for Error subclasses.
### Error Handling
- \`Result<T, E>\` type for expected failures (\`ok\`/\`err\` constructors from \`@united-workforce/util\`)
- \`throw\` only for unrecoverable bugs
- No try-catch for flow control
### Async
Always \`async/await\`, never \`.then()\` chains.
### Logging
\`console.*\` is banned (Biome \`noConsole\` rule). Use the structured logger:
\`\`\`typescript
import { createLogger } from "@united-workforce/util";
const log = createLogger();
log("4KNMR2PX", "Loading workflow..."); // 8-char Crockford Base32 tag
\`\`\`
Each call site gets a unique hand-written tag. \`grep "4KNMR2PX"\` in logs → instant code location.
CLI package (\`@united-workforce/cli\`) may use \`console.log\` for user-facing output with a biome-ignore comment.
### No Dynamic Import
No \`await import()\` in production code. Always static top-level \`import\`. Test files are exempt.
### Naming
- Workflow names: verb-first kebab-case (\`solve-issue\`, \`review-code\`)
- IDs: Crockford Base32 — CAS hash (XXH64, 13-char), Thread ID (ULID, 26-char)
## Development Workflow
\`\`\`bash
bun install # install all workspace deps
bun run build # tsc --build (all packages)
bun run check # tsc + biome check + lint-log-tags
bun run format # biome format --write
bun test # run all tests
\`\`\`
Before committing: \`bun run check\` + \`bun test\` must both pass.
### Testing
- \`cli\`: vitest
- Other packages: \`bun test\`
- Test files live in \`__tests__/\` directories
### Publishing
Fixed-mode versioning — all \`@united-workforce/*\` packages share the same version number.
\`\`\`bash
bun changeset # describe the change
bun version # bump versions + changelogs
bun release # build + test + publish to npmjs
\`\`\`
## Key Modules
### Moderator (\`cli/src/moderator/\`)
Status-based graph evaluator. Reads \`graph[lastRole][output.$status]\` to determine the next role. Zero LLM cost.
### Extract Pipeline (\`util-agent/src/\`)
1. Agent produces frontmatter markdown
2. \`parseFrontmatterMarkdown()\` extracts YAML frontmatter
3. \`tryFrontmatterFastPath()\` validates against role's output schema
4. If fast path fails, retries up to 2 times via agent continue
5. Validated output stored as CAS node
### createAgent Factory (\`util-agent/src/run.ts\`)
Shared entry point for all agent CLIs. Handles:
- Argument parsing (\`--thread\`, \`--role\`, \`--prompt\`)
- Context building (thread history, workflow definition)
- Output extraction and CAS persistence
- Frontmatter retry loop
### CAS Integration
All data is CAS-addressed via \`@ocas/core\`:
- \`store.put(schemaHash, data)\` → content hash
- \`store.get(hash)\` → node
- \`validate(store, node)\` → schema check
- Schemas registered at workflow add time
## Commit Convention
\`\`\`
<type>(<scope>): <description>
type: feat | fix | refactor | docs | chore | test
scope: workflow | cli | moderator | util-agent | hermes | util | protocol
\`\`\`
`;
}
+4 -4
View File
@@ -1,11 +1,9 @@
export { generateActorReference } from "./actor-reference.js";
export { generateAdapterReference } from "./adapter-reference.js";
export { generateAdapterDevelopingReference } from "./adapter-developing-reference.js";
export { generateArchitectureReference } from "./architecture-reference.js";
export { generateAuthorReference } from "./author-reference.js";
export { encodeUint64AsCrockford } from "./base32.js";
export { generateBootstrapReference } from "./bootstrap-reference.js";
export { generateCliReference } from "./cli-reference.js";
export { generateDeveloperReference } from "./developer-reference.js";
export { env } from "./env.js";
export type {
AgentFrontmatter,
@@ -35,5 +33,7 @@ export {
} from "./storage-root.js";
export type { LogFn, Result } from "./types.js";
export { extractUlidTimestamp, generateUlid } from "./ulid.js";
export { generateUserReference } from "./user-reference.js";
export { generateUsageReference } from "./usage-reference.js";
export { VERSION } from "./version.js";
export { generateWorkflowAuthoringReference } from "./workflow-authoring-reference.js";
export { generateYamlReference } from "./yaml-reference.js";
@@ -1,5 +1,14 @@
export function generateUserReference(): string {
return `# User Reference
import { VERSION } from "./version.js";
export function generateUsageReference(): string {
return `---
name: uwf-usage
description: "Guide for using the uwf CLI to manage workflows and threads."
version: ${VERSION}
tags: [uwf, workflow, cli, usage]
---
# Usage Reference
Guide for using the uwf CLI to manage workflows and threads.
@@ -123,14 +132,13 @@ uwf --format <json|yaml> # output format (default: json)
uwf -V, --version # print version
\`\`\`
## Other Skill References
## Other Prompt References
For specific scenarios, run the corresponding \`uwf skill\` command:
For specific scenarios, run the corresponding \`uwf prompt\` command:
| Scenario | Command | When to use |
|----------|---------|-------------|
| Writing workflow YAML | \`uwf skill author\` | Designing roles, conditions, graphs, and edge prompts |
| Contributing to the engine | \`uwf skill developer\` | Modifying the workflow engine codebase itself |
| Building a new agent adapter | \`uwf skill adapter\` | Creating a new \`uwf-<name>\` CLI adapter |
| Writing workflow YAML | \`uwf prompt workflow-authoring\` | Designing roles, conditions, graphs, and edge prompts |
| Building a new agent adapter | \`uwf prompt adapter-developing\` | Creating a new \`uwf-<name>\` CLI adapter |
`;
}
+2
View File
@@ -0,0 +1,2 @@
// This version is kept in sync with package.json during releases.
export const VERSION = "0.1.0";
@@ -1,5 +1,14 @@
export function generateAuthorReference(): string {
return `# Author Reference
import { VERSION } from "./version.js";
export function generateWorkflowAuthoringReference(): string {
return `---
name: uwf-workflow-authoring
description: "Guide for designing and writing workflow YAML definitions."
version: ${VERSION}
tags: [uwf, workflow, yaml, authoring]
---
# Workflow Authoring Reference
Guide for designing and writing workflow YAML definitions.