@vpxa/aikit 0.1.57 → 0.1.59

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.
@@ -162,6 +162,154 @@ The dashboard uses a professional dark theme:
162
162
 
163
163
  ---
164
164
 
165
+ ## Architecture Diagrams
166
+
167
+ > **Behavioral rule:** When asked to present, visualize, or display system architecture, infrastructure, or service topology — **always load the `c4-architecture` skill** and use its HTML/SVG format (Method 2 below) for rich visual output via `present`. The Mermaid method (Method 1) is acceptable only for quick in-chat previews or when the user explicitly asks for Mermaid. Default to HTML/SVG for all architecture presentations.
168
+
169
+ The `present` tool can render C4-style architecture diagrams in both `html` and `browser` formats. The visual design system is centralized in the `c4-architecture` skill's reference file — load that skill for the full type registry, color palette, and template.
170
+
171
+ **Design system source:** `c4-architecture/references/html-design-system.md` (single source of truth for all architecture diagram styling)
172
+
173
+ ### When to Use (Auto-Trigger)
174
+
175
+ Load the `c4-architecture` skill and use HTML/SVG format when the user:
176
+ - Asks to "show architecture", "present the system design", "visualize infrastructure"
177
+ - Wants to display service topology, deployment layout, or component relationships
178
+ - Requests architecture review output, system overview dashboards, or technical presentations
179
+ - Uses words like "architecture diagram", "system diagram", "infrastructure diagram"
180
+
181
+ ### Rendering Methods
182
+
183
+ | Method | Block Type | Format | When to Use |
184
+ |--------|-----------|--------|-------------|
185
+ | Mermaid C4 | `mermaid` | html / browser | Quick diagrams, developer-focused, version-controlled |
186
+ | HTML/SVG | `markdown` | html / browser | Rich visual presentations, stakeholder reviews, dark-themed dashboards |
187
+
188
+ ### Method 1: Mermaid C4 Diagrams
189
+
190
+ Use a `mermaid` content block with standard C4 Mermaid syntax:
191
+
192
+ present({
193
+ format: "html", // or "browser"
194
+ title: "System Architecture",
195
+ content: [
196
+ {
197
+ type: "mermaid",
198
+ title: "C4 Container Diagram",
199
+ value: `C4Container
200
+ title Container Diagram - Payment System
201
+
202
+ Person(user, "Customer", "Places orders")
203
+
204
+ Container_Boundary(app, "Payment Platform") {
205
+
206
+ ---
207
+
208
+ ## Rendering Troubleshooting
209
+
210
+ ### Why `html` format sometimes shows raw text
211
+
212
+ The `html` format renders content inside an MCP Apps companion iframe (UIResource). The chat text fallback is intentionally minimal (just the title). When the UIResource fails to load, the user sees only the title or raw JSON — NOT the rendered dashboard.
213
+
214
+ **Common causes of UIResource rendering failure:**
215
+ 1. **MCP Apps not enabled** — The setting `chat.mcp.apps.enabled` must be `true` in VS Code settings
216
+ 2. **Companion app build missing** — The `packages/present` companion app must be built (`npm run build`)
217
+ 3. **Content too large** — Very large content arrays (20+ blocks or tables with 50+ rows) may cause the companion iframe to fail silently
218
+ 4. **Iframe loading error** — Network issues, CSP restrictions, or extension conflicts can prevent the iframe from loading
219
+
220
+ ### When to prefer `browser` over `html`
221
+
222
+ Use `format: "browser"` instead of `html` when:
223
+ - Content has **10+ blocks** or tables with **20+ rows** (large payloads are more reliable in browser)
224
+ - The output must be **guaranteed visible** (browser format always opens, no silent failures)
225
+ - You need **charts + tables + markdown** in the same view (browser renders all block types reliably)
226
+ - The user reports that `html` format "didn't show anything" or "showed raw text"
227
+
228
+ > **Reliability rule:** If content is complex (5+ blocks of mixed types), prefer `format: "browser"` for guaranteed rendering. The `html` format is best for simple, single-block content.
229
+
230
+ ### Content formatting tips to avoid rendering issues
231
+
232
+ 1. **Use `table` block type** instead of markdown tables inside `markdown` blocks — `table` blocks render natively; markdown pipe-tables may show as raw text in fallback
233
+ 2. **Use `cards` and `metrics`** for summary data instead of embedding it in markdown text
234
+ 3. **Keep `markdown` blocks for narrative text only** — don't embed HTML, tables, or complex formatting
235
+ 4. **Split large content** into multiple smaller `present` calls rather than one massive content array
236
+ 5. **For charts:** Always use ChartValue format (`chartType`, `data`, `xKey`, `yKeys`) — NOT Chart.js format (`labels`, `datasets`)
237
+
238
+ ---
239
+
240
+ Container(api, "API Gateway", "Kong", "Routes requests")
241
+ Container(svc, "Payment Service", "Node.js", "Processes payments")
242
+ ContainerDb(db, "Payment DB", "PostgreSQL", "Transaction records")
243
+ }
244
+
245
+ System_Ext(stripe, "Stripe", "Payment processor")
246
+
247
+ Rel(user, api, "HTTPS")
248
+ Rel(api, svc, "gRPC")
249
+ Rel(svc, db, "SQL")
250
+ Rel(svc, stripe, "REST")`
251
+ }
252
+ ]
253
+ })
254
+ ```
255
+
256
+ ### Method 2: HTML/SVG Architecture Diagrams
257
+
258
+ For rich visual output, embed the full HTML/SVG diagram in a `markdown` block. Compose with `metrics` and `cards` blocks for a complete dashboard.
259
+
260
+ **Both `format: "html"` and `format: "browser"` work with this approach.**
261
+
262
+ ```js
263
+ present({
264
+ format: "html", // or "browser"
265
+ title: "System Architecture",
266
+ content: [
267
+ {
268
+ type: "metrics",
269
+ title: "Overview",
270
+ value: [
271
+ { label: "Services", value: "6" },
272
+ { label: "Data Stores", value: "2" },
273
+ { label: "External Systems", value: "3" }
274
+ ]
275
+ },
276
+ {
277
+ type: "markdown",
278
+ title: "Architecture Diagram",
279
+ value: "<div class='arch-diagram'><style>/* design system CSS from c4-architecture/references/html-design-system.md */</style><svg viewBox='0 0 1000 680'><!-- SVG components using category colors --></svg></div>"
280
+ },
281
+ {
282
+ type: "cards",
283
+ title: "Component Summary",
284
+ value: [
285
+ { title: "Frontend", body: "React SPA + CDN delivery" },
286
+ { title: "Backend", body: "3 microservices, gRPC mesh" },
287
+ { title: "Data", body: "PostgreSQL + Redis cache" }
288
+ ]
289
+ }
290
+ ]
291
+ })
292
+ ```
293
+
294
+ ### Component Categories (Quick Reference)
295
+
296
+ The full type registry with sub-types and icon slots is in `c4-architecture/references/html-design-system.md`. Here is the category summary:
297
+
298
+ | Category | Stroke | CSS Class | Use For |
299
+ |----------|--------|-----------|---------|
300
+ | Frontend | `#22d3ee` | `.cyan` | SPAs, mobile apps, static sites, PWAs |
301
+ | Backend | `#34d399` | `.emerald` | API services, workers, microservices, serverless |
302
+ | Data | `#a78bfa` | `.violet` | Databases, caches, search engines, warehouses |
303
+ | Infrastructure | `#fbbf24` | `.amber` | CDNs, load balancers, DNS, storage |
304
+ | Messaging | `#fb923c` | `.orange` | Queues, event buses, streams, pub/sub |
305
+ | Security | `#fb7185` | `.rose` | Auth, API gateways, WAF, secret managers |
306
+ | External | `#94a3b8` | `.slate` | Third-party APIs, SaaS, legacy systems |
307
+ | Monitoring | `#38bdf8` | `.sky` | Logging, metrics, tracing, alerting |
308
+
309
+ > **Centralization note:** Do not duplicate colors or type definitions here. The `c4-architecture` skill's design system is the single source of truth. When categories or colors change, they are updated in one place.
310
+
311
+ ---
312
+
165
313
  ## Best Practices
