agent-rulebook 0.2.1 → 0.3.0
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/README.md +46 -4
- package/dist/commands/dashboard.d.ts +7 -0
- package/dist/commands/dashboard.js +42 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/diagnostics.d.ts +2 -0
- package/dist/commands/diagnostics.js +38 -0
- package/dist/commands/diagnostics.js.map +1 -0
- package/dist/commands/import.d.ts +2 -0
- package/dist/commands/import.js +34 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/pending.d.ts +2 -0
- package/dist/commands/pending.js +27 -0
- package/dist/commands/pending.js.map +1 -0
- package/dist/commands/resolution.js +25 -11
- package/dist/commands/resolution.js.map +1 -1
- package/dist/commands/stats-renderer.d.ts +3 -0
- package/dist/commands/stats-renderer.js +76 -0
- package/dist/commands/stats-renderer.js.map +1 -0
- package/dist/commands/stats.d.ts +4 -0
- package/dist/commands/stats.js +107 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +17 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.js +1 -1
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/usage.d.ts +2 -0
- package/dist/commands/usage.js +25 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/core/codex-call-parser.d.ts +10 -0
- package/dist/core/codex-call-parser.js +97 -0
- package/dist/core/codex-call-parser.js.map +1 -0
- package/dist/core/codex-usage-import.d.ts +24 -0
- package/dist/core/codex-usage-import.js +259 -0
- package/dist/core/codex-usage-import.js.map +1 -0
- package/dist/core/diagnostic-cluster.d.ts +37 -0
- package/dist/core/diagnostic-cluster.js +20 -0
- package/dist/core/diagnostic-cluster.js.map +1 -0
- package/dist/core/environment-normalization.d.ts +21 -0
- package/dist/core/environment-normalization.js +42 -0
- package/dist/core/environment-normalization.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/invocation-diagnostics.d.ts +40 -0
- package/dist/core/invocation-diagnostics.js +91 -0
- package/dist/core/invocation-diagnostics.js.map +1 -0
- package/dist/core/legacy-candidate.d.ts +159 -0
- package/dist/core/legacy-candidate.js +73 -0
- package/dist/core/legacy-candidate.js.map +1 -0
- package/dist/core/legacy-import-apply.d.ts +215 -0
- package/dist/core/legacy-import-apply.js +172 -0
- package/dist/core/legacy-import-apply.js.map +1 -0
- package/dist/core/legacy-import-manifest.d.ts +197 -0
- package/dist/core/legacy-import-manifest.js +63 -0
- package/dist/core/legacy-import-manifest.js.map +1 -0
- package/dist/core/legacy-scan.d.ts +71 -0
- package/dist/core/legacy-scan.js +99 -0
- package/dist/core/legacy-scan.js.map +1 -0
- package/dist/core/pending-replay.d.ts +4 -0
- package/dist/core/pending-replay.js +96 -0
- package/dist/core/pending-replay.js.map +1 -0
- package/dist/core/resolution-applicability.d.ts +1 -0
- package/dist/core/resolution-applicability.js +28 -11
- package/dist/core/resolution-applicability.js.map +1 -1
- package/dist/core/resolution-ranker.js +9 -2
- package/dist/core/resolution-ranker.js.map +1 -1
- package/dist/core/resolution-search-types.d.ts +9 -0
- package/dist/core/statistics-data.d.ts +98 -0
- package/dist/core/statistics-data.js +53 -0
- package/dist/core/statistics-data.js.map +1 -0
- package/dist/core/statistics-pages.d.ts +3 -0
- package/dist/core/statistics-pages.js +107 -0
- package/dist/core/statistics-pages.js.map +1 -0
- package/dist/core/statistics-query.d.ts +86 -0
- package/dist/core/statistics-query.js +51 -0
- package/dist/core/statistics-query.js.map +1 -0
- package/dist/core/statistics-types.d.ts +286 -0
- package/dist/core/statistics-types.js +2 -0
- package/dist/core/statistics-types.js.map +1 -0
- package/dist/core/statistics.d.ts +5 -0
- package/dist/core/statistics.js +101 -0
- package/dist/core/statistics.js.map +1 -0
- package/dist/core/sync-status.d.ts +53 -0
- package/dist/core/sync-status.js +85 -0
- package/dist/core/sync-status.js.map +1 -0
- package/dist/core/usage-context.d.ts +15 -0
- package/dist/core/usage-context.js +22 -0
- package/dist/core/usage-context.js.map +1 -0
- package/dist/core/usage-observer.d.ts +36 -0
- package/dist/core/usage-observer.js +112 -0
- package/dist/core/usage-observer.js.map +1 -0
- package/dist/core/usage-schema.d.ts +113 -0
- package/dist/core/usage-schema.js +33 -0
- package/dist/core/usage-schema.js.map +1 -0
- package/dist/dashboard/public/api.js +41 -0
- package/dist/dashboard/public/app.js +111 -0
- package/dist/dashboard/public/components/detail-panel.js +21 -0
- package/dist/dashboard/public/components/index.js +216 -0
- package/dist/dashboard/public/components/input-diff.js +15 -0
- package/dist/dashboard/public/diagnostic-detail.js +25 -0
- package/dist/dashboard/public/diagnostics.js +46 -0
- package/dist/dashboard/public/index.html +28 -0
- package/dist/dashboard/public/knowledge.js +57 -0
- package/dist/dashboard/public/overview.js +101 -0
- package/dist/dashboard/public/solution-detail.js +42 -0
- package/dist/dashboard/public/styles.css +205 -0
- package/dist/dashboard/server.d.ts +10 -0
- package/dist/dashboard/server.js +133 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/observed-transport.d.ts +20 -0
- package/dist/mcp/observed-transport.js +99 -0
- package/dist/mcp/observed-transport.js.map +1 -0
- package/dist/mcp/resolution-change.d.ts +1 -1
- package/dist/mcp/resolution-change.js +24 -9
- package/dist/mcp/resolution-change.js.map +1 -1
- package/dist/mcp/resolutions-commit-change-tool.d.ts +5 -0
- package/dist/mcp/resolutions-commit-change-tool.js +22 -4
- package/dist/mcp/resolutions-commit-change-tool.js.map +1 -1
- package/dist/mcp/resolutions-find-tool.d.ts +1 -2
- package/dist/mcp/resolutions-find-tool.js +43 -8
- package/dist/mcp/resolutions-find-tool.js.map +1 -1
- package/dist/mcp/resolutions-list-facets-tool.d.ts +1 -1
- package/dist/mcp/resolutions-list-facets-tool.js +16 -2
- package/dist/mcp/resolutions-list-facets-tool.js.map +1 -1
- package/dist/mcp/resolutions-report-attempt-tool.d.ts +1 -0
- package/dist/mcp/resolutions-report-attempt-tool.js +44 -55
- package/dist/mcp/resolutions-report-attempt-tool.js.map +1 -1
- package/dist/mcp/schemas.d.ts +299 -14
- package/dist/mcp/schemas.js +31 -10
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/server.js +20 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/stats-get-tool.d.ts +99 -0
- package/dist/mcp/stats-get-tool.js +17 -0
- package/dist/mcp/stats-get-tool.js.map +1 -0
- package/dist/mcp/tool-call.d.ts +99 -0
- package/dist/mcp/tool-call.js +20 -0
- package/dist/mcp/tool-call.js.map +1 -0
- package/dist/mcp/tool-output.d.ts +9 -0
- package/dist/mcp/tool-output.js +22 -0
- package/dist/mcp/tool-output.js.map +1 -1
- package/dist/mcp/tools.d.ts +182 -27
- package/dist/mcp/tools.js +9 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/program.js +14 -0
- package/dist/program.js.map +1 -1
- package/dist/storage/canonical-write-lock.d.ts +2 -0
- package/dist/storage/canonical-write-lock.js +32 -0
- package/dist/storage/canonical-write-lock.js.map +1 -0
- package/dist/storage/diagnostic-store.d.ts +21 -0
- package/dist/storage/diagnostic-store.js +50 -0
- package/dist/storage/diagnostic-store.js.map +1 -0
- package/dist/storage/import-manifest.d.ts +6 -0
- package/dist/storage/import-manifest.js +41 -0
- package/dist/storage/import-manifest.js.map +1 -0
- package/dist/storage/pending-store.d.ts +329 -0
- package/dist/storage/pending-store.js +164 -0
- package/dist/storage/pending-store.js.map +1 -0
- package/dist/storage/resolution-candidate-service.js +2 -1
- package/dist/storage/resolution-candidate-service.js.map +1 -1
- package/dist/storage/resolution-change-transaction.d.ts +41 -3
- package/dist/storage/resolution-change-transaction.js +101 -12
- package/dist/storage/resolution-change-transaction.js.map +1 -1
- package/dist/storage/resolution-home.js +1 -1
- package/dist/storage/resolution-home.js.map +1 -1
- package/dist/storage/resolution-index-check.js +3 -2
- package/dist/storage/resolution-index-check.js.map +1 -1
- package/dist/storage/resolution-indexer.js +3 -1
- package/dist/storage/resolution-indexer.js.map +1 -1
- package/dist/storage/usage-store.d.ts +80 -0
- package/dist/storage/usage-store.js +239 -0
- package/dist/storage/usage-store.js.map +1 -0
- package/package.json +11 -4
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export function element(tag, text, className) {
|
|
2
|
+
const node = document.createElement(tag);
|
|
3
|
+
if (text !== undefined)
|
|
4
|
+
node.textContent = text;
|
|
5
|
+
if (className)
|
|
6
|
+
node.className = className;
|
|
7
|
+
return node;
|
|
8
|
+
}
|
|
9
|
+
export const number = (value) => value === null ? 'Not recorded' : new Intl.NumberFormat('en').format(value);
|
|
10
|
+
export function dateTime(value, timezone) {
|
|
11
|
+
return new Intl.DateTimeFormat('en', { dateStyle: 'medium', timeStyle: 'short', timeZone: timezone }).format(new Date(value));
|
|
12
|
+
}
|
|
13
|
+
export function appShell(active) {
|
|
14
|
+
for (const link of document.querySelectorAll('nav a')) {
|
|
15
|
+
if (link.dataset.page === active)
|
|
16
|
+
link.setAttribute('aria-current', 'page');
|
|
17
|
+
else
|
|
18
|
+
link.removeAttribute('aria-current');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function stateNotice(kind, message, retry) {
|
|
22
|
+
const notice = element('section', undefined, `notice notice-${kind}`);
|
|
23
|
+
notice.setAttribute('aria-label', kind.replaceAll('_', ' '));
|
|
24
|
+
notice.append(element('strong', kind.replaceAll('_', ' ')), element('p', message));
|
|
25
|
+
if (retry) {
|
|
26
|
+
const button = element('button', 'Retry');
|
|
27
|
+
button.type = 'button';
|
|
28
|
+
button.addEventListener('click', retry);
|
|
29
|
+
notice.append(button);
|
|
30
|
+
}
|
|
31
|
+
return notice;
|
|
32
|
+
}
|
|
33
|
+
export function metricCard(options) {
|
|
34
|
+
const card = element('article', undefined, 'metric-card');
|
|
35
|
+
if (options.tone)
|
|
36
|
+
card.dataset.tone = options.tone;
|
|
37
|
+
card.append(element('h3', options.label), element('p', number(options.value) + (options.value === null ? '' : options.suffix ?? ''), 'metric-value'));
|
|
38
|
+
if (options.note)
|
|
39
|
+
card.append(element('p', options.note, 'metric-note'));
|
|
40
|
+
if (options.state)
|
|
41
|
+
card.append(element('span', options.state, 'badge'));
|
|
42
|
+
const detail = element('details');
|
|
43
|
+
detail.append(element('summary', 'How this is counted'), element('p', options.detail));
|
|
44
|
+
card.append(detail);
|
|
45
|
+
return card;
|
|
46
|
+
}
|
|
47
|
+
export const defaultFilters = { period: '30', project: '', language: '', source: 'live', timezone: 'UTC' };
|
|
48
|
+
export function filterBar(current, apply) {
|
|
49
|
+
const form = element('form', undefined, 'filter-bar');
|
|
50
|
+
form.setAttribute('aria-label', 'Dashboard filters');
|
|
51
|
+
const controls = {};
|
|
52
|
+
const advanced = element('details', undefined, 'advanced-filters');
|
|
53
|
+
const activeCount = Number(Boolean(current.project)) + Number(Boolean(current.language)) + Number(current.timezone !== 'UTC');
|
|
54
|
+
advanced.open = activeCount > 0;
|
|
55
|
+
advanced.append(element('summary', activeCount ? `More filters · ${activeCount} active` : 'More filters'));
|
|
56
|
+
const advancedFields = element('div', undefined, 'advanced-fields');
|
|
57
|
+
advanced.append(advancedFields);
|
|
58
|
+
function select(name, label, options, parent = form) {
|
|
59
|
+
const wrapper = element('label', label);
|
|
60
|
+
const input = element('select');
|
|
61
|
+
input.name = name;
|
|
62
|
+
for (const [value, text] of options) {
|
|
63
|
+
const option = element('option', text);
|
|
64
|
+
option.value = value;
|
|
65
|
+
input.append(option);
|
|
66
|
+
}
|
|
67
|
+
if (!options.some(([value]) => value === current[name])) {
|
|
68
|
+
const extra = element('option', current[name]);
|
|
69
|
+
extra.value = current[name];
|
|
70
|
+
input.append(extra);
|
|
71
|
+
}
|
|
72
|
+
input.value = current[name];
|
|
73
|
+
controls[name] = input;
|
|
74
|
+
wrapper.append(input);
|
|
75
|
+
parent.append(wrapper);
|
|
76
|
+
}
|
|
77
|
+
select('period', 'Period', [['7', 'Last 7 days'], ['30', 'Last 30 days'], ['90', 'Last 90 days'], ['all', 'All recorded time']]);
|
|
78
|
+
select('source', 'Source', [['live', 'Live'], ['codex_history', 'Imported history']]);
|
|
79
|
+
for (const [name, label] of [['project', 'Project'], ['language', 'Language']]) {
|
|
80
|
+
const wrapper = element('label', label);
|
|
81
|
+
const input = element('input');
|
|
82
|
+
input.name = name;
|
|
83
|
+
input.value = current[name];
|
|
84
|
+
input.placeholder = `All ${name === 'project' ? 'projects' : 'languages'}`;
|
|
85
|
+
input.maxLength = 200;
|
|
86
|
+
controls[name] = input;
|
|
87
|
+
wrapper.append(input);
|
|
88
|
+
advancedFields.append(wrapper);
|
|
89
|
+
}
|
|
90
|
+
select('timezone', 'Timezone', [['UTC', 'UTC'], ['Asia/Seoul', 'Asia/Seoul'], ['America/New_York', 'America/New_York'], ['Europe/London', 'Europe/London']], advancedFields);
|
|
91
|
+
const submit = element('button', 'Apply filters', 'primary');
|
|
92
|
+
submit.type = 'submit';
|
|
93
|
+
const reset = element('button', 'Reset filters', 'quiet');
|
|
94
|
+
reset.type = 'button';
|
|
95
|
+
reset.addEventListener('click', () => apply({ ...defaultFilters }));
|
|
96
|
+
form.append(advanced, submit, reset);
|
|
97
|
+
form.addEventListener('submit', (event) => { event.preventDefault(); apply(Object.fromEntries(Object.entries(controls).map(([key, input]) => [key, input.value.trim()]))); });
|
|
98
|
+
return form;
|
|
99
|
+
}
|
|
100
|
+
export function dataTable(options) {
|
|
101
|
+
const region = element('div', undefined, 'table-region');
|
|
102
|
+
region.tabIndex = 0;
|
|
103
|
+
region.setAttribute('role', 'region');
|
|
104
|
+
region.setAttribute('aria-label', options.caption);
|
|
105
|
+
const table = element('table');
|
|
106
|
+
table.append(element('caption', options.caption));
|
|
107
|
+
const head = element('thead');
|
|
108
|
+
const headers = element('tr');
|
|
109
|
+
for (const column of options.columns) {
|
|
110
|
+
const th = element('th');
|
|
111
|
+
th.scope = 'col';
|
|
112
|
+
if (column.onSort) {
|
|
113
|
+
th.setAttribute('aria-sort', column.sort ?? 'none');
|
|
114
|
+
const button = element('button', column.label);
|
|
115
|
+
button.type = 'button';
|
|
116
|
+
button.addEventListener('click', column.onSort);
|
|
117
|
+
th.append(button);
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
th.textContent = column.label;
|
|
121
|
+
headers.append(th);
|
|
122
|
+
}
|
|
123
|
+
head.append(headers);
|
|
124
|
+
table.append(head);
|
|
125
|
+
const body = element('tbody');
|
|
126
|
+
for (const row of options.rows) {
|
|
127
|
+
const tr = element('tr');
|
|
128
|
+
for (const value of row) {
|
|
129
|
+
const td = element('td');
|
|
130
|
+
typeof value === 'string' ? td.textContent = value : td.append(value);
|
|
131
|
+
tr.append(td);
|
|
132
|
+
}
|
|
133
|
+
body.append(tr);
|
|
134
|
+
}
|
|
135
|
+
if (!options.rows.length) {
|
|
136
|
+
const row = element('tr');
|
|
137
|
+
const cell = element('td', options.state === 'loading' ? 'Loading records…' : options.state === 'error' ? 'Records unavailable. Retry the request.' : 'No matching records.');
|
|
138
|
+
cell.colSpan = options.columns.length;
|
|
139
|
+
row.append(cell);
|
|
140
|
+
body.append(row);
|
|
141
|
+
}
|
|
142
|
+
table.append(body);
|
|
143
|
+
region.append(table);
|
|
144
|
+
if (options.onPage) {
|
|
145
|
+
const page = options.page ?? 1;
|
|
146
|
+
const pages = Math.max(1, options.pages ?? 1);
|
|
147
|
+
const pagination = element('div', undefined, 'pagination');
|
|
148
|
+
for (const [text, target, disabled] of [['Previous page', page - 1, page <= 1], ['Next page', page + 1, page >= pages]]) {
|
|
149
|
+
const button = element('button', text);
|
|
150
|
+
button.type = 'button';
|
|
151
|
+
button.disabled = disabled;
|
|
152
|
+
button.addEventListener('click', () => options.onPage(target));
|
|
153
|
+
pagination.append(button);
|
|
154
|
+
}
|
|
155
|
+
pagination.append(element('span', `Page ${number(page)} of ${number(pages)}`));
|
|
156
|
+
region.append(pagination);
|
|
157
|
+
}
|
|
158
|
+
return region;
|
|
159
|
+
}
|
|
160
|
+
export function breakdownBar(label, count, max) {
|
|
161
|
+
const row = element('div', undefined, 'breakdown');
|
|
162
|
+
row.append(element('span', label), element('strong', count === null ? 'Unknown' : number(count)));
|
|
163
|
+
if (count !== null) {
|
|
164
|
+
const meter = element('meter');
|
|
165
|
+
meter.min = 0;
|
|
166
|
+
meter.max = Math.max(1, max);
|
|
167
|
+
meter.value = count;
|
|
168
|
+
meter.setAttribute('aria-label', `${label}: ${number(count)}`);
|
|
169
|
+
row.append(meter);
|
|
170
|
+
}
|
|
171
|
+
return row;
|
|
172
|
+
}
|
|
173
|
+
/** A daily count chart: gaps are unknown; an outlined baseline marks measured zero. */
|
|
174
|
+
export function activityTimeline(rows) {
|
|
175
|
+
const chart = element('figure', undefined, 'activity-chart');
|
|
176
|
+
const recent = rows.slice(-30);
|
|
177
|
+
if (!recent.length) {
|
|
178
|
+
chart.append(stateNotice('not_recorded', 'No daily observations in this period.'));
|
|
179
|
+
return chart;
|
|
180
|
+
}
|
|
181
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
182
|
+
svg.setAttribute('viewBox', '0 0 720 168');
|
|
183
|
+
svg.setAttribute('role', 'img');
|
|
184
|
+
svg.setAttribute('aria-label', 'Daily search activity. Unknown days are gaps, not zero. Exact values are in the daily table.');
|
|
185
|
+
const max = Math.max(2, Math.ceil(Math.max(...recent.map(row => row.find_calls ?? 0)) / 2) * 2);
|
|
186
|
+
function shape(tag, attributes, text) {
|
|
187
|
+
const node = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
|
188
|
+
for (const [key, value] of Object.entries(attributes))
|
|
189
|
+
node.setAttribute(key, value);
|
|
190
|
+
if (text !== undefined)
|
|
191
|
+
node.textContent = text;
|
|
192
|
+
svg.append(node);
|
|
193
|
+
return node;
|
|
194
|
+
}
|
|
195
|
+
for (const [y, value] of [[16, max], [76, Math.round(max / 2)], [136, 0]]) {
|
|
196
|
+
shape('line', { x1: '32', x2: '716', y1: String(y), y2: String(y), class: 'chart-grid' });
|
|
197
|
+
shape('text', { x: '0', y: String(y + 4), class: 'chart-tick' }, number(value));
|
|
198
|
+
}
|
|
199
|
+
const step = 680 / recent.length;
|
|
200
|
+
for (const [index, row] of recent.entries()) {
|
|
201
|
+
const height = row.find_calls === null ? 12 : Math.max(3, row.find_calls / max * 120);
|
|
202
|
+
const bar = shape('rect', { x: String(36 + index * step), y: String(136 - height), width: String(Math.max(2, step - 6)), height: String(height), rx: '4', class: row.find_calls === null ? 'chart-unknown' : row.find_calls === 0 ? 'chart-zero' : row.partial ? 'chart-bar chart-partial' : 'chart-bar' });
|
|
203
|
+
const title = document.createElementNS('http://www.w3.org/2000/svg', 'title');
|
|
204
|
+
title.textContent = `${row.date}: ${row.find_calls === null ? 'Unknown' : number(row.find_calls)}${row.partial ? ' · Partial coverage' : ''}`;
|
|
205
|
+
bar.append(title);
|
|
206
|
+
}
|
|
207
|
+
chart.append(svg);
|
|
208
|
+
const dates = element('figcaption', undefined, 'chart-dates');
|
|
209
|
+
dates.append(element('span', recent[0].date), element('span', recent[recent.length - 1].date));
|
|
210
|
+
chart.append(dates);
|
|
211
|
+
const legend = element('div', undefined, 'chart-legend');
|
|
212
|
+
for (const [label, kind] of [['Observed searches', 'observed'], ['Partial coverage', 'partial'], ['Unknown ≠ zero', 'unknown']])
|
|
213
|
+
legend.append(element('span', label, kind));
|
|
214
|
+
chart.append(legend);
|
|
215
|
+
return chart;
|
|
216
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dataTable, element, stateNotice } from './index.js';
|
|
2
|
+
export function inputDiff(options) {
|
|
3
|
+
const root = element('section');
|
|
4
|
+
root.append(element('h3', 'Input comparison'));
|
|
5
|
+
root.append(dataTable({ caption: 'Rejected fields', columns: [{ label: 'Field' }, { label: 'Expected' }, { label: 'Received' }, { label: 'Issue' }], rows: options.issues.map(issue => [issue.path || '(root)', `+ ${issue.expected}`, `− ${issue.received}`, issue.code]) }));
|
|
6
|
+
root.append(element('h3', '− Rejected input (redacted)'), element('pre', JSON.stringify(options.before, null, 2)));
|
|
7
|
+
root.append(element('h3', '+ Explicit retry input'));
|
|
8
|
+
if (options.after !== undefined)
|
|
9
|
+
root.append(element('pre', JSON.stringify(options.after, null, 2)));
|
|
10
|
+
else
|
|
11
|
+
root.append(stateNotice('unknown', options.linked ? 'A retry is explicitly linked, but its input was not retained. No corrected payload is inferred.' : 'No explicit retry is linked. Other calls remain unrelated.'));
|
|
12
|
+
if (options.truncated)
|
|
13
|
+
root.append(stateNotice('truncated', 'The representation reached its size or depth limit. Omitted fields cannot be reconstructed.'));
|
|
14
|
+
return root;
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dataTable, element, number, stateNotice } from './components/index.js';
|
|
2
|
+
import { inputDiff } from './components/input-diff.js';
|
|
3
|
+
export function diagnosticDetail(detail) {
|
|
4
|
+
const root = element('div');
|
|
5
|
+
if (!detail) {
|
|
6
|
+
root.append(stateNotice('not_found', 'This diagnostic is unavailable in the selected source, project or language.'));
|
|
7
|
+
return root;
|
|
8
|
+
}
|
|
9
|
+
const { record, metadata, retries } = detail;
|
|
10
|
+
const diagnostic = record.diagnostic;
|
|
11
|
+
root.append(element('p', record.tool, 'eyebrow'), stateNotice('redacted', `Raw payload not retained. Redacted: yes. Truncated: ${diagnostic.truncated ? 'yes' : 'no'}.`));
|
|
12
|
+
root.append(dataTable({ caption: 'Invocation provenance', columns: [{ label: 'Field' }, { label: 'Recorded value' }], rows: [['Invocation ID', record.invocation_id], ['Client', metadata?.client_name ?? 'Unknown caller'], ['Client version', metadata?.client_version ?? 'Unknown'], ['Supplied agent', metadata?.supplied_agent ?? 'Unknown'], ['Supplied model', metadata?.supplied_model ?? 'Unknown'], ['Package version', metadata?.package_version ?? 'Unknown'], ['Schema digest', record.schema_digest], ['Category', metadata?.category ?? 'Unknown'], ['Source / confidence', `${metadata?.source ?? 'Unknown'} / ${metadata?.confidence ?? 'Unknown'}`], ['Investigation trace', metadata?.investigation_id ?? 'Unlinked'], ['Project', metadata?.project_key ?? 'Unknown']] }));
|
|
13
|
+
const shape = element('details');
|
|
14
|
+
shape.append(element('summary', 'Recorded input shape'), element('pre', JSON.stringify(diagnostic.input_shape, null, 2)));
|
|
15
|
+
root.append(shape);
|
|
16
|
+
root.append(inputDiff({ before: diagnostic.redacted_preview, after: retries.find(retry => retry.diagnostic)?.diagnostic?.redacted_preview, issues: diagnostic.issues, linked: detail.retry_total > 0, truncated: diagnostic.truncated }));
|
|
17
|
+
root.append(dataTable({ caption: `Explicit retries (${number(detail.retry_total)} total; up to 20 shown)`, columns: [{ label: 'Invocation ID' }, { label: 'Status' }, { label: 'Result' }], rows: retries.map(retry => [retry.invocation_id, retry.status, retry.category ?? 'Unknown']) }));
|
|
18
|
+
const download = element('button', 'Download fixture');
|
|
19
|
+
download.type = 'button';
|
|
20
|
+
const announcement = element('p');
|
|
21
|
+
announcement.setAttribute('role', 'status');
|
|
22
|
+
download.addEventListener('click', () => { const blob = new Blob([JSON.stringify(detail.fixture, null, 2) + '\n'], { type: 'application/json' }); const url = URL.createObjectURL(blob); const anchor = element('a'); anchor.href = url; anchor.download = `rulebook-diagnostic-${record.diagnostic_id}.json`; root.append(anchor); anchor.click(); anchor.remove(); setTimeout(() => URL.revokeObjectURL(url), 1000); announcement.textContent = 'Sanitized fixture download requested. Review placeholders before using it in a test.'; });
|
|
23
|
+
root.append(download, announcement, element('p', 'Export → review placeholders → add a failing test → improve schema or agent instructions → verify the same test → track this cluster’s error rate.', 'muted'));
|
|
24
|
+
return root;
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { dataTable, dateTime, element, number, stateNotice } from './components/index.js';
|
|
2
|
+
import { filterQuery, readFilters } from './api.js';
|
|
3
|
+
export function diagnosticQuery(search) {
|
|
4
|
+
const params = new URLSearchParams(search);
|
|
5
|
+
const query = filterQuery(readFilters(search));
|
|
6
|
+
for (const key of ['tool', 'client_name', 'schema_digest', 'category', 'page', 'page_size', 'cluster_key'])
|
|
7
|
+
if (params.get(key))
|
|
8
|
+
query.set(key, params.get(key));
|
|
9
|
+
return query;
|
|
10
|
+
}
|
|
11
|
+
export function renderDiagnostics(data, search, change) {
|
|
12
|
+
const root = element('div');
|
|
13
|
+
const params = new URLSearchParams(search);
|
|
14
|
+
const form = element('form', undefined, 'filter-bar');
|
|
15
|
+
form.setAttribute('aria-label', 'Diagnostic filters');
|
|
16
|
+
const controls = {};
|
|
17
|
+
for (const [name, label] of [['tool', 'Tool'], ['client_name', 'Client'], ['schema_digest', 'Schema digest']]) {
|
|
18
|
+
const wrapper = element('label', label);
|
|
19
|
+
const input = element('input');
|
|
20
|
+
input.value = params.get(name) ?? '';
|
|
21
|
+
input.maxLength = 128;
|
|
22
|
+
controls[name] = input;
|
|
23
|
+
wrapper.append(input);
|
|
24
|
+
form.append(wrapper);
|
|
25
|
+
}
|
|
26
|
+
const label = element('label', 'Error category');
|
|
27
|
+
const select = element('select');
|
|
28
|
+
for (const value of ['', 'validation_error', 'domain_error', 'protocol_error']) {
|
|
29
|
+
const option = element('option', value || 'All categories');
|
|
30
|
+
option.value = value;
|
|
31
|
+
select.append(option);
|
|
32
|
+
}
|
|
33
|
+
select.value = params.get('category') ?? '';
|
|
34
|
+
controls.category = select;
|
|
35
|
+
label.append(select);
|
|
36
|
+
form.append(label);
|
|
37
|
+
const apply = element('button', 'Filter diagnostics');
|
|
38
|
+
apply.type = 'submit';
|
|
39
|
+
form.append(apply);
|
|
40
|
+
form.addEventListener('submit', event => { event.preventDefault(); change({ ...Object.fromEntries(Object.entries(controls).map(([key, input]) => [key, input.value.trim() || null])), page: null, detail: null }); });
|
|
41
|
+
root.append(form);
|
|
42
|
+
root.append(stateNotice(data.coverage.status, `${data.query.source === 'live' ? 'Live calls' : 'Imported history: confidence may be confirmed, inferred or unparsed'}. Raw payloads are not retained. Counts cover observed records only.`));
|
|
43
|
+
const rows = data.items.map(cluster => { const button = element('button', `${cluster.tool} · ${cluster.issues[0]?.path || 'root'}`); button.type = 'button'; button.dataset.focusKey = cluster.representative_id; button.addEventListener('click', () => change({ detail: cluster.representative_id })); return [button, number(cluster.count), cluster.issues.map(issue => `${issue.path || 'root'}: ${issue.expected} ← ${issue.received}`).join('\n'), element('span', cluster.confidences?.join(', ') || 'Unknown', 'badge'), cluster.categories?.join(', ') || 'Unknown', cluster.clients.join(', '), cluster.package_versions.join(', '), dateTime(cluster.first_at, data.query.timezone), dateTime(cluster.last_at, data.query.timezone), `${number(cluster.successful_retry_count)} resolved / ${number(cluster.count)} rejected; ${number(cluster.explicit_retry_count)} explicit retries`]; });
|
|
44
|
+
root.append(dataTable({ caption: `${number(data.total)} error clusters`, columns: ['Representative call', 'Affected calls', 'Expected / received', 'Confidence', 'Category', 'Clients', 'Package versions', 'First seen', 'Last seen', 'Retry evidence'].map(label => ({ label })), rows, page: data.page, pages: data.total === null ? 1 : Math.ceil(data.total / data.page_size), onPage: page => change({ page: String(page), detail: null }) }));
|
|
45
|
+
return root;
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Agent Rulebook</title><link rel="stylesheet" href="/styles.css"><script type="module" src="/app.js"></script></head>
|
|
4
|
+
<body>
|
|
5
|
+
<a class="skip-link" href="#main">Skip to content</a>
|
|
6
|
+
<header class="app-header">
|
|
7
|
+
<div class="header-row">
|
|
8
|
+
<a class="brand" href="/">
|
|
9
|
+
<svg class="brand-mark" viewBox="0 0 40 40" aria-hidden="true"><rect width="40" height="40" rx="13"/><path d="M11 12h7a4 4 0 0 1 4 4v14a5 5 0 0 0-5-3h-6zm11 4a4 4 0 0 1 4-4h4v15h-3a5 5 0 0 0-5 3"/></svg>
|
|
10
|
+
<span>Agent Rulebook<span class="brand-caption">KNOWLEDGE & INSIGHTS</span></span>
|
|
11
|
+
</a>
|
|
12
|
+
<div class="connection-controls"><p id="connection" role="status">Connecting to your local Rulebook...</p><button id="refresh" type="button">Refresh connection</button></div>
|
|
13
|
+
</div>
|
|
14
|
+
</header>
|
|
15
|
+
<div class="workspace">
|
|
16
|
+
<aside class="sidebar">
|
|
17
|
+
<p class="nav-caption">WORKSPACE</p>
|
|
18
|
+
<nav aria-label="Main navigation">
|
|
19
|
+
<a href="/#overview" data-page="overview"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="2"/><rect x="14" y="3" width="7" height="7" rx="2"/><rect x="3" y="14" width="7" height="7" rx="2"/><rect x="14" y="14" width="7" height="7" rx="2"/></svg>Overview</a>
|
|
20
|
+
<a href="/#knowledge" data-page="knowledge"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h6a3 3 0 0 1 3 3v14a4 4 0 0 0-4-3H4zm9 3a3 3 0 0 1 3-3h4v14h-3a4 4 0 0 0-4 3"/></svg>Knowledge</a>
|
|
21
|
+
<a href="/#diagnostics" data-page="diagnostics"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12h5l3-8 4 16 3-8h5"/></svg>Diagnostics</a>
|
|
22
|
+
</nav>
|
|
23
|
+
<div class="sidebar-note"><span class="local-badge">LOCAL WORKSPACE</span><p>Your agents’ knowledge.<br>Your machine.</p><span>Read-only dashboard</span></div>
|
|
24
|
+
</aside>
|
|
25
|
+
<main id="main" class="app-main" tabindex="-1"><h1>Knowledge and usage</h1><p>Your local Rulebook, at a glance.</p><noscript>JavaScript is required to read the local dashboard.</noscript></main>
|
|
26
|
+
</div>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { dataTable, dateTime, element, number, stateNotice } from './components/index.js';
|
|
2
|
+
import { filterQuery, readFilters } from './api.js';
|
|
3
|
+
export function knowledgeQuery(search) {
|
|
4
|
+
const input = new URLSearchParams(search);
|
|
5
|
+
const query = filterQuery(readFilters(search));
|
|
6
|
+
for (const key of ['kind', 'search', 'platform', 'revision', 'page', 'page_size'])
|
|
7
|
+
if (input.get(key))
|
|
8
|
+
query.set(key, input.get(key));
|
|
9
|
+
query.set('revision_view', input.get('revision_view') ?? 'latest');
|
|
10
|
+
return query;
|
|
11
|
+
}
|
|
12
|
+
export function renderKnowledge(data, search, change) {
|
|
13
|
+
const root = element('div');
|
|
14
|
+
const params = new URLSearchParams(search);
|
|
15
|
+
const form = element('form', undefined, 'filter-bar');
|
|
16
|
+
form.setAttribute('aria-label', 'Knowledge filters');
|
|
17
|
+
const controls = {};
|
|
18
|
+
for (const [name, label, options] of [['kind', 'Record kind', [['solutions', 'Solutions'], ['problems', 'Problems'], ['pending', 'Pending captures'], ['legacy', 'Legacy imports']]], ['revision_view', 'Revision view', [['latest', 'Latest unique solutions'], ['all', 'All revisions']]], ['page_size', 'Rows per page', [['25', '25'], ['50', '50'], ['100', '100']]]]) {
|
|
19
|
+
const wrapper = element('label', label);
|
|
20
|
+
const select = element('select');
|
|
21
|
+
for (const [value, text] of options) {
|
|
22
|
+
const option = element('option', text);
|
|
23
|
+
option.value = value;
|
|
24
|
+
select.append(option);
|
|
25
|
+
}
|
|
26
|
+
select.value = params.get(name) ?? options[0][0];
|
|
27
|
+
controls[name] = select;
|
|
28
|
+
wrapper.append(select);
|
|
29
|
+
form.append(wrapper);
|
|
30
|
+
}
|
|
31
|
+
for (const [name, label] of [['search', 'Search knowledge'], ['platform', 'Platform'], ['revision', 'Exact revision']]) {
|
|
32
|
+
const wrapper = element('label', label);
|
|
33
|
+
const input = element('input');
|
|
34
|
+
input.value = params.get(name) ?? '';
|
|
35
|
+
input.maxLength = name === 'search' ? 200 : 64;
|
|
36
|
+
if (name === 'revision') {
|
|
37
|
+
input.type = 'number';
|
|
38
|
+
input.min = '1';
|
|
39
|
+
}
|
|
40
|
+
controls[name] = input;
|
|
41
|
+
wrapper.append(input);
|
|
42
|
+
form.append(wrapper);
|
|
43
|
+
}
|
|
44
|
+
const apply = element('button', 'Search knowledge');
|
|
45
|
+
apply.type = 'submit';
|
|
46
|
+
form.append(apply);
|
|
47
|
+
form.addEventListener('submit', (event) => { event.preventDefault(); change({ ...Object.fromEntries(Object.entries(controls).map(([key, node]) => [key, node.value.trim() || null])), page: null, detail: null }); });
|
|
48
|
+
root.append(form);
|
|
49
|
+
root.append(element('p', 'Knowledge creation dates use the selected period. Choose All recorded time to include older entries. Latest view selects the highest matching revision per solution.', 'muted'));
|
|
50
|
+
if (['pending', 'legacy'].includes(params.get('kind') ?? ''))
|
|
51
|
+
root.append(stateNotice('review_required', 'These records are not verified solutions. Inspect their missing evidence before using the CLI recovery workflow.'));
|
|
52
|
+
if (data.status !== 'ok')
|
|
53
|
+
root.append(stateNotice('error', 'Knowledge could not be read completely. Check local storage health.'));
|
|
54
|
+
const rows = data.items.map((row) => { const button = element('button', row.title); button.type = 'button'; button.dataset.focusKey = row.id; button.addEventListener('click', () => change({ detail: row.id })); return [button, row.solution_handle ?? row.id, row.status, row.languages.join(', ') || 'Unknown', row.platforms.join(', ') || 'Unknown', row.created_at ? dateTime(row.created_at, data.query.timezone) : 'Unknown']; });
|
|
55
|
+
root.append(dataTable({ caption: `${number(data.total)} knowledge records`, columns: ['Title', 'Handle / revision', 'Status', 'Languages', 'Platforms', 'Created (newest first)'].map(label => ({ label })), rows, page: data.page, pages: data.total === null ? 1 : Math.ceil(data.total / data.page_size), onPage: page => change({ page: String(page), detail: null }) }));
|
|
56
|
+
return root;
|
|
57
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { activityTimeline, breakdownBar, dataTable, dateTime, element, metricCard, number, stateNotice } from './components/index.js';
|
|
2
|
+
export function renderOverview(stats) {
|
|
3
|
+
const view = element('div', undefined, 'overview');
|
|
4
|
+
const scope = `${stats.query.source === 'live' ? 'Live' : 'Imported history'} · ${stats.query.all ? 'All recorded time' : `${stats.query.days} days`} · ${stats.query.timezone}`;
|
|
5
|
+
function section(title, parent = view, className = '') {
|
|
6
|
+
const node = element('section', undefined, `panel ${className}`);
|
|
7
|
+
node.append(element('h2', title));
|
|
8
|
+
parent.append(node);
|
|
9
|
+
return node;
|
|
10
|
+
}
|
|
11
|
+
function explanation(parent, label, text) {
|
|
12
|
+
const details = element('details', undefined, 'explanation');
|
|
13
|
+
details.append(element('summary', label), element('p', text));
|
|
14
|
+
parent.append(details);
|
|
15
|
+
}
|
|
16
|
+
const activity = element('section', undefined, 'quick-stats');
|
|
17
|
+
activity.setAttribute('aria-label', 'Activity in selected period');
|
|
18
|
+
const metrics = element('div', undefined, 'metric-grid');
|
|
19
|
+
metrics.append(metricCard({ label: 'Search calls', value: stats.activity.find_calls, note: 'Recorded in this period', tone: 'accent', detail: `${scope}. Confirmed invocations of resolutions.find; includes rejected calls.` }));
|
|
20
|
+
function ratio(label, ratio, tone) {
|
|
21
|
+
metrics.append(metricCard({ label, value: ratio.value === null ? null : Math.round(ratio.value * 1000) / 10, suffix: '%', tone,
|
|
22
|
+
note: `${number(ratio.numerator)} / ${number(ratio.denominator)} · sample n=${number(ratio.sample_size)}`,
|
|
23
|
+
detail: `${scope}. ${ratio.definition}` }));
|
|
24
|
+
}
|
|
25
|
+
ratio('Candidate hit rate', stats.activity.hit_rate, 'accent');
|
|
26
|
+
ratio('Solve rate', stats.outcomes.solve_rate, 'accent');
|
|
27
|
+
ratio('Validation error rate', stats.activity.validation_error_rate, 'warning');
|
|
28
|
+
activity.append(metrics);
|
|
29
|
+
view.append(activity);
|
|
30
|
+
view.append(element('p', `${scope} · Updated ${dateTime(stats.query.applied_to, stats.query.timezone)}`, 'snapshot-meta'));
|
|
31
|
+
if (stats.query.source === 'codex_history')
|
|
32
|
+
view.append(stateNotice('partial', `Imported history can overlap live records. Confirmed, inferred and unparsed calls remain separate: ${stats.coverage.confidence.map(row => `${row.key} ${number(row.count)}`).join(' · ') || 'No imported evidence'}.`));
|
|
33
|
+
const primary = element('div', undefined, 'overview-primary');
|
|
34
|
+
view.append(primary);
|
|
35
|
+
const trend = section('Daily searches', primary, 'trend-panel');
|
|
36
|
+
const heading = trend.querySelector('h2');
|
|
37
|
+
heading.append(element('span', `Latest ${Math.min(30, stats.timeline.length)} days · ${stats.query.timezone}`, 'section-meta'));
|
|
38
|
+
trend.append(activityTimeline(stats.timeline));
|
|
39
|
+
const coverage = element('details', undefined, `coverage-note coverage-${stats.coverage.status}`);
|
|
40
|
+
const coverageLabel = stats.coverage.status === 'partial' ? 'Partial coverage · earlier usage is unknown' : `Coverage: ${stats.coverage.status.replaceAll('_', ' ')}`;
|
|
41
|
+
coverage.append(element('summary', coverageLabel), element('p', `${stats.coverage.recorded_from ? `Recording began ${dateTime(stats.coverage.recorded_from, stats.query.timezone)}.` : 'Recording has not started.'} ${stats.coverage.scope}`));
|
|
42
|
+
trend.append(coverage);
|
|
43
|
+
const data = element('details', undefined, 'daily-values');
|
|
44
|
+
data.append(element('summary', 'Show all daily values'), dataTable({ caption: 'Daily activity values', columns: [{ label: 'Date' }, { label: 'Searches' }, { label: 'Candidate hits' }, { label: 'Validation errors' }, { label: 'Coverage' }], rows: stats.timeline.map(row => [row.date, number(row.find_calls), number(row.candidate_hits), number(row.validation_errors), row.partial ? 'Partial' : 'Recorded']) }));
|
|
45
|
+
trend.append(data);
|
|
46
|
+
const inventory = section('Knowledge inventory', primary, 'inventory-panel');
|
|
47
|
+
inventory.append(element('p', 'Your reusable knowledge, right now.', 'muted'));
|
|
48
|
+
const counts = element('dl', undefined, 'inventory-counts');
|
|
49
|
+
for (const key of ['problems', 'solutions', 'revisions', 'outcomes']) {
|
|
50
|
+
const row = element('div');
|
|
51
|
+
row.append(element('dt', `Current ${key}`), element('dd', number(stats.inventory[key])));
|
|
52
|
+
counts.append(row);
|
|
53
|
+
}
|
|
54
|
+
inventory.append(counts);
|
|
55
|
+
const growth = element('div', undefined, 'growth-summary');
|
|
56
|
+
growth.append(element('span', `${number(stats.growth.observed_new_solutions)} new solutions observed`), element('span', `${number(stats.growth.observed_new_revisions)} new revisions observed`));
|
|
57
|
+
inventory.append(growth);
|
|
58
|
+
explanation(inventory, 'Inventory & growth details', `Current inventory matches project and language, independent of the activity period. Status: ${stats.inventory.status}. Global totals: ${Object.entries(stats.inventory.global).map(([key, value]) => `${number(value)} ${key}`).join(', ')}. Growth uses confirmed canonical write receipts in the selected period. ${stats.growth.record_time_caveat}`);
|
|
59
|
+
const secondary = element('div', undefined, 'two-column');
|
|
60
|
+
view.append(secondary);
|
|
61
|
+
const outcomes = section('Reported outcomes', secondary);
|
|
62
|
+
if (stats.outcomes.counts) {
|
|
63
|
+
const outcomeGrid = element('div', undefined, 'outcome-grid');
|
|
64
|
+
for (const [label, count] of Object.entries(stats.outcomes.counts)) {
|
|
65
|
+
const item = element('div', undefined, `outcome outcome-${label}`);
|
|
66
|
+
item.append(element('strong', number(count)), element('span', label));
|
|
67
|
+
outcomeGrid.append(item);
|
|
68
|
+
}
|
|
69
|
+
outcomes.append(outcomeGrid);
|
|
70
|
+
}
|
|
71
|
+
else
|
|
72
|
+
outcomes.append(stateNotice('not_recorded', 'Outcome evidence is unavailable.'));
|
|
73
|
+
explanation(outcomes, 'What these outcomes mean', stats.outcomes.interpretation);
|
|
74
|
+
const funnel = section('Linked investigations', secondary);
|
|
75
|
+
const stages = element('ul', undefined, 'investigation-stages');
|
|
76
|
+
for (const [key, label] of [['searched', 'Searched'], ['candidates_found', 'Candidates'], ['attempted', 'Attempted'], ['solved', 'Solved'], ['captured', 'Captured']]) {
|
|
77
|
+
const item = element('li');
|
|
78
|
+
item.append(element('strong', number(stats.funnel[key])), element('span', label));
|
|
79
|
+
stages.append(item);
|
|
80
|
+
}
|
|
81
|
+
funnel.append(stages, element('p', `${number(stats.funnel.unlinked_calls)} unlinked calls excluded`, 'muted'));
|
|
82
|
+
explanation(funnel, 'How investigations are linked', `${stats.funnel.scope} These counts do not measure instruction compliance.`);
|
|
83
|
+
const breakdowns = element('div', undefined, 'two-column');
|
|
84
|
+
view.append(breakdowns);
|
|
85
|
+
function breakdown(title, rows) {
|
|
86
|
+
const panel = section(title, breakdowns);
|
|
87
|
+
for (const row of rows)
|
|
88
|
+
panel.append(breakdownBar(row.key, row.count, Math.max(1, ...rows.map(r => r.count))));
|
|
89
|
+
if (!rows.length)
|
|
90
|
+
panel.append(element('p', 'No observations in this scope.', 'muted'));
|
|
91
|
+
}
|
|
92
|
+
breakdown('By language', stats.breakdowns.languages);
|
|
93
|
+
breakdown('By project', stats.breakdowns.projects);
|
|
94
|
+
const health = element('details', undefined, 'panel health-panel');
|
|
95
|
+
view.append(health);
|
|
96
|
+
const healthSummary = element('summary');
|
|
97
|
+
healthSummary.append(element('span', 'Local health'), element('span', `Canonical: ${stats.health.canonical} · Index: ${stats.health.index}`, 'muted'));
|
|
98
|
+
health.append(healthSummary);
|
|
99
|
+
health.append(dataTable({ caption: 'Storage and sync status', columns: [{ label: 'Area' }, { label: 'State' }], rows: [['Canonical', stats.health.canonical], ['Index', stats.health.index], ['Pending captures', number(stats.health.pending_count)], ['Legacy backlog', number(stats.health.import_backlog)], ['Recording', stats.health.recording.status], ['Sync (local refs)', stats.health.sync.divergence], ['Remote check', stats.health.sync.remote_check], ['Remote state', stats.health.sync.remote_state]] }));
|
|
100
|
+
return view;
|
|
101
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { dataTable, element, number, stateNotice } from './components/index.js';
|
|
2
|
+
export function solutionDetail(row) {
|
|
3
|
+
const root = element('div');
|
|
4
|
+
if (!row) {
|
|
5
|
+
root.append(stateNotice('not_found', 'This record is unavailable or does not match the selected project and language.'));
|
|
6
|
+
return root;
|
|
7
|
+
}
|
|
8
|
+
root.append(element('p', row.solution_handle ?? row.id, 'eyebrow'), element('p', `Status: ${row.status} · Languages: ${row.languages.join(', ') || 'Unknown'} · Platforms: ${row.platforms.join(', ') || 'Unknown'}`));
|
|
9
|
+
function list(title, values) { if (!values?.length)
|
|
10
|
+
return; root.append(element('h3', title)); const list = element('ul'); for (const value of values)
|
|
11
|
+
list.append(element('li', value)); root.append(list); }
|
|
12
|
+
if (row.kind === 'pending' || row.kind === 'legacy') {
|
|
13
|
+
root.append(stateNotice('review_required', `${row.summary}. This entry is not counted as a verified solution.`));
|
|
14
|
+
list('Missing evidence', row.missing_fields);
|
|
15
|
+
root.append(element('p', `Provenance: ${row.kind}. Relation: ${row.relation ?? 'Unknown'}. Inspect with ${row.kind === 'pending' ? 'agent-rulebook pending list' : 'agent-rulebook import list --manifest <reviewed-manifest>'} before retrying. No action is executed here.`));
|
|
16
|
+
}
|
|
17
|
+
if (row.observations) {
|
|
18
|
+
root.append(element('h3', 'Problem observations'), element('p', `Expected: ${row.observations.expected}`), element('p', `Observed: ${row.observations.observed}`));
|
|
19
|
+
list('Symptoms', row.observations.symptoms);
|
|
20
|
+
list('Error signatures', row.observations.error_signatures);
|
|
21
|
+
}
|
|
22
|
+
if (row.cause)
|
|
23
|
+
root.append(element('h3', 'Verified cause'), element('p', row.cause));
|
|
24
|
+
for (const [title, key] of [['Applicable when', 'applicable_if'], ['Do not apply when', 'reject_if'], ['Inspect first', 'inspections'], ['Recorded actions', 'actions'], ['Verification', 'verification'], ['Safety', 'safety']])
|
|
25
|
+
list(title, row[key]);
|
|
26
|
+
if (row.outcome_counts)
|
|
27
|
+
root.append(dataTable({ caption: 'Outcomes for this exact revision', columns: [{ label: 'Result' }, { label: 'Count' }], rows: Object.entries(row.outcome_counts).map(([result, count]) => [result, number(count)]) }));
|
|
28
|
+
if (row.outcome_reasons?.length)
|
|
29
|
+
root.append(dataTable({ caption: 'Reported failure and applicability reasons', columns: [{ label: 'Result' }, { label: 'Reason' }, { label: 'Count' }], rows: row.outcome_reasons.map(r => [r.result, r.reason, number(r.count)]) }));
|
|
30
|
+
if (row.source_evidence?.length) {
|
|
31
|
+
root.append(element('h3', 'Source evidence'), stateNotice('not_checked', 'Source availability has not been checked. These are stored relative locators; the dashboard does not retrieve source contents.'));
|
|
32
|
+
for (const source of row.source_evidence) {
|
|
33
|
+
const panel = element('section', undefined, 'panel');
|
|
34
|
+
panel.append(element('p', source.project_key), element('code', source.relative_path), element('p', source.revision), element('p', `Tests: ${source.tests.join(', ')}`));
|
|
35
|
+
root.append(panel);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
list('Related solutions', row.related_solution_handles);
|
|
39
|
+
list('Source projects', row.source_projects);
|
|
40
|
+
list('Observed usage projects', row.used_in_projects);
|
|
41
|
+
return root;
|
|
42
|
+
}
|