Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83992a71cd |
@@ -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.
|
||||||
+56
-124
@@ -1,131 +1,63 @@
|
|||||||
name: debate
|
name: "debate"
|
||||||
description: "Multi-role structured debate with critical thinking framework and host summary."
|
description: "Structured debate between two sides. Tests cross-process session resume."
|
||||||
|
|
||||||
# Shared frontmatter schema for debater roles (YAML anchor)
|
|
||||||
x-debater-frontmatter: &debater-frontmatter
|
|
||||||
type: object
|
|
||||||
oneOf:
|
|
||||||
- properties:
|
|
||||||
$status: { const: speak }
|
|
||||||
argument: { type: string }
|
|
||||||
required: [$status, argument]
|
|
||||||
- properties:
|
|
||||||
$status: { const: conceded }
|
|
||||||
reason: { type: string }
|
|
||||||
required: [$status, reason]
|
|
||||||
- properties:
|
|
||||||
$status: { const: final }
|
|
||||||
closing: { type: string }
|
|
||||||
required: [$status, closing]
|
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
proponent:
|
against:
|
||||||
description: "Argues FOR the proposition"
|
description: "Argues against the proposition"
|
||||||
goal: "Build a compelling case for the proposition through logical reasoning and evidence"
|
goal: |
|
||||||
capabilities: []
|
You are a skilled debater arguing AGAINST the proposition.
|
||||||
|
Be logical, cite evidence, and directly address your opponent's points.
|
||||||
|
Keep each argument concise (under 200 words).
|
||||||
|
capabilities:
|
||||||
|
- argumentation
|
||||||
|
- critical-thinking
|
||||||
procedure: |
|
procedure: |
|
||||||
You are an experienced scholar arguing FOR the proposition.
|
1. If this is the opening, present your strongest argument against the proposition.
|
||||||
|
2. If responding to the other side, directly counter their points with evidence and logic.
|
||||||
## Critical Thinking Framework (execute before every speech)
|
3. If you find yourself genuinely convinced by the other side, you may concede.
|
||||||
|
output: |
|
||||||
### A. Pre-speech reflection (internal, do not output)
|
Provide your argument in the frontmatter.
|
||||||
- Does every step in my argument chain hold? Any hidden assumptions or logical gaps?
|
Set status to "conceded" ONLY if you are genuinely convinced and wish to stop debating.
|
||||||
- If I were my opponent, how would I attack this? Where am I weakest?
|
Otherwise set status to "continue".
|
||||||
- Does my evidence actually support my claim, or could it backfire?
|
|
||||||
- Should I go on offense or defense this round?
|
|
||||||
|
|
||||||
### B. Evidence discipline
|
|
||||||
- Verify key numbers — watch for order-of-magnitude errors
|
|
||||||
- Assess data freshness — fast-moving fields have short half-lives
|
|
||||||
- Distinguish primary data from secondary citations, expert opinion, and common assumptions
|
|
||||||
|
|
||||||
### C. Anti-fragility
|
|
||||||
- Anticipate counterarguments; preemptively strengthen or strategically abandon weak points
|
|
||||||
- Catch logical gaps, data misuse, or outdated claims in your opponent's reasoning
|
|
||||||
|
|
||||||
## Rules
|
|
||||||
1. Check Thread Progress to see how many times you have spoken.
|
|
||||||
2. On your 3rd speech, you MUST output $status: final (closing statement).
|
|
||||||
3. If genuinely convinced by the opponent, output $status: conceded.
|
|
||||||
4. Otherwise output $status: speak and counter the opponent's points.
|
|
||||||
5. Be rigorous, cite evidence, stay concise.
|
|
||||||
output: "Debate argument"
|
|
||||||
frontmatter: *debater-frontmatter
|
|
||||||
|
|
||||||
opponent:
|
|
||||||
description: "Argues AGAINST the proposition"
|
|
||||||
goal: "Build a compelling case against the proposition through logical reasoning and evidence"
|
|
||||||
capabilities: []
|
|
||||||
procedure: |
|
|
||||||
You are an experienced scholar arguing AGAINST the proposition.
|
|
||||||
|
|
||||||
## Critical Thinking Framework (execute before every speech)
|
|
||||||
|
|
||||||
### A. Pre-speech reflection (internal, do not output)
|
|
||||||
- Does every step in my argument chain hold? Any hidden assumptions or logical gaps?
|
|
||||||
- If I were my opponent, how would I attack this? Where am I weakest?
|
|
||||||
- Does my evidence actually support my claim, or could it backfire?
|
|
||||||
- Should I go on offense or defense this round?
|
|
||||||
|
|
||||||
### B. Evidence discipline
|
|
||||||
- Verify key numbers — watch for order-of-magnitude errors
|
|
||||||
- Assess data freshness — fast-moving fields have short half-lives
|
|
||||||
- Distinguish primary data from secondary citations, expert opinion, and common assumptions
|
|
||||||
|
|
||||||
### C. Anti-fragility
|
|
||||||
- Anticipate counterarguments; preemptively strengthen or strategically abandon weak points
|
|
||||||
- Catch logical gaps, data misuse, or outdated claims in your opponent's reasoning
|
|
||||||
|
|
||||||
## Rules
|
|
||||||
1. Check Thread Progress to see how many times you have spoken.
|
|
||||||
2. On your 3rd speech, or when the proponent has issued a final statement, you MUST output $status: final.
|
|
||||||
3. If genuinely convinced by the proponent, output $status: conceded.
|
|
||||||
4. Otherwise output $status: speak and counter the proponent's points.
|
|
||||||
5. Be rigorous, cite evidence, stay concise.
|
|
||||||
output: "Debate argument"
|
|
||||||
frontmatter: *debater-frontmatter
|
|
||||||
|
|
||||||
host:
|
|
||||||
description: "Debate moderator — delivers impartial summary and verdict"
|
|
||||||
goal: "Objectively review the debate, analyze both sides, and deliver a verdict"
|
|
||||||
capabilities: []
|
|
||||||
procedure: |
|
|
||||||
You are an experienced academic debate moderator.
|
|
||||||
|
|
||||||
## Task
|
|
||||||
1. Outline each side's core arguments
|
|
||||||
2. Evaluate reasoning quality and evidence use
|
|
||||||
3. Highlight the most impactful exchanges
|
|
||||||
4. Analyze the deeper significance of the topic
|
|
||||||
5. Deliver an overall verdict
|
|
||||||
|
|
||||||
## Style
|
|
||||||
- Impartial but with independent judgment
|
|
||||||
- Substantive, not superficial
|
|
||||||
output: "Debate summary report"
|
|
||||||
frontmatter:
|
frontmatter:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
$status: { const: done }
|
$status:
|
||||||
summary: { type: string }
|
enum: ["continue", "conceded"]
|
||||||
highlights: { type: string }
|
argument:
|
||||||
verdict: { type: string }
|
type: string
|
||||||
required: [$status, summary, highlights, verdict]
|
required: [$status, argument]
|
||||||
|
for:
|
||||||
|
description: "Argues for the proposition"
|
||||||
|
goal: |
|
||||||
|
You are a skilled debater arguing FOR the proposition.
|
||||||
|
Be logical, cite evidence, and directly address your opponent's points.
|
||||||
|
Keep each argument concise (under 200 words).
|
||||||
|
capabilities:
|
||||||
|
- argumentation
|
||||||
|
- critical-thinking
|
||||||
|
procedure: |
|
||||||
|
1. Read the opposing side's latest argument carefully.
|
||||||
|
2. Counter their points with evidence and logic.
|
||||||
|
3. If you find yourself genuinely convinced by the other side, you may concede.
|
||||||
|
output: |
|
||||||
|
Provide your argument in the frontmatter.
|
||||||
|
Set status to "conceded" ONLY if you are genuinely convinced and wish to stop debating.
|
||||||
|
Otherwise set status to "continue".
|
||||||
|
frontmatter:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
$status:
|
||||||
|
enum: ["continue", "conceded"]
|
||||||
|
argument:
|
||||||
|
type: string
|
||||||
|
required: [$status, argument]
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new: { role: proponent, prompt: "The debate begins. You are arguing FOR the proposition. Present your opening argument." }
|
new: { role: "against", prompt: "Present your opening argument against the proposition." }
|
||||||
resume: { role: proponent, prompt: "The debate continues." }
|
resume: { role: "against", prompt: "Review the previous debate output and continue the argument against the proposition." }
|
||||||
|
against:
|
||||||
proponent:
|
conceded: { role: "$END", prompt: "The against side conceded. Debate over." }
|
||||||
speak: { role: opponent, prompt: "Proponent argues:\n\n{{{argument}}}\n\nYou are the opponent. Counter this argument." }
|
continue: { role: "for", prompt: "Counter the opposing argument: {{{argument}}}" }
|
||||||
conceded: { role: host, prompt: "The proponent conceded: {{{reason}}}\n\nPlease summarize the debate." }
|
for:
|
||||||
final: { role: opponent, prompt: "Proponent's closing statement:\n\n{{{closing}}}\n\nYou are the opponent. Deliver your final response." }
|
conceded: { role: "$END", prompt: "The for side conceded. Debate over." }
|
||||||
|
continue: { role: "against", prompt: "Counter the opposing argument: {{{argument}}}" }
|
||||||
opponent:
|
|
||||||
speak: { role: proponent, prompt: "Opponent argues:\n\n{{{argument}}}\n\nYou are the proponent. Counter this argument." }
|
|
||||||
conceded: { role: host, prompt: "The opponent conceded: {{{reason}}}\n\nPlease summarize the debate." }
|
|
||||||
final: { role: host, prompt: "Opponent's closing statement:\n\n{{{closing}}}\n\nThe debate is over. Please summarize." }
|
|
||||||
|
|
||||||
host:
|
|
||||||
done: { role: "$END", prompt: "Summary complete." }
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-builtin",
|
"name": "@united-workforce/agent-builtin",
|
||||||
"version": "0.1.2",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// eslint-disable-next-line -- dynamic import for version
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
const pkg = await import("../package.json", { with: { type: "json" } });
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-claude-code",
|
"name": "@united-workforce/agent-claude-code",
|
||||||
"version": "0.1.3",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
type AgentRunResult,
|
type AgentRunResult,
|
||||||
buildContinuationPrompt,
|
buildContinuationPrompt,
|
||||||
buildRolePrompt,
|
buildRolePrompt,
|
||||||
buildThreadProgress,
|
|
||||||
createAgent,
|
createAgent,
|
||||||
getCachedSessionId,
|
getCachedSessionId,
|
||||||
setCachedSessionId,
|
setCachedSessionId,
|
||||||
@@ -28,10 +27,6 @@ export function buildClaudeCodePrompt(ctx: AgentContext): string {
|
|||||||
if (ctx.outputFormatInstruction !== undefined && ctx.outputFormatInstruction !== "") {
|
if (ctx.outputFormatInstruction !== undefined && ctx.outputFormatInstruction !== "") {
|
||||||
parts.push(ctx.outputFormatInstruction, "");
|
parts.push(ctx.outputFormatInstruction, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject thread progress so the agent knows step count and role visit count
|
|
||||||
parts.push(buildThreadProgress(ctx.steps, ctx.role), "");
|
|
||||||
|
|
||||||
parts.push(rolePrompt, "", "## Task", ctx.start.prompt);
|
parts.push(rolePrompt, "", "## Task", ctx.start.prompt);
|
||||||
|
|
||||||
if (!ctx.isFirstVisit) {
|
if (!ctx.isFirstVisit) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// eslint-disable-next-line -- dynamic import for version
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
const pkg = await import("../package.json", { with: { type: "json" } });
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ describe("Issue #551 — bin entry & engines", () => {
|
|||||||
const pkg = JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf-8"));
|
const pkg = JSON.parse(readFileSync(join(PKG_ROOT, "package.json"), "utf-8"));
|
||||||
const binPath = pkg.bin["uwf-hermes"];
|
const binPath = pkg.bin["uwf-hermes"];
|
||||||
const content = readFileSync(join(PKG_ROOT, binPath), "utf-8");
|
const content = readFileSync(join(PKG_ROOT, binPath), "utf-8");
|
||||||
expect(content.startsWith("#!/usr/bin/env")).toBe(true);
|
expect(content.startsWith("#!/usr/bin/env node")).toBe(true);
|
||||||
expect(content).toContain("node");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("README.md explains uwf-hermes is an adapter", () => {
|
test("README.md explains uwf-hermes is an adapter", () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-hermes",
|
"name": "@united-workforce/agent-hermes",
|
||||||
"version": "0.1.4",
|
"version": "0.1.2",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -12,11 +12,7 @@ const OWN_VERSION = (
|
|||||||
}
|
}
|
||||||
).version;
|
).version;
|
||||||
|
|
||||||
/** Resolve hermes binary: `UWF_HERMES_BIN` override → default `"hermes"` via PATH. */
|
const HERMES_COMMAND = "hermes";
|
||||||
function resolveHermesCommand(): string {
|
|
||||||
const override = process.env.UWF_HERMES_BIN;
|
|
||||||
return override !== undefined && override !== "" ? override : "hermes";
|
|
||||||
}
|
|
||||||
const PROTOCOL_VERSION = 1;
|
const PROTOCOL_VERSION = 1;
|
||||||
|
|
||||||
type JsonRpcResponse = {
|
type JsonRpcResponse = {
|
||||||
@@ -275,8 +271,7 @@ export class HermesAcpClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hermesCommand = resolveHermesCommand();
|
const child = spawn(HERMES_COMMAND, ["acp"], {
|
||||||
const child = spawn(hermesCommand, ["acp"], {
|
|
||||||
env: process.env,
|
env: process.env,
|
||||||
shell: false,
|
shell: false,
|
||||||
stdio: ["pipe", "pipe", "pipe"],
|
stdio: ["pipe", "pipe", "pipe"],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// eslint-disable-next-line -- dynamic import for version
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
const pkg = await import("../package.json", { with: { type: "json" } });
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
type AgentRunResult,
|
type AgentRunResult,
|
||||||
buildContinuationPrompt,
|
buildContinuationPrompt,
|
||||||
buildRolePrompt,
|
buildRolePrompt,
|
||||||
buildThreadProgress,
|
|
||||||
createAgent,
|
createAgent,
|
||||||
} from "@united-workforce/util-agent";
|
} from "@united-workforce/util-agent";
|
||||||
import type { AcpUsage } from "./acp-client.js";
|
import type { AcpUsage } from "./acp-client.js";
|
||||||
@@ -61,9 +60,6 @@ export function buildHermesPrompt(ctx: AgentContext): string {
|
|||||||
parts.push(ctx.outputFormatInstruction, "");
|
parts.push(ctx.outputFormatInstruction, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject thread progress so the agent knows step count and role visit count
|
|
||||||
parts.push(buildThreadProgress(ctx.steps, ctx.role), "");
|
|
||||||
|
|
||||||
if (!ctx.isFirstVisit) {
|
if (!ctx.isFirstVisit) {
|
||||||
// Re-entry: show only steps since last visit, meta only
|
// Re-entry: show only steps since last visit, meta only
|
||||||
parts.push(buildContinuationPrompt(ctx.steps, ctx.role, ctx.edgePrompt));
|
parts.push(buildContinuationPrompt(ctx.steps, ctx.role, ctx.edgePrompt));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/agent-mock",
|
"name": "@united-workforce/agent-mock",
|
||||||
"version": "0.1.2",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// eslint-disable-next-line -- dynamic import for version
|
// eslint-disable-next-line -- dynamic import for version
|
||||||
const pkg = await import("../package.json", { with: { type: "json" } });
|
const pkg = await import("../package.json", { with: { type: "json" } });
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/cli",
|
"name": "@united-workforce/cli",
|
||||||
"version": "0.3.0",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -28,13 +28,9 @@ roles:
|
|||||||
$status: "ready"
|
$status: "ready"
|
||||||
frontmatter:
|
frontmatter:
|
||||||
type: object
|
type: object
|
||||||
oneOf:
|
|
||||||
- properties:
|
|
||||||
$status: { const: "ready" }
|
|
||||||
required: ["$status"]
|
|
||||||
- properties:
|
|
||||||
$status: { const: "not-ready" }
|
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
|
properties:
|
||||||
|
$status: { type: string, enum: ["ready", "not-ready"] }
|
||||||
roleB:
|
roleB:
|
||||||
description: Second role
|
description: Second role
|
||||||
goal: Do B
|
goal: Do B
|
||||||
@@ -46,7 +42,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "done" }
|
$status: { type: string, enum: ["done"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
@@ -86,13 +82,9 @@ roles:
|
|||||||
$status: "pass"
|
$status: "pass"
|
||||||
frontmatter:
|
frontmatter:
|
||||||
type: object
|
type: object
|
||||||
oneOf:
|
|
||||||
- properties:
|
|
||||||
$status: { const: "pass" }
|
|
||||||
required: ["$status"]
|
|
||||||
- properties:
|
|
||||||
$status: { const: "fail" }
|
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
|
properties:
|
||||||
|
$status: { type: string, enum: ["pass", "fail"] }
|
||||||
roleB:
|
roleB:
|
||||||
description: Pass role
|
description: Pass role
|
||||||
goal: Do B
|
goal: Do B
|
||||||
@@ -104,7 +96,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "done" }
|
$status: { type: string, enum: ["done"] }
|
||||||
roleC:
|
roleC:
|
||||||
description: Fail role
|
description: Fail role
|
||||||
goal: Do C
|
goal: Do C
|
||||||
@@ -116,7 +108,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "done" }
|
$status: { type: string, enum: ["done"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
@@ -163,7 +155,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "done" }
|
$status: { type: string, enum: ["done"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
|
|||||||
@@ -71,22 +71,12 @@ describe("prompt commands", () => {
|
|||||||
test("prompt bootstrap returns framework-agnostic setup instructions", () => {
|
test("prompt bootstrap returns framework-agnostic setup instructions", () => {
|
||||||
const result = cmdPromptBootstrap();
|
const result = cmdPromptBootstrap();
|
||||||
expect(typeof result).toBe("string");
|
expect(typeof result).toBe("string");
|
||||||
// Skills installation
|
|
||||||
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).toContain("uwf-usage");
|
expect(result).toContain("uwf-usage");
|
||||||
expect(result).toContain("uwf-workflow-authoring");
|
expect(result).toContain("uwf-workflow-authoring");
|
||||||
expect(result).toContain("uwf-adapter-developing");
|
expect(result).toContain("uwf-adapter-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
|
// Should NOT contain Hermes-specific paths
|
||||||
expect(result).not.toContain("~/.hermes/skills/");
|
expect(result).not.toContain("~/.hermes/skills/");
|
||||||
expect(result).not.toContain("> ~/.hermes/");
|
expect(result).not.toContain("> ~/.hermes/");
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "ready" }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
@@ -114,7 +114,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "ready" }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
@@ -161,7 +161,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "ready" }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "ready" }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ roles:
|
|||||||
type: object
|
type: object
|
||||||
required: ["$status"]
|
required: ["$status"]
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "ready" }
|
$status: { type: string, enum: ["ready"] }
|
||||||
graph:
|
graph:
|
||||||
$START:
|
$START:
|
||||||
new:
|
new:
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function makeWorkflow(overrides?: Partial<WorkflowPayload>): WorkflowPayload {
|
|||||||
frontmatter: {
|
frontmatter: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
$status: { const: "done" },
|
$status: { enum: ["done"] },
|
||||||
plan: { type: "string" },
|
plan: { type: "string" },
|
||||||
},
|
},
|
||||||
required: ["$status", "plan"],
|
required: ["$status", "plan"],
|
||||||
@@ -85,7 +85,7 @@ describe("Suite 1: Role Reference Integrity", () => {
|
|||||||
output: "None",
|
output: "None",
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: { $status: { const: "done" } },
|
properties: { $status: { enum: ["done"] } },
|
||||||
required: ["$status"],
|
required: ["$status"],
|
||||||
} as unknown as string,
|
} as unknown as string,
|
||||||
};
|
};
|
||||||
@@ -187,7 +187,7 @@ describe("Suite 2: Graph Structure", () => {
|
|||||||
output: "Isolated",
|
output: "Isolated",
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: { $status: { const: "done" } },
|
properties: { $status: { enum: ["done"] } },
|
||||||
required: ["$status"],
|
required: ["$status"],
|
||||||
} as unknown as string,
|
} as unknown as string,
|
||||||
};
|
};
|
||||||
@@ -272,8 +272,8 @@ describe("Suite 3: Status-Edge Consistency", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Suite 3b: Enum-Based $status is Rejected", () => {
|
describe("Suite 3b: Enum-Based Multi-Exit", () => {
|
||||||
test("3b.1 enum multi-exit is rejected (must use oneOf + const)", () => {
|
test("3b.1 enum multi-exit passes with matching graph keys", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.roles.reviewer = {
|
wf.roles.reviewer = {
|
||||||
...wf.roles.reviewer,
|
...wf.roles.reviewer,
|
||||||
@@ -291,10 +291,52 @@ describe("Suite 3b: Enum-Based $status is Rejected", () => {
|
|||||||
rejected: { role: "writer", prompt: "Fix: {{{comments}}}", location: null },
|
rejected: { role: "writer", prompt: "Fix: {{{comments}}}", location: null },
|
||||||
};
|
};
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
expect(errors.some((e) => e.includes("must define") && e.includes("const"))).toBe(true);
|
expect(errors).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("3b.2 enum single-exit is rejected (must use const)", () => {
|
test("3b.2 enum multi-exit with extra graph key", () => {
|
||||||
|
const wf = makeWorkflow();
|
||||||
|
wf.roles.reviewer = {
|
||||||
|
...wf.roles.reviewer,
|
||||||
|
frontmatter: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
$status: { enum: ["approved", "rejected"] },
|
||||||
|
comments: { type: "string" },
|
||||||
|
},
|
||||||
|
required: ["$status", "comments"],
|
||||||
|
} as unknown as string,
|
||||||
|
};
|
||||||
|
wf.graph.reviewer = {
|
||||||
|
approved: { role: "$END", prompt: "Done", location: null },
|
||||||
|
rejected: { role: "writer", prompt: "Fix", location: null },
|
||||||
|
timeout: { role: "$END", prompt: "Timed out", location: null },
|
||||||
|
};
|
||||||
|
const errors = validateWorkflow(wf);
|
||||||
|
expect(errors.some((e) => e.includes("extra status keys: timeout"))).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("3b.3 enum multi-exit with missing graph key", () => {
|
||||||
|
const wf = makeWorkflow();
|
||||||
|
wf.roles.reviewer = {
|
||||||
|
...wf.roles.reviewer,
|
||||||
|
frontmatter: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
$status: { enum: ["approved", "rejected"] },
|
||||||
|
comments: { type: "string" },
|
||||||
|
},
|
||||||
|
required: ["$status", "comments"],
|
||||||
|
} as unknown as string,
|
||||||
|
};
|
||||||
|
wf.graph.reviewer = {
|
||||||
|
approved: { role: "$END", prompt: "Done", location: null },
|
||||||
|
};
|
||||||
|
const errors = validateWorkflow(wf);
|
||||||
|
expect(errors.some((e) => e.includes("missing status keys: rejected"))).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("3b.4 enum with single explicit value passes", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.roles.writer = {
|
wf.roles.writer = {
|
||||||
...wf.roles.writer,
|
...wf.roles.writer,
|
||||||
@@ -309,71 +351,28 @@ describe("Suite 3b: Enum-Based $status is Rejected", () => {
|
|||||||
};
|
};
|
||||||
wf.graph.writer = { ready: { role: "reviewer", prompt: "Review: {{{plan}}}", location: null } };
|
wf.graph.writer = { ready: { role: "reviewer", prompt: "Review: {{{plan}}}", location: null } };
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
expect(errors.some((e) => e.includes("must define") && e.includes("const"))).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Suite 3c: Const-Based Flat Schema", () => {
|
|
||||||
test("3c.1 flat schema with const $status passes validation", () => {
|
|
||||||
const wf = makeWorkflow();
|
|
||||||
wf.roles.writer = {
|
|
||||||
...wf.roles.writer,
|
|
||||||
frontmatter: {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
$status: { const: "done" },
|
|
||||||
plan: { type: "string" },
|
|
||||||
},
|
|
||||||
required: ["$status", "plan"],
|
|
||||||
} as unknown as string,
|
|
||||||
};
|
|
||||||
const errors = validateWorkflow(wf);
|
|
||||||
expect(errors).toEqual([]);
|
expect(errors).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("3c.2 flat schema with const $status detects extra graph key", () => {
|
test("3b.5 enum multi-exit mustache var not in frontmatter", () => {
|
||||||
const wf = makeWorkflow();
|
const wf = makeWorkflow();
|
||||||
wf.roles.writer = {
|
wf.roles.reviewer = {
|
||||||
...wf.roles.writer,
|
...wf.roles.reviewer,
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
$status: { const: "done" },
|
$status: { enum: ["approved", "rejected"] },
|
||||||
plan: { type: "string" },
|
comments: { type: "string" },
|
||||||
},
|
},
|
||||||
required: ["$status", "plan"],
|
required: ["$status", "comments"],
|
||||||
} as unknown as string,
|
} as unknown as string,
|
||||||
};
|
};
|
||||||
wf.graph.writer = {
|
wf.graph.reviewer = {
|
||||||
done: { role: "reviewer", prompt: "Review.", location: null },
|
approved: { role: "$END", prompt: "Done: {{{nonexistent}}}", location: null },
|
||||||
extra: { role: "$END", prompt: "Nope.", location: null },
|
rejected: { role: "writer", prompt: "Fix: {{{comments}}}", location: null },
|
||||||
};
|
};
|
||||||
const errors = validateWorkflow(wf);
|
const errors = validateWorkflow(wf);
|
||||||
expect(errors.some((e) => e.includes("extra status keys") && e.includes("extra"))).toBe(true);
|
expect(errors.some((e) => e.includes("nonexistent") && e.includes("not found"))).toBe(true);
|
||||||
});
|
|
||||||
|
|
||||||
test("3c.3 flat schema with const $status validates mustache vars", () => {
|
|
||||||
const wf = makeWorkflow();
|
|
||||||
wf.roles.writer = {
|
|
||||||
...wf.roles.writer,
|
|
||||||
frontmatter: {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
$status: { const: "done" },
|
|
||||||
plan: { type: "string" },
|
|
||||||
},
|
|
||||||
required: ["$status", "plan"],
|
|
||||||
} as unknown as string,
|
|
||||||
};
|
|
||||||
wf.graph.writer = {
|
|
||||||
done: { role: "reviewer", prompt: "Review: {{{nonexistent}}}", location: null },
|
|
||||||
};
|
|
||||||
const errors = validateWorkflow(wf);
|
|
||||||
expect(
|
|
||||||
errors.some(
|
|
||||||
(e) => e.includes('prompt variable "nonexistent"') && e.includes('role "writer"'),
|
|
||||||
),
|
|
||||||
).toBe(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -481,7 +480,7 @@ describe("Suite 6: Multiple Errors Collection", () => {
|
|||||||
output: "None",
|
output: "None",
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: { $status: { const: "done" } },
|
properties: { $status: { enum: ["done"] } },
|
||||||
required: ["$status"],
|
required: ["$status"],
|
||||||
} as unknown as string,
|
} as unknown as string,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function makeMinimalPayload(name: string, description: string): WorkflowPayload
|
|||||||
frontmatter: {
|
frontmatter: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
$status: { const: "done" },
|
$status: { type: "string", enum: ["done"] },
|
||||||
},
|
},
|
||||||
required: ["$status"],
|
required: ["$status"],
|
||||||
} as unknown as CasRef,
|
} as unknown as CasRef,
|
||||||
|
|||||||
+6
-10
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import type { CasRef, ThreadId, ThreadStatus } from "@united-workforce/protocol";
|
import type { CasRef, ThreadId, ThreadStatus } from "@united-workforce/protocol";
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
cmdPromptUsage,
|
cmdPromptUsage,
|
||||||
cmdPromptWorkflowAuthoring,
|
cmdPromptWorkflowAuthoring,
|
||||||
} from "./commands/prompt.js";
|
} from "./commands/prompt.js";
|
||||||
import { cmdSetup, cmdSetupInteractive, resolvePresetBaseUrl } from "./commands/setup.js";
|
import { cmdSetup, cmdSetupInteractive } 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,
|
||||||
@@ -542,7 +542,7 @@ prompt
|
|||||||
|
|
||||||
program
|
program
|
||||||
.command("setup")
|
.command("setup")
|
||||||
.description("Configure provider, model, and agent. Run without options for interactive wizard.")
|
.description("Configure provider, model, and agent")
|
||||||
.option("--provider <name>", "Provider name")
|
.option("--provider <name>", "Provider name")
|
||||||
.option("--base-url <url>", "OpenAI-compatible API base URL")
|
.option("--base-url <url>", "OpenAI-compatible API base URL")
|
||||||
.option("--api-key <key>", "API key")
|
.option("--api-key <key>", "API key")
|
||||||
@@ -558,14 +558,10 @@ program
|
|||||||
}) => {
|
}) => {
|
||||||
const storageRoot = resolveStorageRoot();
|
const storageRoot = resolveStorageRoot();
|
||||||
runAction(async () => {
|
runAction(async () => {
|
||||||
// Resolve preset base-url when provider is known but --base-url is omitted
|
if (opts.provider && opts.baseUrl && opts.apiKey && opts.model) {
|
||||||
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: resolvedBaseUrl,
|
baseUrl: opts.baseUrl,
|
||||||
apiKey: opts.apiKey,
|
apiKey: opts.apiKey,
|
||||||
model: opts.model,
|
model: opts.model,
|
||||||
agent: opts.agent ?? undefined,
|
agent: opts.agent ?? undefined,
|
||||||
@@ -576,7 +572,7 @@ program
|
|||||||
await cmdSetupInteractive(storageRoot);
|
await cmdSetupInteractive(storageRoot);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Non-interactive setup requires: --provider, --api-key, --model (--base-url is optional for preset providers)",
|
"Non-interactive setup requires all of: --provider, --base-url, --api-key, --model",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,35 +1,10 @@
|
|||||||
import { readFileSync } from "node:fs";
|
|
||||||
import { dirname, join } from "node:path";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
import {
|
import {
|
||||||
generateAdapterDevelopingReference,
|
generateAdapterDevelopingReference,
|
||||||
generateUsageReference,
|
generateUsageReference,
|
||||||
generateWorkflowAuthoringReference,
|
generateWorkflowAuthoringReference,
|
||||||
|
VERSION,
|
||||||
} 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,
|
||||||
generateUsageReference as cmdPromptUsage,
|
generateUsageReference as cmdPromptUsage,
|
||||||
@@ -47,275 +22,33 @@ export function cmdPromptList(): ReadonlyArray<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function cmdPromptBootstrap(): string {
|
export function cmdPromptBootstrap(): string {
|
||||||
return `# uwf Bootstrap
|
return `# uwf Skill Bootstrap
|
||||||
|
|
||||||
Set up or upgrade uwf (United Workforce) — from zero to running your first workflow.
|
Install or update the uwf (United Workforce) skills for your agent.
|
||||||
|
|
||||||
## Scenario A: Fresh Install
|
## Steps
|
||||||
|
|
||||||
### Step 0 — Environment pre-flight check
|
|
||||||
|
|
||||||
Run ALL checks below BEFORE installing anything. If any check fails, fix it first — do NOT skip ahead.
|
|
||||||
|
|
||||||
|
1. **Check if uwf CLI is installed:**
|
||||||
\`\`\`bash
|
\`\`\`bash
|
||||||
# 1. Node.js
|
uwf --help
|
||||||
node --version # need v20+
|
|
||||||
# FIX: install via nvm (https://github.com/nvm-sh/nvm) or your OS package manager
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
If not installed: \`npm install -g @united-workforce/cli\`
|
||||||
|
Current version: ${VERSION}
|
||||||
|
|
||||||
**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.
|
2. **Install the skills** by running each command below and creating a skill from its output:
|
||||||
|
- Run \`uwf prompt usage\` → create a skill named \`uwf-usage\`
|
||||||
|
- Run \`uwf prompt workflow-authoring\` → create a skill named \`uwf-workflow-authoring\`
|
||||||
|
- Run \`uwf prompt adapter-developing\` → create a skill named \`uwf-adapter-developing\`
|
||||||
|
|
||||||
### Step 1 — Discover agents and install adapter
|
Each command outputs a complete SKILL.md with YAML frontmatter — use your agent framework's skill creation API to save them.
|
||||||
|
|
||||||
**First, detect which supported agents are already installed on the user's machine:**
|
3. **Verify** the skills are loadable by your agent framework.
|
||||||
|
|
||||||
\`\`\`bash
|
## Updating
|
||||||
# Check for Hermes Agent
|
|
||||||
which hermes 2>/dev/null && hermes --version
|
|
||||||
|
|
||||||
# Check for Claude Code
|
When \`uwf\` is upgraded, re-run \`uwf prompt bootstrap\` and follow the steps again.
|
||||||
which claude 2>/dev/null && claude --version # should show "X.Y.Z (Claude Code)"
|
The skill content is bundled with the CLI — always use \`uwf prompt <name>\` to get
|
||||||
\`\`\`
|
content matching your installed version.
|
||||||
|
|
||||||
**Based on the results:**
|
|
||||||
|
|
||||||
- **Only hermes found** → install \`uwf-hermes\` adapter
|
|
||||||
- **Only claude found** → install \`uwf-claude-code\` adapter
|
|
||||||
- **Both found** → ask the user which agent they want uwf to use as default
|
|
||||||
- **Neither found** → the user must install at least one agent first:
|
|
||||||
- Hermes Agent: https://hermes-agent.nousresearch.com/docs
|
|
||||||
- Claude Code: \`npm install -g @anthropic-ai/claude-code\`
|
|
||||||
|
|
||||||
**Install the uwf CLI and the chosen adapter** using pnpm or npm:
|
|
||||||
|
|
||||||
\`\`\`bash
|
|
||||||
# CLI (required)
|
|
||||||
pnpm add -g @united-workforce/cli # or: npm install -g @united-workforce/cli
|
|
||||||
|
|
||||||
# Adapter — install the one matching the detected agent:
|
|
||||||
pnpm add -g @united-workforce/agent-hermes # or: npm i -g @united-workforce/agent-hermes
|
|
||||||
pnpm add -g @united-workforce/agent-claude-code # or: npm i -g @united-workforce/agent-claude-code
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
**⚠ Adapter versions are independent from CLI versions.** Do NOT try to match adapter version to CLI version. Just install \`@latest\` (the default).
|
|
||||||
|
|
||||||
**After installing, verify that \`uwf\` and the adapter are available in PATH:**
|
|
||||||
|
|
||||||
\`\`\`bash
|
|
||||||
uwf --version # should print ${CLI_VERSION}
|
|
||||||
uwf-hermes --version # or: uwf-claude-code --version
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
If either command is not found, the global bin directory is not in the current shell's PATH. **You must fix this before continuing:**
|
|
||||||
|
|
||||||
1. Find where the binary was installed:
|
|
||||||
\`\`\`bash
|
|
||||||
find ~/.local ~/.hermes /usr/local -name uwf -type f 2>/dev/null
|
|
||||||
npm prefix -g # global prefix — bin is <prefix>/bin
|
|
||||||
\`\`\`
|
|
||||||
2. Add the directory to PATH permanently by appending to the user's shell config (e.g. \`~/.bashrc\`, \`~/.zshrc\`, \`~/.profile\`, or fish config):
|
|
||||||
\`\`\`bash
|
|
||||||
export PATH="<global-bin-dir>:$PATH"
|
|
||||||
\`\`\`
|
|
||||||
3. Source the updated config or open a new shell, then re-verify the commands work.
|
|
||||||
|
|
||||||
**uwf-hermes** also requires the Hermes ACP plugin. Verify with \`hermes acp --help\`. If not available, install it:
|
|
||||||
\`\`\`bash
|
|
||||||
# Option A: install into hermes venv (recommended)
|
|
||||||
source ~/.hermes/hermes-agent/.venv/bin/activate && pip install hermes-agent[acp]
|
|
||||||
|
|
||||||
# Option B: pipx
|
|
||||||
pipx install 'hermes-agent[acp]'
|
|
||||||
|
|
||||||
# Option C: if installed from source
|
|
||||||
pip install -e '.[acp]'
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
### 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> --api-key <key> --model <model> --agent <adapter-command>
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
**Note:** \`--agent\` takes the adapter **command name** (e.g. \`uwf-hermes\`), not the npm package name.
|
|
||||||
|
|
||||||
**Preset providers** — when using a preset name, \`--base-url\` is auto-filled and can be omitted:
|
|
||||||
|
|
||||||
| Provider | Name | Default base URL |
|
|
||||||
|----------|------|-----------------|
|
|
||||||
| OpenAI | \`openai\` | https://api.openai.com/v1 |
|
|
||||||
| xAI | \`xai\` | https://api.x.ai/v1 |
|
|
||||||
| OpenRouter | \`openrouter\` | https://openrouter.ai/api/v1 |
|
|
||||||
| Venice | \`venice\` | https://api.venice.ai/api/v1 |
|
|
||||||
| Dashscope | \`dashscope\` | https://dashscope.aliyuncs.com/compatible-mode/v1 |
|
|
||||||
| DeepSeek | \`deepseek\` | https://api.deepseek.com/v1 |
|
|
||||||
| SiliconFlow | \`siliconflow\` | https://api.siliconflow.cn/v1 |
|
|
||||||
| VolcEngine | \`volcengine\` | https://ark.cn-beijing.volces.com/api/v3 |
|
|
||||||
| Kimi (Moonshot) | \`kimi\` | https://api.moonshot.cn/v1 |
|
|
||||||
| GLM (Zhipu AI) | \`glm\` | https://open.bigmodel.cn/api/paas/v4 |
|
|
||||||
| StepFun | \`stepfun\` | https://api.stepfun.com/v1 |
|
|
||||||
| MiniMax | \`minimax\` | https://api.minimax.io/v1 |
|
|
||||||
| Ollama (local) | \`ollama\` | http://localhost:11434/v1 |
|
|
||||||
|
|
||||||
For **non-preset providers**, you must specify \`--base-url\` manually.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
**⚠ After saving all skills, start a new session** so the agent loads the updated skill content. Skills saved in the current session are not active until the next session.
|
|
||||||
|
|
||||||
### 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: { const: 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
|
|
||||||
# Using pnpm
|
|
||||||
pnpm add -g @united-workforce/cli@latest
|
|
||||||
|
|
||||||
# Using npm
|
|
||||||
npm install -g @united-workforce/cli@latest
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
\`\`\`bash
|
|
||||||
uwf --version # should print ${CLI_VERSION}
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
Also update your adapter(s):
|
|
||||||
|
|
||||||
\`\`\`bash
|
|
||||||
# pnpm
|
|
||||||
pnpm add -g @united-workforce/agent-hermes@latest
|
|
||||||
|
|
||||||
# npm
|
|
||||||
npm install -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"
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
**⚠ After updating skills, start a new session** to load the new skill content.
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
- **v0.2.1**: \`$status: { enum: [value] }\` → \`$status: { const: "value" }\`. The validator no longer accepts \`enum\` for \`$status\`. Update all workflow YAML files:
|
|
||||||
\`\`\`yaml
|
|
||||||
# Before (v0.2.0)
|
|
||||||
$status: { enum: [done] }
|
|
||||||
$status: { type: string, enum: ["ready", "failed"] }
|
|
||||||
|
|
||||||
# After (v0.2.1+)
|
|
||||||
$status: { const: "done" }
|
|
||||||
# For multi-exit, use oneOf with const (unchanged)
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
### Step 4 — Verify
|
|
||||||
|
|
||||||
\`\`\`bash
|
|
||||||
uwf thread start <your-workflow> -p "upgrade test"
|
|
||||||
uwf thread exec <thread-id>
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## Available prompts
|
## Available prompts
|
||||||
|
|
||||||
@@ -324,7 +57,6 @@ uwf prompt list # list available prompt names
|
|||||||
uwf prompt usage # CLI usage guide
|
uwf prompt usage # CLI usage guide
|
||||||
uwf prompt workflow-authoring # workflow YAML design guide
|
uwf prompt workflow-authoring # workflow YAML design guide
|
||||||
uwf prompt adapter-developing # building agent adapters
|
uwf prompt adapter-developing # building agent adapters
|
||||||
uwf prompt bootstrap # this guide
|
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
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";
|
||||||
@@ -73,12 +72,6 @@ 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;
|
||||||
@@ -182,6 +175,7 @@ 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"],
|
||||||
@@ -397,37 +391,6 @@ 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.
|
||||||
*/
|
*/
|
||||||
@@ -442,26 +405,15 @@ 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)
|
|
||||||
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) {
|
|
||||||
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,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1004,12 +1004,6 @@ function spawnAgent(
|
|||||||
});
|
});
|
||||||
} 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
|
||||||
? ""
|
? ""
|
||||||
|
|||||||
@@ -24,22 +24,22 @@ function isOneOfSchema(fm: unknown): fm is SchemaObj & { oneOf: SchemaObj[] } {
|
|||||||
return Array.isArray(obj.oneOf);
|
return Array.isArray(obj.oneOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if a frontmatter schema declares "$status" as const (flat schema form). */
|
/** Check if a frontmatter schema declares "$status" as an enum (the required form for user roles). */
|
||||||
function hasStatusConst(fm: unknown): boolean {
|
function hasStatusEnum(fm: unknown): boolean {
|
||||||
if (typeof fm !== "object" || fm === null) return false;
|
if (typeof fm !== "object" || fm === null) return false;
|
||||||
const obj = fm as SchemaObj;
|
const obj = fm as SchemaObj;
|
||||||
const props = obj.properties as Record<string, SchemaObj> | undefined;
|
const props = obj.properties as Record<string, SchemaObj> | undefined;
|
||||||
if (!props?.$status) return false;
|
if (!props?.$status) return false;
|
||||||
return typeof props.$status.const === "string";
|
return Array.isArray(props.$status.enum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Extract status values from a const-based $status field. */
|
/** Extract status values from an enum-based $status field. */
|
||||||
function getConstStatuses(fm: SchemaObj): string[] {
|
function getEnumStatuses(fm: SchemaObj): string[] {
|
||||||
const props = fm.properties as Record<string, SchemaObj> | undefined;
|
const props = fm.properties as Record<string, SchemaObj> | undefined;
|
||||||
if (!props?.$status) return [];
|
if (!props?.$status) return [];
|
||||||
const statusDef = props.$status;
|
const statusDef = props.$status;
|
||||||
if (typeof statusDef.const === "string") return [statusDef.const];
|
if (!Array.isArray(statusDef.enum)) return [];
|
||||||
return [];
|
return statusDef.enum as string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get property names from a schema object. */
|
/** Get property names from a schema object. */
|
||||||
@@ -248,21 +248,21 @@ function checkRoleConsistency(payload: WorkflowPayload, errors: string[]): void
|
|||||||
checkOneOfDiscriminant(roleName, variants, statuses, errors);
|
checkOneOfDiscriminant(roleName, variants, statuses, errors);
|
||||||
checkStatusEdges(roleName, graphKeys, new Set(statuses), errors);
|
checkStatusEdges(roleName, graphKeys, new Set(statuses), errors);
|
||||||
checkMultiExitMustache(roleName, graphEntry, variants, errors);
|
checkMultiExitMustache(roleName, graphEntry, variants, errors);
|
||||||
} else if (hasStatusConst(fm)) {
|
} else if (hasStatusEnum(fm)) {
|
||||||
const statuses = getConstStatuses(fm as SchemaObj);
|
const statuses = getEnumStatuses(fm as SchemaObj);
|
||||||
checkStatusEdges(roleName, graphKeys, new Set(statuses), errors);
|
checkStatusEdges(roleName, graphKeys, new Set(statuses), errors);
|
||||||
// For const-based flat schemas, mustache vars come from the flat properties
|
// For enum-based schemas, mustache vars come from the flat properties
|
||||||
checkFlatMustache(roleName, graphEntry, fm as SchemaObj, errors);
|
checkEnumMustache(roleName, graphEntry, fm as SchemaObj, errors);
|
||||||
} else {
|
} else {
|
||||||
errors.push(
|
errors.push(
|
||||||
`role "${roleName}" must define "$status" as const (or oneOf with const) in frontmatter`,
|
`role "${roleName}" must define "$status" as an enum (or oneOf const) in frontmatter`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check mustache vars in all edge prompts against flat schema properties. */
|
/** Check mustache vars in all edge prompts against flat schema properties. */
|
||||||
function checkFlatMustache(
|
function checkEnumMustache(
|
||||||
roleName: string,
|
roleName: string,
|
||||||
graphEntry: Record<string, { role: string; prompt: string }>,
|
graphEntry: Record<string, { role: string; prompt: string }>,
|
||||||
fm: SchemaObj,
|
fm: SchemaObj,
|
||||||
|
|||||||
@@ -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}". Either rename the file to "${payload.name}.yaml" or change the YAML \`name\` field to "${expected}"`;
|
return `workflow name mismatch: file "${basename(filePath)}" implies name "${expected}" but YAML declares name "${payload.name}"`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ describe("buildOutputFormatInstruction", () => {
|
|||||||
{
|
{
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
$status: { const: "approved" },
|
$status: { type: "string", enum: ["approved"] },
|
||||||
branch: { type: "string" },
|
branch: { type: "string" },
|
||||||
},
|
},
|
||||||
required: ["$status"],
|
required: ["$status"],
|
||||||
@@ -151,7 +151,7 @@ describe("buildOutputFormatInstruction", () => {
|
|||||||
{
|
{
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
$status: { const: "rejected" },
|
$status: { type: "string", enum: ["rejected"] },
|
||||||
comments: { type: "string" },
|
comments: { type: "string" },
|
||||||
},
|
},
|
||||||
required: ["$status"],
|
required: ["$status"],
|
||||||
@@ -225,34 +225,4 @@ describe("buildOutputFormatInstruction", () => {
|
|||||||
const result = buildOutputFormatInstruction({});
|
const result = buildOutputFormatInstruction({});
|
||||||
expect(result).toContain("Focus exclusively on YOUR role");
|
expect(result).toContain("Focus exclusively on YOUR role");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("renders const value as literal in flat schema example", () => {
|
|
||||||
const schema = {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
$status: { type: "string", const: "greeted" },
|
|
||||||
message: { type: "string" },
|
|
||||||
},
|
|
||||||
required: ["$status", "message"],
|
|
||||||
};
|
|
||||||
const result = buildOutputFormatInstruction(schema);
|
|
||||||
expect(result).toContain("$status: greeted");
|
|
||||||
expect(result).toContain("fixed value");
|
|
||||||
expect(result).not.toContain("$status: <string>");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("renders const value for non-string types", () => {
|
|
||||||
const schema = {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
count: { type: "number", const: 42 },
|
|
||||||
done: { type: "boolean", const: true },
|
|
||||||
},
|
|
||||||
required: ["count", "done"],
|
|
||||||
};
|
|
||||||
const result = buildOutputFormatInstruction(schema);
|
|
||||||
expect(result).toContain("count: 42");
|
|
||||||
expect(result).toContain("done: true");
|
|
||||||
expect(result).toContain("fixed value");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
import type { StepContext } from "@united-workforce/protocol";
|
|
||||||
import { describe, expect, test } from "vitest";
|
|
||||||
import { buildThreadProgress } from "../src/build-thread-progress.js";
|
|
||||||
|
|
||||||
function makeStep(role: string): StepContext {
|
|
||||||
return {
|
|
||||||
role,
|
|
||||||
output: {},
|
|
||||||
detail: "0000000000000" as string,
|
|
||||||
agent: "uwf-mock",
|
|
||||||
edgePrompt: "",
|
|
||||||
startedAtMs: 0,
|
|
||||||
completedAtMs: 0,
|
|
||||||
cwd: "",
|
|
||||||
assembledPrompt: null,
|
|
||||||
usage: null,
|
|
||||||
content: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("buildThreadProgress", () => {
|
|
||||||
test("first step of thread", () => {
|
|
||||||
const result = buildThreadProgress([], "proponent");
|
|
||||||
expect(result).toContain("## Thread Progress");
|
|
||||||
expect(result).toContain("first step");
|
|
||||||
expect(result).toContain("first time");
|
|
||||||
expect(result).toContain("proponent");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("second step, role not seen before", () => {
|
|
||||||
const steps = [makeStep("opponent")];
|
|
||||||
const result = buildThreadProgress(steps, "proponent");
|
|
||||||
expect(result).toContain("Thread step 2");
|
|
||||||
expect(result).toContain("spoken 0 times");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("role has spoken once before", () => {
|
|
||||||
const steps = [makeStep("proponent"), makeStep("opponent")];
|
|
||||||
const result = buildThreadProgress(steps, "proponent");
|
|
||||||
expect(result).toContain("Thread step 3");
|
|
||||||
expect(result).toContain("spoken 1 time before");
|
|
||||||
// singular "time" not "times"
|
|
||||||
expect(result).not.toContain("1 times");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("role has spoken multiple times", () => {
|
|
||||||
const steps = [
|
|
||||||
makeStep("proponent"),
|
|
||||||
makeStep("opponent"),
|
|
||||||
makeStep("proponent"),
|
|
||||||
makeStep("opponent"),
|
|
||||||
makeStep("proponent"),
|
|
||||||
makeStep("opponent"),
|
|
||||||
];
|
|
||||||
const result = buildThreadProgress(steps, "proponent");
|
|
||||||
expect(result).toContain("Thread step 7");
|
|
||||||
expect(result).toContain("spoken 3 times");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/util-agent",
|
"name": "@united-workforce/util-agent",
|
||||||
"version": "0.1.1",
|
"version": "0.1.0",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -74,10 +74,6 @@ function collectObjectSchemas(schema: JSONSchema): JSONSchema[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resolvePropertySchema(prop: JSONSchema): JSONSchema {
|
function resolvePropertySchema(prop: JSONSchema): JSONSchema {
|
||||||
if (prop.const !== undefined) {
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(prop.enum) && prop.enum.length > 0) {
|
if (Array.isArray(prop.enum) && prop.enum.length > 0) {
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
@@ -117,11 +113,6 @@ function buildPropertyExampleLine(prop: SchemaProperty): string {
|
|||||||
commentParts.push("required");
|
commentParts.push("required");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolved.const !== undefined) {
|
|
||||||
commentParts.push("fixed value");
|
|
||||||
return `${prop.name}: ${formatYamlScalar(resolved.const)}${buildPropertyComment(commentParts)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(resolved.enum) && resolved.enum.length > 0) {
|
if (Array.isArray(resolved.enum) && resolved.enum.length > 0) {
|
||||||
const enumValues = resolved.enum.map((v) => String(v));
|
const enumValues = resolved.enum.map((v) => String(v));
|
||||||
commentParts.push(...enumValues);
|
commentParts.push(...enumValues);
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import type { StepContext } from "@united-workforce/protocol";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a compact thread-progress summary so the agent knows where it is
|
|
||||||
* in the conversation without making tool calls to count steps.
|
|
||||||
*
|
|
||||||
* Example output:
|
|
||||||
* ## Thread Progress
|
|
||||||
* Thread step 6. You (proponent) have spoken 2 times before this turn.
|
|
||||||
*/
|
|
||||||
export function buildThreadProgress(steps: StepContext[], role: string): string {
|
|
||||||
const totalSteps = steps.length;
|
|
||||||
const roleVisits = steps.filter((s) => s.role === role).length;
|
|
||||||
|
|
||||||
const parts = [`## Thread Progress`];
|
|
||||||
if (totalSteps === 0) {
|
|
||||||
parts.push(
|
|
||||||
`This is the first step of the thread. You (${role}) are speaking for the first time.`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
parts.push(
|
|
||||||
`Thread step ${totalSteps + 1}. You (${role}) have spoken ${roleVisits} time${roleVisits === 1 ? "" : "s"} before this turn.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parts.join("\n");
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
export { buildContinuationPrompt } from "./build-continuation-prompt.js";
|
export { buildContinuationPrompt } from "./build-continuation-prompt.js";
|
||||||
export { buildOutputFormatInstruction } from "./build-output-format-instruction.js";
|
export { buildOutputFormatInstruction } from "./build-output-format-instruction.js";
|
||||||
export { buildRolePrompt } from "./build-role-prompt.js";
|
export { buildRolePrompt } from "./build-role-prompt.js";
|
||||||
export { buildThreadProgress } from "./build-thread-progress.js";
|
|
||||||
export type { BuildContextMeta } from "./context.js";
|
export type { BuildContextMeta } from "./context.js";
|
||||||
export { buildContext, buildContextWithMeta } from "./context.js";
|
export { buildContext, buildContextWithMeta } from "./context.js";
|
||||||
export type { ExtractResult, ResolvedLlmProvider } from "./extract.js";
|
export type { ExtractResult, ResolvedLlmProvider } from "./extract.js";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@united-workforce/util",
|
"name": "@united-workforce/util",
|
||||||
"version": "0.1.4",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@@ -15,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,
|
||||||
@@ -35,3 +35,4 @@ 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";
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
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:
|
||||||
|
new: { role: planner, prompt: "Analyze the issue." }
|
||||||
|
resume: { role: planner, prompt: "Review the previous run output and continue." }
|
||||||
|
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 keys \`new\` (first start) and \`resume\` (resuming a completed thread)
|
||||||
|
- \`$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
|
||||||
|
`;
|
||||||
|
}
|
||||||
@@ -140,18 +140,5 @@ For specific scenarios, run the corresponding \`uwf prompt\` command:
|
|||||||
|----------|---------|-------------|
|
|----------|---------|-------------|
|
||||||
| Writing workflow YAML | \`uwf prompt workflow-authoring\` | Designing roles, conditions, graphs, and edge prompts |
|
| Writing workflow YAML | \`uwf prompt workflow-authoring\` | Designing roles, conditions, graphs, and edge prompts |
|
||||||
| Building a new agent adapter | \`uwf prompt adapter-developing\` | Creating a new \`uwf-<name>\` CLI adapter |
|
| Building a new agent adapter | \`uwf prompt adapter-developing\` | Creating a new \`uwf-<name>\` CLI adapter |
|
||||||
|
|
||||||
## Upgrading
|
|
||||||
|
|
||||||
\`\`\`bash
|
|
||||||
# Install the latest version
|
|
||||||
pnpm add -g @united-workforce/cli@latest @united-workforce/agent-hermes@latest
|
|
||||||
# or: npm install -g @united-workforce/cli@latest @united-workforce/agent-hermes@latest
|
|
||||||
|
|
||||||
# Verify
|
|
||||||
uwf --version
|
|
||||||
|
|
||||||
# Then run uwf prompt bootstrap and follow the upgrade instructions
|
|
||||||
\`\`\`
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ roles: # named actors
|
|||||||
2. Do that
|
2. Do that
|
||||||
output: "..." # what the agent should produce
|
output: "..." # what the agent should produce
|
||||||
frontmatter: # JSON Schema for structured output
|
frontmatter: # JSON Schema for structured output
|
||||||
type: object
|
|
||||||
oneOf:
|
oneOf:
|
||||||
- properties:
|
- properties:
|
||||||
$status: { const: "ready" }
|
$status: { const: "ready" }
|
||||||
@@ -72,13 +71,10 @@ The \`frontmatter\` field is a standard JSON Schema. It defines the structured f
|
|||||||
|
|
||||||
### \`$status\` Field
|
### \`$status\` Field
|
||||||
|
|
||||||
\`$status\` is the only standard field. Its value determines which graph edge the moderator follows.
|
\`$status\` is the only standard field. Its value determines which graph edge the moderator follows. Use \`const\` to constrain each variant:
|
||||||
|
|
||||||
**Multi-exit (oneOf)** — use \`const\` to constrain each variant:
|
|
||||||
|
|
||||||
\`\`\`yaml
|
\`\`\`yaml
|
||||||
frontmatter:
|
frontmatter:
|
||||||
type: object
|
|
||||||
oneOf:
|
oneOf:
|
||||||
- properties:
|
- properties:
|
||||||
$status: { const: "done" }
|
$status: { const: "done" }
|
||||||
@@ -90,26 +86,22 @@ frontmatter:
|
|||||||
required: [$status, error]
|
required: [$status, error]
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
**Single-exit (flat schema)** — same syntax, just no \`oneOf\` wrapper:
|
### Custom Fields
|
||||||
|
|
||||||
|
Add any fields you need for data passing between roles. These are available in edge prompts via Mustache templates.
|
||||||
|
|
||||||
|
### Flat Schema (Single Status)
|
||||||
|
|
||||||
|
When a role has only one outcome:
|
||||||
|
|
||||||
\`\`\`yaml
|
\`\`\`yaml
|
||||||
frontmatter:
|
frontmatter:
|
||||||
type: object
|
|
||||||
properties:
|
properties:
|
||||||
$status: { const: "done" }
|
$status: { const: "done" }
|
||||||
summary: { type: string }
|
summary: { type: string }
|
||||||
required: [$status, summary]
|
required: [$status, summary]
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
**Important rules:**
|
|
||||||
- \`type: object\` is **required** at the top level of frontmatter (both flat and oneOf)
|
|
||||||
- \`$status\` always uses \`const: "value"\` — simple and consistent
|
|
||||||
- \`enum\` is **not supported** for \`$status\` — the validator will reject it
|
|
||||||
|
|
||||||
### Custom Fields
|
|
||||||
|
|
||||||
Add any fields you need for data passing between roles. These are available in edge prompts via Mustache templates.
|
|
||||||
|
|
||||||
## 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:
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
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:
|
||||||
|
new: { role: planner, prompt: "Analyze the issue." }
|
||||||
|
resume: { role: planner, prompt: "Review the previous run output and continue." }
|
||||||
|
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 | Target: \`{ role, prompt }\` |
|
||||||
|
|
||||||
|
### Special Nodes
|
||||||
|
- \`$START\` — entry point; uses status keys \`new\` (first start) and \`resume\` (resuming a completed thread)
|
||||||
|
- \`$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}}}."\`
|
||||||
|
`;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user