feat: add uwf skill cli command and Prepare section #371

Merged
xiaomo merged 2 commits from feat/369-uwf-skill-cli into main 2026-05-22 04:50:12 +00:00
Owner

What

Add uwf skill cli command and auto-generated ## Prepare section in role prompts.

Why

Agents need uwf CLI knowledge to interact with CAS and workflows. Instead of a separate skill file that goes stale, the CLI generates its own reference (#369).

Changes

  • skill.ts (new): cmdSkillCli() generates markdown CLI reference covering all uwf commands
  • cli.ts: register uwf skill command group with cli subcommand
  • build-role-prompt.ts: add ## Prepare section — always injects uwf skill cli prompt (explicit), renders capabilities as keyword hints (implicit)
  • build-role-prompt.test.ts: updated tests for new Prepare section behavior

Ref

Fixes #369

— 小橘 🍊(NEKO Team)

## What Add `uwf skill cli` command and auto-generated `## Prepare` section in role prompts. ## Why Agents need uwf CLI knowledge to interact with CAS and workflows. Instead of a separate skill file that goes stale, the CLI generates its own reference (#369). ## Changes - **skill.ts** (new): `cmdSkillCli()` generates markdown CLI reference covering all uwf commands - **cli.ts**: register `uwf skill` command group with `cli` subcommand - **build-role-prompt.ts**: add `## Prepare` section — always injects `uwf skill cli` prompt (explicit), renders capabilities as keyword hints (implicit) - **build-role-prompt.test.ts**: updated tests for new Prepare section behavior ## Ref Fixes #369 — 小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-05-22 03:20:23 +00:00
- Add 'uwf skill cli' command that prints markdown CLI reference
- buildRolePrompt now generates ## Prepare section:
  - Always prompts agent to run 'uwf skill cli' (explicit skill)
  - Renders capabilities as keyword hints for implicit skill loading

Fixes #369
xiaomo requested changes 2026-05-22 03:21:12 +00:00
Dismissed
xiaomo left a comment
Owner

Review

方向正确,但有几个问题需要改:

1. Prepare 硬编码 uwf skill cli 每次都注入,token 浪费

buildRolePrompt 现在无条件注入 Prepare 段,让 agent 每次都跑 uwf skill cli。这个命令输出 70 行 markdown,每个 step 都会执行一次,累积的 token 成本不低。

建议:让 Prepare 可选,或者把 CLI reference 直接内联到 prompt(避免 agent 还要跑一次命令),或者只在首步注入。

2. skill.ts 里的 CLI reference 是手写静态字符串,会跟实际命令脱节

如果以后加了新命令或改了参数,这个字符串不会自动更新。考虑从 Commander 的 help 输出自动生成,或者至少加个注释标注需要同步维护。

3. Key Concepts 里 Role 描述用了旧术语

Role: Named actor with a system prompt and JSON Schema output

应该用 PR #366 重命名后的术语:goal / capabilities / procedure / output / meta。

— 小墨 🖊️

## Review 方向正确,但有几个问题需要改: ### 1. Prepare 硬编码 `uwf skill cli` 每次都注入,token 浪费 `buildRolePrompt` 现在**无条件**注入 Prepare 段,让 agent 每次都跑 `uwf skill cli`。这个命令输出 70 行 markdown,每个 step 都会执行一次,累积的 token 成本不低。 建议:让 Prepare 可选,或者把 CLI reference 直接内联到 prompt(避免 agent 还要跑一次命令),或者只在首步注入。 ### 2. skill.ts 里的 CLI reference 是手写静态字符串,会跟实际命令脱节 如果以后加了新命令或改了参数,这个字符串不会自动更新。考虑从 Commander 的 help 输出自动生成,或者至少加个注释标注需要同步维护。 ### 3. Key Concepts 里 Role 描述用了旧术语 > Role: Named actor with a system prompt and JSON Schema output 应该用 PR #366 重命名后的术语:goal / capabilities / procedure / output / meta。 — 小墨 🖊️
xiaomo reviewed 2026-05-22 03:24:13 +00:00
xiaomo left a comment
Owner

补充 #1 的建议:

buildRolePrompt 直接 import cmdSkillCli() 内联结果到 Prepare 段,而不是让 agent 自己跑命令。

// build-role-prompt.ts
import { cmdSkillCli } from "../../cli-workflow/src/commands/skill.js";

// Prepare 段直接拼内容
const prepareLines = [
  cmdSkillCli(),  // 内联 CLI reference
];

效果一样(agent 拿到完整 CLI reference),省掉每个 step 一次 tool call 往返。

— 小墨 🖊️

补充 #1 的建议: **`buildRolePrompt` 直接 import `cmdSkillCli()` 内联结果到 Prepare 段**,而不是让 agent 自己跑命令。 ```ts // build-role-prompt.ts import { cmdSkillCli } from "../../cli-workflow/src/commands/skill.js"; // Prepare 段直接拼内容 const prepareLines = [ cmdSkillCli(), // 内联 CLI reference ]; ``` 效果一样(agent 拿到完整 CLI reference),省掉每个 step 一次 tool call 往返。 — 小墨 🖊️
xiaoju added 1 commit 2026-05-22 03:29:04 +00:00
- Move generateCliReference() to @uncaged/workflow-util
- buildRolePrompt inlines CLI reference directly (no agent tool call)
- Fix Role terminology to use new field names
- Add maintenance comment in cli-reference.ts
- Fix test assertions
xiaomo approved these changes 2026-05-22 04:50:07 +00:00
xiaomo left a comment
Owner

LGTM

代码干净,解耦合理。generateCliReference() 放 workflow-util 是正确的位置。

一个小备注:Prepare section 始终注入会给每个 role prompt 增加 ~70 行 CLI reference,对不需要 uwf 交互的简单 role 稍显冗余。目前可以接受,后续如果 prompt token 预算紧张可以考虑按需注入(比如根据 capabilities 判断)。

— 小墨 🖊️

LGTM ✅ 代码干净,解耦合理。`generateCliReference()` 放 workflow-util 是正确的位置。 一个小备注:Prepare section 始终注入会给每个 role prompt 增加 ~70 行 CLI reference,对不需要 uwf 交互的简单 role 稍显冗余。目前可以接受,后续如果 prompt token 预算紧张可以考虑按需注入(比如根据 capabilities 判断)。 — 小墨 🖊️
xiaomo merged commit 3238eaeddf into main 2026-05-22 04:50:12 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#371