@vpxa/aikit 0.1.351 → 0.1.352

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.
Files changed (30) hide show
  1. package/package.json +1 -1
  2. package/packages/blocks-core/dist/index.mjs +91 -58
  3. package/packages/core/dist/index.d.ts +3 -0
  4. package/packages/core/dist/index.js +1 -1
  5. package/packages/present/dist/annotation-layer.js +48 -74
  6. package/packages/present/dist/index.html +154 -114
  7. package/packages/server/dist/bin.js +1 -1
  8. package/packages/server/dist/index.js +288 -109
  9. package/packages/server/dist/prelude-CXds3AXY.js +2 -0
  10. package/packages/server/dist/prelude-Cms2H0-F.js +1 -0
  11. package/packages/server/dist/sampling-BoH5wpOJ.js +1 -0
  12. package/packages/server/dist/sampling-SoUYZhFs.js +2 -0
  13. package/packages/server/dist/{server-Dc2XtS92.js → server-Crfl8sRN.js} +59 -54
  14. package/packages/server/dist/{server-Ct4BK2hi.js → server-Znp0a9J2.js} +59 -54
  15. package/packages/server/dist/{server-http-BNC9qZBj.js → server-http-BGF1k0j9.js} +1 -1
  16. package/packages/server/dist/{server-http-DBmzukZH.js → server-http-BSGdxVRV.js} +1 -1
  17. package/packages/server/dist/{server-stdio-DkDdZI98.js → server-stdio-B2N-eM5T.js} +1 -1
  18. package/packages/server/dist/{server-stdio-JHWimdo9.js → server-stdio-CTgwgIGC.js} +1 -1
  19. package/packages/server/viewers/canvas.html +127 -94
  20. package/packages/server/viewers/code-review-viewer.html +352 -0
  21. package/packages/server/viewers/report-template.html +100 -67
  22. package/packages/server/viewers/tour-viewer.html +94 -61
  23. package/packages/tools/dist/index.js +82 -82
  24. package/scaffold/dist/definitions/skills/c4-architecture.mjs +1 -1
  25. package/scaffold/dist/definitions/skills/docs.mjs +19 -3
  26. package/scaffold/dist/definitions/skills/present.mjs +317 -13
  27. package/packages/server/dist/prelude-Clxlztkk.js +0 -1
  28. package/packages/server/dist/prelude-Dn7jTsqe.js +0 -2
  29. package/packages/server/dist/sampling-giGWyrcO.js +0 -1
  30. package/packages/server/dist/sampling-nivAea83.js +0 -2
@@ -27,12 +27,16 @@ Always include schemaVersion: 1 and title. Use concise description when helpful.
27
27
  ## Selection Guide
28
28
 
29
29
  | Need | Shape |
30
- |---|---|
30
+ |---|---|---|
31
31
  | Summary/report | report template or heading + markdown/table |
32
32
  | Plan/progress | task-plan/checklist/status-board |
33
33
  | Metrics/trends | metrics + chart |
34
34
  | Compare options | table + kv + recommendation |
35
- | Review/approval | review template + approval action |
35
+ | Review/approval | review template + approval action, or code-review@1 viewer for per-file diffs |
36
+ | Code review (per-file) | code-review@1 viewer — diff grid + risk map + review bubbles + annotations |
37
+ | Architecture diagram | c4@1 / c4-static@1 viewers |
38
+ | Process diagram | process-flow@1 / process-flow-static@1 viewers |
39
+ | Guided tour | tour@1 viewer |
36
40
  | Logs/errors | code/error block |
37
41
  | Choice | actions select/confirm/button |
38
42
 
