@aidenhq/sdk 0.5.8 → 0.5.10

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.
Files changed (74) hide show
  1. package/dist/assets/page-kit.js +13 -33
  2. package/dist/src/attribution.d.ts +0 -4
  3. package/dist/src/attribution.js +1 -9
  4. package/dist/src/box-bundle.d.ts +1 -5
  5. package/dist/src/box-bundle.js +2 -9
  6. package/dist/src/caller.d.ts +0 -2
  7. package/dist/src/caller.js +2 -6
  8. package/dist/src/card-words.js +0 -1
  9. package/dist/src/checks.d.ts +9 -52
  10. package/dist/src/checks.js +10 -53
  11. package/dist/src/churn.d.ts +2 -12
  12. package/dist/src/churn.js +3 -17
  13. package/dist/src/closed-event.d.ts +0 -1
  14. package/dist/src/closed-event.js +1 -5
  15. package/dist/src/executor.d.ts +4 -7
  16. package/dist/src/executor.js +2 -8
  17. package/dist/src/face-kit.js +1 -4
  18. package/dist/src/fence.d.ts +2 -10
  19. package/dist/src/fence.js +4 -15
  20. package/dist/src/for-others.d.ts +0 -1
  21. package/dist/src/for-others.js +1 -5
  22. package/dist/src/instance-details.d.ts +1 -7
  23. package/dist/src/instance-details.js +4 -16
  24. package/dist/src/instance-paths.d.ts +1 -6
  25. package/dist/src/instance-paths.js +2 -11
  26. package/dist/src/judge.d.ts +3 -21
  27. package/dist/src/judge.js +5 -25
  28. package/dist/src/kernel-client.d.ts +0 -1
  29. package/dist/src/kernel-client.js +3 -12
  30. package/dist/src/kit.d.ts +0 -3
  31. package/dist/src/kit.js +0 -3
  32. package/dist/src/maintained-repos.d.ts +5 -22
  33. package/dist/src/maintained-repos.js +7 -23
  34. package/dist/src/number-setting.d.ts +0 -2
  35. package/dist/src/number-setting.js +1 -6
  36. package/dist/src/owner-day.d.ts +0 -4
  37. package/dist/src/owner-day.js +1 -8
  38. package/dist/src/paperclip.d.ts +0 -3
  39. package/dist/src/paperclip.js +1 -7
  40. package/dist/src/pass-rule.d.ts +0 -2
  41. package/dist/src/pass-rule.js +2 -10
  42. package/dist/src/provider.d.ts +1 -7
  43. package/dist/src/provider.js +2 -8
  44. package/dist/src/quality.d.ts +0 -10
  45. package/dist/src/quality.js +2 -12
  46. package/dist/src/reason-codes.d.ts +2 -2
  47. package/dist/src/reason-codes.js +0 -2
  48. package/dist/src/repeat.d.ts +1 -6
  49. package/dist/src/repeat.js +2 -10
  50. package/dist/src/responses.d.ts +1 -8
  51. package/dist/src/responses.js +3 -13
  52. package/dist/src/selector.d.ts +1 -11
  53. package/dist/src/selector.js +1 -6
  54. package/dist/src/source-store.d.ts +4 -26
  55. package/dist/src/source-store.js +5 -30
  56. package/dist/src/task-state-types.d.ts +3 -18
  57. package/dist/src/task-state-types.js +1 -3
  58. package/dist/src/teammate-name.d.ts +0 -1
  59. package/dist/src/teammate-name.js +2 -6
  60. package/dist/src/tiers.d.ts +1 -11
  61. package/dist/src/tiers.js +4 -14
  62. package/dist/src/tools-client.d.ts +3 -13
  63. package/dist/src/tools-client.js +7 -28
  64. package/dist/src/types.d.ts +0 -2
  65. package/dist/src/types.js +1 -2
  66. package/dist/src/url-setting.d.ts +0 -1
  67. package/dist/src/url-setting.js +1 -4
  68. package/dist/src/vendor/needs.d.ts +1 -7
  69. package/dist/src/vendor/needs.js +3 -12
  70. package/dist/src/vendor/oauth.d.ts +6 -35
  71. package/dist/src/vendor/oauth.js +12 -37
  72. package/dist/src/vendor/proxy.d.ts +5 -27
  73. package/dist/src/vendor/proxy.js +42 -114
  74. package/package.json +1 -1
@@ -4,14 +4,12 @@ const waiting = new Map();
4
4
  const send = (method, params) => new Promise((ok, ko) => { const id = next++; waiting.set(id, { ok, ko }); parent.postMessage({ jsonrpc: "2.0", id, method, params }, "*"); });
5
5
  const notify = (method, params) => parent.postMessage({ jsonrpc: "2.0", method, params }, "*");
6
6
  const theme = (ctx) => { for (const [k, v] of Object.entries(ctx?.styles?.variables ?? {})) if (v) document.documentElement.style.setProperty(k, v); if (ctx?.theme) document.documentElement.style.colorScheme = ctx.theme; };
7
- // The part of this frame the host shows (its host context's frameViewport, { top, height, width } in this frame's coordinates): the
8
- // board shows the frame inline in its own scrolling page, so the frame's innerHeight runs far below the fold. Kept from the last context.
7
+ // The part of this frame the host shows (host context frameViewport, in this frame's coordinates): the board shows the frame inline in its own scrolling page, so innerHeight runs far below the fold.
9
8
  let frameViewport = null, mpOpen = null;
10
9
  const hostContext = (ctx) => { if (ctx?.frameViewport) frameViewport = ctx.frameViewport; theme(ctx); };
