@signalridge/pi-workflows 1.3.2 → 1.4.0

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.
@@ -1,51 +1,90 @@
1
1
  ---
2
2
  name: workflow-patterns
3
- description: Argument shapes for the 5 built-in workflow patterns — deep-research, adversarial-review, code-review, multi-perspective, codebase-audit — runnable via the `workflow` tool's `name` input, without slash-command syntax. Use for requests like "research X", "fact-check/adversarially review this", "review this diff/PR", "analyze from multiple perspectives", or "audit the codebase for Y". Not for authoring a new workflow script — see workflow-authoring.
3
+ description: Choose and run one of Pi's built-in multi-agent workflows for research, adversarial review, code review, multi-perspective analysis, or codebase auditing. Use when the request matches a named pattern; use workflow-authoring instead for a new script or custom topology.
4
4
  metadata:
5
- version: "1.2.1"
5
+ version: "1.4.0"
6
6
  ---
7
7
 
8
8
  # Built-in workflow patterns
9
9
 
10
- @signalridge/pi-workflows ships 5 curated, tested workflow patterns. Each is also a
11
- slash command (`/deep-research`, `/adversarial-review`, `/code-review`,
12
- `/multi-perspective`, `/codebase-audit`), but they are equally reachable from
13
- the `workflow` tool directly: call it with `name` set to the pattern name
14
- below and `args` matching its shape, instead of writing an equivalent script
15
- from scratch. Prefer this over authoring a new script whenever the request
16
- fits one of these shapes — the curated version is already reviewed and tested.
10
+ Use a built-in when its input shape matches the request. The built-ins are
11
+ reviewed scripts with bounded fan-out, structured intermediate results, and a
12
+ final aggregation step. Prefer them over writing a new script for a standard
13
+ research or review task.
17
14
 
18
- A project or user saved workflow of the same name always takes precedence
19
- over a built-in of that name — on the slash command, too.
15
+ ## Choose by task shape
20
16
 
21
- These 5 names are reachable only at the `workflow` tool's top-level `name`
22
- input, not via the in-script `await workflow(savedName, childArgs)` helper —
23
- that helper resolves saved workflows only. Calling `workflow('deep-research')`
24
- from inside a script fails as an unknown saved workflow; use the top-level
25
- `name` input instead.
17
+ | Request | Pattern | Input |
18
+ | --- | --- | --- |
19
+ | Investigate a question with cross-checked sources | `deep-research` | `{ question, angles?, minSupport? }` |
20
+ | Test a claim or task with skeptical reviewers | `adversarial-review` | `{ task, reviewers?, threshold? }` |
21
+ | Review a diff or change set from multiple angles | `code-review` | `{ diff, diffSource? }` |
22
+ | Compare a topic from independent viewpoints | `multi-perspective` | `{ topic, perspectives? }` |
23
+ | Assess codebase health, risk, and debt | `codebase-audit` | `{ scope?, root?, focus?, checks? }` |
26
24
 
27
- ## Patterns
25
+ Do not use a built-in for one direct question, one simple delegation, or a
26
+ custom dependency graph. Use the ordinary agent tool for small work and load
27
+ [workflow-authoring](../workflow-authoring/SKILL.md) for custom scripts.
28
28
 
29
- | `name` | When to reach for it | `args` |
30
- | --- | --- | --- |
31
- | `deep-research` | Research a question across the web with cross-checked sources | `{ question: string, angles?: number, minSupport?: number }` — `angles` (default 4) is the number of distinct search queries; `minSupport` (default 2) is the minimum distinct sources required for a claim to survive cross-checking |
32
- | `adversarial-review` | Investigate a task/claim, then cross-check each finding with skeptical reviewers | `{ task: string, reviewers?: number, threshold?: number }` |
33
- | `code-review` | Multi-angle review of a diff (correctness, reuse, simplification, efficiency, altitude) | `{ diff: string, diffSource?: string }` — get `diff` yourself first (e.g. `git diff`, `gh pr diff <n>`); this path does not fetch it for you |
34
- | `multi-perspective` | Analyze a topic from several independent perspectives in parallel, then synthesize | `{ topic: string, perspectives?: string[] }` — omit or give fewer than 2 to use the default set (technical, product, security, user experience, maintainability) |
35
- | `codebase-audit` | Audit a codebase for health, risk, and debt across dimensions | `{ scope?: string, root?: string, focus?: string, checks?: string[] }` — `scope`/`root` chooses the directory and `focus`/`checks` refines what the agents inspect |
29
+ ## Invocation contract
36
30
 
