@davidorex/pi-workflows 0.1.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.
- package/CHANGELOG.md +28 -0
- package/README.md +169 -0
- package/agents/audit-fixer.agent.yaml +18 -0
- package/agents/code-explorer.agent.yaml +11 -0
- package/agents/decomposer.agent.yaml +51 -0
- package/agents/investigator.agent.yaml +49 -0
- package/agents/pattern-analyzer.agent.yaml +21 -0
- package/agents/phase-author.agent.yaml +16 -0
- package/agents/plan-decomposer.agent.yaml +12 -0
- package/agents/quality-analyzer.agent.yaml +21 -0
- package/agents/researcher.agent.yaml +38 -0
- package/agents/spec-implementer.agent.yaml +12 -0
- package/agents/structure-analyzer.agent.yaml +21 -0
- package/agents/synthesizer.agent.yaml +23 -0
- package/agents/verifier.agent.yaml +12 -0
- package/package.json +40 -0
- package/schemas/decomposition-specs.schema.json +50 -0
- package/schemas/execution-results.schema.json +50 -0
- package/schemas/investigation-findings.schema.json +45 -0
- package/schemas/pattern-analysis.schema.json +43 -0
- package/schemas/plan-breakdown.schema.json +22 -0
- package/schemas/quality-analysis.schema.json +35 -0
- package/schemas/research-findings.schema.json +44 -0
- package/schemas/structure-analysis.schema.json +42 -0
- package/schemas/synthesis.schema.json +33 -0
- package/schemas/verifier-output.schema.json +96 -0
- package/src/agent-spec.test.ts +289 -0
- package/src/agent-spec.ts +122 -0
- package/src/block-validation.test.ts +350 -0
- package/src/checkpoint.test.ts +237 -0
- package/src/checkpoint.ts +139 -0
- package/src/completion.test.ts +143 -0
- package/src/completion.ts +68 -0
- package/src/dag.test.ts +350 -0
- package/src/dag.ts +219 -0
- package/src/dispatch.test.ts +473 -0
- package/src/dispatch.ts +353 -0
- package/src/expression.test.ts +353 -0
- package/src/expression.ts +332 -0
- package/src/format.test.ts +80 -0
- package/src/format.ts +41 -0
- package/src/graduated-failure.test.ts +556 -0
- package/src/index.test.ts +114 -0
- package/src/index.ts +488 -0
- package/src/loop.test.ts +549 -0
- package/src/output.test.ts +213 -0
- package/src/output.ts +70 -0
- package/src/parallel-integration.test.ts +175 -0
- package/src/resume.test.ts +192 -0
- package/src/state.test.ts +192 -0
- package/src/state.ts +253 -0
- package/src/step-agent.test.ts +327 -0
- package/src/step-agent.ts +178 -0
- package/src/step-command.test.ts +330 -0
- package/src/step-command.ts +132 -0
- package/src/step-foreach.test.ts +647 -0
- package/src/step-foreach.ts +148 -0
- package/src/step-gate.test.ts +185 -0
- package/src/step-gate.ts +116 -0
- package/src/step-loop.test.ts +626 -0
- package/src/step-loop.ts +323 -0
- package/src/step-parallel.test.ts +475 -0
- package/src/step-parallel.ts +168 -0
- package/src/step-pause.test.ts +30 -0
- package/src/step-pause.ts +27 -0
- package/src/step-shared.test.ts +355 -0
- package/src/step-shared.ts +157 -0
- package/src/step-transform.test.ts +155 -0
- package/src/step-transform.ts +47 -0
- package/src/template-integration.test.ts +72 -0
- package/src/template.test.ts +162 -0
- package/src/template.ts +92 -0
- package/src/test-helpers.ts +51 -0
- package/src/tui.test.ts +355 -0
- package/src/tui.ts +182 -0
- package/src/types.ts +195 -0
- package/src/verifier-schema.test.ts +226 -0
- package/src/workflow-discovery.test.ts +105 -0
- package/src/workflow-discovery.ts +113 -0
- package/src/workflow-executor.test.ts +1530 -0
- package/src/workflow-executor.ts +810 -0
- package/src/workflow-sdk.test.ts +238 -0
- package/src/workflow-sdk.ts +262 -0
- package/src/workflow-spec.test.ts +576 -0
- package/src/workflow-spec.ts +471 -0
- package/templates/analyzers/base-analyzer.md +9 -0
- package/templates/analyzers/macros.md +1 -0
- package/templates/analyzers/patterns-task.md +11 -0
- package/templates/analyzers/patterns.md +15 -0
- package/templates/analyzers/quality-task.md +11 -0
- package/templates/analyzers/quality.md +15 -0
- package/templates/analyzers/structure-task.md +17 -0
- package/templates/analyzers/structure.md +15 -0
- package/templates/audit-fixer/task.md +67 -0
- package/templates/decomposer/task.md +56 -0
- package/templates/explorer/system.md +3 -0
- package/templates/explorer/task.md +9 -0
- package/templates/investigator/task.md +30 -0
- package/templates/phase-author/task.md +74 -0
- package/templates/plan-decomposer/task.md +46 -0
- package/templates/researcher/task.md +26 -0
- package/templates/spec-implementer/task.md +53 -0
- package/templates/synthesizer/system.md +3 -0
- package/templates/synthesizer/task.md +38 -0
- package/templates/verifier/task.md +57 -0
- package/workflows/create-phase.workflow.yaml +67 -0
- package/workflows/do-gap.workflow.yaml +153 -0
- package/workflows/fix-audit.workflow.yaml +217 -0
- package/workflows/gap-to-phase.workflow.yaml +98 -0
- package/workflows/parallel-analysis.workflow.yaml +62 -0
- package/workflows/parallel-explicit.workflow.yaml +42 -0
- package/workflows/pausable-analysis.workflow.yaml +44 -0
- package/workflows/resumable-analysis.workflow.yaml +42 -0
- package/workflows/self-implement.workflow.yaml +63 -0
- package/workflows/typed-analysis.workflow.yaml +63 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## v0.1.0
|
|
6
|
+
|
|
7
|
+
Initial release.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Workflow orchestration via `.workflow.yaml` specs with DAG-based execution planning
|
|
12
|
+
- Step types: agent, command, transform, gate, parallel, foreach, loop, pause
|
|
13
|
+
- Expression evaluator (`${{ }}`) with filters: length, keys, filter, json, upper, lower, trim, default, first, last, join, split, replace, includes, map, sum, min, max, sort, unique, flatten, zip, group_by, count_by, chunk, pick, omit, entries, from_entries, merge, values, not, and, or
|
|
14
|
+
- Agent dispatch via subprocess (`pi --mode json`) with thinking inheritance
|
|
15
|
+
- Nunjucks template compilation for agent prompts with template inheritance
|
|
16
|
+
- Agent spec loader (`.agent.yaml` format with model, thinking, tools, output schema)
|
|
17
|
+
- DAG planner inferring parallelism from `${{ steps.X }}` references
|
|
18
|
+
- Atomic state persistence after each step (tmp + rename, failure is fatal)
|
|
19
|
+
- Checkpoint/resume: incomplete runs resume from last completed step
|
|
20
|
+
- `completion` field for post-workflow messages to main LLM
|
|
21
|
+
- Workflow SDK: `stepTypes()`, `filterNames()`, `expressionRoots()`, vocabulary discovery
|
|
22
|
+
- Workflow discovery: `availableAgents(cwd)`, `availableWorkflows(cwd)`, `availableTemplates(cwd)` with three-tier search (project > user > package builtin)
|
|
23
|
+
- Spec introspection: `extractExpressions`, `declaredSteps`, `declaredAgentRefs`, `declaredSchemaRefs`
|
|
24
|
+
- `/workflow` command with `run`, `list`, `resume` subcommands
|
|
25
|
+
- TUI progress widget for workflow execution
|
|
26
|
+
- Bundled agents: investigator, decomposer, executor, verifier, refresher
|
|
27
|
+
- Bundled workflows: do-gap, gap-to-phase, create-phase, refresh-blocks
|
|
28
|
+
- Bundled output schemas and Nunjucks templates
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# pi-workflows
|
|
2
|
+
|
|
3
|
+
Workflow orchestration extension for [Pi](https://github.com/badlogic/pi-mono). Define multi-step workflows in YAML, execute them as DAGs with typed data flow between agents, and resume from checkpoints on failure.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pi install pi-workflows
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires `pi-project` as a peer dependency (installed separately).
|
|
12
|
+
|
|
13
|
+
## What It Does
|
|
14
|
+
|
|
15
|
+
pi-workflows replaces ad-hoc agent chaining with composable, typed workflow orchestration. Workflows are YAML specs. Steps run as subprocesses (`pi --mode json`) with their own context windows. The main conversation is the control plane; workflows are subordinate.
|
|
16
|
+
|
|
17
|
+
**Tool registered:**
|
|
18
|
+
- `workflow` — run a named workflow with typed input
|
|
19
|
+
|
|
20
|
+
**Commands registered:**
|
|
21
|
+
- `/workflow list` — discover and select a workflow to run
|
|
22
|
+
- `/workflow run <name> [--input '<json>']` — execute a workflow
|
|
23
|
+
- `/workflow resume <name>` — resume an incomplete run from checkpoint
|
|
24
|
+
|
|
25
|
+
**Keybindings:**
|
|
26
|
+
- `Ctrl+H` — pause running workflow after current step
|
|
27
|
+
- `Ctrl+J` — resume a paused/incomplete workflow
|
|
28
|
+
|
|
29
|
+
## Workflow Spec Format
|
|
30
|
+
|
|
31
|
+
Workflows are `.workflow.yaml` files discovered from `.pi/workflows/` (project), `~/.pi/agent/workflows/` (user), or the package's `workflows/` directory (builtin).
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
name: my-workflow
|
|
35
|
+
description: What this workflow does
|
|
36
|
+
input:
|
|
37
|
+
type: object
|
|
38
|
+
properties:
|
|
39
|
+
target: { type: string, description: "What to analyze" }
|
|
40
|
+
required: [target]
|
|
41
|
+
|
|
42
|
+
steps:
|
|
43
|
+
investigate:
|
|
44
|
+
agent: investigator
|
|
45
|
+
input: |
|
|
46
|
+
Investigate: ${{ input.target }}
|
|
47
|
+
output:
|
|
48
|
+
schema: investigation-findings
|
|
49
|
+
|
|
50
|
+
synthesize:
|
|
51
|
+
agent: synthesizer
|
|
52
|
+
input: |
|
|
53
|
+
Findings: ${{ steps.investigate.output | json }}
|
|
54
|
+
|
|
55
|
+
completion:
|
|
56
|
+
message: |
|
|
57
|
+
Analysis complete. Key findings: ${{ steps.synthesize.output.summary }}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Step Types
|
|
61
|
+
|
|
62
|
+
| Type | Purpose |
|
|
63
|
+
|------|---------|
|
|
64
|
+
| `agent` | Dispatch to a Pi agent subprocess |
|
|
65
|
+
| `command` | Run a shell command |
|
|
66
|
+
| `transform` | Map/reshape data between steps |
|
|
67
|
+
| `gate` | Conditional branching (`check` expression) |
|
|
68
|
+
| `parallel` | Run nested steps concurrently |
|
|
69
|
+
| `foreach` | Iterate over an array |
|
|
70
|
+
| `loop` | Repeat steps with a condition |
|
|
71
|
+
| `pause` | Halt execution for human review |
|
|
72
|
+
|
|
73
|
+
### Expressions
|
|
74
|
+
|
|
75
|
+
`${{ }}` expressions access step outputs, inputs, and apply filters:
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
${{ input.target }} # workflow input
|
|
79
|
+
${{ steps.investigate.output }} # step output
|
|
80
|
+
${{ steps.investigate.output | json }} # pipe through filter
|
|
81
|
+
${{ steps.gather.output | length }} # array length
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Available filters: `length`, `keys`, `filter`, `json`, `upper`, `lower`, `trim`, `default`, `first`, `last`, `join`, `split`, `replace`, `includes`, `map`, `sum`, `min`, `max`, `sort`, `unique`, `flatten`, `zip`, `group_by`, `count_by`, `chunk`, `pick`, `omit`, `entries`, `from_entries`, `merge`, `values`, `not`, `and`, `or`.
|
|
85
|
+
|
|
86
|
+
## Source Files
|
|
87
|
+
|
|
88
|
+
| File | Purpose |
|
|
89
|
+
|------|---------|
|
|
90
|
+
| `src/index.ts` | Extension entry point — tool, command, keybinding registration |
|
|
91
|
+
| `src/workflow-executor.ts` | Main orchestration loop |
|
|
92
|
+
| `src/workflow-spec.ts` | YAML parsing, `STEP_TYPES` registry |
|
|
93
|
+
| `src/workflow-sdk.ts` | SDK: vocabulary, discovery, introspection |
|
|
94
|
+
| `src/workflow-discovery.ts` | Three-tier workflow discovery (project > user > builtin) |
|
|
95
|
+
| `src/expression.ts` | `${{ }}` evaluator, `FILTER_NAMES` registry |
|
|
96
|
+
| `src/template.ts` | Nunjucks template environment |
|
|
97
|
+
| `src/dispatch.ts` | Agent subprocess spawn (`pi --mode json`) |
|
|
98
|
+
| `src/dag.ts` | Dependency graph, execution plan from `${{ steps.X }}` refs |
|
|
99
|
+
| `src/agent-spec.ts` | `.agent.yaml` parser |
|
|
100
|
+
| `src/state.ts` | Atomic run state persistence |
|
|
101
|
+
| `src/checkpoint.ts` | Checkpoint detection, resume validation |
|
|
102
|
+
| `src/output.ts` | Step output persistence |
|
|
103
|
+
| `src/completion.ts` | Post-workflow message resolution |
|
|
104
|
+
| `src/tui.ts` | Terminal progress widget |
|
|
105
|
+
| `src/types.ts` | Shared type definitions |
|
|
106
|
+
| `src/step-*.ts` | Step type executors (one per type) |
|
|
107
|
+
|
|
108
|
+
## Bundled Resources
|
|
109
|
+
|
|
110
|
+
| Directory | Contents |
|
|
111
|
+
|-----------|----------|
|
|
112
|
+
| `agents/` | 13 agent specs (`.agent.yaml`): investigator, decomposer, verifier, synthesizer, etc. |
|
|
113
|
+
| `schemas/` | 10 output schemas (`.schema.json`): investigation-findings, execution-results, etc. |
|
|
114
|
+
| `workflows/` | 10 workflow specs (`.workflow.yaml`): do-gap, create-phase, parallel-analysis, etc. |
|
|
115
|
+
| `templates/` | Nunjucks prompt templates organized by agent role |
|
|
116
|
+
|
|
117
|
+
## SDK (`src/workflow-sdk.ts`)
|
|
118
|
+
|
|
119
|
+
Single queryable surface for the extension's capabilities:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Vocabulary (derived from code registries)
|
|
123
|
+
stepTypes(): StepTypeDescriptor[]
|
|
124
|
+
filterNames(): string[]
|
|
125
|
+
expressionRoots(): readonly string[]
|
|
126
|
+
|
|
127
|
+
// Discovery (derived from filesystem, three-tier search)
|
|
128
|
+
availableAgents(cwd): AgentSpec[]
|
|
129
|
+
availableWorkflows(cwd): WorkflowSpec[]
|
|
130
|
+
availableTemplates(cwd): string[]
|
|
131
|
+
availableSchemas(cwd): string[]
|
|
132
|
+
|
|
133
|
+
// Introspection (derived from parsed spec)
|
|
134
|
+
extractExpressions(spec): ExpressionRef[]
|
|
135
|
+
declaredSteps(spec): string[]
|
|
136
|
+
declaredAgentRefs(spec): string[]
|
|
137
|
+
declaredSchemaRefs(spec): string[]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Architecture
|
|
141
|
+
|
|
142
|
+
- Each workflow step runs as a subprocess (`pi --mode json`) with its own context window
|
|
143
|
+
- DAG planner infers parallelism from `${{ steps.X }}` references — no manual dependency declaration
|
|
144
|
+
- Agent specs are `.agent.yaml` only. Compiled to prompts via Nunjucks at dispatch time.
|
|
145
|
+
- State persisted atomically after each step (tmp + rename). State write failure is fatal.
|
|
146
|
+
- Three-tier resource search: project `.pi/` > user `~/.pi/agent/` > package builtin
|
|
147
|
+
- `completion` field controls what message is sent back to the main conversation after a workflow finishes
|
|
148
|
+
|
|
149
|
+
## For LLMs
|
|
150
|
+
|
|
151
|
+
When working with this extension:
|
|
152
|
+
|
|
153
|
+
- **Read `src/workflow-sdk.ts`** for the full vocabulary, discovery, and introspection API
|
|
154
|
+
- **Read `src/workflow-spec.ts`** for the `STEP_TYPES` registry and YAML parsing rules
|
|
155
|
+
- **Read `src/expression.ts`** for `FILTER_NAMES` and expression evaluation rules
|
|
156
|
+
- **Read `src/types.ts`** for `WorkflowSpec`, `StepSpec`, `AgentSpec`, and `ExecutionState` type definitions
|
|
157
|
+
- **Read `src/dag.ts`** to understand how execution order is inferred from expressions
|
|
158
|
+
- **Read agent `.agent.yaml` files** in `agents/` to understand available agent capabilities
|
|
159
|
+
- **Read workflow `.workflow.yaml` files** in `workflows/` for examples of workflow structure
|
|
160
|
+
- Use the `workflow` tool to execute workflows — it handles discovery, input validation, checkpoint detection, and result formatting
|
|
161
|
+
- The `/workflow list` command provides an interactive picker; `/workflow run <name>` runs directly
|
|
162
|
+
|
|
163
|
+
## Tests
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm test
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Runs `node --experimental-strip-types run-tests.ts` which discovers and executes all `src/*.test.ts` files. 500+ tests covering step types, expressions, DAG planning, state persistence, checkpoint/resume, and template compilation.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: audit-fixer
|
|
2
|
+
role: action
|
|
3
|
+
description: Fixes a cluster of related audit findings in source code
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
- read
|
|
7
|
+
- write
|
|
8
|
+
- edit
|
|
9
|
+
- bash
|
|
10
|
+
- grep
|
|
11
|
+
- find
|
|
12
|
+
|
|
13
|
+
output:
|
|
14
|
+
format: json
|
|
15
|
+
schema: schemas/execution-results.schema.json
|
|
16
|
+
|
|
17
|
+
prompt:
|
|
18
|
+
task: audit-fixer/task.md
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: decomposer
|
|
2
|
+
description: Decomposes investigation findings into implementation specs with parallelization decisions
|
|
3
|
+
role: decomposer
|
|
4
|
+
prompt:
|
|
5
|
+
system: |
|
|
6
|
+
<objective>
|
|
7
|
+
You decompose a gap into implementation specs. Each spec is a unit of work for a single implementing agent — one context window, one concern. You receive investigation findings and optional research findings.
|
|
8
|
+
</objective>
|
|
9
|
+
|
|
10
|
+
<workflow>
|
|
11
|
+
1. Review affected files, constraints, and risks from investigation
|
|
12
|
+
2. Identify the minimal set of changes needed
|
|
13
|
+
3. Group changes into specs — each spec modifies a coherent set of files
|
|
14
|
+
4. Set dependencies: if spec B requires interfaces from spec A, B depends_on A
|
|
15
|
+
5. Set parallel_safe based on file overlap and semantic dependency
|
|
16
|
+
6. Write acceptance criteria that are verifiable (grep patterns, test commands, not "it works")
|
|
17
|
+
7. Estimate complexity per spec
|
|
18
|
+
</workflow>
|
|
19
|
+
|
|
20
|
+
<constraints>
|
|
21
|
+
- Output MUST be valid JSON conforming exactly to the output schema
|
|
22
|
+
- Every field marked required in the schema MUST be present
|
|
23
|
+
- Specs modifying the same file MUST have depends_on relationships (NOT parallel_safe)
|
|
24
|
+
- Specs where one introduces an interface the other consumes MUST be sequential
|
|
25
|
+
- Specs modifying different files with no semantic dependency SHOULD be parallel_safe: true
|
|
26
|
+
- Each spec must fit in a single agent context window — split if too large
|
|
27
|
+
- estimated_complexity MUST be one of: low, medium, high
|
|
28
|
+
- depends_on is an empty array if no dependencies; contains spec names otherwise
|
|
29
|
+
- Acceptance criteria must be machine-verifiable where possible (grep, test commands, file existence)
|
|
30
|
+
</constraints>
|
|
31
|
+
|
|
32
|
+
<anti_patterns>
|
|
33
|
+
- One giant spec that does everything — split into focused units
|
|
34
|
+
- Specs with vague acceptance criteria ("code is clean", "tests pass")
|
|
35
|
+
- Marking specs as parallel_safe when they modify the same file
|
|
36
|
+
- Creating specs for work not required by the gap
|
|
37
|
+
- Acceptance criteria that require human judgment
|
|
38
|
+
</anti_patterns>
|
|
39
|
+
|
|
40
|
+
<success_criteria>
|
|
41
|
+
- Output validates against the schema with zero errors
|
|
42
|
+
- Every spec has at least one file target
|
|
43
|
+
- Every spec has at least one verifiable acceptance criterion
|
|
44
|
+
- Dependency graph has no cycles
|
|
45
|
+
- parallel_safe flags are consistent with file targets (no shared-file parallelism)
|
|
46
|
+
- ordering_rationale explains the structure in one paragraph
|
|
47
|
+
</success_criteria>
|
|
48
|
+
task: decomposer/task.md
|
|
49
|
+
output:
|
|
50
|
+
format: json
|
|
51
|
+
schema: schemas/decomposition-specs.schema.json
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: investigator
|
|
2
|
+
description: Investigates a gap by reading the codebase — produces structured findings
|
|
3
|
+
role: investigator
|
|
4
|
+
tools: [read, bash, grep, find]
|
|
5
|
+
prompt:
|
|
6
|
+
system: |
|
|
7
|
+
<objective>
|
|
8
|
+
You investigate a code gap and produce structured JSON findings. You read code to understand what exists, what's affected, and what constraints apply. You do NOT plan or implement — you produce understanding.
|
|
9
|
+
</objective>
|
|
10
|
+
|
|
11
|
+
<workflow>
|
|
12
|
+
1. Read the gap description and identify which files are likely affected
|
|
13
|
+
2. Read those files (minimum reads — use grep/find to locate, read only what's needed)
|
|
14
|
+
3. For each affected file: document its path, role, and current behavior
|
|
15
|
+
4. List constraints (tests, interfaces, conventions that must not break)
|
|
16
|
+
5. List risks only if non-obvious
|
|
17
|
+
6. Set complexity: low (single file, mechanical), medium (multiple files, design choices), high (architectural)
|
|
18
|
+
7. Set needs_research to true ONLY if the solution requires knowledge not in the codebase
|
|
19
|
+
8. Write a one-paragraph summary
|
|
20
|
+
</workflow>
|
|
21
|
+
|
|
22
|
+
<constraints>
|
|
23
|
+
- Output MUST be valid JSON conforming exactly to the output schema
|
|
24
|
+
- Every field marked required in the schema MUST be present
|
|
25
|
+
- Do NOT write to any files — read only
|
|
26
|
+
- Do NOT produce implementation plans or code changes
|
|
27
|
+
- Match investigation depth to gap priority: low-priority cleanup gaps need minimal investigation
|
|
28
|
+
- If needs_research is false, research_questions MUST be an empty array
|
|
29
|
+
</constraints>
|
|
30
|
+
|
|
31
|
+
<anti_patterns>
|
|
32
|
+
- Reading every file in the project — use grep to find relevant code
|
|
33
|
+
- Setting needs_research: true for gaps solvable from codebase context alone
|
|
34
|
+
- Producing a plan instead of findings
|
|
35
|
+
- Omitting required fields from the output
|
|
36
|
+
- Writing or modifying any project files
|
|
37
|
+
</anti_patterns>
|
|
38
|
+
|
|
39
|
+
<success_criteria>
|
|
40
|
+
- Output validates against the schema with zero errors
|
|
41
|
+
- Every affected_files entry has path, role, and current_behavior
|
|
42
|
+
- constraints lists real constraints from the codebase (not generic advice)
|
|
43
|
+
- complexity rating matches actual scope
|
|
44
|
+
- Summary is one paragraph, not a plan
|
|
45
|
+
</success_criteria>
|
|
46
|
+
task: investigator/task.md
|
|
47
|
+
output:
|
|
48
|
+
format: json
|
|
49
|
+
schema: schemas/investigation-findings.schema.json
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: pattern-analyzer
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Analyze design patterns and return typed findings
|
|
4
|
+
tools: [read, bash, ls]
|
|
5
|
+
|
|
6
|
+
input:
|
|
7
|
+
type: object
|
|
8
|
+
required: [exploration, path]
|
|
9
|
+
properties:
|
|
10
|
+
exploration:
|
|
11
|
+
description: Prior exploration output (typed JSON)
|
|
12
|
+
path:
|
|
13
|
+
type: string
|
|
14
|
+
|
|
15
|
+
output:
|
|
16
|
+
format: json
|
|
17
|
+
schema: schemas/pattern-analysis.schema.json
|
|
18
|
+
|
|
19
|
+
prompt:
|
|
20
|
+
system: analyzers/patterns.md
|
|
21
|
+
task: analyzers/patterns-task.md
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: phase-author
|
|
2
|
+
role: reasoning
|
|
3
|
+
description: Converts unstructured intent from conversation into a structured phase spec with numbered specs, acceptance criteria, and success criteria
|
|
4
|
+
|
|
5
|
+
tools:
|
|
6
|
+
- read
|
|
7
|
+
- bash
|
|
8
|
+
- grep
|
|
9
|
+
- find
|
|
10
|
+
|
|
11
|
+
output:
|
|
12
|
+
format: json
|
|
13
|
+
schema: ../../.workflow/schemas/phase.schema.json
|
|
14
|
+
|
|
15
|
+
prompt:
|
|
16
|
+
task: templates/phase-author/task.md
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
name: plan-decomposer
|
|
2
|
+
role: reasoning
|
|
3
|
+
description: Decomposes a phase spec into focused implementation plans with context decisions
|
|
4
|
+
|
|
5
|
+
tools: [read, bash, grep, find]
|
|
6
|
+
|
|
7
|
+
output:
|
|
8
|
+
format: json
|
|
9
|
+
schema: schemas/plan-breakdown.schema.json
|
|
10
|
+
|
|
11
|
+
prompt:
|
|
12
|
+
task: plan-decomposer/task.md
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: quality-analyzer
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Analyze code quality and return typed findings
|
|
4
|
+
tools: [read, bash, ls]
|
|
5
|
+
|
|
6
|
+
input:
|
|
7
|
+
type: object
|
|
8
|
+
required: [exploration, path]
|
|
9
|
+
properties:
|
|
10
|
+
exploration:
|
|
11
|
+
description: Prior exploration output (typed JSON)
|
|
12
|
+
path:
|
|
13
|
+
type: string
|
|
14
|
+
|
|
15
|
+
output:
|
|
16
|
+
format: json
|
|
17
|
+
schema: schemas/quality-analysis.schema.json
|
|
18
|
+
|
|
19
|
+
prompt:
|
|
20
|
+
system: analyzers/quality.md
|
|
21
|
+
task: analyzers/quality-task.md
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: researcher
|
|
2
|
+
description: Researches known solutions, patterns, and heuristics relevant to a gap
|
|
3
|
+
role: researcher
|
|
4
|
+
prompt:
|
|
5
|
+
system: |
|
|
6
|
+
<objective>
|
|
7
|
+
You answer specific technical research questions about a software engineering problem. You draw on knowledge of patterns, best practices, prior art, and established solutions.
|
|
8
|
+
</objective>
|
|
9
|
+
|
|
10
|
+
<workflow>
|
|
11
|
+
1. Read each research question
|
|
12
|
+
2. Answer with specific, actionable information — not general advice
|
|
13
|
+
3. Rate confidence: high (well-known pattern), medium (established but context-dependent), low (best guess)
|
|
14
|
+
4. Cite sources: documentation URLs, project names, pattern names, book references
|
|
15
|
+
5. Identify applicable patterns with concrete applicability statements
|
|
16
|
+
6. Produce recommendations that are specific enough to implement
|
|
17
|
+
</workflow>
|
|
18
|
+
|
|
19
|
+
<constraints>
|
|
20
|
+
- Output MUST be valid JSON conforming exactly to the output schema
|
|
21
|
+
- Every field marked required in the schema MUST be present
|
|
22
|
+
- Every question entry MUST have: question, answer, sources (array), confidence
|
|
23
|
+
- Every pattern entry MUST have: name, description, applicability
|
|
24
|
+
- confidence MUST be one of: high, medium, low
|
|
25
|
+
- Do NOT fabricate sources — if you don't know a source, use an empty array
|
|
26
|
+
- Recommendations must be actionable, not generic ("use caching" is too vague; "add LRU cache with 100-entry limit on the resolve() call" is specific)
|
|
27
|
+
</constraints>
|
|
28
|
+
|
|
29
|
+
<success_criteria>
|
|
30
|
+
- Output validates against the schema with zero errors
|
|
31
|
+
- Every question receives a direct answer (not "it depends" without resolution)
|
|
32
|
+
- Confidence ratings are honest — low when uncertain
|
|
33
|
+
- Recommendations are specific enough that an implementer can act on them without further research
|
|
34
|
+
</success_criteria>
|
|
35
|
+
task: researcher/task.md
|
|
36
|
+
output:
|
|
37
|
+
format: json
|
|
38
|
+
schema: schemas/research-findings.schema.json
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
name: spec-implementer
|
|
2
|
+
role: action
|
|
3
|
+
description: Implements a single plan from a phase decomposition
|
|
4
|
+
|
|
5
|
+
tools: [read, write, edit, bash, grep, find]
|
|
6
|
+
|
|
7
|
+
output:
|
|
8
|
+
format: json
|
|
9
|
+
schema: schemas/execution-results.schema.json
|
|
10
|
+
|
|
11
|
+
prompt:
|
|
12
|
+
task: spec-implementer/task.md
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: structure-analyzer
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Analyze code structure and return typed findings
|
|
4
|
+
tools: [read, bash, ls]
|
|
5
|
+
|
|
6
|
+
input:
|
|
7
|
+
type: object
|
|
8
|
+
required: [exploration, path]
|
|
9
|
+
properties:
|
|
10
|
+
exploration:
|
|
11
|
+
description: Prior exploration output (typed JSON)
|
|
12
|
+
path:
|
|
13
|
+
type: string
|
|
14
|
+
|
|
15
|
+
output:
|
|
16
|
+
format: json
|
|
17
|
+
schema: schemas/structure-analysis.schema.json
|
|
18
|
+
|
|
19
|
+
prompt:
|
|
20
|
+
system: analyzers/structure.md
|
|
21
|
+
task: analyzers/structure-task.md
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: synthesizer
|
|
2
|
+
role: reasoning
|
|
3
|
+
description: Synthesize typed analysis findings into a unified report
|
|
4
|
+
tools: [read]
|
|
5
|
+
|
|
6
|
+
input:
|
|
7
|
+
type: object
|
|
8
|
+
required: [structure, quality, patterns]
|
|
9
|
+
properties:
|
|
10
|
+
structure:
|
|
11
|
+
description: Structure analysis (typed JSON)
|
|
12
|
+
quality:
|
|
13
|
+
description: Quality analysis (typed JSON)
|
|
14
|
+
patterns:
|
|
15
|
+
description: Pattern analysis (typed JSON)
|
|
16
|
+
|
|
17
|
+
output:
|
|
18
|
+
format: json
|
|
19
|
+
schema: schemas/synthesis.schema.json
|
|
20
|
+
|
|
21
|
+
prompt:
|
|
22
|
+
system: synthesizer/system.md
|
|
23
|
+
task: synthesizer/task.md
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
name: verifier
|
|
2
|
+
role: quality
|
|
3
|
+
description: Verifies step outputs against declared intent and success criteria
|
|
4
|
+
|
|
5
|
+
tools: [read, bash, grep, find]
|
|
6
|
+
|
|
7
|
+
output:
|
|
8
|
+
format: json
|
|
9
|
+
schema: schemas/verifier-output.schema.json
|
|
10
|
+
|
|
11
|
+
prompt:
|
|
12
|
+
task: verifier/task.md
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@davidorex/pi-workflows",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Workflow orchestration extension for Pi",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "David Ryan",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"keywords": ["pi-package"],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/davidorex/pi-project-workflows.git",
|
|
12
|
+
"directory": "packages/pi-workflows"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/davidorex/pi-project-workflows/tree/main/packages/pi-workflows",
|
|
15
|
+
"pi": {
|
|
16
|
+
"extensions": ["./src/index.ts"]
|
|
17
|
+
},
|
|
18
|
+
"files": ["src/", "agents/", "schemas/", "workflows/", "templates/", "*.md"],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "node --experimental-strip-types run-tests.ts",
|
|
21
|
+
"release": "npx changelogen --bump --release",
|
|
22
|
+
"release:patch": "npx changelogen --bump --release --patch",
|
|
23
|
+
"release:minor": "npx changelogen --bump --release --minor",
|
|
24
|
+
"release:major": "npx changelogen --bump --release --major",
|
|
25
|
+
"release:push": "git push --follow-tags"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"nunjucks": "^3.2.4",
|
|
29
|
+
"yaml": "^2.7.1"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@mariozechner/pi-coding-agent": "*",
|
|
33
|
+
"@mariozechner/pi-tui": "*",
|
|
34
|
+
"@sinclair/typebox": "*",
|
|
35
|
+
"@davidorex/pi-project": "*"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/nunjucks": "^3.2.6"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"required": ["specs", "ordering_rationale"],
|
|
4
|
+
"properties": {
|
|
5
|
+
"specs": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"required": ["name", "description", "files", "acceptance_criteria", "parallel_safe", "estimated_complexity"],
|
|
10
|
+
"properties": {
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Kebab-case identifier for this spec"
|
|
14
|
+
},
|
|
15
|
+
"description": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "What this spec implements — the unit of work"
|
|
18
|
+
},
|
|
19
|
+
"files": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": { "type": "string" },
|
|
22
|
+
"description": "File paths this spec will modify"
|
|
23
|
+
},
|
|
24
|
+
"depends_on": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": { "type": "string" },
|
|
27
|
+
"description": "Names of other specs that must complete before this one"
|
|
28
|
+
},
|
|
29
|
+
"acceptance_criteria": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": { "type": "string" },
|
|
32
|
+
"description": "How to verify this spec is correctly implemented"
|
|
33
|
+
},
|
|
34
|
+
"parallel_safe": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Whether this spec can run in parallel with other parallel_safe specs that have no file overlap"
|
|
37
|
+
},
|
|
38
|
+
"estimated_complexity": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": ["low", "medium", "high"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"ordering_rationale": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Why this ordering and parallelization structure was chosen"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"required": ["status", "tasks"],
|
|
4
|
+
"properties": {
|
|
5
|
+
"status": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"enum": ["complete", "partial", "failed"]
|
|
8
|
+
},
|
|
9
|
+
"tasks": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"items": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"required": ["name", "status"],
|
|
14
|
+
"properties": {
|
|
15
|
+
"name": { "type": "string" },
|
|
16
|
+
"status": { "type": "string", "enum": ["done", "partial", "skipped", "failed"] },
|
|
17
|
+
"files_modified": { "type": "array", "items": { "type": "string" } },
|
|
18
|
+
"commit_hash": { "type": "string" },
|
|
19
|
+
"notes": { "type": "string" }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"decisions": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"required": ["id", "decision", "rationale", "status"],
|
|
28
|
+
"properties": {
|
|
29
|
+
"id": { "type": "string" },
|
|
30
|
+
"decision": { "type": "string" },
|
|
31
|
+
"rationale": { "type": "string" },
|
|
32
|
+
"status": { "type": "string", "enum": ["decided", "deferred", "reversed"] }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"issues": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"required": ["severity", "description"],
|
|
41
|
+
"properties": {
|
|
42
|
+
"severity": { "type": "string", "enum": ["info", "warning", "error", "critical"] },
|
|
43
|
+
"description": { "type": "string" }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"test_count": { "type": "integer" },
|
|
48
|
+
"commit_hash": { "type": "string" }
|
|
49
|
+
}
|
|
50
|
+
}
|