@alan-ai-hq/agent-manager-linux-arm64 0.1.199 → 0.1.201

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 (96) hide show
  1. package/alan-agent.cjs +8928 -5241
  2. package/alan-holder.cjs +5364 -3401
  3. package/alan-lease.cjs +808 -200
  4. package/builtin-skills/agent-desktop/SKILL.md +94 -0
  5. package/builtin-skills/alan-artifact/SKILL.md +128 -0
  6. package/builtin-skills/alan-artifact/examples/interactive-diagram.md +50 -0
  7. package/builtin-skills/alan-artifact/examples/prototype.md +53 -0
  8. package/builtin-skills/alan-artifact/examples/test-report.md +55 -0
  9. package/builtin-skills/alan-artifact/references/design.md +39 -0
  10. package/builtin-skills/alan-artifact/references/diagrams.md +20 -0
  11. package/builtin-skills/alan-deck/SKILL.md +189 -0
  12. package/builtin-skills/alan-diagrams/SKILL.md +105 -0
  13. package/builtin-skills/alan-diagrams/references/diagram-catalogue.md +847 -0
  14. package/builtin-skills/alan-docs/SKILL.md +143 -0
  15. package/builtin-skills/alan-docs/references/administration/members-and-teams.md +48 -0
  16. package/builtin-skills/alan-docs/references/administration/org-dashboard.md +19 -0
  17. package/builtin-skills/alan-docs/references/administration/organisation-settings.md +41 -0
  18. package/builtin-skills/alan-docs/references/agents-and-sessions/code-context.md +60 -0
  19. package/builtin-skills/alan-docs/references/agents-and-sessions/coding-agents-and-models.md +78 -0
  20. package/builtin-skills/alan-docs/references/agents-and-sessions/session-lifecycle.md +62 -0
  21. package/builtin-skills/alan-docs/references/agents-and-sessions/start-a-session.md +110 -0
  22. package/builtin-skills/alan-docs/references/automations/automation-runs.md +69 -0
  23. package/builtin-skills/alan-docs/references/automations/create-an-automation.md +143 -0
  24. package/builtin-skills/alan-docs/references/automations/overview.md +77 -0
  25. package/builtin-skills/alan-docs/references/cloud-and-local/cloud-images.md +64 -0
  26. package/builtin-skills/alan-docs/references/cloud-and-local/cloud-sessions-and-execution.md +89 -0
  27. package/builtin-skills/alan-docs/references/cloud-and-local/cloud-setup.md +128 -0
  28. package/builtin-skills/alan-docs/references/cloud-and-local/codex-cli-connector.md +92 -0
  29. package/builtin-skills/alan-docs/references/cloud-and-local/local-execution.md +213 -0
  30. package/builtin-skills/alan-docs/references/cloud-and-local/runtime-recovery.md +60 -0
  31. package/builtin-skills/alan-docs/references/cloud-and-local/sandboxes.md +74 -0
  32. package/builtin-skills/alan-docs/references/cloud-and-local/troubleshooting-and-faq.md +102 -0
  33. package/builtin-skills/alan-docs/references/get-started/connect-azure-devops.md +89 -0
  34. package/builtin-skills/alan-docs/references/get-started/connect-bitbucket.md +86 -0
  35. package/builtin-skills/alan-docs/references/get-started/connect-github.md +114 -0
  36. package/builtin-skills/alan-docs/references/get-started/join-a-team.md +114 -0
  37. package/builtin-skills/alan-docs/references/get-started/product-map.md +96 -0
  38. package/builtin-skills/alan-docs/references/get-started/quickstart.md +158 -0
  39. package/builtin-skills/alan-docs/references/get-started/set-up-your-team.md +200 -0
  40. package/builtin-skills/alan-docs/references/get-started/sign-in.md +104 -0
  41. package/builtin-skills/alan-docs/references/get-started/welcome.md +39 -0
  42. package/builtin-skills/alan-docs/references/integrations/connect-microsoft-teams.md +116 -0
  43. package/builtin-skills/alan-docs/references/integrations/connect-slack.md +164 -0
  44. package/builtin-skills/alan-docs/references/integrations/import-from-linear.md +172 -0
  45. package/builtin-skills/alan-docs/references/plans-and-billing/plans-and-limits.md +115 -0
  46. package/builtin-skills/alan-docs/references/plans-and-billing/usage-and-credits.md +47 -0
  47. package/builtin-skills/alan-docs/references/reference/documents-and-artifacts.md +52 -0
  48. package/builtin-skills/alan-docs/references/reference/faq.md +89 -0
  49. package/builtin-skills/alan-docs/references/reference/feature-catalog.md +89 -0
  50. package/builtin-skills/alan-docs/references/reference/glossary.md +96 -0
  51. package/builtin-skills/alan-docs/references/reference/links-and-ids.md +80 -0
  52. package/builtin-skills/alan-docs/references/reference/roles-and-permissions.md +64 -0
  53. package/builtin-skills/alan-docs/references/reference/statuses.md +86 -0
  54. package/builtin-skills/alan-docs/references/reviews-testing-deploys/deployments.md +28 -0
  55. package/builtin-skills/alan-docs/references/reviews-testing-deploys/pull-requests.md +85 -0
  56. package/builtin-skills/alan-docs/references/reviews-testing-deploys/review-work.md +55 -0
  57. package/builtin-skills/alan-docs/references/reviews-testing-deploys/testing-evidence.md +52 -0
  58. package/builtin-skills/alan-docs/references/skills/plugins-and-mcp.md +24 -0
  59. package/builtin-skills/alan-docs/references/skills/skills.md +103 -0
  60. package/builtin-skills/alan-docs/references/tasks/complete-a-task.md +79 -0
  61. package/builtin-skills/alan-docs/references/tasks/create-a-task.md +67 -0
  62. package/builtin-skills/alan-docs/references/tasks/subtasks-and-status.md +55 -0
  63. package/builtin-skills/alan-docs/references/tasks/task-artifacts.md +56 -0
  64. package/builtin-skills/alan-docs/references/tasks/task-detail.md +65 -0
  65. package/builtin-skills/alan-docs/references/teams-and-planning/cycles.md +93 -0
  66. package/builtin-skills/alan-docs/references/teams-and-planning/documents.md +66 -0
  67. package/builtin-skills/alan-docs/references/teams-and-planning/epics.md +95 -0
  68. package/builtin-skills/alan-docs/references/teams-and-planning/whiteboard.md +52 -0
  69. package/builtin-skills/alan-docs/references/troubleshooting/agent-blocked.md +38 -0
  70. package/builtin-skills/alan-docs/references/troubleshooting/common-problems.md +118 -0
  71. package/builtin-skills/alan-docs/references/troubleshooting/github-access.md +41 -0
  72. package/builtin-skills/alan-docs/references/troubleshooting/missing-artifact.md +47 -0
  73. package/builtin-skills/alan-docs/references/troubleshooting/report-an-issue.md +74 -0
  74. package/builtin-skills/alan-docs/references/troubleshooting/runtime-unavailable.md +49 -0
  75. package/builtin-skills/alan-docs/scripts/generate-references.mjs +363 -0
  76. package/builtin-skills/alan-environment-setup/SKILL.md +368 -0
  77. package/builtin-skills/alan-environment-setup/references/android.md +118 -0
  78. package/builtin-skills/alan-environment-setup/references/troubleshooting.md +38 -0
  79. package/builtin-skills/alan-skill-authoring/SKILL.md +83 -0
  80. package/builtin-skills/alan-tasks/SKILL.md +195 -0
  81. package/builtin-skills/alan-test-android/SKILL.md +224 -0
  82. package/builtin-skills/alan-test-android/scripts/android-up.sh +227 -0
  83. package/builtin-skills/alan-test-android/scripts/install-launch.sh +38 -0
  84. package/builtin-skills/alan-test-android/scripts/record.sh +64 -0
  85. package/builtin-skills/alan-test-android/scripts/ui.py +367 -0
  86. package/builtin-skills/alan-test-desktop/SKILL.md +107 -0
  87. package/builtin-skills/alan-test-desktop/references/linux-recording.md +31 -0
  88. package/builtin-skills/alan-test-feature/SKILL.md +243 -0
  89. package/builtin-skills/alan-test-mobile/SKILL.md +65 -0
  90. package/builtin-skills/alan-test-web/SKILL.md +113 -0
  91. package/builtin-skills/alan-walkthrough/SKILL.md +152 -0
  92. package/builtin-skills/alan-walkthrough/scripts/mark-changes.js +419 -0
  93. package/builtin-skills/alan-walkthrough/scripts/publish-capture.mjs +288 -0
  94. package/builtin-skills/alan-workflows/SKILL.md +235 -0
  95. package/builtin-skills/manifest.json +19 -0
  96. package/package.json +3 -2
