yadflow 4.10.0 → 4.12.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +14 -3
  3. package/bin/commands.mjs +7 -1
  4. package/bin/yad.mjs +163 -16
  5. package/cli/agent-guard-worker.mjs +13 -0
  6. package/cli/agent-guard.mjs +1053 -57
  7. package/cli/agent-rules.mjs +59 -3
  8. package/cli/argv-flags.mjs +2 -2
  9. package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
  10. package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
  11. package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
  12. package/cli/brain/vendor/graphology-library.min.js +2 -0
  13. package/cli/brain/vendor/graphology.umd.min.js +2 -0
  14. package/cli/brain/vendor/sigma.min.js +1369 -0
  15. package/cli/brain/view/app.js +382 -0
  16. package/cli/brain/view/index.html +63 -0
  17. package/cli/brain/view/live.css +228 -0
  18. package/cli/brain/view/live.html +110 -0
  19. package/cli/brain/view/live.js +884 -0
  20. package/cli/brain/view/style.css +141 -0
  21. package/cli/brain-about.mjs +206 -0
  22. package/cli/brain-activity.mjs +285 -0
  23. package/cli/brain-skills.mjs +118 -0
  24. package/cli/brain-vendor.mjs +71 -0
  25. package/cli/brain-view.mjs +345 -0
  26. package/cli/brain.mjs +810 -0
  27. package/cli/brand-cmd.mjs +326 -0
  28. package/cli/brand.mjs +327 -0
  29. package/cli/ci-check.mjs +3 -3
  30. package/cli/doctor.mjs +145 -14
  31. package/cli/epic-state.mjs +93 -1
  32. package/cli/epic.mjs +15 -3
  33. package/cli/errors.mjs +2 -1
  34. package/cli/find-product.mjs +69 -15
  35. package/cli/foundation-publish.mjs +256 -0
  36. package/cli/gate.mjs +29 -3
  37. package/cli/git-read.mjs +38 -0
  38. package/cli/guard-stream.mjs +409 -0
  39. package/cli/guide.mjs +26 -3
  40. package/cli/hook.mjs +59 -9
  41. package/cli/issues-act.mjs +57 -13
  42. package/cli/issues-write.mjs +19 -6
  43. package/cli/issues.mjs +69 -24
  44. package/cli/lib.mjs +37 -2
  45. package/cli/local-page.mjs +138 -0
  46. package/cli/local-setup-record.mjs +71 -0
  47. package/cli/local-setup-steps.mjs +186 -0
  48. package/cli/local-setup.mjs +611 -0
  49. package/cli/machine.mjs +1 -1
  50. package/cli/manifest.mjs +55 -0
  51. package/cli/map/view/app.js +712 -0
  52. package/cli/map/view/index.html +50 -0
  53. package/cli/map/view/style.css +142 -0
  54. package/cli/map-view.mjs +190 -0
  55. package/cli/map.mjs +637 -0
  56. package/cli/members.mjs +9 -15
  57. package/cli/next.mjs +1 -1
  58. package/cli/openpr.mjs +2 -2
  59. package/cli/plain-text.mjs +22 -0
  60. package/cli/plan.mjs +310 -36
  61. package/cli/platform.mjs +5 -5
  62. package/cli/product-index.mjs +1 -1
  63. package/cli/protection.mjs +32 -0
  64. package/cli/reconcile.mjs +61 -13
  65. package/cli/report.mjs +9 -3
  66. package/cli/reports-dir.mjs +393 -0
  67. package/cli/reports.mjs +65 -0
  68. package/cli/run-checks.mjs +5 -2
  69. package/cli/scan.mjs +4 -6
  70. package/cli/secret-text.mjs +66 -0
  71. package/cli/setup.mjs +54 -8
  72. package/cli/standup.mjs +94 -72
  73. package/cli/status.mjs +6 -5
  74. package/cli/test-agents-file.mjs +614 -8
  75. package/cli/test-brain-activity.mjs +753 -0
  76. package/cli/test-brain-view.mjs +381 -0
  77. package/cli/test-brain.mjs +795 -0
  78. package/cli/test-brand.mjs +558 -0
  79. package/cli/test-guide.mjs +438 -0
  80. package/cli/test-local-setup.mjs +1188 -0
  81. package/cli/test-machine.mjs +59 -0
  82. package/cli/test-map.mjs +615 -0
  83. package/cli/test-reports.mjs +382 -0
  84. package/cli/test-run-checks.mjs +4 -0
  85. package/cli/test-worktree.mjs +24 -3
  86. package/cli/toolbox-connect.mjs +21 -6
  87. package/cli/toolbox.mjs +74 -5
  88. package/cli/update-commit.mjs +118 -9
  89. package/cli/usage.mjs +17 -7
  90. package/cli/workspace.mjs +11 -2
  91. package/package.json +8 -4
  92. package/skills/sdlc/module-help.csv +1 -0
  93. package/skills/yad-architecture/SKILL.md +22 -4
  94. package/skills/yad-brand/SKILL.md +69 -0
  95. package/skills/yad-change/SKILL.md +3 -1
  96. package/skills/yad-change/references/triage.md +2 -0
  97. package/skills/yad-checks/SKILL.md +2 -0
  98. package/skills/yad-checks/references/check-gates.md +8 -5
  99. package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
  100. package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
  101. package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
  102. package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
  103. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
  104. package/skills/yad-checks/templates/hooks/local-setup-notice.mjs +96 -0
  105. package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
  106. package/skills/yad-connect-repos/SKILL.md +14 -0
  107. package/skills/yad-discovery/SKILL.md +11 -0
  108. package/skills/yad-discovery/references/foundation-schema.md +11 -0
  109. package/skills/yad-docs/templates/app/package-lock.json +18 -10
  110. package/skills/yad-docs/templates/app/package.json +6 -1
  111. package/skills/yad-epic/SKILL.md +3 -0
  112. package/skills/yad-epic/references/state-schema.md +35 -1
  113. package/skills/yad-guide/SKILL.md +10 -7
  114. package/skills/yad-implement/SKILL.md +76 -15
  115. package/skills/yad-issues/SKILL.md +2 -1
  116. package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
  117. package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
  118. package/skills/yad-spec/SKILL.md +19 -0
  119. package/skills/yad-stories/SKILL.md +22 -4
  120. package/skills/yad-stories/references/story-schema.md +1 -1
