-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add swarm dashboard tooling and package manifest #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| $traceFile = "C:\\PersonalRepo\\.planning\\traces.jsonl" | ||
| $clearString = [char]27 + "[2J" + [char]27 + "[H" | ||
|
|
||
| while ($true) { | ||
| Write-Host -NoNewline $clearString | ||
| Write-Host "================================================================================" -ForegroundColor Cyan | ||
| Write-Host " LIVE SWARM DASHBOARD (2026 OTel Architecture) " -ForegroundColor White -BackgroundColor DarkBlue | ||
| Write-Host "================================================================================`n" -ForegroundColor Cyan | ||
|
|
||
| if (Test-Path $traceFile) { | ||
| # Read the last 15 lines so the dashboard doesn't overflow | ||
| $rawLines = Get-Content -Path $traceFile -Tail 15 -ErrorAction SilentlyContinue | ||
|
|
||
| $logs = @() | ||
| foreach ($line in $rawLines) { | ||
| try { | ||
| if (-not [string]::IsNullOrWhiteSpace($line)) { | ||
| $logs += $line | ConvertFrom-Json -ErrorAction Stop | ||
| } | ||
| } catch { | ||
| # Skip invalid JSON lines | ||
| } | ||
| } | ||
|
|
||
| if ($logs.Count -gt 0) { | ||
| $formattedLogs = foreach ($log in $logs) { | ||
| $reason = $log.reasoning_path | ||
| if ($null -ne $reason -and $reason.Length -gt 60) { | ||
| $reason = $reason.Substring(0,57) + "..." | ||
| } | ||
|
|
||
| [PSCustomObject]@{ | ||
| Time = [datetime]::Parse($log.timestamp).ToString("HH:mm:ss") | ||
| Span = if ($log.span_id) { $log.span_id } else { "N/A" } | ||
| Persona = if ($log.persona) { $log.persona } else { "Unknown" } | ||
| Action = if ($log.action_type) { $log.action_type } else { "Unknown" } | ||
| Tokens = if ($log.metrics.total_tokens) { $log.metrics.total_tokens } else { 0 } | ||
| Reasoning = $reason | ||
| } | ||
| } | ||
| $formattedLogs | Format-Table -AutoSize | ||
| } else { | ||
| Write-Host "No valid traces found yet." -ForegroundColor Yellow | ||
| } | ||
| } else { | ||
| Write-Host "Waiting for traces... ($traceFile not found)" -ForegroundColor Yellow | ||
| } | ||
|
|
||
| Write-Host "`nPress Ctrl+C to exit. Refreshing every 2 seconds..." -ForegroundColor DarkGray | ||
| Start-Sleep -Seconds 2 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Promptimprover Swarm Dashboard</title> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>Promptimprover Swarm Dashboard</h1> | ||
| </header> | ||
| <main> | ||
| <table id="dashboard"> | ||
| <thead> | ||
| <tr> | ||
| <th>Time</th> | ||
| <th>Span</th> | ||
| <th>Persona</th> | ||
| <th>Action</th> | ||
| <th>Tokens</th> | ||
| <th>Reasoning</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody></tbody> | ||
| </table> | ||
| </main> | ||
| <script> | ||
| async function fetchData() { | ||
| const resp = await fetch('/data'); | ||
| const logs = await resp.json(); | ||
| const tbody = document.querySelector('#dashboard tbody'); | ||
| tbody.innerHTML = ''; | ||
| logs.reverse().forEach(log => { | ||
| const tr = document.createElement('tr'); | ||
| const fmtTime = new Date(log.timestamp).toLocaleTimeString(); | ||
| const reason = log.reasoning_path && log.reasoning_path.length > 60 ? log.reasoning_path.slice(0,57) + '...' : log.reasoning_path; | ||
| ['time', 'span', 'persona', 'action', 'tokens', 'reasoning'].forEach((k, i) => { | ||
| const td = document.createElement('td'); | ||
| const values = [fmtTime, log.span_id || 'N/A', log.persona || 'Unknown', log.action_type || 'Unknown', log.metrics?.total_tokens || 0, reason || '']; | ||
| td.textContent = values[i]; | ||
| tr.appendChild(td); | ||
| }); | ||
| tbody.appendChild(tr); | ||
| }); | ||
| } | ||
| setInterval(fetchData, 2000); | ||
| fetchData(); | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // C:\PersonalRepo\portfolio\Promptimprover\dashboard\server.js | ||
| const http = require('http'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const url = require('url'); | ||
| const { once } = require('events'); | ||
|
|
||
| const TRACE_FILE = path.resolve('C:/PersonalRepo/.planning/traces.jsonl'); | ||
| const STATIC_DIR = path.join(__dirname); | ||
| const PORT = 3000; | ||
|
|
||
| // Helper: read last N lines from trace file | ||
| async function readLastLines(filePath, maxLines = 20) { | ||
| if (!fs.existsSync(filePath)) return []; | ||
| const stream = fs.createReadStream(filePath, { encoding: 'utf8' }); | ||
| let data = ''; | ||
| stream.on('data', chunk => { data += chunk; }); | ||
| await once(stream, 'end'); | ||
| const lines = data.trim().split(/\r?\n/); | ||
| const recent = lines.slice(-maxLines); | ||
| // parse each JSON line safely | ||
| return recent.map(l => { | ||
| try { return JSON.parse(l); } catch (_) { return null; } | ||
| }).filter(Boolean); | ||
| } | ||
|
|
||
| function serveStatic(res, filePath, contentType) { | ||
| fs.readFile(filePath, (err, content) => { | ||
| if (err) { | ||
| res.writeHead(404); | ||
| res.end('Not found'); | ||
| } else { | ||
| res.writeHead(200, { 'Content-Type': contentType }); | ||
| res.end(content); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| const server = http.createServer(async (req, res) => { | ||
| const parsed = url.parse(req.url, true); | ||
| if (parsed.pathname === '/' || parsed.pathname === '/index.html') { | ||
| serveStatic(res, path.join(STATIC_DIR, 'index.html'), 'text/html'); | ||
| } else if (parsed.pathname === '/style.css') { | ||
| serveStatic(res, path.join(STATIC_DIR, 'style.css'), 'text/css'); | ||
| } else if (parsed.pathname === '/data') { | ||
| try { | ||
| const logs = await readLastLines(TRACE_FILE, 20); | ||
| res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
| res.end(JSON.stringify(logs)); | ||
| } catch (e) { | ||
| res.writeHead(500); | ||
| res.end('Error reading trace file'); | ||
| } | ||
| } else { | ||
| res.writeHead(404); | ||
| res.end('Not found'); | ||
| } | ||
| }); | ||
|
|
||
| server.listen(PORT, '127.0.0.1', () => { | ||
| console.log(`Promptimprover dashboard listening on http://127.0.0.1:${PORT}`); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "promptimprover", | ||
| "version": "0.1.0", | ||
| "scripts": { | ||
| "dashboard": "powershell -NoProfile -ExecutionPolicy Bypass -File ./run-dashboard.ps1", | ||
| "dashboard-web": "node dashboard/server.js" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| $script = Join-Path $PSScriptRoot "dashboard\View-SwarmDashboard.ps1" | ||
| if (Test-Path $script) { | ||
| powershell -NoProfile -ExecutionPolicy Bypass -File $script | ||
| } else { | ||
| Write-Host "Dashboard script not found at $script" -ForegroundColor Red | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the dashboard is opened before
C:\PersonalRepo\.planning\traces.jsonlexists, such as on a fresh checkout or any machine without that local path,/datareaches this catch and sends a plain-text 500 whiledashboard/index.htmlalways callsawait resp.json(). That makes every poll throw and leaves the web dashboard blank instead of showing an empty/waiting state; return JSON like[]or handle non-OK responses in the client.Useful? React with 👍 / 👎.