pi-pipelines 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 ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to pi-pipelines will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [0.1.0] — 2026-06-11
11
+
12
+ ### Added
13
+
14
+ - **Initial release** — declarative multi-agent pipelines as a Pi extension.
15
+ - YAML pipeline definitions (`.pi/pipelines/*.pipeline.yaml`) with validation.
16
+ - Three stage types: sequential, parallel (fan-out), and review gates (scoring loops).
17
+ - Dynamic stage expansion (`expand.from`) — fan out one stage into N parallel stages from structured output.
18
+ - Automatic pipeline report synthesis after all stages complete.
19
+ - Stage output compression (`report: summary`) for long-running pipelines.
20
+ - Template variables: `{task}`, `{outputs.*}`, `{lastFeedback}`, `{item}`, `{item.*}`.
21
+ - LLM-callable tools: `run_pipeline` and `list_pipelines` with prompt guidelines.
22
+ - TUI status widget showing pipeline progress and results.
23
+ - Auto-discovery: `/pipeline-<name>` commands generated per pipeline definition.
24
+ - Auto-seed: bundled pipelines copied to `~/.pi/pipelines/` on first startup.
25
+ - 5 built-in example pipelines: `hello-world`, `tdd-review`, `dev-sprint`, `release-check`, `refactor`.
26
+ - Complete skill (`skills/pi-pipelines/SKILL.md`) for agent to create and manage pipelines autonomously.
27
+ - Per-round timeouts in review gates (10 min worker, 5 min reviewer).
28
+ - ESLint + Prettier configuration with `pnpm check` pre-publish hook.
29
+ - 314 tests with 97.4% code coverage.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pi Pipelines
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,367 @@
1
+ # 🧩 Pi Pipelines
2
+
3
+ > Declarative multi-agent pipelines for Pi — with review gates, scoring loops, parallel execution, and dynamic stage expansion.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/pi-pipelines?style=flat-square)](https://www.npmjs.com/package/pi-pipelines)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
7
+ [![Pi](https://img.shields.io/badge/pi-%E2%89%A50.74-5B5BD6?style=flat-square)](https://pi.dev)
8
+ [![Test Status](https://img.shields.io/badge/tests-314%20passing-brightgreen?style=flat-square)](https://github.com/Rybens92/pi-pipelines)
9
+ [![Code Coverage](https://img.shields.io/badge/coverage-97.4%25-brightgreen?style=flat-square)](https://github.com/Rybens92/pi-pipelines)
10
+
11
+ ---
12
+
13
+ ## 💡 Why This Exists
14
+
15
+ Recently, there's been a lot of discussion on social media about **agent loops** — the idea that an AI agent shouldn't just produce output and move on, but should iterate on its work through review and refinement loops. The conversation has been especially active around AI, LLMs, and agent harnesses.
16
+
17
+ This project is a small attempt to implement something like that as a **Pi extension**.
18
+
19
+ **My interpretation of loops** is first and foremost a **review process**: having AI review what AI already produced, then iterating on it until it reaches a quality target. The reviewer agents run in a different context than the main workflow — they are independent, focused evaluators that ensure the primary agent's work is at the right level. That's what review gates in this project are built for.
20
+
21
+ There's also talk about **agent/subagent recurrence** as the next step beyond loops. My answer to that in this project is **Dynamic Stage Expansion** — a mechanism that takes structured output from one stage (e.g., a list of files, topics, or tasks discovered by a scout agent), and dynamically fans them out into N parallel worker stages. It's not true agent recursion yet — it's an attempt to move in that direction, and I'm open to where that leads.
22
+
23
+ The result is a system where you can:
24
+
25
+ - Define multi-agent workflows as **YAML files** (manually)
26
+ - **Ask the agent** to create pipelines for you using the built-in skill
27
+ - Run **automated pipelines** that chain together exploration, planning, implementation, review, and verification into repeatable workflows
28
+
29
+ ---
30
+
31
+ ## 📦 Install
32
+
33
+ ### Prerequisites
34
+
35
+ | Requirement | Version | Install |
36
+ |---|---|---|
37
+ | [Pi](https://pi.dev) | `>= 0.74` | `npm install -g @earendil-works/pi-coding-agent` |
38
+ | [pi-subagents](https://github.com/Rybens92/pi-subagents) | latest | `pi install npm:pi-subagents` |
39
+
40
+ ### Install the extension
41
+
42
+ ```bash
43
+ # From npm (recommended)
44
+ pi install npm:pi-pipelines
45
+
46
+ # From GitHub
47
+ pi install git:github.com/Rybens92/pi-pipelines
48
+
49
+ # From a local path
50
+ pi install /path/to/pi-pipelines
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 🚀 Quick Start
56
+
57
+ ```bash
58
+ # 1. Create a pipeline directory
59
+ mkdir -p .pi/pipelines
60
+
61
+ # 2. Create a pipeline file
62
+ cat > .pi/pipelines/hello.pipeline.yaml << 'EOF'
63
+ name: hello
64
+ description: "Quick project exploration and action plan"
65
+
66
+ stages:
67
+ - id: explore
68
+ agent: scout
69
+ task: "Explore the project for: {task}"
70
+ - id: plan
71
+ agent: planner
72
+ task: "Create a plan based on: {outputs.explore}"
73
+ EOF
74
+
75
+ # 3. Run it (via command)
76
+ /run-pipeline hello "Add user authentication"
77
+
78
+ # 4. Or discover available pipelines
79
+ /list-pipelines
80
+ ```
81
+
82
+ ### Letting the Agent Create Pipelines for You
83
+
84
+ The extension ships with a [built-in skill](skills/pi-pipelines/SKILL.md) that teaches the Pi agent how to create, validate, and run pipeline definitions. The agent can generate complete pipeline YAML files based on your description, place them in the right directory, and even test them. Just describe what you want and the agent will handle the rest.
85
+
86
+ Try saying: *"Create a code review pipeline with a security gate"* — the agent will use the skill to build it for you.
87
+
88
+ ---
89
+
90
+ ## ✨ Features
91
+
92
+ ### 🎯 Declarative YAML Pipelines
93
+ Define entire workflows in `.pi/pipelines/*.pipeline.yaml`. No code, just YAML.
94
+
95
+ ### 🔄 Three Stage Types
96
+
97
+ | Stage Type | Description |
98
+ |---|---|
99
+ | **Sequential** | Agents run one after another, passing outputs via `{outputs.stageId}` |
100
+ | **Parallel** | Fan-out to multiple agents concurrently for independent work |
101
+ | **Review Gate** | Worker → parallel reviewers → score → retry loop until quality target is met |
102
+
103
+ ### 📊 Review Gates with Scoring — The Loop Pattern
104
+
105
+ This is the core idea: **AI reviewing what AI produced, iterating until it's good enough.**
106
+
107
+ ```
108
+ Round 1: Worker → 3 Reviewers (parallel, independent context) → Avg Score: 7.3
109
+ ❌ 7.3 < 9.0 → Feedback collected → Round 2
110
+
111
+ Round 2: Worker (with feedback from round 1) → 3 Reviewers → Avg Score: 9.3
112
+ ✅ PASS — quality target met
113
+ ```
114
+
115
+ Each reviewer runs in its own context — isolated from the worker and from each other — to provide an independent quality assessment. They score on a 0–10 scale. The worker retries with the collected feedback until the average meets `targetScore` or `maxRounds` is exhausted.
116
+
117
+ ### 🧩 Dynamic Stage Expansion — Towards Agent Recurrence
118
+
119
+ Some people on X (formerly Twitter) argue that the future of agentic workflows isn't just loops, but **recurrence** — agents spawning subagents that spawn further subagents, recursively decomposing work.
120
+
121
+ Dynamic Stage Expansion is this project's take on that idea. It takes structured output from one stage (JSON, YAML, or a markdown list) and dynamically fans it out into N parallel stages. It's not true agent recursion — each expansion is one level deep and each expanded stage runs the same agent type. But it's a step in that direction, and it's already useful for real workflows.
122
+
123
+ ```yaml
124
+ stages:
125
+ - id: find-files
126
+ agent: scout
127
+ task: "Return JSON files to refactor: [{\"path\":\"...\"}, ...]"
128
+
129
+ - id: refactor-each
130
+ expand:
131
+ from: find-files
132
+ maxItems: 10
133
+ agent: worker
134
+ task: "Refactor {item.path}"
135
+ ```
136
+
137
+ ### 🔗 Template Variables
138
+
139
+ | Variable | Resolves to |
140
+ |---|---|
141
+ | `{task}` | Original user task passed to the pipeline |
142
+ | `{outputs.<stageId>}` | Output from a previous stage |
143
+ | `{lastFeedback}` | Latest review feedback (auto-injected in gate retries) |
144
+ | `{item}` | Whole item from dynamic stage expansion |
145
+ | `{item.<key>}` | Single field from a dynamic expansion item |
146
+
147
+ ### 🤖 LLM-Friendly Tools
148
+ Pi Pipelines registers tools that the LLM can use:
149
+
150
+ | Tool | Purpose |
151
+ |---|---|
152
+ | `run_pipeline({ pipeline, task })` | Execute any defined pipeline |
153
+ | `list_pipelines({ query? })` | Discover and filter available pipelines |
154
+
155
+ ### 📋 Automatic Report Synthesis
156
+ After all stages complete, a synthesis agent automatically generates a structured report of what was accomplished, key findings, issues, and next steps.
157
+
158
+ ---
159
+
160
+ ## 📚 Built-in Pipelines
161
+
162
+ The extension ships with 5 example pipelines. They're automatically copied to `~/.pi/pipelines/` on first run.
163
+
164
+ | Pipeline | Stages | Gates | Use Case |
165
+ |---|---|---|---|
166
+ | `hello-world` | 2 | 0 | Smoke test / quick exploration |
167
+ | `tdd-review` | 5 | 2 | Feature implementation with test + code quality gates |
168
+ | `dev-sprint` | 6 | 2 | Full development cycle with project review |
169
+ | `release-check` | 2 | 0 | Pre-release quality: code review, security audit, stability |
170
+ | `refactor` | 5 | 1 | Safe refactoring with regression verification |
171
+
172
+ Use them as-is or as templates for your own pipelines.
173
+
174
+ ---
175
+
176
+ ## 🏗️ Creating Custom Pipelines
177
+
178
+ ### Three ways to create pipelines
179
+
180
+ | Method | When to use |
181
+ |---|---|
182
+ | **Manually** — write `.pipeline.yaml` files in `.pi/pipelines/` | When you know exactly what you want |
183
+ | **Via the agent** — describe your workflow, the agent uses the built-in skill to write the YAML | When you want the LLM to handle the details |
184
+ | **Copy and modify** — fork one of the 5 built-in pipelines | The fastest way to get started |
185
+
186
+ ### Minimal Pipeline
187
+
188
+ ```yaml
189
+ # .pi/pipelines/my-pipeline.pipeline.yaml
190
+ name: my-pipeline
191
+ description: "Short description"
192
+
193
+ stages:
194
+ - id: explore
195
+ agent: scout
196
+ task: "Explore: {task}"
197
+
198
+ - id: plan
199
+ agent: planner
200
+ task: "Plan based on: {outputs.explore}"
201
+ ```
202
+
203
+ ### Pipeline with a Review Gate
204
+
205
+ ```yaml
206
+ stages:
207
+ - id: implement
208
+ agent: worker
209
+ task: "Implement: {outputs.analyze}"
210
+ gate:
211
+ type: review-loop
212
+ maxRounds: 3 # Default: 3
213
+ targetScore: 8 # Default: 8 (use 9 for tests)
214
+ reviewers:
215
+ - focus: "Does the implementation satisfy all criteria?"
216
+ - focus: "Is the code clean and maintainable?"
217
+ - focus: "Are error paths handled correctly?"
218
+ ```
219
+
220
+ ### Parallel Stage
221
+
222
+ ```yaml
223
+ stages:
224
+ - id: checks
225
+ parallel:
226
+ - id: code-review
227
+ agent: reviewer
228
+ task: "Review code quality: {task}"
229
+ - id: security
230
+ agent: reviewer
231
+ task: "Security audit: {task}"
232
+ - id: perf
233
+ agent: scout
234
+ task: "Performance analysis: {task}"
235
+
236
+ - id: decision
237
+ agent: planner
238
+ task: >
239
+ Based on:
240
+ Code Review: {outputs.code-review}
241
+ Security: {outputs.security}
242
+ Decide next steps.
243
+ ```
244
+
245
+ ### Expand Stage (Dynamic)
246
+
247
+ ```yaml
248
+ stages:
249
+ - id: research
250
+ agent: researcher
251
+ task: >
252
+ Find topics for: {task}.
253
+ Return JSON: [{"title":"...","angle":"..."}]
254
+
255
+ - id: write-posts
256
+ expand:
257
+ from: research
258
+ maxItems: 5
259
+ agent: worker
260
+ task: "Write blog post: {item.title}. Angle: {item.angle}"
261
+ ```
262
+
263
+ For the full pipeline authoring guide with all configuration options, see [skills/pi-pipelines/SKILL.md](skills/pi-pipelines/SKILL.md).
264
+
265
+ ---
266
+
267
+ ## 📐 Architecture
268
+
269
+ ```
270
+ User / LLM
271
+
272
+ ├── /run-pipeline <name> <task> (TUI command)
273
+ ├── /pipeline-<name> <task> (dedicated command per pipeline)
274
+ └── run_pipeline() / list_pipelines() (LLM tools)
275
+
276
+
277
+ Pi Pipelines Extension (TypeScript)
278
+
279
+ ├── config-loader.ts — Parse & validate YAML pipeline definitions
280
+ ├── pipeline-runner.ts — Orchestrate stages, gates, and expansions
281
+ ├── subagent-bridge.ts — Event bridge to pi-subagents (with fallback)
282
+ ├── tui-widgets.ts — TUI status widget for pipeline progress
283
+ └── utils.ts — Shared utilities
284
+
285
+
286
+ pi-subagents (event bridge)
287
+
288
+ └── Subagents (scout, planner, worker, reviewer, oracle, ...)
289
+ ```
290
+
291
+ ---
292
+
293
+ ## 📊 Project Status
294
+
295
+ | Metric | Status |
296
+ |---|---|
297
+ | Tests | 314 passing |
298
+ | Code Coverage | 97.4% statements, 90% branches |
299
+ | Linter | ESLint + Prettier (flat config) |
300
+ | Runtime | TypeScript (no build step — Pi loads via jiti) |
301
+ | Dependencies | 1 production dep (`js-yaml`) |
302
+
303
+ ---
304
+
305
+ ## 🤝 Contributing
306
+
307
+ Contributions are welcome! Please follow these steps:
308
+
309
+ 1. **Fork** the repository
310
+ 2. **Create a branch** for your feature or fix
311
+ 3. **Write tests** for your changes
312
+ 4. **Run the check suite**: `pnpm check` (lint + format + tests)
313
+ 5. **Open a pull request** with a clear description
314
+
315
+ ### Development Setup
316
+
317
+ ```bash
318
+ git clone https://github.com/Rybens92/pi-pipelines.git
319
+ cd pi-pipelines
320
+ pnpm install
321
+ pnpm test # Run tests (314 tests, ~700ms)
322
+ pnpm check # Full suite: lint + format + tests
323
+ pnpm test:coverage # With coverage report
324
+ ```
325
+
326
+ ### Code of Conduct
327
+
328
+ This project follows the [Contributor Covenant](https://www.contributor-covenant.org/).
329
+
330
+ ---
331
+
332
+ ## ❓ FAQ
333
+
334
+ **Q: Do I need pi-subagents?**
335
+ Yes. Pi Pipelines delegates agent execution to pi-subagents. Install it first: `pi install npm:pi-subagents`.
336
+
337
+ **Q: Can I use this without Pi?**
338
+ No. This is a Pi extension and requires the Pi CLI environment.
339
+
340
+ **Q: Do I need to build / compile TypeScript?**
341
+ No. Pi uses [jiti](https://github.com/unjs/jiti) to load TypeScript directly. No build step needed.
342
+
343
+ **Q: How many pipelines can I have?**
344
+ As many as you like. Each `.pipeline.yaml` file in `.pi/pipelines/` becomes a `/pipeline-<name>` command.
345
+
346
+ **Q: Can the agent create pipelines for me?**
347
+ Yes. The extension includes a [skill](skills/pi-pipelines/SKILL.md) that teaches the Pi agent how to create, validate, and manage pipeline YAML files. Just describe what you need.
348
+
349
+ **Q: What agents are available for pipeline stages?**
350
+
351
+ | Agent | Read-only | Edits files | Use case |
352
+ |---|---|---|---|
353
+ | `scout` | ✅ | ❌ | Code exploration and analysis |
354
+ | `planner` | ✅ | ❌ | Planning and synthesis |
355
+ | `worker` | ❌ | ✅ | Implementation — only one at a time |
356
+ | `reviewer` | ✅ | ❌ | Code review and quality assessment |
357
+ | `oracle` | ✅ | ❌ | Strategic analysis and second opinions |
358
+ | `researcher` | ✅ | ❌ | Web research (requires `pi-web-access`) |
359
+
360
+ **Q: How do reviewers score?**
361
+ Each reviewer ends their output with `SCORE: N` on the last line (0–10). The pipeline runner parses these scores automatically.
362
+
363
+ ---
364
+
365
+ ## 📝 License
366
+
367
+ [MIT](LICENSE) — Copyright (c) 2026 Pi Pipelines