@bonesofspring/ai-rules 0.2.52 → 0.2.53
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.
- package/CHANGELOG.md +24 -0
- package/README.md +27 -3
- package/bin/cli.js +551 -60
- package/bin/lib/engine-scripts.js +10 -0
- package/bin/lib/mcp/clients.js +168 -0
- package/bin/lib/mcp/credentials.js +298 -0
- package/bin/lib/mcp/doctor.js +394 -0
- package/bin/lib/mcp/prompt.js +115 -0
- package/bin/lib/mcp/registry.js +170 -0
- package/bin/lib/mcp/run.js +123 -0
- package/bin/lib/merged-config.js +45 -0
- package/bin/lib/seed-ai-local-team.js +5 -0
- package/bin/lib/tool-installs.js +27 -0
- package/docs/MCP-SETUP.md +62 -0
- package/docs/PRESET-CONTRIBUTION.md +3 -1
- package/docs/TEAM-DB.md +173 -0
- package/docs/openapi/team-db.v1.json +5085 -0
- package/mcp/gitlab.mjs +123 -0
- package/mcp/lib/envfile.mjs +126 -0
- package/mcp/lib/yandex.mjs +384 -0
- package/mcp/yandex-mcp-proxy.mjs +155 -0
- package/mcp/yandex-token-refresh.mjs +65 -0
- package/package.json +14 -1
- package/presets/_shared/ai-local/scripts/manifest.mjs +99 -0
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +1275 -0
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +1067 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +1301 -0
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +1506 -0
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +831 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +251 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +109 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/android-kotlin/team/README.md +10 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/go/team/README.md +10 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/ios-swift/team/README.md +10 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/java/team/README.md +10 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/mcp-ts/team/README.md +10 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/next/team/README.md +10 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/nuxt/team/README.md +10 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-hexagonal/team/README.md +10 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-laravel/team/README.md +10 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/svelte/team/README.md +10 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/android-kotlin/team/README.md +10 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/go/team/README.md +10 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/ios-swift/team/README.md +10 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/java/team/README.md +10 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/mcp-ts/team/README.md +10 -0
- package/presets/cursor/next/MCP.md +7 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/next/team/README.md +10 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/nuxt/team/README.md +10 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-hexagonal/team/README.md +10 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-laravel/team/README.md +10 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/svelte/team/README.md +10 -0
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/android-kotlin/team/README.md +10 -0
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/go/team/README.md +10 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/ios-swift/team/README.md +10 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/java/team/README.md +10 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/mcp-ts/team/README.md +10 -0
- package/presets/mavis/next/MCP.md +7 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/next/team/README.md +10 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/nuxt/team/README.md +10 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-hexagonal/team/README.md +10 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-laravel/team/README.md +10 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/svelte/team/README.md +10 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/android-kotlin/team/README.md +10 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/go/team/README.md +10 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/ios-swift/team/README.md +10 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/java/team/README.md +10 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/mcp-ts/team/README.md +10 -0
- package/presets/opencode/next/MCP.md +7 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/next/team/README.md +10 -0
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/nuxt/team/README.md +10 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-hexagonal/team/README.md +10 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-laravel/team/README.md +10 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/svelte/team/README.md +10 -0
|
@@ -0,0 +1,1067 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The no-build operator dashboard.
|
|
3
|
+
*
|
|
4
|
+
* Three strings and nothing else: `DASHBOARD_HTML`, `DASHBOARD_CSS`,
|
|
5
|
+
* `DASHBOARD_JS`. The API serves them from memory, so a consumer needs no
|
|
6
|
+
* bundler, package script, asset directory, web font or external request.
|
|
7
|
+
*
|
|
8
|
+
* Rules the shipped client keeps (asserted by `test-team-db-dashboard.mjs`):
|
|
9
|
+
* same-origin relative URLs only, every dynamic value through `textContent`,
|
|
10
|
+
* no HTML sink, and exactly one mutating call — the rescan behind a confirm.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const DASHBOARD_HTML = `<!doctype html>
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<head>
|
|
16
|
+
<meta charset="utf-8">
|
|
17
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
18
|
+
<title>Agent team projection</title>
|
|
19
|
+
<link rel="stylesheet" href="/assets/app.css">
|
|
20
|
+
<script src="/assets/app.js" defer></script>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<a class="skip-link" href="#main">Skip to content</a>
|
|
24
|
+
<header class="page-header">
|
|
25
|
+
<h1>Agent team projection</h1>
|
|
26
|
+
<p class="lede">Task files are authoritative. This page reads the local SQLite projection over the loopback API.</p>
|
|
27
|
+
<div id="banner" class="banner" role="status" aria-live="polite" hidden></div>
|
|
28
|
+
</header>
|
|
29
|
+
<main id="main">
|
|
30
|
+
<section id="view-list" aria-labelledby="list-heading">
|
|
31
|
+
<h2 id="list-heading">Tasks</h2>
|
|
32
|
+
<form id="filters" class="filters" role="search" aria-label="Task filters">
|
|
33
|
+
<div class="field">
|
|
34
|
+
<label for="filter-q">Search</label>
|
|
35
|
+
<input id="filter-q" name="q" type="search" autocomplete="off" aria-describedby="filter-q-help">
|
|
36
|
+
<p id="filter-q-help" class="help">Slug, title, artifact summary, document or prompt text.</p>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="field">
|
|
39
|
+
<label for="filter-status">Status</label>
|
|
40
|
+
<select id="filter-status" name="status">
|
|
41
|
+
<option value="">Any</option>
|
|
42
|
+
<option value="in_progress">in_progress</option>
|
|
43
|
+
<option value="completed">completed</option>
|
|
44
|
+
<option value="changes_requested">changes_requested</option>
|
|
45
|
+
<option value="validation_failed">validation_failed</option>
|
|
46
|
+
<option value="blocked">blocked</option>
|
|
47
|
+
<option value="awaiting_approval">awaiting_approval</option>
|
|
48
|
+
<option value="awaiting_artifact_receipt">awaiting_artifact_receipt</option>
|
|
49
|
+
</select>
|
|
50
|
+
</div>
|
|
51
|
+
<div class="field">
|
|
52
|
+
<label for="filter-agent">Agent</label>
|
|
53
|
+
<input id="filter-agent" name="agent" type="text" autocomplete="off">
|
|
54
|
+
</div>
|
|
55
|
+
<div class="field">
|
|
56
|
+
<label for="filter-intent">Intent</label>
|
|
57
|
+
<input id="filter-intent" name="intent" type="text" autocomplete="off">
|
|
58
|
+
</div>
|
|
59
|
+
<div class="field">
|
|
60
|
+
<label for="filter-profile">Profile</label>
|
|
61
|
+
<select id="filter-profile" name="profile">
|
|
62
|
+
<option value="">Any</option>
|
|
63
|
+
<option value="light">light</option>
|
|
64
|
+
<option value="standard">standard</option>
|
|
65
|
+
<option value="full">full</option>
|
|
66
|
+
</select>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="field">
|
|
69
|
+
<label for="filter-from">Updated from</label>
|
|
70
|
+
<input id="filter-from" name="from" type="date">
|
|
71
|
+
</div>
|
|
72
|
+
<div class="field">
|
|
73
|
+
<label for="filter-to">Updated to</label>
|
|
74
|
+
<input id="filter-to" name="to" type="date">
|
|
75
|
+
</div>
|
|
76
|
+
<div class="field">
|
|
77
|
+
<label for="sort">Sort</label>
|
|
78
|
+
<select id="sort" name="sort">
|
|
79
|
+
<option value="-updatedAt">Newest update</option>
|
|
80
|
+
<option value="updatedAt">Oldest update</option>
|
|
81
|
+
<option value="-startAt">Newest start</option>
|
|
82
|
+
<option value="startAt">Oldest start</option>
|
|
83
|
+
<option value="slug">Slug A–Z</option>
|
|
84
|
+
<option value="-slug">Slug Z–A</option>
|
|
85
|
+
</select>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="field checkbox">
|
|
88
|
+
<input id="filter-absent" name="includeAbsent" type="checkbox">
|
|
89
|
+
<label for="filter-absent">Include absent tasks</label>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="actions">
|
|
92
|
+
<button id="apply" type="submit">Apply</button>
|
|
93
|
+
<button id="reset" type="button">Reset</button>
|
|
94
|
+
<button id="rescan" type="button">Rescan</button>
|
|
95
|
+
<a id="link-stats" href="/api/v1/stats">Stats JSON</a>
|
|
96
|
+
</div>
|
|
97
|
+
</form>
|
|
98
|
+
<p id="state-loading" class="state" role="status" aria-live="polite" hidden>Loading…</p>
|
|
99
|
+
<p id="state-empty" class="state" role="status" aria-live="polite" hidden>No tasks match these filters.</p>
|
|
100
|
+
<p id="state-error" class="state error" role="alert" hidden></p>
|
|
101
|
+
<table id="task-list" class="tasks">
|
|
102
|
+
<caption>Tasks in the local projection</caption>
|
|
103
|
+
<thead>
|
|
104
|
+
<tr>
|
|
105
|
+
<th scope="col">Task</th>
|
|
106
|
+
<th scope="col">Status</th>
|
|
107
|
+
<th scope="col">Intent</th>
|
|
108
|
+
<th scope="col">Profile</th>
|
|
109
|
+
<th scope="col">Stack / platform</th>
|
|
110
|
+
<th scope="col">Current agent</th>
|
|
111
|
+
<th scope="col">Gate</th>
|
|
112
|
+
<th scope="col">Updated</th>
|
|
113
|
+
<th scope="col">Start</th>
|
|
114
|
+
<th scope="col">End</th>
|
|
115
|
+
<th scope="col">Duration</th>
|
|
116
|
+
<th scope="col">Attempts</th>
|
|
117
|
+
</tr>
|
|
118
|
+
</thead>
|
|
119
|
+
<tbody id="task-rows"></tbody>
|
|
120
|
+
</table>
|
|
121
|
+
<button id="load-more" type="button" hidden>Load more</button>
|
|
122
|
+
</section>
|
|
123
|
+
<section id="view-detail" aria-labelledby="detail-heading" hidden>
|
|
124
|
+
<h2 id="detail-heading">Task detail</h2>
|
|
125
|
+
<p class="detail-nav"><a id="back-to-list" href="/">Back to all tasks</a></p>
|
|
126
|
+
<section id="detail-status" class="panel" data-endpoint="/api/v1/tasks/{slug}" data-view="status" aria-labelledby="detail-status-title">
|
|
127
|
+
<h3 id="detail-status-title">Status</h3>
|
|
128
|
+
<div class="panel-body"></div>
|
|
129
|
+
</section>
|
|
130
|
+
<section id="detail-stats" class="panel" data-endpoint="/api/v1/tasks/{slug}" data-view="stats" aria-labelledby="detail-stats-title">
|
|
131
|
+
<h3 id="detail-stats-title">Counts</h3>
|
|
132
|
+
<div class="panel-body"></div>
|
|
133
|
+
</section>
|
|
134
|
+
<section id="detail-pipeline" class="panel" data-endpoint="/api/v1/tasks/{slug}/pipeline" data-view="pipeline" aria-labelledby="detail-pipeline-title">
|
|
135
|
+
<h3 id="detail-pipeline-title">Pipeline</h3>
|
|
136
|
+
<div class="panel-body"></div>
|
|
137
|
+
</section>
|
|
138
|
+
<section id="detail-durations" class="panel" data-endpoint="/api/v1/tasks/{slug}/metrics" data-view="durations" aria-labelledby="detail-durations-title">
|
|
139
|
+
<h3 id="detail-durations-title">Durations</h3>
|
|
140
|
+
<div class="panel-body"></div>
|
|
141
|
+
</section>
|
|
142
|
+
<section id="detail-attempts" class="panel" data-endpoint="/api/v1/tasks/{slug}/attempts?limit=200" data-view="attempts" aria-labelledby="detail-attempts-title">
|
|
143
|
+
<h3 id="detail-attempts-title">Agent and attempt timeline</h3>
|
|
144
|
+
<div class="panel-body"></div>
|
|
145
|
+
</section>
|
|
146
|
+
<section id="detail-gates" class="panel" data-endpoint="/api/v1/tasks/{slug}/gates" data-view="gates" aria-labelledby="detail-gates-title">
|
|
147
|
+
<h3 id="detail-gates-title">Human gates</h3>
|
|
148
|
+
<div class="panel-body"></div>
|
|
149
|
+
</section>
|
|
150
|
+
<section id="detail-artifacts" class="panel" data-endpoint="/api/v1/tasks/{slug}/artifacts" data-view="artifacts" aria-labelledby="detail-artifacts-title">
|
|
151
|
+
<h3 id="detail-artifacts-title">Artifacts</h3>
|
|
152
|
+
<div class="panel-body"></div>
|
|
153
|
+
</section>
|
|
154
|
+
<section id="detail-documents" class="panel" data-endpoint="/api/v1/tasks/{slug}/documents?limit=200" data-view="documents" aria-labelledby="detail-documents-title">
|
|
155
|
+
<h3 id="detail-documents-title">Raw documents</h3>
|
|
156
|
+
<div class="panel-body"></div>
|
|
157
|
+
</section>
|
|
158
|
+
<section id="detail-metrics" class="panel" data-endpoint="/api/v1/tasks/{slug}/metrics" data-view="metrics" aria-labelledby="detail-metrics-title">
|
|
159
|
+
<h3 id="detail-metrics-title">Metrics</h3>
|
|
160
|
+
<div class="panel-body"></div>
|
|
161
|
+
</section>
|
|
162
|
+
<details id="detail-prompts" class="panel" data-endpoint="/api/v1/tasks/{slug}/prompts" data-view="prompts">
|
|
163
|
+
<summary>Prompts (verbatim, local only)</summary>
|
|
164
|
+
<div class="panel-body"></div>
|
|
165
|
+
</details>
|
|
166
|
+
<p class="detail-actions"><a id="link-export" href="/api/v1/tasks">Download task JSON</a></p>
|
|
167
|
+
</section>
|
|
168
|
+
</main>
|
|
169
|
+
<footer class="page-footer">
|
|
170
|
+
<p>Read-only surface. The only mutation is the rescan, which re-reads task files. <a href="/api/v1/sync-runs">Rescan history</a>.</p>
|
|
171
|
+
</footer>
|
|
172
|
+
</body>
|
|
173
|
+
</html>
|
|
174
|
+
`;
|
|
175
|
+
|
|
176
|
+
export const DASHBOARD_CSS = `:root {
|
|
177
|
+
color-scheme: light;
|
|
178
|
+
--text: #111827;
|
|
179
|
+
--muted: #4b5563;
|
|
180
|
+
--error: #b00020;
|
|
181
|
+
--focus: #0b57d0;
|
|
182
|
+
--bg: #ffffff;
|
|
183
|
+
--surface: #f8fafc;
|
|
184
|
+
--border: #d1d5db;
|
|
185
|
+
--badge-bg: #eef2ff;
|
|
186
|
+
--badge-text: #1e3a8a;
|
|
187
|
+
--radius: 8px;
|
|
188
|
+
--space: 0.75rem;
|
|
189
|
+
--font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
|
|
190
|
+
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
* {
|
|
194
|
+
box-sizing: border-box;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
body {
|
|
198
|
+
margin: 0;
|
|
199
|
+
padding: 0 1.25rem 3rem;
|
|
200
|
+
background: var(--bg);
|
|
201
|
+
color: var(--text);
|
|
202
|
+
font-family: var(--font);
|
|
203
|
+
font-size: 16px;
|
|
204
|
+
line-height: 1.5;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
h1,
|
|
208
|
+
h2,
|
|
209
|
+
h3 {
|
|
210
|
+
line-height: 1.25;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
h2 {
|
|
214
|
+
margin-top: 1.5rem;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
a {
|
|
218
|
+
color: var(--focus);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
a:hover {
|
|
222
|
+
text-decoration-thickness: 2px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.skip-link {
|
|
226
|
+
position: absolute;
|
|
227
|
+
left: -9999px;
|
|
228
|
+
top: 0;
|
|
229
|
+
padding: 0.5rem 0.75rem;
|
|
230
|
+
background: var(--bg);
|
|
231
|
+
color: var(--text);
|
|
232
|
+
border: 2px solid var(--focus);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.skip-link:focus {
|
|
236
|
+
left: 0.5rem;
|
|
237
|
+
z-index: 10;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
:focus-visible {
|
|
241
|
+
outline: 2px solid var(--focus);
|
|
242
|
+
outline-offset: 2px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.page-header .lede,
|
|
246
|
+
.help,
|
|
247
|
+
.page-footer,
|
|
248
|
+
.state {
|
|
249
|
+
color: var(--muted);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.banner {
|
|
253
|
+
margin: 0.75rem 0;
|
|
254
|
+
padding: 0.6rem 0.8rem;
|
|
255
|
+
border: 1px solid var(--border);
|
|
256
|
+
border-left: 4px solid var(--error);
|
|
257
|
+
border-radius: var(--radius);
|
|
258
|
+
background: var(--surface);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.filters {
|
|
262
|
+
display: grid;
|
|
263
|
+
grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
|
|
264
|
+
gap: var(--space);
|
|
265
|
+
align-items: start;
|
|
266
|
+
margin: 1rem 0;
|
|
267
|
+
padding: var(--space);
|
|
268
|
+
border: 1px solid var(--border);
|
|
269
|
+
border-radius: var(--radius);
|
|
270
|
+
background: var(--surface);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.field {
|
|
274
|
+
display: flex;
|
|
275
|
+
flex-direction: column;
|
|
276
|
+
gap: 0.25rem;
|
|
277
|
+
min-width: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.field label {
|
|
281
|
+
font-weight: 600;
|
|
282
|
+
font-size: 0.9rem;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.field input,
|
|
286
|
+
.field select {
|
|
287
|
+
font: inherit;
|
|
288
|
+
color: var(--text);
|
|
289
|
+
background: var(--bg);
|
|
290
|
+
border: 1px solid var(--border);
|
|
291
|
+
border-radius: 6px;
|
|
292
|
+
padding: 0.35rem 0.45rem;
|
|
293
|
+
min-width: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.field.checkbox {
|
|
297
|
+
flex-direction: row;
|
|
298
|
+
align-items: center;
|
|
299
|
+
gap: 0.5rem;
|
|
300
|
+
padding-top: 1.6rem;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.help {
|
|
304
|
+
margin: 0;
|
|
305
|
+
font-size: 0.8rem;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.actions,
|
|
309
|
+
.detail-actions {
|
|
310
|
+
grid-column: 1 / -1;
|
|
311
|
+
display: flex;
|
|
312
|
+
flex-wrap: wrap;
|
|
313
|
+
gap: 0.6rem;
|
|
314
|
+
align-items: center;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
button {
|
|
318
|
+
font: inherit;
|
|
319
|
+
padding: 0.4rem 0.8rem;
|
|
320
|
+
border-radius: 6px;
|
|
321
|
+
border: 1px solid var(--focus);
|
|
322
|
+
background: var(--bg);
|
|
323
|
+
color: var(--focus);
|
|
324
|
+
cursor: pointer;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
button:hover {
|
|
328
|
+
background: var(--badge-bg);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.state {
|
|
332
|
+
margin: 0.5rem 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.state.error {
|
|
336
|
+
color: var(--error);
|
|
337
|
+
font-weight: 600;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.tasks {
|
|
341
|
+
width: 100%;
|
|
342
|
+
border-collapse: collapse;
|
|
343
|
+
font-size: 0.9rem;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.tasks caption {
|
|
347
|
+
text-align: left;
|
|
348
|
+
color: var(--muted);
|
|
349
|
+
padding-bottom: 0.4rem;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.tasks th,
|
|
353
|
+
.tasks td {
|
|
354
|
+
text-align: left;
|
|
355
|
+
vertical-align: top;
|
|
356
|
+
padding: 0.45rem 0.5rem;
|
|
357
|
+
border-bottom: 1px solid var(--border);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.tasks thead th {
|
|
361
|
+
position: sticky;
|
|
362
|
+
top: 0;
|
|
363
|
+
background: var(--bg);
|
|
364
|
+
white-space: nowrap;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.tasks tbody tr:hover {
|
|
368
|
+
background: var(--surface);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.badge {
|
|
372
|
+
display: inline-block;
|
|
373
|
+
padding: 0.1rem 0.45rem;
|
|
374
|
+
border-radius: 999px;
|
|
375
|
+
background: var(--badge-bg);
|
|
376
|
+
color: var(--badge-text);
|
|
377
|
+
font-size: 0.8rem;
|
|
378
|
+
font-weight: 600;
|
|
379
|
+
white-space: nowrap;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.badge[data-state="completed"] {
|
|
383
|
+
background: #e7f6ec;
|
|
384
|
+
color: #14532d;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.badge[data-state="blocked"],
|
|
388
|
+
.badge[data-state="validation_failed"],
|
|
389
|
+
.badge[data-state="changes_requested"] {
|
|
390
|
+
background: #fdecec;
|
|
391
|
+
color: var(--error);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.mono {
|
|
395
|
+
font-family: var(--mono);
|
|
396
|
+
font-size: 0.85rem;
|
|
397
|
+
word-break: break-word;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.panel {
|
|
401
|
+
margin: 1rem 0;
|
|
402
|
+
padding: var(--space);
|
|
403
|
+
border: 1px solid var(--border);
|
|
404
|
+
border-radius: var(--radius);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.panel h3 {
|
|
408
|
+
margin: 0 0 0.5rem;
|
|
409
|
+
font-size: 1rem;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.panel table {
|
|
413
|
+
width: 100%;
|
|
414
|
+
border-collapse: collapse;
|
|
415
|
+
font-size: 0.85rem;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.panel th,
|
|
419
|
+
.panel td {
|
|
420
|
+
text-align: left;
|
|
421
|
+
vertical-align: top;
|
|
422
|
+
padding: 0.3rem 0.4rem;
|
|
423
|
+
border-bottom: 1px solid var(--border);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.panel pre {
|
|
427
|
+
margin: 0.3rem 0 0;
|
|
428
|
+
padding: 0.6rem;
|
|
429
|
+
max-height: 22rem;
|
|
430
|
+
overflow: auto;
|
|
431
|
+
background: var(--surface);
|
|
432
|
+
border: 1px solid var(--border);
|
|
433
|
+
border-radius: 6px;
|
|
434
|
+
font-family: var(--mono);
|
|
435
|
+
font-size: 0.8rem;
|
|
436
|
+
white-space: pre-wrap;
|
|
437
|
+
word-break: break-word;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.section-error {
|
|
441
|
+
color: var(--error);
|
|
442
|
+
font-weight: 600;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.kv {
|
|
446
|
+
display: grid;
|
|
447
|
+
grid-template-columns: minmax(9rem, 14rem) 1fr;
|
|
448
|
+
gap: 0.2rem 0.8rem;
|
|
449
|
+
margin: 0;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.kv dt {
|
|
453
|
+
color: var(--muted);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.kv dd {
|
|
457
|
+
margin: 0;
|
|
458
|
+
overflow-wrap: anywhere;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@media (prefers-reduced-motion: reduce) {
|
|
462
|
+
* {
|
|
463
|
+
transition: none !important;
|
|
464
|
+
animation: none !important;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
@media (max-width: 720px) {
|
|
469
|
+
body {
|
|
470
|
+
padding: 0 0.6rem 2rem;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.tasks {
|
|
474
|
+
display: block;
|
|
475
|
+
overflow-x: auto;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.kv {
|
|
479
|
+
grid-template-columns: 1fr;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
`;
|
|
483
|
+
|
|
484
|
+
export const DASHBOARD_JS = `(function () {
|
|
485
|
+
'use strict';
|
|
486
|
+
|
|
487
|
+
var STATUS = ['in_progress', 'completed', 'changes_requested', 'validation_failed', 'blocked', 'awaiting_approval', 'awaiting_artifact_receipt'];
|
|
488
|
+
var PAGE_SIZE = 50;
|
|
489
|
+
var state = { offset: 0, total: 0, slug: '' };
|
|
490
|
+
var cache = {};
|
|
491
|
+
|
|
492
|
+
var byId = function (id) {
|
|
493
|
+
return document.getElementById(id);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
var text = function (tag, value, className) {
|
|
497
|
+
var node = document.createElement(tag);
|
|
498
|
+
node.textContent = value === null || value === undefined || value === '' ? '—' : String(value);
|
|
499
|
+
if (className) node.className = className;
|
|
500
|
+
return node;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
var clear = function (node) {
|
|
504
|
+
while (node.firstChild) node.removeChild(node.firstChild);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
var describeError = function (error) {
|
|
508
|
+
var code = error && error.code ? error.code : 'E_INTERNAL';
|
|
509
|
+
var message = error && error.message ? error.message : 'request failed';
|
|
510
|
+
var action = '';
|
|
511
|
+
if (code === 'E_DB_MISSING') action = ' Run: node .ai.local/scripts/team-db.mjs sync';
|
|
512
|
+
else if (code === 'E_SCHEMA_MISMATCH' || code === 'E_SCHEMA_OUTDATED' || code === 'E_DB_CORRUPT') action = ' Run: node .ai.local/scripts/team-db.mjs sync --rebuild';
|
|
513
|
+
else if (code === 'E_DISABLED') action = ' Unset AI_RULES_TEAM_DB_DISABLE to enable the projection.';
|
|
514
|
+
else if (code === 'E_BUSY') action = ' The database is busy; retry in a moment.';
|
|
515
|
+
return { code: code, message: message + action };
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
var showError = function (error) {
|
|
519
|
+
var target = byId('state-error');
|
|
520
|
+
var described = describeError(error);
|
|
521
|
+
target.textContent = described.code + ': ' + described.message;
|
|
522
|
+
target.hidden = false;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
var hideError = function () {
|
|
526
|
+
var target = byId('state-error');
|
|
527
|
+
target.hidden = true;
|
|
528
|
+
target.textContent = '';
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
var setLoading = function (loading) {
|
|
532
|
+
byId('state-loading').hidden = !loading;
|
|
533
|
+
byId('task-list').setAttribute('aria-busy', loading ? 'true' : 'false');
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
var request = function (url, options) {
|
|
537
|
+
return fetch(url, options).then(function (response) {
|
|
538
|
+
return response.text().then(function (body) {
|
|
539
|
+
var parsed = null;
|
|
540
|
+
try {
|
|
541
|
+
parsed = body ? JSON.parse(body) : null;
|
|
542
|
+
} catch (parseError) {
|
|
543
|
+
parsed = null;
|
|
544
|
+
}
|
|
545
|
+
if (!response.ok) {
|
|
546
|
+
var envelope = parsed && parsed.error ? parsed.error : { code: 'E_INTERNAL', message: response.status + ' ' + response.statusText };
|
|
547
|
+
var failure = new Error(envelope.message || 'request failed');
|
|
548
|
+
failure.code = envelope.code || 'E_INTERNAL';
|
|
549
|
+
failure.status = response.status;
|
|
550
|
+
throw failure;
|
|
551
|
+
}
|
|
552
|
+
return parsed;
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
var cached = function (url) {
|
|
558
|
+
if (!cache[url]) cache[url] = request(url);
|
|
559
|
+
return cache[url];
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
var formatDuration = function (ms) {
|
|
563
|
+
if (ms === null || ms === undefined) return '—';
|
|
564
|
+
var seconds = Math.round(Number(ms) / 1000);
|
|
565
|
+
if (seconds < 60) return seconds + 's';
|
|
566
|
+
var minutes = Math.floor(seconds / 60);
|
|
567
|
+
if (minutes < 60) return minutes + 'm ' + (seconds % 60) + 's';
|
|
568
|
+
var hours = Math.floor(minutes / 60);
|
|
569
|
+
return hours + 'h ' + (minutes % 60) + 'm';
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
var formatDate = function (value) {
|
|
573
|
+
if (!value) return '—';
|
|
574
|
+
var parsed = new Date(value);
|
|
575
|
+
if (Number.isNaN(parsed.getTime())) return value;
|
|
576
|
+
return parsed.toISOString().replace('T', ' ').replace('.000Z', 'Z');
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
var isoTimestamp = function (value, endOfDay) {
|
|
580
|
+
if (!value) return '';
|
|
581
|
+
return value + (endOfDay ? 'T23:59:59.999Z' : 'T00:00:00.000Z');
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
var readFilters = function () {
|
|
585
|
+
var params = new URLSearchParams();
|
|
586
|
+
var q = byId('filter-q').value.trim();
|
|
587
|
+
var status = byId('filter-status').value;
|
|
588
|
+
var agent = byId('filter-agent').value.trim();
|
|
589
|
+
var intent = byId('filter-intent').value.trim();
|
|
590
|
+
var profile = byId('filter-profile').value;
|
|
591
|
+
var from = byId('filter-from').value;
|
|
592
|
+
var to = byId('filter-to').value;
|
|
593
|
+
var sort = byId('sort').value;
|
|
594
|
+
var includeAbsent = byId('filter-absent').checked;
|
|
595
|
+
if (q) params.set('q', q);
|
|
596
|
+
if (status) params.set('status', status);
|
|
597
|
+
if (agent) params.set('agent', agent);
|
|
598
|
+
if (intent) params.set('intent', intent);
|
|
599
|
+
if (profile) params.set('profile', profile);
|
|
600
|
+
if (from) params.set('from', isoTimestamp(from, false));
|
|
601
|
+
if (to) params.set('to', isoTimestamp(to, true));
|
|
602
|
+
if (sort) params.set('sort', sort);
|
|
603
|
+
if (includeAbsent) params.set('includeAbsent', 'true');
|
|
604
|
+
params.set('limit', String(PAGE_SIZE));
|
|
605
|
+
params.set('offset', String(state.offset));
|
|
606
|
+
return params;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
var writeUrl = function () {
|
|
610
|
+
var params = readFilters();
|
|
611
|
+
params.delete('limit');
|
|
612
|
+
params.delete('offset');
|
|
613
|
+
if (state.slug) params.set('slug', state.slug);
|
|
614
|
+
var next = params.toString();
|
|
615
|
+
history.replaceState(null, '', next ? '/?' + next : '/');
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
var applyUrlState = function () {
|
|
619
|
+
var params = new URLSearchParams(window.location.search);
|
|
620
|
+
var map = {
|
|
621
|
+
q: 'filter-q',
|
|
622
|
+
agent: 'filter-agent',
|
|
623
|
+
intent: 'filter-intent',
|
|
624
|
+
from: 'filter-from',
|
|
625
|
+
to: 'filter-to'
|
|
626
|
+
};
|
|
627
|
+
Object.keys(map).forEach(function (key) {
|
|
628
|
+
var value = params.get(key);
|
|
629
|
+
if (!value) return;
|
|
630
|
+
byId(map[key]).value = key === 'from' || key === 'to' ? value.slice(0, 10) : value;
|
|
631
|
+
});
|
|
632
|
+
var status = params.get('status');
|
|
633
|
+
if (status && STATUS.indexOf(status) !== -1) byId('filter-status').value = status;
|
|
634
|
+
var profile = params.get('profile');
|
|
635
|
+
if (profile) byId('filter-profile').value = profile;
|
|
636
|
+
var sort = params.get('sort');
|
|
637
|
+
if (sort) byId('sort').value = sort;
|
|
638
|
+
if (params.get('includeAbsent') === 'true') byId('filter-absent').checked = true;
|
|
639
|
+
return params.get('slug') || '';
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
var badge = function (value) {
|
|
643
|
+
var node = text('span', value, 'badge');
|
|
644
|
+
if (value) node.setAttribute('data-state', String(value));
|
|
645
|
+
return node;
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
var row = function (task) {
|
|
649
|
+
var tr = document.createElement('tr');
|
|
650
|
+
var head = document.createElement('th');
|
|
651
|
+
head.setAttribute('scope', 'row');
|
|
652
|
+
var link = document.createElement('a');
|
|
653
|
+
link.href = '/?slug=' + encodeURIComponent(task.slug);
|
|
654
|
+
link.textContent = task.slug;
|
|
655
|
+
link.addEventListener('click', function (event) {
|
|
656
|
+
event.preventDefault();
|
|
657
|
+
openDetail(task.slug);
|
|
658
|
+
});
|
|
659
|
+
head.appendChild(link);
|
|
660
|
+
tr.appendChild(head);
|
|
661
|
+
tr.appendChild((function () { var td = document.createElement('td'); td.appendChild(badge(task.state)); return td; })());
|
|
662
|
+
tr.appendChild(text('td', task.intent));
|
|
663
|
+
tr.appendChild(text('td', task.profile));
|
|
664
|
+
tr.appendChild(text('td', [task.stack, task.platform].filter(Boolean).join(' / ')));
|
|
665
|
+
tr.appendChild(text('td', task.currentAgent));
|
|
666
|
+
tr.appendChild(text('td', task.gateState));
|
|
667
|
+
tr.appendChild(text('td', formatDate(task.updatedAt)));
|
|
668
|
+
tr.appendChild(text('td', formatDate(task.startAt)));
|
|
669
|
+
tr.appendChild(text('td', formatDate(task.endAt)));
|
|
670
|
+
tr.appendChild(text('td', formatDuration(task.durationMs)));
|
|
671
|
+
tr.appendChild(text('td', task.attempts));
|
|
672
|
+
return tr;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
var renderList = function (payload) {
|
|
676
|
+
var body = byId('task-rows');
|
|
677
|
+
if (state.offset === 0) clear(body);
|
|
678
|
+
payload.items.forEach(function (task) {
|
|
679
|
+
body.appendChild(row(task));
|
|
680
|
+
});
|
|
681
|
+
state.total = payload.total;
|
|
682
|
+
var shown = body.children.length;
|
|
683
|
+
byId('state-empty').hidden = payload.total !== 0;
|
|
684
|
+
byId('task-list').hidden = payload.total === 0;
|
|
685
|
+
byId('load-more').hidden = !payload.nextOffset;
|
|
686
|
+
byId('load-more').textContent = 'Load more (' + shown + ' of ' + payload.total + ')';
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
var loadList = function () {
|
|
690
|
+
setLoading(true);
|
|
691
|
+
hideError();
|
|
692
|
+
var params = readFilters();
|
|
693
|
+
return request('/api/v1/tasks?' + params.toString())
|
|
694
|
+
.then(function (payload) {
|
|
695
|
+
renderList(payload);
|
|
696
|
+
writeUrl();
|
|
697
|
+
})
|
|
698
|
+
.catch(function (error) {
|
|
699
|
+
showError(error);
|
|
700
|
+
})
|
|
701
|
+
.then(function () {
|
|
702
|
+
setLoading(false);
|
|
703
|
+
});
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
var definition = function (label, value) {
|
|
707
|
+
var dt = text('dt', label);
|
|
708
|
+
var dd = document.createElement('dd');
|
|
709
|
+
if (value && typeof value === 'object' && value.nodeType) dd.appendChild(value);
|
|
710
|
+
else dd.textContent = value === null || value === undefined || value === '' ? '—' : String(value);
|
|
711
|
+
return [dt, dd];
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
var kv = function (pairs) {
|
|
715
|
+
var list = document.createElement('dl');
|
|
716
|
+
list.className = 'kv';
|
|
717
|
+
pairs.forEach(function (pair) {
|
|
718
|
+
var entry = definition(pair[0], pair[1]);
|
|
719
|
+
list.appendChild(entry[0]);
|
|
720
|
+
list.appendChild(entry[1]);
|
|
721
|
+
});
|
|
722
|
+
return list;
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
var miniTable = function (headers, rows) {
|
|
726
|
+
var table = document.createElement('table');
|
|
727
|
+
var thead = document.createElement('thead');
|
|
728
|
+
var headRow = document.createElement('tr');
|
|
729
|
+
headers.forEach(function (header) {
|
|
730
|
+
var th = text('th', header);
|
|
731
|
+
th.setAttribute('scope', 'col');
|
|
732
|
+
headRow.appendChild(th);
|
|
733
|
+
});
|
|
734
|
+
thead.appendChild(headRow);
|
|
735
|
+
table.appendChild(thead);
|
|
736
|
+
var tbody = document.createElement('tbody');
|
|
737
|
+
rows.forEach(function (values) {
|
|
738
|
+
var tr = document.createElement('tr');
|
|
739
|
+
values.forEach(function (value) {
|
|
740
|
+
var td = document.createElement('td');
|
|
741
|
+
if (value && typeof value === 'object' && value.nodeType) td.appendChild(value);
|
|
742
|
+
else td.textContent = value === null || value === undefined || value === '' ? '—' : String(value);
|
|
743
|
+
tr.appendChild(td);
|
|
744
|
+
});
|
|
745
|
+
tbody.appendChild(tr);
|
|
746
|
+
});
|
|
747
|
+
table.appendChild(tbody);
|
|
748
|
+
return table;
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
var views = {
|
|
752
|
+
status: function (payload) {
|
|
753
|
+
var task = payload.task;
|
|
754
|
+
return kv([
|
|
755
|
+
['Slug', task.slug],
|
|
756
|
+
['State', badge(task.state)],
|
|
757
|
+
['Phase', task.phase],
|
|
758
|
+
['Intent', task.intent],
|
|
759
|
+
['Profile', task.profile],
|
|
760
|
+
['Spec mode', task.specMode],
|
|
761
|
+
['Pipeline index', task.pipelineIndex],
|
|
762
|
+
['Current agent', task.currentAgent],
|
|
763
|
+
['Awaiting human gate', task.awaitingHumanGate ? 'yes' : 'no'],
|
|
764
|
+
['Gate', task.gateState],
|
|
765
|
+
['Stack / platform', [task.stack, task.platform].filter(Boolean).join(' / ')],
|
|
766
|
+
['Start', formatDate(task.startAt)],
|
|
767
|
+
['End', formatDate(task.endAt)],
|
|
768
|
+
['Duration', formatDuration(task.durationMs)],
|
|
769
|
+
['Updated', formatDate(task.updatedAt)],
|
|
770
|
+
['Projected', formatDate(task.projectedAt)],
|
|
771
|
+
['Last seen', formatDate(task.lastSeenAt)],
|
|
772
|
+
['Absent', task.absentAt ? formatDate(task.absentAt) : 'no'],
|
|
773
|
+
['Routing', payload.routing && payload.routing.summary ? payload.routing.summary : '—']
|
|
774
|
+
]);
|
|
775
|
+
},
|
|
776
|
+
stats: function (payload) {
|
|
777
|
+
var counts = payload.counts || {};
|
|
778
|
+
return kv([
|
|
779
|
+
['Events', counts.events],
|
|
780
|
+
['Attempts', counts.attempts],
|
|
781
|
+
['Gates', counts.gates],
|
|
782
|
+
['Prompts', counts.prompts],
|
|
783
|
+
['Documents', counts.documents],
|
|
784
|
+
['Has prompt', payload.hasPrompt ? 'yes' : 'no']
|
|
785
|
+
]);
|
|
786
|
+
},
|
|
787
|
+
pipeline: function (payload) {
|
|
788
|
+
var rows = payload.steps.map(function (step) {
|
|
789
|
+
return [
|
|
790
|
+
step.index,
|
|
791
|
+
step.label,
|
|
792
|
+
step.agents.join(', '),
|
|
793
|
+
step.state,
|
|
794
|
+
step.dependsOn.join(', '),
|
|
795
|
+
step.taskIds.join(', '),
|
|
796
|
+
step.writeScopes.join(', ')
|
|
797
|
+
];
|
|
798
|
+
});
|
|
799
|
+
return miniTable(['#', 'Step', 'Agents', 'State', 'Depends on', 'Tasks', 'Write scopes'], rows);
|
|
800
|
+
},
|
|
801
|
+
durations: function (payload) {
|
|
802
|
+
var byAgent = payload.byAgent.map(function (entry) {
|
|
803
|
+
return [entry.agent, entry.attempts, formatDuration(entry.durationMs)];
|
|
804
|
+
});
|
|
805
|
+
var byStep = payload.byStep.map(function (entry) {
|
|
806
|
+
return [entry.stepIndex, entry.attempts, formatDuration(entry.durationMs)];
|
|
807
|
+
});
|
|
808
|
+
var wrapper = document.createElement('div');
|
|
809
|
+
wrapper.appendChild(kv([['Total attempt time', formatDuration(payload.totalAttemptDurationMs)]]));
|
|
810
|
+
wrapper.appendChild(miniTable(['Agent', 'Attempts', 'Duration'], byAgent));
|
|
811
|
+
wrapper.appendChild(miniTable(['Step', 'Attempts', 'Duration'], byStep));
|
|
812
|
+
return wrapper;
|
|
813
|
+
},
|
|
814
|
+
attempts: function (payload) {
|
|
815
|
+
var rows = payload.items.map(function (attempt) {
|
|
816
|
+
return [
|
|
817
|
+
attempt.agent,
|
|
818
|
+
attempt.role,
|
|
819
|
+
attempt.stepIndex,
|
|
820
|
+
attempt.attempt,
|
|
821
|
+
formatDate(attempt.startedAt),
|
|
822
|
+
formatDate(attempt.finishedAt),
|
|
823
|
+
formatDuration(attempt.durationMs),
|
|
824
|
+
attempt.outcome
|
|
825
|
+
];
|
|
826
|
+
});
|
|
827
|
+
return miniTable(['Agent', 'Role', 'Step', 'Attempt', 'Started', 'Finished', 'Duration', 'Outcome'], rows);
|
|
828
|
+
},
|
|
829
|
+
gates: function (payload) {
|
|
830
|
+
var rows = payload.items.map(function (gate) {
|
|
831
|
+
return [formatDate(gate.startedAt), formatDate(gate.endedAt), formatDuration(gate.durationMs), gate.startEventId];
|
|
832
|
+
});
|
|
833
|
+
return miniTable(['Started', 'Ended', 'Duration', 'Start event'], rows);
|
|
834
|
+
},
|
|
835
|
+
artifacts: function (payload) {
|
|
836
|
+
var rows = payload.items.map(function (artifact) {
|
|
837
|
+
return [
|
|
838
|
+
artifact.id,
|
|
839
|
+
artifact.producer,
|
|
840
|
+
artifact.status,
|
|
841
|
+
artifact.outcome,
|
|
842
|
+
artifact.acceptanceCriteriaIds.join(', '),
|
|
843
|
+
artifact.paths.authoritative.join(', '),
|
|
844
|
+
artifact.paths.evidence.join(', '),
|
|
845
|
+
artifact.summary
|
|
846
|
+
];
|
|
847
|
+
});
|
|
848
|
+
return miniTable(['Id', 'Producer', 'Status', 'Outcome', 'AC ids', 'Authoritative', 'Evidence', 'Summary'], rows);
|
|
849
|
+
},
|
|
850
|
+
documents: function (payload) {
|
|
851
|
+
var wrapper = document.createElement('div');
|
|
852
|
+
wrapper.appendChild(miniTable(['Path', 'Bytes', 'Media type', 'SHA-256', 'Omitted', 'Parse error'], payload.items.map(function (document) {
|
|
853
|
+
return [document.path, document.bytes, document.mediaType, document.sha256 ? document.sha256.slice(0, 12) : '—', document.contentOmitted, document.parseError];
|
|
854
|
+
})));
|
|
855
|
+
var preview = document.createElement('pre');
|
|
856
|
+
preview.className = 'document-preview';
|
|
857
|
+
preview.hidden = true;
|
|
858
|
+
var buttons = document.createElement('div');
|
|
859
|
+
buttons.className = 'actions';
|
|
860
|
+
payload.items.slice(0, 40).forEach(function (document) {
|
|
861
|
+
if (!document.isText || document.contentOmitted) return;
|
|
862
|
+
var open = text('button', 'Open ' + document.path);
|
|
863
|
+
open.type = 'button';
|
|
864
|
+
open.addEventListener('click', function () {
|
|
865
|
+
openDocument(state.slug, document.path, preview);
|
|
866
|
+
});
|
|
867
|
+
buttons.appendChild(open);
|
|
868
|
+
});
|
|
869
|
+
wrapper.appendChild(buttons);
|
|
870
|
+
wrapper.appendChild(preview);
|
|
871
|
+
return wrapper;
|
|
872
|
+
},
|
|
873
|
+
metrics: function (payload) {
|
|
874
|
+
var wrapper = document.createElement('div');
|
|
875
|
+
var counts = Object.keys(payload.eventCounts).sort().map(function (type) {
|
|
876
|
+
return [type, payload.eventCounts[type]];
|
|
877
|
+
});
|
|
878
|
+
wrapper.appendChild(kv([
|
|
879
|
+
['Run id', payload.runId],
|
|
880
|
+
['Total attempt time', formatDuration(payload.totalAttemptDurationMs)]
|
|
881
|
+
]));
|
|
882
|
+
wrapper.appendChild(miniTable(['Event type', 'Count'], counts));
|
|
883
|
+
return wrapper;
|
|
884
|
+
},
|
|
885
|
+
prompts: function (payload) {
|
|
886
|
+
var wrapper = document.createElement('div');
|
|
887
|
+
if (!payload.prompt) {
|
|
888
|
+
wrapper.appendChild(text('p', 'No prompt recorded for this task.'));
|
|
889
|
+
return wrapper;
|
|
890
|
+
}
|
|
891
|
+
var entries = [payload.prompt].concat(payload.log || []);
|
|
892
|
+
entries.forEach(function (entry) {
|
|
893
|
+
var title = text('h4', (entry.kind === 'prompt' ? 'Prompt' : 'Prompt log #' + entry.seq) + ' — ' + (entry.command || entry.source || 'user'));
|
|
894
|
+
var meta = text('p', (entry.capturedAt || '') + ' · ' + entry.bytes + ' bytes · ' + (entry.language || 'unknown'));
|
|
895
|
+
var pre = text('pre', entry.content);
|
|
896
|
+
wrapper.appendChild(title);
|
|
897
|
+
wrapper.appendChild(meta);
|
|
898
|
+
wrapper.appendChild(pre);
|
|
899
|
+
});
|
|
900
|
+
return wrapper;
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
var openDocument = function (slug, path, preview) {
|
|
905
|
+
var url = '/api/v1/tasks/' + encodeURIComponent(slug) + '/document?path=' + encodeURIComponent(path);
|
|
906
|
+
preview.hidden = false;
|
|
907
|
+
preview.textContent = 'Loading…';
|
|
908
|
+
request(url).then(function (document) {
|
|
909
|
+
preview.textContent = document.content + (document.truncated ? '\\n… truncated at ' + document.limit + ' bytes of ' + document.totalBytes : '');
|
|
910
|
+
}).catch(function (error) {
|
|
911
|
+
var described = describeError(error);
|
|
912
|
+
preview.textContent = described.code + ': ' + described.message;
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
var renderSection = function (section, payload) {
|
|
917
|
+
var body = section.querySelector('.panel-body');
|
|
918
|
+
clear(body);
|
|
919
|
+
var view = section.getAttribute('data-view');
|
|
920
|
+
var render = views[view];
|
|
921
|
+
if (!render) {
|
|
922
|
+
body.appendChild(text('p', 'No renderer for ' + view));
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
body.appendChild(render(payload));
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
var loadSection = function (section, slug) {
|
|
929
|
+
var endpoint = section.getAttribute('data-endpoint').replace('{slug}', encodeURIComponent(slug));
|
|
930
|
+
var body = section.querySelector('.panel-body');
|
|
931
|
+
clear(body);
|
|
932
|
+
body.appendChild(text('p', 'Loading…', 'section-state'));
|
|
933
|
+
return cached(endpoint)
|
|
934
|
+
.then(function (payload) {
|
|
935
|
+
renderSection(section, payload);
|
|
936
|
+
})
|
|
937
|
+
.catch(function (error) {
|
|
938
|
+
var described = describeError(error);
|
|
939
|
+
clear(body);
|
|
940
|
+
body.appendChild(text('p', described.code + ': ' + described.message, 'section-error'));
|
|
941
|
+
});
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
var openDetail = function (slug) {
|
|
945
|
+
state.slug = slug;
|
|
946
|
+
cache = {};
|
|
947
|
+
byId('view-list').hidden = true;
|
|
948
|
+
byId('view-detail').hidden = false;
|
|
949
|
+
byId('link-export').href = '/api/v1/tasks/' + encodeURIComponent(slug) + '/export';
|
|
950
|
+
writeUrl();
|
|
951
|
+
var sections = document.querySelectorAll('#view-detail [data-endpoint]');
|
|
952
|
+
Array.prototype.forEach.call(sections, function (section) {
|
|
953
|
+
// Prompt text is the most sensitive content: it is fetched only when the
|
|
954
|
+
// disclosure is opened, not on every detail view.
|
|
955
|
+
var disclosure = section.closest ? section.closest('details') : null;
|
|
956
|
+
if (disclosure && !disclosure.open) {
|
|
957
|
+
var onOpen = function () {
|
|
958
|
+
if (!disclosure.open) return;
|
|
959
|
+
disclosure.removeEventListener('toggle', onOpen);
|
|
960
|
+
loadSection(section, slug);
|
|
961
|
+
};
|
|
962
|
+
disclosure.addEventListener('toggle', onOpen);
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
loadSection(section, slug);
|
|
966
|
+
});
|
|
967
|
+
request('/api/v1/tasks/' + encodeURIComponent(slug))
|
|
968
|
+
.then(function (payload) {
|
|
969
|
+
document.title = payload.task.slug + ' — agent team projection';
|
|
970
|
+
})
|
|
971
|
+
.catch(function (error) {
|
|
972
|
+
var described = describeError(error);
|
|
973
|
+
var heading = byId('detail-heading');
|
|
974
|
+
heading.textContent = 'Task not found';
|
|
975
|
+
showError(error);
|
|
976
|
+
var panel = byId('detail-status');
|
|
977
|
+
clear(panel.querySelector('.panel-body'));
|
|
978
|
+
panel.querySelector('.panel-body').appendChild(text('p', described.code + ': ' + described.message, 'section-error'));
|
|
979
|
+
});
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
var showList = function () {
|
|
983
|
+
state.slug = '';
|
|
984
|
+
byId('view-detail').hidden = true;
|
|
985
|
+
byId('view-list').hidden = false;
|
|
986
|
+
document.title = 'Agent team projection';
|
|
987
|
+
writeUrl();
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
var applyFilters = function (event) {
|
|
991
|
+
if (event) event.preventDefault();
|
|
992
|
+
state.offset = 0;
|
|
993
|
+
showList();
|
|
994
|
+
loadList();
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
var loadMore = function () {
|
|
998
|
+
if (state.offset + PAGE_SIZE >= state.total) return;
|
|
999
|
+
state.offset += PAGE_SIZE;
|
|
1000
|
+
loadList();
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
var rescan = function () {
|
|
1004
|
+
if (!confirm('Re-read task files into the local database? Task files are not changed.')) return;
|
|
1005
|
+
var button = byId('rescan');
|
|
1006
|
+
button.disabled = true;
|
|
1007
|
+
button.textContent = 'Rescanning…';
|
|
1008
|
+
request('/api/v1/sync', { method: 'POST' })
|
|
1009
|
+
.then(function (result) {
|
|
1010
|
+
byId('banner').hidden = false;
|
|
1011
|
+
byId('banner').textContent = 'Rescan ' + (result.mode || 'full') + ': inserted ' + result.inserted + ', updated ' + result.updated + ', unchanged ' + result.unchanged + ', failed ' + result.failed;
|
|
1012
|
+
return state.slug ? openDetail(state.slug) : loadList();
|
|
1013
|
+
})
|
|
1014
|
+
.catch(function (error) {
|
|
1015
|
+
showError(error);
|
|
1016
|
+
})
|
|
1017
|
+
.then(function () {
|
|
1018
|
+
button.disabled = false;
|
|
1019
|
+
button.textContent = 'Rescan';
|
|
1020
|
+
});
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
var health = function () {
|
|
1024
|
+
request('/health')
|
|
1025
|
+
.then(function (payload) {
|
|
1026
|
+
if (payload.status !== 'ok') {
|
|
1027
|
+
byId('banner').hidden = false;
|
|
1028
|
+
byId('banner').textContent = 'Projection degraded: schema ' + payload.db.schemaVersion + ', search ' + payload.db.search;
|
|
1029
|
+
}
|
|
1030
|
+
})
|
|
1031
|
+
.catch(function (error) {
|
|
1032
|
+
var described = describeError(error);
|
|
1033
|
+
byId('banner').hidden = false;
|
|
1034
|
+
byId('banner').textContent = 'Projection degraded — ' + described.code + ': ' + described.message;
|
|
1035
|
+
});
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
var bind = function () {
|
|
1039
|
+
var filters = byId('filters');
|
|
1040
|
+
if (filters) filters.addEventListener('submit', applyFilters);
|
|
1041
|
+
var apply = byId('apply');
|
|
1042
|
+
if (apply) apply.addEventListener('click', applyFilters);
|
|
1043
|
+
var reset = byId('reset');
|
|
1044
|
+
if (reset) reset.addEventListener('click', function () {
|
|
1045
|
+
filters.reset();
|
|
1046
|
+
state.offset = 0;
|
|
1047
|
+
showList();
|
|
1048
|
+
loadList();
|
|
1049
|
+
});
|
|
1050
|
+
var more = byId('load-more');
|
|
1051
|
+
if (more) more.addEventListener('click', loadMore);
|
|
1052
|
+
var re = byId('rescan');
|
|
1053
|
+
if (re) re.addEventListener('click', rescan);
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
var start = function () {
|
|
1057
|
+
bind();
|
|
1058
|
+
health();
|
|
1059
|
+
var slug = applyUrlState();
|
|
1060
|
+
if (slug) openDetail(slug);
|
|
1061
|
+
else loadList();
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);
|
|
1065
|
+
else start();
|
|
1066
|
+
})();
|
|
1067
|
+
`;
|