Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0e0e561f3 | |||
| a33f12c74f | |||
| 0ad10b9b6d | |||
| 3be92bfac2 | |||
| 8d6f480b0f | |||
| 5450bc1230 | |||
| f1f122b0b1 | |||
| 57ae6d1755 | |||
| d64d150071 | |||
| c5eb8b79d1 | |||
| 36a3ca6a08 | |||
| eb0b7b514f | |||
| a47871ec4e | |||
| 5851e5d162 | |||
| 61dfb40933 | |||
| fbfd31a042 | |||
| d99a376b60 | |||
| a536efee00 | |||
| 9260d81084 | |||
| c8d884072a | |||
| abeb465f46 | |||
| 28427a973f | |||
| 794f9db568 | |||
| cd585a26f1 | |||
| 1cf8f350d0 |
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
"@united-workforce/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: expand bootstrap prompt with full onboarding and upgrade guide
|
||||||
|
|
||||||
|
Bootstrap now covers two scenarios:
|
||||||
|
- Fresh install: CLI + adapter installation, `uwf setup` configuration, skill installation, end-to-end verification
|
||||||
|
- Upgrade: package update, skill regeneration, breaking change migrations (e.g. $START new/resume)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
"@united-workforce/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: bootstrap adds Step 0 environment pre-flight check
|
||||||
|
|
||||||
|
- Pre-flight checks for node, pnpm/npm, global bin PATH, hermes CLI with FIX instructions (#112)
|
||||||
|
- Install commands changed from npm to pnpm (with npm fallback)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
"@united-workforce/cli": patch
|
||||||
|
"@united-workforce/util": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: workflow-authoring flat schema example uses enum, bootstrap adds PATH guidance
|
||||||
|
|
||||||
|
- workflow-authoring: flat schema example uses `enum: [done]` instead of bare `const` (#110.3)
|
||||||
|
- bootstrap: adds `which hermes` check and PATH guidance for venv installs (#110.4)
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
"@united-workforce/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: preset provider base-url auto-fill, bootstrap ACP docs, friendlier name mismatch error
|
||||||
|
|
||||||
|
- `uwf setup --provider dashscope` now auto-fills `--base-url` from preset list (#106)
|
||||||
|
- Bootstrap guide documents uwf-hermes ACP dependency (`pip install hermes-agent[acp]`) (#107)
|
||||||
|
- Bootstrap verify step uses inline workflow instead of missing `examples/eval-simple.yaml` (#107)
|
||||||
|
- Workflow filename mismatch error now suggests how to fix it (#108)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
"@united-workforce/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: setup UX improvements (#114)
|
||||||
|
|
||||||
|
- Setup validates adapter availability and prints install command if missing
|
||||||
|
- Setup prints "Config saved to <path> ✓" on success
|
||||||
|
- Spawn ENOENT gives actionable error ("not found in PATH" + which command)
|
||||||
|
- SQLite ExperimentalWarning suppressed via NODE_OPTIONS in spawned processes
|
||||||
|
- Bootstrap VERSION reads cli package version (was reading util version)
|
||||||
|
- Bootstrap PATH guidance is shell-agnostic (no hardcoded .bashrc/.profile)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
"@united-workforce/cli": minor
|
||||||
|
"@united-workforce/util": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: replace $START `_` status with `new`/`resume` semantics
|
||||||
|
|
||||||
|
BREAKING: All workflow YAML files must update `$START._` to `$START.new` + `$START.resume`.
|
||||||
|
The `resume` edge prompt replaces the previously hardcoded resume message in the CLI.
|
||||||
@@ -264,7 +264,8 @@ roles:
|
|||||||
|
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: "bootstrap", prompt: "Set up the Docker container and verify uwf is runnable." }
|
new: { role: "bootstrap", prompt: "Set up the Docker container and verify uwf is runnable." }
|
||||||
|
resume: { role: "bootstrap", prompt: "Review the previous run output and continue the walkthrough." }
|
||||||
bootstrap:
|
bootstrap:
|
||||||
pass: { role: "config-and-registry", prompt: "Container {{{containerName}}} is ready. Validate config and workflow registration." }
|
pass: { role: "config-and-registry", prompt: "Container {{{containerName}}} is ready. Validate config and workflow registration." }
|
||||||
fail: { role: "$END", prompt: "Bootstrap failed: {{{error}}}. No container was created." }
|
fail: { role: "$END", prompt: "Bootstrap failed: {{{error}}}. No container was created." }
|
||||||
|
|||||||
@@ -227,7 +227,8 @@ roles:
|
|||||||
required: [$status, error]
|
required: [$status, error]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: "planner", prompt: "Analyze the issue and produce an implementation plan." }
|
new: { role: "planner", prompt: "Analyze the issue and produce an implementation plan." }
|
||||||
|
resume: { role: "planner", prompt: "Review the previous run output and continue the work." }
|
||||||
planner:
|
planner:
|
||||||
insufficient_info: { role: "$SUSPEND", prompt: "信息不足,需要补充:{{{reason}}}" }
|
insufficient_info: { role: "$SUSPEND", prompt: "信息不足,需要补充:{{{reason}}}" }
|
||||||
ready: { role: "developer", prompt: "Implement the TDD test spec (CAS hash: {{{plan}}}) in repo {{{repoPath}}}. Repo remote: {{{repoRemote}}}." }
|
ready: { role: "developer", prompt: "Implement the TDD test spec (CAS hash: {{{plan}}}) in repo {{{repoPath}}}. Repo remote: {{{repoRemote}}}." }
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ payload:
|
|||||||
|
|
||||||
- `roles` — 内联定义,每个 role 的 `meta` 是独立的 ocas_ref(指向 ocas 内置 JSON Schema 节点)
|
- `roles` — 内联定义,每个 role 的 `meta` 是独立的 ocas_ref(指向 ocas 内置 JSON Schema 节点)
|
||||||
- `graph` — `Record<Role | "$START", Record<Status, Target>>`,每个 Target = `{ role, prompt }`
|
- `graph` — `Record<Role | "$START", Record<Status, Target>>`,每个 Target = `{ role, prompt }`
|
||||||
- Status 来自上一个 role 输出的 `status` 字段,`$START` 用 `_` 作为初始 status
|
- Status 来自上一个 role 输出的 `$status` 字段,`$START` 使用 `new`(首次启动)和 `resume`(恢复已完成的 thread)作为 status
|
||||||
- Prompt 模板使用 Mustache 渲染,变量来自 lastOutput
|
- Prompt 模板使用 Mustache 渲染,变量来自 lastOutput
|
||||||
- 不含 agent binding — agent 配置在 `~/.uwf/config.yaml` 中管理
|
- 不含 agent binding — agent 配置在 `~/.uwf/config.yaml` 中管理
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ Moderator 的求值逻辑:
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
evaluate(graph, lastRole, lastOutput) → { role, prompt }
|
evaluate(graph, lastRole, lastOutput) → { role, prompt }
|
||||||
// 1. status = lastRole === "$START" ? "_" : lastOutput.status
|
// 1. status = lastOutput.$status (e.g. "new" for $START first run, "resume" for completed thread resume)
|
||||||
// 2. target = graph[lastRole][status]
|
// 2. target = graph[lastRole][status]
|
||||||
// 3. prompt = mustache.render(target.prompt, lastOutput)
|
// 3. prompt = mustache.render(target.prompt, lastOutput)
|
||||||
```
|
```
|
||||||
@@ -422,8 +422,8 @@ type StepNodePayload = StepRecord & {
|
|||||||
Moderator 使用 `evaluate(graph, lastRole, lastOutput)` 进行同步 status-based routing:
|
Moderator 使用 `evaluate(graph, lastRole, lastOutput)` 进行同步 status-based routing:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// graph[lastRole][lastOutput.status] → Target { role, prompt }
|
// graph[lastRole][lastOutput.$status] → Target { role, prompt }
|
||||||
// $START 角色使用 "_" 作为初始 status
|
// $START 使用 "new"(首次启动)和 "resume"(恢复已完成 thread)作为 status
|
||||||
// prompt 通过 Mustache 模板渲染,变量来自 lastOutput
|
// prompt 通过 Mustache 模板渲染,变量来自 lastOutput
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ roles:
|
|||||||
required: [$status, thesis, keyPoints]
|
required: [$status, thesis, keyPoints]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: "analyst", prompt: "Analyze the topic in the task and produce a structured summary with key points." }
|
new: { role: "analyst", prompt: "Analyze the topic in the task and produce a structured summary with key points." }
|
||||||
|
resume: { role: "analyst", prompt: "Review the previous analysis output and continue with additional context." }
|
||||||
analyst:
|
analyst:
|
||||||
done: { role: "$END", prompt: "Analysis complete. Finish the workflow." }
|
done: { role: "$END", prompt: "Analysis complete. Finish the workflow." }
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ roles:
|
|||||||
required: [$status, argument]
|
required: [$status, argument]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: "against", prompt: "Present your opening argument against the proposition." }
|
new: { role: "against", prompt: "Present your opening argument against the proposition." }
|
||||||
|
resume: { role: "against", prompt: "Review the previous debate output and continue the argument against the proposition." }
|
||||||
against:
|
against:
|
||||||
conceded: { role: "$END", prompt: "The against side conceded. Debate over." }
|
conceded: { role: "$END", prompt: "The against side conceded. Debate over." }
|
||||||
continue: { role: "for", prompt: "Counter the opposing argument: {{{argument}}}" }
|
continue: { role: "for", prompt: "Counter the opposing argument: {{{argument}}}" }
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ roles:
|
|||||||
required: [$status, summary]
|
required: [$status, summary]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: "fixer", prompt: "Fix the code issue described in the task prompt." }
|
new: { role: "fixer", prompt: "Fix the code issue described in the task prompt." }
|
||||||
|
resume: { role: "fixer", prompt: "Review the previous run output and continue fixing the code issue." }
|
||||||
fixer:
|
fixer:
|
||||||
done: { role: "$END", prompt: "Fix complete." }
|
done: { role: "$END", prompt: "Fix complete." }
|
||||||
|
|||||||
@@ -215,7 +215,8 @@ roles:
|
|||||||
required: [$status, error]
|
required: [$status, error]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: "planner", prompt: "Analyze the issue and produce an implementation plan." }
|
new: { role: "planner", prompt: "Analyze the issue and produce an implementation plan." }
|
||||||
|
resume: { role: "planner", prompt: "Review the previous run output and continue the work." }
|
||||||
planner:
|
planner:
|
||||||
insufficient_info: { role: "$SUSPEND", prompt: "信息不足,需要补充:{{{reason}}}" }
|
insufficient_info: { role: "$SUSPEND", prompt: "信息不足,需要补充:{{{reason}}}" }
|
||||||
ready: { role: "developer", prompt: "Implement the TDD test spec (CAS hash: {{{plan}}}) in repo {{{repoPath}}}." }
|
ready: { role: "developer", prompt: "Implement the TDD test spec (CAS hash: {{{plan}}}) in repo {{{repoPath}}}." }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-builtin",
|
"name": "@united-workforce/agent-builtin",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
||||||
|
process.stdout.write(`${pkg.default.version}\n`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
import { createBuiltinAgent } from "./agent.js";
|
import { createBuiltinAgent } from "./agent.js";
|
||||||
|
|
||||||
const main = createBuiltinAgent();
|
const main = createBuiltinAgent();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-claude-code",
|
"name": "@united-workforce/agent-claude-code",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
||||||
|
process.stdout.write(`${pkg.default.version}\n`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
import { createClaudeCodeAgent } from "./claude-code.js";
|
import { createClaudeCodeAgent } from "./claude-code.js";
|
||||||
|
|
||||||
const model = process.env.CLAUDE_MODEL ?? null;
|
const model = process.env.CLAUDE_MODEL ?? null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-hermes",
|
"name": "@united-workforce/agent-hermes",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
import type { ChildProcess } from "node:child_process";
|
import type { ChildProcess } from "node:child_process";
|
||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
import { createInterface } from "node:readline";
|
import { createInterface } from "node:readline";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const OWN_VERSION = (
|
||||||
|
JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8")) as {
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
).version;
|
||||||
|
|
||||||
const HERMES_COMMAND = "hermes";
|
const HERMES_COMMAND = "hermes";
|
||||||
const PROTOCOL_VERSION = 1;
|
const PROTOCOL_VERSION = 1;
|
||||||
@@ -299,7 +309,7 @@ export class HermesAcpClient {
|
|||||||
private async initialize(): Promise<void> {
|
private async initialize(): Promise<void> {
|
||||||
const initResponse = await this.sendRequest("initialize", {
|
const initResponse = await this.sendRequest("initialize", {
|
||||||
protocolVersion: PROTOCOL_VERSION,
|
protocolVersion: PROTOCOL_VERSION,
|
||||||
clientInfo: { name: "uwf", version: "0.1.0" },
|
clientInfo: { name: "uwf-hermes", version: OWN_VERSION },
|
||||||
capabilities: {},
|
capabilities: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
||||||
|
process.stdout.write(`${pkg.default.version}\n`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
import { createHermesAgent } from "./hermes.js";
|
import { createHermesAgent } from "./hermes.js";
|
||||||
import { isResumeDisabled } from "./session-cache.js";
|
import { isResumeDisabled } from "./session-cache.js";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-mock",
|
"name": "@united-workforce/agent-mock",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
||||||
|
process.stdout.write(`${pkg.default.version}\n`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
import { createMockAgent } from "./mock-agent.js";
|
import { createMockAgent } from "./mock-agent.js";
|
||||||
|
|
||||||
const USAGE = "usage: uwf-mock --mock-data <path> --thread <id> --role <role> --prompt <text>";
|
const USAGE = "usage: uwf-mock --mock-data <path> --thread <id> --role <role> --prompt <text>";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/cli",
|
"name": "@united-workforce/cli",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ describe("C1: adapter JSON round-trip integration", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Do the work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Do the work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume the work", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "completed", location: null } },
|
worker: { done: { role: "$END", prompt: "completed", location: null } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,10 +45,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["done"] }
|
$status: { type: string, enum: ["done"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: roleA
|
role: roleA
|
||||||
prompt: "Do A"
|
prompt: "Do A"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: roleA
|
||||||
|
prompt: "Resume A"
|
||||||
|
location: null
|
||||||
roleA:
|
roleA:
|
||||||
ready:
|
ready:
|
||||||
role: roleB
|
role: roleB
|
||||||
@@ -107,10 +111,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["done"] }
|
$status: { type: string, enum: ["done"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: roleA
|
role: roleA
|
||||||
prompt: "Do A"
|
prompt: "Do A"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: roleA
|
||||||
|
prompt: "Resume A"
|
||||||
|
location: null
|
||||||
roleA:
|
roleA:
|
||||||
pass:
|
pass:
|
||||||
role: roleB
|
role: roleB
|
||||||
@@ -150,10 +158,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["done"] }
|
$status: { type: string, enum: ["done"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: worker
|
role: worker
|
||||||
prompt: "Work"
|
prompt: "Work"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: worker
|
||||||
|
prompt: "Resume work"
|
||||||
|
location: null
|
||||||
worker:
|
worker:
|
||||||
done:
|
done:
|
||||||
role: $END
|
role: $END
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ roles:
|
|||||||
required: [$status]
|
required: [$status]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: analyst, prompt: 'Analyze the task' }
|
new: { role: analyst, prompt: 'Analyze the task' }
|
||||||
|
resume: { role: analyst, prompt: 'Review the previous run output and continue the work.' }
|
||||||
analyst:
|
analyst:
|
||||||
analyzed: { role: developer, prompt: 'Implement the change' }
|
analyzed: { role: developer, prompt: 'Implement the change' }
|
||||||
developer:
|
developer:
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ roles:
|
|||||||
required: [$status]
|
required: [$status]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: planner, prompt: 'Plan the task' }
|
new: { role: planner, prompt: 'Plan the task' }
|
||||||
|
resume: { role: planner, prompt: 'Review the previous run output and continue the work.' }
|
||||||
planner:
|
planner:
|
||||||
ready: { role: worker, prompt: 'Do the work' }
|
ready: { role: worker, prompt: 'Do the work' }
|
||||||
worker:
|
worker:
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ roles:
|
|||||||
required: [$status]
|
required: [$status]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: developer, prompt: 'Implement the change' }
|
new: { role: developer, prompt: 'Implement the change' }
|
||||||
|
resume: { role: developer, prompt: 'Review the previous run output and continue the work.' }
|
||||||
developer:
|
developer:
|
||||||
review_needed: { role: reviewer, prompt: 'Review the change' }
|
review_needed: { role: reviewer, prompt: 'Review the change' }
|
||||||
reviewer:
|
reviewer:
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ roles:
|
|||||||
required: [$status]
|
required: [$status]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: planner, prompt: 'Plan the task' }
|
new: { role: planner, prompt: 'Plan the task' }
|
||||||
|
resume: { role: planner, prompt: 'Review the previous run output and continue the work.' }
|
||||||
planner:
|
planner:
|
||||||
ready: { role: worker, prompt: 'Work on branch {{{branch}}} in {{{repoPath}}}' }
|
ready: { role: worker, prompt: 'Work on branch {{{branch}}} in {{{repoPath}}}' }
|
||||||
worker:
|
worker:
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ roles:
|
|||||||
required: [$status]
|
required: [$status]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_: { role: planner, prompt: 'Analyze the task' }
|
new: { role: planner, prompt: 'Analyze the task' }
|
||||||
|
resume: { role: planner, prompt: 'Review the previous run output and continue the work.' }
|
||||||
planner:
|
planner:
|
||||||
insufficient_info: { role: '$SUSPEND', prompt: 'Need more info: {{{reason}}}' }
|
insufficient_info: { role: '$SUSPEND', prompt: 'Need more info: {{{reason}}}' }
|
||||||
ready: { role: '$END', prompt: 'Done' }
|
ready: { role: '$END', prompt: 'Done' }
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import { evaluate } from "../moderator/evaluate.js";
|
|||||||
|
|
||||||
const solveIssueGraph: WorkflowPayload["graph"] = {
|
const solveIssueGraph: WorkflowPayload["graph"] = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "planner", prompt: "Start planning from the issue in the task.", location: null },
|
new: { role: "planner", prompt: "Start planning from the issue in the task.", location: null },
|
||||||
|
resume: {
|
||||||
|
role: "planner",
|
||||||
|
prompt: "Review the previous run output and continue the work.",
|
||||||
|
location: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
planner: {
|
planner: {
|
||||||
planned: { role: "developer", prompt: "Implement the plan: {{plan}}", location: null },
|
planned: { role: "developer", prompt: "Implement the plan: {{plan}}", location: null },
|
||||||
@@ -20,8 +25,8 @@ const solveIssueGraph: WorkflowPayload["graph"] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe("evaluate", () => {
|
describe("evaluate", () => {
|
||||||
test("$START → first role (unit status _)", () => {
|
test("$START → first role (status new)", () => {
|
||||||
const result = evaluate(solveIssueGraph, "$START", { $status: "_" });
|
const result = evaluate(solveIssueGraph, "$START", { $status: "new" });
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
ok: true,
|
ok: true,
|
||||||
value: {
|
value: {
|
||||||
@@ -32,6 +37,18 @@ describe("evaluate", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("$START → first role (status resume)", () => {
|
||||||
|
const result = evaluate(solveIssueGraph, "$START", { $status: "resume" });
|
||||||
|
expect(result).toEqual({
|
||||||
|
ok: true,
|
||||||
|
value: {
|
||||||
|
role: "planner",
|
||||||
|
prompt: "Review the previous run output and continue the work.",
|
||||||
|
location: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("status-based routing (reviewer rejected → developer)", () => {
|
test("status-based routing (reviewer rejected → developer)", () => {
|
||||||
const result = evaluate(solveIssueGraph, "reviewer", {
|
const result = evaluate(solveIssueGraph, "reviewer", {
|
||||||
$status: "rejected",
|
$status: "rejected",
|
||||||
@@ -95,7 +112,7 @@ describe("evaluate", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("missing role in graph → error", () => {
|
test("missing role in graph → error", () => {
|
||||||
const result = evaluate(solveIssueGraph, "unknown-role", { $status: "_" });
|
const result = evaluate(solveIssueGraph, "unknown-role", { $status: "new" });
|
||||||
expect(result.ok).toBe(false);
|
expect(result.ok).toBe(false);
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
expect(result.error.message).toBe('no transitions defined for role "unknown-role"');
|
expect(result.error.message).toBe('no transitions defined for role "unknown-role"');
|
||||||
|
|||||||
@@ -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,29 @@ 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");
|
// Skills installation
|
||||||
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)/);
|
// Fresh install scenario
|
||||||
|
expect(result).toContain("Fresh Install");
|
||||||
|
expect(result).toContain("uwf setup");
|
||||||
|
expect(result).toContain("--provider");
|
||||||
|
expect(result).toContain("--api-key");
|
||||||
|
expect(result).toContain("agent adapter");
|
||||||
|
// Upgrade scenario
|
||||||
|
expect(result).toContain("Upgrade");
|
||||||
|
expect(result).toContain("Migrate");
|
||||||
|
// 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 +101,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");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -253,7 +253,10 @@ describe("thread read timing", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "go", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "go", location: null },
|
||||||
|
resume: { role: "worker", prompt: "resume", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "", location: null } },
|
worker: { done: { role: "$END", prompt: "", location: null } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -319,7 +322,10 @@ describe("thread read timing", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "go", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "go", location: null },
|
||||||
|
resume: { role: "worker", prompt: "resume", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "", location: null } },
|
worker: { done: { role: "$END", prompt: "", location: null } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,10 +57,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["ready"] }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: planner
|
role: planner
|
||||||
prompt: "Plan the work"
|
prompt: "Plan the work"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: planner
|
||||||
|
prompt: "Resume the work"
|
||||||
|
location: null
|
||||||
planner:
|
planner:
|
||||||
ready:
|
ready:
|
||||||
role: $END
|
role: $END
|
||||||
@@ -113,10 +117,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["ready"] }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: planner
|
role: planner
|
||||||
prompt: "Plan"
|
prompt: "Plan"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: planner
|
||||||
|
prompt: "Resume"
|
||||||
|
location: null
|
||||||
planner:
|
planner:
|
||||||
ready:
|
ready:
|
||||||
role: $END
|
role: $END
|
||||||
@@ -156,10 +164,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["ready"] }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: planner
|
role: planner
|
||||||
prompt: "Plan"
|
prompt: "Plan"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: planner
|
||||||
|
prompt: "Resume"
|
||||||
|
location: null
|
||||||
planner:
|
planner:
|
||||||
ready:
|
ready:
|
||||||
role: $END
|
role: $END
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ async function setupSuspendedThread(mode: MockAgentMode): Promise<{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume the work", location: null },
|
||||||
|
},
|
||||||
worker: {
|
worker: {
|
||||||
needs_input: {
|
needs_input: {
|
||||||
role: "$SUSPEND",
|
role: "$SUSPEND",
|
||||||
@@ -233,7 +236,10 @@ describe("uwf thread resume", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "Done", location: null } },
|
worker: { done: { role: "$END", prompt: "Done", location: null } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -479,7 +485,10 @@ describe("uwf thread resume - completed threads", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume the work", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "reviewer", prompt: "Review the work", location: null } },
|
worker: { done: { role: "reviewer", prompt: "Review the work", location: null } },
|
||||||
reviewer: { done: { role: "$END", prompt: "Done", location: null } },
|
reviewer: { done: { role: "$END", prompt: "Done", location: null } },
|
||||||
},
|
},
|
||||||
@@ -610,7 +619,7 @@ echo '${adapterJson}'
|
|||||||
expect(cliOutput.done).toBe(false);
|
expect(cliOutput.done).toBe(false);
|
||||||
|
|
||||||
const capturedPrompt = await readFile(promptCapturePath, "utf8");
|
const capturedPrompt = await readFile(promptCapturePath, "utf8");
|
||||||
expect(capturedPrompt).toContain("Previous run completed");
|
expect(capturedPrompt).toContain("Resume the work");
|
||||||
expect(capturedPrompt).toContain("Additional context");
|
expect(capturedPrompt).toContain("Additional context");
|
||||||
|
|
||||||
const storeModule = await import("../store.js");
|
const storeModule = await import("../store.js");
|
||||||
@@ -640,7 +649,10 @@ echo '${adapterJson}'
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "Done", location: null } },
|
worker: { done: { role: "$END", prompt: "Done", location: null } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -688,7 +700,10 @@ echo '${adapterJson}'
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "Done", location: null } },
|
worker: { done: { role: "$END", prompt: "Done", location: null } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,10 +34,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["ready"] }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: planner
|
role: planner
|
||||||
prompt: "Plan the work"
|
prompt: "Plan the work"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: planner
|
||||||
|
prompt: "Resume the work"
|
||||||
|
location: null
|
||||||
planner:
|
planner:
|
||||||
ready:
|
ready:
|
||||||
role: $END
|
role: $END
|
||||||
@@ -66,10 +70,14 @@ roles:
|
|||||||
question: { type: string }
|
question: { type: string }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: worker
|
role: worker
|
||||||
prompt: "Start work"
|
prompt: "Start work"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: worker
|
||||||
|
prompt: "Resume work"
|
||||||
|
location: null
|
||||||
worker:
|
worker:
|
||||||
needs_input:
|
needs_input:
|
||||||
role: $SUSPEND
|
role: $SUSPEND
|
||||||
|
|||||||
@@ -57,10 +57,14 @@ roles:
|
|||||||
$status: { type: string, enum: ["ready"] }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: planner
|
role: planner
|
||||||
prompt: "Plan the work"
|
prompt: "Plan the work"
|
||||||
location: null
|
location: null
|
||||||
|
resume:
|
||||||
|
role: planner
|
||||||
|
prompt: "Resume the work"
|
||||||
|
location: null
|
||||||
planner:
|
planner:
|
||||||
ready:
|
ready:
|
||||||
role: $END
|
role: $END
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ describe("suspend step CAS chain and threads.yaml metadata", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume work", location: null },
|
||||||
|
},
|
||||||
worker: {
|
worker: {
|
||||||
needs_input: {
|
needs_input: {
|
||||||
role: "$SUSPEND",
|
role: "$SUSPEND",
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ describe("suspended thread display", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume work", location: null },
|
||||||
|
},
|
||||||
worker: {
|
worker: {
|
||||||
needs_input: {
|
needs_input: {
|
||||||
role: "$SUSPEND",
|
role: "$SUSPEND",
|
||||||
@@ -162,7 +165,10 @@ describe("suspended thread display", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume work", location: null },
|
||||||
|
},
|
||||||
worker: {
|
worker: {
|
||||||
needs_input: {
|
needs_input: {
|
||||||
role: "$SUSPEND",
|
role: "$SUSPEND",
|
||||||
@@ -248,7 +254,10 @@ describe("suspended thread display", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "Start work", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "Start work", location: null },
|
||||||
|
resume: { role: "worker", prompt: "Resume work", location: null },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ function makeWorkflow(overrides?: Partial<WorkflowPayload>): WorkflowPayload {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "writer", prompt: "Begin writing", location: null } },
|
$START: {
|
||||||
|
new: { role: "writer", prompt: "Begin writing", location: null },
|
||||||
|
resume: { role: "writer", prompt: "Review previous output and continue", location: null },
|
||||||
|
},
|
||||||
writer: { done: { role: "reviewer", prompt: "Review this: {{{plan}}}", location: null } },
|
writer: { done: { role: "reviewer", prompt: "Review this: {{{plan}}}", location: null } },
|
||||||
reviewer: {
|
reviewer: {
|
||||||
approved: { role: "$END", prompt: "Done: {{{summary}}}", location: null },
|
approved: { role: "$END", prompt: "Done: {{{summary}}}", location: null },
|
||||||
@@ -135,27 +138,38 @@ describe("Suite 2: Graph Structure", () => {
|
|||||||
expect(errors.some((e) => e.includes("$START must be defined in graph"))).toBe(true);
|
expect(errors.some((e) => e.includes("$START must be defined in graph"))).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("2.2 $START has multiple status keys", () => {
|
test("2.2 $START missing resume edge", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.graph.$START = {
|
wf.graph.$START = {
|
||||||
_: { role: "writer", prompt: "Begin", location: null },
|
new: { role: "writer", prompt: "Begin", location: null },
|
||||||
other: { role: "reviewer", prompt: "Also", location: null },
|
|
||||||
};
|
};
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
expect(
|
expect(
|
||||||
errors.some((e) => e.includes('$START must have exactly one edge with status "_"')),
|
errors.some((e) => e.includes('$START must have edges with statuses "new" and "resume"')),
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("2.3 $START edge uses non-_ status", () => {
|
test("2.3 $START missing new edge", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.graph.$START = { ready: { role: "writer", prompt: "Begin", location: null } };
|
wf.graph.$START = {
|
||||||
|
resume: { role: "writer", prompt: "Resume", location: null },
|
||||||
|
};
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
expect(
|
expect(
|
||||||
errors.some((e) => e.includes('$START must have exactly one edge with status "_"')),
|
errors.some((e) => e.includes('$START must have edges with statuses "new" and "resume"')),
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("2.3b $START with new and resume passes", () => {
|
||||||
|
const wf = makeWorkflow();
|
||||||
|
wf.graph.$START = {
|
||||||
|
new: { role: "writer", prompt: "Begin", location: null },
|
||||||
|
resume: { role: "writer", prompt: "Resume", location: null },
|
||||||
|
};
|
||||||
|
const errors = validateWorkflow(wf);
|
||||||
|
expect(errors.some((e) => e.includes("$START must have edges"))).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
test("2.4 $END has outgoing edges", () => {
|
test("2.4 $END has outgoing edges", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.graph.$END = { _: { role: "writer", prompt: "Loop", location: null } };
|
wf.graph.$END = { _: { role: "writer", prompt: "Loop", location: null } };
|
||||||
@@ -193,15 +207,18 @@ describe("Suite 2: Graph Structure", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Suite 3: Status-Edge Consistency", () => {
|
describe("Suite 3: Status-Edge Consistency", () => {
|
||||||
test("3.1 user role using _ graph key is rejected", () => {
|
test("3.1 user role using _ graph key is treated as an unknown status", () => {
|
||||||
|
// "_" is no longer special-cased — it's just a status key that does not
|
||||||
|
// match the role's $status enum, so it surfaces as extra/missing keys.
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.graph.writer = { _: { role: "reviewer", prompt: "Review", location: null } };
|
wf.graph.writer = { _: { role: "reviewer", prompt: "Review", location: null } };
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
expect(
|
expect(errors.some((e) => e.includes('role "writer" graph has extra status keys: _'))).toBe(
|
||||||
errors.some((e) =>
|
true,
|
||||||
e.includes('role "writer" must use explicit $status keys in graph, not "_"'),
|
);
|
||||||
),
|
expect(errors.some((e) => e.includes('role "writer" graph is missing status keys: done'))).toBe(
|
||||||
).toBe(true);
|
true,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("3.2 user role graph key not matching $status enum", () => {
|
test("3.2 user role graph key not matching $status enum", () => {
|
||||||
@@ -240,13 +257,16 @@ describe("Suite 3: Status-Edge Consistency", () => {
|
|||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("3.5 multi-exit role with _ key", () => {
|
test("3.5 multi-exit role with _ key is treated as an unknown status", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.graph.reviewer = { _: { role: "$END", prompt: "Done", location: null } };
|
wf.graph.reviewer = { _: { role: "$END", prompt: "Done", location: null } };
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
|
expect(errors.some((e) => e.includes('role "reviewer" graph has extra status keys: _'))).toBe(
|
||||||
|
true,
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
errors.some((e) =>
|
errors.some((e) =>
|
||||||
e.includes('role "reviewer" must use explicit $status keys in graph, not "_"'),
|
e.includes('role "reviewer" graph is missing status keys: approved, rejected'),
|
||||||
),
|
),
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ function makeMinimalPayload(name: string, description: string): WorkflowPayload
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
$START: { _: { role: "worker", prompt: "start working", location: null } },
|
$START: {
|
||||||
|
new: { role: "worker", prompt: "start working", location: null },
|
||||||
|
resume: { role: "worker", prompt: "resume working", location: null },
|
||||||
|
},
|
||||||
worker: { done: { role: "$END", prompt: "done", location: null } },
|
worker: { done: { role: "$END", prompt: "done", location: null } },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+12
-24
@@ -8,12 +8,10 @@ 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, resolvePresetBaseUrl } from "./commands/setup.js";
|
||||||
import { cmdStepFork, cmdStepList, cmdStepRead, cmdStepShow } from "./commands/step.js";
|
import { cmdStepFork, cmdStepList, cmdStepRead, cmdStepShow } from "./commands/step.js";
|
||||||
import {
|
import {
|
||||||
cmdThreadCancel,
|
cmdThreadCancel,
|
||||||
@@ -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")
|
||||||
@@ -574,10 +558,14 @@ program
|
|||||||
}) => {
|
}) => {
|
||||||
const storageRoot = resolveStorageRoot();
|
const storageRoot = resolveStorageRoot();
|
||||||
runAction(async () => {
|
runAction(async () => {
|
||||||
if (opts.provider && opts.baseUrl && opts.apiKey && opts.model) {
|
// Resolve preset base-url when provider is known but --base-url is omitted
|
||||||
|
const resolvedBaseUrl =
|
||||||
|
opts.baseUrl ??
|
||||||
|
(opts.provider !== undefined ? resolvePresetBaseUrl(opts.provider) : null);
|
||||||
|
if (opts.provider && resolvedBaseUrl && opts.apiKey && opts.model) {
|
||||||
const result = await cmdSetup({
|
const result = await cmdSetup({
|
||||||
provider: opts.provider,
|
provider: opts.provider,
|
||||||
baseUrl: opts.baseUrl,
|
baseUrl: resolvedBaseUrl,
|
||||||
apiKey: opts.apiKey,
|
apiKey: opts.apiKey,
|
||||||
model: opts.model,
|
model: opts.model,
|
||||||
agent: opts.agent ?? undefined,
|
agent: opts.agent ?? undefined,
|
||||||
@@ -588,7 +576,7 @@ program
|
|||||||
await cmdSetupInteractive(storageRoot);
|
await cmdSetupInteractive(storageRoot);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Non-interactive setup requires all of: --provider, --base-url, --api-key, --model",
|
"Non-interactive setup requires: --provider, --api-key, --model (--base-url is optional for preset providers)",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,35 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
import {
|
import {
|
||||||
generateAdapterDevelopingReference,
|
generateAdapterDevelopingReference,
|
||||||
generateBootstrapReference,
|
|
||||||
generateUsageReference,
|
generateUsageReference,
|
||||||
generateWorkflowAuthoringReference,
|
generateWorkflowAuthoringReference,
|
||||||
} from "@united-workforce/util";
|
} from "@united-workforce/util";
|
||||||
|
|
||||||
|
// CLI package version (for bootstrap prompt — uwf --version prints this)
|
||||||
|
// Walk up from __dirname to find the nearest package.json (works from both src/ and dist/)
|
||||||
|
function _findCliVersion(): string {
|
||||||
|
let dir = dirname(fileURLToPath(import.meta.url));
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
const candidate = join(dir, "package.json");
|
||||||
|
try {
|
||||||
|
const pkg = JSON.parse(readFileSync(candidate, "utf-8")) as { name?: string; version?: string };
|
||||||
|
if (pkg.name === "@united-workforce/cli") {
|
||||||
|
return pkg.version ?? "0.0.0";
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// not found, keep walking
|
||||||
|
}
|
||||||
|
dir = dirname(dir);
|
||||||
|
}
|
||||||
|
return "0.0.0";
|
||||||
|
}
|
||||||
|
const CLI_VERSION = _findCliVersion();
|
||||||
|
|
||||||
export {
|
export {
|
||||||
generateAdapterDevelopingReference as cmdPromptAdapterDeveloping,
|
generateAdapterDevelopingReference as cmdPromptAdapterDeveloping,
|
||||||
generateBootstrapReference as cmdPromptBootstrap,
|
generateUsageReference as cmdPromptUsage,
|
||||||
generateUsageReference as cmdPromptUsageReference,
|
|
||||||
generateWorkflowAuthoringReference as cmdPromptWorkflowAuthoring,
|
generateWorkflowAuthoringReference as cmdPromptWorkflowAuthoring,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -16,66 +37,205 @@ 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 Bootstrap
|
||||||
.map((e) => e.generate())
|
|
||||||
.join("\n\n---\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function cmdPromptSetup(): string {
|
Set up or upgrade uwf (United Workforce) — from zero to running your first workflow.
|
||||||
return `# uwf Skill Setup
|
|
||||||
|
|
||||||
You are being asked to install or update the uwf (United Workforce) skill
|
## Scenario A: Fresh Install
|
||||||
so that you know how to use the \`uwf\` CLI for workflow orchestration.
|
|
||||||
|
|
||||||
## Steps
|
### Step 0 — Environment pre-flight check
|
||||||
|
|
||||||
1. **Check if uwf CLI is installed:**
|
Run ALL checks below BEFORE installing anything. If any check fails, fix it first — do NOT skip ahead.
|
||||||
\`\`\`bash
|
|
||||||
uwf --help
|
|
||||||
\`\`\`
|
|
||||||
If not installed: \`npm install -g @united-workforce/cli\`
|
|
||||||
|
|
||||||
2. **Clean up old versions of the skill** (if any exist):
|
|
||||||
- Look for any existing uwf/workflow skill files in your skill directories
|
|
||||||
(e.g. \`~/.hermes/skills/uwf/SKILL.md\` or similar paths).
|
|
||||||
- If a skill exists, read its \`version\` from the YAML frontmatter.
|
|
||||||
- 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:**
|
|
||||||
\`\`\`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.
|
|
||||||
|
|
||||||
## Individual prompts
|
|
||||||
|
|
||||||
Each prompt outputs a complete SKILL.md with frontmatter — pipe directly to a file:
|
|
||||||
|
|
||||||
\`\`\`bash
|
\`\`\`bash
|
||||||
uwf prompt list # list available prompt names
|
# 1. Node.js
|
||||||
uwf prompt usage > ~/.hermes/skills/uwf-usage/SKILL.md # CLI usage guide
|
node --version # need v20+
|
||||||
uwf prompt workflow-authoring > ~/.hermes/skills/uwf-workflow-authoring/SKILL.md
|
# FIX: install via nvm (https://github.com/nvm-sh/nvm) or your OS package manager
|
||||||
uwf prompt adapter-developing > ~/.hermes/skills/uwf-adapter-developing/SKILL.md
|
|
||||||
uwf prompt bootstrap > ~/.hermes/skills/uwf/SKILL.md # bootstrap skill
|
# 2. Package manager — pnpm (preferred) or npm
|
||||||
|
pnpm --version || npm --version
|
||||||
|
# FIX for pnpm: corepack enable pnpm (Node 20+)
|
||||||
|
# or: npm install -g pnpm
|
||||||
|
# If pnpm is not an option, npm works too — adjust install commands below
|
||||||
|
|
||||||
|
# 3. Global bin directory is in PATH
|
||||||
|
# For pnpm:
|
||||||
|
pnpm bin -g # prints the global bin directory
|
||||||
|
# For npm:
|
||||||
|
npm prefix -g # global prefix; bin is <prefix>/bin
|
||||||
|
# The directory printed above MUST be in your PATH.
|
||||||
|
# Test: echo \\$PATH | tr ':' '\\\\n'
|
||||||
|
# FIX: add the missing directory to your shell's startup file
|
||||||
|
# (e.g. ~/.bashrc, ~/.zshrc, ~/.profile, or fish config):
|
||||||
|
# export PATH="<global-bin-dir>:$PATH"
|
||||||
|
|
||||||
|
# 4. (uwf-hermes only) hermes CLI
|
||||||
|
which hermes
|
||||||
|
# FIX: if hermes is in a virtualenv, add it to PATH:
|
||||||
|
# export PATH="$HOME/.hermes/hermes-agent/.venv/bin:$PATH"
|
||||||
|
# or create a symlink: ln -s ~/.hermes/hermes-agent/.venv/bin/hermes ~/.local/bin/hermes
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
## Notes
|
**All checks must pass before continuing.** If you had to modify PATH, verify the change persists by opening a new shell or sourcing your shell config.
|
||||||
|
|
||||||
- The skill content is bundled with the CLI and versioned with it — always use
|
### Step 1 — Install CLI and agent adapter
|
||||||
\`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\`
|
\`\`\`bash
|
||||||
and follow the steps again.
|
pnpm add -g @united-workforce/cli # or: npm install -g @united-workforce/cli
|
||||||
- When upgrading, always delete the old skill first to avoid stale instructions.
|
uwf --version # should print ${CLI_VERSION}
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Install an agent adapter (at least one is required):
|
||||||
|
|
||||||
|
| Adapter | Install | When to use |
|
||||||
|
|---------|---------|-------------|
|
||||||
|
| uwf-hermes | \`pnpm add -g @united-workforce/agent-hermes\` | When your agent framework is Hermes Agent |
|
||||||
|
| uwf-claude-code | \`pnpm add -g @united-workforce/agent-claude-code\` | When using Claude Code CLI directly |
|
||||||
|
| uwf-builtin | \`pnpm add -g @united-workforce/agent-builtin\` | Lightweight built-in agent (no external dependency) |
|
||||||
|
|
||||||
|
**uwf-hermes** also requires the Hermes ACP plugin. After installing \`hermes-agent\`, run:
|
||||||
|
\`\`\`bash
|
||||||
|
pip install hermes-agent[acp] # or: pip install -e .[acp] if installed from source
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Verify the adapter is installed: \`uwf-hermes --version\` (or whichever you chose).
|
||||||
|
|
||||||
|
### Step 2 — Configure provider and model
|
||||||
|
|
||||||
|
uwf needs an LLM provider to run agents. **Ask the user** for their provider, API key, and model, then run:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
uwf setup --provider <name> --base-url <url> --api-key <key> --model <model> [--agent <adapter>]
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Preset providers (base-url is auto-filled when using a preset name):
|
||||||
|
openai, xai, openrouter, venice, dashscope, deepseek, siliconflow, volcengine, kimi, glm, stepfun, minimax, ollama
|
||||||
|
|
||||||
|
Example:
|
||||||
|
\`\`\`bash
|
||||||
|
uwf setup --provider openrouter --api-key sk-or-... --model anthropic/claude-sonnet-4 --agent uwf-hermes
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
If the user doesn't know what to choose, suggest \`openrouter\` with \`anthropic/claude-sonnet-4\` as a sensible default.
|
||||||
|
|
||||||
|
Config is saved to \`~/.uwf/config.yaml\`. Verify with \`cat ~/.uwf/config.yaml\`.
|
||||||
|
|
||||||
|
### Step 3 — Install skills
|
||||||
|
|
||||||
|
Run each command and create a skill from its output:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
uwf prompt usage # → save as skill "uwf-usage"
|
||||||
|
uwf prompt workflow-authoring # → save as skill "uwf-workflow-authoring"
|
||||||
|
uwf prompt adapter-developing # → save as skill "uwf-adapter-developing"
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Each command outputs a complete SKILL.md with YAML frontmatter. Use your agent framework's skill creation API to save them (e.g. \`skill_manage(action='create', name='uwf-usage', content=<output>)\`).
|
||||||
|
|
||||||
|
Verify skills are installed by listing them (e.g. \`skills_list()\`) and confirming all three appear.
|
||||||
|
|
||||||
|
### Step 4 — Verify end-to-end
|
||||||
|
|
||||||
|
Create a minimal workflow file to test your setup:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
cat > /tmp/hello.yaml << 'YAML'
|
||||||
|
name: hello
|
||||||
|
description: Minimal smoke test
|
||||||
|
roles:
|
||||||
|
greeter:
|
||||||
|
description: "Greet the user"
|
||||||
|
goal: "Respond with a friendly greeting"
|
||||||
|
capabilities: []
|
||||||
|
procedure: "Write a short greeting based on the prompt."
|
||||||
|
output: "A greeting message."
|
||||||
|
frontmatter:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
$status: { enum: [done] }
|
||||||
|
message: { type: string }
|
||||||
|
required: [$status, message]
|
||||||
|
graph:
|
||||||
|
$START:
|
||||||
|
new: { role: greeter, prompt: "Say hello to the user." }
|
||||||
|
resume: { role: greeter, prompt: "Greet the user again." }
|
||||||
|
greeter:
|
||||||
|
done: { role: "$END", prompt: "Done." }
|
||||||
|
YAML
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Then run:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
uwf thread start /tmp/hello.yaml -p "Hello, world!"
|
||||||
|
uwf thread exec <thread-id>
|
||||||
|
uwf thread show <thread-id>
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
If the thread reaches \`$END\` with status \`completed\`, the setup is working.
|
||||||
|
|
||||||
|
## Scenario B: Upgrade from Previous Version
|
||||||
|
|
||||||
|
### Step 1 — Update packages
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
pnpm add -g @united-workforce/cli@latest # or: npm install -g @united-workforce/cli@latest
|
||||||
|
uwf --version # should print ${CLI_VERSION}
|
||||||
|
|
||||||
|
# Also update your adapter(s)
|
||||||
|
pnpm add -g @united-workforce/agent-hermes@latest
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### Step 2 — Regenerate skills
|
||||||
|
|
||||||
|
Skill content is bundled with the CLI — always regenerate after upgrading:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
uwf prompt usage # → update skill "uwf-usage"
|
||||||
|
uwf prompt workflow-authoring # → update skill "uwf-workflow-authoring"
|
||||||
|
uwf prompt adapter-developing # → update skill "uwf-adapter-developing"
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### Step 3 — Migrate workflow YAML files (if needed)
|
||||||
|
|
||||||
|
Check the changelog for breaking changes. Known migrations:
|
||||||
|
|
||||||
|
- **v0.2.0**: \`$START._\` → \`$START.new\` + \`$START.resume\`. All workflow YAML files must be updated:
|
||||||
|
\`\`\`yaml
|
||||||
|
# Before (v0.1.x)
|
||||||
|
$START:
|
||||||
|
_: { role: planner, prompt: "..." }
|
||||||
|
|
||||||
|
# After (v0.2.0+)
|
||||||
|
$START:
|
||||||
|
new: { role: planner, prompt: "..." }
|
||||||
|
resume: { role: planner, prompt: "Review previous run and continue." }
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Update all \`.workflow/\` and \`.workflows/\` YAML files in your projects. \`uwf workflow add\` will reject files with the old \`_\` syntax.
|
||||||
|
|
||||||
|
### Step 4 — Verify
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
uwf thread start <your-workflow> -p "upgrade test"
|
||||||
|
uwf thread exec <thread-id>
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
## Available prompts
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
uwf prompt list # list available prompt names
|
||||||
|
uwf prompt usage # CLI usage guide
|
||||||
|
uwf prompt workflow-authoring # workflow YAML design guide
|
||||||
|
uwf prompt adapter-developing # building agent adapters
|
||||||
|
uwf prompt bootstrap # this guide
|
||||||
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { execFileSync } from "node:child_process";
|
||||||
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { stdin as input, stdout as output } from "node:process";
|
import { stdin as input, stdout as output } from "node:process";
|
||||||
@@ -72,6 +73,12 @@ const PRESET_PROVIDERS = [
|
|||||||
{ name: "ollama", label: "Ollama (local)", baseUrl: "http://localhost:11434/v1" },
|
{ name: "ollama", label: "Ollama (local)", baseUrl: "http://localhost:11434/v1" },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
/** Look up the base URL for a preset provider name. Returns null if not a preset. */
|
||||||
|
export function resolvePresetBaseUrl(providerName: string): string | null {
|
||||||
|
const preset = PRESET_PROVIDERS.find((p) => p.name === providerName);
|
||||||
|
return preset !== undefined ? preset.baseUrl : null;
|
||||||
|
}
|
||||||
|
|
||||||
type SetupArgs = {
|
type SetupArgs = {
|
||||||
provider: string;
|
provider: string;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
@@ -175,7 +182,6 @@ export async function _discoverAgents(): Promise<string[]> {
|
|||||||
|
|
||||||
async function _tryWhichDiscovery(): Promise<string[] | null> {
|
async function _tryWhichDiscovery(): Promise<string[] | null> {
|
||||||
try {
|
try {
|
||||||
const { execFileSync } = await import("node:child_process");
|
|
||||||
const text = execFileSync("which", ["-a", "uwf-hermes", "uwf-claude-code", "uwf-cursor"], {
|
const text = execFileSync("which", ["-a", "uwf-hermes", "uwf-claude-code", "uwf-cursor"], {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
stdio: ["pipe", "pipe", "pipe"],
|
stdio: ["pipe", "pipe", "pipe"],
|
||||||
@@ -391,6 +397,37 @@ function mergeConfig(existing: Record<string, unknown>, args: SetupArgs): Record
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the configured adapter binary (and its dependencies) are in PATH.
|
||||||
|
* Returns warnings array — empty means all good.
|
||||||
|
*/
|
||||||
|
export function _checkAdapterAvailability(agentName: string): string[] {
|
||||||
|
const warnings: string[] = [];
|
||||||
|
const binary = `uwf-${agentName}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
execFileSync("which", [binary], { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
||||||
|
} catch {
|
||||||
|
warnings.push(
|
||||||
|
`${binary} not found in PATH. Install it: pnpm add -g @united-workforce/agent-${agentName}`,
|
||||||
|
);
|
||||||
|
return warnings; // skip dependency check if adapter itself is missing
|
||||||
|
}
|
||||||
|
|
||||||
|
// uwf-hermes depends on hermes CLI
|
||||||
|
if (agentName === "hermes") {
|
||||||
|
try {
|
||||||
|
execFileSync("which", ["hermes"], { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
||||||
|
} catch {
|
||||||
|
warnings.push(
|
||||||
|
'hermes CLI not found in PATH (required by uwf-hermes). Fix: export PATH="$HOME/.hermes/hermes-agent/.venv/bin:$PATH"',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return warnings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-interactive setup. All required args provided via CLI flags.
|
* Non-interactive setup. All required args provided via CLI flags.
|
||||||
*/
|
*/
|
||||||
@@ -405,15 +442,28 @@ export async function cmdSetup(args: SetupArgs): Promise<Record<string, unknown>
|
|||||||
|
|
||||||
writeFileSync(configPath, stringify(merged, { indent: 2 }), "utf8");
|
writeFileSync(configPath, stringify(merged, { indent: 2 }), "utf8");
|
||||||
|
|
||||||
|
// Print config path to stderr (stdout is reserved for JSON output)
|
||||||
|
// biome-ignore lint/nursery/noConsole: CLI user-facing output
|
||||||
|
console.error(`Config saved to ${configPath} ✓`);
|
||||||
|
|
||||||
// Validate model connectivity
|
// Validate model connectivity
|
||||||
const validation = await validateModel(args.baseUrl, args.apiKey, args.model);
|
const validation = await validateModel(args.baseUrl, args.apiKey, args.model);
|
||||||
|
|
||||||
|
// Check adapter availability
|
||||||
|
const agentName = _agentNameFromBinary(args.agent ?? "hermes");
|
||||||
|
const adapterWarnings = _checkAdapterAvailability(agentName);
|
||||||
|
for (const w of adapterWarnings) {
|
||||||
|
// biome-ignore lint/nursery/noConsole: CLI user-facing output
|
||||||
|
console.error(`⚠ ${w}`);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configPath,
|
configPath,
|
||||||
provider: args.provider,
|
provider: args.provider,
|
||||||
model: args.model,
|
model: args.model,
|
||||||
defaultAgent: merged.defaultAgent,
|
defaultAgent: merged.defaultAgent,
|
||||||
validation,
|
validation,
|
||||||
|
adapterWarnings,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -911,7 +911,7 @@ function resolveEvaluateArgs(
|
|||||||
chain: ChainState,
|
chain: ChainState,
|
||||||
): { lastRole: string; lastOutput: EvaluateLastOutput } {
|
): { lastRole: string; lastOutput: EvaluateLastOutput } {
|
||||||
if (chain.headIsStart) {
|
if (chain.headIsStart) {
|
||||||
return { lastRole: START_ROLE, lastOutput: { [STATUS_KEY]: "_" } };
|
return { lastRole: START_ROLE, lastOutput: { [STATUS_KEY]: "new" } };
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastStep = chain.stepsNewestFirst[0];
|
const lastStep = chain.stepsNewestFirst[0];
|
||||||
@@ -1001,9 +1001,21 @@ function spawnAgent(
|
|||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
maxBuffer: 50 * 1024 * 1024, // 50 MB — stream-json output can be large
|
maxBuffer: 50 * 1024 * 1024, // 50 MB — stream-json output can be large
|
||||||
cwd,
|
cwd,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
NODE_OPTIONS: [process.env.NODE_OPTIONS, "--disable-warning=ExperimentalWarning"]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" "),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const err = e as NodeJS.ErrnoException & { stderr?: Buffer | string | null };
|
const err = e as NodeJS.ErrnoException & { stderr?: Buffer | string | null };
|
||||||
|
if (err.code === "ENOENT") {
|
||||||
|
failStep(
|
||||||
|
plog,
|
||||||
|
`"${agent.command}" not found in PATH. Install it or check your PATH config. Run: which ${agent.command}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
const stderr =
|
const stderr =
|
||||||
err.stderr == null
|
err.stderr == null
|
||||||
? ""
|
? ""
|
||||||
@@ -1037,7 +1049,6 @@ function archiveThread(uwf: UwfStore, threadId: ThreadId, _workflow: CasRef, _he
|
|||||||
completeThread(uwf.varStore, threadId, "completed");
|
completeThread(uwf.varStore, threadId, "completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: orchestration function with inherent branching
|
|
||||||
export async function cmdThreadResume(
|
export async function cmdThreadResume(
|
||||||
storageRoot: string,
|
storageRoot: string,
|
||||||
threadId: ThreadId,
|
threadId: ThreadId,
|
||||||
@@ -1101,7 +1112,7 @@ export async function cmdThreadResume(
|
|||||||
|
|
||||||
// status === "completed"
|
// status === "completed"
|
||||||
const workflow = loadWorkflowPayload(uwf, workflowHash);
|
const workflow = loadWorkflowPayload(uwf, workflowHash);
|
||||||
const startResult = evaluate(workflow.graph, START_ROLE, {});
|
const startResult = evaluate(workflow.graph, START_ROLE, { [STATUS_KEY]: "resume" });
|
||||||
if (!startResult.ok) {
|
if (!startResult.ok) {
|
||||||
fail(`failed to evaluate $START: ${startResult.error.message}`);
|
fail(`failed to evaluate $START: ${startResult.error.message}`);
|
||||||
}
|
}
|
||||||
@@ -1113,11 +1124,7 @@ export async function cmdThreadResume(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const startRole = startResult.value.role;
|
const startRole = startResult.value.role;
|
||||||
const completedPromptPrefix = "Previous run completed. Resuming with additional context.";
|
const completedResumePrompt = buildResumePrompt(startResult.value.prompt, supplement);
|
||||||
const completedResumePrompt =
|
|
||||||
supplement !== null && supplement !== ""
|
|
||||||
? `${completedPromptPrefix}\n\n${supplement}`
|
|
||||||
: completedPromptPrefix;
|
|
||||||
|
|
||||||
const updatedEntry = { ...entry, status: "idle" as const, completedAt: null };
|
const updatedEntry = { ...entry, status: "idle" as const, completedAt: null };
|
||||||
setThread(uwf.varStore, threadId, updatedEntry);
|
setThread(uwf.varStore, threadId, updatedEntry);
|
||||||
@@ -1247,6 +1254,12 @@ async function cmdThreadStepBackground(
|
|||||||
const child = spawn(scriptPath, args, {
|
const child = spawn(scriptPath, args, {
|
||||||
detached: true,
|
detached: true,
|
||||||
stdio: "ignore",
|
stdio: "ignore",
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
NODE_OPTIONS: [process.env.NODE_OPTIONS, "--disable-warning=ExperimentalWarning"]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" "),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
child.unref();
|
child.unref();
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ describe("Edge prompt template variable resolution", () => {
|
|||||||
test("returns error when rendered prompt is empty string", () => {
|
test("returns error when rendered prompt is empty string", () => {
|
||||||
const graph = {
|
const graph = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "classifier", prompt: "{{{userPrompt}}}", location: null },
|
new: { role: "classifier", prompt: "{{{userPrompt}}}", location: null },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = evaluate(graph, "$START", {});
|
const result = evaluate(graph, "$START", { $status: "new" });
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
expect(result.ok).toBe(false);
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
@@ -22,11 +22,11 @@ describe("Edge prompt template variable resolution", () => {
|
|||||||
test("returns error when rendered prompt is whitespace-only", () => {
|
test("returns error when rendered prompt is whitespace-only", () => {
|
||||||
const graph = {
|
const graph = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "classifier", prompt: " {{{userPrompt}}} ", location: null },
|
new: { role: "classifier", prompt: " {{{userPrompt}}} ", location: null },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = evaluate(graph, "$START", {});
|
const result = evaluate(graph, "$START", { $status: "new" });
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
expect(result.ok).toBe(false);
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
@@ -38,11 +38,11 @@ describe("Edge prompt template variable resolution", () => {
|
|||||||
test("succeeds when all template variables resolve to non-empty values", () => {
|
test("succeeds when all template variables resolve to non-empty values", () => {
|
||||||
const graph = {
|
const graph = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "classifier", prompt: "{{{userPrompt}}}", location: null },
|
new: { role: "classifier", prompt: "{{{userPrompt}}}", location: null },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = evaluate(graph, "$START", { userPrompt: "Fix the bug" });
|
const result = evaluate(graph, "$START", { $status: "new", userPrompt: "Fix the bug" });
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
expect(result.ok).toBe(true);
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
@@ -53,11 +53,11 @@ describe("Edge prompt template variable resolution", () => {
|
|||||||
test("succeeds with static (no-variable) prompt", () => {
|
test("succeeds with static (no-variable) prompt", () => {
|
||||||
const graph = {
|
const graph = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "classifier", prompt: "Classify this input", location: null },
|
new: { role: "classifier", prompt: "Classify this input", location: null },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = evaluate(graph, "$START", {});
|
const result = evaluate(graph, "$START", { $status: "new" });
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
expect(result.ok).toBe(true);
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
@@ -68,11 +68,11 @@ describe("Edge prompt template variable resolution", () => {
|
|||||||
test("succeeds when prompt has mix of static text and unresolved variables", () => {
|
test("succeeds when prompt has mix of static text and unresolved variables", () => {
|
||||||
const graph = {
|
const graph = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "classifier", prompt: "Please handle: {{{userPrompt}}}", location: null },
|
new: { role: "classifier", prompt: "Please handle: {{{userPrompt}}}", location: null },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = evaluate(graph, "$START", {});
|
const result = evaluate(graph, "$START", { $status: "new" });
|
||||||
|
|
||||||
expect(result.ok).toBe(true);
|
expect(result.ok).toBe(true);
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
@@ -83,11 +83,11 @@ describe("Edge prompt template variable resolution", () => {
|
|||||||
test("returns error when ALL variables missing and no static text remains", () => {
|
test("returns error when ALL variables missing and no static text remains", () => {
|
||||||
const graph = {
|
const graph = {
|
||||||
$START: {
|
$START: {
|
||||||
_: { role: "classifier", prompt: "{{{a}}}{{{b}}}", location: null },
|
new: { role: "classifier", prompt: "{{{a}}}{{{b}}}", location: null },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = evaluate(graph, "$START", {});
|
const result = evaluate(graph, "$START", { $status: "new" });
|
||||||
|
|
||||||
expect(result.ok).toBe(false);
|
expect(result.ok).toBe(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import type { EvaluateResult, Result } from "./types.js";
|
|||||||
// Disable HTML escaping — prompts are plain text, not HTML.
|
// Disable HTML escaping — prompts are plain text, not HTML.
|
||||||
mustache.escape = (text: string) => text;
|
mustache.escape = (text: string) => text;
|
||||||
|
|
||||||
const START_ROLE = "$START";
|
|
||||||
const SUSPEND_ROLE = "$SUSPEND";
|
const SUSPEND_ROLE = "$SUSPEND";
|
||||||
// $START is a special entry node with no agent output — it always uses this key.
|
|
||||||
const START_STATUS = "_";
|
|
||||||
|
|
||||||
type LastOutput = Record<string, unknown>;
|
type LastOutput = Record<string, unknown>;
|
||||||
|
|
||||||
@@ -21,9 +18,7 @@ export function evaluate(
|
|||||||
lastOutput: LastOutput,
|
lastOutput: LastOutput,
|
||||||
): Result<EvaluateResult, Error> {
|
): Result<EvaluateResult, Error> {
|
||||||
let status: string;
|
let status: string;
|
||||||
if (lastRole === START_ROLE) {
|
if (typeof lastOutput[STATUS_KEY] === "string") {
|
||||||
status = START_STATUS;
|
|
||||||
} else if (typeof lastOutput[STATUS_KEY] === "string") {
|
|
||||||
status = lastOutput[STATUS_KEY] as string;
|
status = lastOutput[STATUS_KEY] as string;
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ function checkGraphStructure(payload: WorkflowPayload, errors: string[]): void {
|
|||||||
if (!graphNodes.has("$START")) {
|
if (!graphNodes.has("$START")) {
|
||||||
errors.push("$START must be defined in graph");
|
errors.push("$START must be defined in graph");
|
||||||
} else {
|
} else {
|
||||||
const startKeys = Object.keys(payload.graph.$START);
|
const startKeys = new Set(Object.keys(payload.graph.$START));
|
||||||
if (startKeys.length !== 1 || startKeys[0] !== "_") {
|
if (!startKeys.has("new") || !startKeys.has("resume")) {
|
||||||
errors.push('$START must have exactly one edge with status "_"');
|
errors.push('$START must have edges with statuses "new" and "resume"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,22 +190,13 @@ function checkOneOfDiscriminant(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check status-edge consistency for a user role. "_" is reserved for $START and rejected here. */
|
/** Check status-edge consistency for a user role. */
|
||||||
function checkStatusEdges(
|
function checkStatusEdges(
|
||||||
roleName: string,
|
roleName: string,
|
||||||
graphKeys: Set<string>,
|
graphKeys: Set<string>,
|
||||||
statusSet: Set<string>,
|
statusSet: Set<string>,
|
||||||
errors: string[],
|
errors: string[],
|
||||||
): void {
|
): void {
|
||||||
if (graphKeys.has("_")) {
|
|
||||||
errors.push(`role "${roleName}" must use explicit $status keys in graph, not "_"`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (statusSet.has("_")) {
|
|
||||||
errors.push(`role "${roleName}" $status enum must use explicit values, not "_"`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const extraKeys = [...graphKeys].filter((k) => !statusSet.has(k));
|
const extraKeys = [...graphKeys].filter((k) => !statusSet.has(k));
|
||||||
const missingKeys = [...statusSet].filter((k) => !graphKeys.has(k));
|
const missingKeys = [...statusSet].filter((k) => !graphKeys.has(k));
|
||||||
if (extraKeys.length > 0) {
|
if (extraKeys.length > 0) {
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ function isGraph(value: unknown): boolean {
|
|||||||
if (!isRecord(value)) {
|
if (!isRecord(value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Object.entries(value).every(([node, statusMap]) => {
|
return Object.values(value).every((statusMap) => {
|
||||||
if (!isRecord(statusMap)) {
|
if (!isRecord(statusMap)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Object.entries(statusMap).every(([status, target]) => {
|
return Object.entries(statusMap).every(([status, target]) => {
|
||||||
// "_" is only valid as a status key for the $START entry node.
|
// "_" is no longer a valid status key anywhere — $START uses "new"/"resume".
|
||||||
if (status === "_" && node !== "$START") {
|
if (status === "_") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isTarget(target);
|
return isTarget(target);
|
||||||
@@ -99,7 +99,7 @@ export function checkWorkflowFilenameConsistency(
|
|||||||
): string | null {
|
): string | null {
|
||||||
const expected = workflowNameFromPath(filePath);
|
const expected = workflowNameFromPath(filePath);
|
||||||
if (payload.name !== expected) {
|
if (payload.name !== expected) {
|
||||||
return `workflow name mismatch: file "${basename(filePath)}" implies name "${expected}" but YAML declares name "${payload.name}"`;
|
return `workflow name mismatch: file "${basename(filePath)}" implies name "${expected}" but YAML declares name "${payload.name}". Either rename the file to "${payload.name}.yaml" or change the YAML \`name\` field to "${expected}"`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/eval",
|
"name": "@united-workforce/eval",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
|
|||||||
@@ -7,12 +7,15 @@ import {
|
|||||||
registerRunCommand,
|
registerRunCommand,
|
||||||
} from "./commands/index.js";
|
} from "./commands/index.js";
|
||||||
|
|
||||||
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
|
|
||||||
program
|
program
|
||||||
.name("uwf-eval")
|
.name("uwf-eval")
|
||||||
.description("Evaluate uwf workflow quality with real agents")
|
.description("Evaluate uwf workflow quality with real agents")
|
||||||
.version("0.1.0");
|
.version(pkg.default.version, "-V, --version");
|
||||||
|
|
||||||
registerRunCommand(program);
|
registerRunCommand(program);
|
||||||
registerReportCommand(program);
|
registerReportCommand(program);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/util",
|
"name": "@united-workforce/util",
|
||||||
"version": "0.1.0",
|
"version": "0.1.2",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -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)。
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
@@ -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 {
|
||||||
@@ -16,7 +15,7 @@ export {
|
|||||||
validateFrontmatter,
|
validateFrontmatter,
|
||||||
} from "./frontmatter-markdown/index.js";
|
} from "./frontmatter-markdown/index.js";
|
||||||
export { createLogger } from "./logger.js";
|
export { createLogger } from "./logger.js";
|
||||||
export { generateModeratorReference } from "./moderator-reference.js";
|
|
||||||
export type {
|
export type {
|
||||||
CreateProcessLoggerOptions,
|
CreateProcessLoggerOptions,
|
||||||
ProcessLogFn,
|
ProcessLogFn,
|
||||||
@@ -36,4 +35,3 @@ export { extractUlidTimestamp, generateUlid } from "./ulid.js";
|
|||||||
export { generateUsageReference } from "./usage-reference.js";
|
export { generateUsageReference } from "./usage-reference.js";
|
||||||
export { VERSION } from "./version.js";
|
export { VERSION } from "./version.js";
|
||||||
export { generateWorkflowAuthoringReference } from "./workflow-authoring-reference.js";
|
export { generateWorkflowAuthoringReference } from "./workflow-authoring-reference.js";
|
||||||
export { generateYamlReference } from "./yaml-reference.js";
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
export function generateModeratorReference(): string {
|
|
||||||
return `# Moderator Reference
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
The moderator is the workflow engine's routing component. It evaluates the directed graph defined in the workflow YAML to determine the next role (or \`$END\`) after each step — with zero LLM cost.
|
|
||||||
|
|
||||||
## Status-Based Routing
|
|
||||||
|
|
||||||
The moderator uses **status-based routing**: it inspects the previous step's extracted output (specifically the \`$status\` field) and looks up the corresponding edge in the graph.
|
|
||||||
|
|
||||||
### Graph Structure
|
|
||||||
|
|
||||||
The graph is a nested map: \`Record<Role | "$START", Record<Status, Target>>\`. Each role maps its possible \`$status\` values to a target with a \`role\` and \`prompt\`:
|
|
||||||
|
|
||||||
\`\`\`yaml
|
|
||||||
graph:
|
|
||||||
$START:
|
|
||||||
_: { role: planner, prompt: "Analyze the issue." }
|
|
||||||
planner:
|
|
||||||
ready: { role: developer, prompt: "Implement the plan (CAS hash: {{{plan}}})." }
|
|
||||||
insufficient_info: { role: $END, prompt: "Not enough info." }
|
|
||||||
developer:
|
|
||||||
done: { role: reviewer, prompt: "Review branch {{{branch}}} at {{{worktree}}}." }
|
|
||||||
failed: { role: $END, prompt: "Developer failed: {{{reason}}}." }
|
|
||||||
reviewer:
|
|
||||||
approved: { role: tester, prompt: "Run tests on {{{branch}}} at {{{worktree}}}." }
|
|
||||||
rejected: { role: developer, prompt: "Fix issues: {{{comments}}}." }
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
### Routing Algorithm
|
|
||||||
|
|
||||||
1. Look up \`graph[lastRole]\` to get the status map for the current role
|
|
||||||
2. Look up \`statusMap[lastOutput.$status]\` to get the target
|
|
||||||
3. If target role is \`$END\`, mark thread as completed
|
|
||||||
4. Otherwise, render the edge prompt (Mustache templates with \`{{{field}}}\` from output) and spawn the next agent
|
|
||||||
|
|
||||||
### Edge Prompts and Mustache Templates
|
|
||||||
|
|
||||||
Edge prompts use triple-brace Mustache syntax (\`{{{field}}}\`) to interpolate values from the previous step's output into the next agent's task prompt. This passes structured data (branch names, file paths, CAS hashes) between roles without manual wiring.
|
|
||||||
|
|
||||||
## Special Nodes
|
|
||||||
|
|
||||||
- \`$START\` — entry point; uses status key \`_\` (unconditional) since there is no previous output
|
|
||||||
- \`$END\` — terminal node; thread completes when reached and is moved to history
|
|
||||||
|
|
||||||
## Integration with Steps
|
|
||||||
|
|
||||||
Each \`uwf thread exec\` cycle:
|
|
||||||
1. Moderator reads the thread's head step output
|
|
||||||
2. Looks up \`graph[lastRole][output.$status]\` to pick the next role
|
|
||||||
3. If next is \`$END\`, marks thread as completed
|
|
||||||
4. Otherwise, renders the edge prompt and spawns the agent for the selected role
|
|
||||||
5. Extract pipeline parses agent output → new step node → append to CAS chain
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,9 @@
|
|||||||
// This version is kept in sync with package.json during releases.
|
import { readFileSync } from "node:fs";
|
||||||
export const VERSION = "0.1.0";
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8")) as {
|
||||||
|
version: string;
|
||||||
|
};
|
||||||
|
export const VERSION = pkg.version;
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ roles: # named actors
|
|||||||
|
|
||||||
graph: # status-based routing
|
graph: # status-based routing
|
||||||
$START:
|
$START:
|
||||||
_: { role: planner, prompt: "Analyze the issue." }
|
new: { role: planner, prompt: "Analyze the issue." }
|
||||||
|
resume: { role: planner, prompt: "Review the previous run output and continue." }
|
||||||
planner:
|
planner:
|
||||||
ready: { role: developer, prompt: "Implement {{{plan}}}." }
|
ready: { role: developer, prompt: "Implement {{{plan}}}." }
|
||||||
failed: { role: $END, prompt: "Failed: {{{error}}}" }
|
failed: { role: $END, prompt: "Failed: {{{error}}}" }
|
||||||
@@ -91,16 +92,21 @@ Add any fields you need for data passing between roles. These are available in e
|
|||||||
|
|
||||||
### Flat Schema (Single Status)
|
### Flat Schema (Single Status)
|
||||||
|
|
||||||
When a role has only one outcome:
|
When a role has only one outcome, use \`enum\` with a single value:
|
||||||
|
|
||||||
\`\`\`yaml
|
\`\`\`yaml
|
||||||
frontmatter:
|
frontmatter:
|
||||||
|
type: object
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "done" }
|
$status:
|
||||||
|
type: string
|
||||||
|
enum: [done]
|
||||||
summary: { type: string }
|
summary: { type: string }
|
||||||
required: [$status, summary]
|
required: [$status, summary]
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
|
Note: \`$status: { const: "done" }\` is **not** valid in flat schemas — the validator requires \`enum\` or \`oneOf\` with \`const\`. Use \`const\` only inside \`oneOf\` variants.
|
||||||
|
|
||||||
## Graph Routing
|
## Graph Routing
|
||||||
|
|
||||||
The graph maps each role's \`$status\` values to the next role:
|
The graph maps each role's \`$status\` values to the next role:
|
||||||
@@ -113,7 +119,7 @@ graph[role][$status] → { role: nextRole, prompt: edgePrompt }
|
|||||||
|
|
||||||
| Node | Purpose |
|
| Node | Purpose |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| \`$START\` | Entry point — status key is always \`_\` (unconditional) |
|
| \`$START\` | Entry point — status keys \`new\` (first start) and \`resume\` (resuming a completed thread) |
|
||||||
| \`$END\` | Terminal — thread completes and is archived |
|
| \`$END\` | Terminal — thread completes and is archived |
|
||||||
|
|
||||||
### Edge Prompts
|
### Edge Prompts
|
||||||
@@ -178,7 +184,7 @@ ocas get <output-hash>
|
|||||||
1. Every \`$status\` value in a role's frontmatter has a matching edge in the graph
|
1. Every \`$status\` value in a role's frontmatter has a matching edge in the graph
|
||||||
2. Every field referenced in edge prompts (\`{{{field}}}\`) exists in the source role's schema
|
2. Every field referenced in edge prompts (\`{{{field}}}\`) exists in the source role's schema
|
||||||
3. Every role referenced in the graph exists in \`roles\`
|
3. Every role referenced in the graph exists in \`roles\`
|
||||||
4. \`$START\` has exactly one edge with key \`_\`
|
4. \`$START\` has edges with keys \`new\` and \`resume\`
|
||||||
5. At least one path leads to \`$END\`
|
5. At least one path leads to \`$END\`
|
||||||
6. No orphan roles (defined but never routed to)
|
6. No orphan roles (defined but never routed to)
|
||||||
|
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
export function generateYamlReference(): string {
|
|
||||||
return `# Workflow YAML Schema Reference
|
|
||||||
|
|
||||||
## Top-Level Structure
|
|
||||||
|
|
||||||
A workflow YAML file defines the complete workflow specification:
|
|
||||||
|
|
||||||
\`\`\`yaml
|
|
||||||
name: solve-issue # verb-first kebab-case identifier
|
|
||||||
description: "..." # human-readable description
|
|
||||||
|
|
||||||
roles: # named actors in the workflow
|
|
||||||
planner:
|
|
||||||
description: "Analyzes issue and outputs a plan"
|
|
||||||
goal: "You are a planning agent."
|
|
||||||
capabilities:
|
|
||||||
- issue-analysis
|
|
||||||
- planning
|
|
||||||
procedure: |
|
|
||||||
1. Read the issue
|
|
||||||
2. Produce a test spec
|
|
||||||
output: "Output the plan summary. Set $status to ready or insufficient_info."
|
|
||||||
frontmatter: # JSON Schema for structured output (drives routing)
|
|
||||||
oneOf:
|
|
||||||
- properties:
|
|
||||||
$status: { const: ready }
|
|
||||||
plan: { type: string }
|
|
||||||
required: [$status, plan]
|
|
||||||
- properties:
|
|
||||||
$status: { const: insufficient_info }
|
|
||||||
required: [$status]
|
|
||||||
|
|
||||||
graph: # status-based routing (nested map)
|
|
||||||
$START:
|
|
||||||
_: { role: planner, prompt: "Analyze the issue." }
|
|
||||||
planner:
|
|
||||||
ready: { role: developer, prompt: "Implement plan {{{plan}}}." }
|
|
||||||
insufficient_info: { role: $END, prompt: "Not enough info." }
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## roles
|
|
||||||
|
|
||||||
Each role defines an actor in the workflow:
|
|
||||||
|
|
||||||
| Field | Type | Description |
|
|
||||||
|-------|------|-------------|
|
|
||||||
| \`description\` | string | Short description of the role's purpose |
|
|
||||||
| \`goal\` | string | System-level goal statement for the agent |
|
|
||||||
| \`capabilities\` | string[] | Tags describing what the role can do |
|
|
||||||
| \`procedure\` | string | Step-by-step instructions for the agent |
|
|
||||||
| \`output\` | string | Description of expected output format |
|
|
||||||
| \`frontmatter\` | JSON Schema | Defines the structured output the agent must produce |
|
|
||||||
|
|
||||||
### frontmatter
|
|
||||||
|
|
||||||
The \`frontmatter\` field is a standard JSON Schema object. The extract pipeline validates agent output against it. Key conventions:
|
|
||||||
- \`$status\` field drives routing decisions in the graph
|
|
||||||
- Use \`const\` or \`enum\` to constrain status values
|
|
||||||
- Use \`oneOf\` to define multiple valid output shapes (one per status)
|
|
||||||
- All \`required\` fields must appear in the agent's frontmatter output
|
|
||||||
|
|
||||||
## graph
|
|
||||||
|
|
||||||
The graph is a nested map defining status-based routing:
|
|
||||||
|
|
||||||
\`\`\`
|
|
||||||
Record<Role | "$START", Record<Status, { role: string, prompt: string }>>
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
| Level | Key | Value |
|
|
||||||
|-------|-----|-------|
|
|
||||||
| Outer | Role name or \`$START\` | Status map for that role |
|
|
||||||
| Inner | \`$status\` value (or \`_\` for unconditional) | Target: \`{ role, prompt }\` |
|
|
||||||
|
|
||||||
### Special Nodes
|
|
||||||
- \`$START\` — entry point; uses status key \`_\` (unconditional, no previous output)
|
|
||||||
- \`$END\` — terminal node; thread completes when reached
|
|
||||||
|
|
||||||
### Edge Prompts
|
|
||||||
Prompts use triple-brace Mustache templates (\`{{{field}}}\`) to interpolate values from the previous step's output. Example: \`"Implement plan {{{plan}}} in repo {{{repoPath}}}."\`
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
@@ -21,9 +21,12 @@ graph:
|
|||||||
role: package-metadata
|
role: package-metadata
|
||||||
prompt: Biome setup failed ({{{reason}}}), but continue. Standardize package metadata for repo at {{{repoPath}}}.
|
prompt: Biome setup failed ({{{reason}}}), but continue. Standardize package metadata for repo at {{{repoPath}}}.
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: workspace
|
role: workspace
|
||||||
prompt: Set up bun workspace structure for repo at {{{repoPath}}}.
|
prompt: Set up bun workspace structure for repo at {{{repoPath}}}.
|
||||||
|
resume:
|
||||||
|
role: workspace
|
||||||
|
prompt: Review the previous run output and continue setting up the bun workspace structure for repo at {{{repoPath}}}.
|
||||||
release:
|
release:
|
||||||
done:
|
done:
|
||||||
role: testing
|
role: testing
|
||||||
|
|||||||
@@ -283,9 +283,12 @@ roles:
|
|||||||
- error
|
- error
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
_:
|
new:
|
||||||
role: planner
|
role: planner
|
||||||
prompt: Analyze the issue and produce an implementation plan.
|
prompt: Analyze the issue and produce an implementation plan.
|
||||||
|
resume:
|
||||||
|
role: planner
|
||||||
|
prompt: Review the previous run output and continue the work.
|
||||||
planner:
|
planner:
|
||||||
insufficient_info:
|
insufficient_info:
|
||||||
role: $SUSPEND
|
role: $SUSPEND
|
||||||
|
|||||||
Reference in New Issue
Block a user