166
314
 
167
315
  1. **Use `browser` format** for data-rich content — charts, tables, dashboards. **Always use `browser` in CLI mode** (the `html` UIResource doesn't render in terminal environments).
@@ -178,6 +326,38 @@ The dashboard uses a professional dark theme:
178
326
 
179
327
  ---
180
328
 
329
+ ## Rendering Troubleshooting
330
+
331
+ ### Why `html` format sometimes shows raw text
332
+
333
+ The `html` format renders content inside an MCP Apps companion iframe (UIResource). The chat text fallback is intentionally minimal (just the title). When the UIResource fails to load, the user sees only the title or raw JSON — NOT the rendered dashboard.
334
+
335
+ **Common causes of UIResource rendering failure:**
336
+ 1. **MCP Apps not enabled** — The setting `chat.mcp.apps.enabled` must be `true` in VS Code settings
337
+ 2. **Companion app build missing** — The `packages/present` companion app must be built (`npm run build`)
338
+ 3. **Content too large** — Very large content arrays (20+ blocks or tables with 50+ rows) may cause the companion iframe to fail silently
339
+ 4. **Iframe loading error** — Network issues, CSP restrictions, or extension conflicts can prevent the iframe from loading
340
+
341
+ ### When to prefer `browser` over `html`
342
+
343
+ Use `format: "browser"` instead of `html` when:
344
+ - Content has **10+ blocks** or tables with **20+ rows** (large payloads are more reliable in browser)
345
+ - The output must be **guaranteed visible** (browser format always opens, no silent failures)
346
+ - You need **charts + tables + markdown** in the same view (browser renders all block types reliably)
347
+ - The user reports that `html` format "didn't show anything" or "showed raw text"
348
+
349
+ > **Reliability rule:** If content is complex (5+ blocks of mixed types), prefer `format: "browser"` for guaranteed rendering. The `html` format is best for simple, single-block content.
350
+
351
+ ### Content formatting tips to avoid rendering issues
352
+
353
+ 1. **Use `table` block type** instead of markdown tables inside `markdown` blocks — `table` blocks render natively; markdown pipe-tables may show as raw text in fallback
354
+ 2. **Use `cards` and `metrics`** for summary data instead of embedding it in markdown text
355
+ 3. **Keep `markdown` blocks for narrative text only** — don't embed HTML, tables, or complex formatting
356
+ 4. **Split large content** into multiple smaller `present` calls rather than one massive content array
357
+ 5. **For charts:** Always use ChartValue format (`chartType`, `data`, `xKey`, `yKeys`) — NOT Chart.js format (`labels`, `datasets`)
358
+
359
+ ---
360
+
181
361
  ## MCP Apps Templates (VS Code Chat Widgets)
182
362
 
183
363
  When `chat.mcp.apps.enabled` is true in VS Code settings, the `present` tool can render **interactive widgets directly in the chat panel** using the `template` parameter. These are distinct from the browser/html dashboard modes.