@@ -0,0 +1,382 @@
1
+ // The project brain's page (E177). It only DRAWS: what to show, the colours, sizes and filters all come
2
+ // from the view model built by cli/brain-view.mjs. Every name comes from a file anyone can edit, so text is
3
+ // only ever set with textContent — never innerHTML.
4
+ /* global graphology, graphologyLibrary, Sigma */
5
+ (function () {
6
+ 'use strict';
7
+
8
+ var $ = function (id) { return document.getElementById(id); };
9
+ function el(tag, text, cls) {
10
+ var e = document.createElement(tag);
11
+ if (text !== undefined && text !== null) e.textContent = String(text);
12
+ if (cls) e.className = cls;
13
+ return e;
14
+ }
15
+ function clear(node) { while (node.firstChild) node.removeChild(node.firstChild); }
16
+ function notice(parts) {
17
+ var n = $('notice');
18
+ clear(n);
19
+ if (!parts) { n.hidden = true; return; }
20
+ parts.forEach(function (p) { n.appendChild(p); });
21
+ n.hidden = false;
22
+ }
23
+
24
+ // The model: inline in the file written by --html, or from the server, which needs the page's key.
25
+ function load() {
26
+ var inline = document.getElementById('yad-brain-data');
27
+ if (inline) return Promise.resolve(JSON.parse(inline.textContent));
28
+ var key = new URLSearchParams(location.search).get('t') || '';
29
+ return fetch('graph.json?t=' + encodeURIComponent(key), { cache: 'no-store' }).then(function (r) {
30
+ return r.json().then(function (body) {
31
+ if (!r.ok) throw new Error(String(body.error || 'the brain could not be read') + (body.hint ? ' — ' + body.hint : ''));
32
+ return body;
33
+ });
34
+ });
35
+ }
36
+
37
+ var FADED = 'rgba(148, 163, 184, 0.45)';
38
+ var EDGE = 'rgba(71, 85, 105, 0.6)';
39
+ var EDGE_INFERRED = 'rgba(100, 116, 139, 0.3)';
40
+
41
+ // Label colours come from the page's theme (style.css), so a label is light on the dark theme and dark on the
42
+ // light one. Sigma's own default is black text, and a white box on hover.
43
+ function theme() {
44
+ var css = getComputedStyle(document.documentElement);
45
+ var get = function (name, fallback) { return (css.getPropertyValue(name) || '').trim() || fallback; };
46
+ return { text: get('--text', '#0f172a'), panel: get('--panel', '#ffffff'), line: get('--line', '#e2e8f0') };
47
+ }
48
+ function drawHover(context, d, s) {
49
+ if (!d.label) return; // a faded node has no label: no empty box
50
+ var t = theme();
51
+ var size = s.labelSize;
52
+ context.font = s.labelWeight + ' ' + size + 'px ' + s.labelFont;
53
+ var w = context.measureText(d.label || '').width;
54
+ var x = d.x + d.size + 3; // where sigma draws the plain label, so it does not move on hover
55
+ var y = d.y;
56
+ context.fillStyle = t.panel;
57
+ context.strokeStyle = t.line;
58
+ context.lineWidth = 1;
59
+ context.beginPath();
60
+ if (context.roundRect) context.roundRect(x - 6, y - size / 2 - 5, w + 12, size + 10, 6); else context.rect(x - 6, y - size / 2 - 5, w + 12, size + 10);
61
+ context.fill(); context.stroke();
62
+ context.fillStyle = t.text;
63
+ context.fillText(d.label || '', x, y + size / 3);
64
+ }
65
+
66
+ function start(model) {
67
+ var nodes = model.nodes;
68
+ var edges = model.edges;
69
+ var outOf = nodes.map(function () { return []; });
70
+ var into = nodes.map(function () { return []; });
71
+ edges.forEach(function (e, k) { outOf[e.s].push(k); into[e.t].push(k); });
72
+
73
+ var state = { work: true, code: true, allCode: false, filter: null, selected: null, near: null, found: null };
74
+
75
+ // ---- the header
76
+ var c = model.counts;
77
+ var built = model.meta.builtAt ? new Date(model.meta.builtAt).toLocaleString() : 'an unknown time';
78
+ $('summary').textContent = c.nodes + ' nodes (' + c.work + ' work, ' + c.code + ' code) · ' + c.edges + ' links · built ' + built;
79
+ if (model.meta.codeBehind && model.meta.codeBehind.length) {
80
+ $('fresh').textContent = 'The code moved in ' + model.meta.codeBehind.join(', ') + ' since this was built. Run yad brain build for a current picture.';
81
+ $('fresh').hidden = false;
82
+ }
83
+
84
+ // ---- the key
85
+ model.legend.forEach(function (k) {
86
+ var li = el('li');
87
+ var dot = el('span', null, 'dot');
88
+ dot.style.background = k.colour;
89
+ li.appendChild(dot);
90
+ li.appendChild(el('span', k.legend));
91
+ $('legend').appendChild(li);
92
+ });
93
+
94
+ // ---- the filters
95
+ function fill(select, list) {
96
+ list.forEach(function (f, i) {
97
+ var o = el('option', f.label === f.id.replace(/^\w+:/, '') ? f.label : f.label + ' (' + f.id.replace(/^\w+:/, '') + ')');
98
+ o.value = String(i);
99
+ select.appendChild(o);
100
+ });
101
+ }
102
+ fill($('f-epic'), model.filters.epics);
103
+ fill($('f-story'), model.filters.stories);
104
+ fill($('f-repo'), model.filters.repos);
105
+
106
+ function shown(i) {
107
+ var n = nodes[i];
108
+ if (n.layer === 'work' && !state.work) return false;
109
+ if (n.layer === 'code' && !state.code) return false;
110
+ if (!state.allCode && !n.inDefault) return false;
111
+ if (state.filter && !state.filter.has(i)) return false;
112
+ return true;
113
+ }
114
+
115
+ // ---- the graph: every node that can be shown without "all the code", or every node with it
116
+ var Graph = graphology.MultiDirectedGraph || graphology;
117
+ var graph = null;
118
+ var renderer = null;
119
+ function build() {
120
+ graph = new Graph();
121
+ nodes.forEach(function (n, i) {
122
+ if (!state.allCode && !n.inDefault) return;
123
+ graph.addNode(String(i), { label: n.label, size: n.size, color: n.colour, x: 0, y: 0 });
124
+ });
125
+ edges.forEach(function (e, k) {
126
+ if (graph.hasNode(String(e.s)) && graph.hasNode(String(e.t))) {
127
+ graph.addEdgeWithKey(String(k), String(e.s), String(e.t), { size: e.confidence === 'EXTRACTED' ? 1 : 0.6, color: e.confidence === 'EXTRACTED' ? EDGE : EDGE_INFERRED });
128
+ }
129
+ });
130
+ // The same brain draws the same picture: a circle to start from, then a fixed number of layout steps.
131
+ graphologyLibrary.layout.circular.assign(graph);
132
+ var order = graph.order;
133
+ if (order > 1) {
134
+ var settings = graphologyLibrary.layoutForceAtlas2.inferSettings(graph);
135
+ settings.barnesHutOptimize = order > 800;
136
+ graphologyLibrary.layoutForceAtlas2.assign(graph, { iterations: order < 500 ? 300 : order < 2000 ? 150 : 60, settings: settings });
137
+ }
138
+ }
139
+
140
+ function neighbourSet(i) {
141
+ var s = new Set([i]);
142
+ outOf[i].forEach(function (k) { s.add(edges[k].t); });
143
+ into[i].forEach(function (k) { s.add(edges[k].s); });
144
+ return s;
145
+ }
146
+
147
+ function draw() {
148
+ if (renderer) { renderer.kill(); renderer = null; }
149
+ try {
150
+ renderer = new Sigma(graph, $('graph'), {
151
+ defaultEdgeType: 'arrow',
152
+ labelRenderedSizeThreshold: 7,
153
+ labelColor: { color: theme().text },
154
+ labelFont: getComputedStyle(document.body).fontFamily,
155
+ defaultDrawNodeHover: drawHover,
156
+ zIndex: true,
157
+ nodeReducer: function (key, data) {
158
+ var i = Number(key);
159
+ var res = Object.assign({}, data);
160
+ if (!shown(i)) { res.hidden = true; return res; }
161
+ // A faded node is never highlighted: sigma would draw an empty label box for it.
162
+ if (state.selected !== null && !state.near.has(i)) { res.color = FADED; res.label = ''; res.zIndex = 0; return res; }
163
+ if (state.selected !== null) { res.zIndex = 1; res.forceLabel = true; if (i === state.selected) res.highlighted = true; }
164
+ if (state.found && state.found.has(i)) { res.highlighted = true; res.forceLabel = true; }
165
+ return res;
166
+ },
167
+ edgeReducer: function (key, data) {
168
+ var e = edges[Number(key)];
169
+ var res = Object.assign({}, data);
170
+ if (!shown(e.s) || !shown(e.t)) { res.hidden = true; return res; }
171
+ if (state.selected !== null && e.s !== state.selected && e.t !== state.selected) res.hidden = true;
172
+ return res;
173
+ },
174
+ });
175
+ } catch {
176
+ notice([el('strong', 'This browser cannot draw the graph. '), el('span', 'It needs WebGL, which is turned off or not available here. Search and the details panel still work.')]);
177
+ return;
178
+ }
179
+ renderer.on('clickNode', function (ev) { if (!justDragged) select(Number(ev.node)); });
180
+ renderer.on('clickStage', function () { if (!justDragged) select(null); });
181
+ // Press and hold a node to drag it: it is selected at once, so its links stay lit while it moves, and the
182
+ // camera holds still (no pan, no re-fit) until the button is let go.
183
+ var dragged = null;
184
+ var justDragged = false;
185
+ renderer.on('downNode', function (ev) {
186
+ // The left button only: sigma never reports a right or middle button's release, so such a drag would
187
+ // never end.
188
+ var o = ev.event.original;
189
+ if (o && o.button !== undefined && o.button !== 0) return;
190
+ dragged = ev.node;
191
+ renderer.getContainer().style.cursor = 'grabbing';
192
+ justDragged = false;
193
+ if (!renderer.getCustomBBox()) renderer.setCustomBBox(renderer.getBBox());
194
+ if (state.selected !== Number(ev.node)) select(Number(ev.node));
195
+ });
196
+ renderer.on('moveBody', function (ev) {
197
+ if (dragged === null) return;
198
+ // The button came up where no mouseup reached the page (the window lost focus): the drag is over.
199
+ if (ev.event.original.buttons === 0 && !('touches' in ev.event.original)) { drop(); return; }
200
+ var at = renderer.viewportToGraph(ev.event);
201
+ graph.mergeNodeAttributes(dragged, { x: at.x, y: at.y });
202
+ justDragged = true;
203
+ ev.preventSigmaDefault();
204
+ if (ev.event.original.cancelable) ev.event.original.preventDefault();
205
+ ev.event.original.stopPropagation();
206
+ });
207
+ var drop = function () {
208
+ if (dragged === null) return;
209
+ dragged = null;
210
+ renderer.getContainer().style.cursor = '';
211
+ // The click that follows a drag must not select or clear anything.
212
+ setTimeout(function () { justDragged = false; }, 0);
213
+ };
214
+ renderer.on('enterNode', function () { renderer.getContainer().style.cursor = 'grab'; });
215
+ renderer.on('leaveNode', function () { if (dragged === null) renderer.getContainer().style.cursor = ''; });
216
+ renderer.on('upNode', drop);
217
+ renderer.on('upStage', drop);
218
+ renderer.getMouseCaptor().on('mouseup', drop);
219
+ }
220
+
221
+ function refresh() { if (renderer) renderer.refresh(); }
222
+
223
+ function focus(i) {
224
+ if (!renderer || !graph.hasNode(String(i))) return;
225
+ var d = renderer.getNodeDisplayData(String(i));
226
+ if (d) renderer.getCamera().animate({ x: d.x, y: d.y, ratio: 0.35 }, { duration: 400 });
227
+ }
228
+
229
+ // ---- the details panel
230
+ function row(dl, name, value) {
231
+ if (value === undefined || value === null || value === '') return;
232
+ dl.appendChild(el('dt', name));
233
+ dl.appendChild(el('dd', value));
234
+ }
235
+ function linkList(title, ks, other) {
236
+ var box = $('details');
237
+ if (!ks.length) return;
238
+ box.appendChild(el('h3', title + ' (' + ks.length + ')'));
239
+ var ul = el('ul', null, 'links');
240
+ ks.slice(0, 150).forEach(function (k) {
241
+ var e = edges[k];
242
+ var j = other(e);
243
+ var n = nodes[j];
244
+ var li = el('li');
245
+ var b = el('button');
246
+ b.type = 'button';
247
+ b.appendChild(el('span', e.relation + (e.confidence === 'EXTRACTED' ? '' : ' · ' + e.confidence.toLowerCase()) + ' ', 'rel' + (e.confidence === 'EXTRACTED' ? '' : ' inferred')));
248
+ b.appendChild(el('span', n.label));
249
+ b.appendChild(el('span', ' ' + n.kind, 'rel'));
250
+ b.addEventListener('click', function () { select(j, true); });
251
+ li.appendChild(b);
252
+ ul.appendChild(li);
253
+ });
254
+ if (ks.length > 150) ul.appendChild(el('li', '… and ' + (ks.length - 150) + ' more', 'muted'));
255
+ box.appendChild(ul);
256
+ }
257
+ function select(i, move) {
258
+ // A node outside the drawn graph (code the work does not name): draw all the code first, when that is
259
+ // small enough to do without asking.
260
+ if (i !== null && graph && !graph.hasNode(String(i)) && !state.allCode && nodes.length <= model.warnAbove) {
261
+ $('all-code').checked = true;
262
+ state.allCode = true;
263
+ build();
264
+ draw();
265
+ }
266
+ state.selected = i;
267
+ state.near = i === null ? null : neighbourSet(i);
268
+ var box = $('details');
269
+ clear(box);
270
+ if (i === null) {
271
+ box.appendChild(el('p', 'Click a node to see what it is and what it links to.', 'muted'));
272
+ refresh();
273
+ return;
274
+ }
275
+ var n = nodes[i];
276
+ var kind = model.legend.find(function (k) { return k.kind === n.kind; });
277
+ box.appendChild(el('span', kind ? kind.legend : n.kind, 'chip'));
278
+ box.appendChild(el('h2', n.label));
279
+ var dl = el('dl');
280
+ row(dl, 'Id', n.id);
281
+ row(dl, 'Repo', n.repo);
282
+ row(dl, 'File', n.file ? n.file + (n.at ? ' ' + n.at : '') : null);
283
+ row(dl, 'Step', n.step);
284
+ row(dl, 'Status', n.status);
285
+ row(dl, 'Type', n.type);
286
+ row(dl, 'About', n.summary);
287
+ box.appendChild(dl);
288
+ if (n.missing) box.appendChild(el('p', 'A task declares this file, but the code graph does not hold it.', 'banner warn'));
289
+ if (!shown(i)) box.appendChild(el('p', 'This node is hidden by the current filters or the "Show" choices.', 'muted small'));
290
+ linkList('Links out', outOf[i], function (e) { return e.t; });
291
+ linkList('Links in', into[i], function (e) { return e.s; });
292
+ refresh();
293
+ if (move) focus(i);
294
+ }
295
+
296
+ // ---- search
297
+ $('search').addEventListener('input', function () {
298
+ var q = this.value.trim().toLowerCase();
299
+ var list = $('results');
300
+ clear(list);
301
+ if (!q) { state.found = null; refresh(); return; }
302
+ // Best first: a label that IS the text, then one that starts with it, then one that holds it, then an id
303
+ // or a file that holds it; the work items before the code at each level.
304
+ var scored = [];
305
+ for (var i = 0; i < nodes.length; i++) {
306
+ var n = nodes[i];
307
+ var label = String(n.label).toLowerCase();
308
+ var rank = label === q ? 0 : label.indexOf(q) === 0 ? 1 : label.indexOf(q) !== -1 ? 2
309
+ : n.id.toLowerCase().indexOf(q) !== -1 || (n.file && n.file.toLowerCase().indexOf(q) !== -1) ? 3 : -1;
310
+ if (rank !== -1) scored.push([rank * 2 + (n.layer === 'work' ? 0 : 1), i]);
311
+ }
312
+ scored.sort(function (a, b) { return a[0] - b[0] || a[1] - b[1]; });
313
+ var hits = scored.slice(0, 200).map(function (x) { return x[1]; });
314
+ state.found = new Set(hits);
315
+ hits.slice(0, 20).forEach(function (j) {
316
+ var li = el('li');
317
+ var b = el('button');
318
+ b.type = 'button';
319
+ b.appendChild(el('span', nodes[j].label));
320
+ b.appendChild(el('span', ' ' + nodes[j].kind, 'rel'));
321
+ b.addEventListener('click', function () { select(j, true); });
322
+ li.appendChild(b);
323
+ list.appendChild(li);
324
+ });
325
+ if (!hits.length) list.appendChild(el('li', 'Nothing matches.', 'muted'));
326
+ else if (scored.length > 20) list.appendChild(el('li', scored.length + ' match; the best 20 are listed', 'muted small'));
327
+ refresh();
328
+ });
329
+
330
+ // ---- the "Show" choices and the filters
331
+ $('layer-work').addEventListener('change', function () { state.work = this.checked; refresh(); });
332
+ $('layer-code').addEventListener('change', function () { state.code = this.checked; refresh(); });
333
+ function drawAllCode(on) {
334
+ state.allCode = on;
335
+ build();
336
+ draw();
337
+ // A selected node the smaller view does not hold is let go, rather than drawing all the code again
338
+ // (review 1: unticking "All the code" undid itself).
339
+ select(state.selected !== null && graph.hasNode(String(state.selected)) ? state.selected : null);
340
+ }
341
+ $('all-code').addEventListener('change', function () {
342
+ var box = this;
343
+ if (box.checked && nodes.length > model.warnAbove) {
344
+ box.checked = false;
345
+ var go = el('button', 'Draw all ' + nodes.length + ' nodes', 'button');
346
+ go.type = 'button';
347
+ go.addEventListener('click', function () { notice(null); box.checked = true; drawAllCode(true); });
348
+ var no = el('button', 'Keep the smaller view', 'button');
349
+ no.type = 'button';
350
+ no.addEventListener('click', function () { notice(null); });
351
+ notice([el('p', 'The whole brain has ' + nodes.length + ' nodes. Drawing them all can make this tab slow for a while.'), go, el('span', ' '), no]);
352
+ return;
353
+ }
354
+ drawAllCode(box.checked);
355
+ });
356
+ var selects = { epics: $('f-epic'), stories: $('f-story'), repos: $('f-repo') };
357
+ Object.keys(selects).forEach(function (kind) {
358
+ selects[kind].addEventListener('change', function () {
359
+ Object.keys(selects).forEach(function (other) { if (other !== kind) selects[other].value = ''; });
360
+ state.filter = this.value === '' ? null : new Set(model.filters[kind][Number(this.value)].nodes);
361
+ select(null);
362
+ if (renderer) renderer.getCamera().animate({ x: 0.5, y: 0.5, ratio: 1 }, { duration: 300 });
363
+ });
364
+ });
365
+ $('reset').addEventListener('click', function () {
366
+ Object.keys(selects).forEach(function (k) { selects[k].value = ''; });
367
+ state.filter = null;
368
+ select(null);
369
+ });
370
+
371
+ build();
372
+ draw();
373
+ // The system switched between light and dark while the page is open: change the label colour in place, so the
374
+ // camera stays where the person left it (the hover box reads the theme each time it draws).
375
+ try { window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function () { if (renderer) renderer.setSetting('labelColor', { color: theme().text }); }); } catch { /* an old browser keeps its first colours */ }
376
+ }
377
+
378
+ load().then(start, function (err) {
379
+ $('summary').textContent = 'The brain could not be loaded.';
380
+ notice([el('strong', 'Nothing to draw. '), el('span', err && err.message ? err.message : String(err))]);
381
+ });
382
+ })();
@@ -0,0 +1,63 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src data:; connect-src 'self'; base-uri 'none'; form-action 'none'">
7
+ <meta name="referrer" content="no-referrer">
8
+ <title>Project brain</title>
9
+ <link rel="stylesheet" href="style.css?t=__TOKEN__">
10
+ </head>
11
+ <body>
12
+ <header class="top">
13
+ <div class="brand">
14
+ <h1>Project brain</h1>
15
+ <p id="summary" class="muted">Loading…</p>
16
+ </div>
17
+ <p id="fresh" class="banner warn" hidden></p>
18
+ </header>
19
+ <main class="layout">
20
+ <aside class="controls" aria-label="Find and filter">
21
+ <section>
22
+ <label for="search" class="label">Find a node</label>
23
+ <input id="search" type="search" placeholder="A name, a file or an id" autocomplete="off" spellcheck="false">
24
+ <ul id="results" class="results"></ul>
25
+ </section>
26
+ <section>
27
+ <h2 class="label">Show</h2>
28
+ <label class="check"><input type="checkbox" id="layer-work" checked> Work items</label>
29
+ <label class="check"><input type="checkbox" id="layer-code" checked> Code</label>
30
+ <label class="check"><input type="checkbox" id="all-code"> All the code, not only what the work names</label>
31
+ </section>
32
+ <section>
33
+ <label for="f-epic" class="label">Epic</label>
34
+ <select id="f-epic"><option value="">All epics</option></select>
35
+ <label for="f-story" class="label">Story</label>
36
+ <select id="f-story"><option value="">All stories</option></select>
37
+ <label for="f-repo" class="label">Repo</label>
38
+ <select id="f-repo"><option value="">All repos</option></select>
39
+ <button id="reset" type="button" class="button">Clear the filters</button>
40
+ </section>
41
+ <section>
42
+ <h2 class="label">Key</h2>
43
+ <ul id="legend" class="legend"></ul>
44
+ <p class="muted small">A solid line is read from a file (extracted). A faint line is a match yadflow inferred.</p>
45
+ </section>
46
+ </aside>
47
+ <section class="stage" aria-label="The graph">
48
+ <div id="graph" class="graph"></div>
49
+ <div id="notice" class="notice" hidden></div>
50
+ </section>
51
+ <aside id="details" class="details" aria-live="polite">
52
+ <p class="muted">Click a node to see what it is and what it links to.</p>
53
+ </aside>
54
+ </main>
55
+ <!--SCRIPTS-->
56
+ <!--SERVED:start-->
57
+ <script src="vendor/graphology.umd.min.js?t=__TOKEN__"></script>
58
+ <script src="vendor/graphology-library.min.js?t=__TOKEN__"></script>
59
+ <script src="vendor/sigma.min.js?t=__TOKEN__"></script>
60
+ <script src="app.js?t=__TOKEN__"></script>
61
+ <!--SERVED:end-->
62
+ </body>
63
+ </html>
@@ -0,0 +1,228 @@
1
+ /* The Observatory (E178): the brain as a night sky, lit by what the agent touches.
2
+ One bold thing — the comets crossing the sky. Everything around it is quiet instrument glass. */
3
+ :root {
4
+ --sky-0: #060a18;
5
+ --sky-1: #0c1430;
6
+ --haze: rgba(98, 76, 168, 0.22);
7
+ --ink: #e6ecff;
8
+ --ink-2: #aab5d6;
9
+ --ink-3: #6f7ba0;
10
+ --glass: rgba(14, 21, 46, 0.66);
11
+ --rule: rgba(173, 190, 255, 0.12);
12
+ --read: #38bdf8;
13
+ --search: #fbbf24;
14
+ --edit: #f472b6;
15
+ --run: #a78bfa;
16
+ --yad: #34d399;
17
+ --warn: #fb7185;
18
+ --sans: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
19
+ --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;
20
+ color-scheme: dark;
21
+ }
22
+ * { box-sizing: border-box; }
23
+ html, body { height: 100%; margin: 0; }
24
+ body {
25
+ background:
26
+ radial-gradient(1200px 700px at 72% 18%, var(--haze), transparent 60%),
27
+ radial-gradient(900px 600px at 10% 90%, rgba(20, 90, 140, 0.18), transparent 60%),
28
+ linear-gradient(180deg, var(--sky-1), var(--sky-0) 70%);
29
+ color: var(--ink);
30
+ font: 15px/1.45 var(--sans);
31
+ display: grid;
32
+ grid-template-rows: auto 1fr auto;
33
+ overflow: hidden;
34
+ }
35
+ [hidden] { display: none !important; }
36
+ .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
37
+ .stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
38
+ .bar, .deck, .river { position: relative; z-index: 1; }
39
+ button { font: inherit; color: inherit; }
40
+ :focus-visible { outline: 2px solid var(--read); outline-offset: 2px; }
41
+ .quiet { color: var(--ink-3); margin: 0; }
42
+ .small { font-size: 13px; }
43
+
44
+ /* ---- the top bar ---- */
45
+ .bar {
46
+ display: flex;
47
+ align-items: center;
48
+ gap: 28px;
49
+ padding: 14px 22px;
50
+ border-bottom: 1px solid var(--rule);
51
+ }
52
+ .mark { display: flex; align-items: center; gap: 10px; min-width: 120px; }
53
+ .pulse {
54
+ width: 10px; height: 10px; border-radius: 50%;
55
+ background: var(--ink-3);
56
+ box-shadow: 0 0 0 0 transparent;
57
+ }
58
+ .pulse.is-live { background: var(--yad); animation: breathe 2.4s ease-in-out infinite; }
59
+ .pulse.is-idle { background: var(--ink-3); }
60
+ .pulse.is-replay { background: var(--search); }
61
+ @keyframes breathe {
62
+ 0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
63
+ 50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
64
+ }
65
+ .mode { font-weight: 600; letter-spacing: 0.01em; }
66
+ .where { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
67
+ .where-story { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
68
+ .where-task { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
69
+ .limit {
70
+ margin: 0;
71
+ color: var(--ink-2);
72
+ font-size: 13px;
73
+ padding: 5px 12px;
74
+ border: 1px solid var(--rule);
75
+ border-radius: 999px;
76
+ white-space: nowrap;
77
+ }
78
+
79
+ /* ---- the deck: Now | sky | Plan ---- */
80
+ .deck {
81
+ min-height: 0;
82
+ display: grid;
83
+ grid-template-columns: 300px 1fr 330px;
84
+ }
85
+ .now, .plan {
86
+ background: var(--glass);
87
+ backdrop-filter: blur(14px);
88
+ -webkit-backdrop-filter: blur(14px);
89
+ overflow-y: auto;
90
+ padding: 22px 22px 18px;
91
+ }
92
+ .now { border-right: 1px solid var(--rule); }
93
+ .plan { border-left: 1px solid var(--rule); }
94
+
95
+ .now-op { font-size: 28px; font-weight: 600; line-height: 1.1; color: var(--ink); transition: color 0.4s; }
96
+ .now-path.is-quiet { font-family: var(--sans); color: var(--ink-2); }
97
+ .now-path {
98
+ margin-top: 8px;
99
+ font: 500 15px/1.4 var(--mono);
100
+ color: var(--ink);
101
+ overflow-wrap: anywhere;
102
+ min-height: 2.8em;
103
+ }
104
+ .now-when { margin-top: 6px; color: var(--ink-3); font-size: 13px; min-height: 1.2em; }
105
+ .tally { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 14px; }
106
+ .tally li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: baseline; }
107
+ .tally-n { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
108
+ .tally-l { color: var(--ink-2); }
109
+ .tally .spark { grid-column: 1 / -1; width: 100%; height: 26px; margin-top: 4px; }
110
+ .tally li[data-op="read"] .tally-n { color: var(--read); }
111
+ .tally li[data-op="search"] .tally-n { color: var(--search); }
112
+ .tally li[data-op="edit"] .tally-n { color: var(--edit); }
113
+ .tally li[data-op="run"] .tally-n { color: var(--run); }
114
+ .sessions { margin-top: 24px; display: grid; gap: 6px; }
115
+ .sessions label { color: var(--ink-2); font-size: 13px; }
116
+ select {
117
+ width: 100%; max-width: 100%;
118
+ background: rgba(6, 10, 24, 0.7); color: var(--ink);
119
+ border: 1px solid var(--rule); border-radius: 8px; padding: 7px 9px; font: inherit;
120
+ }
121
+
122
+ /* ---- the sky ---- */
123
+ .sky { position: relative; min-width: 0; min-height: 0; }
124
+ .graph, .fx { position: absolute; inset: 0; width: 100%; height: 100%; }
125
+ .fx { pointer-events: none; }
126
+ .sky-tools { position: absolute; right: 16px; top: 14px; display: flex; gap: 6px; }
127
+ .tool {
128
+ background: rgba(10, 16, 36, 0.72);
129
+ border: 1px solid var(--rule);
130
+ border-radius: 8px;
131
+ padding: 6px 11px;
132
+ color: var(--ink-2);
133
+ cursor: pointer;
134
+ font-size: 13px;
135
+ }
136
+ .tool:hover { color: var(--ink); border-color: rgba(173, 190, 255, 0.3); }
137
+ .tool[aria-pressed="true"] { color: var(--ink); border-color: rgba(56, 189, 248, 0.55); background: rgba(56, 189, 248, 0.12); }
138
+ .tool-live.is-on { color: #052e1f; background: var(--yad); border-color: var(--yad); }
139
+ .toast {
140
+ position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
141
+ margin: 0; padding: 8px 14px; border-radius: 10px;
142
+ background: rgba(10, 16, 36, 0.9); border: 1px solid var(--rule); color: var(--ink-2); font-size: 13px;
143
+ }
144
+ .empty {
145
+ position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
146
+ width: min(520px, calc(100% - 32px));
147
+ display: grid; grid-template-columns: auto 1fr; column-gap: 18px; align-items: center;
148
+ padding: 18px 22px; border-radius: 16px;
149
+ background: rgba(10, 16, 36, 0.78); border: 1px solid var(--rule);
150
+ backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
151
+ pointer-events: none;
152
+ }
153
+ .empty .empty-ring { grid-row: 1 / span 2; }
154
+ .empty-ring {
155
+ width: 44px; height: 44px; border-radius: 50%;
156
+ border: 1px solid rgba(56, 189, 248, 0.45);
157
+ box-shadow: 0 0 40px rgba(56, 189, 248, 0.25), inset 0 0 30px rgba(56, 189, 248, 0.15);
158
+ animation: ring 3.2s ease-in-out infinite;
159
+ }
160
+ @keyframes ring { 0%, 100% { transform: scale(0.92); opacity: 0.6; } 50% { transform: scale(1.04); opacity: 1; } }
161
+ .empty-title { margin: 0; font-size: 17px; font-weight: 600; }
162
+ .empty-hint { margin: 0; max-width: 44ch; color: var(--ink-2); }
163
+ .empty-hint code { font-family: var(--mono); font-size: 13px; color: var(--ink); }
164
+ .inspect {
165
+ position: absolute; z-index: 3; max-width: 320px;
166
+ padding: 12px 14px; border-radius: 12px;
167
+ background: rgba(10, 16, 36, 0.94); border: 1px solid var(--rule);
168
+ box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
169
+ font-size: 13px; color: var(--ink-2);
170
+ }
171
+ .inspect strong { display: block; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
172
+ .inspect .ipath { font-family: var(--mono); overflow-wrap: anywhere; margin-top: 2px; }
173
+ .inspect .icounts { display: flex; gap: 12px; margin-top: 8px; }
174
+
175
+ /* ---- plan and reality ---- */
176
+ .plan-h { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
177
+ .plan h3 { margin: 22px 0 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
178
+ .plan-task .story { color: var(--ink-2); font-size: 13px; margin: 0; }
179
+ .plan-task .task { font-size: 16px; font-weight: 600; margin: 2px 0 10px; overflow-wrap: anywhere; }
180
+ .meter { height: 6px; border-radius: 3px; background: rgba(173, 190, 255, 0.12); overflow: hidden; }
181
+ .meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--edit), #f9a8d4); border-radius: 3px; transition: width 0.5s ease; }
182
+ .meter-l { margin: 6px 0 10px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
183
+ .files, .paths { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
184
+ .files li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: baseline; font: 13px/1.45 var(--mono); overflow-wrap: anywhere; }
185
+ .files .st { font-family: var(--sans); text-align: center; }
186
+ .files .is-edit .st { color: var(--edit); }
187
+ .files .is-read .st { color: var(--read); }
188
+ .files .is-none { color: var(--ink-3); }
189
+ .paths li { font: 13px/1.45 var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
190
+ .plan-out h3 { color: var(--warn); }
191
+ .plan-out .paths li { color: #fecdd3; }
192
+ .plan-touched h3 span { font-variant-numeric: tabular-nums; }
193
+ details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
194
+ details .paths { margin-top: 6px; }
195
+ .note { margin: 18px 0 0; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(251, 191, 36, 0.35); color: #fde68a; font-size: 13px; }
196
+
197
+ /* ---- the river ---- */
198
+ .river {
199
+ border-top: 1px solid var(--rule);
200
+ background: rgba(6, 10, 24, 0.82);
201
+ padding: 10px 22px 12px;
202
+ }
203
+ .river-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
204
+ .speeds, .spans { display: flex; gap: 4px; }
205
+ .spans { margin-left: auto; }
206
+ .river-wrap { position: relative; }
207
+ .river-canvas { display: block; width: 100%; height: 76px; cursor: ew-resize; border-radius: 8px; }
208
+ .river-tip {
209
+ position: absolute; bottom: 84px; transform: translateX(-50%);
210
+ padding: 6px 10px; border-radius: 8px; white-space: nowrap;
211
+ background: rgba(10, 16, 36, 0.95); border: 1px solid var(--rule);
212
+ font-size: 12px; color: var(--ink-2); pointer-events: none;
213
+ }
214
+ .river-tip b { color: var(--ink); font-weight: 600; }
215
+ .river-ends { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
216
+
217
+ @media (max-width: 1100px) {
218
+ body { overflow: auto; }
219
+ .deck { grid-template-columns: 1fr; grid-template-rows: 58vh auto auto; }
220
+ .sky { order: 1; }
221
+ .now { order: 2; border-right: 0; border-top: 1px solid var(--rule); }
222
+ .plan { order: 3; border-left: 0; border-top: 1px solid var(--rule); }
223
+ .limit { display: none; }
224
+ }
225
+ @media (prefers-reduced-motion: reduce) {
226
+ .pulse.is-live, .empty-ring { animation: none; }
227
+ .meter > span, .now-op { transition: none; }
228
+ }