Streaming Component Protocol
AutoForge supports rich components embedded in AI streaming text via partial JSON code blocks.
Supported Components
table
Render a data table. The AI should emit:
markdown
Here is the analysis of your codebase:
```json
{"type": "table", "columns": ["File", "Lines", "Complexity"], "rows": [{"File": "src/main.rs", "Lines": 120, "Complexity": "Low"}]}
```
As you can see, the main entry point is quite small.Rules:
- Output the JSON inline (single line or compact) so it can be parsed even when truncated mid-stream
- Use
"type": "table"exactly columnsis an array of stringsrowsis an array of objects with keys matchingcolumns- Always close the code fence (
\n```\n) when done
chart (planned)
Not yet implemented. Future components: form, diagram, diff.
How the Frontend Parses It
useStreamingDocument(rawText)scans for```jsonfencesparsePartialJSON()attempts to parse even incomplete JSON:- Adds missing closing
}/] - Adds missing closing
"
- Adds missing closing
- If
value.type === 'table'→ render<StreamingTable> - If not recognized → render as normal markdown code block
final=trueonly when the fence is closed
Testing It Manually
You can test the table rendering without the AI by pasting this into the Furnace chat (the AI will echo it back, or you can hardcode a mock response):
I've analyzed the API endpoints. Here's a summary:
```json
{"type": "table", "columns": ["Endpoint", "Method", "Status"], "rows": [{"Endpoint": "/api/users", "Method": "GET", "Status": "OK"}, {"Endpoint": "/api/users", "Method": "POST", "Status": "OK"}, {"Endpoint": "/api/auth", "Method": "POST", "Status": "Needs Tests"}]}
```
All endpoints are documented. Let me know if you want me to add more.Prompt Template for the AI
Add this to the system prompt when you want the AI to use tables:
When presenting structured data (comparisons, lists, analysis results),
output a JSON table inside a markdown code block:
```json
{"type": "table", "columns": ["Col1", "Col2"], "rows": [{"Col1": "...", "Col2": "..."}]}