ai-agentmanager 1.61.0 β 1.63.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/CHANGELOG.md +30 -0
- package/README.md +124 -0
- package/package.json +1 -1
- package/public/acceptance.js +194 -0
- package/public/announce.js +9 -1
- package/public/app.js +82 -10
- package/public/attach.js +4 -0
- package/public/autonomy.js +140 -0
- package/public/boardcols.js +1 -0
- package/public/claims.js +65 -0
- package/public/dropzone.js +203 -0
- package/public/index.html +56 -0
- package/public/menu.js +20 -0
- package/public/scorecard.js +1 -1
- package/public/standup.js +1 -0
- package/public/style.css +64 -1
- package/src/acceptance.js +123 -0
- package/src/advisor.js +30 -8
- package/src/autonomy.js +624 -0
- package/src/autopilot.js +7 -1
- package/src/backlog.js +16 -3
- package/src/brief.js +21 -3
- package/src/bughunt.js +1 -0
- package/src/claims.js +239 -0
- package/src/cli.js +164 -2
- package/src/config.js +3 -0
- package/src/decisions.js +5 -1
- package/src/groundrules.js +97 -0
- package/src/judge.js +1 -1
- package/src/manager.js +257 -6
- package/src/notify.js +16 -0
- package/src/prereview.js +7 -2
- package/src/scorecard.js +27 -10
- package/src/server.js +67 -4
- package/src/standup.js +1 -0
package/public/app.js
CHANGED
|
@@ -5,11 +5,13 @@ import DOMPurify from '/vendor/dompurify/purify.es.mjs';
|
|
|
5
5
|
import { touchScroll } from '/touchscroll.js';
|
|
6
6
|
import { openStream, post, REMOTE } from '/transport.js';
|
|
7
7
|
import { attachBox } from '/attach.js';
|
|
8
|
+
import { initDropZone } from '/dropzone.js';
|
|
8
9
|
import { initSide } from '/side.js';
|
|
9
10
|
import { openCopy, pasteInto } from '/termclip.js';
|
|
10
11
|
import { initBuilt } from '/built.js';
|
|
11
12
|
import { addTools, download, htmlFile, initExport } from '/export.js';
|
|
12
13
|
import { evalChip, evalHtml } from '/eval.js';
|
|
14
|
+
import { claimsHtml, claimsNote } from '/claims.js';
|
|
13
15
|
import { badgeHtml as scoreBadge, chipHtml as scoreChip, improveHtml, scorecardHtml, scorecardSpeech } from '/scorecard.js';
|
|
14
16
|
import { bindListen, listenHtml, play, speakable, now as speaking, stop as stopSpeaking } from '/speak.js';
|
|
15
17
|
import { initReview } from '/review.js';
|
|
@@ -55,6 +57,8 @@ import { initPalette } from '/palette.js';
|
|
|
55
57
|
import { initFiles } from '/files.js';
|
|
56
58
|
import { initUpdateView, updateHtml, updateWaits } from '/announce.js';
|
|
57
59
|
import { morph } from '/morph.js';
|
|
60
|
+
import { acceptanceRow, acceptanceWaits, initAcceptance } from '/acceptance.js';
|
|
61
|
+
import { autoNeedHtml, autonomyNeeds, autonomyRow, initAutonomy } from '/autonomy.js';
|
|
58
62
|
|
|
59
63
|
const $ = (sel) => document.querySelector(sel);
|
|
60
64
|
const agents = new Map();
|
|
@@ -188,6 +192,12 @@ async function act(fn, okMsg) {
|
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
const reviewUi = initReview({ api, esc, toast, agents, $ });
|
|
195
|
+
const acceptUi = initAcceptance({ dialog: $('#accept-dialog'), api, esc, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a) });
|
|
196
|
+
const autoUi = initAutonomy({ dialog: $('#auto-dialog'), api, esc, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a) });
|
|
197
|
+
// Past "Ask me", what done means is agreed first: that is what the answers given for you are checked against.
|
|
198
|
+
$('#new-autonomy')?.addEventListener('change', (e) => {
|
|
199
|
+
if (['run', 'pr', 'merge'].includes(e.target.value) && e.target.form?.acceptance) e.target.form.acceptance.checked = true;
|
|
200
|
+
});
|
|
191
201
|
const triggersUi = initTriggers({ api, esc, toast, $ });
|
|
192
202
|
initSpend({ api, esc, toast, $ });
|
|
193
203
|
const goalsUi = initGoals({ api, esc, toast, $, ago: (t) => ago(t), getProjects: () => projectsState, rerender: () => renderBacklog() });
|
|
@@ -636,9 +646,10 @@ const INSIGHT_ICONS = { why: 'π―', what: 'π¦', how: 'π ', now: 'π' };
|
|
|
636
646
|
|
|
637
647
|
// ------------------------------------------------------------------ stakeholder documents
|
|
638
648
|
|
|
639
|
-
const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', estimate: 'Estimate', documentation: 'Documentation', diagrams: 'Diagrams', scorecard: 'Scorecard', update: 'Update' };
|
|
649
|
+
const DOCS = { analysis: 'Analysis', design: 'Design', flow: 'Flow', proposal: 'Proposal', humanai: 'Human vs AI', estimate: 'Estimate', documentation: 'Documentation', diagrams: 'Diagrams', scorecard: 'Scorecard', update: 'Update', claims: 'Claims' };
|
|
640
650
|
// What a document is before it's written, where "Write a β¦ document for stakeholders" doesn't say it.
|
|
641
651
|
const DOC_HINTS = {
|
|
652
|
+
claims: 'Check what the brief and the documents written about this work say against the work itself: each statement of fact traced to a source by another model, and the app checking the quotes, files, links and numbers are really there',
|
|
642
653
|
update: 'What to tell the people who asked: a short Slack message and a short email for you to send, and the details they point to. Written by itself when the agent finishes or opens a pull request',
|
|
643
654
|
estimate: 'For planning: how long a person would take to do this work by hand, split into tasks with optimistic, likely and pessimistic hours, a suggested split into tickets, the roles needed and the risks',
|
|
644
655
|
documentation: 'The documentation for this change: what is new, how to use it, configuration, upgrade notes, which docs to add or update, and an OpenAPI spec of any API changes',
|
|
@@ -646,7 +657,7 @@ const DOC_HINTS = {
|
|
|
646
657
|
/** The OpenAPI spec in a Documentation document (its ```yaml block), if the change has API changes. */
|
|
647
658
|
const openApiOf = (markdown) => (markdown ?? '').match(/```ya?ml\s*\n((?:#.*\n|\s*\n)*openapi:[\s\S]*?)```/)?.[1] ?? null;
|
|
648
659
|
// Optional extras that "Write all" leaves out.
|
|
649
|
-
const DOC_EXTRAS = new Set(['diagrams', 'scorecard', 'update']);
|
|
660
|
+
const DOC_EXTRAS = new Set(['diagrams', 'scorecard', 'update', 'claims']);
|
|
650
661
|
const DOC_TITLES = { ...DOCS, estimate: 'Human time estimate', eval: 'Eval', plan: 'Plan', intent: 'Intent', spec: 'Spec', designdoc: 'Design doc', benchmark: 'Benchmark' };
|
|
651
662
|
// The agent's intent, spec and plan files (read from the daemon when opened; kept here by agent and kind).
|
|
652
663
|
const SPEC_KINDS = { intent: 'Intent', spec: 'Spec', plan: 'Plan', designdoc: 'Design doc', benchmark: 'Benchmark' };
|
|
@@ -732,7 +743,7 @@ function docButtons(a) {
|
|
|
732
743
|
const d = a.docs?.[k];
|
|
733
744
|
const stale = d?.markdown && a.brief?.updatedAt && d.briefUpdatedAt !== a.brief.updatedAt;
|
|
734
745
|
return `<button class="small doc-btn ${d?.markdown ? 'has' : ''}" data-doc="${k}" ${d?.pending ? 'disabled' : ''}
|
|
735
|
-
title="${k === 'scorecard' ? (d?.markdown ? `Open the review scorecard: ${d.data?.overall ?? 'β'}/100` : 'Score the changes for review: intent, spec, scope, plan, tests and safety, with an overall readiness and where to look') : k === 'diagrams' ? (d?.markdown ? `Open the diagrams${stale ? ' (the brief changed since)' : ''}` : 'Draw the problem and its solution for a quick grasp: architecture, design, data flow (animated) and the key interaction, diagrams only. Built from the documents already written and the agent\'s work') : d?.markdown ? `Open the ${label.toLowerCase()} document${stale ? ' (the brief changed since)' : ''}` : DOC_HINTS[k] ?? `Write a ${label.toLowerCase()} document for stakeholders`}">${d?.pending ? `${label}β¦` : label}${d?.markdown ? (stale ? ' β’' : ' β') : ''}</button>`;
|
|
746
|
+
title="${k === 'claims' && d?.data ? `Open the claims check: ${claimsLine(d.data)}` : k === 'scorecard' ? (d?.markdown ? `Open the review scorecard: ${d.data?.overall ?? 'β'}/100` : 'Score the changes for review: intent, spec, scope, plan, tests and safety, with an overall readiness and where to look') : k === 'diagrams' ? (d?.markdown ? `Open the diagrams${stale ? ' (the brief changed since)' : ''}` : 'Draw the problem and its solution for a quick grasp: architecture, design, data flow (animated) and the key interaction, diagrams only. Built from the documents already written and the agent\'s work') : d?.markdown ? `Open the ${label.toLowerCase()} document${stale ? ' (the brief changed since)' : ''}` : DOC_HINTS[k] ?? `Write a ${label.toLowerCase()} document for stakeholders`}">${d?.pending ? `${label}β¦` : label}${d?.markdown ? (k === 'claims' && d.data?.verdict !== 'backed' ? ' !' : stale ? ' β’' : ' β') : ''}</button>`;
|
|
736
747
|
})
|
|
737
748
|
.join('')}</span>${specButtons(a)}${driveButton(a)}`;
|
|
738
749
|
}
|
|
@@ -767,6 +778,9 @@ function demoButton(a) {
|
|
|
767
778
|
: '<button class="small doc-btn" disabled title="The agent makes it once the change works and publishes it as an Artifact">Demo page</button>';
|
|
768
779
|
}
|
|
769
780
|
|
|
781
|
+
/** "1 contradicted, 2 not backed, 5 backed" for a tooltip. */
|
|
782
|
+
const claimsLine = (c) => [c.counts.contradicted && `${c.counts.contradicted} contradicted`, (c.counts.not_backed || c.missing) && `${c.counts.not_backed + c.missing} not backed`, `${c.counts.backed} backed`].filter(Boolean).join(', ');
|
|
783
|
+
|
|
770
784
|
let docView = null; // { agentId, kind }
|
|
771
785
|
|
|
772
786
|
function renderDocDialog() {
|
|
@@ -782,9 +796,9 @@ function renderDocDialog() {
|
|
|
782
796
|
if (docView.kind === 'eval') return renderEval(a, body, d);
|
|
783
797
|
body.classList.toggle('diagrams-view', docView.kind === 'diagrams');
|
|
784
798
|
if (d?.pending) {
|
|
785
|
-
body.innerHTML = `<p class="hint">${docView.kind === 'humanai' ? 'Splitting the open questions and answering the AI ones, then asking a second model to checkβ¦' : docView.kind === 'diagrams' ? "Drawing the diagrams from the documents and the agent's work so farβ¦" : `Writing the ${label.toLowerCase()} document from the agent's work so farβ¦`}</p>`;
|
|
799
|
+
body.innerHTML = `<p class="hint">${docView.kind === 'humanai' ? 'Splitting the open questions and answering the AI ones, then asking a second model to checkβ¦' : docView.kind === 'diagrams' ? "Drawing the diagrams from the documents and the agent's work so farβ¦" : docView.kind === 'claims' ? 'Checking each statement of the brief and the documents against the work, with another modelβ¦ a minute or two.' : `Writing the ${label.toLowerCase()} document from the agent's work so farβ¦`}</p>`;
|
|
786
800
|
body.dataset.rendered = '';
|
|
787
|
-
} else if (d?.error) body.innerHTML = `<p class="error">Couldn't write it: ${esc(d.error)}</p>`;
|
|
801
|
+
} else if (d?.error) body.innerHTML = `<p class="error">Couldn't ${docView.kind === 'claims' ? 'check' : 'write'} it: ${esc(d.error)}</p>`;
|
|
788
802
|
else if (plan && !d?.markdown) body.innerHTML = '<p class="hint">The agent is investigating and hasn\'t written its plan yet. You\'ll see it here (and in the inbox) when it has.</p>';
|
|
789
803
|
else if (specKind && !d?.loaded) body.innerHTML = '<p class="hint">Loadingβ¦</p>';
|
|
790
804
|
else if (specKind && !d?.markdown) body.innerHTML = `<p class="hint">${docView.kind === 'intent' ? 'No intent file for this agent (agents created before 1.9 have none).' : `The agent hasn't written its ${label.toLowerCase()} yet. It writes ${docView.kind === 'spec' ? 'the spec before changing code' : docView.kind === 'designdoc' ? 'the design doc once its plan is settled and publishes it as an Artifact' : docView.kind === 'benchmark' ? 'the benchmark results once the change works' : 'the plan and keeps it current'}.`}</p>`;
|
|
@@ -792,7 +806,7 @@ function renderDocDialog() {
|
|
|
792
806
|
// The scorecard's Improve button follows the agent being improved.
|
|
793
807
|
const version = docView.kind === 'scorecard' ? `${d.at}:${Boolean(a.improving)}` : d.at;
|
|
794
808
|
if (body.dataset.rendered !== version) {
|
|
795
|
-
body.innerHTML = docView.kind === 'scorecard' ? scorecardHtml(d, esc, { actions: improveHtml(a) }) : docView.kind === 'update' ? updateHtml(a, d, { esc, docHtml }) : d.data ? humanAiHtml(d) : docHtml(d.markdown);
|
|
809
|
+
body.innerHTML = docView.kind === 'scorecard' ? scorecardHtml(d, esc, { actions: improveHtml(a) }) : docView.kind === 'update' ? updateHtml(a, d, { esc, docHtml }) : docView.kind === 'claims' ? claimsHtml(d, esc) : d.data ? humanAiHtml(d) : docHtml(d.markdown);
|
|
796
810
|
body.dataset.rendered = version;
|
|
797
811
|
renderDiagrams(body);
|
|
798
812
|
}
|
|
@@ -800,7 +814,7 @@ function renderDocDialog() {
|
|
|
800
814
|
}
|
|
801
815
|
const stale = !plan && d?.markdown && a.brief?.updatedAt && d.briefUpdatedAt !== a.brief.updatedAt;
|
|
802
816
|
const by = d?.writer ? ` by ${d.writer}${d.critique ? `, checked by ${d.critique.label}` : ''}${d.from ? ` from ${d.from.length ? d.from.join(', ') : "the agent's work"}` : ''}` : '';
|
|
803
|
-
$('#doc-meta').textContent = d?.markdown ? `${plan ? `Plan Β· ${PLAN_LABEL[a.planReview.status]} Β· updated` : specKind ? 'Updated' : docView.kind === 'diagrams' ? 'Drawn' : 'Written'} ${ago(d.at)}${by}${stale && !specKind ? ' Β· the brief has changed since; Regenerate for the latest' : ''}${specKind ? ' Β· goes into the pull request description' : ''}` : '';
|
|
817
|
+
$('#doc-meta').textContent = d?.markdown ? `${plan ? `Plan Β· ${PLAN_LABEL[a.planReview.status]} Β· updated` : specKind ? 'Updated' : docView.kind === 'diagrams' ? 'Drawn' : docView.kind === 'claims' ? 'Checked' : 'Written'} ${ago(d.at)}${by}${stale && !specKind ? ' Β· the brief has changed since; Regenerate for the latest' : ''}${specKind ? ' Β· goes into the pull request description' : ''}` : '';
|
|
804
818
|
for (const id of ['doc-copy', 'doc-download', 'doc-print']) $(`#${id}`).disabled = !d?.markdown;
|
|
805
819
|
// Diagrams: the whole document as one HTML file with every diagram (each also has Copy / PNG / SVG).
|
|
806
820
|
$('#doc-html').hidden = !/```mermaid/.test(d?.markdown ?? '');
|
|
@@ -885,7 +899,7 @@ $('#doc-body').addEventListener('submit', (e) => {
|
|
|
885
899
|
});
|
|
886
900
|
|
|
887
901
|
// The Update document's own buttons: copy, open in mail, post to Slack, the link to its details.
|
|
888
|
-
const announceUi = initUpdateView({ body: $('#doc-body'), api, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a) });
|
|
902
|
+
const announceUi = initUpdateView({ body: $('#doc-body'), api, toast, ago, agentOf: (id) => agents.get(id), upsert: (a) => upsert(a), claimsNote: (a) => claimsNote(a, 'update', a.docs?.update?.at ?? null, esc) });
|
|
889
903
|
|
|
890
904
|
function generateDoc() {
|
|
891
905
|
const { agentId, kind } = docView;
|
|
@@ -940,6 +954,14 @@ $('#doc-openapi').onclick = () => {
|
|
|
940
954
|
link.click();
|
|
941
955
|
setTimeout(() => URL.revokeObjectURL(link.href), 1000);
|
|
942
956
|
};
|
|
957
|
+
// From one document to another (an update to its claims check); "run" checks again when it is of an earlier text.
|
|
958
|
+
$('#doc-body').addEventListener('click', (e) => {
|
|
959
|
+
const b = e.target.closest('button[data-doc]');
|
|
960
|
+
if (!b || !docView) return;
|
|
961
|
+
const had = Boolean(agents.get(docView.agentId)?.docs?.[b.dataset.doc]?.markdown);
|
|
962
|
+
openDoc(docView.agentId, b.dataset.doc);
|
|
963
|
+
if (had && 'run' in b.dataset) generateDoc();
|
|
964
|
+
});
|
|
943
965
|
const haAnswers = () => Object.fromEntries([...document.querySelectorAll('#doc-body [data-ha]')].map((t) => [t.dataset.ha, t.value]));
|
|
944
966
|
$('#doc-body').addEventListener('click', (e) => {
|
|
945
967
|
const pick = e.target.closest('[data-ha-pick]');
|
|
@@ -1061,6 +1083,7 @@ function resultsCard(a) {
|
|
|
1061
1083
|
return `<div class="results ${r.outcome.replace(' ', '-')}">
|
|
1062
1084
|
<h4>Results <span class="outcome">${icon} ${label}</span>${r.fromAgent ? '' : ' <span class="hint">(from what AI Agent Manager can see; the agent adds its own when it next updates its brief)</span>'}</h4>
|
|
1063
1085
|
${scoreStrip(a)}
|
|
1086
|
+
${r.confidence ? `<p class="own-conf"><span class="tag conf-${esc(r.confidence.level)}" title="The agent's own confidence in what it built, as it wrote it in its brief. The review scorecard is the separate check.">Its own confidence: ${r.confidence.percent}%</span> ${esc(r.confidence.why)}</p>` : r.fromAgent && ['done', 'partial'].includes(r.outcome) ? '<p class="hint own-conf">The agent has not said how confident it is in this.</p>' : ''}
|
|
1064
1087
|
${r.blockers.length ? `<ul class="blockers">${r.blockers.map((x) => item(x, 'blocker')).join('')}</ul>` : ''}
|
|
1065
1088
|
${r.delivered.length ? `<ul class="delivered">${r.delivered.map((x) => item(x, 'delivered')).join('')}</ul>` : '<p class="hint">Nothing delivered yet.</p>'}
|
|
1066
1089
|
${r.notes ? `<div class="md">${md(r.notes)}</div>` : ''}
|
|
@@ -1076,6 +1099,8 @@ function briefPanel(a) {
|
|
|
1076
1099
|
if (!b) {
|
|
1077
1100
|
return `<div class="card brief">
|
|
1078
1101
|
<h3>Brief <span class="brief-actions">${ins.button} ${ex.button} ${rv.button}</span></h3>
|
|
1102
|
+
${noRepo(a) ? '' : acceptanceRow(a, esc)}
|
|
1103
|
+
${noRepo(a) ? '' : autonomyRow(a, esc)}
|
|
1079
1104
|
${planRow(a)}
|
|
1080
1105
|
<div class="share-row"><span class="hint">Share for review:</span> ${docButtons(a)}</div>
|
|
1081
1106
|
${resultsCard(a)}
|
|
@@ -1094,6 +1119,8 @@ function briefPanel(a) {
|
|
|
1094
1119
|
: '<p class="hint">No checks yet.</p>';
|
|
1095
1120
|
return `<div class="card brief">
|
|
1096
1121
|
<h3>Brief <span class="brief-actions"><span title="${esc(b.updatedAt)}">updated ${ago(b.updatedAt)}</span> ${ins.button} ${ex.button} ${rv.button}</span></h3>
|
|
1122
|
+
${noRepo(a) ? '' : acceptanceRow(a, esc)}
|
|
1123
|
+
${noRepo(a) ? '' : autonomyRow(a, esc)}
|
|
1097
1124
|
${planRow(a)}
|
|
1098
1125
|
<div class="share-row"><span class="hint">Share for review:</span> ${docButtons(a)}</div>
|
|
1099
1126
|
${resultsCard(a)}
|
|
@@ -1555,17 +1582,19 @@ function loadLimitEngines() {
|
|
|
1555
1582
|
})
|
|
1556
1583
|
.catch(() => (limitEngines = null));
|
|
1557
1584
|
}
|
|
1558
|
-
const NEED_ORDER = { approval: 0, prompt: 0, limit: 1, waiting: 1, plan: 1, question: 1, team: 1, rule: 2, review: 2, prereview: 2, autopilot: 2, stuck: 3, conflict: 4, reminder: 5, close: 5, repeat: 5, update: 4 };
|
|
1585
|
+
const NEED_ORDER = { approval: 0, prompt: 0, limit: 1, waiting: 1, plan: 1, acceptance: 1, question: 1, team: 1, rule: 2, auto: 2, review: 2, prereview: 2, autopilot: 2, stuck: 3, conflict: 4, reminder: 5, close: 5, repeat: 5, update: 4 };
|
|
1559
1586
|
/** What an agent needs from the user. `both`: overlaps on both agents (detail), else only the one that should rebase (inbox). */
|
|
1560
1587
|
function needsFor(a, { both = false } = {}) {
|
|
1561
1588
|
const items = [];
|
|
1562
1589
|
if (a.runtime.attention) items.push({ a, kind: 'prompt', key: `prompt:${a.id}` });
|
|
1563
1590
|
if (a.runtime.limited) items.push({ a, kind: 'limit', key: `limit:${a.id}` });
|
|
1564
1591
|
if (a.runtime.waiting) items.push({ a, kind: 'waiting', key: `waiting:${a.id}` });
|
|
1592
|
+
if (acceptanceWaits(a)) items.push({ a, kind: 'acceptance', key: `acceptance:${a.id}` });
|
|
1565
1593
|
if (a.planReview?.status === 'review') items.push({ a, kind: 'plan', key: `plan:${a.id}` });
|
|
1566
1594
|
if (a.aiReview?.verdict && !a.aiReview.seen) items.push({ a, kind: 'review', key: `review:${a.id}` });
|
|
1567
1595
|
if (['stalled', 'error'].includes(a.preReview?.status)) items.push({ a, kind: 'prereview', key: `prereview:${a.id}` });
|
|
1568
1596
|
for (const q of a.questions ?? []) if (!q.answer) items.push({ a, kind: 'question', key: `q:${a.id}:${q.id}`, q });
|
|
1597
|
+
items.push(...autonomyNeeds(a));
|
|
1569
1598
|
for (const f of a.stuck ?? []) items.push({ a, kind: 'stuck', key: `stuck:${a.id}:${f.key}`, f });
|
|
1570
1599
|
if (updateWaits(a)) items.push({ a, kind: 'update', key: `update:${a.id}` });
|
|
1571
1600
|
if (a.followUp) items.push({ a, kind: a.followUp.kind === 'close' ? 'close' : 'reminder', key: `reminder:${a.id}`, r: a.followUp });
|
|
@@ -1604,7 +1633,7 @@ function inboxItems() {
|
|
|
1604
1633
|
.sort((x, y) => NEED_ORDER[x.kind] - NEED_ORDER[y.kind] || (x.a.priority ?? 2) - (y.a.priority ?? 2));
|
|
1605
1634
|
}
|
|
1606
1635
|
|
|
1607
|
-
const NEED_LABEL = { update: 'Update to send', limit: 'Limit', reminder: 'Follow up', close: 'Close session?', repeat: 'Make it a playbook?', autopilot: 'Autopilot held', rule: 'Always allow?', approval: 'Approval', team: 'Team', prompt: 'Needs input', waiting: 'Waiting on you', plan: 'Plan review', question: 'Question', review: 'AI review', prereview: 'Not approved', stuck: 'Stuck?', conflict: 'Overlap' };
|
|
1636
|
+
const NEED_LABEL = { update: 'Update to send', limit: 'Limit', reminder: 'Follow up', close: 'Close session?', repeat: 'Make it a playbook?', autopilot: 'Autopilot held', rule: 'Always allow?', approval: 'Approval', team: 'Team', prompt: 'Needs input', waiting: 'Waiting on you', acceptance: 'Done means', auto: 'Done for you', plan: 'Plan review', question: 'Question', review: 'AI review', prereview: 'Not approved', stuck: 'Stuck?', conflict: 'Overlap' };
|
|
1608
1637
|
/** Why the AI judge thinks so, as a small tag. */
|
|
1609
1638
|
const aiTag = (confidence, what = 'AI') => `<span class="tag ai" title="Judged by a model from the agent's activity; your reactions tune later calls">π€ ${what}${confidence != null ? ` ${Math.round(confidence * 100)}%` : ''}</span>`;
|
|
1610
1639
|
/** What a permission prompt asks about: the command, file or tool. */
|
|
@@ -1717,6 +1746,14 @@ function needCard(it, { inDetail = false } = {}) {
|
|
|
1717
1746
|
body = `<p class="need-title">${t.stage === 'ready' ? `β The reviewer approved <b>${esc(t.name)}</b>${t.gaps ? ', with parts still missing: run a gap round?' : ''}` : `<b>${esc(t.name)}</b> needs a decision: ${esc(t.blocked?.reason ?? '')}`}</p>
|
|
1718
1747
|
<p class="hint">${esc(t.intent.split('\n')[0].slice(0, 140))}</p>
|
|
1719
1748
|
<div class="need-actions"><button class="small primary" data-ib="team-open" data-team="${t.id}">${t.stage !== 'ready' ? 'Decide' : t.gaps ? 'See the gaps' : 'Review and finalize'}</button></div>`;
|
|
1749
|
+
} else if (it.kind === 'auto') {
|
|
1750
|
+
body = autoNeedHtml(it, { esc, ago });
|
|
1751
|
+
} else if (it.kind === 'acceptance') {
|
|
1752
|
+
const pts = a.acceptance.points;
|
|
1753
|
+
body = `<p class="need-title">What done means: ${pts.length} point${pts.length === 1 ? '' : 's'}</p>
|
|
1754
|
+
<ol class="acc-need">${pts.map((p) => `<li>${esc(p.text)}</li>`).join('')}</ol>
|
|
1755
|
+
<p class="hint">Written ${ago(a.acceptance.updatedAt)}. The agent changes nothing until you agree; its work is then checked against these.</p>
|
|
1756
|
+
<div class="need-actions"><button class="small primary" data-ib="accept-open">Change points</button><button class="small" data-ib="accept-agree">Agree as written</button></div>`;
|
|
1720
1757
|
} else if (it.kind === 'plan') {
|
|
1721
1758
|
const title = a.planReview.markdown?.match(/^#\s+(.+)$/m)?.[1] ?? 'Implementation plan';
|
|
1722
1759
|
body = `<p class="need-title">${esc(title)}</p>
|
|
@@ -1974,6 +2011,14 @@ async function onNeed(e) {
|
|
|
1974
2011
|
return openTeam(el.dataset.team);
|
|
1975
2012
|
case 'plan-open':
|
|
1976
2013
|
return openPlan(id);
|
|
2014
|
+
case 'accept-open':
|
|
2015
|
+
return acceptUi.open(id);
|
|
2016
|
+
case 'auto-ok':
|
|
2017
|
+
return autoUi.ok(id, el.dataset.entry);
|
|
2018
|
+
case 'auto-change':
|
|
2019
|
+
return autoUi.change(id, el.dataset.entry);
|
|
2020
|
+
case 'accept-agree':
|
|
2021
|
+
return act(async () => upsert(await api('POST', `/agents/${id}/acceptance/agree`, {})), 'Agreed; the agent goes ahead');
|
|
1977
2022
|
case 'plan-approve':
|
|
1978
2023
|
return act(async () => upsert(await api('POST', `/agents/${id}/plan/approve`, {})), 'Approved; the agent is implementing it');
|
|
1979
2024
|
case 'clash-dismiss':
|
|
@@ -3939,6 +3984,8 @@ function agentChanged(a) {
|
|
|
3939
3984
|
loadSpec(a.id, docView.kind).then(renderDocDialog);
|
|
3940
3985
|
}
|
|
3941
3986
|
reviewUi.agentChanged(a);
|
|
3987
|
+
acceptUi.agentChanged(a);
|
|
3988
|
+
autoUi.agentChanged(a);
|
|
3942
3989
|
sidePane?.agentChanged(a);
|
|
3943
3990
|
}
|
|
3944
3991
|
|
|
@@ -4130,6 +4177,12 @@ $('#detail-body').addEventListener('click', async (e) => {
|
|
|
4130
4177
|
return openEdit(a);
|
|
4131
4178
|
case 'plan-open':
|
|
4132
4179
|
return openPlan(a.id);
|
|
4180
|
+
case 'accept-open':
|
|
4181
|
+
return acceptUi.open(a.id);
|
|
4182
|
+
case 'auto-open':
|
|
4183
|
+
return autoUi.open(a.id);
|
|
4184
|
+
case 'accept-skip':
|
|
4185
|
+
return act(async () => upsert(await api('POST', `/agents/${a.id}/acceptance/skip`)), 'Not waiting; the agent goes ahead with its own criteria');
|
|
4133
4186
|
case 'plan-on':
|
|
4134
4187
|
return act(async () => upsert(await api('POST', `/agents/${a.id}/plan/review`, { on: true })), 'The agent will write a plan and wait for your review');
|
|
4135
4188
|
case 'plan-skip':
|
|
@@ -4322,6 +4375,7 @@ function renderProjectOptions() {
|
|
|
4322
4375
|
|
|
4323
4376
|
function openNewDialog(mode = 'now') {
|
|
4324
4377
|
renderProjectOptions();
|
|
4378
|
+
newDrop.reset();
|
|
4325
4379
|
$('#new-error').hidden = true;
|
|
4326
4380
|
dialog.querySelector(`input[name="when"][value="${mode}"]`).checked = true;
|
|
4327
4381
|
restoreIntentSplit();
|
|
@@ -4386,6 +4440,20 @@ function syncIntentPlaceholder() {
|
|
|
4386
4440
|
form.intents.placeholder = form.split.value === 'one' || ['race', 'team'].includes(form.when.value) ? WHOLE_PLACEHOLDER : LINES_PLACEHOLDER;
|
|
4387
4441
|
}
|
|
4388
4442
|
for (const r of dialog.querySelectorAll('input[name="when"]')) r.addEventListener('change', syncWhen);
|
|
4443
|
+
// Tickets, requirements, designs and files dropped on the page or on the form fill it in (dropzone.js).
|
|
4444
|
+
const newDrop = initDropZone({
|
|
4445
|
+
form: $('#new-form'),
|
|
4446
|
+
zone: $('#new-drop'),
|
|
4447
|
+
overlay: $('#drop-overlay'),
|
|
4448
|
+
attach: newFiles,
|
|
4449
|
+
open: () => openNewDialog('now'),
|
|
4450
|
+
isOpen: () => dialog.open,
|
|
4451
|
+
sync: () => {
|
|
4452
|
+
syncIntentPlaceholder();
|
|
4453
|
+
syncIntentCount();
|
|
4454
|
+
},
|
|
4455
|
+
toast,
|
|
4456
|
+
});
|
|
4389
4457
|
$('#new-btn').onclick = () => openNewDialog('now');
|
|
4390
4458
|
$('#new-cancel').onclick = () => dialog.close();
|
|
4391
4459
|
$('#new-form').addEventListener('submit', async (e) => {
|
|
@@ -4491,6 +4559,8 @@ $('#new-form').addEventListener('submit', async (e) => {
|
|
|
4491
4559
|
...containerChoice(e.target),
|
|
4492
4560
|
plan: Boolean(f.get('plan')),
|
|
4493
4561
|
planReview: Boolean(f.get('planReview')),
|
|
4562
|
+
acceptance: Boolean(f.get('acceptance')),
|
|
4563
|
+
autonomy: f.get('autonomy') || undefined,
|
|
4494
4564
|
designDoc: Boolean(f.get('designDoc')),
|
|
4495
4565
|
demoPage: Boolean(f.get('demoPage')),
|
|
4496
4566
|
benchmarks: Boolean(f.get('benchmarks')),
|
|
@@ -4524,6 +4594,8 @@ $('#new-form').addEventListener('submit', async (e) => {
|
|
|
4524
4594
|
project: f.get('project') || undefined,
|
|
4525
4595
|
plan: Boolean(f.get('plan')),
|
|
4526
4596
|
planReview: Boolean(f.get('planReview')),
|
|
4597
|
+
acceptance: Boolean(f.get('acceptance')),
|
|
4598
|
+
autonomy: f.get('autonomy') || undefined,
|
|
4527
4599
|
designDoc: Boolean(f.get('designDoc')),
|
|
4528
4600
|
start: Boolean(f.get('start')),
|
|
4529
4601
|
...containerChoice(e.target),
|
package/public/attach.js
CHANGED
|
@@ -90,6 +90,10 @@ export function attachBox({ slot, form, paste, esc, toast }) {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
return {
|
|
93
|
+
/** Attach these files (dropped somewhere else on the page). */
|
|
94
|
+
add,
|
|
95
|
+
/** Open the file picker. */
|
|
96
|
+
pick: () => input.click(),
|
|
93
97
|
paths: () => items.filter((it) => it.path).map((it) => it.path),
|
|
94
98
|
pending: () => items.some((it) => it.uploading),
|
|
95
99
|
clear() {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Autonomy on the page: how far an agent goes without you, and what was done for you meanwhile
|
|
2
|
+
// (questions answered from what is already decided, nudges sent, a merge made or held). An answer
|
|
3
|
+
// given for you shows in the inbox until you say OK or give your own.
|
|
4
|
+
|
|
5
|
+
export const LEVELS = ['ask', 'run', 'pr', 'merge'];
|
|
6
|
+
export const LEVEL_LABEL = { ask: 'Ask me', run: 'Agree, then run', pr: 'Run to pull request', merge: 'Run to merge' };
|
|
7
|
+
export const LEVEL_HINT = {
|
|
8
|
+
ask: 'Questions, stuck findings and follow-ups wait for you in the inbox.',
|
|
9
|
+
run: 'You agree on what done means. After that, its questions and its plan are decided for you when the answer is sure and easy to undo, a nudge the judge is sure of is sent, and a quiet agent is told to carry on.',
|
|
10
|
+
pr: 'The same, and its pull request is opened when the review approves the work.',
|
|
11
|
+
merge: 'The same, and the pull request is merged when its checks pass, the scorecard says ready and no high-risk path is touched.',
|
|
12
|
+
};
|
|
13
|
+
const KIND = { answer: 'Answered', left: 'Left for you', nudge: 'Nudged', followup: 'Told to carry on', plan: 'Plan decided', merge: 'Merged' };
|
|
14
|
+
|
|
15
|
+
export const levelOf = (a) => (LEVELS.includes(a.autonomy?.level) ? a.autonomy.level : 'ask');
|
|
16
|
+
|
|
17
|
+
/** "2 answered, 1 nudge, 1 left for you". */
|
|
18
|
+
export function logLine(log = []) {
|
|
19
|
+
const n = (k) => log.filter((e) => e.kind === k).length;
|
|
20
|
+
return [n('answer') ? `${n('answer')} answered` : '', n('nudge') ? `${n('nudge')} nudge${n('nudge') === 1 ? '' : 's'}` : '', n('followup') ? `${n('followup')} follow-up${n('followup') === 1 ? '' : 's'}` : '', n('merge') ? 'merged' : '', n('left') ? `${n('left')} left for you` : '']
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join(', ');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** What was decided for you on an agent and you have not seen: inbox items. */
|
|
26
|
+
export function autonomyNeeds(a) {
|
|
27
|
+
const st = a.autonomy;
|
|
28
|
+
if (!st) return [];
|
|
29
|
+
const items = (st.log ?? []).filter((e) => e.kind === 'answer' && !e.ack).map((e) => ({ a, kind: 'auto', key: `auto:${a.id}:${e.id}`, e }));
|
|
30
|
+
if (st.hold && !st.hold.ack && st.level === 'merge') items.push({ a, kind: 'auto', key: `auto:${a.id}:hold`, e: { id: 'hold', kind: 'hold', ...st.hold } });
|
|
31
|
+
return items;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The inbox card of one such item. */
|
|
35
|
+
export function autoNeedHtml(it, { esc, ago }) {
|
|
36
|
+
const e = it.e;
|
|
37
|
+
if (e.kind === 'hold') {
|
|
38
|
+
return `<p class="need-title">Not merged: ${esc(e.note)}</p>
|
|
39
|
+
<p class="hint">Held ${ago(e.at)}. Its pull request stays open; merging it is yours.</p>
|
|
40
|
+
<div class="need-actions"><button class="small primary" data-ib="ap-review">Review changes</button><button class="small" data-ib="auto-ok" data-entry="hold">OK</button></div>`;
|
|
41
|
+
}
|
|
42
|
+
return `<p class="need-title">${esc(e.question)}</p>
|
|
43
|
+
<p class="auto-answer"><b>Answered for you:</b> ${esc(e.answer)}</p>
|
|
44
|
+
<p class="hint">${e.basis ? `From: ${esc(e.basis)} Β· ` : ''}${esc(e.model ?? (e.via === 'decide' ? 'Decide' : 'a model'))}, ${Math.round((e.confidence ?? 0) * 100)}% sure Β· ${ago(e.at)}.</p>
|
|
45
|
+
<div class="need-actions"><button class="small primary" data-ib="auto-ok" data-entry="${esc(e.id)}">OK</button><button class="small" data-ib="auto-change" data-entry="${esc(e.id)}" title="Give your own answer; the agent is told to apply it and undo what differs">Change answerβ¦</button></div>`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The row in the brief card: the level, what was done, and the way in. */
|
|
49
|
+
export function autonomyRow(a, esc) {
|
|
50
|
+
const st = a.autonomy;
|
|
51
|
+
if (a.team || a.reviewing || a.hunting || a.fixing || a.builds || a.raceId) return '';
|
|
52
|
+
if (!st || levelOf(a) === 'ask') {
|
|
53
|
+
return `<div class="plan-row"><button class="small ghost" data-act="auto-open" title="Let it go on without you: routine questions answered from what is already decided, nudges sent, and if you choose, its pull request opened or merged">${st?.log?.length ? 'Without you: off' : 'Run without meβ¦'}</button></div>`;
|
|
54
|
+
}
|
|
55
|
+
const line = logLine(st.log);
|
|
56
|
+
const held = st.hold && !st.hold.ack && st.level === 'merge';
|
|
57
|
+
return `<div class="plan-row auto-row"><b>Without you</b> <span class="tag auto-on">${esc(LEVEL_LABEL[st.level])}</span>${line ? ` <span class="hint">${esc(line)}</span>` : ''}${held ? ' <span class="tag acc-bad">merge held</span>' : ''}
|
|
58
|
+
<button class="small" data-act="auto-open">Open</button></div>`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function initAutonomy({ dialog, api, esc, toast, ago, agentOf, upsert }) {
|
|
62
|
+
let id = null;
|
|
63
|
+
|
|
64
|
+
function render() {
|
|
65
|
+
const a = id && agentOf(id);
|
|
66
|
+
if (!a) return;
|
|
67
|
+
const st = a.autonomy ?? { level: 'ask', log: [] };
|
|
68
|
+
const level = levelOf(a);
|
|
69
|
+
dialog.querySelector('#auto-title').textContent = `Without you: ${a.name}`;
|
|
70
|
+
const log = (st.log ?? []).slice().reverse();
|
|
71
|
+
const entry = (e) => {
|
|
72
|
+
const head = `<b>${KIND[e.kind] ?? esc(e.kind)}</b> <span class="hint">${ago(e.at)}</span>`;
|
|
73
|
+
if (e.kind === 'answer') {
|
|
74
|
+
return `<li>${head}<div>${esc(e.question)}</div>
|
|
75
|
+
<div class="auto-answer">β ${e.corrected ? `<s>${esc(e.answer)}</s> yours: ${esc(e.corrected)}` : esc(e.answer)}</div>
|
|
76
|
+
<div class="hint">${e.basis ? `From: ${esc(e.basis)} Β· ` : ''}${esc(e.model ?? (e.via === 'decide' ? 'Decide' : 'a model'))}, ${Math.round((e.confidence ?? 0) * 100)}% sure</div>
|
|
77
|
+
${e.corrected ? '' : `<div class="need-actions">${e.ack ? '' : `<button type="button" class="small" data-auto="ok" data-entry="${esc(e.id)}">OK</button>`}<button type="button" class="small ghost" data-auto="change" data-entry="${esc(e.id)}">Change answerβ¦</button></div>`}</li>`;
|
|
78
|
+
}
|
|
79
|
+
if (e.kind === 'left') return `<li>${head}<div>${esc(e.question)}</div>${e.why ? `<div class="hint">${esc(e.why)}</div>` : ''}</li>`;
|
|
80
|
+
return `<li>${head}<div>${esc(e.title ?? '')}</div>${e.text ? `<div class="hint">${esc(e.text)}</div>` : ''}</li>`;
|
|
81
|
+
};
|
|
82
|
+
dialog.querySelector('#auto-body').innerHTML = `
|
|
83
|
+
<label>How far it goes
|
|
84
|
+
<select data-auto="level">${LEVELS.map((l) => `<option value="${l}" ${l === level ? 'selected' : ''}>${LEVEL_LABEL[l]}</option>`).join('')}</select>
|
|
85
|
+
</label>
|
|
86
|
+
<p class="hint">${LEVEL_HINT[level]}</p>
|
|
87
|
+
<p class="hint">Never done for you: answering a permission prompt, or a question about deleting, publishing, money, credentials or the scope of the task.</p>
|
|
88
|
+
${st.hold && !st.hold.ack && level === 'merge' ? `<p class="auto-hold"><b>Not merged:</b> ${esc(st.hold.note)} <button type="button" class="small" data-auto="ok" data-entry="hold">OK</button></p>` : ''}
|
|
89
|
+
${log.length ? `<h4>Done for you</h4><ul class="auto-log">${log.map(entry).join('')}</ul>` : level === 'ask' ? '' : '<p class="hint">Nothing was done for you yet.</p>'}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const run = async (fn, ok) => {
|
|
93
|
+
try {
|
|
94
|
+
const a = await fn();
|
|
95
|
+
if (a?.id) upsert(a);
|
|
96
|
+
if (ok) toast(ok);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
toast(`Error: ${e.message}`, 5000);
|
|
99
|
+
}
|
|
100
|
+
render();
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** Your own answer to a question that was answered for you. */
|
|
104
|
+
function change(agentId, entryId) {
|
|
105
|
+
const e = agentOf(agentId)?.autonomy?.log?.find((x) => x.id === entryId);
|
|
106
|
+
if (!e) return;
|
|
107
|
+
const text = prompt(`${e.question}\n\nAnswered for you: ${e.answer}\n\nYour answer:`, '');
|
|
108
|
+
if (!text?.trim()) return;
|
|
109
|
+
return run(() => api('POST', `/agents/${agentId}/autonomy/correct`, { entry: entryId, text: text.trim() }), 'Your answer was sent; the agent applies it');
|
|
110
|
+
}
|
|
111
|
+
const ok = (agentId, entryId) => run(() => api('POST', `/agents/${agentId}/autonomy/ack`, { entry: entryId }));
|
|
112
|
+
|
|
113
|
+
dialog.addEventListener('change', (e) => {
|
|
114
|
+
if (e.target.dataset.auto !== 'level' || !id) return;
|
|
115
|
+
const level = e.target.value;
|
|
116
|
+
run(() => api('POST', `/agents/${id}/autonomy`, { level }), level === 'ask' ? 'It asks you again' : `${LEVEL_LABEL[level]}: it goes on without you`);
|
|
117
|
+
});
|
|
118
|
+
dialog.addEventListener('click', (e) => {
|
|
119
|
+
const el = e.target.closest('[data-auto]');
|
|
120
|
+
if (!el || !id) return;
|
|
121
|
+
if (el.dataset.auto === 'close') return dialog.close();
|
|
122
|
+
if (el.dataset.auto === 'ok') return ok(id, el.dataset.entry);
|
|
123
|
+
if (el.dataset.auto === 'change') return change(id, el.dataset.entry);
|
|
124
|
+
});
|
|
125
|
+
dialog.addEventListener('close', () => (id = null));
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
open(agentId) {
|
|
129
|
+
id = agentId;
|
|
130
|
+
render();
|
|
131
|
+
if (!dialog.open) dialog.showModal();
|
|
132
|
+
},
|
|
133
|
+
ok,
|
|
134
|
+
change,
|
|
135
|
+
/** The agent changed (a new answer, a new level): show it, unless the level menu is open. */
|
|
136
|
+
agentChanged(a) {
|
|
137
|
+
if (id === a.id && document.activeElement?.dataset?.auto !== 'level') render();
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
package/public/boardcols.js
CHANGED
|
@@ -20,6 +20,7 @@ export function needOf(a) {
|
|
|
20
20
|
if (a.status === 'error') return 'an error';
|
|
21
21
|
if (rt.limited) return 'stopped at a limit';
|
|
22
22
|
if (a.planReview?.status === 'review') return 'a plan to approve';
|
|
23
|
+
if (a.acceptance?.status === 'review' && a.acceptance.wait) return 'what done means, to agree';
|
|
23
24
|
const q = (a.questions ?? []).filter((x) => !x.answer).length;
|
|
24
25
|
if (q) return q === 1 ? 'a question' : `${q} questions`;
|
|
25
26
|
if (rt.waiting) return rt.waiting.kind === 'error' ? 'an error on its screen' : 'a question on its screen';
|
package/public/claims.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Claims check, in the document dialog: each statement of fact in an agent's brief and in what was
|
|
2
|
+
// written about its work, with the source that backs it (src/claims.js). What is contradicted or
|
|
3
|
+
// not backed comes first; the rest is folded away.
|
|
4
|
+
|
|
5
|
+
const LABEL = { contradicted: 'Contradicted', not_backed: 'Not backed', said: 'Only the agent says so', backed: 'Backed', opinion: 'Opinion or plan' };
|
|
6
|
+
const HINT = {
|
|
7
|
+
contradicted: 'A source says otherwise',
|
|
8
|
+
not_backed: 'No source says so, or what the checker quoted is not in the source',
|
|
9
|
+
said: 'In the brief, spec, plan or conversation only: nothing measured shows it',
|
|
10
|
+
backed: 'A source says so, and the quote was found in it',
|
|
11
|
+
opinion: 'A judgment, estimate or plan: the sources cannot settle it',
|
|
12
|
+
};
|
|
13
|
+
const ORDER = ['contradicted', 'not_backed', 'said', 'backed', 'opinion'];
|
|
14
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
15
|
+
|
|
16
|
+
/** "1 contradicted Β· 2 not backed Β· 5 backed" as chips. */
|
|
17
|
+
export function countsHtml(counts, gone, esc) {
|
|
18
|
+
const chip = (v, n) => (n ? `<span class="cl-chip cl-${v}" title="${esc(HINT[v])}">${n} ${esc(LABEL[v].toLowerCase())}</span>` : '');
|
|
19
|
+
return `${ORDER.slice(0, 4).map((v) => chip(v, counts[v])).join('')}${gone ? `<span class="cl-chip cl-not_backed" title="Files, links, pull requests or numbers in the text that are in none of the sources, in statements the checker passed over">${plural(gone, 'particular')} nowhere in the sources</span>` : ''}` || '<span class="cl-chip">no statements of fact</span>';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function textHtml(t, esc) {
|
|
23
|
+
if (t.error) return `<section class="ha-card cl-text"><h3>${esc(t.label)}</h3><p class="error">Not checked: ${esc(t.error)}</p></section>`;
|
|
24
|
+
const item = (c) => `<li class="cl-claim cl-${c.verdict}">
|
|
25
|
+
<div class="cl-said">${esc(c.text)}</div>
|
|
26
|
+
${c.quote ? `<div class="hint cl-quote"><b>${esc(c.source.name)}:</b> β${esc(c.quote)}β</div>` : ''}
|
|
27
|
+
${c.note ? `<div class="hint">${esc(c.note)}</div>` : ''}
|
|
28
|
+
</li>`;
|
|
29
|
+
const group = (v) => {
|
|
30
|
+
const list = t.claims.filter((c) => c.verdict === v);
|
|
31
|
+
if (!list.length) return '';
|
|
32
|
+
const open = v === 'contradicted' || v === 'not_backed' || v === 'said';
|
|
33
|
+
return `<details class="cl-group" ${open ? 'open' : ''}><summary><span class="cl-chip cl-${v}">${list.length}</span> ${esc(LABEL[v])} <span class="hint">${esc(HINT[v])}</span></summary><ul class="cl-list">${list.map(item).join('')}</ul></details>`;
|
|
34
|
+
};
|
|
35
|
+
const gone = t.missing.length
|
|
36
|
+
? `<details class="cl-group" open><summary><span class="cl-chip cl-not_backed">${t.missing.length}</span> Nowhere in the sources <span class="hint">in statements the checker passed over</span></summary><ul class="cl-list">${t.missing.map((s) => `<li class="cl-claim cl-not_backed"><span class="hint">${esc(s.kind)}</span> <code>${esc(s.value)}</code></li>`).join('')}</ul></details>`
|
|
37
|
+
: '';
|
|
38
|
+
return `<section class="ha-card cl-text" data-claims-text="${esc(t.key)}"><h3>${esc(t.label)}</h3><p class="cl-counts">${countsHtml(t.counts, t.missing.length, esc)}</p>${ORDER.map(group).join('')}${gone}</section>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function claimsHtml(d, esc) {
|
|
42
|
+
const c = d.data;
|
|
43
|
+
return `<div class="cl">
|
|
44
|
+
<p class="cl-counts cl-total">${countsHtml(c.counts, c.missing, esc)}</p>
|
|
45
|
+
<p class="hint">Each statement of fact, traced to a source by ${esc(d.writer ?? 'another model')}. The app checked that every statement is in the text, every quote in its source, and that the files, links, pull requests and numbers exist in the sources. Whether a quote really shows the statement is the model's reading: read the ones that matter.</p>
|
|
46
|
+
${c.texts.map((t) => textHtml(t, esc)).join('')}
|
|
47
|
+
<p class="hint">Sources: ${c.sources.map((s) => `${esc(s.name)}${s.own ? " (the agent's own account)" : ''}`).join(' Β· ')}</p>
|
|
48
|
+
</div>`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The check of one text of an agent, if it was made of the text as it is now. */
|
|
52
|
+
export function checkOf(a, key, at) {
|
|
53
|
+
const t = a?.docs?.claims?.data?.texts.find((x) => x.key === key && !x.error);
|
|
54
|
+
return t && t.at === at ? t : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** One line over a document about its last check, with the way to the whole of it. */
|
|
58
|
+
export function claimsNote(a, key, at, esc) {
|
|
59
|
+
const d = a?.docs?.claims;
|
|
60
|
+
if (d?.pending) return '<p class="hint cl-note">Checking its statements against the workβ¦</p>';
|
|
61
|
+
const t = checkOf(a, key, at);
|
|
62
|
+
if (!t) return `<p class="hint cl-note">Its statements are not checked against the work yet. <button type="button" class="link" data-doc="claims" data-run>Check claims</button></p>`;
|
|
63
|
+
const doubt = t.counts.contradicted + t.counts.not_backed + t.missing.length;
|
|
64
|
+
return `<p class="cl-note ${doubt ? 'cl-doubt' : ''}">${doubt ? '<b>Read before sending:</b> ' : 'Checked against the work: '}${countsHtml(t.counts, t.missing.length, esc)} <button type="button" class="link" data-doc="claims">Claims</button></p>`;
|
|
65
|
+
}
|