@agimon-ai/po-workflow 0.0.0-alpha.21 → 0.0.0-alpha.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +110 -149
  2. package/README.md +155 -53
  3. package/dist/apiContracts.cjs +205 -36
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +205 -36
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/contract-BpzJeyjh.mjs +33 -0
  10. package/dist/contract-BpzJeyjh.mjs.map +1 -0
  11. package/dist/contract-D80yV2d-.cjs +68 -0
  12. package/dist/contract-D80yV2d-.cjs.map +1 -0
  13. package/dist/extensions/native.mjs +4643 -1020
  14. package/dist/extensions/native.mjs.map +1 -1
  15. package/dist/extensions/server.cjs +21507 -3593
  16. package/dist/extensions/server.cjs.map +1 -1
  17. package/dist/extensions/server.d.mts.map +1 -1
  18. package/dist/extensions/server.mjs +21495 -3558
  19. package/dist/extensions/server.mjs.map +1 -1
  20. package/dist/extensions/web.mjs +5224 -2610
  21. package/dist/extensions/web.mjs.map +1 -1
  22. package/dist/index-CxS__mkJ.d.mts +5210 -0
  23. package/dist/index-CxS__mkJ.d.mts.map +1 -0
  24. package/dist/index.cjs +41 -3
  25. package/dist/index.cjs.map +1 -0
  26. package/dist/index.d.mts +104 -4
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.mjs +38 -1
  29. package/dist/index.mjs.map +1 -0
  30. package/dist/po-runtime-identity.json +1 -0
  31. package/dist/workflowHost-B8ludUOG.cjs +4190 -0
  32. package/dist/workflowHost-B8ludUOG.cjs.map +1 -0
  33. package/dist/workflowHost-DB4GtWpM.mjs +3974 -0
  34. package/dist/workflowHost-DB4GtWpM.mjs.map +1 -0
  35. package/dist/workflowHost.cjs +7 -0
  36. package/dist/workflowHost.d.mts +29 -0
  37. package/dist/workflowHost.d.mts.map +1 -0
  38. package/dist/workflowHost.mjs +3 -0
  39. package/dist/workflowServices-CSHleLJo.mjs +273 -0
  40. package/dist/workflowServices-CSHleLJo.mjs.map +1 -0
  41. package/dist/workflowServices-DYXhIDVE.cjs +350 -0
  42. package/dist/workflowServices-DYXhIDVE.cjs.map +1 -0
  43. package/llms.txt +10 -8
  44. package/locales/vi.json +492 -0
  45. package/locales/zh-CN.json +492 -0
  46. package/package.json +150 -26
  47. package/src/prompts/codemode-how-to-workflow/SKILL.md +226 -0
  48. package/src/prompts/help-how-to-workflow/SKILL.md +185 -0
  49. package/src/prompts/help-how-to-workflow-settings/SKILL.md +33 -0
  50. package/src/types/webWorkflowTerminal.ts +21 -0
  51. package/src/types/webWorkflows.ts +52 -2
  52. package/dist/workflowLaunchCommand-C69Nn3k5.cjs +0 -139
  53. package/dist/workflowLaunchCommand-C69Nn3k5.cjs.map +0 -1
  54. package/dist/workflowLaunchCommand-GGqimmTC.mjs +0 -122
  55. package/dist/workflowLaunchCommand-GGqimmTC.mjs.map +0 -1
  56. package/skills/workflow-recovery/SKILL.md +0 -85
  57. package/src/prompts/po-author-workflow/SKILL.md +0 -64
  58. package/src/prompts/po-use-workflow/SKILL.md +0 -21
