@topce/pizx 0.4.0 → 0.6.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/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![GitHub Sponsors](https://img.shields.io/github/sponsors/topce?style=social&logo=github)](https://github.com/sponsors/topce)
4
4
 
5
- > **zx fork with native Pi AI integration** — 15 template tags for shell scripting, AI text generation, coding agents, agentic patterns, communication, and orchestration topologies.
5
+ ![pizx zx fork with native Pi AI integration](github-social-banner.png)
6
+
7
+ > **zx fork with native Pi AI integration** — 15 agent pattern tags (plus shell and AI core) for shell scripting, AI text generation, coding agents, agentic patterns, multi-agent communication, and orchestration topologies.
6
8
 
7
9
  ## Quick Start
8
10
 
@@ -46,7 +48,7 @@ npm install @topce/pizx
46
48
 
47
49
  **Prerequisites:**
48
50
  - Node.js >= 22.19.0
49
- - [Pi AI](https://github.com/earendil-works/pi-ai) installed and configured (`pi auth login`)
51
+ - [Pi AI](https://github.com/earendil-works/pi) installed and configured (`pi auth login`)
50
52
  - Shell commands from [zx](https://github.com/google/zx) (`$`, `cd`, `echo`, `fetch`, etc.)
51
53
 
52
54
  ## Writing Scripts
@@ -66,14 +68,44 @@ echo(intro)
66
68
  ```js
67
69
  import { $, π, Π, Ρ, Φ, Σ } from '@topce/pizx'
68
70
 
71
+ // Greek letters work everywhere...
69
72
  const output = await $`ls src/ | grep '.ts'`
70
73
  console.log(output.stdout)
71
74
 
72
75
  const review = await π`review this code for issues:\n${output.stdout}`
73
76
  console.log(review.text)
74
77
 
75
- // Use the coding agent to fix issues
76
- await Π`fix the TypeScript errors in src/`
78
+ // ...and so do English word aliases:
79
+ import { pi, Pi, ralph, fleet, subagent } from '@topce/pizx'
80
+
81
+ const answer = await pi`explain async/await`
82
+ await Pi`fix the TypeScript errors in src/`
83
+ await fleet`review all files in src/`
84
+ ```
85
+
86
+ > **English word aliases**: Every Greek letter tag has an English alternative.
87
+ > `pi` (alias for `π`), `Pi` (alias for `Π`), `fleet` (alias for `Φ`), `ralph` (alias for `Ρ`),
88
+ > `pipeline` (alias for `Λ`), etc. — use whichever style you prefer. See [full mapping](#english-aliases) below.
89
+
90
+ ### Global Access (pizx/globals)
91
+
92
+ Import the `pizx/globals` module to make **all tags and English aliases** available without explicit imports — matching the `#!/usr/bin/env pizx` shebang experience inside scripts loaded via `import()`:
93
+
94
+ ```js
95
+ import '@topce/pizx/globals'
96
+
97
+ // All Greek tags are available without imports:
98
+ const answer = await π`explain async/await`
99
+ await Π`fix the lint issues`
100
+ await Φ`review all files`
101
+
102
+ // English aliases too:
103
+ const docs = await fleet`check all .ts files`
104
+ const plan = await orchestrator`design the architecture`
105
+
106
+ // Helpers:
107
+ configurePi({ model: 'anthropic/claude-sonnet-4-5' })
108
+ closeAgent()
77
109
  ```
78
110
 
79
111
  ### CLI Quick Queries
@@ -126,6 +158,24 @@ Each tag has detailed documentation in [`docs/`](docs/):
126
158
  | `Χ` | Chi | Analyze traces → extract patterns | [docs/chi.md](docs/chi.md) |
127
159
  | `Τ` | Tau | Define schema → write → refine → consolidate | [docs/tau.md](docs/tau.md) |
128
160
 
161
+ ### English Aliases
162
+
163
+ Every Greek letter tag has an equivalent English word. They're interchangeable — use whichever style you prefer.
164
+
165
+ | Greek | English | Greek | English |
166
+ |-------|---------|-------|---------|
167
+ | `π` | `pi` | `Π` | `Pi` |
168
+ | `Ρ` | `ralph` | `Φ` | `fleet` |
169
+ | `Σ` | `subagent` | `Δ` | `debate` |
170
+ | `Λ` | `pipeline` | `Ψ` | `critique` |
171
+ | `Ω` | `orchestrator` | `Ν` | `team` |
172
+ | `Θ` | `thread` | `Μ` | `memory` |
173
+ | `Β` | `broadcast` | `Α` | `adaptive` |
174
+ | `Γ` | `graph` | `Χ` | `learn` |
175
+ | `Τ` | `store` | | |
176
+
177
+ See [`english-examples/`](english-examples/) for runnable examples using all English aliases.
178
+
129
179
  ## Architecture
130
180
 
131
181
  See [docs/decisions/](docs/decisions/) for Architecture Decision Records covering the key design choices:
@@ -164,7 +214,10 @@ await Ω({ system: 'You are a senior security architect.' })`design an auth syst
164
214
 
165
215
  ### Quality Validation
166
216
 
167
- All 15 patterns support an optional `qualityCheck` flag. When enabled, the pattern runs a post-execution LLM review that scores the final output (0.0–1.0), provides an assessment, and recommends improvements:
217
+ 12 patterns support an optional `qualityCheck` flag. When enabled, the pattern runs a post-execution LLM review that scores the final output (0.0–1.0), provides an assessment, and recommends improvements:
218
+
219
+ Supported by: `Ω` (Orchestrator), `Φ` (Fleet), `Σ` (Subagents), `Δ` (Debate), `Λ` (Pipeline), `Θ` (Thread), `Μ` (Memory), `Β` (Broadcast), `Γ` (Graph), `Ν` (Nu/Team), `Χ` (Chi/Learn), `Τ` (Tau/Store).
220
+ Not applicable to: `Ρ` (Ralph Loop — has its own review phase), `Α` (Adaptive), `Ψ` (Critique).
168
221
 
169
222
  ```js
170
223
  const result = await Ω({ qualityCheck: true })`design the system architecture`
@@ -190,7 +243,32 @@ await Ω({ confirm: true })`design the system`
190
243
  // → "Proceed? [Y/n] "
191
244
  ```
192
245
 
193
- Supported by: `Ω`, `Σ`, `Φ`, `Λ` (more patterns coming).
246
+ Supported by: `Ω`, `Σ`, `Φ`, `Λ`.
247
+
248
+ ### Agent Mode (File Tools for Any Pattern)
249
+
250
+ By default, all patterns (except `Pi` and `ralph`) use **text generation** — they can read files only if you pass content in via template interpolation. `ralph` already uses coding agent tools when `useTools: true` (default).
251
+
252
+ Set `mode: 'agent'` to give every subtask the same **coding agent tools** as `Pi`:
253
+
254
+ ```js
255
+ // Fleet workers can read files
256
+ await fleet({ mode: 'agent' })`read package.json and analyze the project`
257
+
258
+ // Pipeline stages can edit code
259
+ await pipeline({ mode: 'agent' })`read src/ and refactor the error handling`
260
+
261
+ // Orchestrator workers can run commands
262
+ await orchestrator({ mode: 'agent' })`check the test coverage and report gaps`
263
+
264
+ // Debate perspectives can research the codebase
265
+ await debate({ mode: 'agent' })`read the architecture docs and debate the design`
266
+ ```
267
+
268
+ Available tools: `read`, `bash`, `edit`, `write`, `grep`, `ls`.
269
+
270
+ Supported by: all patterns (`fleet`, `orchestrator`, `pipeline`, `debate`, `subagent`, `critique`, `thread`, `memory`, `broadcast`, `adaptive`, `graph`, `team`, `learn`, `store`).
271
+ Not applicable to: `pi`/`π` (always text), `Pi`/`Π` and `ralph` (already use coding agent).
194
272
 
195
273
  ### Option Chaining & Quiet Mode
196
274
 
@@ -205,7 +283,7 @@ await Θ({ agents: 4, turns: 3 })`debate the architecture`
205
283
  await Γ({ graph: { nodes: [...], edges: [...] } })`execute workflow`
206
284
  ```
207
285
 
208
- ### Timeout & Retry
286
+ ### Timeout, Retry & API Key
209
287
 
210
288
  All tags accept `timeoutMs` and `maxRetries` to control LLM call resilience. When unset, the provider SDK defaults apply (typically 10 min timeout, 2 retries).
211
289
 
@@ -220,6 +298,23 @@ await π({ timeoutMs: 15000 })`summarize this document`
220
298
  configurePi({ timeoutMs: 60000, maxRetries: 3 })
221
299
  ```
222
300
 
301
+ Use `apiKey` to specify a provider API key directly, bypassing environment variable lookup:
302
+
303
+ ```js
304
+ await π({ apiKey: 'sk-...' })`analyze this data`
305
+ await Ω({ apiKey: 'sk-...' })`design the system`
306
+ ```
307
+
308
+ ### Streaming (π.stream)
309
+
310
+ For real-time streaming, use `π.stream` as an async generator:
311
+
312
+ ```js
313
+ for await (const chunk of π.stream`tell me a long story`) {
314
+ process.stdout.write(chunk)
315
+ }
316
+ ```
317
+
223
318
  ### Token, Cost & Phase Tracking
224
319
 
225
320
  Every pattern output and π call includes an execution trace with token usage, cost, and a structured phase log. All collected automatically — no extra flags needed.
@@ -297,6 +392,9 @@ All tags accept `system` (replaces default) and `appendSystemPrompt` (appended a
297
392
  // π: custom system prompt
298
393
  await π({ system: 'You are a security auditor' })`review this code`
299
394
 
395
+ // π: with appendSystemPrompt
396
+ await π({ appendSystemPrompt: 'Respond in JSON format' })`list all .ts files`
397
+
300
398
  // Π: set system prompt and append extra instructions
301
399
  await Π({ system: 'You are a test engineer', appendSystemPrompt: 'Write tests first' })`add tests for auth`
302
400
 
@@ -304,6 +402,15 @@ await Π({ system: 'You are a test engineer', appendSystemPrompt: 'Write tests f
304
402
  await Ω({ system: 'Prioritize security over performance' })`design login flow`
305
403
  ```
306
404
 
405
+ ### closeAgent()
406
+
407
+ Dispose the shared Pi coding agent session (`Π`). Useful in long-running scripts or tests to reset state:
408
+
409
+ ```js
410
+ import { closeAgent } from '@topce/pizx'
411
+ await closeAgent() // dispose shared agent session
412
+ ```
413
+
307
414
  ### Thinking Budgets
308
415
 
309
416
  Fine-grained token budgets per reasoning level. Passes through to providers via `thinkingBudgets`.
@@ -352,15 +459,15 @@ pizx --help # Print help
352
459
  **Options:**
353
460
  - `-p, --prompt <text>` — Run a quick pi-ai query (no script needed)
354
461
  - `-m, --model <id>` — Specify AI model to use
355
- - `--quiet` — Suppress output except errors
356
- - `--shell <path>` — Shell to use (default: auto-detect)
462
+ - `-q, --quiet` — Suppress status output
463
+ - `--system <text>` — System context for pi-ai (print mode only)
357
464
 
358
465
  ## Commands
359
466
 
360
467
  ```bash
361
468
  npm run build # Build (JS + DTS)
362
469
  npm run check # Lint and format with Biome
363
- npm test # 223 unit tests (no network)
470
+ npm test # 311 unit tests (no network)
364
471
  npm run test:integration # Integration tests (requires Pi credentials)
365
472
  npm run test:quality # Run qualityCheck example
366
473
  npm run test:confirm # Run confirm gate example
@@ -380,10 +487,40 @@ See [`examples/`](examples/) for runnable examples of every pattern and feature:
380
487
  - [`hello-pizx.mjs`](examples/hello-pizx.mjs) — Basic script with shell + AI
381
488
  - [`basic-pi.mjs`](examples/basic-pi.mjs) — π text generation
382
489
  - [`basic-capital-pi.mjs`](examples/basic-capital-pi.mjs) — Π coding agent
383
- - [`pattern-ralph.mjs`](examples/pattern-ralph.mjs) — Ralph Loop
490
+ - [`quick-ask.mjs`](examples/quick-ask.mjs) — Quick π query
491
+ - [`ralph-loop.mjs`](examples/ralph-loop.mjs) — Ralph Loop (detailed)
492
+ - [`pattern-ralph.mjs`](examples/pattern-ralph.mjs) — Ralph Loop (concise)
384
493
  - [`pattern-fleet.mjs`](examples/pattern-fleet.mjs) — Fleet parallel execution
494
+ - [`pattern-subagent.mjs`](examples/pattern-subagent.mjs) — Subagents delegation
385
495
  - [`pattern-debate.mjs`](examples/pattern-debate.mjs) — Multi-perspective debate
386
- - ... and more for every pattern
496
+ - [`pattern-orchestrator.mjs`](examples/pattern-orchestrator.mjs) Orchestrator
497
+ - [`pattern-pipeline.mjs`](examples/pattern-pipeline.mjs) — Pipeline chain
498
+ - [`pattern-critique.mjs`](examples/pattern-critique.mjs) — Critique loop
499
+ - [`pattern-thread.mjs`](examples/pattern-thread.mjs) — Thread conversation
500
+ - [`pattern-memory.mjs`](examples/pattern-memory.mjs) — Memory blackboard
501
+ - [`pattern-broadcast.mjs`](examples/pattern-broadcast.mjs) — Broadcast messaging
502
+ - [`pattern-adaptive.mjs`](examples/pattern-adaptive.mjs) — Adaptive workflow
503
+ - [`pattern-graph.mjs`](examples/pattern-graph.mjs) — DAG execution
504
+ - [`pattern-nu.mjs`](examples/pattern-nu.mjs) — Self-organizing teams
505
+ - [`pattern-chi.mjs`](examples/pattern-chi.mjs) — Cross-agent learning
506
+ - [`pattern-tau.mjs`](examples/pattern-tau.mjs) — Tool-mediated store
507
+ - [`pattern-five-whys.mjs`](examples/pattern-five-whys.mjs) — Five Whys analysis
508
+ - [`pattern-tracking.mjs`](examples/pattern-tracking.mjs) — Token/cost tracking
509
+ - [`pattern-quality.mjs`](examples/pattern-quality.mjs) — Quality check demo
510
+ - [`pattern-timeout-retry.mjs`](examples/pattern-timeout-retry.mjs) — Timeout & retry demo
511
+ - [`pattern-system-propagation.mjs`](examples/pattern-system-propagation.mjs) — System prompt propagation
512
+
513
+ ### English Aliases Examples
514
+
515
+ See [`english-examples/`](english-examples/) for runnable examples using all English aliases:
516
+
517
+ - [`english-hello.mjs`](english-examples/english-hello.mjs) — Hello world with English aliases
518
+ - [`english-fleet.mjs`](english-examples/english-fleet.mjs) — Fleet via English aliases
519
+ - [`english-debate.mjs`](english-examples/english-debate.mjs) — Debate via English aliases
520
+ - [`english-orchestrator.mjs`](english-examples/english-orchestrator.mjs) — Orchestrator via English aliases
521
+ - [`english-pipeline.mjs`](english-examples/english-pipeline.mjs) — Pipeline via English aliases
522
+ - [`english-all-patterns.mjs`](english-examples/english-all-patterns.mjs) — All patterns via English aliases
523
+ - [`english-import-verify.mjs`](english-examples/english-import-verify.mjs) — Verify all imports
387
524
 
388
525
  ### New Feature Demos
389
526
 
@@ -395,3 +532,10 @@ See [`examples/`](examples/) for runnable examples of every pattern and feature:
395
532
  ## License
396
533
 
397
534
  MIT
535
+
536
+ ## Credits
537
+
538
+ Built on the shoulders of two outstanding tools:
539
+
540
+ - [**zx**](https://github.com/google/zx) by [Anton Medvedev](https://github.com/antonmedv) — the original shell scripting tool for Node.js that popularized template-tag ergonomics for command execution. pizx preserves every zx API (`$`, `cd`, `echo`, `fetch`, `chalk`, etc.) unchanged.
541
+ - [**Pi**](https://github.com/earendil-works/pi) by Mario Zechner / Earendil Works — the unified LLM API and coding agent harness that powers all `π`, `Π`, and pattern tags through `@earendil-works/pi-ai` and `@earendil-works/pi-coding-agent`.