|
| 1 | +# 🧱 Building Blocks |
| 2 | + |
| 3 | +> Marketplace-ready YAML presets — share, remix, and discover pipelines, agents, quality packs, and language packs. |
| 4 | +
|
| 5 | +<div class="slm-banner" markdown> |
| 6 | +<span class="slm-banner__emoji">🧱</span> |
| 7 | +<p class="slm-banner__text" markdown> |
| 8 | +<strong>Blocks are the foundation of extensibility.</strong> Every pipeline, every specialist agent, every quality check — all defined as portable YAML that anyone can create, share, and apply. |
| 9 | +</p> |
| 10 | +</div> |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## What are Building Blocks? |
| 15 | + |
| 16 | +Blocks are **versioned, marketplace-ready YAML packages** that define reusable configurations for the SLMCode pipeline. They come in four kinds: |
| 17 | + |
| 18 | +| Kind | Schema | Purpose | |
| 19 | +|------|--------|---------| |
| 20 | +| `pipeline` | `PipelineBlock` | Phase graph, loop agents, insertable slots | |
| 21 | +| `agent` | `AgentBlock` | Custom specialist definition or builtin override | |
| 22 | +| `quality` | `QualityBlock` | Format/lint/test/build commands per language | |
| 23 | +| `pack` | `PackBlock` | Composes pipeline + quality + agents + skills | |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Discovery Order |
| 28 | + |
| 29 | +Blocks are discovered in a priority chain. **First ID wins per kind:** |
| 30 | + |
| 31 | +1. **Project** — `.slmcode/blocks/{pipelines,agents,quality,packs}/*.yaml` |
| 32 | +2. **User** — `~/.slmcode/blocks/…` or `$XDG_CONFIG_HOME/slmcode/blocks/…` |
| 33 | +3. **Extra** — `$SLMCODE_BLOCKS` env var, walk-up `blocks/` dirs |
| 34 | +4. **Builtin** — embedded in `pkg/blocks/bundled/` (compiled into binary) |
| 35 | + |
| 36 | +This means **project overrides** always win. Drop a `.slmcode/blocks/pipelines/go.yaml` with your customizations, and it replaces the builtin Go pipeline for that project. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Common Schema (Meta) |
| 41 | + |
| 42 | +Every block YAML file shares this header: |
| 43 | + |
| 44 | +```yaml |
| 45 | +api_version: blocks/v1 # required — current schema version |
| 46 | +kind: pipeline # pipeline | agent | quality | pack |
| 47 | +id: my-block # lowercase kebab-case, 2-64 chars, [a-z][a-z0-9_-]+ |
| 48 | +name: My Block # human-readable display name |
| 49 | +description: A reusable block |
| 50 | +version: "1.0.0" |
| 51 | +author: UnicoLab |
| 52 | +license: MIT |
| 53 | +language: go # lowercase language code |
| 54 | +tags: [go, worker] |
| 55 | +icon: "🐹" |
| 56 | +shareable: true # marketplace-ready flag (default: true) |
| 57 | +``` |
| 58 | +
|
| 59 | +--- |
| 60 | +
|
| 61 | +## Predefined Language Packs (Builtin) |
| 62 | +
|
| 63 | +SLMCode ships with **three production-ready language packs:** |
| 64 | +
|
| 65 | +### 🐹 Go |
| 66 | +
|
| 67 | +``` |
| 68 | +Pipeline: go | Agents: go-worker, go-tester | Quality: go |
| 69 | +``` |
| 70 | +
|
| 71 | +- **Pipeline**: Go-aware execute phase with `go-tester` agent |
| 72 | +- **Worker**: Module-aware, uses `go test ./<pkg> -short` after edits |
| 73 | +- **Tester**: Full verify chain — `gofmt` → `go vet` → `go test -race` → `go build` |
| 74 | +- **QA Gate**: `go test ./... -race -count=1` |
| 75 | + |
| 76 | +### 🐍 Python |
| 77 | + |
| 78 | +``` |
| 79 | +Pipeline: python | Agents: python-worker, python-tester | Quality: python |
| 80 | +``` |
| 81 | +
|
| 82 | +- **Pipeline**: Python-aware with `python-tester` agent |
| 83 | +- **Worker**: PyProject-aware, smokes with `py_compile` + `pytest` |
| 84 | +- **Tester**: `ruff check` → `mypy` → `pytest` (uv-aware) |
| 85 | +- **QA Gate**: `python -m pytest -q` (or `uv run pytest -q`) |
| 86 | +
|
| 87 | +### ⚛️ React / TypeScript |
| 88 | +
|
| 89 | +``` |
| 90 | +Pipeline: react | Agents: react-worker, react-tester | Quality: react |
| 91 | +``` |
| 92 | +
|
| 93 | +- **Pipeline**: Frontend-aware with `react-tester` agent |
| 94 | +- **Worker**: Vite/Next-aware, smokes with `tsc --noEmit` |
| 95 | +- **Tester**: `npm run lint` → `tsc --noEmit` → `npm test` → `npm run build` |
| 96 | +- **QA Gate**: `npm test --silent` |
| 97 | +
|
| 98 | +--- |
| 99 | +
|
| 100 | +## CLI Commands |
| 101 | +
|
| 102 | +```bash |
| 103 | +# List all available blocks, grouped by kind |
| 104 | +slmcode blocks list |
| 105 | +
|
| 106 | +# Show details of a specific block |
| 107 | +slmcode blocks show pipeline go |
| 108 | +slmcode blocks show agent python-worker |
| 109 | +slmcode blocks show pack react |
| 110 | +
|
| 111 | +# Apply a language pack (writes pipeline.yaml + config) |
| 112 | +slmcode blocks apply go |
| 113 | +slmcode blocks apply go --materialize-agents |
| 114 | +
|
| 115 | +# Validate all block YAML configs |
| 116 | +slmcode blocks validate |
| 117 | +``` |
| 118 | + |
| 119 | +In the interactive chat REPL: |
| 120 | + |
| 121 | +``` |
| 122 | +/pack go — apply the Go language pack |
| 123 | +/pack python — apply the Python language pack |
| 124 | +/blocks — list all available blocks |
| 125 | +``` |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +## Creating Custom Blocks |
| 130 | + |
| 131 | +### Pipeline Block |
| 132 | + |
| 133 | +Save as `.slmcode/blocks/pipelines/my-pipeline.yaml`: |
| 134 | + |
| 135 | +```yaml |
| 136 | +api_version: blocks/v1 |
| 137 | +kind: pipeline |
| 138 | +id: my-lang |
| 139 | +name: My Language Pipeline |
| 140 | +version: "1.0.0" |
| 141 | +language: rust |
| 142 | +tags: [rust, pipeline] |
| 143 | +icon: "🦀" |
| 144 | +spec: |
| 145 | + version: 1 |
| 146 | + order: [init, skills, context, explore, plan, split, coord, execute, learn, test, memory, done] |
| 147 | + groups: |
| 148 | + - {id: prepare, label: Prepare, steps: [init, skills, context, explore]} |
| 149 | + - {id: design, label: Design, steps: [plan, split]} |
| 150 | + - {id: build, label: Build, steps: [coord, execute, learn]} |
| 151 | + - {id: verify, label: Verify, steps: [test]} |
| 152 | + - {id: finish, label: Finish, steps: [memory, done]} |
| 153 | + phases: |
| 154 | + init: {agent: "", when: always, label: Init} |
| 155 | + context: {agent: context, when: always, label: Context} |
| 156 | + explore: {agent: explorer, when: auto, label: Explore} |
| 157 | + plan: {agent: planner, when: always, label: Plan} |
| 158 | + split: {agent: splitter, when: always, label: Split} |
| 159 | + coord: {agent: coordinator, when: always, label: Coord} |
| 160 | + execute: {agent: worker, when: always, label: Execute} |
| 161 | + test: {agent: tester, when: always, label: Test} |
| 162 | + memory: {agent: memory, when: always, label: Memory} |
| 163 | + done: {agent: "", when: always, label: Done} |
| 164 | + execute: |
| 165 | + default_role: worker |
| 166 | + reviewer: reviewer |
| 167 | + corrector: corrector |
| 168 | + max_waves: 2 |
| 169 | + slots: |
| 170 | + - id: quality-reminder |
| 171 | + agent: tester |
| 172 | + title: Quality reminder |
| 173 | + before: execute |
| 174 | + when: always |
| 175 | + persist_to: scratch |
| 176 | + fail_mode: continue |
| 177 | + input: | |
| 178 | + Remember quality bar: cargo clippy, cargo test, cargo build |
| 179 | + Query: {{query}} |
| 180 | +``` |
| 181 | +
|
| 182 | +### Agent Block |
| 183 | +
|
| 184 | +Save as `.slmcode/blocks/agents/my-worker.yaml`: |
| 185 | + |
| 186 | +```yaml |
| 187 | +api_version: blocks/v1 |
| 188 | +kind: agent |
| 189 | +id: my-worker |
| 190 | +name: My Worker |
| 191 | +version: "1.0.0" |
| 192 | +language: rust |
| 193 | +tags: [rust, worker] |
| 194 | +icon: "🦀" |
| 195 | +spec: |
| 196 | + id: my-worker |
| 197 | + title: My Worker |
| 198 | + system_prompt: | |
| 199 | + You are a Rust implementation specialist. Stay inside HARD SCOPE. |
| 200 | + After edits, smoke with: cargo test -p <crate> |
| 201 | + tools: true |
| 202 | + max_iter: 16 |
| 203 | + temperature: 0.12 |
| 204 | + max_tokens: 3072 |
| 205 | + skills: [specialist-worker, atomic-coding] |
| 206 | +``` |
| 207 | + |
| 208 | +### Quality Block |
| 209 | + |
| 210 | +Save as `.slmcode/blocks/quality/my-lang.yaml`: |
| 211 | + |
| 212 | +```yaml |
| 213 | +api_version: blocks/v1 |
| 214 | +kind: quality |
| 215 | +id: my-lang |
| 216 | +name: My Lang Quality |
| 217 | +version: "1.0.0" |
| 218 | +language: rust |
| 219 | +spec: |
| 220 | + detect: |
| 221 | + files: [Cargo.toml] |
| 222 | + extensions: [.rs] |
| 223 | + priority: 20 |
| 224 | + lint: |
| 225 | + - {cmd: cargo clippy -- -D warnings, label: clippy} |
| 226 | + test: |
| 227 | + - {cmd: cargo test, label: cargo test} |
| 228 | + build: |
| 229 | + - {cmd: cargo build, label: cargo build} |
| 230 | + smoke: cargo test --quiet |
| 231 | + qa_gate: cargo test |
| 232 | + safe_prefixes: |
| 233 | + - cargo test |
| 234 | + - cargo build |
| 235 | + - cargo clippy |
| 236 | +``` |
| 237 | + |
| 238 | +### Pack Block |
| 239 | + |
| 240 | +Save as `.slmcode/blocks/packs/my-lang.yaml`: |
| 241 | + |
| 242 | +```yaml |
| 243 | +api_version: blocks/v1 |
| 244 | +kind: pack |
| 245 | +id: my-lang |
| 246 | +name: My Language Pack |
| 247 | +version: "1.0.0" |
| 248 | +language: rust |
| 249 | +spec: |
| 250 | + pipeline: my-lang |
| 251 | + quality: my-lang |
| 252 | + agents: [my-worker, my-tester] |
| 253 | + skills: [atomic-coding] |
| 254 | + pin_skills: true |
| 255 | + override_tester: my-tester |
| 256 | + override_worker: my-worker |
| 257 | +``` |
| 258 | + |
| 259 | +--- |
| 260 | + |
| 261 | +## Studio Integration |
| 262 | + |
| 263 | +The **BlockManager** page (navigate to Blocks in the sidebar) provides a visual browser for all available blocks: |
| 264 | + |
| 265 | +- **Tabbed interface**: All, Packs, Pipelines, Agents, Quality |
| 266 | +- **Cards** showing metadata: name, description, language, version, tags, source |
| 267 | +- **One-click Apply** for packs and pipelines |
| 268 | +- **Active indicators** showing which pack/pipeline is currently active |
| 269 | + |
| 270 | +The **PackSelector** in Settings lets you switch language packs directly from the settings page, alongside the Stack Selector. |
| 271 | + |
| 272 | +The **PipelineEditor** includes a preset selector that lets you switch between predefined pipeline configurations (Go, Python, React) with one click. |
| 273 | + |
| 274 | +--- |
| 275 | + |
| 276 | +## Validation |
| 277 | + |
| 278 | +```bash |
| 279 | +slmcode blocks validate |
| 280 | +``` |
| 281 | + |
| 282 | +Loads every block, calls `Validate()` on each, and for packs also verifies that all referenced pipelines, agents, and quality packs actually exist. Reports exact errors so you can fix YAML issues before running. |
| 283 | + |
| 284 | +--- |
| 285 | + |
| 286 | +## Marketplace-Ready |
| 287 | + |
| 288 | +All blocks are designed for sharing: |
| 289 | + |
| 290 | +- **Versioned** — Semantic versioning (`"1.0.0"`) |
| 291 | +- **Authored** — `author` and `license` fields |
| 292 | +- **Tagged** — `tags` for discovery and filtering |
| 293 | +- **Iconed** — `icon` for visual recognition in UI |
| 294 | +- **Shareable** — `shareable: true` flag for marketplace listing |
| 295 | + |
| 296 | +Drop your custom blocks into a GitHub repo's `blocks/` directory, and anyone can use them by setting the `SLMCODE_BLOCKS` environment variable. |
0 commit comments