@@ -1,122 +0,0 @@
1
- //#region src/services/workflowLaunchCommand/index.ts
2
- /**
3
- * The `/workflow-launch` line, parsed.
4
- *
5
- * WHY A VERB AT ALL:
6
- * A browser can only send a session a prompt frame, so every cockpit action
7
- * that has to run inside the session travels as a slash line, the way the
8
- * agent catalog sends `/run`. The workflow tools answer to the agent, not to a
9
- * page, and the leader board answers to a keyboard, so neither of them can be
10
- * what the launch dialog sends.
11
- *
12
- * THE SHAPE:
13
- * /workflow-launch <workflow> [key=value ...] [prompt words]
14
- *
15
- * Key-value pairs come first and stop at the first token that is not one, so
16
- * everything after them is the prompt exactly as it was typed, including any
17
- * `=` inside it. `runner`, `command` and `choice` are reserved keys; the rest
18
- * are the workflow's own `workflow_dispatch` inputs. Values may be double
19
- * quoted to hold spaces.
20
- */
21
- /** Reserved key: which runner map entry the run executes with. */
22
- const RUNNER_KEY = "runner";
23
- /** Reserved key: which command templated steps run through. */
24
- const COMMAND_KEY = "command";
25
- /** Reserved key: which model choice steps without their own run with. */
26
- const CHOICE_KEY = "choice";
27
- const KEY_VALUE = /^([A-Za-z_][\w.-]*)=(.*)$/s;
28
- /** Strips one layer of surrounding double quotes, which is how a value holds spaces. */
29
- function unquote(value) {
30
- return value.length > 1 && value.startsWith("\"") && value.endsWith("\"") ? value.slice(1, -1) : value;
31
- }
32
- /**
33
- * Splits on whitespace, keeping double-quoted runs together.
34
- *
35
- * Returns each token with the offset it started at, so the caller can take the
36
- * rest of the line verbatim rather than rebuilding it from tokens and losing
37
- * the spacing a prompt was written with.
38
- */
39
- function tokenize(line) {
40
- const tokens = [];
41
- let index = 0;
42
- while (index < line.length) {
43
- while (index < line.length && /\s/.test(line[index])) index += 1;
44
- if (index >= line.length) break;
45
- const start = index;
46
- let quoted = false;
47
- while (index < line.length && (quoted || !/\s/.test(line[index]))) {
48
- if (line[index] === "\"") quoted = !quoted;
49
- index += 1;
50
- }
51
- tokens.push({
52
- text: line.slice(start, index),
53
- start
54
- });
55
- }
56
- return tokens;
57
- }
58
- function parseWorkflowLaunchCommand(args) {
59
- const tokens = tokenize(args.trim());
60
- const first = tokens[0];
61
- if (first === void 0) return { error: "Usage: /workflow-launch <workflow> [key=value …] [prompt]" };
62
- const inputs = {};
63
- const reserved = {};
64
- let index = 1;
65
- for (; index < tokens.length; index += 1) {
66
- const token = tokens[index];
67
- const match = KEY_VALUE.exec(token.text);
68
- if (!match) break;
69
- const key = match[1];
70
- const value = unquote(match[2]);
71
- if (key === RUNNER_KEY || key === COMMAND_KEY || key === CHOICE_KEY) reserved[key] = value;
72
- else inputs[key] = value;
73
- }
74
- const rest = tokens[index];
75
- const prompt = rest === void 0 ? void 0 : args.trim().slice(rest.start).trim();
76
- return {
77
- workflow: unquote(first.text),
78
- ...reserved,
79
- inputs,
80
- ...prompt === void 0 || prompt === "" ? {} : { prompt }
81
- };
82
- }
83
- /**
84
- * The workflow a token names: its name, its path in the repository, or the
85
- * tail of that path. Case-insensitive on the name, because the catalog shows
86
- * names as their author capitalised them and nobody types that back exactly.
87
- */
88
- function resolveWorkflowEntry(entries, token) {
89
- const needle = token.trim();
90
- const lower = needle.toLocaleLowerCase();
91
- return entries.find((entry) => entry.name.toLocaleLowerCase() === lower) ?? entries.find((entry) => entry.relativePath === needle || entry.path === needle) ?? entries.find((entry) => entry.relativePath.endsWith(`/${needle}`) || entry.path.endsWith(`/${needle}`));
92
- }
93
- /** The trigger that makes a prompt mandatory: the run waits for one otherwise. */
94
- const USER_PROMPT_TRIGGER = "user_prompt";
95
- /**
96
- * Everything wrong with a launch, before it is started.
97
- *
98
- * Checked here rather than left to the engine because the failure would
99
- * otherwise be a run that starts and then waits forever for terminal input, or
100
- * one that dies on a runner its steps never declared. Both read as the launch
101
- * having worked.
102
- */
103
- function validateWorkflowLaunch(requirements, parsed) {
104
- const problems = [];
105
- if (requirements.triggers.includes(USER_PROMPT_TRIGGER) && (parsed.prompt ?? "") === "") problems.push("This workflow is triggered by a prompt, so it needs one.");
106
- const missing = requirements.inputs.filter((input) => input.required === true && (parsed.inputs[input.name] ?? "") === "").map((input) => input.name);
107
- if (missing.length > 0) problems.push(`Missing required input${missing.length > 1 ? "s" : ""}: ${missing.join(", ")}.`);
108
- for (const input of requirements.inputs) {
109
- const value = parsed.inputs[input.name];
110
- if (value === void 0 || input.options === void 0 || input.options.includes(value)) continue;
111
- problems.push(`Input ${input.name} must be one of: ${input.options.join(", ")}.`);
112
- }
113
- const declared = requirements.runners;
114
- if (parsed.runner !== void 0 && declared !== void 0 && !declared.includes(parsed.runner)) problems.push(declared.length === 0 ? "This workflow declares no runner its steps agree on." : `Runner ${parsed.runner} is not one this workflow declares: ${declared.join(", ")}.`);
115
- if (parsed.command !== void 0 && !(requirements.commands ?? []).includes(parsed.command)) problems.push(requirements.commands === void 0 || requirements.commands.length === 0 ? "This workflow has no templated steps to run through a command." : `Command ${parsed.command} is not one every step offers: ${requirements.commands.join(", ")}.`);
116
- if (parsed.choice !== void 0 && !(requirements.choices ?? []).includes(parsed.choice)) problems.push(`Choice ${parsed.choice} is not declared${requirements.choices?.length ? `: ${requirements.choices.join(", ")}` : ""}.`);
117
- return problems;
118
- }
119
- //#endregion
120
- export { resolveWorkflowEntry as n, validateWorkflowLaunch as r, parseWorkflowLaunchCommand as t };
121
-
122
- //# sourceMappingURL=workflowLaunchCommand-GGqimmTC.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflowLaunchCommand-GGqimmTC.mjs","names":[],"sources":["../src/services/workflowLaunchCommand/index.ts"],"sourcesContent":["/**\n * The `/workflow-launch` line, parsed.\n *\n * WHY A VERB AT ALL:\n * A browser can only send a session a prompt frame, so every cockpit action\n * that has to run inside the session travels as a slash line, the way the\n * agent catalog sends `/run`. The workflow tools answer to the agent, not to a\n * page, and the leader board answers to a keyboard, so neither of them can be\n * what the launch dialog sends.\n *\n * THE SHAPE:\n * /workflow-launch <workflow> [key=value ...] [prompt words]\n *\n * Key-value pairs come first and stop at the first token that is not one, so\n * everything after them is the prompt exactly as it was typed, including any\n * `=` inside it. `runner`, `command` and `choice` are reserved keys; the rest\n * are the workflow's own `workflow_dispatch` inputs. Values may be double\n * quoted to hold spaces.\n */\n\n/** Reserved key: which runner map entry the run executes with. */\nconst RUNNER_KEY = 'runner';\n/** Reserved key: which command templated steps run through. */\nconst COMMAND_KEY = 'command';\n/** Reserved key: which model choice steps without their own run with. */\nconst CHOICE_KEY = 'choice';\nconst KEY_VALUE = /^([A-Za-z_][\\w.-]*)=(.*)$/s;\n\nexport interface ParsedWorkflowLaunch {\n /** The workflow's name or its path, as typed; resolution belongs to the caller. */\n workflow: string;\n runner?: string;\n command?: string;\n choice?: string;\n inputs: Record<string, string>;\n prompt?: string;\n}\n\nexport interface WorkflowLaunchParseFailure {\n error: string;\n}\n\nexport function isLaunchParseFailure(\n value: ParsedWorkflowLaunch | WorkflowLaunchParseFailure,\n): value is WorkflowLaunchParseFailure {\n return 'error' in value;\n}\n\n/** Strips one layer of surrounding double quotes, which is how a value holds spaces. */\nfunction unquote(value: string): string {\n return value.length > 1 && value.startsWith('\"') && value.endsWith('\"') ? value.slice(1, -1) : value;\n}\n\n/**\n * Splits on whitespace, keeping double-quoted runs together.\n *\n * Returns each token with the offset it started at, so the caller can take the\n * rest of the line verbatim rather than rebuilding it from tokens and losing\n * the spacing a prompt was written with.\n */\nfunction tokenize(line: string): { text: string; start: number }[] {\n const tokens: { text: string; start: number }[] = [];\n let index = 0;\n while (index < line.length) {\n while (index < line.length && /\\s/.test(line[index] as string)) index += 1;\n if (index >= line.length) break;\n const start = index;\n let quoted = false;\n while (index < line.length && (quoted || !/\\s/.test(line[index] as string))) {\n if (line[index] === '\"') quoted = !quoted;\n index += 1;\n }\n tokens.push({ text: line.slice(start, index), start });\n }\n return tokens;\n}\n\nexport function parseWorkflowLaunchCommand(args: string): ParsedWorkflowLaunch | WorkflowLaunchParseFailure {\n const tokens = tokenize(args.trim());\n const first = tokens[0];\n if (first === undefined) return { error: 'Usage: /workflow-launch <workflow> [key=value …] [prompt]' };\n\n const inputs: Record<string, string> = {};\n const reserved: { runner?: string; command?: string; choice?: string } = {};\n let index = 1;\n for (; index < tokens.length; index += 1) {\n const token = tokens[index] as { text: string; start: number };\n const match = KEY_VALUE.exec(token.text);\n if (!match) break;\n const key = match[1] as string;\n const value = unquote(match[2] as string);\n if (key === RUNNER_KEY || key === COMMAND_KEY || key === CHOICE_KEY) reserved[key] = value;\n else inputs[key] = value;\n }\n\n const rest = tokens[index];\n const prompt = rest === undefined ? undefined : args.trim().slice(rest.start).trim();\n return {\n workflow: unquote(first.text),\n ...reserved,\n inputs,\n ...(prompt === undefined || prompt === '' ? {} : { prompt }),\n };\n}\n\n/** The line the cockpit sends, built from what its dialog collected. */\nexport function workflowLaunchCommand(request: ParsedWorkflowLaunch): string {\n const quote = (value: string): string => (/\\s/.test(value) ? `\"${value}\"` : value);\n const pairs = [\n ...(request.runner === undefined ? [] : [`${RUNNER_KEY}=${quote(request.runner)}`]),\n ...(request.command === undefined ? [] : [`${COMMAND_KEY}=${quote(request.command)}`]),\n ...(request.choice === undefined ? [] : [`${CHOICE_KEY}=${quote(request.choice)}`]),\n ...Object.entries(request.inputs).map(([key, value]) => `${key}=${quote(value)}`),\n ];\n const prompt = request.prompt?.trim();\n return ['/workflow-launch', quote(request.workflow), ...pairs, ...(prompt ? [prompt] : [])].join(' ');\n}\n\n/** One catalog row, as much of it as resolution needs. */\nexport interface LaunchResolvableWorkflow {\n name: string;\n path: string;\n relativePath: string;\n}\n\n/**\n * The workflow a token names: its name, its path in the repository, or the\n * tail of that path. Case-insensitive on the name, because the catalog shows\n * names as their author capitalised them and nobody types that back exactly.\n */\nexport function resolveWorkflowEntry<T extends LaunchResolvableWorkflow>(\n entries: readonly T[],\n token: string,\n): T | undefined {\n const needle = token.trim();\n const lower = needle.toLocaleLowerCase();\n return (\n entries.find((entry) => entry.name.toLocaleLowerCase() === lower) ??\n entries.find((entry) => entry.relativePath === needle || entry.path === needle) ??\n entries.find((entry) => entry.relativePath.endsWith(`/${needle}`) || entry.path.endsWith(`/${needle}`))\n );\n}\n\n/** What a workflow declares, as much of it as a launch has to satisfy. */\nexport interface LaunchRequirements {\n triggers: readonly string[];\n inputs: readonly { name: string; required?: boolean; options?: readonly string[] }[];\n /** Absent means the workflow names no runner map, so any runner will do. */\n runners?: readonly string[];\n /** Commands every templated step offers; absent when no step is templated. */\n commands?: readonly string[];\n /** Declared model choices. */\n choices?: readonly string[];\n}\n\n/** The trigger that makes a prompt mandatory: the run waits for one otherwise. */\nconst USER_PROMPT_TRIGGER = 'user_prompt';\n\n/**\n * Everything wrong with a launch, before it is started.\n *\n * Checked here rather than left to the engine because the failure would\n * otherwise be a run that starts and then waits forever for terminal input, or\n * one that dies on a runner its steps never declared. Both read as the launch\n * having worked.\n */\nexport function validateWorkflowLaunch(\n requirements: LaunchRequirements,\n parsed: Pick<ParsedWorkflowLaunch, 'inputs' | 'prompt' | 'runner' | 'command' | 'choice'>,\n): string[] {\n const problems: string[] = [];\n if (requirements.triggers.includes(USER_PROMPT_TRIGGER) && (parsed.prompt ?? '') === '') {\n problems.push('This workflow is triggered by a prompt, so it needs one.');\n }\n const missing = requirements.inputs\n .filter((input) => input.required === true && (parsed.inputs[input.name] ?? '') === '')\n .map((input) => input.name);\n if (missing.length > 0)\n problems.push(`Missing required input${missing.length > 1 ? 's' : ''}: ${missing.join(', ')}.`);\n for (const input of requirements.inputs) {\n const value = parsed.inputs[input.name];\n if (value === undefined || input.options === undefined || input.options.includes(value)) continue;\n problems.push(`Input ${input.name} must be one of: ${input.options.join(', ')}.`);\n }\n const declared = requirements.runners;\n if (parsed.runner !== undefined && declared !== undefined && !declared.includes(parsed.runner)) {\n problems.push(\n declared.length === 0\n ? 'This workflow declares no runner its steps agree on.'\n : `Runner ${parsed.runner} is not one this workflow declares: ${declared.join(', ')}.`,\n );\n }\n if (parsed.command !== undefined && !(requirements.commands ?? []).includes(parsed.command)) {\n problems.push(\n requirements.commands === undefined || requirements.commands.length === 0\n ? 'This workflow has no templated steps to run through a command.'\n : `Command ${parsed.command} is not one every step offers: ${requirements.commands.join(', ')}.`,\n );\n }\n if (parsed.choice !== undefined && !(requirements.choices ?? []).includes(parsed.choice)) {\n problems.push(\n `Choice ${parsed.choice} is not declared${requirements.choices?.length ? `: ${requirements.choices.join(', ')}` : ''}.`,\n );\n }\n return problems;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,aAAa;;AAEnB,MAAM,cAAc;;AAEpB,MAAM,aAAa;AACnB,MAAM,YAAY;;AAuBlB,SAAS,QAAQ,OAAuB;CACtC,OAAO,MAAM,SAAS,KAAK,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG,IAAI,MAAM,MAAM,GAAG,EAAE,I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AS,KAAK,IAAI,EAAE,EACxF;CAEF,IAAI,OAAO,YAAY,KAAA,KAAa,EAAE,aAAa,YAAY,CAAC,EAAA,CAAG,SAAS,OAAO,OAAO,GACxF,SAAS,KACP,aAAa,aAAa,KAAA,KAAa,aAAa,SAAS,WAAW,IACpE,mEACA,WAAW,OAAO,QAAQ,iCAAiC,aAAa,SAAS,KAAK,IAAI,EAAE,EAClG;CAEF,IAAI,OAAO,WAAW,KAAA,KAAa,EAAE,aAAa,WAAW,CAAC,EAAA,CAAG,SAAS,OAAO,MAAM,GACrF,SAAS,KACP,UAAU,OAAO,OAAO,kBAAkB,aAAa,SAAS,SAAS,KAAK,aAAa,QAAQ,KAAK,IAAI,MAAM,GAAG,EACvH;CAEF,OAAO;AACT"}
@@ -1,85 +0,0 @@
1
- ---
2
- name: workflow-recovery
3
- description: Recover a failed or interrupted workflow-mcp run so it resumes from its active repair rather than starting over. Use before a recover action (workflow_run in Pi CLI, workflow_tools in server/web sessions), whenever a run shows stage error or interrupted, or when deciding between recovery, a fresh launch, and deferral. Covers evidence, permitted outcomes, judgement cases, and files that must never be edited.
4
- ---
5
-
6
- # Recovering a workflow run
7
-
8
- A recovery is **not** a relaunch, and the difference is expensive to get wrong. A
9
- relaunch throws away the run's state and starts again; a recovery resumes the
10
- existing run from its active repair, preserving the worktree and the work already
11
- done. Choosing the wrong one either destroys progress or resumes a run that can
12
- never succeed.
13
-
14
- Recovery is also the explicit ownership-transfer path. A replacement Pi session
15
- may recover a terminal failed run launched by an earlier session; the replay is
16
- then stamped to the recovering session. This does not permit cross-session
17
- control of running or completed work.
18
-
19
- Read this before action `recover`: use `workflow_run` in Pi CLI sessions and
20
- `workflow_tools` in server/web sessions. Both take the same `runKey` and separate `workspace`.
21
-
22
- ## 1. Gather evidence first
23
-
24
- Never act on the stage alone. Before touching a failed run, collect:
25
-
26
- - **Every log source**, not just the first one that looks relevant.
27
- - **Process state**: is anything still alive from the original run?
28
- - **The exact staged `run.json`** for the run.
29
- - **Only the repair referenced by `activeRepairId`.** Other repairs in the
30
- directory belong to earlier cycles and are not yours to act on.
31
-
32
- Use action `recovery-evidence` on the same tool for the terminal `run.json`
33
- and durable `changelog.md`, `context.md`, and progress evidence. This dedicated
34
- action is terminal-only and read-only, including for failures from an earlier
35
- session; it never scrapes that session's live launcher. Generic `status` and
36
- `tail` remain limited to runs owned by this session.
37
-
38
- ## 2. Choose exactly one outcome
39
-
40
- Every failed run resolves to one of three, and never two in the same pass:
41
-
42
- | Outcome | When |
43
- | ---------------------------- | ----------------------------------------------------------------------------------------- |
44
- | **Recover** the existing run | The recorded target is still valid and the failure was transient or an interruption |
45
- | **Launch fresh** | The run cannot resume, or the branch has diverged far enough that resuming is meaningless |
46
- | **Defer** | A named prerequisite is materially unresolved |
47
-
48
- Recovery and a fresh launch each consume one launch from the pass budget.
49
-
50
- ## 3. Judgement cases
51
-
52
- - `interrupted` with a valid failed job: the strong recovery case.
53
- - `failed` with a valid failed job: recoverable when the failure was transient
54
- and the recorded target remains valid.
55
- - **Empty failed job**: cannot be recovered. Launch fresh if the work is ready,
56
- otherwise defer.
57
- - **Terminal repair-triage run**: must never be recovered. Launch fresh once the
58
- work is ready again.
59
- - **Stale branch**: prefer a fresh launch once the branch has diverged enough
60
- that resuming would rebase onto unrecognisable history.
61
- - **No job id**: the run was launched by hand and is outside dispatch. Report
62
- it; do not recover it.
63
- - **Blocked**: never recover or launch a run whose job sits in a blocked column.
64
- A human resolves the blocker first.
65
-
66
- ## 4. Hard constraints
67
-
68
- - **Never edit `issue.md` or `repair.json`.** They are the record of what went
69
- wrong; editing them destroys the evidence and the repair chain.
70
- - **Never manufacture a recovery target.** If the recorded target is invalid,
71
- that is a fresh-launch case, not a reason to invent one.
72
- - Prepare `run.json` **only** when verified recovery state requires it.
73
- - Preserve the active repair and the existing worktree identity.
74
- - Treat an “already claimed” result as another recovery winning the race; do
75
- not launch fresh or retry around the claim.
76
- - Do not use `--dry-run` for a real recovery.
77
-
78
- ## 5. Verify before reporting
79
-
80
- In Pi CLI sessions, recover through the launcher recorded for the run. In server/web
81
- sessions, the replay runs inside the recovering session; closing it requests a stop.
82
- Then confirm **real process and registry progress**. A `recover` call that returns is
83
- not a recovery that succeeded. After ownership transfers and the replacement run is
84
- visible to this session, check `workflow_run` with action `status` before reporting an outcome.
85
- Say what you recovered, what you skipped and why, and anything still blocked.
@@ -1,64 +0,0 @@
1
- ---
2
- name: po-author-workflow
3
- description: Author Po workflow definitions. Use when creating or changing a *.workflow.yml graph, arranging job dependencies and host-executed steps, or deciding how a command requiring a TTY should run.
4
- ---
5
-
6
- # Author Po workflows
7
-
8
- Create a `*.workflow.yml` file and keep its graph explicit:
9
-
10
- ```yaml
11
- name: verify
12
-
13
- jobs:
14
- test:
15
- steps:
16
- - name: Run tests
17
- run: pnpm test
18
-
19
- summarize:
20
- needs: test
21
- steps:
22
- - name: Record result
23
- run: node scripts/write-verification-summary.mjs
24
- ```
25
-
26
- `needs` expresses job ordering. Keep steps small enough that failure evidence identifies the command that needs attention. Use runner-specific `interactiveRun` configuration when a command genuinely requires a TTY.
27
-
28
- For an agent step, declare the command once under `commands` (usually in an imported file) and let the step name it. A command is a Liquid template; `inProcess: true` lets the Po server run it as a child session instead of the shell, and the CLI and the TUI run the rendered command:
29
-
30
- ```yaml
31
- imports: [commands.yml]
32
- choices:
33
- default: { model: openai-codex/gpt-6-sol, thinking: medium }
34
- jobs:
35
- develop:
36
- steps:
37
- - name: Develop
38
- runConfig: { majorMode: dev, domains: [engineering] }
39
- systemPrompt: ${{ env.JOB_SYSTEM_PROMPT }}
40
- prompt: ${{ env.WORKFLOW_CONTEXT }}
41
- interactiveRun: [{ command: po }, { command: terminal }]
42
- ```
43
-
44
- `po` and `terminal` are the commands `commands.yml` declares; a step can only name a declared command. `runConfig` takes `majorMode`, `minorModes`, `profile`, `domains`, `model`, and `thinking`, plus any key the template reads; any other key fails the step, so a typo such as `majormode` never runs on workspace defaults. `choices` compose model and thinking, with per-command overrides such as `terminal: { model: openai-codex/gpt-6-luna }`; a step can pin `choice:`, and a launch picks `command=` and `choice=` for the rest. Templates must quote prompts with `{{ prompt | shell }}`.
45
-
46
- Before committing a workflow, run `workflow-mcp doctor <file-or-directory> --run-config-keys majorMode,minorModes,profile,domains,model,thinking` and fix every error it reports; the Po server refuses to launch a workflow with errors.
47
-
48
- An agent step ends by recording its outcome: `workflow-mcp step complete`, `step fix --restart-from <job> --reason ...`, or `step fail --reason ...`. The engine puts the instructions in the step's system prompt, and an agent that stops without deciding is sent back until it does. Write repair contracts in those terms, not as `fix.md`.
49
-
50
- What a step or job must leave is held the same way. A step's `artifacts` must be written during the step. A job must be the last to have written each run-directory entry it produces (`produced-by`): an entry an earlier job wrote must be written again, while a retry or a job that skips work it already did keeps its own output, and removing a file counts. `writes.ndjson` in the run directory records which job and step last wrote each entry. An agent step that ends its job is sent back until those entries are written, and the job fails when one was not. List a job under `produced-by` only when it writes the entry in every run. Write a `description` for every entry: the reminder tells the agent what the file holds from it.
51
-
52
- Put independent checks in a `parallel` group. A `run:` check with `restart-from: <job>` turns a failure into a fix request, and every fix request of the job merges into one repair, so one loop back fixes all of them. Keep steps that edit files out of a group: its steps share the checkout.
53
-
54
- Every `run` command executes on the workflow host with that process's environment and privileges. There is no VM, container, or sandbox. Review workflow changes as executable code, avoid embedding secrets, and make retry-sensitive external side effects explicit.
55
-
56
- Before relying on the graph, enable Workflow mode, discover it with `list_workflows`, launch a disposable run, and inspect job and step status with `workflow_run`. Test a failure path when recovery behavior matters.
57
-
58
- ## Native execution contract
59
-
60
- Agent steps require an effective `runConfig.majorMode`; delegated workflows require top-level `runConfig.majorMode` before their owner child is created. Selection projects major mode, minor modes, profile and domains, adding the workflow minor mode once. `subagentModel` and `subagentThinking` set Team preferences independently of the step model.
61
-
62
- The native host requires execution-state inspection before creating agent steps. After settlement it waits for idle, no pending messages and a known background snapshot without core holds or holding-provider errors before checking decisions. Unknown ownership waits closed without consuming reminders; stops interrupt reads and retry delays.
63
-
64
- Delegated successes are informational. Errors wake the workflow owner through durable custom-message admission; the launcher gets an error notification, not an agent-waking failure completion. Diagnosis stays local. Recovery, pause, resume and stop are request-driven. User-requested stops do not trigger diagnosis or automatic restart.
@@ -1,21 +0,0 @@
1
- ---
2
- name: po-use-workflow
3
- description: Use Po workflows. Use when discovering or launching workflows, monitoring or controlling asynchronous runs, interpreting terminal notifications, or recovering a failed run safely.
4
- ---
5
-
6
- # Use Po workflows
7
-
8
- Enable model-visible Workflow tools with `SPC w e`. In a non-interactive harness, set `WORKFLOW_MCP_MODE=on` before starting the session.
9
-
10
- Use the tools in this order:
11
-
12
- 1. `list_workflows` discovers available workflow definitions.
13
- 2. `launch_workflow` registers and starts a run. A successful launch response does not mean the jobs have finished. For a workflow whose agent steps name commands, pass `command` (such as `po` or `claude`) and `choice` (a declared model choice); both default to what the workflow lists first and to `default`.
14
- 3. `workflow_run` inspects status, follows progress, or applies a supported control action. In server/web sessions it supports status, pause, resume, and stop; `workflow_tools` carries `recovery-evidence` and `recover`.
15
- 4. Wait for a terminal notification and verify the final job and step states before reporting success.
16
-
17
- In the TUI, `SPC w l` lists the repository's workflows and launches the one under the cursor with `r`, `SPC w r` inspects this session's runs, and `SPC w c` opens recovery. The root session can launch. Child sessions can inspect the catalog but do not receive an unrestricted workflow factory.
18
-
19
- Recover only a record already in a terminal failure state. Inspect its evidence first, then use the package's `workflow-recovery` runtime skill for the repair workflow. Recovery atomically adopts eligible work, but it cannot make non-idempotent external side effects safe or guarantee that in-process work survives parent shutdown.
20
-
21
- Workflow steps and model-backed repair can consume provider quota and repeat external effects. Do not relaunch or replay a run merely because progress is quiet. Inspect live ownership and persisted state first.