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.
@@ -0,0 +1,203 @@
1
+ // Drop to start: tickets, requirements, designs and files dragged onto the page (or onto the New
2
+ // agents form) fill the form in. A ticket link becomes the request (the agent is named after the
3
+ // issue and tracks it), a repository link fills the repository, requirement and design links are
4
+ // listed as context, text becomes the request, and files are attached. Nothing starts until you
5
+ // press the button: what was understood is shown first.
6
+
7
+ const IMAGE = /\.(png|jpe?g|gif|webp|svg|fig|sketch|xd|psd)(\?|#|$)/i;
8
+ const DOCUMENT = /\.(pdf|md|markdown|docx?|txt|rtf|pptx?|xlsx?|csv)(\?|#|$)/i;
9
+
10
+ /** What a link is: { kind: 'ticket' | 'repo' | 'design' | 'doc' | 'link', url, label, repo? }. */
11
+ export function classifyUrl(raw) {
12
+ let u;
13
+ try {
14
+ u = new URL(String(raw).trim());
15
+ } catch {
16
+ return null;
17
+ }
18
+ if (!/^https?:$/.test(u.protocol)) return null;
19
+ const url = u.href;
20
+ const host = u.hostname.replace(/^www\./, '').toLowerCase();
21
+ const parts = u.pathname.split('/').filter(Boolean);
22
+ const jira = u.pathname.match(/\/browse\/([A-Z][A-Z0-9_]+-\d+)/i)?.[1] ?? u.searchParams.get('selectedIssue');
23
+ if (jira && /^[A-Z][A-Z0-9_]+-\d+$/i.test(jira)) return { kind: 'ticket', url, label: jira.toUpperCase() };
24
+ if (['github.com', 'gitlab.com', 'bitbucket.org'].includes(host) && parts.length >= 2) {
25
+ const repo = `https://${host}/${parts[0]}/${parts[1].replace(/\.git$/, '')}.git`;
26
+ const issue = u.pathname.match(/\/(?:-\/)?issues\/(\d+)/);
27
+ if (issue) return { kind: 'ticket', url, label: `${parts[1]}#${issue[1]}`, repo };
28
+ if (parts.length === 2) return { kind: 'repo', url: repo, label: `${parts[0]}/${parts[1].replace(/\.git$/, '')}` };
29
+ }
30
+ if (/\.git$/.test(u.pathname)) return { kind: 'repo', url, label: parts.slice(-2).join('/').replace(/\.git$/, '') };
31
+ if (host === 'linear.app' && /\/issue\//.test(u.pathname)) return { kind: 'ticket', url, label: u.pathname.match(/\/issue\/([^/]+)/)?.[1] ?? 'issue' };
32
+ if (/(^|\.)(figma\.com|sketch\.com|zeplin\.io|miro\.com|whimsical\.com|excalidraw\.com|invisionapp\.com|framer\.com|canva\.com)$/.test(host) || IMAGE.test(u.pathname)) return { kind: 'design', url, label: host };
33
+ if (/(^|\.)(docs\.google\.com|drive\.google\.com|notion\.so|notion\.site|paper\.dropbox\.com|coda\.io|sharepoint\.com|quip\.com)$/.test(host) || /(^|\.)atlassian\.net$/.test(host) || /\/(wiki|confluence)\//.test(u.pathname) || DOCUMENT.test(u.pathname)) return { kind: 'doc', url, label: host };
34
+ return { kind: 'link', url, label: host };
35
+ }
36
+
37
+ /**
38
+ * What was dropped or pasted, sorted: `uris` (the text/uri-list of a drag) and `text` (its
39
+ * text/plain). Text that is only links counts as links; any other text is kept as the request.
40
+ * Returns { tickets, repo, designs, docs, links, text }.
41
+ */
42
+ export function readDrop({ uris = '', text = '' } = {}) {
43
+ const out = { tickets: [], repo: null, designs: [], docs: [], links: [], text: '' };
44
+ const seen = new Set();
45
+ const take = (raw) => {
46
+ const c = classifyUrl(raw);
47
+ if (!c || seen.has(c.url)) return Boolean(c);
48
+ seen.add(c.url);
49
+ if (c.kind === 'ticket') out.tickets.push(c);
50
+ else if (c.kind === 'repo') out.repo ??= c;
51
+ else out[`${c.kind}s`].push(c);
52
+ if (c.repo && !out.repo) out.repo = { kind: 'repo', url: c.repo, label: c.repo.replace(/^https:\/\/[^/]+\//, '').replace(/\.git$/, ''), implied: true };
53
+ return true;
54
+ };
55
+ for (const line of String(uris).split(/\r?\n/)) if (line.trim() && !line.startsWith('#')) take(line);
56
+ const words = String(text).trim().split(/\s+/).filter(Boolean);
57
+ if (words.length && words.every((w) => classifyUrl(w))) words.forEach(take);
58
+ else if (String(text).trim() && !seen.has(classifyUrl(String(text).trim())?.url)) out.text = String(text).trim();
59
+ return out;
60
+ }
61
+
62
+ export const isEmptyDrop = (d) => !d.tickets.length && !d.repo && !d.designs.length && !d.docs.length && !d.links.length && !d.text;
63
+
64
+ const contextLines = (d) => [...d.docs.map((x) => `- Requirements: ${x.url}`), ...d.designs.map((x) => `- Design: ${x.url}`), ...d.links.map((x) => `- Link: ${x.url}`)];
65
+
66
+ /**
67
+ * The request text after a drop. `current` is what the form holds and `split` its mode ("lines":
68
+ * one agent per line; "one": the whole text is one request). Several tickets become one line each;
69
+ * one ticket (or none) with context becomes one request with the context listed under it.
70
+ * Returns { text, split }.
71
+ */
72
+ export function composeIntents(current, d, split = 'lines') {
73
+ const cur = String(current ?? '').replace(/\s+$/, '');
74
+ const ctx = contextLines(d);
75
+ const flat = [...d.docs, ...d.designs, ...d.links].map((x) => x.url).join(' ');
76
+ // Lines that are each their own agent stay that way: context rides on the ticket's line.
77
+ if (d.tickets.length > 1 || (cur && split === 'lines')) {
78
+ const lines = d.tickets.map((t) => `${t.url}${flat ? ` (context: ${flat})` : ''}`);
79
+ if (!lines.length && (flat || d.text)) lines.push([d.text.replace(/\s*\n\s*/g, ' '), flat ? `(context: ${flat})` : ''].filter(Boolean).join(' '));
80
+ else if (d.text) lines.push(d.text.replace(/\s*\n\s*/g, ' '));
81
+ return { text: [cur, ...lines].filter(Boolean).join('\n'), split: 'lines' };
82
+ }
83
+ const whole = Boolean(ctx.length || /\n/.test(d.text) || (d.tickets.length && d.text) || split === 'one');
84
+ const body = [d.tickets[0]?.url, d.text, ctx.length ? `Context:\n${ctx.join('\n')}` : ''].filter(Boolean).join('\n\n');
85
+ return { text: [cur, body].filter(Boolean).join('\n\n'), split: whole ? 'one' : split };
86
+ }
87
+
88
+ /** "2 tickets, 1 requirements link, 1 design, the repository, 2 files". */
89
+ export function dropSummary(d, files = 0) {
90
+ const n = (k, one, many) => (k ? `${k} ${k === 1 ? one : many}` : '');
91
+ return [n(d.tickets.length, 'ticket', 'tickets'), n(d.docs.length, 'requirements link', 'requirements links'), n(d.designs.length, 'design', 'designs'), n(d.links.length, 'link', 'links'), d.repo ? 'the repository' : '', d.text ? 'the text' : '', n(files, 'file', 'files')].filter(Boolean).join(', ');
92
+ }
93
+
94
+ const has = (e, type) => [...(e.dataTransfer?.types ?? [])].includes(type);
95
+ const droppable = (e) => has(e, 'Files') || has(e, 'text/uri-list') || has(e, 'text/plain');
96
+
97
+ /**
98
+ * `form`: the New agents form (fields intents, split, repo, dir). `zone`: the box inside it.
99
+ * `overlay`: the page-wide "drop to start" frame. `attach.add(files)` attaches files. `open()`
100
+ * opens the form; `isOpen()` says whether it is. `sync()` after the text or the mode changed.
101
+ */
102
+ export function initDropZone({ form, zone, overlay, attach, open, isOpen, sync, toast }) {
103
+ const added = zone.querySelector('.drop-added');
104
+ let internal = false; // a drag that started on this page (reordering agents, moving text) is not ours
105
+
106
+ function apply(d, files = []) {
107
+ if (isEmptyDrop(d) && !files.length) return false;
108
+ if (!isEmptyDrop(d)) {
109
+ const next = composeIntents(form.intents.value, d, form.split.value);
110
+ form.intents.value = next.text;
111
+ if (next.split !== form.split.value) form.split.value = next.split;
112
+ if (d.repo && !form.repo.value.trim() && !form.dir.value.trim() && !form.project?.value.trim()) form.repo.value = d.repo.url;
113
+ }
114
+ if (files.length) attach.add(files);
115
+ sync();
116
+ const what = dropSummary(d, files.length);
117
+ added.textContent = what ? `Added: ${what}. Check the request below, then start.` : '';
118
+ zone.classList.toggle('filled', Boolean(what));
119
+ return true;
120
+ }
121
+
122
+ const take = (e) => {
123
+ const files = [...(e.dataTransfer?.files ?? [])];
124
+ // A picture dragged from a web page comes as a file and as its link: the file is enough.
125
+ const d = files.length ? readDrop({}) : readDrop({ uris: e.dataTransfer?.getData('text/uri-list') ?? '', text: e.dataTransfer?.getData('text/plain') ?? '' });
126
+ return { d, files };
127
+ };
128
+
129
+ document.addEventListener('dragstart', () => (internal = true));
130
+ document.addEventListener('dragend', () => (internal = false));
131
+ // A drag whose element was redrawn under it ends without "dragend": the next press starts clean.
132
+ document.addEventListener('pointerdown', () => (internal = false), true);
133
+
134
+ // On the form: links and text (files are taken by the attachments box, which listens there too).
135
+ form.addEventListener('dragover', (e) => {
136
+ if (internal || !droppable(e)) return;
137
+ e.preventDefault();
138
+ zone.classList.add('over');
139
+ });
140
+ form.addEventListener('dragleave', (e) => {
141
+ if (!form.contains(e.relatedTarget)) zone.classList.remove('over');
142
+ });
143
+ form.addEventListener('drop', (e) => {
144
+ zone.classList.remove('over');
145
+ if (internal) return;
146
+ const { d, files } = take(e);
147
+ if (files.length) {
148
+ // The attachments box adds them; here only the summary.
149
+ added.textContent = `Added: ${dropSummary(d, files.length)}. Check the request below, then start.`;
150
+ zone.classList.add('filled');
151
+ return;
152
+ }
153
+ if (isEmptyDrop(d)) return;
154
+ e.preventDefault();
155
+ apply(d);
156
+ });
157
+
158
+ // Anywhere on the page, when nothing else takes the drop and no dialog is open: start a new agent.
159
+ const busy = () => internal || Boolean(document.querySelector('dialog[open]'));
160
+ const hide = () => (overlay.hidden = true);
161
+ document.addEventListener('dragover', (e) => {
162
+ if (busy() || e.defaultPrevented || !droppable(e)) return hide();
163
+ e.preventDefault();
164
+ e.dataTransfer.dropEffect = 'copy';
165
+ overlay.hidden = false;
166
+ });
167
+ document.addEventListener('dragleave', (e) => {
168
+ if (!e.relatedTarget) hide();
169
+ });
170
+ document.addEventListener('drop', (e) => {
171
+ const shown = !overlay.hidden;
172
+ hide();
173
+ if (!shown || busy() || e.defaultPrevented) return;
174
+ const { d, files } = take(e);
175
+ if (isEmptyDrop(d) && !files.length) return;
176
+ e.preventDefault();
177
+ if (!isOpen()) open();
178
+ apply(d, files);
179
+ });
180
+
181
+ // Without a mouse (a phone): paste what was copied, or pick files.
182
+ zone.addEventListener('click', async (e) => {
183
+ const act = e.target.closest('[data-drop-act]')?.dataset.dropAct;
184
+ if (act === 'pick') return attach.pick();
185
+ if (act !== 'paste') return;
186
+ try {
187
+ const text = await navigator.clipboard.readText();
188
+ if (!apply(readDrop({ text }))) toast('Nothing to paste: copy a ticket or document link first', 4000);
189
+ } catch {
190
+ toast('The browser did not allow reading the clipboard: paste into the text box instead', 5000);
191
+ }
192
+ });
193
+ if (!navigator.clipboard?.readText) zone.querySelector('[data-drop-act="paste"]')?.remove();
194
+
195
+ return {
196
+ apply,
197
+ /** A new form: nothing added yet. */
198
+ reset() {
199
+ added.textContent = '';
200
+ zone.classList.remove('filled', 'over');
201
+ },
202
+ };
203
+ }
package/public/index.html CHANGED
@@ -257,6 +257,13 @@
257
257
  <label class="check" title="The whole text goes to one agent: a long description, a spec, pasted notes"><input type="radio" name="split" value="one" /> One agent for all of it</label>
258
258
  <span class="spacer"></span><span class="hint" id="intent-count"></span>
259
259
  </div>
260
+ <div id="new-drop" class="drop-zone">
261
+ <span class="drop-icon" aria-hidden="true">⤓</span>
262
+ <span class="drop-text"><b>Drop tickets, requirements and designs here</b>
263
+ <span class="hint">Jira or GitHub issue links, a PRD or design link, screenshots, documents: the form is filled in for you. <button type="button" class="link" data-drop-act="paste">Paste what you copied</button> · <button type="button" class="link" data-drop-act="pick">Choose files</button></span>
264
+ <span class="drop-added" role="status"></span>
265
+ </span>
266
+ </div>
260
267
  <label>
261
268
  <span class="sr-only">Intents</span>
262
269
  <textarea name="intents" rows="6" required placeholder="Add a dark mode toggle that remembers the user's choice&#10;Make search results show up as you type&#10;Find out why the dashboard takes 5 seconds to load and speed it up&#10;Add a one-click CSV export to the reports page"></textarea>
@@ -314,6 +321,20 @@
314
321
  <input type="checkbox" name="plan" checked />
315
322
  Plan with Claude while the repo clones <span class="hint">(repo URLs only; the session moves into the repo when it's ready)</span>
316
323
  </label>
324
+ <label class="check">
325
+ <input type="checkbox" name="acceptance" />
326
+ Agree on what done means first <span class="hint">(the agent writes three to six points you can check and waits; you change them and agree, and its work is checked against them)</span>
327
+ </label>
328
+ <label>
329
+ Without you <span class="hint">how far each agent goes before it needs you; routine questions are answered from what is already decided, and each answer shows in your inbox</span>
330
+ <select name="autonomy" id="new-autonomy">
331
+ <option value="">The default</option>
332
+ <option value="ask">Ask me</option>
333
+ <option value="run">Agree, then run</option>
334
+ <option value="pr">Run to pull request</option>
335
+ <option value="merge">Run to merge</option>
336
+ </select>
337
+ </label>
317
338
  <label class="check">
318
339
  <input type="checkbox" name="planReview" />
319
340
  Review the implementation plan first <span class="hint">(the agent writes a plan and waits for your approval before changing anything)</span>
@@ -913,6 +934,22 @@
913
934
  </div>
914
935
  </dialog>
915
936
 
937
+ <dialog id="accept-dialog" class="update-dialog accept-dialog" aria-label="What done means">
938
+ <h2 id="acc-title">What done means</h2>
939
+ <div id="acc-body"></div>
940
+ <div class="dialog-actions" id="acc-actions"></div>
941
+ </dialog>
942
+
943
+ <div id="drop-overlay" class="drop-overlay" hidden aria-hidden="true">
944
+ <div class="drop-frame"><span class="drop-icon">⤓</span><b>Drop to start a new agent</b><span>Tickets, requirements, designs, screenshots or files: the form is filled in, and you start it.</span></div>
945
+ </div>
946
+
947
+ <dialog id="auto-dialog" class="update-dialog auto-dialog" aria-label="Without you">
948
+ <h2 id="auto-title">Without you</h2>
949
+ <div id="auto-body"></div>
950
+ <div class="dialog-actions"><button type="button" class="small primary" data-auto="close">Close</button></div>
951
+ </dialog>
952
+
916
953
  <dialog id="update-dialog" class="update-dialog" aria-label="Update">
917
954
  <h2 id="update-title">Update</h2>
918
955
  <div id="update-body"></div>
@@ -978,6 +1015,25 @@
978
1015
  <label class="check"><input type="checkbox" name="judgeOn" /> AI judge: checks stuck agents, idle screens, finished work, overlaps, backlog order and alerts</label>
979
1016
  <p class="hint">On your own Claude or Codex plan; without it, fixed rules only. <span id="settings-judge-state"></span></p>
980
1017
  </fieldset>
1018
+ <fieldset id="settings-ground">
1019
+ <legend>Ground rules</legend>
1020
+ <p class="hint">Your own rules for every agent, in every repository, one per line. Agents get them with their instructions, next to what is in the repository's memory and its standards, and are told to stop and say so when a task cannot be done without breaking one.</p>
1021
+ <textarea name="groundRules" rows="5" placeholder="Ask before adding a dependency&#10;Never force-push or rewrite history&#10;Say how sure you are of anything you build, and why" aria-label="Ground rules, one per line"></textarea>
1022
+ <label class="check"><input type="checkbox" name="groundTell" /> Also tell the agents running now <span class="hint">(others get them when they start)</span></label>
1023
+ </fieldset>
1024
+ <fieldset id="settings-autonomy">
1025
+ <legend>Without you</legend>
1026
+ <label>New agents
1027
+ <select name="autoLevel">
1028
+ <option value="ask">Ask me</option>
1029
+ <option value="run">Agree, then run</option>
1030
+ <option value="pr">Run to pull request</option>
1031
+ <option value="merge">Run to merge</option>
1032
+ </select>
1033
+ </label>
1034
+ <label>Models, best first <input name="autoModels" placeholder="fable, opus, sonnet" autocomplete="off" autocapitalize="off" spellcheck="false" /></label>
1035
+ <p class="hint">How far an agent goes when you name no level. Past "Ask me", routine questions are answered from what is already decided (your request, the agreed points, your ground rules, the repository's lessons), nudges are sent and quiet agents told to carry on. The first model answers; the next one is used when a call fails. Never answered for you: permission prompts, and questions about deleting, publishing, money, credentials or scope. <span id="settings-autonomy-state"></span></p>
1036
+ </fieldset>
981
1037
  <fieldset class="local-only" id="settings-service">
982
1038
  <legend>Start at login</legend>
983
1039
  <label class="check"><input type="checkbox" name="startAtLogin" /> Start AI Agent Manager when I log in</label>
package/public/menu.js CHANGED
@@ -61,6 +61,9 @@ export function initMenu({ api, esc, toast, $ }) {
61
61
  let features = null; // what you use, and who you are, as the dialog opened
62
62
  let rounds = null; // review rounds as the dialog opened
63
63
  let judge = null; // the AI judge as the dialog opened
64
+ let ground = null; // your ground rules as the dialog opened
65
+ let autonomy = null; // the autonomy settings as the dialog opened
66
+ const modelList = (a) => (a?.models ?? []).map((m) => (typeof m === 'string' ? m : m.model)).join(', ');
64
67
  const FEATURE_KEYS = ['jira', 'slack', 'gemini'];
65
68
  function showContainers() {
66
69
  const c = containers;
@@ -118,6 +121,15 @@ export function initMenu({ api, esc, toast, $ }) {
118
121
  form.judgeOn.closest('label').hidden = !judge;
119
122
  form.judgeOn.checked = Boolean(judge?.enabled);
120
123
  $('#settings-judge-state').textContent = judge?.enabled ? `${judge.calls} of ${judge.cap} calls today.` : '';
124
+ ground = await api('GET', '/ground-rules').catch(() => null);
125
+ $('#settings-ground').hidden = !ground;
126
+ form.groundRules.value = ground?.text ?? '';
127
+ form.groundTell.checked = false;
128
+ autonomy = await api('GET', '/autonomy').catch(() => null);
129
+ $('#settings-autonomy').hidden = !autonomy;
130
+ form.autoLevel.value = autonomy?.level ?? 'ask';
131
+ form.autoModels.value = modelList(autonomy);
132
+ $('#settings-autonomy-state').textContent = autonomy ? `${autonomy.agents} agent${autonomy.agents === 1 ? '' : 's'} running without you now; ${autonomy.calls} of ${autonomy.dailyCalls} calls today${autonomy.lastModel ? `, last answered by ${autonomy.lastModel}` : ''}.` : '';
121
133
  const u = await api('GET', '/update').catch(() => null);
122
134
  form.updateCheck.checked = u?.check !== false;
123
135
  if (!remote()) {
@@ -209,6 +221,14 @@ export function initMenu({ api, esc, toast, $ }) {
209
221
  if (Object.keys(changed).length) rounds = await api('PUT', '/prereview', changed);
210
222
  }
211
223
  if (judge && form.judgeOn.checked !== Boolean(judge.enabled)) judge = await api('PUT', '/judge', { enabled: form.judgeOn.checked });
224
+ if (ground && form.groundRules.value.trim() !== ground.text.trim()) {
225
+ const g = await api('PUT', '/ground-rules', { text: form.groundRules.value, tell: form.groundTell.checked });
226
+ toast(`${g.rules.length} ground rule${g.rules.length === 1 ? '' : 's'}: agents get them when they start${g.told ? `, and ${g.told} running now ${g.told === 1 ? 'was' : 'were'} told` : ''}`, 5000);
227
+ }
228
+ if (autonomy) {
229
+ const want = { ...(form.autoLevel.value !== autonomy.level ? { level: form.autoLevel.value } : {}), ...(form.autoModels.value.trim() && form.autoModels.value.trim() !== modelList(autonomy) ? { models: form.autoModels.value } : {}) };
230
+ if (Object.keys(want).length) autonomy = await api('PUT', '/autonomy', want);
231
+ }
212
232
  document.dispatchEvent(new CustomEvent('agentmgr:review-settings'));
213
233
  if (!remote() && jira && (form.jiraSite.value.trim() !== (jira.site ?? '') || form.jiraEmail.value.trim() !== (jira.email ?? '') || form.jiraToken.value.trim())) {
214
234
  const j = await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
@@ -64,7 +64,7 @@ export function scorecardHtml(doc, esc, { stale = false, actions = '' } = {}) {
64
64
  return `<div class="sc-row"><span class="sc-label">${label}</span><span class="sc-bar"><span class="${tone(d.score)}" style="width:${d.score}%"></span></span><span class="sc-n">${d.score}</span><span class="sc-why">${esc(d.why)}${d.notes.length ? ` <span class="sc-note">${esc(d.notes.join('; '))}</span>` : ''}</span></div>`;
65
65
  }).join('');
66
66
  const crit = sc.criteria.length
67
- ? `<details class="sc-crit" ${sc.criteria.some((c) => c.status !== 'met') ? 'open' : ''}><summary>Acceptance criteria: ${sc.criteria.filter((c) => c.status === 'met').length} of ${sc.criteria.length} met</summary><ul>${sc.criteria.map((c) => `<li class="${c.status}"><span class="sc-mark">${c.status === 'met' ? '✓' : c.status === 'not_met' ? '✗' : '?'}</span>${esc(c.criterion)}${c.evidence ? ` <span class="hint">${esc(c.evidence)}</span>` : ''}</li>`).join('')}</ul></details>`
67
+ ? `<details class="sc-crit" ${sc.criteria.some((c) => c.status !== 'met') ? 'open' : ''}><summary>${sc.criteria.some((c) => c.agreed) ? 'What done means, as agreed' : 'Acceptance criteria'}: ${sc.criteria.filter((c) => c.status === 'met').length} of ${sc.criteria.length} met</summary><ul>${sc.criteria.map((c) => `<li class="${c.status}"><span class="sc-mark">${c.status === 'met' ? '✓' : c.status === 'not_met' ? '✗' : '?'}</span>${esc(c.criterion)}${c.evidence ? ` <span class="hint">${esc(c.evidence)}</span>` : ''}</li>`).join('')}</ul></details>`
68
68
  : '';
69
69
  const look = sc.look.length
70
70
  ? `<div class="sc-look"><b>Where to look</b><ol>${sc.look.map((l) => `<li><button type="button" class="link" data-sc-look="${esc(`${l.file}\t${l.head}`)}"><code>${esc(l.file)}</code></button> ${esc(l.reason)}</li>`).join('')}</ol></div>`
package/public/standup.js CHANGED
@@ -165,6 +165,7 @@ export function initStandup({ api, $, esc, agents, needsFor, needCard, onNeed, t
165
165
  }
166
166
  if (need.kind === 'question') return { label: `answer “${t}”`, run: () => api('POST', `/agents/${a.id}/answer`, { question: need.q.id, text: t }) };
167
167
  if (need.kind === 'waiting') return { label: `reply “${t}”`, run: () => api('POST', `/agents/${a.id}/waiting/answer`, { text: t }) };
168
+ if (need.kind === 'acceptance' && /\b(agree|agreed|approve|looks good|go ahead)\b/i.test(t)) return { label: 'agree on its points as written', run: () => api('POST', `/agents/${a.id}/acceptance/agree`, {}) };
168
169
  if (need.kind === 'plan' && /\b(approve|looks good|go ahead|ship it)\b/i.test(t)) return { label: 'approve its plan', run: () => api('POST', `/agents/${a.id}/plan/approve`, {}) };
169
170
  return { label: `tell it “${t}”`, run: () => api('POST', `/agents/${a.id}/tell`, { text: t }) };
170
171
  }
package/public/style.css CHANGED
@@ -516,7 +516,7 @@ dialog::backdrop { background: rgba(0, 0, 0, .45); }
516
516
  .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
517
517
  .row.three { grid-template-columns: 1fr 1fr 1fr; }
518
518
  .team-gaps { max-height: 220px; overflow: auto; margin: 6px 0; font-size: 13px; }
519
- .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
519
+ .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
520
520
  .error { color: var(--red); margin: 0; font-size: 13px; }
521
521
 
522
522
  .update-dialog { width: min(520px, calc(100vw - 32px)); padding: 20px; }
@@ -676,6 +676,22 @@ pre.diff .meta { color: var(--muted); font-weight: 600; }
676
676
  .doc-foot-actions { display: flex; gap: 8px; justify-content: flex-end; }
677
677
  .plan-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
678
678
  .tag.plan-review { color: var(--accent); font-weight: 600; }
679
+ .tag.acc-review { color: var(--accent); font-weight: 600; }
680
+ .tag.acc-agreed { color: var(--green); }
681
+ .tag.acc-agreed.acc-bad { color: var(--red); font-weight: 600; }
682
+ .accept-dialog { width: min(620px, calc(100vw - 32px)); }
683
+ .acc-edit, .acc-list, .acc-need { margin: 8px 0; padding-left: 22px; }
684
+ .acc-need { font-size: 13px; }
685
+ .acc-edit li { margin: 6px 0; }
686
+ .acc-edit li::marker, .acc-list li::marker { color: var(--muted); }
687
+ .acc-edit textarea { width: calc(100% - 34px); vertical-align: top; font: inherit; font-size: 14px; padding: 6px 8px; resize: vertical; }
688
+ .acc-edit [data-acc-remove] { font-size: 18px; padding: 4px 8px; vertical-align: top; }
689
+ .acc-list li { margin: 8px 0; font-size: 13px; overflow-wrap: anywhere; }
690
+ .acc-chip.acc-met { border-color: var(--green); color: var(--green); }
691
+ .acc-chip.acc-not_met { border-color: var(--red); color: var(--red); font-weight: 600; }
692
+ .acc-chip.acc-unverified { border-color: var(--yellow); color: var(--yellow); }
693
+ .acc-evidence { margin-top: 2px; }
694
+ @media (max-width: 800px) { .acc-edit textarea { font-size: 16px; } }
679
695
  .tag.plan-approved { color: #2f9e55; }
680
696
  .tag.plan-changes { color: #c08a1e; }
681
697
  .need-kind.plan { background: var(--accent); color: #fff; }
@@ -1887,3 +1903,50 @@ table.eval-items tr.eval-na td { color: var(--muted); }
1887
1903
  .screen-tap { position: fixed; width: 28px; height: 28px; margin: -14px 0 0 -14px; border: 2px solid #4c8dff; border-radius: 50%; pointer-events: none; z-index: 5; animation: screen-tap 0.45s ease-out forwards; }
1888
1904
  @keyframes screen-tap { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
1889
1905
  @media (max-width: 800px) { .needs.inbox.one .need-actions button { padding: 10px 14px; font-size: 15px; } }
1906
+
1907
+ /* Claims check (claims.js): statements of fact and what backs them. */
1908
+ .cl-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
1909
+ .cl-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); font-size: 12px; white-space: nowrap; }
1910
+ .cl-chip.cl-contradicted { border-color: var(--red); color: var(--red); font-weight: 600; }
1911
+ .cl-chip.cl-not_backed { border-color: var(--yellow); color: var(--yellow); font-weight: 600; }
1912
+ .cl-chip.cl-backed { border-color: var(--green); color: var(--green); }
1913
+ .cl-group { margin: 8px 0; }
1914
+ .cl-group summary { cursor: pointer; }
1915
+ .cl-list { list-style: none; margin: 6px 0 0; padding: 0; }
1916
+ .cl-claim { border-left: 3px solid var(--border); padding: 4px 0 4px 10px; margin: 6px 0; overflow-wrap: anywhere; }
1917
+ .cl-claim.cl-contradicted { border-left-color: var(--red); }
1918
+ .cl-claim.cl-not_backed { border-left-color: var(--yellow); }
1919
+ .cl-claim.cl-backed { border-left-color: var(--green); }
1920
+ .cl-quote { margin-top: 2px; }
1921
+ .cl-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
1922
+ .cl-note.cl-doubt { border: 1px solid var(--yellow); border-radius: 8px; padding: 6px 10px; }
1923
+
1924
+ /* The agent's own confidence in what it built (Results). */
1925
+ .own-conf { margin: 6px 0; font-size: 13px; overflow-wrap: anywhere; }
1926
+ .own-conf .tag { font-weight: 600; margin-right: 4px; }
1927
+
1928
+ /* Without you (autonomy): the row in the brief card, the inbox card and the dialog. */
1929
+ .tag.auto-on { border-color: var(--accent, #4c8dff); color: var(--accent, #4c8dff); }
1930
+ .auto-answer { margin: 4px 0; font-size: 14px; overflow-wrap: anywhere; }
1931
+ .auto-hold { margin: 8px 0; font-size: 13px; }
1932
+ .auto-log { list-style: none; margin: 8px 0; padding: 0; }
1933
+ .auto-log li { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
1934
+ .auto-dialog select, #settings-autonomy select, #settings-autonomy input, #settings-ground textarea, #new-autonomy { width: 100%; font: inherit; font-size: 16px; }
1935
+ #settings-ground textarea { padding: 6px 8px; resize: vertical; }
1936
+
1937
+ /* Drop to start (dropzone.js): the box in the New agents form, and the frame over the page while dragging. */
1938
+ .drop-zone { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; padding: 12px 14px; border: 2px dashed var(--border); border-radius: 12px; background: var(--panel-2); transition: border-color 0.12s, background 0.12s; }
1939
+ .drop-zone .drop-icon { font-size: 26px; line-height: 1; color: var(--muted); }
1940
+ .drop-zone .drop-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
1941
+ .drop-zone .hint { font-size: 12px; }
1942
+ .drop-zone .link { font-size: 12px; padding: 0; color: var(--accent); text-decoration: underline; }
1943
+ .drop-zone.over, form.dropping .drop-zone { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); }
1944
+ .drop-zone.over .drop-icon, form.dropping .drop-zone .drop-icon { color: var(--accent); }
1945
+ .drop-zone.filled { border-style: solid; border-color: var(--green); }
1946
+ .drop-added { font-size: 12px; color: var(--green); overflow-wrap: anywhere; }
1947
+ .drop-added:empty { display: none; }
1948
+ .drop-overlay { position: fixed; inset: 0; z-index: 1000; pointer-events: none; display: flex; padding: 16px; background: color-mix(in srgb, var(--accent) 14%, transparent); }
1949
+ .drop-overlay[hidden] { display: none; }
1950
+ .drop-frame { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 3px dashed var(--accent); border-radius: 18px; background: color-mix(in srgb, var(--bg, #fff) 82%, transparent); text-align: center; padding: 20px; font-size: 15px; }
1951
+ .drop-frame b { font-size: 22px; }
1952
+ .drop-frame .drop-icon { font-size: 44px; color: var(--accent); }
@@ -0,0 +1,123 @@
1
+ // Acceptance: what "done" means for an agent's task, agreed with the person before the work is
2
+ // judged against it. The agent drafts a few checkable points in SPEC.md (it has read the code);
3
+ // the person edits them and agrees; from then on the points are kept by the app, not by the
4
+ // agent, and the review scorecard reports each one as met, not met or not verified.
5
+ //
6
+ // Everything here is pure: reading the points out of a spec, cleaning what the person sends,
7
+ // the messages to the agent, and matching the scorecard's answers back to the agreed points.
8
+
9
+ export const MAX_POINTS = 12;
10
+ export const MAX_POINT_CHARS = 300;
11
+
12
+ const tidy = (s) => String(s ?? '').replace(/\s+/g, ' ').trim();
13
+ const norm = (s) => tidy(s).toLowerCase().replace(/[^\p{L}\p{N} ]+/gu, '').replace(/\s+/g, ' ').trim();
14
+
15
+ /** The points under "## Acceptance criteria" in a spec: one per list item, wrapped lines joined. */
16
+ export function parseCriteria(spec) {
17
+ const block = /^##\s*Acceptance criteria\s*$([\s\S]*?)(?=^##\s|(?![\s\S]))/im.exec(String(spec ?? ''))?.[1] ?? '';
18
+ const out = [];
19
+ for (const line of block.split('\n')) {
20
+ const item = /^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX~!]\]\s*)?(.*)$/.exec(line);
21
+ if (item) out.push(item[1]);
22
+ // A wrapped line of the item above (indented), not a new paragraph.
23
+ else if (out.length && /^\s+\S/.test(line)) out[out.length - 1] += ` ${line}`;
24
+ }
25
+ return out.map((t) => tidy(t).slice(0, MAX_POINT_CHARS)).filter((t) => /\p{L}|\p{N}/u.test(t)).slice(0, MAX_POINTS);
26
+ }
27
+
28
+ /**
29
+ * The points the person sent (texts, or { text }), cleaned: no empty ones, no repeats, numbered
30
+ * A1.. in their order. `draft` is what the agent wrote: a point with its wording is "agent", any
31
+ * other is "you". Throws with a status when there is nothing to agree on, or too much.
32
+ */
33
+ export function cleanPoints(list, draft = []) {
34
+ if (!Array.isArray(list)) throw Object.assign(new Error('points must be a list'), { status: 400 });
35
+ const drafted = new Set(draft.map(norm));
36
+ const seen = new Set();
37
+ const out = [];
38
+ for (const p of list) {
39
+ const text = tidy(typeof p === 'string' ? p : p?.text);
40
+ if (!text || seen.has(norm(text))) continue;
41
+ if (text.length > MAX_POINT_CHARS) throw Object.assign(new Error(`A point is at most ${MAX_POINT_CHARS} characters; split it`), { status: 400 });
42
+ seen.add(norm(text));
43
+ out.push({ id: `A${out.length + 1}`, text, from: drafted.has(norm(text)) ? 'agent' : 'you' });
44
+ }
45
+ if (!out.length) throw Object.assign(new Error('Give at least one point that says what done means'), { status: 400 });
46
+ if (out.length > MAX_POINTS) throw Object.assign(new Error(`At most ${MAX_POINTS} points: keep the ones you would check`), { status: 400 });
47
+ return out;
48
+ }
49
+
50
+ export const pointsBlock = (points) => points.map((p) => `${p.id}: ${p.text}`).join('\n');
51
+
52
+ /** The agent's instructions when the person agrees on the points before anything is changed. */
53
+ export const acceptancePrompt = (specFile, { planReview = false } = {}) =>
54
+ 'The user agrees with you on what "done" means before you change anything. First investigate as much as you need ' +
55
+ `(reading code, docs and running read-only commands is fine), then write ${specFile} with three to six points under ` +
56
+ '"## Acceptance criteria": each one a single sentence a person can check without reading the code (a behavior they can see, ' +
57
+ 'a command and its result, a test that passes), specific to this task, and none that only restates the request. ' +
58
+ 'Then stop and wait. Until a message starting with "Acceptance agreed" or "Acceptance review skipped" arrives, do not edit, ' +
59
+ 'create or delete files in the repository, commit, or run commands that change anything' +
60
+ (planReview ? ', and do not write your implementation plan yet: the plan comes after the points are agreed' : '') +
61
+ '. The agreed points may differ from yours: they are the ones the work is checked against.';
62
+
63
+ /** For a session started after the points were agreed (a restart, a resume). */
64
+ export const acceptanceAgreedPrompt = (points) =>
65
+ `The user agreed on what "done" means for this task. The work is checked against these points, as written:\n${pointsBlock(points)}\n` +
66
+ 'Keep them under "## Acceptance criteria" in your spec as they are; you cannot change them. If one cannot be met, say so in the brief and why.';
67
+
68
+ /**
69
+ * What the agent is told when the points are agreed. `waiting`: it was stopped until now.
70
+ * `planNext`: its plan is reviewed too, and comes next. `changed`: they had been agreed before.
71
+ */
72
+ export function agreedMessage(points, { waiting = false, planNext = false, changed = false } = {}) {
73
+ const head = waiting || !changed ? 'Acceptance agreed.' : 'Acceptance agreed again: the user changed the points.';
74
+ const next = waiting
75
+ ? planNext
76
+ ? 'Now write your implementation plan and wait for its approval, as instructed.'
77
+ : 'Go ahead with the work.'
78
+ : 'Check the work you have done against them and fix what does not meet them; say in the brief what you changed.';
79
+ return `${head} The work is done when all of these are true, and it is checked against them as written:\n${pointsBlock(points)}\n` +
80
+ `Replace the points under "## Acceptance criteria" in your spec with these, word for word. ${next}`;
81
+ }
82
+
83
+ export const SKIPPED_MESSAGE = 'Acceptance review skipped. Go ahead with the work, against the criteria in your own spec.';
84
+
85
+ /**
86
+ * The agreed points with what the scorecard found for each. `criteria` is the scorecard's list
87
+ * ({ id, criterion, status, evidence }); a point it has no answer for is "unchecked".
88
+ */
89
+ export function results(points, criteria = null) {
90
+ const byId = new Map((criteria ?? []).filter((c) => c.id).map((c) => [String(c.id).toUpperCase(), c]));
91
+ const byText = new Map((criteria ?? []).map((c) => [norm(c.criterion), c]));
92
+ return points.map((p) => {
93
+ const c = byId.get(p.id) ?? byText.get(norm(p.text));
94
+ return { ...p, status: c ? c.status : 'unchecked', evidence: c?.evidence ?? '' };
95
+ });
96
+ }
97
+
98
+ export const STATUS_LABEL = { met: 'Met', not_met: 'Not met', unverified: 'Not verified', unchecked: 'Not checked yet' };
99
+
100
+ export function counts(res) {
101
+ const n = (s) => res.filter((r) => r.status === s).length;
102
+ return { total: res.length, met: n('met'), notMet: n('not_met'), unverified: n('unverified'), unchecked: n('unchecked') };
103
+ }
104
+
105
+ /** "3 of 5 met, 1 not met, 1 not verified", or what is left to do before there is a result. */
106
+ export function countsLine(c) {
107
+ if (!c.total) return 'no points';
108
+ if (c.unchecked === c.total) return `${c.total} point${c.total === 1 ? '' : 's'}, not checked yet`;
109
+ return [`${c.met} of ${c.total} met`, c.notMet ? `${c.notMet} not met` : '', c.unverified ? `${c.unverified} not verified` : '', c.unchecked ? `${c.unchecked} not checked yet` : ''].filter(Boolean).join(', ');
110
+ }
111
+
112
+ const MARK = { met: '✅', not_met: '❌', unverified: '❔', unchecked: '⏳' };
113
+
114
+ /** The acceptance of an agent as Markdown (the CLI prints it). `v` is what Manager.acceptanceOf returns. */
115
+ export function acceptanceMarkdown(v, name) {
116
+ const out = [`# What done means: ${name}`, ''];
117
+ if (v.status === 'none') return [...out, v.draft.length ? 'Not agreed. The agent wrote these in its spec:' : 'Not agreed, and the agent wrote no acceptance criteria.', '', ...v.draft.map((t, i) => `${i + 1}. ${t}`), ''].join('\n');
118
+ if (v.status === 'writing') return [...out, 'The agent is writing its points; it waits for you before changing anything.', ''].join('\n');
119
+ if (v.status === 'review') return [...out, 'Waiting for you. The agent wrote these and changes nothing until you agree:', '', ...v.draft.map((t, i) => `${i + 1}. ${t}`), ''].join('\n');
120
+ out.push(`Agreed ${v.agreedAt}: ${countsLine(v.counts)}${v.stale ? ' (the work changed or the points changed since the last check)' : ''}`, '');
121
+ for (const r of v.results) out.push(`- ${MARK[r.status]} **${r.id}** ${r.text}${r.from === 'you' ? ' _(yours)_' : ''}${r.evidence ? `\n ${STATUS_LABEL[r.status]}: ${r.evidence}` : ''}`);
122
+ return [...out, ''].join('\n');
123
+ }