@@ -0,0 +1,419 @@
1
+ // quirk: draws a temporary what-changed overlay on the live page; run it on the before and after states with the same numbers, then call alanMarks.clear().
2
+ //
3
+ // Playwright: await page.addScriptTag({ path: "<skill-dir>/scripts/mark-changes.js" });
4
+ // agent-browser: agent-browser eval "$(cat <skill-dir>/scripts/mark-changes.js)"
5
+ // agent-browser eval 'alanMarks.mark([{"n":1,"selector":"#save","label":"Save moved"}])'
6
+ //
7
+ // A mark is { n, selector | rect: { x, y, w, h }, label?, kind? }:
8
+ // label sentence case, about 28 characters; longer text is truncated with an ellipsis
9
+ // (the full text belongs in the legend under the table)
10
+ // kind "changed" (default, solid box), "removed" (dashed, before only), "added" (dotted, after only)
11
+ // mark(marks, { accent }) forces the one colour used (default red, or blue when
12
+ // a target's own background is reddish). Every shape is a single stroke or fill.
13
+ //
14
+ // Layout: callouts sit in free space near the box, arrows stay short, and in a
15
+ // crowd the callouts move to a gutter along the left or right edge, ordered by
16
+ // number from top to bottom. mark() returns { marks, overlaps, crossings }: per
17
+ // mark its rects and arrow points in viewport pixels; overlaps are collisions
18
+ // between callouts, arrows and boxes (also warned on the console), crossings
19
+ // are arrows that pass over another mark's box, which only a crowd forces.
20
+ // The overlay lives in page coordinates, so it also works with full-page screenshots.
21
+ (() => {
22
+ const ROOT_ATTR = "data-alan-marks";
23
+ const RED = { accent: "#FF4D4F", dark: "#B42318" };
24
+ const BLUE = { accent: "#3B82F6", dark: "#1D4ED8" };
25
+ const FONT = "system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif";
26
+ const PAD = 3;
27
+ const PILL_H = 24;
28
+ const CIRCLE = 16;
29
+ const TIP_GAP = 2.5;
30
+ const HEAD = 7;
31
+ const EDGE = 6;
32
+ const MAX_LABEL = 28;
33
+ const DISTANCES = [18, 30, 46, 66, 92, 120];
34
+ const SAMPLE = 3;
35
+ const KIND_DASH = { changed: "none", removed: "5 3", added: "1.5 3" };
36
+
37
+ const clear = () => {
38
+ for (const node of document.querySelectorAll(`[${ROOT_ATTR}]`)) node.remove();
39
+ };
40
+
41
+ const rectsOverlap = (a, b, margin = 0) =>
42
+ Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x) + margin * 2 > 0 &&
43
+ Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y) + margin * 2 > 0;
44
+
45
+ const contains = (outer, inner) =>
46
+ inner.x >= outer.x &&
47
+ inner.y >= outer.y &&
48
+ inner.x + inner.w <= outer.x + outer.w &&
49
+ inner.y + inner.h <= outer.y + outer.h;
50
+
51
+ const inside = (p, r, margin = 0) =>
52
+ p.x >= r.x - margin &&
53
+ p.x <= r.x + r.w + margin &&
54
+ p.y >= r.y - margin &&
55
+ p.y <= r.y + r.h + margin;
56
+
57
+ const partsCollide = (a, b) => {
58
+ if (a.rect && b.rect) return rectsOverlap(a.rect, b.rect, 1);
59
+ if (a.path && b.path)
60
+ return a.path.some((p) => b.path.some((q) => Math.hypot(p.x - q.x, p.y - q.y) < SAMPLE));
61
+ const path = a.path ?? b.path;
62
+ const rect = a.rect ?? b.rect;
63
+ return path.some((p) => inside(p, rect, 1));
64
+ };
65
+
66
+ const clamp = (value, low, high) => Math.min(Math.max(value, low), Math.max(low, high));
67
+
68
+ const quad = (a, c, e) => {
69
+ const chord = Math.hypot(e.x - a.x, e.y - a.y);
70
+ const steps = Math.max(2, Math.ceil(chord / SAMPLE));
71
+ return Array.from({ length: steps + 1 }, (_, i) => {
72
+ const t = i / steps;
73
+ const u = 1 - t;
74
+ return {
75
+ x: u * u * a.x + 2 * u * t * c.x + t * t * e.x,
76
+ y: u * u * a.y + 2 * u * t * c.y + t * t * e.y,
77
+ };
78
+ });
79
+ };
80
+
81
+ // Curve from the callout edge a to the box edge point t: a gentle quadratic
82
+ // bend, ending TIP_GAP short of the box with room for the arrowhead.
83
+ const arrowBetween = (a, t) => {
84
+ const length = Math.hypot(t.x - a.x, t.y - a.y) || 1;
85
+ const mid = { x: (a.x + t.x) / 2, y: (a.y + t.y) / 2 };
86
+ const ctrl = {
87
+ x: mid.x - ((t.y - a.y) / length) * length * 0.14,
88
+ y: mid.y + ((t.x - a.x) / length) * length * 0.14,
89
+ };
90
+ const dl = Math.hypot(t.x - ctrl.x, t.y - ctrl.y) || 1;
91
+ const dir = { x: (t.x - ctrl.x) / dl, y: (t.y - ctrl.y) / dl };
92
+ const tip = { x: t.x - dir.x * TIP_GAP, y: t.y - dir.y * TIP_GAP };
93
+ const end = { x: tip.x - dir.x * (HEAD - 1), y: tip.y - dir.y * (HEAD - 1) };
94
+ return { from: a, ctrl, end, tip, dir, path: [...quad(a, ctrl, end), tip], length };
95
+ };
96
+
97
+ const callout = (x, y, width, facing, box) => {
98
+ const pill = { x, y, w: width, h: PILL_H };
99
+ const mid = { x: x + width / 2, y: y + PILL_H / 2 };
100
+ const anchors = {
101
+ top: { x: mid.x, y: y + PILL_H },
102
+ bottom: { x: mid.x, y },
103
+ left: { x: x + width, y: mid.y },
104
+ right: { x, y: mid.y },
105
+ };
106
+ const a = anchors[facing];
107
+ const t =
108
+ facing === "top" || facing === "bottom"
109
+ ? {
110
+ x: clamp(a.x, box.x + 8, box.x + box.w - 8),
111
+ y: facing === "top" ? box.y : box.y + box.h,
112
+ }
113
+ : {
114
+ x: facing === "left" ? box.x : box.x + box.w,
115
+ y: clamp(a.y, box.y + 8, box.y + box.h - 8),
116
+ };
117
+ const arrow = arrowBetween(a, t);
118
+ return { pill, arrow, parts: [{ rect: pill }, { path: arrow.path }] };
119
+ };
120
+
121
+ const nearCandidates = (item, view) => {
122
+ const { box, width } = item;
123
+ const found = [];
124
+ for (const d of DISTANCES) {
125
+ for (const side of ["top", "bottom", "right", "left"]) {
126
+ const facing = { top: "top", bottom: "bottom", left: "left", right: "right" }[side];
127
+ const horizontal = side === "top" || side === "bottom";
128
+ const starts = horizontal
129
+ ? [box.x, box.x + box.w / 2 - width / 2, box.x + box.w - width]
130
+ : [box.y, box.y + box.h / 2 - PILL_H / 2, box.y + box.h - PILL_H];
131
+ for (const along of starts) {
132
+ const x = horizontal ? along : side === "left" ? box.x - d - width : box.x + box.w + d;
133
+ const y = horizontal ? (side === "top" ? box.y - d - PILL_H : box.y + box.h + d) : along;
134
+ const candidate = callout(x, y, width, facing, box);
135
+ if (contains(view, candidate.pill)) found.push({ placement: "near", ...candidate });
136
+ }
137
+ }
138
+ }
139
+ return found;
140
+ };
141
+
142
+ const gutterCandidate = (item, view, side, y) => {
143
+ const x = side === "left" ? view.x + EDGE : view.x + view.w - item.width - EDGE;
144
+ const facing = side === "left" ? "left" : "right";
145
+ const candidate = callout(x, y, item.width, facing === "left" ? "left" : "right", item.box);
146
+ return { placement: "gutter", ...candidate };
147
+ };
148
+
149
+ const score = (candidate, item, index, boxes, taken) => {
150
+ let hits = 0;
151
+ for (const part of candidate.parts) {
152
+ boxes.forEach((target, i) => {
153
+ if (part.path && i === index) {
154
+ if (part.path.slice(0, -2).some((p) => inside(p, item.box))) hits += 5;
155
+ } else if (partsCollide(part, target)) {
156
+ hits += part.path ? 1 : 100;
157
+ }
158
+ });
159
+ for (const earlier of taken) if (partsCollide(part, earlier)) hits += 100;
160
+ }
161
+ return hits;
162
+ };
163
+
164
+ const place = (items, view) => {
165
+ const boxes = items.map((item) => ({ rect: item.box }));
166
+ const taken = [];
167
+ const placed = new Array(items.length).fill(null);
168
+ const pending = [];
169
+ items.forEach((item, index) => {
170
+ const free = nearCandidates(item, view).find(
171
+ (candidate) => score(candidate, item, index, boxes, taken) === 0
172
+ );
173
+ if (free) {
174
+ placed[index] = free;
175
+ taken.push(...free.parts);
176
+ } else {
177
+ pending.push(index);
178
+ }
179
+ });
180
+ const step = PILL_H + 4;
181
+ const byNumber = [...pending].sort((a, b) => items[a].n - items[b].n);
182
+ const sides = new Map(
183
+ byNumber.map((index) => {
184
+ const box = items[index].box;
185
+ return [index, box.x + box.w / 2 < view.x + view.w / 2 ? "left" : "right"];
186
+ })
187
+ );
188
+ for (const side of ["left", "right"]) {
189
+ let floor = view.y + EDGE;
190
+ for (const index of byNumber.filter((i) => sides.get(i) === side)) {
191
+ const item = items[index];
192
+ const wanted = item.box.y + item.box.h / 2 - PILL_H / 2;
193
+ let best = null;
194
+ for (
195
+ let top = Math.max(wanted, floor);
196
+ top <= view.y + view.h - PILL_H - EDGE;
197
+ top += step
198
+ ) {
199
+ const candidate = gutterCandidate(item, view, side, top);
200
+ const hits = score(candidate, item, index, boxes, taken);
201
+ if (!best || hits < best.hits) best = { candidate, hits, top };
202
+ if (hits < 100) break;
203
+ }
204
+ const chosen =
205
+ best?.candidate ??
206
+ gutterCandidate(
207
+ item,
208
+ view,
209
+ side,
210
+ clamp(wanted, view.y + EDGE, view.y + view.h - PILL_H - EDGE)
211
+ );
212
+ floor = (best?.top ?? floor) + step;
213
+ placed[index] = chosen;
214
+ taken.push(...chosen.parts);
215
+ }
216
+ }
217
+ return placed;
218
+ };
219
+
220
+ const svg = (tag, attrs) => {
221
+ const node = document.createElementNS("http://www.w3.org/2000/svg", tag);
222
+ for (const [key, value] of Object.entries(attrs)) node.setAttribute(key, String(value));
223
+ return node;
224
+ };
225
+
226
+ const resolveRect = (spec) => {
227
+ if (spec.rect) {
228
+ return {
229
+ x: spec.rect.x + window.scrollX,
230
+ y: spec.rect.y + window.scrollY,
231
+ w: spec.rect.w,
232
+ h: spec.rect.h,
233
+ };
234
+ }
235
+ const element = document.querySelector(spec.selector);
236
+ if (!element) throw new Error(`alanMarks: no element matches "${spec.selector}"`);
237
+ const r = element.getBoundingClientRect();
238
+ return { x: r.left + window.scrollX, y: r.top + window.scrollY, w: r.width, h: r.height };
239
+ };
240
+
241
+ const truncate = (text) =>
242
+ text.length > MAX_LABEL ? `${text.slice(0, MAX_LABEL - 1).trimEnd()}…` : text;
243
+
244
+ const measure = (texts) => {
245
+ const probe = svg("svg", { width: 0, height: 0, style: "position:absolute;visibility:hidden" });
246
+ document.body.append(probe);
247
+ const widths = texts.map((text) => {
248
+ const node = svg("text", { "font-size": 12, "font-weight": 500, "font-family": FONT });
249
+ node.textContent = text;
250
+ probe.append(node);
251
+ return text ? node.getComputedTextLength() : 0;
252
+ });
253
+ probe.remove();
254
+ return widths;
255
+ };
256
+
257
+ const findOverlaps = (items, placed) => {
258
+ const entries = [];
259
+ items.forEach((item, i) => {
260
+ entries.push({ n: item.n, name: "box", part: { rect: item.box } });
261
+ entries.push({ n: item.n, name: "callout", part: { rect: placed[i].pill } });
262
+ entries.push({ n: item.n, name: "arrow", part: { path: placed[i].arrow.path } });
263
+ });
264
+ const overlaps = [];
265
+ const crossings = [];
266
+ for (let i = 0; i < entries.length; i += 1) {
267
+ for (let j = i + 1; j < entries.length; j += 1) {
268
+ const a = entries[i];
269
+ const b = entries[j];
270
+ if (a.name === "box" && b.name === "box") continue;
271
+ if (a.n === b.n && a.name !== "box" && b.name !== "box") continue;
272
+ if (a.n === b.n && (a.name === "arrow" || b.name === "arrow")) continue;
273
+ if (!partsCollide(a.part, b.part)) continue;
274
+ const text = `${a.name} ${a.n} / ${b.name} ${b.n}`;
275
+ const arrowOnBox =
276
+ (a.name === "arrow" && b.name === "box") || (a.name === "box" && b.name === "arrow");
277
+ (arrowOnBox ? crossings : overlaps).push(text);
278
+ }
279
+ }
280
+ return { overlaps, crossings };
281
+ };
282
+
283
+ const reddish = (color) => {
284
+ const m = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
285
+ return m ? Number(m[1]) > Number(m[2]) + 40 && Number(m[1]) > Number(m[3]) + 40 : false;
286
+ };
287
+
288
+ const pickPalette = (specs, accent) => {
289
+ if (accent) return { accent, dark: accent };
290
+ const backgrounds = specs.flatMap((spec) => {
291
+ const element = spec.selector ? document.querySelector(spec.selector) : null;
292
+ return element ? [getComputedStyle(element).backgroundColor] : [];
293
+ });
294
+ return backgrounds.some(reddish) ? BLUE : RED;
295
+ };
296
+
297
+ const text = (x, y, size, weight, anchor, content) => {
298
+ const node = svg("text", {
299
+ x,
300
+ y,
301
+ fill: "#ffffff",
302
+ "font-size": size,
303
+ "font-weight": weight,
304
+ "font-family": FONT,
305
+ "text-anchor": anchor,
306
+ "dominant-baseline": "central",
307
+ });
308
+ node.textContent = content;
309
+ return node;
310
+ };
311
+
312
+ const mark = (specs, options = {}) => {
313
+ clear();
314
+ const view = {
315
+ x: window.scrollX,
316
+ y: window.scrollY,
317
+ w: window.innerWidth,
318
+ h: window.innerHeight,
319
+ };
320
+ const labels = specs.map((spec) => truncate(spec.label ?? ""));
321
+ const widths = measure(labels);
322
+ const items = specs.map((spec, i) => {
323
+ const r = resolveRect(spec);
324
+ return {
325
+ n: spec.n ?? i + 1,
326
+ kind: KIND_DASH[spec.kind] ? spec.kind : "changed",
327
+ label: labels[i],
328
+ width: 4 + CIRCLE + (labels[i] ? 5 + Math.ceil(widths[i]) : 0) + 8,
329
+ box: { x: r.x - PAD, y: r.y - PAD, w: r.w + PAD * 2, h: r.h + PAD * 2 },
330
+ };
331
+ });
332
+ const { accent, dark } = pickPalette(specs, options.accent);
333
+ const placed = place(items, view);
334
+ const { overlaps, crossings } = findOverlaps(items, placed);
335
+ if (overlaps.length > 0)
336
+ console.warn(`alanMarks: ${overlaps.length} overlap(s): ${overlaps.join(", ")}`);
337
+
338
+ const doc = document.documentElement;
339
+ const width = Math.max(doc.scrollWidth, view.x + view.w);
340
+ const height = Math.max(doc.scrollHeight, view.y + view.h);
341
+ const root = document.createElement("div");
342
+ root.setAttribute(ROOT_ATTR, "");
343
+ root.style.cssText = `position:absolute;left:0;top:0;width:${width}px;height:${height}px;pointer-events:none;z-index:2147483647;outline:none;border:0;box-shadow:none`;
344
+ const layer = svg("svg", {
345
+ width,
346
+ height,
347
+ viewBox: `0 0 ${width} ${height}`,
348
+ style: "position:absolute;left:0;top:0;outline:none",
349
+ });
350
+ root.append(layer);
351
+
352
+ const toView = (r) => ({ x: r.x - view.x, y: r.y - view.y, w: r.w, h: r.h });
353
+ const marks = items.map((item, i) => {
354
+ const { box, n, kind } = item;
355
+ const { pill, arrow, placement } = placed[i];
356
+ const group = svg("g", {
357
+ "data-alan-mark": n,
358
+ "data-kind": kind,
359
+ "data-placement": placement,
360
+ });
361
+ const head = `${arrow.tip.x},${arrow.tip.y} ${arrow.end.x - arrow.dir.y * 3.5},${arrow.end.y + arrow.dir.x * 3.5} ${arrow.end.x + arrow.dir.y * 3.5},${arrow.end.y - arrow.dir.x * 3.5}`;
362
+ group.append(
363
+ svg("rect", {
364
+ x: box.x,
365
+ y: box.y,
366
+ width: box.w,
367
+ height: box.h,
368
+ rx: 6,
369
+ fill: "none",
370
+ stroke: accent,
371
+ "stroke-width": 1.5,
372
+ "stroke-dasharray": KIND_DASH[kind],
373
+ "stroke-linecap": "round",
374
+ }),
375
+ svg("path", {
376
+ d: `M${arrow.from.x},${arrow.from.y} Q${arrow.ctrl.x},${arrow.ctrl.y} ${arrow.end.x},${arrow.end.y}`,
377
+ fill: "none",
378
+ stroke: accent,
379
+ "stroke-width": 1.5,
380
+ "stroke-linecap": "round",
381
+ }),
382
+ svg("polygon", { points: head, fill: accent }),
383
+ svg("rect", {
384
+ x: pill.x,
385
+ y: pill.y,
386
+ width: pill.w,
387
+ height: pill.h,
388
+ rx: pill.h / 2,
389
+ fill: accent,
390
+ }),
391
+ svg("circle", {
392
+ cx: pill.x + 4 + CIRCLE / 2,
393
+ cy: pill.y + pill.h / 2,
394
+ r: CIRCLE / 2,
395
+ fill: dark,
396
+ }),
397
+ text(pill.x + 4 + CIRCLE / 2, pill.y + pill.h / 2, 12, 600, "middle", String(n))
398
+ );
399
+ if (item.label)
400
+ group.append(
401
+ text(pill.x + 4 + CIRCLE + 5, pill.y + pill.h / 2, 12, 500, "start", item.label)
402
+ );
403
+ layer.append(group);
404
+ return {
405
+ n,
406
+ label: item.label,
407
+ kind,
408
+ placement,
409
+ box: toView(box),
410
+ callout: toView(pill),
411
+ arrow: arrow.path.map((p) => ({ x: p.x - view.x, y: p.y - view.y })),
412
+ };
413
+ });
414
+ document.body.append(root);
415
+ return { marks, overlaps, crossings };
416
+ };
417
+
418
+ window.alanMarks = { mark, clear };
419
+ })();