11
10
  addEventListener("message", (e) => {
12
11
  if (e.source !== parent) return;
13
- // The host's theme or the visible part of the frame changed (a scroll, a resize): restyle, and keep an open picker with its trigger
14
- // (re-place it while the trigger is still in sight, close it once the board's scroll has carried the trigger out of sight).
12
+ // Host theme or visible slice changed: restyle; re-place an open picker while its trigger is in sight, close it once scrolled out.
15
13
  if (e.data?.method === "ui/notifications/host-context-changed") { hostContext(e.data.params); mpOpen?.keep?.(); return; }
16
14
  const w = waiting.get(e.data?.id);
17
15
  if (!w) return;
@@ -22,7 +20,6 @@ addEventListener("message", (e) => {
22
20
  const unfence = (v) => typeof v === "string" ? (v.match(/^<untrusted-data[^>]*>([\s\S]*)<\/untrusted-data>$/)?.[1] ?? v).replace(/&lt;(\/?untrusted-data)/gi, "<$1") : Array.isArray(v) ? v.map(unfence) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, unfence(x)])) : v;
23
21
  const tool = async (name, args) => { const r = await send("tools/call", { name, arguments: args }); if (r?.isError) throw new Error(r.content?.[0]?.text ?? "failed"); return unfence(r.structuredContent ?? {}); };
24
22
  new ResizeObserver(() => { const r = document.body.getBoundingClientRect(); notify("ui/notifications/size-changed", { width: Math.ceil(r.width), height: Math.ceil(r.height) }); }).observe(document.body);
25
- // A message to the owner's chat with the host (ui/message): the host opens its assistant with the text ready to send.
26
23
  const ask = (text) => send("ui/message", { role: "user", content: [{ type: "text", text }] });
27
24
  const $ = (id) => document.getElementById(id);
28
25
  const h = (tag, props, ...kids) => { const el = Object.assign(document.createElement(tag), props); el.append(...kids.filter((k) => k !== null)); return el; };
@@ -33,7 +30,7 @@ const inOrder = (fn) => (queue = queue.then(fn, fn));
33
30
  const proposed = (r) => say(`Changes are proposed; Save in the bar above applies them. ${(r.changes ?? []).join("; ")}.`);
34
31
  const setSwitch = (b, on) => b.setAttribute("aria-checked", String(!!on));
35
32
  const toggle = (on, label, fn) => { const b = h("button", { className: "sw", role: "switch", ariaLabel: label }); setSwitch(b, on); b.addEventListener("click", fn); return b; };
36
- // A link: the frame can't navigate, so a click asks the host (ui/open-link) to open it in a new tab. Only http(s) addresses are links; any other is plain text.
33
+ // A link: the frame can't navigate, so a click asks the host (ui/open-link); only http(s) addresses are links.
37
34
  const link = (url, text) => {
38
35
  if (!/^https?:\/\//i.test(String(url ?? ""))) return h("span", { textContent: text ?? String(url ?? "") });
39
36
  const a = h("a", { href: url, textContent: text ?? url, className: "lnk", rel: "noopener noreferrer" });
@@ -41,7 +38,7 @@ const link = (url, text) => {
41
38
  a.addEventListener("click", open); a.addEventListener("auxclick", open);
42
39
  return a;
43
40
  };
44
- // A small safe markdown: headings, lists, fenced code, bold, italics, `code` and [text](http…) links. Built from text nodes only, so nothing in the source is ever HTML; a table or quote is shown as preformatted text.
41
+ // A small safe markdown built from text nodes only (nothing in the source is ever HTML); a table or quote shows as preformatted text.
45
42
  const mdInline = (text) => {
46
43
  const out = [], re = /`([^`]+)`|\*\*([^*]+)\*\*|\*([^*\s][^*]*)\*|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g;
47
44
  let i = 0, m;
@@ -71,9 +68,7 @@ const md = (src) => {
71
68
  flush();
72
69
  return root;
73
70
  };
74
- // The help "?" next to a label: help(label, text, { options: { value: meaning }, current, note }) returns the label with its button. One shared
75
- // tooltip (role=tooltip) opens on hover, on keyboard focus and on tap (a tap pins it; tap again, Escape or a tap elsewhere closes it), and is
76
- // placed by the button inside the frame, so no card clips it. Call closeHelp() when a render replaces the buttons.
71
+ // Help "?" beside a label: help(label, text, { options: { value: meaning }, current, note }). One shared tooltip (role=tooltip), placed inside the frame so no card clips it; call closeHelp() when a render replaces the buttons.
77
72
  const tipEl = h("div", { id: "tip", className: "tip", role: "tooltip", hidden: true });
78
73
  document.body.append(tipEl);
79
74
  let tipFor = null, tipPinned = false;
@@ -94,7 +89,6 @@ addEventListener("resize", closeHelp);
94
89
  let helpN = 0;
95
90
  const help = (label, text, more = {}) => {
96
91
  const c = { text, ...more }, btn = h("button", { type: "button", className: "q", textContent: "?", ariaLabel: `About ${label}` });
97
- // The button's own description (hidden text, read by a screen reader); the shared tooltip is its sighted twin.
98
92
  const did = `hd${++helpN}`, desc = [text, ...Object.entries(more.options ?? {}).map(([v, m]) => `${v}: ${m}`), more.note].filter(Boolean).join(" ");
99
93
  const dsc = h("span", { id: did, hidden: true, textContent: desc });
100
94
  btn.setAttribute("aria-describedby", did); btn.setAttribute("aria-expanded", "false");
@@ -105,12 +99,10 @@ const help = (label, text, more = {}) => {
105
99
  btn.addEventListener("click", () => { if (tipFor?.btn === btn && tipPinned) closeHelp(); else { openHelp(btn, c); tipPinned = true; } });
106
100
  return h("span", { className: "hd" }, more.bare ? null : label, btn, dsc);
107
101
  };
108
- // "3 hours ago" for an ISO time, or "" when there is none.
109
102
  const ago = (iso) => { const s = (Date.now() - Date.parse(iso)) / 1000; if (!(s >= 0)) return ""; const [n, u] = s < 90 ? [0, ""] : s < 5400 ? [Math.round(s / 60), "minute"] : s < 172800 ? [Math.round(s / 3600), "hour"] : [Math.round(s / 86400), "day"]; return u ? `${n} ${u}${n === 1 ? "" : "s"} ago` : "just now"; };
110
- // The Settings drawers: one field = a help label, an editor and a meta line. editor({ kind: select | checks | list | num | text, label, value, values, titles, f, set })
111
- // builds the control (list: one item per line; num: blank = null, else a whole number); set(value, live) runs as you type (live: no redraw) and on the change, and
112
- // keepFocus(render) puts the focus back on the control with the same data-f after a render replaced it.
113
- // soon(fn): run fn after the current event, and after a pressed pointer is released (a redraw between a press and its click would lose the click); a newer soon(fn) of the same fn replaces a pending one.
103
+ // Settings drawers: editor({ kind: select | checks | list | num | text, label, value, values, titles, f, set }); list: one item per line; num: blank = null; set(value, live) runs as you type (live: no redraw) and on change.
104
+ // keepFocus(render) restores focus to the control with the same data-f after a render.
105
+ // soon(fn): run fn after the current event and after a pressed pointer is released (a redraw between press and click loses the click); a newer soon of the same fn replaces a pending one.
114
106
  let pointerDown = false, queued = null;
115
107
  for (const [e, v] of [["pointerdown", true], ["pointerup", false], ["pointercancel", false]]) addEventListener(e, () => { pointerDown = v; }, true);
116
108
  const soon = (fn) => { queued = fn; const go = () => setTimeout(() => { if (queued === fn) { queued = null; fn(); } }, 0); if (pointerDown) addEventListener("pointerup", go, { once: true }); else go(); };
@@ -122,7 +114,7 @@ const editor = (k) => {
122
114
  if (k.kind === "seg") return h("div", { className: "seg", role: "radiogroup", ariaLabel: k.label }, ...k.values.map((v, i) => { const b = h("button", { type: "button", role: "radio", textContent: v, title: k.titles?.[v] }); b.setAttribute("aria-checked", String(v === k.value)); b.tabIndex = v === k.value ? 0 : -1; b.dataset.v = v; b.dataset.f = `${k.f}:${v}`; b.addEventListener("click", () => { if (v !== k.value) k.set(v); });
123
115
  b.addEventListener("keydown", (e) => { const d = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }[e.key]; if (d) { e.preventDefault(); const n = (i + d + k.values.length) % k.values.length; e.currentTarget.parentNode.children[n].focus(); k.set(k.values[n]); } }); return b; }));
124
116
  if (k.kind === "chips") {
125
- // One entry per chip; Enter (or leaving the box) adds what is typed, a multi-line paste adds one chip per line, and in a list that is not ordered (no k.dups) a comma-separated one too (a comma inside {braces} stays). k.dups allows a repeated entry (an ordered list).
117
+ // One entry per chip; Enter (or leaving the box) adds what is typed; a multi-line paste adds one chip per line, and in an unordered list (no k.dups) a comma-separated one too (a comma inside {braces} stays). k.dups allows repeats (an ordered list).
126
118
  let items = k.value ?? [];
127
119
  const inp = h("input", { type: "text", ariaLabel: k.label, placeholder: k.placeholder ?? "Add one, press Enter", autocomplete: "off", spellcheck: false });
128
120
  inp.dataset.f = k.f;
@@ -153,12 +145,9 @@ const editor = (k) => {
153
145
  el.addEventListener("change", () => { clearTimeout(typing); const v = read(false); if (v !== undefined) k.set(v); });
154
146
  return el;
155
147
  };
156
- // One labelled field of a drawer: help label, editor, then a meta line (default, overridden mark, reset).
157
148
  const fld = (label, text, more, ed, ...meta) => h("div", { className: "fld" }, h("div", { className: "fl" }, help(label, text, more)), ed, h("div", { className: "meta" }, ...meta.filter((m) => m)));
158
149
  const linkBtn = (text, fn) => { const b = h("button", { type: "button", className: "link", textContent: text }); b.addEventListener("click", fn); return b; };
159
- // The model picker, the twin of the board's ModelPicker.tsx: a trigger showing the model's plain name over its id, and a searchable list under it
160
- // (a popover, so a card or dialog can't clip it): Recommended first, then by provider, a "Suggested" tag, a check on the current row, a count footer,
161
- // arrows + Enter + Escape. modelPicker({ label, value, models, onChange, recommended, suggested, none, custom, name }) returns the element.
150
+ // Model picker, twin of the board's ModelPicker.tsx: searchable popover (a card or dialog can't clip it), Recommended first then by provider. modelPicker({ label, value, models, onChange, recommended, suggested, none, custom, usable, name }) returns the element.
162
151
  // models ids, or { id, name?, provider?, meta? } (a name and provider are made from the id when absent)
163
152
  // recommended ids listed first (default: all of models); the rest are grouped by provider
164
153
  // suggested the id that carries the "Suggested" tag
@@ -167,11 +156,9 @@ const linkBtn = (text, fn) => { const b = h("button", { type: "button", classNam
167
156
  // usable(id) whether the active provider can run that id: the list and the typed "Use" row offer only ids it can run, so a click
168
157
  // and Enter both pick a model the page will accept
169
158
  // name the name of the hidden input that carries the chosen id (for a page that submits a form)
170
- // onChange(id) runs on a pick.
171
159
  const MP_WORDS = { gpt: "GPT", glm: "GLM", deepseek: "DeepSeek", openai: "OpenAI", qwen: "Qwen", llm: "LLM", ai: "AI" };
172
160
  const MP_VENDORS = { openai: "OpenAI", deepseek: "DeepSeek", "x-ai": "xAI", "meta-llama": "Meta", mistralai: "Mistral", moonshotai: "Moonshot AI", "z-ai": "Z.ai" };
173
161
  const mpShort = (id) => String(id ?? "").replace(/^~/, "");
174
- // "~openai/gpt-6.2-sol-latest" -> "GPT 6.2 Sol"; "claude-opus-4-7" -> "Claude Opus 4.7".
175
162
  const mpName = (id) => mpShort(id).split("/").pop().split(":")[0].replace(/-latest$/, "").split("-").reduce((out, w) => {
176
163
  if (/^\d{1,2}$/.test(w) && /^\d+(\.\d+)*$/.test(out[out.length - 1] ?? "")) out[out.length - 1] += `.${w}`; else out.push(w);
177
164
  return out;
@@ -249,10 +236,7 @@ const modelPicker = (k) => {
249
236
  foot.textContent = `${n} model${n === 1 ? "" : "s"}`;
250
237
  mark(true);
251
238
  };
252
- // The frame's visible part, not its whole document: the board shows the frame inline inside its own scrolling page, so the bottom
253
- // of `innerHeight` may be far below what the owner can see. The host sends that slice (frameViewport, this frame's coordinates);
254
- // without it (another host, or before the first context) this frame is all shown. A phone keyboard shrinks the visual viewport
255
- // without changing innerHeight, so the slice also ends at it.
239
+ // The frame's visible slice (host frameViewport), not its document: the board shows the frame inline, so innerHeight may be far below the fold; without it the whole frame is shown. A phone keyboard shrinks the visual viewport without changing innerHeight, so the slice also ends there.
256
240
  const viewport = () => {
257
241
  const vv = visualViewport, top = Math.max(frameViewport?.top ?? 0, vv?.offsetTop ?? 0), vvBottom = (vv?.offsetTop ?? 0) + (vv?.height ?? innerHeight);
258
242
  const hostBottom = frameViewport ? frameViewport.top + frameViewport.height : innerHeight;
@@ -260,14 +244,11 @@ const modelPicker = (k) => {
260
244
  };
261
245
  const place = () => {
262
246
  const v = viewport(), b = trigger.getBoundingClientRect(), vw = v.width, narrow = vw <= 560, w = narrow ? vw - 16 : Math.min(560, vw - 16);
263
- // Room under the trigger down to what is visible, and above it up to the top of it (a trigger a keyboard covers counts as at the
264
- // slice's bottom edge, so the panel sits in the visible part); open where the panel fits (300px), else on
265
- // the larger side, never past the visible edge.
247
+ // Room under the trigger to the visible edge and above it to the top (a keyboard-covered trigger counts as at the slice's bottom); open where the panel fits (300px), else on the larger side.
266
248
  const below = v.bottom - b.bottom - 8, edge = Math.min(b.top, v.bottom), above = edge - v.top - 8, down = below >= 300 || below >= above, room = Math.max(160, down ? below : above);
267
249
  Object.assign(panel.style, { width: `${w}px`, left: `${narrow ? 8 : Math.max(8, Math.min(b.left, vw - w - 8))}px`, maxHeight: `${Math.min(room, 420)}px`, top: down ? `${b.bottom + 4}px` : "auto", bottom: down ? "auto" : `${innerHeight - edge + 4}px` });
268
250
  };
269
- // After the host's page moved (its scroll, a resize), an open picker stays only while its trigger is in the visible slice: with the
270
- // trigger scrolled out, a panel clamped to the edge would sit by nothing and a later Enter would pick a model the owner can't see.
251
+ // After the host page moved, an open picker stays only while its trigger is visible: a clamped panel beside nothing would let Enter pick a model the owner can't see.
271
252
  const keep = () => {
272
253
  if (!isOpen()) return;
273
254
  const v = viewport(), b = trigger.getBoundingClientRect();
@@ -283,7 +264,6 @@ const modelPicker = (k) => {
283
264
  mpOpen?.close(false); mpOpen = { close, keep, has: (n) => panel.contains(n) || trigger.contains(n) }; query = ""; input.value = ""; build(); place();
284
265
  panel.showPopover(); trigger.setAttribute("aria-expanded", "true"); input.focus(); mark(true);
285
266
  };
286
- // A pick redraws the page, which may replace this trigger: the focus goes to its twin (same data-f).
287
267
  const refocus = () => { if (!trigger.isConnected && document.activeElement === document.body) document.querySelector(`.mp-trigger[data-f="${CSS.escape(k.label)}"]`)?.focus(); };
288
268
  const pick = (id) => { const same = id === value; value = id; paint(); close(true); if (same) return; k.onChange?.(id); refocus(); setTimeout(refocus, 0); };
289
269
  trigger.addEventListener("click", () => (isOpen() ? close(true) : open()));
@@ -1,6 +1,4 @@
1
- /** The fixed address in every trailer. */
2
1
  export declare const TRAILER_EMAIL = "noreply@aidenhq.ai";
3
- /** The fixed link in every footer. */
4
2
  export declare const FOOTER_LINK = "https://aidenhq.ai";
5
3
  /** `Co-authored-by: AidenHQ <agent> <noreply@aidenhq.ai>` */
6
4
  export declare const trailer: (agent: string) => string;
@@ -8,9 +6,7 @@ export declare const trailer: (agent: string) => string;
8
6
  export declare const footer: (agent: string) => string;
9
7
  /** A commit message ending with the agent's trailer (once: a message already carrying an AidenHQ trailer keeps it). */
10
8
  export declare const withTrailer: (message: string, agent: string) => string;
11
- /** A posted text ending with the agent's footer (once). */
12
9
  export declare const withFooter: (text: string, agent: string) => string;
13
- /** Whether a commit message carries an AidenHQ trailer (any agent). */
14
10
  export declare const hasTrailer: (message: string) => boolean;
15
11
  /** Whether a text ends with the exact footer line `footer()` writes, for any agent (a link to AidenHQ in anyone's words is not one). */
16
12
  export declare const hasFooter: (text: string) => boolean;
@@ -1,11 +1,5 @@
1
- // How AidenHQ signs what it writes on GitHub as the owner (spec 2026-11-20-github-owner-identity §4; owner, 2026-11-20): every
2
- // commit carries a trailer naming the agent, every posted text ends with a footer naming it and linking AidenHQ. Readers
3
- // (flow.ts author_kind) match only the fixed parts, never the names: the noreply address and the link.
4
- //
5
- // First-party modules hold byte-identical copies (scripts/sync-shared.ts: edit this one and run it).
6
- /** The fixed address in every trailer. */
1
+ // How AidenHQ signs what it writes on GitHub as the owner: every commit carries a trailer naming the agent, every posted text ends with a footer naming it and linking AidenHQ. Readers (flow.ts author_kind) match only the fixed parts: the noreply address and the link. First-party modules hold byte-identical copies (scripts/sync-shared.ts).
7
2
  export const TRAILER_EMAIL = "noreply@aidenhq.ai";
8
- /** The fixed link in every footer. */
9
3
  export const FOOTER_LINK = "https://aidenhq.ai";
10
4
  /** `Co-authored-by: AidenHQ <agent> <noreply@aidenhq.ai>` */
11
5
  export const trailer = (agent) => `Co-authored-by: AidenHQ ${agent} <${TRAILER_EMAIL}>`;
@@ -13,9 +7,7 @@ export const trailer = (agent) => `Co-authored-by: AidenHQ ${agent} <${TRAILER_E
13
7
  export const footer = (agent) => `🤖 Generated by ${agent} with [AidenHQ](${FOOTER_LINK})`;
14
8
  /** A commit message ending with the agent's trailer (once: a message already carrying an AidenHQ trailer keeps it). */
15
9
  export const withTrailer = (message, agent) => (hasTrailer(message) ? message : [message.trimEnd(), trailer(agent)].filter(Boolean).join("\n\n"));
16
- /** A posted text ending with the agent's footer (once). */
17
10
  export const withFooter = (text, agent) => (hasFooter(text) ? text : [text.trimEnd(), footer(agent)].filter(Boolean).join("\n\n"));
18
- /** Whether a commit message carries an AidenHQ trailer (any agent). */
19
11
  export const hasTrailer = (message) => new RegExp(`^Co-authored-by: AidenHQ .*<${TRAILER_EMAIL.replace(/\./g, "\\.")}>\\s*$`, "im").test(message);
20
12
  /** Whether a text ends with the exact footer line `footer()` writes, for any agent (a link to AidenHQ in anyone's words is not one). */
21
13
  export const hasFooter = (text) => new RegExp(`(^|\\n)🤖 Generated by [^\\n]+ with \\[AidenHQ\\]\\(${FOOTER_LINK.replace(/[.]/g, "\\.")}\\)\\s*$`).test(text);
@@ -1,9 +1,5 @@
1
- /** Where the in-box `aidenhq` leaves a branch's bundle, relative to the task's workspace. */
2
1
  export declare const bundlePath: (sha: string) => string;
3
2
  /** The one ref a bundle carries, named by the sha alone so no branch decides it; hosts fetch it into the branch they push. The in-box `aidenhq` (plain node) writes the same literal. */
4
3
  export declare const publishRef: (sha: string) => string;
5
- /**
6
- * Copies task `ident`'s bundle of `sha` to `<scratch>/branch.bundle` (made exclusively) and returns that path. `what` names it in
7
- * refusals (e.g. "acme/x `fix`"). 404: no bundle; 400: a symlink, not a regular file, or outside the task; 413: too large.
8
- */
4
+ /** Copies task `ident`'s bundle of `sha` to `<scratch>/branch.bundle` (made exclusively), returning its path. `what` names it in refusals. 404: no bundle; 400: symlink, not a regular file, or outside the task; 413: too large. */
9
5
  export declare function copyBoxBundle(tasksDir: string, scratch: string, ident: string, sha: string, what: string): string;
@@ -1,10 +1,6 @@
1
- // A job's branch as its box handed it over: a git bundle the in-box `aidenhq publish|review|apply` wrote at
2
- // <workspace>/.aidenhq/bundles/<sha>.bundle. Both code hosts read it the one way: that one file, opened without following a
3
- // symlink, resolved after opening to a regular file inside that task's folder, copied whole into the reader's own scratch.
4
- // Host git and host fs writes never run in a workspace a box can write; git then reads only the copy.
1
+ // A job's branch as its box handed it over: a git bundle the in-box `aidenhq publish|review|apply` wrote at <workspace>/.aidenhq/bundles/<sha>.bundle. Both code hosts read that one file only: opened without following a symlink, resolved after opening to a regular file inside the task's folder, copied whole to the reader's scratch. Host git and fs writes never run in a box-writable workspace; git reads only the copy.
5
2
  import { closeSync, constants, existsSync, fstatSync, openSync, readSync, readlinkSync, realpathSync, writeSync } from "node:fs";
6
3
  import { join, sep } from "node:path";
7
- /** Where the in-box `aidenhq` leaves a branch's bundle, relative to the task's workspace. */
8
4
  export const bundlePath = (sha) => `.aidenhq/bundles/${sha}.bundle`;
9
5
  /** The one ref a bundle carries, named by the sha alone so no branch decides it; hosts fetch it into the branch they push. The in-box `aidenhq` (plain node) writes the same literal. */
10
6
  export const publishRef = (sha) => `refs/aidenhq/publish/${sha}`;
@@ -12,10 +8,7 @@ const MAX_BUNDLE = 1 << 30;
12
8
  const IDENT = /^[A-Za-z][A-Za-z0-9]*-\d+$/;
13
9
  const SHA = /^[0-9a-f]{40}$/;
14
10
  const fail = (status, message) => Object.assign(new Error(message), { status });
15
- /**
16
- * Copies task `ident`'s bundle of `sha` to `<scratch>/branch.bundle` (made exclusively) and returns that path. `what` names it in
17
- * refusals (e.g. "acme/x `fix`"). 404: no bundle; 400: a symlink, not a regular file, or outside the task; 413: too large.
18
- */
11
+ /** Copies task `ident`'s bundle of `sha` to `<scratch>/branch.bundle` (made exclusively), returning its path. `what` names it in refusals. 404: no bundle; 400: symlink, not a regular file, or outside the task; 413: too large. */
19
12
  export function copyBoxBundle(tasksDir, scratch, ident, sha, what) {
20
13
  if (!IDENT.test(String(ident)))
21
14
  throw fail(400, `${ident} is not a task's workspace`);
@@ -1,6 +1,5 @@
1
1
  import { type JsonWebKey } from "node:crypto";
2
2
  import type { IncomingMessage } from "node:http";
3
- /** The calling agent, as the kernel resolved it. `agent` is its control-plane id, `key` its agent key, `call` the call id. */
4
3
  export interface Caller {
5
4
  agent: string;
6
5
  key: string;
@@ -21,7 +20,6 @@ export type JWKS = {
21
20
  export declare const CALLER_HEADER = "x-aidenhq-caller";
22
21
  /** The kernel's keys from `url` (its /v1/jwks), fetched once and again at most once a minute when a key id is unknown. */
23
22
  export declare function kernelJwks(url?: string): () => Promise<JWKS>;
24
- /** The caller of this request, for module `aud`. Throws on a missing, forged, expired or misaddressed assertion. */
25
23
  export declare function verifyCaller(req: IncomingMessage | {
26
24
  headers: Record<string, unknown>;
27
25
  }, jwks: JWKS | (() => Promise<JWKS>), aud: string, now?: number): Promise<Caller>;
@@ -1,8 +1,5 @@
1
- // Who a proxied tool call is for: the kernel's signed caller assertion (X-AidenHQ-Caller, an EdDSA JWT, 60 s), checked
2
- // against the kernel's keys (GET /v1/jwks). A module trusts nothing else about the caller: not a header, not an argument.
3
- //
4
- // Every module imports it from npm (@aidenhq/sdk/caller) at an exact pin: a change here needs a version bump in package.json,
5
- // which is what publishes it.
1
+ // Who a proxied tool call is for: the kernel's signed caller assertion (X-AidenHQ-Caller, EdDSA JWT, 60 s), checked against the kernel's keys (GET /v1/jwks). A module trusts nothing else about the caller: not a header, not an argument.
2
+ // Modules import it from npm (@aidenhq/sdk/caller) at an exact pin: a change here needs a package.json version bump, which publishes it.
6
3
  import { createPublicKey, verify } from "node:crypto";
7
4
  export const CALLER_HEADER = "x-aidenhq-caller";
8
5
  const b64 = (s) => Buffer.from(s, "base64url");
@@ -20,7 +17,6 @@ export function kernelJwks(url = `${process.env.AIDENHQ_KERNEL_URL ?? "http://10
20
17
  return cached;
21
18
  };
22
19
  }
23
- /** The caller of this request, for module `aud`. Throws on a missing, forged, expired or misaddressed assertion. */
24
20
  export async function verifyCaller(req, jwks, aud, now = Date.now()) {
25
21
  const jwt = String(req.headers[CALLER_HEADER] ?? "");
26
22
  const [h, p, s] = jwt.split(".");
@@ -20,7 +20,6 @@ export const REVIEW_WORDS = {
20
20
  files_not_shown: "The diff didn't match the code host's own count of the change.",
21
21
  instance_details: "It would post this server's hosts, addresses or paths to GitHub.",
22
22
  tool_call_unreadable: "The tool call's arguments couldn't be read or shown whole, so it went back to the agent.",
23
- code_review_owns: "Code approved it without an AI review: your setting leaves pushes and PRs on this repo to code review.",
24
23
  owner_veto: "You vetoed this action on this task: it is yours.",
25
24
  shadow: "Your autonomy is below full: the reviewer's verdict is only a note.",
26
25
  refused_by_code: "Code refused it: the same content was already rejected as malicious.",
@@ -1,35 +1,21 @@
1
1
  type Json = any;
2
- /** Code review's commit status: a mirror of its merge verdict for people and `gh pr checks`. The merge queue asks code review's
3
- * verdict itself, so the status never becomes a second gate here. */
2
+ /** Code review's commit status: a mirror of its merge verdict for people and `gh pr checks`; never a second gate (the merge queue asks code review directly). */
4
3
  export declare const CODE_REVIEW_STATUS = "aidenhq/review";
5
4
  /** The aggregate check a repository's CI may end with (the product's ci.yml `ci-required`). */
6
5
  export declare const GATE_CHECK = "ci-required";
7
6
  /** The product's PR-metadata job: its title check (and the supply-chain checks), the one job an `edited` run still runs. */
8
7
  export declare const POLICY_CHECK = "policy";
9
- /** One context's result: a check run's conclusion once completed, else PENDING; a status's state. */
10
8
  export declare const contextStatus: (n: Json) => string | null | undefined;
11
9
  /** Which judgement a context is: a check run and a status context that share a name are different judgements, both counted. */
12
10
  export declare const contextKind: (n: Json) => "run" | "status";
13
- /**
14
- * Where a context sits in its name's history, higher is later: a check run's `databaseId` (GitHub creates every run, a re-run
15
- * included, with a higher one), else its `id` where that is a number (REST), else its start or completion time; a status's
16
- * `id` (REST), else its `createdAt`. Undefined when GitHub gave none, so a caller never trusts a rollup's node order as a contract.
17
- */
11
+ /** A context's position in its name's history (higher is later): check run `databaseId`, else numeric `id`, else start/completion time; status `id`, else `createdAt`. Undefined when none, so nobody trusts a rollup's node order. */
18
12
  export declare function contextRank(n: Json): number | undefined;
19
- /**
20
- * One judgement per name and kind: the newest check run of a name, and the newest status of a name (a check run and a status
21
- * sharing a name judge the same name twice, so both survive and the gate takes the worst). `rank` (contextRank) decides the
22
- * newest. An entry with no rank proves no order, so it stays its own judgement and the worst of the name still counts: only
23
- * entries carrying a rank are resolved against each other, and entries of one name whose ranks tie (two statuses in the same
24
- * second) all stay judgements, so the worst of them counts rather than whichever the rollup listed first. An entry with no
25
- * `kind` is left as it is for the same reason.
26
- */
13
+ /** One judgement per name and kind: the newest check run and the newest status of a name (a run and a status sharing a name both survive; the gate takes the worst). Entries without `rank` or `kind`, and ties on rank, all stay judgements so the worst counts, not whichever the rollup listed first. */
27
14
  export declare function latestChecks<T extends {
28
15
  name?: string;
29
16
  kind?: "run" | "status";
30
17
  rank?: number;
31
18
  }>(checks: T[]): T[];
32
- /** A named check as this module reads it: its status, which judgement it is (`kind`) and where it sits in its name's history (`rank`). */
33
19
  export type Check = {
34
20
  name: string;
35
21
  status: string | null | undefined;
@@ -41,61 +27,32 @@ export type Check = {
41
27
  skipped?: true; /** When it last reported: a run's completion, a status's creation. */
42
28
  at?: string;
43
29
  };
44
- /** Every context in a rollup as a named check, advisory ones (code review's status) included: { name, status, kind, rank?, ok, success, pending, skipped? } (`ok` counts neutral and skipped as passed, `success` only success). A name's newest run is picked where it is judged (latestChecks). */
30
+ /** Every context in a rollup as a named check, advisory ones (code review's status) included; `ok` counts neutral and skipped as passed, `success` only success. A name's newest run is picked where it is judged (latestChecks). */
45
31
  export declare function contextChecks(rollup: Json): Check[];
46
- /** The named checks in a rollup, code review's status left out (contextChecks): every context is returned, and a name's newest run is picked where it is judged (latestChecks). */
32
+ /** The named checks in a rollup without code review's status (contextChecks); a name's newest run is picked where it is judged (latestChecks). */
47
33
  export declare function namedChecks(rollup: Json): Check[];
48
- /**
49
- * Whether a check is the aggregate gate reporting that it judged nothing: `ci-required` `skipped` (a job skipped by an `if`, as
50
- * an `edited` run's is) or `cancelled` (a run superseded before the job started). GitHub counts a skip as a pass for branch
51
- * protection; nothing here does. Scoped to the gate name: a suite's own skip is a real result (the change didn't touch it).
52
- */
34
+ /** A check is the aggregate gate reporting it judged nothing: `ci-required` skipped (job `if`, as in an `edited` run) or cancelled before it started. GitHub counts a skip as a pass for branch protection; nothing here does. A suite's own skip is a real result. */
53
35
  export declare const gateJudgedNothing: (c: {
54
36
  name?: string;
55
37
  status?: string | null;
56
38
  }) => boolean;
57
- /** Whether a report actually judged something: a job skipped by `if` or a run cancelled before it started judged nothing. */
58
39
  export declare const judgedSomething: (c: {
59
40
  status?: string | null;
60
41
  }) => boolean;
61
- /**
62
- * Whether the head's newest aggregate report judged nothing: the `ci-required` an `edited` run posts, skipped because that run
63
- * planned no suite. Every check that run posted is a skip too, and those skips are newer than the run that tested the head — so
64
- * they are no verdict, and reading them as passes is exactly the bug this rule exists to stop.
65
- */
42
+ /** Whether the head's newest aggregate report judged nothing (the `ci-required` an `edited` run posts, with a skip for every job it didn't run): those skips are newer than the run that tested the head and are no verdict. */
66
43
  export declare function newestGateSkipped<T extends {
67
44
  name?: string;
68
45
  kind?: "run" | "status";
69
46
  rank?: number;
70
47
  status?: string | null;
71
48
  }>(checks: T[]): boolean;
72
- /**
73
- * The reports that judge a head, for a reader that decides on its checks. A run that plans no suite (`edited`) posts a
74
- * `skipped` check for every job it did not run — and a job `if` skips is still a check GitHub counts as a pass. Those reports
75
- * are newer than the run that tested the head, so judging them would let a body edit read as green over a real failure and
76
- * hide it.
77
- *
78
- * Per name and kind: when the newest report is `skipped` and an older report of that same name judged something, the skip is
79
- * dropped and the older result stands — it is the run that tested the code, and an edit's skip says nothing about it. Two runs
80
- * on one head differ only in the event (an edit against a push or a re-run); within one run a path-filtered suite is skipped
81
- * the same way both times, so an older judgement of the same name is the same tree's. A name whose only report is a skip keeps
82
- * it: a suite skipped by the run that judged the head is a real result (the change didn't touch it). An unranked report proves
83
- * no order, so it is never dropped. `cancelled` is left alone: latestChecks still reads it as a superseded run's red.
84
- */
49
+ /** The reports that judge a head: per name and kind, when the newest report is `skipped` and an older report of that name judged something, the skip is dropped (an `edited` run's skips must not read as green over a real failure). A name whose only report is a skip keeps it (the change didn't touch that suite); an unranked report is never dropped; `cancelled` is left alone (latestChecks reads it as a superseded run's red). */
85
50
  export declare function judgedOnHead<T extends {
86
51
  name?: string;
87
52
  kind?: "run" | "status";
88
53
  rank?: number;
89
54
  status?: string | null;
90
55
  }>(checks: T[]): T[];
91
- /**
92
- * `image-scan` skipped on a PR that changes an image definition (or whose files weren't read at all): nothing was scanned.
93
- * The scan's newest report that judged the head is the judgement (judgedOnHead): a run that scanned the head after an edit
94
- * superseded a skip cleared the question, so the obsolete skip is not one, and a skip that is the newest judgement is.
95
- * The file list answers on its own: a truncated list is answered on the pages that were read; paging happens at the caller.
96
- * Deleting an image definition is not one: the workflow selects Dockerfiles from the head's tree, so a PR that only removes
97
- * a service's Dockerfile skips the scan for a real reason, and no commit could unskip it. A file whose `changeType` is
98
- * missing counts as a change (fail closed).
99
- */
56
+ /** `image-scan` skipped on a PR that changes an image definition (or whose files weren't read): nothing was scanned. The newest report that judged the head decides (judgedOnHead). A truncated file list is answered on the pages read (paging is the caller's). Deleting an image definition is not a change: the workflow selects Dockerfiles from the head's tree, so no commit could unskip it. A missing `changeType` counts as a change (fail closed). */
100
57
  export declare function skippedImageScan(pr: Json): boolean;
101
58
  export {};
@@ -1,11 +1,9 @@
1
- /** Code review's commit status: a mirror of its merge verdict for people and `gh pr checks`. The merge queue asks code review's
2
- * verdict itself, so the status never becomes a second gate here. */
1
+ /** Code review's commit status: a mirror of its merge verdict for people and `gh pr checks`; never a second gate (the merge queue asks code review directly). */
3
2
  export const CODE_REVIEW_STATUS = "aidenhq/review";
4
3
  /** The aggregate check a repository's CI may end with (the product's ci.yml `ci-required`). */
5
4
  export const GATE_CHECK = "ci-required";
6
5
  /** The product's PR-metadata job: its title check (and the supply-chain checks), the one job an `edited` run still runs. */
7
6
  export const POLICY_CHECK = "policy";
8
- /** One context's result: a check run's conclusion once completed, else PENDING; a status's state. */
9
7
  export const contextStatus = (n) => (n.__typename === "CheckRun" ? (n.status === "COMPLETED" ? n.conclusion : "PENDING") : n.state);
10
8
  /** Which judgement a context is: a check run and a status context that share a name are different judgements, both counted. */
11
9
  export const contextKind = (n) => (n.__typename === "CheckRun" ? "run" : n.__typename === "StatusContext" || n.state !== undefined ? "status" : "run");
@@ -19,26 +17,14 @@ const timeOf = (v) => {
19
17
  const t = Date.parse(String(v ?? ""));
20
18
  return Number.isNaN(t) ? undefined : t;
21
19
  };
22
- /**
23
- * Where a context sits in its name's history, higher is later: a check run's `databaseId` (GitHub creates every run, a re-run
24
- * included, with a higher one), else its `id` where that is a number (REST), else its start or completion time; a status's
25
- * `id` (REST), else its `createdAt`. Undefined when GitHub gave none, so a caller never trusts a rollup's node order as a contract.
26
- */
20
+ /** A context's position in its name's history (higher is later): check run `databaseId`, else numeric `id`, else start/completion time; status `id`, else `createdAt`. Undefined when none, so nobody trusts a rollup's node order. */
27
21
  export function contextRank(n) {
28
22
  if (contextKind(n) === "status")
29
23
  return numOf(n.id) ?? timeOf(n.createdAt ?? n.created_at);
30
- // A run's id is the authority; without one, its start is the point every run of a name shares, so the fallback never compares
31
- // one run's completion with another's start (a cancelled run finishes after its replacement has started, and would outrank it).
24
+ // A run's id is the authority; else its start (shared by every run of a name), never completion: a cancelled run finishes after its replacement starts.
32
25
  return numOf(n.databaseId ?? n.id) ?? timeOf(n.startedAt ?? n.started_at) ?? timeOf(n.completedAt ?? n.completed_at);
33
26
  }
34
- /**
35
- * One judgement per name and kind: the newest check run of a name, and the newest status of a name (a check run and a status
36
- * sharing a name judge the same name twice, so both survive and the gate takes the worst). `rank` (contextRank) decides the
37
- * newest. An entry with no rank proves no order, so it stays its own judgement and the worst of the name still counts: only
38
- * entries carrying a rank are resolved against each other, and entries of one name whose ranks tie (two statuses in the same
39
- * second) all stay judgements, so the worst of them counts rather than whichever the rollup listed first. An entry with no
40
- * `kind` is left as it is for the same reason.
41
- */
27
+ /** One judgement per name and kind: the newest check run and the newest status of a name (a run and a status sharing a name both survive; the gate takes the worst). Entries without `rank` or `kind`, and ties on rank, all stay judgements so the worst counts, not whichever the rollup listed first. */
42
28
  export function latestChecks(checks) {
43
29
  const out = [];
44
30
  const groups = new Map();
@@ -64,7 +50,7 @@ export function latestChecks(checks) {
64
50
  out.push(...g.items);
65
51
  return out;
66
52
  }
67
- /** Every context in a rollup as a named check, advisory ones (code review's status) included: { name, status, kind, rank?, ok, success, pending, skipped? } (`ok` counts neutral and skipped as passed, `success` only success). A name's newest run is picked where it is judged (latestChecks). */
53
+ /** Every context in a rollup as a named check, advisory ones (code review's status) included; `ok` counts neutral and skipped as passed, `success` only success. A name's newest run is picked where it is judged (latestChecks). */
68
54
  export function contextChecks(rollup) {
69
55
  const pass = new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
70
56
  return (rollup?.contexts?.nodes ?? [])
@@ -72,41 +58,20 @@ export function contextChecks(rollup) {
72
58
  .filter((c) => c.name)
73
59
  .map((c) => ({ ...c, ok: pass.has(c.status), success: c.status === "SUCCESS", pending: ["PENDING", "EXPECTED", "QUEUED", null, undefined].includes(c.status), ...(c.status === "SKIPPED" ? { skipped: true } : {}) }));
74
60
  }
75
- /** The named checks in a rollup, code review's status left out (contextChecks): every context is returned, and a name's newest run is picked where it is judged (latestChecks). */
61
+ /** The named checks in a rollup without code review's status (contextChecks); a name's newest run is picked where it is judged (latestChecks). */
76
62
  export function namedChecks(rollup) {
77
63
  return contextChecks(rollup).filter((c) => c.name !== CODE_REVIEW_STATUS);
78
64
  }
79
- /**
80
- * Whether a check is the aggregate gate reporting that it judged nothing: `ci-required` `skipped` (a job skipped by an `if`, as
81
- * an `edited` run's is) or `cancelled` (a run superseded before the job started). GitHub counts a skip as a pass for branch
82
- * protection; nothing here does. Scoped to the gate name: a suite's own skip is a real result (the change didn't touch it).
83
- */
65
+ /** A check is the aggregate gate reporting it judged nothing: `ci-required` skipped (job `if`, as in an `edited` run) or cancelled before it started. GitHub counts a skip as a pass for branch protection; nothing here does. A suite's own skip is a real result. */
84
66
  export const gateJudgedNothing = (c) => c.name === GATE_CHECK && ["SKIPPED", "CANCELLED"].includes(String(c.status ?? "").toUpperCase());
85
- /** Whether a report actually judged something: a job skipped by `if` or a run cancelled before it started judged nothing. */
86
67
  export const judgedSomething = (c) => !["SKIPPED", "CANCELLED"].includes(String(c.status ?? "").toUpperCase());
87
- /**
88
- * Whether the head's newest aggregate report judged nothing: the `ci-required` an `edited` run posts, skipped because that run
89
- * planned no suite. Every check that run posted is a skip too, and those skips are newer than the run that tested the head — so
90
- * they are no verdict, and reading them as passes is exactly the bug this rule exists to stop.
91
- */
68
+ /** Whether the head's newest aggregate report judged nothing (the `ci-required` an `edited` run posts, with a skip for every job it didn't run): those skips are newer than the run that tested the head and are no verdict. */
92
69
  export function newestGateSkipped(checks) {
93
70
  const runs = checks.filter((c) => c.name === GATE_CHECK && (c.kind ?? "run") === "run" && typeof c.rank === "number");
94
71
  const newest = runs.reduce((a, b) => (a === undefined || b.rank > a.rank ? b : a), undefined);
95
72
  return newest !== undefined && gateJudgedNothing(newest);
96
73
  }
97
- /**
98
- * The reports that judge a head, for a reader that decides on its checks. A run that plans no suite (`edited`) posts a
99
- * `skipped` check for every job it did not run — and a job `if` skips is still a check GitHub counts as a pass. Those reports
100
- * are newer than the run that tested the head, so judging them would let a body edit read as green over a real failure and
101
- * hide it.
102
- *
103
- * Per name and kind: when the newest report is `skipped` and an older report of that same name judged something, the skip is
104
- * dropped and the older result stands — it is the run that tested the code, and an edit's skip says nothing about it. Two runs
105
- * on one head differ only in the event (an edit against a push or a re-run); within one run a path-filtered suite is skipped
106
- * the same way both times, so an older judgement of the same name is the same tree's. A name whose only report is a skip keeps
107
- * it: a suite skipped by the run that judged the head is a real result (the change didn't touch it). An unranked report proves
108
- * no order, so it is never dropped. `cancelled` is left alone: latestChecks still reads it as a superseded run's red.
109
- */
74
+ /** The reports that judge a head: per name and kind, when the newest report is `skipped` and an older report of that name judged something, the skip is dropped (an `edited` run's skips must not read as green over a real failure). A name whose only report is a skip keeps it (the change didn't touch that suite); an unranked report is never dropped; `cancelled` is left alone (latestChecks reads it as a superseded run's red). */
110
75
  export function judgedOnHead(checks) {
111
76
  const groups = new Map();
112
77
  for (const c of checks) {
@@ -130,15 +95,7 @@ export function judgedOnHead(checks) {
130
95
  return drop.size ? checks.filter((c) => !drop.has(c)) : checks;
131
96
  }
132
97
  const IMAGE_FILE = /(^|\/)(Dockerfile|Containerfile)[^/]*$|\.dockerfile$/i;
133
- /**
134
- * `image-scan` skipped on a PR that changes an image definition (or whose files weren't read at all): nothing was scanned.
135
- * The scan's newest report that judged the head is the judgement (judgedOnHead): a run that scanned the head after an edit
136
- * superseded a skip cleared the question, so the obsolete skip is not one, and a skip that is the newest judgement is.
137
- * The file list answers on its own: a truncated list is answered on the pages that were read; paging happens at the caller.
138
- * Deleting an image definition is not one: the workflow selects Dockerfiles from the head's tree, so a PR that only removes
139
- * a service's Dockerfile skips the scan for a real reason, and no commit could unskip it. A file whose `changeType` is
140
- * missing counts as a change (fail closed).
141
- */
98
+ /** `image-scan` skipped on a PR that changes an image definition (or whose files weren't read): nothing was scanned. The newest report that judged the head decides (judgedOnHead). A truncated file list is answered on the pages read (paging is the caller's). Deleting an image definition is not a change: the workflow selects Dockerfiles from the head's tree, so no commit could unskip it. A missing `changeType` counts as a change (fail closed). */
142
99
  export function skippedImageScan(pr) {
143
100
  const nodes = pr.commits?.nodes?.[0]?.commit?.statusCheckRollup?.contexts?.nodes ?? [];
144
101
  const scans = latestChecks(judgedOnHead(contextChecks({ contexts: { nodes } })).filter((c) => c.name === "image-scan"));
@@ -1,4 +1,3 @@
1
- /** The paths churn ignores. */
2
1
  export declare const DEFAULT_CHURN_EXCLUDE: string[];
3
2
  export type ChurnPr = {
4
3
  pr: string;
@@ -11,11 +10,7 @@ export type Rewrite = {
11
10
  lines: number;
12
11
  days: number;
13
12
  };
14
- /**
15
- * Per-PR survival from `prs` in merge order. `opts.windowDays`: a removed line counts as rewritten when it was added at most
16
- * that many days earlier. `opts.exclude`: globs of paths ignored. `added[pr]`: lines the PR added that were not moves.
17
- * `rewritten`: per (pr, by_pr) the lines of `pr` that `by_pr` removed, and their mean age in whole days.
18
- */
13
+ /** Per-PR survival from `prs` in merge order. `opts.windowDays`: a removed line counts as rewritten when added at most that many days earlier. `opts.exclude`: ignored path globs. `added[pr]`: non-move lines added. `rewritten`: per (pr, by_pr) the lines of `pr` that `by_pr` removed, with mean age in whole days. */
19
14
  export declare function churn(prs: ChurnPr[], opts: {
20
15
  windowDays: number;
21
16
  exclude: string[];
@@ -23,12 +18,7 @@ export declare function churn(prs: ChurnPr[], opts: {
23
18
  added: Record<string, number>;
24
19
  rewritten: Rewrite[];
25
20
  };
26
- /**
27
- * Churn over a repo's first-parent history through `git` (args → stdout, run in the repo): each commit whose subject
28
- * names a PR (`prOf`) is one PR. With a `cursor` only the window before it is read again, so lines added just before it keep
29
- * their owner; `fresh` says which of the results are new since it. `last`: the newest commit's time, the next cursor.
30
- * `first`: without a cursor, only the newest that many commits (a first pass on the caller's own thread).
31
- */
21
+ /** Churn over a repo's first-parent history through `git` (args -> stdout): each commit whose subject names a PR (`prOf`) is one PR. With a `cursor` only the window before it is re-read so lines added just before it keep their owner; `fresh` says which results are new. `last`: newest commit's time, the next cursor. `first`: without a cursor, only the newest that many commits. */
32
22
  export declare function churnFromGit(git: (args: string[]) => Promise<string>, o: {
33
23
  rev: string;
34
24
  cursor?: string;
package/dist/src/churn.js CHANGED
@@ -1,15 +1,10 @@
1
- // Code churn (docs/design/flow.md): how much of each merged PR's code is rewritten soon after it landed. A pure function over
2
- // PRs' unified diffs in merge order: every line is tracked by identity (the PR that added it, and when) through later hunks and
3
- // renames, so a line counts once: as added by its PR, and, when a later PR removes it inside the window, as rewritten. A hunk
4
- // a PR removes in one place and adds in another unchanged is a move: the lines keep their owner and count as neither.
1
+ // Code churn (docs/design/flow.md): how much of each merged PR's code is rewritten soon after it landed. Pure over PRs' unified diffs in merge order: every line is tracked by identity (adding PR, when) through later hunks and renames, counting once as added and, when a later PR removes it inside the window, as rewritten. A hunk removed in one place and added unchanged in another is a move: lines keep their owner and count as neither.
5
2
  // Copied into the code host's service (scripts/sync-shared.ts); codehost-local calls it from the kernel.
6
- /** The paths churn ignores. */
7
3
  export const DEFAULT_CHURN_EXCLUDE = ["**/package-lock.json", "**/bun.lock", "**/dist/**", "**/vendor/**", "**/*.min.*"];
8
4
  const DAY = 86_400_000;
9
5
  /** Shortest trimmed line a move may match on: `}` and `return;` appear everywhere and prove nothing. */
10
6
  const MIN_MOVE = 8;
11
7
  const globRe = (g) => new RegExp(`^${g.replace(/[.+^${}()|[\]\\?]/g, "\\$&").replace(/\*\*\//g, "\u0000").replace(/\*\*/g, "\u0001").replace(/\*/g, "[^/]*").replace(/\u0000/g, "(?:.*/)?").replace(/\u0001/g, ".*")}$`);
12
- /** A unified diff (git's, with renames) as per-file hunks; binary files and mode-only changes have none. */
13
8
  function parse(diff) {
14
9
  const out = [];
15
10
  const lines = diff.split("\n");
@@ -68,11 +63,7 @@ function parse(diff) {
68
63
  }
69
64
  return out;
70
65
  }
71
- /**
72
- * Per-PR survival from `prs` in merge order. `opts.windowDays`: a removed line counts as rewritten when it was added at most
73
- * that many days earlier. `opts.exclude`: globs of paths ignored. `added[pr]`: lines the PR added that were not moves.
74
- * `rewritten`: per (pr, by_pr) the lines of `pr` that `by_pr` removed, and their mean age in whole days.
75
- */
66
+ /** Per-PR survival from `prs` in merge order. `opts.windowDays`: a removed line counts as rewritten when added at most that many days earlier. `opts.exclude`: ignored path globs. `added[pr]`: non-move lines added. `rewritten`: per (pr, by_pr) the lines of `pr` that `by_pr` removed, with mean age in whole days. */
76
67
  export function churn(prs, opts) {
77
68
  const skip = opts.exclude.map(globRe);
78
69
  const excluded = (p) => skip.some((r) => r.test(p));
@@ -152,12 +143,7 @@ export function churn(prs, opts) {
152
143
  }
153
144
  return { added, rewritten: [...rewritten.values()].map(({ sum, ...e }) => ({ ...e, days: Math.round(sum / e.lines) })) };
154
145
  }
155
- /**
156
- * Churn over a repo's first-parent history through `git` (args → stdout, run in the repo): each commit whose subject
157
- * names a PR (`prOf`) is one PR. With a `cursor` only the window before it is read again, so lines added just before it keep
158
- * their owner; `fresh` says which of the results are new since it. `last`: the newest commit's time, the next cursor.
159
- * `first`: without a cursor, only the newest that many commits (a first pass on the caller's own thread).
160
- */
146
+ /** Churn over a repo's first-parent history through `git` (args -> stdout): each commit whose subject names a PR (`prOf`) is one PR. With a `cursor` only the window before it is re-read so lines added just before it keep their owner; `fresh` says which results are new. `last`: newest commit's time, the next cursor. `first`: without a cursor, only the newest that many commits. */
161
147
  export async function churnFromGit(git, o) {
162
148
  const since = o.cursor ? [`--since=${new Date(Date.parse(o.cursor) - o.windowDays * DAY).toISOString()}`] : o.first ? [`--max-count=${o.first}`] : [];
163
149
  const log = await git(["log", "--first-parent", "--reverse", "--format=%H%x09%cI%x09%s", ...since, o.rev]);
@@ -13,7 +13,6 @@ type Closer = {
13
13
  };
14
14
  oid?: string;
15
15
  };
16
- /** The latest close's actor and its closer, as a tool shows them; undefined for an issue no close event is known for. */
17
16
  export declare function closedBy(node: {
18
17
  closedEvents?: {
19
18
  nodes?: {