37
- ## Example
31
+ The model-facing call is a `workflow` tool call, not JavaScript:
38
32
 
39
33
  ```json
40
- { "name": "deep-research", "args": { "question": "What are the tradeoffs of X vs Y?" } }
34
+ {
35
+ "name": "deep-research",
36
+ "args": { "question": "What are the trade-offs between X and Y?" },
37
+ "background": true
38
+ }
41
39
  ```
42
40
 
43
- This is a `workflow` tool call, not a script — omit `script` entirely. The run
44
- starts in the background exactly like the slash-command form; `background`,
45
- `maxAgents`, `concurrency`, `agentRetries`, `agentTimeoutMs`, and `tokenBudget`
46
- all still apply.
41
+ `name` resolves a saved workflow before the built-in. A saved workflow with the
42
+ same name intentionally overrides the built-in. Do not send `script` together
43
+ with `name`; choose one form. `background` defaults to `true`; use
44
+ `background: false` only when the caller needs the result inline or a human
45
+ checkpoint must be shown.
46
+
47
+ ## Input rules
48
+
49
+ - `deep-research` requires a non-empty `question`; `angles` and `minSupport`
50
+ should be small positive bounds appropriate to the question.
51
+ - `adversarial-review` requires a non-empty `task`; use reviewer counts and
52
+ thresholds that fit the risk rather than maximizing votes.
53
+ - `code-review` requires the actual diff. Obtain it first with the host's safe
54
+ diff path; do not ask the workflow to guess which files changed.
55
+ - `multi-perspective` requires a non-empty `topic`; provide at least two
56
+ distinct perspectives when overriding the defaults.
57
+ - `codebase-audit` accepts a scope/root and optional focus/check list. Keep the
58
+ scope narrow enough that every worker can inspect it and cite concrete paths.
59
+
60
+ ## Result and recovery rules
61
+
62
+ Every built-in returns a bounded aggregate of successful intermediate results
63
+ and a final report. Failed worker calls can remain `null` or be omitted from that
64
+ aggregate, but stay visible in run details. A background call returns a run ID
65
+ immediately; inspect it with `workflow_control` (`get`, `pause`, `resume`, or
66
+ `stop`) rather than starting a duplicate run. If a provider limit pauses the run, resume the same
67
+ run after the configured retry window. A changed script or saved workflow
68
+ replays only its unchanged journal prefix, so preserve the original inputs when
69
+ resuming.
70
+
71
+ Inspect run details for missing or `null` worker results before treating the
72
+ aggregate as complete. State when sources, review angles, or audit dimensions
73
+ were unavailable; a settled workflow may still contain incomplete evidence.
74
+
75
+ ## Built-in topology summary
47
76
 
48
- ## Writing a new workflow instead
77
+ - Research plans queries, gathers them concurrently, cross-checks claims, then
78
+ writes a cited report.
79
+ - Adversarial review separates finding generation from skeptical verification
80
+ before consensus.
81
+ - Code review fans out correctness, reuse, simplification, efficiency,
82
+ architecture, security, and testability lenses, then verifies candidates
83
+ before ranking them.
84
+ - Multi-perspective analysis runs independent views behind a barrier before
85
+ synthesis.
86
+ - Codebase audit maps structure first, then runs bounded dimension audits before
87
+ its roadmap.
49
88
 
