|
1 | 1 | # network-ai · Examples |
2 | 2 |
|
3 | | -Runnable demos that show the core features in under five minutes. |
4 | | -All three examples work without an API key. |
| 3 | +Runnable demos that show the core features in under five minutes. |
5 | 4 |
|
6 | 5 | ``` |
7 | 6 | examples/ |
8 | | - 01-hello-swarm.ts ← three agents passing work through a blackboard |
9 | | - 02-fsm-pipeline.ts ← FSM governance (state-based access control) |
10 | | - 03-parallel-agents.ts ← parallel agents + four synthesis strategies |
| 7 | + 01-hello-swarm.ts ← three agents passing work through a blackboard (no API key) |
| 8 | + 02-fsm-pipeline.ts ← FSM governance (state-based access control) (no API key) |
| 9 | + 03-parallel-agents.ts ← parallel agents + four synthesis strategies (no API key) |
| 10 | + 05-code-review-swarm.ts ← 5-agent AI code review swarm, 4 modes (OPENAI_API_KEY required) |
11 | 11 | ``` |
12 | 12 |
|
| 13 | +Examples `01`–`03` run without any API key. `05` calls the OpenAI API — copy `.env.example` to `.env` and add your key before running it. |
| 14 | + |
13 | 15 | ## Prerequisites |
14 | 16 |
|
15 | 17 | ```bash |
@@ -79,10 +81,38 @@ npx ts-node examples/03-parallel-agents.ts |
79 | 81 | npx ts-node examples/01-hello-swarm.ts |
80 | 82 | npx ts-node examples/02-fsm-pipeline.ts |
81 | 83 | npx ts-node examples/03-parallel-agents.ts |
| 84 | + |
| 85 | +# 05 requires OPENAI_API_KEY in .env |
| 86 | +npx ts-node examples/05-code-review-swarm.ts |
82 | 87 | ``` |
83 | 88 |
|
84 | 89 | --- |
85 | 90 |
|
| 91 | +## 05 · Code Review Swarm |
| 92 | + |
| 93 | +A 5-agent swarm (Security, Performance, Reliability, Testing, Architecture) reviews code or documents in parallel, then a coordinator synthesizes the findings and a fixer agent applies them. Requires `OPENAI_API_KEY`. |
| 94 | + |
| 95 | +```bash |
| 96 | +# Setup (one time) |
| 97 | +cp .env.example .env # then add your key inside .env |
| 98 | + |
| 99 | +# Run |
| 100 | +npx ts-node examples/05-code-review-swarm.ts |
| 101 | +``` |
| 102 | + |
| 103 | +**4 modes at launch:** |
| 104 | + |
| 105 | +| Mode | Prompt | Output | |
| 106 | +|------|--------|--------| |
| 107 | +| `[1]` Built-in | Reviews the bundled `auth-service.ts` | Fixed `.ts` file | |
| 108 | +| `[2]` Paste code | Paste your own source (ends with `end`) | Fixed `.ts` file | |
| 109 | +| `[3]` System design | Paste a design/architecture doc | Revised `.md` file | |
| 110 | +| `[4]` Custom role | Define your own reviewers for any content | Revised `.md` file | |
| 111 | + |
| 112 | +Output files are saved to `examples/output/`. See the [YouTube demo](https://youtu.be/UyMsNhaw9lU) for a walkthrough. |
| 113 | + |
| 114 | +--- |
| 115 | + |
86 | 116 | ## Next steps |
87 | 117 |
|
88 | 118 | | Goal | Starting point | |
|
0 commit comments