initial: hermes-dashboard snapshot (post overview + git integration)

This commit is contained in:
hermes-dashboard
2026-08-17 19:51:51 +08:00
commit 1e5e30ffcb
22 changed files with 2333 additions and 0 deletions

352
templates/base.html Normal file
View File

@@ -0,0 +1,352 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{% block title %}Hermes Dashboard{% endblock %}</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Courier New', Courier, monospace;
background: #1a1a1a;
color: #e0e0e0;
line-height: 1.6;
padding: 20px;
}
a {
color: #4a9eff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1, h2, h3 {
color: #fff;
margin-bottom: 15px;
}
h1 {
font-size: 24px;
border-bottom: 2px solid #333;
padding-bottom: 10px;
margin-bottom: 20px;
}
h2 {
font-size: 20px;
margin-top: 20px;
}
h3 {
font-size: 16px;
margin-top: 15px;
}
nav {
margin-bottom: 30px;
padding: 10px 0;
border-bottom: 1px solid #333;
}
nav a {
margin-right: 20px;
padding: 5px 10px;
background: #2a2a2a;
border-radius: 3px;
}
nav a:hover {
background: #3a3a3a;
}
.container {
max-width: 1400px;
margin: 0 auto;
}
.card {
background: #2a2a2a;
border: 1px solid #3a3a3a;
border-radius: 5px;
padding: 15px;
margin-bottom: 20px;
}
.card h3 {
margin-top: 0;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th, td {
padding: 8px 12px;
text-align: left;
border-bottom: 1px solid #3a3a3a;
}
th {
background: #333;
color: #fff;
font-weight: bold;
}
tr:hover {
background: #2f2f2f;
}
.btn {
display: inline-block;
padding: 6px 12px;
background: #3a3a3a;
border: 1px solid #4a4a4a;
border-radius: 3px;
color: #e0e0e0;
cursor: pointer;
text-decoration: none;
margin-right: 5px;
}
.btn:hover {
background: #4a4a4a;
text-decoration: none;
}
.btn-primary {
background: #2a5a9a;
border-color: #3a6aaa;
}
.btn-primary:hover {
background: #3a6aaa;
}
.status-badge {
display: inline-block;
padding: 3px 8px;
border-radius: 3px;
font-size: 12px;
font-weight: bold;
}
.status-ready {
background: #2a5a2a;
color: #8f8;
}
.status-running {
background: #5a5a2a;
color: #ff8;
}
.status-done {
background: #2a5a2a;
color: #8f8;
}
.status-blocked {
background: #5a2a2a;
color: #f88;
}
.status-failed {
background: #5a2a2a;
color: #f88;
}
.kanban-board {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 15px;
margin-top: 20px;
}
.kanban-column {
background: #252525;
border: 1px solid #3a3a3a;
border-radius: 5px;
padding: 10px;
min-height: 200px;
}
.kanban-column h3 {
text-align: center;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 2px solid #3a3a3a;
}
.kanban-card {
background: #2a2a2a;
border: 1px solid #3a3a3a;
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
cursor: pointer;
}
.kanban-card:hover {
background: #333;
border-color: #4a9eff;
}
.kanban-card-title {
font-size: 14px;
margin-bottom: 5px;
word-wrap: break-word;
}
.kanban-card-meta {
font-size: 11px;
color: #888;
}
pre {
background: #1a1a1a;
border: 1px solid #3a3a3a;
border-radius: 3px;
padding: 10px;
overflow-x: auto;
font-size: 13px;
line-height: 1.5;
}
.grid-2 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.grid-3 {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 20px;
}
.text-muted {
color: #888;
}
.text-small {
font-size: 12px;
}
.mt-10 {
margin-top: 10px;
}
.mt-20 {
margin-top: 20px;
}
.mb-10 {
margin-bottom: 10px;
}
.mb-20 {
margin-bottom: 20px;
}
.filter-buttons {
margin: 15px 0;
}
.filter-buttons .btn {
margin-right: 10px;
}
.filter-buttons .btn.active {
background: #2a5a9a;
border-color: #3a6aaa;
}
.timeline-item {
border-left: 2px solid #3a3a3a;
padding-left: 15px;
margin-left: 10px;
margin-bottom: 15px;
}
.timeline-item-header {
font-size: 12px;
color: #888;
margin-bottom: 5px;
}
.timeline-item-content {
background: #2a2a2a;
padding: 10px;
border-radius: 3px;
}
.comment {
background: #2a2a2a;
border: 1px solid #3a3a3a;
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
}
.comment-header {
font-size: 12px;
color: #888;
margin-bottom: 5px;
}
.attachment-list {
list-style: none;
}
.attachment-list li {
padding: 5px 0;
border-bottom: 1px solid #3a3a3a;
}
.attachment-list li:last-child {
border-bottom: none;
}
@media (max-width: 1200px) {
.kanban-board {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 768px) {
.kanban-board {
grid-template-columns: 1fr;
}
.grid-2, .grid-3 {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<h1>🔥 Hermes Dashboard</h1>
<nav>
<a href="/">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/tasks">Tasks</a>
</nav>
{% block content %}{% endblock %}
</div>
<script type="module" src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html>

151
templates/dashboard.html Normal file
View File

@@ -0,0 +1,151 @@
{% extends "base.html" %}
{% block title %}Dashboard - Hermes{% endblock %}
{% block content %}
<div class="grid-2">
<div>
<div class="card">
<h3>🔧 Worker Status</h3>
<div id="worker-status">
{% if worker_status.current_task %}
<p><strong>Current Task:</strong> #{{ worker_status.current_task.id }} - {{ worker_status.current_task.title[:60] }}</p>
<p><strong>Worker PID:</strong> {{ worker_status.current_task.worker_pid or 'N/A' }}</p>
{% if worker_status.current_task.started_at %}
<p><strong>Elapsed:</strong> <span class="elapsed-time" data-started="{{ worker_status.current_task.started_at }}"></span></p>
{% endif %}
{% else %}
<p class="text-muted">No task currently running</p>
{% endif %}
</div>
</div>
<div class="card">
<h3>📜 SOUL.md Excerpt</h3>
<pre>{{ worker_status.soul_excerpt[:500] }}</pre>
</div>
</div>
<div>
<div class="card">
<h3>⚙️ Running Processes</h3>
<div id="process-list">
{% if processes %}
<table>
<thead>
<tr>
<th>PID</th>
<th>Elapsed</th>
<th>Command</th>
</tr>
</thead>
<tbody>
{% for proc in processes %}
<tr>
<td>{{ proc.pid }}</td>
<td><span class="elapsed-time" data-started="{{ proc.create_time }}"></span></td>
<td class="text-small">{{ proc.cmdline }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">No opencode workers running</p>
{% endif %}
</div>
</div>
</div>
</div>
<h2>📋 Kanban Board</h2>
<div class="kanban-board" id="kanban-board">
{% for status in ['ready', 'running', 'done', 'blocked', 'failed'] %}
<div class="kanban-column">
<h3>{{ status|upper }} ({{ board.get(status, [])|length }})</h3>
{% for task in board.get(status, []) %}
<a href="/tasks/{{ task.id }}" style="text-decoration: none;">
<div class="kanban-card">
<div class="kanban-card-title">#{{ task.id }} {{ task.title[:60] }}</div>
<div class="kanban-card-meta">
{% if task.status == 'running' and task.started_at %}
<span class="elapsed-time" data-started="{{ task.started_at }}"></span>
{% elif task.status == 'done' and task.completed_at %}
{{ task.completed_at|rel }}
{% endif %}
{% if task.assignee %}
<br>{{ task.assignee }}
{% endif %}
</div>
</div>
</a>
{% endfor %}
</div>
{% endfor %}
</div>
<h2 class="mt-20">📤 派活 Dispatch</h2>
<div class="card">
<form id="dispatch-form">
<div style="margin-bottom:10px;">
<label for="dispatch-template">Template:</label>
<select id="dispatch-template" style="width:100%;padding:6px;background:#1a1a1a;color:#e0e0e0;border:1px solid #3a3a3a;border-radius:3px;">
<option value="">-- choose a template (optional) --</option>
</select>
</div>
<div style="margin-bottom:10px;">
<label for="dispatch-title">Title (required):</label>
<input type="text" id="dispatch-title" name="title" required maxlength="200"
style="width:100%;padding:6px;background:#1a1a1a;color:#e0e0e0;border:1px solid #3a3a3a;border-radius:3px;"
placeholder="e.g. Fix CSRF in blog-app">
</div>
<div style="margin-bottom:10px;">
<label for="dispatch-body">Body (markdown):</label>
<textarea id="dispatch-body" name="body" rows="6"
style="width:100%;padding:6px;background:#1a1a1a;color:#e0e0e0;border:1px solid #3a3a3a;border-radius:3px;font-family:inherit;"
placeholder="## 背景&#10;...&#10;## 任务&#10;...&#10;## 验收&#10;- [ ] ..."></textarea>
</div>
<div class="grid-2" style="margin-bottom:10px;">
<div>
<label for="dispatch-assignee">Assignee:</label>
<input type="text" id="dispatch-assignee" name="assignee" value="omo-pm" maxlength="64"
style="width:100%;padding:6px;background:#1a1a1a;color:#e0e0e0;border:1px solid #3a3a3a;border-radius:3px;">
</div>
<div>
<label for="dispatch-max-runtime">Max runtime (seconds, 60-7200):</label>
<input type="number" id="dispatch-max-runtime" name="max_runtime" value="1800" min="60" max="7200"
style="width:100%;padding:6px;background:#1a1a1a;color:#e0e0e0;border:1px solid #3a3a3a;border-radius:3px;">
</div>
</div>
<div>
<button type="submit" class="btn btn-primary">🚀 Dispatch</button>
<span id="dispatch-result" class="text-small" style="margin-left:10px;"></span>
</div>
</form>
</div>
<h2 class="mt-20">📦 Project Status</h2>
<div class="card">
<table>
<thead>
<tr>
<th>Name</th>
<th>Branch</th>
<th>Last Commit</th>
<th>Time</th>
<th>Dirty</th>
</tr>
</thead>
<tbody>
{% for proj in projects %}
<tr>
<td><a href="/projects/{{ proj.name }}">{{ proj.name }}</a></td>
<td>{{ proj.branch or 'N/A' }}</td>
<td class="text-small">{{ proj.commit_short }} {{ proj.commit_msg[:40] }}</td>
<td>{% if proj.commit_time %}{{ proj.commit_time|int|rel }}{% else %}N/A{% endif %}</td>
<td>{{ proj.dirty_count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View File

@@ -0,0 +1,70 @@
{% extends "base.html" %}
{% block title %}{{ name }} - Project Detail{% endblock %}
{% block content %}
<h2>📦 {{ name }}</h2>
{% if project.error %}
<div class="card">
<p class="text-muted">Error: {{ project.error }}</p>
</div>
{% else %}
<div class="grid-2">
<div>
<div class="card">
<h3>Repository Info</h3>
<p><strong>Path:</strong> <span class="text-small">{{ project.path }}</span></p>
<p><strong>Branch:</strong> {{ project.branch or 'N/A' }}</p>
<p><strong>Status:</strong> {{ project.status }}</p>
{% if project.gitea_repo %}
<p><strong>Gitea:</strong> <a href="http://localhost:3000/admin/{{ project.gitea_repo }}" target="_blank">{{ project.gitea_repo }} ↗</a></p>
{% endif %}
</div>
<div class="card">
<h3>Latest Commit</h3>
{% if project.commit_hash %}
<p><strong>Hash:</strong> <span class="text-small">{{ project.commit_hash }}</span></p>
<p><strong>Message:</strong> {{ project.commit_msg }}</p>
<p><strong>Time:</strong> {% if project.commit_time %}{{ project.commit_time|int|dt }} ({{ project.commit_time|int|rel }}){% else %}N/A{% endif %}</p>
{% else %}
<p class="text-muted">No commits found</p>
{% endif %}
</div>
</div>
<div>
<div class="card">
<h3>Git Status</h3>
{% if project.status_porcelain %}
<pre>{{ project.status_porcelain }}</pre>
{% else %}
<p class="text-muted">Clean working directory</p>
{% endif %}
</div>
{% if project.diff_stat %}
<div class="card">
<h3>Last Commit Diff Stat</h3>
<pre>{{ project.diff_stat }}</pre>
</div>
{% endif %}
</div>
</div>
<div class="card mt-20">
<h3>Recent Commits (last 10)</h3>
{% if project.recent_commits %}
<pre>{% for commit in project.recent_commits %}{{ commit }}
{% endfor %}</pre>
{% else %}
<p class="text-muted">No commits found</p>
{% endif %}
</div>
{% endif %}
<p class="mt-20">
<a href="/projects" class="btn">← Back to Projects</a>
</p>
{% endblock %}

46
templates/projects.html Normal file
View File

@@ -0,0 +1,46 @@
{% extends "base.html" %}
{% block title %}Projects - Hermes{% endblock %}
{% block content %}
<h2>📦 Managed Projects</h2>
<div class="card">
<table>
<thead>
<tr>
<th>Name</th>
<th>Path</th>
<th>Branch</th>
<th>Last Commit</th>
<th>Time</th>
<th>Dirty</th>
<th>Gitea</th>
</tr>
</thead>
<tbody>
{% for proj in projects %}
<tr>
<td><a href="/projects/{{ proj.name }}">{{ proj.name }}</a></td>
<td class="text-small">{{ proj.path }}</td>
<td>{{ proj.branch or 'N/A' }}</td>
<td class="text-small">
{% if proj.commit_short %}
{{ proj.commit_short }} {{ proj.commit_msg[:50] }}
{% else %}
<span class="text-muted">{{ proj.status }}</span>
{% endif %}
</td>
<td>{% if proj.commit_time %}{{ proj.commit_time|int|rel }}{% else %}N/A{% endif %}</td>
<td>{{ proj.dirty_count }}</td>
<td>
{% if proj.gitea_repo %}
<a href="http://localhost:3000/admin/{{ proj.gitea_repo }}" target="_blank"></a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

144
templates/task_detail.html Normal file
View File

@@ -0,0 +1,144 @@
{% extends "base.html" %}
{% block title %}Task #{{ task_id }} - Hermes{% endblock %}
{% block content %}
{% if data.error %}
<h2>Error</h2>
<div class="card">
<p class="text-muted">{{ data.error }}</p>
</div>
{% else %}
{% set task = data.task %}
<h2>📋 Task #{{ task.id }}: {{ task.title }}</h2>
<div class="grid-2">
<div>
<div class="card">
<h3>Task Info</h3>
<p><strong>Status:</strong> <span class="status-badge status-{{ task.status }}">{{ task.status }}</span></p>
<p><strong>Assignee:</strong> {{ task.assignee or 'N/A' }}</p>
<p><strong>Priority:</strong> {{ task.priority or 'N/A' }}</p>
<p><strong>Workspace:</strong> <span class="text-small">{{ task.workspace_path or 'N/A' }}</span></p>
<p><strong>Created:</strong> {% if task.created_at %}{{ task.created_at|int|dt }}{% else %}N/A{% endif %}</p>
{% if task.started_at %}
<p><strong>Started:</strong> {{ task.started_at|int|dt }} ({{ task.started_at|int|rel }})</p>
{% endif %}
{% if task.completed_at %}
<p><strong>Completed:</strong> {{ task.completed_at|int|dt }} ({{ task.completed_at|int|rel }})</p>
{% endif %}
</div>
<div class="card">
<h3>Description</h3>
{% if task.body %}
<pre>{{ task.body[:500] }}</pre>
{% else %}
<p class="text-muted">No description</p>
{% endif %}
</div>
{% if task.result %}
<div class="card">
<h3>Result</h3>
<pre>{{ task.result }}</pre>
</div>
{% endif %}
</div>
<div>
<div class="card">
<h3>Timeline ({{ data.events|length }} events)</h3>
{% if data.events %}
{% for event in data.events %}
<div class="timeline-item">
<div class="timeline-item-header">
{{ event.created_at|int|dt }} - {{ event.kind }}
</div>
<div class="timeline-item-content">
{% if event.payload %}
<pre class="text-small">{{ event.payload }}</pre>
{% endif %}
</div>
</div>
{% endfor %}
{% else %}
<p class="text-muted">No events</p>
{% endif %}
</div>
</div>
</div>
<div class="card mt-20">
<h3>Comments ({{ data.comments|length }})</h3>
{% if data.comments %}
{% for comment in data.comments %}
<div class="comment">
<div class="comment-header">
<strong>{{ comment.author or 'Anonymous' }}</strong> - {{ comment.created_at|int|dt }}
</div>
<div>{{ comment.body }}</div>
</div>
{% endfor %}
{% else %}
<p class="text-muted">No comments</p>
{% endif %}
</div>
<div class="card mt-20">
<h3>Runs ({{ data.runs|length }})</h3>
{% if data.runs %}
<table>
<thead>
<tr>
<th>ID</th>
<th>Profile</th>
<th>Status</th>
<th>PID</th>
<th>Started</th>
<th>Ended</th>
<th>Outcome</th>
</tr>
</thead>
<tbody>
{% for run in data.runs %}
<tr>
<td>{{ run.id }}</td>
<td>{{ run.profile or 'N/A' }}</td>
<td><span class="status-badge status-{{ run.status }}">{{ run.status }}</span></td>
<td>{{ run.worker_pid or 'N/A' }}</td>
<td>{% if run.started_at %}{{ run.started_at|int|dt }}{% else %}N/A{% endif %}</td>
<td>{% if run.ended_at %}{{ run.ended_at|int|dt }}{% else %}N/A{% endif %}</td>
<td>{{ run.outcome or 'N/A' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">No runs</p>
{% endif %}
</div>
<div class="card mt-20">
<h3>Attachments ({{ data.attachments|length }})</h3>
{% if data.attachments %}
<ul class="attachment-list">
{% for attachment in data.attachments %}
<li>
<strong>{{ attachment.filename }}</strong>
<span class="text-muted">({{ attachment.content_type }}, {{ attachment.size }} bytes)</span>
<br>
<span class="text-small">Uploaded by {{ attachment.uploaded_by or 'unknown' }} on {{ attachment.created_at|int|dt }}</span>
</li>
{% endfor %}
</ul>
{% else %}
<p class="text-muted">No attachments</p>
{% endif %}
</div>
{% endif %}
<p class="mt-20">
<a href="/tasks" class="btn">← Back to Tasks</a>
</p>
{% endblock %}

43
templates/tasks.html Normal file
View File

@@ -0,0 +1,43 @@
{% extends "base.html" %}
{% block title %}Tasks - Hermes{% endblock %}
{% block content %}
<h2>📋 Tasks</h2>
<div class="filter-buttons">
<a href="/tasks" class="btn {% if not current_status %}active{% endif %}">All ({{ counts.get('ready', 0) + counts.get('running', 0) + counts.get('done', 0) + counts.get('blocked', 0) + counts.get('failed', 0) }})</a>
<a href="/tasks?status=ready" class="btn {% if current_status == 'ready' %}active{% endif %}">Ready ({{ counts.get('ready', 0) }})</a>
<a href="/tasks?status=running" class="btn {% if current_status == 'running' %}active{% endif %}">Running ({{ counts.get('running', 0) }})</a>
<a href="/tasks?status=done" class="btn {% if current_status == 'done' %}active{% endif %}">Done ({{ counts.get('done', 0) }})</a>
<a href="/tasks?status=blocked" class="btn {% if current_status == 'blocked' %}active{% endif %}">Blocked ({{ counts.get('blocked', 0) }})</a>
<a href="/tasks?status=failed" class="btn {% if current_status == 'failed' %}active{% endif %}">Failed ({{ counts.get('failed', 0) }})</a>
</div>
<div class="card">
<table>
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Status</th>
<th>Assignee</th>
<th>Started</th>
<th>Completed</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr>
<td><a href="/tasks/{{ task.id }}">#{{ task.id }}</a></td>
<td>{{ task.title[:80] }}</td>
<td><span class="status-badge status-{{ task.status }}">{{ task.status }}</span></td>
<td>{{ task.assignee or 'N/A' }}</td>
<td>{% if task.started_at %}{{ task.started_at|int|rel }}{% else %}N/A{% endif %}</td>
<td>{% if task.completed_at %}{{ task.completed_at|int|rel }}{% else %}N/A{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}