50
- If the request doesn't fit one of these 5 shapes, author a script with
51
- `script` as usual — see the workflow-authoring skill.
89
+ When a built-in needs a dependency beyond these shapes, author a custom
90
+ `orchestrate()` graph instead of adding hidden assumptions to a built-in.
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: workflow-review
3
+ description: Audit an existing Pi JavaScript workflow for topology, prompt/data flow, limits, failure handling, cancellation, resume safety, and publication compatibility. Use when reviewing or debugging a workflow script or saved run; do not use to run a standard named workflow.
4
+ metadata:
5
+ version: "1.4.0"
6
+ ---
7
+
8
+ # Workflow review
9
+
10
+ Review the workflow as an executable orchestration program, not as prose. The
11
+ review is read-only unless the user explicitly asks for a fix. Report concrete
12
+ failure scenarios and evidence; do not recommend extra agents merely because
13
+ they are available.
14
+
15
+ ## Review procedure
16
+
17
+ 1. **Identify the boundary.** Read the complete script, its invocation `args`,
18
+ saved-workflow source if applicable, and the relevant package version. Do not
19
+ infer behavior from a truncated run notification.
20
+ 2. **Map the topology.** List every work unit and its stable ID. Mark each as a
21
+ direct call, `orchestrate` task, `parallel` item, `pipeline` stage, loop
22
+ round, quality helper, checkpoint, or nested workflow. Draw the dependency
23
+ edges and barriers in declaration order.
24
+ 3. **Trace data flow.** For every downstream prompt, identify the exact input
25
+ values and their bounds. Confirm that structured fields have a schema and
26
+ that failed/null results remain visible in a ledger.
27
+ 4. **Check admission.** Verify finite bounds for task count, fan-out, loops,
28
+ retries, concurrency, token budget, timeout, and evidence size. Check that
29
+ a graph validates IDs, references, duplicate edges, and cycles before any
30
+ callback runs.
31
+ 5. **Check failure policy.** Distinguish recoverable child `null` from fatal
32
+ workflow errors. For graphs, verify whether the default
33
+ `skip-dependents`, explicit `continue`, or `fail-fast` policy matches the
34
+ task. Ensure ordinary task retries do not silently duplicate side effects.
35
+ 6. **Check lifecycle.** Verify every batch is awaited, cancellation stops
36
+ owned work, checkpoints have a headless behavior, and nested workflows stay
37
+ within one level and shared capacity.
38
+ 7. **Check resume.** Keep call order, labels, prompts, routing options, and
39
+ inputs stable. Confirm that edited or missing calls invalidate downstream
40
+ replay and that nested results use a generation-scoped boundary. Treat
41
+ effectful worktree/file changes as non-replayable unless its effects are
42
+ explicitly restored.
43
+ 8. **Check publication.** Confirm the literal meta envelope, no imports or
44
+ nondeterministic APIs, safe relative links, current capability facts, and
45
+ an appropriate changeset when shipped package files changed.
46
+
47
+ ## Output format
48
+
49
+ Rank findings by severity and include:
50
+
51
+ - `file:line` or the task ID;
52
+ - the concrete input or lifecycle sequence that triggers it;
53
+ - the incorrect or risky behavior;
54
+ - the smallest safe fix;
55
+ - whether it blocks correctness, loses coverage, wastes tokens, or is only a
56
+ documentation concern.
57
+
58
+ End with a short topology summary and a list of verified strengths. If no
59
+ finding is reproducible, say so and state which paths were checked.
60
+
61
+ ## References
62
+
63
+ - Use [the review checklist](../workflow-authoring/references/review.md) for
64
+ the compact acceptance gate.
65
+ - Use [lifecycle](../workflow-authoring/references/lifecycle.md) for pause,
66
+ stop, budget, retry, and resume semantics.
67
+ - Use [debugging](../workflow-authoring/references/debugging.md) to reduce a
68
+ failure to a deterministic fake-agent reproduction.
69
+ - Use [the generated capability index](../workflow-authoring/references/capabilities.md)
70
+ only when a signature or support boundary is disputed.
@@ -58,6 +58,7 @@ export const WORKFLOW_CAPABILITIES: readonly CapabilityEntry[] = [
58
58
  "recoverable failures return null after retries; nonrecoverable failures throw",
59
59
  "schema noncompliance after bounded repair attempts is nonrecoverable",
60
60
  "resume replays only the longest unchanged prefix; the first miss and every later call execute live",
61
+ "replayed calls do not consume the real-dispatch maxAgents or token/phase budgets",
61
62
  "spawnKeys rotate by generation on resume so pi-subagents never raises a fingerprint conflict",
62
63
  "explicit model is resolved and scope-checked by pi-subagents; unavailable selectors fail closed",
63
64
  "same-thread calls must be sequential and preserve a stable workflow thread name",
@@ -72,8 +73,9 @@ export const WORKFLOW_CAPABILITIES: readonly CapabilityEntry[] = [
72
73
  constraints: [
73
74
  "requires functions rather than promises",
74
75
  "result order matches input order",
75
- "recoverable thunk failures become null; nonrecoverable failures throw",
76
+ "recoverable thunk failures become null; nonrecoverable failures throw after the batch barrier settles",
76
77
  "a breached agent cap cancels only its own batch",
78
+ "accepts at most 4096 thunks per call",
77
79
  ],
78
80
  },
79
81
  {
@@ -85,6 +87,28 @@ export const WORKFLOW_CAPABILITIES: readonly CapabilityEntry[] = [
85
87
  "items run concurrently while stages per item run sequentially",
86
88
  "each stage receives previousValue, originalItem, and zero-based index",
87
89
  "a null stage result is passed to the next stage",
90
+ "accepts at most 4096 items per call and awaits the whole batch before surfacing fatal errors",
91
+ ],
92
+ },
93
+ {
94
+ name: "orchestrate",
95
+ classification: "runtime-global",
96
+ signature: "orchestrate(tasks, options?) => Promise<{ results, tasks }>",
97
+ options: [
98
+ {
99
+ name: "onError",
100
+ kind: '"skip-dependents"|"continue"|"fail-fast"',
101
+ optional: true,
102
+ default: '"skip-dependents"',
103
+ },
104
+ ],
105
+ constraints: [
106
+ "task ids and dependencies are validated before any callback runs",
107
+ "ready tasks run in declaration-order layers with a barrier between layers",
108
+ "task context carries detached named results and statuses",
109
+ "ordinary task failures can retry up to three times; fatal workflow errors propagate",
110
+ "failed or skipped dependencies skip descendants by default; continue runs them with null values",
111
+ "the graph accepts at most 128 tasks and emits task start/retry/end/skip runtime events",
88
112
  ],
89
113
  },
90
114
  {
@@ -93,9 +117,9 @@ export const WORKFLOW_CAPABILITIES: readonly CapabilityEntry[] = [
93
117
  signature: "workflow(savedName, childArgs?) => Promise<unknown>",
94
118
  options: [],
95
119
  constraints: [
96
- "one nested level",
120
+ "one nested level; concurrent sibling nested calls are allowed",
97
121
  "shares limiter, counters, token accounting, and store",
98
- "nested runs get unique runIds via nestedCallSeq",
122
+ "nested calls use call-index/generation namespaces and replay as one parent result",
99
123
  ],
100
124
  },
101
125
  {
@@ -271,6 +295,7 @@ export const WORKFLOW_CAPABILITIES: readonly CapabilityEntry[] = [
271
295
  options: [],
272
296
  constraints: [
273
297
  "resumes a prior incomplete run with an edited script",
298
+ "original args and execution limits are reused on resume",
274
299
  "unchanged positional calls replay from cache until the first changed call",
275
300
  "always runs in the background",
276
301
  ],