@@ -55,8 +59,28 @@ Always include schemaVersion: 1 and title. Use concise description when helpful.
55
59
  - Use \`preferBrowser: true\` when user explicitly requests "open in browser", "external window", or "browser transport"
56
60
  - Templates \`c4@1\`, \`tour@1\`, \`process-flow@1\` are browser-only (interactive) — always open in browser
57
61
  - Templates \`c4-static@1\`, \`task-plan-static@1\`, \`process-flow-static@1\` are mcp-app-only — inline by default, use \`preferBrowser\` to force browser
62
+ - Template \`code-review@1\` supports both transports: inline for reading, browser for annotated review with actions (Approve/Request Changes). Text selection annotations auto-activate in browser transport when actions are present.
58
63
  - Block-only surfaces (no template) respond to \`preferBrowser\` as expected
59
64
 
65
+ ## Diagram Renderers vs Viewer Templates
66
+
67
+ Two separate paths for diagram/visual output — choose based on use case:
68
+
69
+ **Diagram renderers** (programmatic API — NOT present tool):
70
+ - Import from \`@aikit/server/diagram\`: \`renderToResult\`, \`renderHtml\`, \`renderDiagram\`
71
+ - 5 types: \`architecture\`, \`workflow\`, \`sequence\`, \`dataflow\`, \`lifecycle\`
72
+ - Standalone HTML (not wrapped in present shell) — embed in docs, write to disk
73
+ - All 5 now use warm clay/olive/gold design system, serif headings, dark/light mode, responsive
74
+ - All 5 now support click-to-detail card interaction on SVG nodes
75
+ - Invoke: \`renderToResult({ diagram_type: 'architecture', meta: {title}, components, connections })\`
76
+ - Use when diagrams go to files, docs, or you don't need present tool's action/annotation system
77
+
78
+ **Viewer templates** (present tool — \`present({ template: '...', data: {...} })\`):
79
+ - 7 templates listed below — rendered inside present shell with header/footer/theme toggle
80
+ - Support actions (approve, confirm, select) and annotation layer for code-review@1
81
+ - Invoke: \`present({ template: 'code-review@1', data: {...}, actions: [...] })\`
82
+ - Use when you need interactive UI, user actions, annotations, or present workflow integration
83
+
60
84
  ## Quality Bar
61
85
 
62
86
  - One clear title, no giant unstructured markdown dumps.
@@ -74,7 +98,7 @@ If validation fails, fix schema shape first. Use schema/preset/template resource
74
98
 
75
99
  Load on demand:
76
100
  - references/block-catalog.md — Complete 32-block type catalog with value shapes, best block for each data type, and rules.
77
- - references/presets-templates.md — Preset contracts (8 presets), viewer templates (6), MCP App templates (14), and error recovery patterns.
101
+ - references/presets-templates.md — Preset contracts (8 presets), viewer templates (7), MCP App templates (14), diagram renderers (5), and error recovery patterns.
78
102
  `},{file:`references/block-catalog.md`,content:`# Block Catalog — 32 Content Blocks
79
103
 
80
104
  Pass content as blocks array of { type, title?, value } objects.
@@ -160,16 +184,296 @@ Pass content as blocks array of { type, title?, value } objects.
160
184
 
161
185
  Each preset supplies inputSchema (JSON Schema), example (JSON), and expandsTo (block description) via aikit://present/presets.
162
186
 
163
- ## 6 Viewer Templates
164
-
165
- | Template | Transport | Purpose |
166
- |----------|-----------|---------|
167
- | c4@1 | browser | Interactive C4 architecture diagram |
168
- | c4-static@1 | mcp-app | Static architecture diagram |
169
- | process-flow@1 | browser | Interactive process flow |
170
- | process-flow-static@1 | mcp-app | Static process flow |
171
- | tour@1 | browser | Guided walkthrough |
172
- | task-plan-static@1 | mcp-app | Static task execution plan card layout |
187
+ Viewer templates also supply inputSchema programmatically — query via aikit://present/templates resource or call registerViewer() definitions.
188
+
189
+ ## 7 Viewer Templates
190
+
191
+ Viewer templates are self-contained HTML pages rendered inside the present tool shell. Each has a specific data contract. Pass as \`present({ template: '<id>', data: {...} })\`.
192
+
193
+ | Template | Transport | When to use | Required fields |
194
+ |----------|-----------|-------------|----------------|
195
+ | c4@1 | browser | Interactive C4 architecture with zoom/pan/ELK auto-layout | nodes: [{ id, type, label }] |
196
+ | c4-static@1 | mcp-app | Static SVG architecture diagram inline (no interaction) | nodes: [{ id, type, label }] |
197
+ | process-flow@1 | browser | Interactive process flow with ReactFlow drag/zoom | nodes: [{ id, label }] |
198
+ | process-flow-static@1 | mcp-app | Static SVG process flow inline | nodes: [{ id, label }] |
199
+ | tour@1 | browser | Guided walkthrough with step nav + dependency graph | steps: [{ id, title, file?, code? }] |
200
+ | task-plan-static@1 | mcp-app | Task execution plan with phases/batches/agents | phases: [{ id, label, batches }] |
201
+ | code-review@1 | mcp-app, browser | Per-file diff code review with risk map, bubbles, annotations | files: [{ path }] |
202
+
203
+ ### c4@1 / c4-static@1 Data Contract
204
+
205
+ {
206
+ title: "System Context — Acme Web",
207
+ description: "Top-level system context diagram",
208
+ layout: { direction: "TB", spacing: 60, layerSpacing: 80 },
209
+ nodes: [
210
+ { id: "user", type: "person", label: "User", icon: "person" },
211
+ { id: "web", type: "container", label: "Web App", technology: "React",
212
+ description: "Single-page application" },
213
+ { id: "api", type: "container", label: "API Server", technology: "Hono" },
214
+ { id: "db", type: "database", label: "Postgres", technology: "RDS" }
215
+ ],
216
+ edges: [
217
+ { source: "user", target: "web", label: "browses", style: "sync" },
218
+ { source: "web", target: "api", label: "fetch /api", style: "sync" },
219
+ { source: "api", target: "db", label: "query", style: "async" }
220
+ ]
221
+ }
222
+
223
+ - \`nodes[].type\`: \`person\` | \`system\` | \`container\` | \`component\` | \`database\` | \`queue\` | \`external\` | \`boundary\`
224
+ - \`edges[].style\`: \`sync\` | \`async\` | \`dashed\` | \`dotted\` | \`solid\`
225
+ - c4@1 = interactive (browser-only), c4-static@1 = static SVG (mcp-app inline)
226
+
227
+ ### process-flow@1 / process-flow-static@1 Data Contract
228
+
229
+ {
230
+ nodes: [
231
+ { id: "start", label: "Start", type: "start-end" },
232
+ { id: "review", label: "Code Review", type: "manual",
233
+ description: "Peer review required before merge" },
234
+ { id: "deploy", label: "Deploy", type: "automated" },
235
+ { id: "approve?", label: "Approved?", type: "decision" }
236
+ ],
237
+ edges: [
238
+ { source: "start", target: "review", label: "assign" },
239
+ { source: "review", target: "approve?", type: "standard" },
240
+ { source: "approve?", target: "deploy", label: "yes", type: "standard" },
241
+ { source: "approve?", target: "review", label: "no", type: "loop-back" }
242
+ ]
243
+ }
244
+
245
+ - \`nodes[].type\`: \`start-end\` | \`manual\` | \`automated\` | \`integration\` | \`decision\` | \`prerequisite\`
246
+ - \`edges[].type\`: \`standard\` | \`loop-back\` | \`exception\`
247
+ - process-flow@1 = interactive (browser), process-flow-static@1 = static SVG (mcp-app)
248
+
249
+ ### tour@1 Data Contract
250
+
251
+ {
252
+ title: "Scaffold Build Pipeline",
253
+ description: "How the scaffold generation pipeline works",
254
+ estimatedTime: "10 min",
255
+ steps: [
256
+ { stepNumber: 1, id: "intro", title: "Overview",
257
+ file: "scaffold/generate.mjs",
258
+ explanation: "The scaffold reads definitions from scaffold/definitions/...",
259
+ description: "Entry point for the entire pipeline",
260
+ learnsConcept: "pipeline architecture",
261
+ duration: "2 min",
262
+ code: "export async function generate() { ... }"
263
+ },
264
+ { stepNumber: 2, id: "definitions", title: "Source of Truth",
265
+ file: "scaffold/definitions/agents.mjs" }
266
+ ],
267
+ dependencies: [
268
+ { source: "intro", target: "definitions" }
269
+ ]
270
+ }
271
+
272
+ ### task-plan-static@1 Data Contract
273
+
274
+ {
275
+ title: "Implement Auth Module",
276
+ description: "Task breakdown for adding auth",
277
+ phases: [{
278
+ id: "phase-1", label: "Research",
279
+ outcome: "Selected auth strategy",
280
+ batches: [{
281
+ id: "batch-1", order: 1, parallel: false,
282
+ label: "Analyze options",
283
+ tasks: [{ id: "t1", title: "Compare JWT vs session",
284
+ agent: "Researcher-Alpha", status: "done",
285
+ files: ["docs/auth-comparison.md"] }]
286
+ }]
287
+ }]
288
+ }
289
+
290
+ - \`batches[].tasks[].agent\`: any agent name (e.g. Implementer, Researcher-Alpha)
291
+ - \`batches[].tasks[].status\`: \`pending\` | \`in-progress\` | \`done\` | \`blocked\`
292
+ - Supports \`dependsOn\` array for task dependencies
293
+
294
+ ### code-review@1 Data Contract
295
+
296
+ {
297
+ title: "PR #247 — Add optimistic updates",
298
+ repo: "acme/web",
299
+ author: "Mira Okafor",
300
+ additions: 142, deletions: 38,
301
+ files: [{
302
+ path: "src/hooks/useOptimisticTasks.ts",
303
+ risk: "attention", // "safe" | "medium" | "attention"
304
+ collapsed: true, // wrap in <details>
305
+ diff: [
306
+ { t: "add", n: 1, c: "import { useMutation } from '...'" },
307
+ { t: "del", n: 43, c: "const [pending, setPending] = useState(null)" },
308
+ { t: "ctx", n: 50, c: "return <ul className='tasks'>" },
309
+ { t: "hunk", c: "@@ -42,14 +42,17 @@" }
310
+ ],
311
+ comments: [
312
+ { line: 11, text: "Missing cancelQueries()", blocking: true }
313
+ ]
314
+ }],
315
+ conclusion: ["Fix the cancelQueries gap before merging."]
316
+ }
317
+
318
+ - \`files[].risk\`: safe=green chip, medium=gold chip, attention=terracotta chip
319
+ - \`diff[].t\`: add=green bg, del=red bg, ctx=neutral, hunk=dim header row
320
+ - \`comments[].blocking\`: true=red left border, false=gray left border
321
+ - Add \`actions\` array (e.g. approve, request-changes) to auto-activate browser transport + annotation layer
322
+ - Annotations: user selects diff text -> comment popover -> stored in \`__annotationLayer\` -> bundled with action callback
323
+ - Viewer uses warm clay/olive/gold design, serif headings, dark/light toggle, responsive layout
324
+
325
+ ## 5 Diagram Renderers (programmatic — NOT present tool)
326
+
327
+ Diagram renderers produce standalone HTML with warm design system, dark/light mode, and click-to-detail interaction on all SVG nodes. Invoke via:
328
+
329
+ import { renderToResult, renderHtml, renderDiagram } from '@aikit/server/diagram'
330
+ const { html } = renderToResult({ diagram_type: 'architecture', meta: {title: '...'}, ... })
331
+ // or for HTML string only:
332
+ const html = renderHtml({ diagram_type: 'workflow', meta: {title: '...'}, ... })
333
+
334
+ All renderers accept \`meta: { palette: 'warm' | 'technical', title: string, subtitle?: string }\`. Default palette is warm.
335
+
336
+ ### architecture Data Contract
337
+
338
+ {
339
+ diagram_type: 'architecture',
340
+ meta: { title: "System Architecture", subtitle: "High-level overview", palette: "warm" },
341
+ components: [
342
+ { id: "web", type: "frontend", label: "React SPA", sublabel: "Vite",
343
+ pos: { x: 40, y: 60 }, size: [140, 70] },
344
+ { id: "api", type: "backend", label: "API Server", sublabel: "Hono",
345
+ pos: { x: 240, y: 60 } },
346
+ { id: "db", type: "database", label: "Postgres",
347
+ pos: { x: 440, y: 60 } }
348
+ ],
349
+ connections: [
350
+ { from: "web", to: "api", label: "fetch /v1", variant: "emphasis" },
351
+ { from: "api", to: "db", label: "query", variant: "dashed" }
352
+ ],
353
+ boundaries: [
354
+ { kind: "region", label: "AWS", wraps: ["api", "db"] }
355
+ ],
356
+ cards: [{ dot: "green", title: "Key", items: ["SPA served from edge"] }]
357
+ }
358
+
359
+ - \`components[].type\`: \`frontend\` | \`backend\` | \`database\` | \`cloud\` | \`security\` | \`messagebus\` | \`external\`
360
+ - \`connections[].variant\`: \`default\` | \`emphasis\` | \`security\` | \`dashed\` | \`animated\`
361
+ - \`connections[].route\`: \`straight\` | \`drop\` | \`auto\` (bent elbow)
362
+ - Components auto-wrapped in \`<g class="node" data-k="[id]">\` for click-to-detail interaction
363
+
364
+ ### workflow Data Contract
365
+
366
+ {
367
+ diagram_type: 'workflow',
368
+ meta: { title: "Deploy Pipeline" },
369
+ lanes: [{ id: "dev", label: "Developer" }, { id: "ci", label: "CI/CD" }],
370
+ nodes: [
371
+ { id: "push", lane: "dev", col: 1, type: "frontend",
372
+ label: "git push", sublabel: "main branch" },
373
+ { id: "lint", lane: "ci", col: 2, type: "backend",
374
+ label: "Lint + Typecheck" },
375
+ { id: "test", lane: "ci", col: 3, type: "backend",
376
+ label: "Unit tests", tag: "3 shards" },
377
+ { id: "deploy", lane: "ci", col: 4, type: "cloud",
378
+ label: "Deploy", sublabel: "Argo" }
379
+ ],
380
+ edges: [
381
+ { from: "push", to: "lint", label: "trigger" },
382
+ { from: "lint", to: "test" },
383
+ { from: "test", to: "deploy", variant: "emphasis" }
384
+ ]
385
+ }
386
+
387
+ - \`nodes[].col\`: 1-based column position within lane (1-6 max)
388
+ - \`nodes[].type\`: same component types as architecture
389
+ - Auto-wrapped in \`<g class="node" data-k="[id]">\`
390
+
391
+ ### sequence Data Contract
392
+
393
+ {
394
+ diagram_type: 'sequence',
395
+ meta: { title: "Auth Flow" },
396
+ participants: [
397
+ { id: "user", type: "frontend", label: "User" },
398
+ { id: "spa", type: "frontend", label: "SPA" },
399
+ { id: "api", type: "backend", label: "API" },
400
+ { id: "db", type: "database", label: "DB" }
401
+ ],
402
+ messages: [
403
+ { from: "user", to: "spa", y: 180, label: "click login", variant: "emphasis" },
404
+ { from: "spa", to: "api", y: 240, label: "POST /auth/login" },
405
+ { from: "api", to: "db", y: 300, label: "SELECT user" },
406
+ { from: "api", to: "spa", y: 360, label: "200 { token }", variant: "return" }
407
+ ],
408
+ activations: [
409
+ { participant: "api", from: 220, to: 380, type: "backend" }
410
+ ],
411
+ segments: [
412
+ { from: 160, to: 220, label: "User input" }
413
+ ]
414
+ }
415
+
416
+ - \`messages[].y\`: absolute Y coordinate in SVG (descending = later in time)
417
+ - \`messages[].variant\`: \`default\` | \`emphasis\` | \`security\` | \`return\` | \`dashed\`
418
+ - Participants auto-wrapped in \`<g class="node" data-k="[id]">\`
419
+
420
+ ### dataflow Data Contract
421
+
422
+ {
423
+ diagram_type: 'dataflow',
424
+ meta: { title: "User Registration Flow" },
425
+ stages: [
426
+ { label: "Client" }, { label: "Edge" }, { label: "Services" }, { label: "Storage" }
427
+ ],
428
+ nodes: [
429
+ { id: "browser", type: "frontend", label: "Browser", stage: 0, row: 0 },
430
+ { id: "cdn", type: "cloud", label: "CDN", stage: 1, row: 0, tag: "cache" },
431
+ { id: "auth", type: "backend", label: "Auth Service", stage: 2, row: 0 },
432
+ { id: "db", type: "database", label: "Postgres", stage: 3, row: 0 }
433
+ ],
434
+ flows: [
435
+ { from: "browser", to: "cdn", label: "GET /login", classification: "public" },
436
+ { from: "cdn", to: "auth", label: "forward", variant: "emphasis" },
437
+ { from: "auth", to: "db", label: "SELECT", classification: "PII" }
438
+ ]
439
+ }
440
+
441
+ - \`stages\`: vertical columns (left to right)
442
+ - \`nodes[].stage\`: 0-based index into stages array
443
+ - \`nodes[].row\`: vertical position within stage
444
+ - \`flows[].classification\`: \`public\` | \`internal\` | \`PII\` (controls edge color)
445
+ - Auto-wrapped in \`<g class="node" data-k="[id]">\`
446
+
447
+ ### lifecycle Data Contract
448
+
449
+ {
450
+ diagram_type: 'lifecycle',
451
+ meta: { title: "Order State Machine" },
452
+ lanes: [
453
+ { id: "phase", label: "Phase" },
454
+ { id: "event", label: "Event" },
455
+ { id: "outcome", label: "Outcome" }
456
+ ],
457
+ states: [
458
+ { id: "created", lane: "phase", col: 1, type: "active", label: "Created" },
459
+ { id: "paid", lane: "phase", col: 2, type: "active", label: "Paid", step: "1" },
460
+ { id: "shipped", lane: "phase", col: 3, type: "active", label: "Shipped", step: "2" },
461
+ { id: "delivered", lane: "outcome", col: 4, type: "success", label: "Delivered" },
462
+ { id: "cancelled", lane: "outcome", col: 2, type: "failure", label: "Cancelled" }
463
+ ],
464
+ transitions: [
465
+ { from: "created", to: "paid", label: "charge" },
466
+ { from: "paid", to: "shipped", label: "fulfill" },
467
+ { from: "paid", to: "cancelled", label: "refund", variant: "dashed" },
468
+ { from: "shipped", to: "delivered", label: "confirm" }
469
+ ]
470
+ }
471
+
472
+ - \`states[].type\`: \`start\` | \`active\` | \`waiting\` | \`decision\` | \`success\` | \`failure\` | \`neutral\` | \`external\`
473
+ - \`states[].col\`: 1-based column position
474
+ - \`states[].step\`: optional step number badge
475
+ - \`transitions[].variant\`: \`default\` | \`emphasis\` | \`dashed\` | \`security\`
476
+ - Auto-wrapped in \`<g class="node" data-k="[id]">\`
173
477
 
174
478
  ## 14 MCP App Templates
175
479
 
@@ -1 +0,0 @@
1
- import{n as e,t}from"./server-Dc2XtS92.js";export{t as buildPreludeInjection,e as generatePrelude};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{n as e,t}from"./server-Ct4BK2hi.js";export{t as buildPreludeInjection,e as generatePrelude};
@@ -1 +0,0 @@
1
- import{r as e}from"./server-Dc2XtS92.js";export{e as createSamplingClient};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{r as e}from"./server-Ct4BK2hi.js";export{e as createSamplingClient};