ai-first-os 1.10.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -31
- package/core/CLAUDE.md +48 -12
- package/core/VERSION +1 -1
- package/core/install.sh +173 -52
- package/core/lib/bootstrap.sh +41 -26
- package/core/lib/build-indexes.sh +283 -0
- package/core/lib/capture.sh +126 -55
- package/core/lib/check-resolvable.sh +13 -2
- package/core/lib/close-session.sh +172 -119
- package/core/lib/common.sh +505 -92
- package/core/lib/focus-read.sh +94 -58
- package/core/lib/manual-link.sh +10 -8
- package/core/lib/markdown.py +2 -2
- package/core/lib/migrate-layout.sh +92 -0
- package/core/lib/migrate-root.sh +497 -0
- package/core/lib/migrate_layout.py +2000 -0
- package/core/lib/new-memory.sh +33 -44
- package/core/lib/new-product.sh +11 -13
- package/core/lib/new-workspace.sh +18 -9
- package/core/lib/orchestrator-init.sh +80 -0
- package/core/lib/pack-install.sh +44 -30
- package/core/lib/recall.sh +1 -1
- package/core/lib/recall_index.py +48 -6
- package/core/lib/remote-backup.sh +30 -20
- package/core/lib/rename-heads.sh +8 -8
- package/core/lib/rename-workspaces.sh +3 -3
- package/core/lib/session-read.sh +133 -73
- package/core/lib/session-start.sh +238 -221
- package/core/lib/supersede.sh +199 -3
- package/core/lib/sweep.sh +5 -0
- package/core/manual/COMO-FUNCIONA.md +169 -58
- package/core/manual/HOW-IT-WORKS.md +158 -57
- package/core/resolver.md +4 -2
- package/core/skills/bootstrap.md +63 -44
- package/core/skills/capture.md +15 -8
- package/core/skills/check-resolvable.md +1 -1
- package/core/skills/close-session.md +9 -5
- package/core/skills/grill.md +3 -3
- package/core/skills/migrate-layout.md +48 -0
- package/core/skills/migrate-root.md +64 -0
- package/core/skills/mount-repo.md +6 -6
- package/core/skills/new-memory.md +20 -18
- package/core/skills/new-product.md +4 -3
- package/core/skills/new-spec.md +6 -0
- package/core/skills/new-workspace.md +7 -5
- package/core/skills/orchestrator.md +101 -0
- package/core/skills/supersede.md +14 -0
- package/core/templates/node-repo/context/open-questions.md +3 -0
- package/core/templates/strings.md +396 -271
- package/core/templates/tree.md +22 -27
- package/package.json +1 -1
- package/core/lib/my-wiki-gates.sh +0 -137
- package/core/lib/my-wiki.sh +0 -202
- package/core/lib/my_wiki_build.py +0 -548
- package/core/lib/my_wiki_graph.py +0 -137
- package/core/lib/my_wiki_overview.py +0 -392
- package/core/skills/my-wiki.md +0 -103
- package/core/templates/my-wiki-graph.js +0 -431
- package/core/templates/my-wiki-overview.js +0 -174
- package/core/templates/my-wiki.html +0 -1017
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
/* My Wiki's Graph screen (spec 061). Inlined verbatim into the page by `my_wiki_build.py`, in one
|
|
2
|
-
<script id="wiki-graph"> block, right before `wiki-view` so `WIKIGRAPH` exists when the router
|
|
3
|
-
first runs. No DOM is touched outside a function body, so this whole file loads and its pure
|
|
4
|
-
half (WIKIGRAPH.neighbors/atDate/applyHide/view/radius/layout) runs the same way in a plain
|
|
5
|
-
Node `vm` context as it does in the page — that pure half is what the suite exercises headless,
|
|
6
|
-
the same pattern `wiki-core` set in spec 060. `WIKIGRAPH.mount` is the DOM half; nothing calls
|
|
7
|
-
it outside a real page. */
|
|
8
|
-
var WIKIGRAPH = (function () {
|
|
9
|
-
// One radius per kind, before its own connections grow it (spec 061 C1).
|
|
10
|
-
var BASE_RADIUS = {workspace: 14, entity: 9, initiative: 7, person: 6, document: 4};
|
|
11
|
-
var COLORS = {workspace: 'var(--text)', entity: 'var(--accent)', initiative: '#0f8b8d',
|
|
12
|
-
person: '#d97706', document: 'var(--muted)'};
|
|
13
|
-
var LEGEND_ORDER = ['workspace', 'entity', 'initiative', 'person', 'document'];
|
|
14
|
-
|
|
15
|
-
function radius(kind, degree) {
|
|
16
|
-
var base = BASE_RADIUS[kind] || 5;
|
|
17
|
-
return base + Math.min(degree || 0, 12) * 0.5;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Every neighbour of one node, from the edge list alone — what a hover highlights (C3).
|
|
21
|
-
function neighbors(edges, id) {
|
|
22
|
-
var seen = {}, out = [];
|
|
23
|
-
for (var i = 0; i < edges.length; i++) {
|
|
24
|
-
var e = edges[i], other = null;
|
|
25
|
-
if (e.a === id) other = e.b;
|
|
26
|
-
else if (e.b === id) other = e.a;
|
|
27
|
-
if (other !== null && !seen[other]) { seen[other] = true; out.push(other); }
|
|
28
|
-
}
|
|
29
|
-
return out;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function edgesAmong(edges, ids) {
|
|
33
|
-
return edges.filter(function (e) { return ids[e.a] && ids[e.b]; });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function scope(graph, ws) {
|
|
37
|
-
if (!ws) return graph;
|
|
38
|
-
var nodes = graph.nodes.filter(function (n) { return n.ws === ws; });
|
|
39
|
-
var ids = {};
|
|
40
|
-
nodes.forEach(function (n) { ids[n.id] = true; });
|
|
41
|
-
return {nodes: nodes, edges: edgesAmong(graph.edges, ids), dates: graph.dates};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Only what already existed at `date` — the state one tick of "how it grew" shows (C5). A node
|
|
45
|
-
// with no known first commit is treated as always having been there, never hidden by a date it
|
|
46
|
-
// does not carry.
|
|
47
|
-
function atDate(graph, date) {
|
|
48
|
-
if (!date) return graph;
|
|
49
|
-
var ids = {};
|
|
50
|
-
var nodes = graph.nodes.filter(function (n) {
|
|
51
|
-
var ok = !n.first || n.first <= date;
|
|
52
|
-
if (ok) ids[n.id] = true;
|
|
53
|
-
return ok;
|
|
54
|
-
});
|
|
55
|
-
return {nodes: nodes, edges: edgesAmong(graph.edges, ids), dates: graph.dates};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Hiding a type never recomputes anything about the rest (C4): it is a pure filter on top of
|
|
59
|
-
// whatever scope/date already produced.
|
|
60
|
-
function applyHide(graph, hide) {
|
|
61
|
-
hide = hide || {};
|
|
62
|
-
var nodes = graph.nodes.filter(function (n) { return !hide[n.kind]; });
|
|
63
|
-
var ids = {};
|
|
64
|
-
nodes.forEach(function (n) { ids[n.id] = true; });
|
|
65
|
-
return {nodes: nodes, edges: edgesAmong(graph.edges, ids), dates: graph.dates};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// The one composition point every other filter goes through, headless-testable end to end.
|
|
69
|
-
function view(graph, opts) {
|
|
70
|
-
opts = opts || {};
|
|
71
|
-
var g = scope(graph, opts.ws);
|
|
72
|
-
g = atDate(g, opts.date);
|
|
73
|
-
g = applyHide(g, opts.hide);
|
|
74
|
-
return g;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// A minimal force layout: repulsion between every pair, a spring on every edge, a pull to the
|
|
78
|
-
// centre so a page with no link at all still settles on the canvas instead of flying off it
|
|
79
|
-
// (spec 061: an unlinked page shows loose and dim, never hidden). Fixed tick count, no timers,
|
|
80
|
-
// no DOM — the same run in Node as in the page, which is how C7's 650-node budget is measured.
|
|
81
|
-
function layout(graph, opts) {
|
|
82
|
-
opts = opts || {};
|
|
83
|
-
// 60 ticks is a compromise, not a perfect settle: spec 061's budget is 650 nodes drawn in
|
|
84
|
-
// under 2 seconds, and a rough, organic scatter reads fine for a screen nobody stares at
|
|
85
|
-
// pixel-perfect. More ticks converge tighter but blow the budget well before 650 nodes do.
|
|
86
|
-
var w = opts.width || 760, h = opts.height || 520, ticks = opts.ticks || 60;
|
|
87
|
-
var n = graph.nodes.length;
|
|
88
|
-
var nodes = graph.nodes.map(function (node, i) {
|
|
89
|
-
var a = n ? (i / n) * Math.PI * 2 : 0;
|
|
90
|
-
return {
|
|
91
|
-
id: node.id, kind: node.kind, degree: node.degree,
|
|
92
|
-
x: w / 2 + Math.cos(a) * (Math.min(w, h) / 3),
|
|
93
|
-
y: h / 2 + Math.sin(a) * (Math.min(w, h) / 3),
|
|
94
|
-
vx: 0, vy: 0,
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
var index = {};
|
|
98
|
-
nodes.forEach(function (node, i) { index[node.id] = i; });
|
|
99
|
-
var edges = [];
|
|
100
|
-
for (var e = 0; e < graph.edges.length; e++) {
|
|
101
|
-
var a = index[graph.edges[e].a], b = index[graph.edges[e].b];
|
|
102
|
-
if (a !== undefined && b !== undefined) edges.push({a: a, b: b});
|
|
103
|
-
}
|
|
104
|
-
var REPEL = 2600, SPRING = 0.02, LEN = 70, CENTER = 0.012, DAMP = 0.85;
|
|
105
|
-
for (var t = 0; t < ticks; t++) {
|
|
106
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
107
|
-
var ni = nodes[i];
|
|
108
|
-
for (var j = i + 1; j < nodes.length; j++) {
|
|
109
|
-
var nj = nodes[j];
|
|
110
|
-
var dx = ni.x - nj.x, dy = ni.y - nj.y;
|
|
111
|
-
var d2 = dx * dx + dy * dy + 0.01;
|
|
112
|
-
var f = REPEL / d2;
|
|
113
|
-
var d = Math.sqrt(d2);
|
|
114
|
-
var fx = (dx / d) * f, fy = (dy / d) * f;
|
|
115
|
-
ni.vx += fx; ni.vy += fy;
|
|
116
|
-
nj.vx -= fx; nj.vy -= fy;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for (var k = 0; k < edges.length; k++) {
|
|
120
|
-
var na = nodes[edges[k].a], nb = nodes[edges[k].b];
|
|
121
|
-
var ex = nb.x - na.x, ey = nb.y - na.y;
|
|
122
|
-
var ed = Math.sqrt(ex * ex + ey * ey) || 0.01;
|
|
123
|
-
var stretch = (ed - LEN) * SPRING;
|
|
124
|
-
var sfx = (ex / ed) * stretch, sfy = (ey / ed) * stretch;
|
|
125
|
-
na.vx += sfx; na.vy += sfy;
|
|
126
|
-
nb.vx -= sfx; nb.vy -= sfy;
|
|
127
|
-
}
|
|
128
|
-
for (var m = 0; m < nodes.length; m++) {
|
|
129
|
-
var nm = nodes[m];
|
|
130
|
-
nm.vx += (w / 2 - nm.x) * CENTER;
|
|
131
|
-
nm.vy += (h / 2 - nm.y) * CENTER;
|
|
132
|
-
nm.vx *= DAMP; nm.vy *= DAMP;
|
|
133
|
-
nm.x += nm.vx; nm.y += nm.vy;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return nodes;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
COLORS: COLORS, LEGEND_ORDER: LEGEND_ORDER,
|
|
141
|
-
radius: radius, neighbors: neighbors, scope: scope, atDate: atDate, applyHide: applyHide,
|
|
142
|
-
view: view, layout: layout,
|
|
143
|
-
};
|
|
144
|
-
})();
|
|
145
|
-
if (typeof module !== 'undefined' && module.exports) { module.exports = WIKIGRAPH; }
|
|
146
|
-
|
|
147
|
-
(function () {
|
|
148
|
-
// The DOM half (spec 066): a <canvas> with its own force simulation, pan and zoom, drag, hover
|
|
149
|
-
// highlight, click to open, filters and the time slider. Nothing loads from outside the page.
|
|
150
|
-
function ensureStyle() {
|
|
151
|
-
if (typeof document === 'undefined' || document.getElementById('wiki-graph-style')) return;
|
|
152
|
-
var css =
|
|
153
|
-
'.graph-legend{display:flex;gap:14px;margin-bottom:10px;flex-wrap:wrap;font-size:13px;color:var(--text);align-items:center}' +
|
|
154
|
-
'.graph-legend .sw{width:10px;height:10px;border-radius:999px;display:inline-block;margin-right:6px}' +
|
|
155
|
-
'.graph-filters{margin-left:auto;display:flex;gap:8px}' +
|
|
156
|
-
'.graph-filters .chip{cursor:pointer;user-select:none}' +
|
|
157
|
-
'.graph-wrap{border:1px solid var(--border);background:var(--card);border-radius:12px;overflow:hidden;position:relative}' +
|
|
158
|
-
'.graph-wrap canvas{display:block;width:100%;cursor:grab}' +
|
|
159
|
-
'.graph-wrap canvas.grabbing{cursor:grabbing}' +
|
|
160
|
-
'.graph-hint{position:absolute;right:10px;bottom:8px;font-size:11.5px;color:var(--muted);pointer-events:none}' +
|
|
161
|
-
'.graph-slider-row{display:flex;align-items:center;gap:12px;margin-top:12px}' +
|
|
162
|
-
'.graph-slider-row input[type=range]{flex:1;accent-color:var(--accent)}' +
|
|
163
|
-
'.graph-date{font-family:ui-monospace,Menlo,monospace;font-size:12.5px;color:var(--muted);min-width:86px;text-align:right}';
|
|
164
|
-
var styleTag = document.createElement('style');
|
|
165
|
-
styleTag.id = 'wiki-graph-style';
|
|
166
|
-
styleTag.textContent = css;
|
|
167
|
-
document.head.appendChild(styleTag);
|
|
168
|
-
}
|
|
169
|
-
function esc(s) {
|
|
170
|
-
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
171
|
-
}
|
|
172
|
-
function cssVar(name, fallback) {
|
|
173
|
-
try { var v = getComputedStyle(document.documentElement).getPropertyValue(name).trim(); return v || fallback; } catch (e) { return fallback; }
|
|
174
|
-
}
|
|
175
|
-
function hexA(hex, a) {
|
|
176
|
-
var m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex || '');
|
|
177
|
-
if (!m) return hex;
|
|
178
|
-
return 'rgba(' + parseInt(m[1], 16) + ',' + parseInt(m[2], 16) + ',' + parseInt(m[3], 16) + ',' + a + ')';
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// What survives between visits to the screen inside one visit to the page: the camera, the
|
|
182
|
-
// filters, the date, and where the reader left the nodes.
|
|
183
|
-
var keep = {};
|
|
184
|
-
|
|
185
|
-
WIKIGRAPH.mount = function (root, DATA, T, href, opts) {
|
|
186
|
-
ensureStyle();
|
|
187
|
-
opts = opts || {};
|
|
188
|
-
var full = DATA.graph || {nodes: [], edges: [], dates: []};
|
|
189
|
-
// The builder's edges are the explicit links (about:, paths in backticks, people). The graph
|
|
190
|
-
// also needs the structure the brain already has —a document hangs from its node, an
|
|
191
|
-
// initiative from its entity, an entity from its workspace— or most pages float alone.
|
|
192
|
-
if (!full._structured) {
|
|
193
|
-
var seen = {}; full.edges.forEach(function (e) { seen[e.a + '|' + e.b] = 1; seen[e.b + '|' + e.a] = 1; });
|
|
194
|
-
var homes = {}; (DATA.workspaces || []).forEach(function (w) { homes[w.slug] = w.home; });
|
|
195
|
-
function link(a, b) { if (!a || !b || a === b || seen[a + '|' + b]) return; seen[a + '|' + b] = 1; seen[b + '|' + a] = 1; full.edges.push({a: a, b: b, structural: true}); }
|
|
196
|
-
var pages = DATA.pages || {};
|
|
197
|
-
for (var id in pages) {
|
|
198
|
-
var pg = pages[id];
|
|
199
|
-
// The builder keeps the tree on the node: `docs` are the documents that hang from it,
|
|
200
|
-
// `children` its initiatives, `about` the entity an initiative belongs to.
|
|
201
|
-
(pg.docs || []).forEach(function (d) { var dp = d && (d.path || d); if (pages[dp]) link(dp, id); });
|
|
202
|
-
(pg.children || []).forEach(function (c) { if (pages[c]) link(c, id); });
|
|
203
|
-
if (pg.kind === 'initiative') {
|
|
204
|
-
var ent = pg.about || (pg.fm && pg.fm.about) || '';
|
|
205
|
-
ent = String(ent).replace(/^\.?\/?/, '');
|
|
206
|
-
if (ent && pages[ent]) link(id, ent); else if (homes[pg.ws]) link(id, homes[pg.ws]);
|
|
207
|
-
} else if ((pg.kind === 'entity' || pg.kind === 'person') && homes[pg.ws]) link(id, homes[pg.ws]);
|
|
208
|
-
}
|
|
209
|
-
var deg = {}; full.edges.forEach(function (e) { deg[e.a] = (deg[e.a] || 0) + 1; deg[e.b] = (deg[e.b] || 0) + 1; });
|
|
210
|
-
full.nodes.forEach(function (n) { n.degree = deg[n.id] || 0; });
|
|
211
|
-
full._structured = true;
|
|
212
|
-
}
|
|
213
|
-
var dates = full.dates || [];
|
|
214
|
-
var k = keep[opts.ws] || (keep[opts.ws] = {hide: {document: true, person: false}, labels: false, dateIdx: dates.length ? dates.length - 1 : -1, cam: null, pos: {}});
|
|
215
|
-
var state = {ws: opts.ws, hover: null, drag: null, playing: null, raf: null, alpha: 1};
|
|
216
|
-
var COLORS = {workspace: cssVar('--text', '#1c1b22'), entity: cssVar('--accent', '#4b5563'), initiative: '#0f8b8d', person: '#d97706', document: cssVar('--muted', '#6b6a75')};
|
|
217
|
-
|
|
218
|
-
root.innerHTML =
|
|
219
|
-
'<div class="graph-legend">' +
|
|
220
|
-
[['entity', T('WIKI_GRAPH_ENTITY', 'Entities')], ['initiative', T('WIKI_GRAPH_INITIATIVE', 'Initiatives')], ['person', T('WIKI_GRAPH_PERSON', 'People')], ['document', T('WIKI_GRAPH_DOCUMENT', 'Documents')]]
|
|
221
|
-
.map(function (l) { return '<span><span class="sw" style="background:' + COLORS[l[0]] + '"></span>' + esc(l[1]) + '</span>'; }).join('') +
|
|
222
|
-
'<span class="graph-filters">' +
|
|
223
|
-
'<span class="chip' + (k.hide.document ? '' : ' vio') + '" data-hide="document">' + esc(T('WIKI_GRAPH_SHOW_DOCS', 'Show documents')) + '</span>' +
|
|
224
|
-
'<span class="chip' + (k.hide.person ? '' : ' vio') + '" data-hide="person">' + esc(T('WIKI_GRAPH_SHOW_PEOPLE', 'Show people')) + '</span>' +
|
|
225
|
-
'<label class="chip" style="cursor:pointer;gap:6px"><input type="checkbox" data-labels' + (k.labels ? ' checked' : '') + ' style="margin:0"> ' + esc(T('WIKI_GRAPH_LABELS', 'Labels')) + '</label>' +
|
|
226
|
-
'</span></div>' +
|
|
227
|
-
'<div class="graph-wrap"><canvas></canvas><div class="graph-hint">' + esc(T('WIKI_GRAPH_HINT', 'drag · wheel to zoom · double-click to fit · click opens')) + '</div></div>' +
|
|
228
|
-
(dates.length ? '<div class="graph-slider-row"><span class="muted" style="font-size:13px">' + esc(T('WIKI_GRAPH_GREW', 'How it grew')) + '</span>' +
|
|
229
|
-
'<input type="range" min="0" max="' + (dates.length - 1) + '" value="' + k.dateIdx + '">' +
|
|
230
|
-
'<span class="graph-date"></span><button class="btn" data-play>' + esc(T('WIKI_GRAPH_PLAY', 'Play')) + '</button></div>' : '');
|
|
231
|
-
|
|
232
|
-
var canvas = root.querySelector('canvas'), ctx = canvas.getContext('2d');
|
|
233
|
-
var wrap = root.querySelector('.graph-wrap');
|
|
234
|
-
var W = 0, H = 520, dpr = window.devicePixelRatio || 1;
|
|
235
|
-
function size() {
|
|
236
|
-
W = wrap.clientWidth || 760;
|
|
237
|
-
canvas.width = W * dpr; canvas.height = H * dpr; canvas.style.height = H + 'px';
|
|
238
|
-
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
239
|
-
}
|
|
240
|
-
size();
|
|
241
|
-
|
|
242
|
-
// The graph on screen: the pure half filters by workspace, date and hidden kinds.
|
|
243
|
-
var nodes = [], edges = [], byId = {}, adj = {};
|
|
244
|
-
function rebuild(reheat) {
|
|
245
|
-
var g = WIKIGRAPH.view(full, {ws: state.ws, date: k.dateIdx >= 0 ? dates[k.dateIdx] : null, hide: k.hide});
|
|
246
|
-
var old = {}; nodes.forEach(function (n) { old[n.id] = n; });
|
|
247
|
-
nodes = g.nodes.map(function (n) {
|
|
248
|
-
var p = old[n.id] || k.pos[n.id];
|
|
249
|
-
var r = WIKIGRAPH.radius(n.kind, n.degree) * 1.7;
|
|
250
|
-
return {id: n.id, kind: n.kind, title: n.title, degree: n.degree, r: r,
|
|
251
|
-
x: p ? p.x : (W / 2 + (Math.random() - .5) * W * .6), y: p ? p.y : (H / 2 + (Math.random() - .5) * H * .6),
|
|
252
|
-
vx: 0, vy: 0, fx: p && p.fx != null ? p.fx : null, fy: p && p.fy != null ? p.fy : null};
|
|
253
|
-
});
|
|
254
|
-
byId = {}; nodes.forEach(function (n) { byId[n.id] = n; });
|
|
255
|
-
edges = g.edges.filter(function (e) { return byId[e.a] && byId[e.b]; });
|
|
256
|
-
adj = {}; edges.forEach(function (e) { (adj[e.a] = adj[e.a] || {})[e.b] = 1; (adj[e.b] = adj[e.b] || {})[e.a] = 1; });
|
|
257
|
-
if (reheat) state.alpha = 1;
|
|
258
|
-
if (!k.cam) fit(true);
|
|
259
|
-
loop();
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Camera ------------------------------------------------------------------------
|
|
263
|
-
function fit(silent) {
|
|
264
|
-
if (!nodes.length) { k.cam = {x: 0, y: 0, s: 1}; return; }
|
|
265
|
-
var minX = 1e9, minY = 1e9, maxX = -1e9, maxY = -1e9;
|
|
266
|
-
nodes.forEach(function (n) { minX = Math.min(minX, n.x); maxX = Math.max(maxX, n.x); minY = Math.min(minY, n.y); maxY = Math.max(maxY, n.y); });
|
|
267
|
-
var s = Math.min(2.2, Math.max(.2, .92 * Math.min(W / Math.max(1, maxX - minX + 80), H / Math.max(1, maxY - minY + 80))));
|
|
268
|
-
k.cam = {s: s, x: W / 2 - s * (minX + maxX) / 2, y: H / 2 - s * (minY + maxY) / 2};
|
|
269
|
-
if (!silent) draw();
|
|
270
|
-
}
|
|
271
|
-
function toWorld(px, py) { return {x: (px - k.cam.x) / k.cam.s, y: (py - k.cam.y) / k.cam.s}; }
|
|
272
|
-
|
|
273
|
-
// Physics -----------------------------------------------------------------------
|
|
274
|
-
// Repulsion between every pair (n² is fine for a few hundred nodes), links as springs, a soft
|
|
275
|
-
// pull to the centre, velocity damping, and a temperature that cools until the graph sleeps.
|
|
276
|
-
function tick() {
|
|
277
|
-
var n = nodes.length; if (!n) return;
|
|
278
|
-
var a = state.alpha;
|
|
279
|
-
var k2 = 2600 * a;
|
|
280
|
-
for (var i = 0; i < n; i++) {
|
|
281
|
-
var p = nodes[i];
|
|
282
|
-
for (var j = i + 1; j < n; j++) {
|
|
283
|
-
var q = nodes[j];
|
|
284
|
-
var dx = p.x - q.x, dy = p.y - q.y, d2 = dx * dx + dy * dy + 0.01;
|
|
285
|
-
if (d2 > 90000) continue;
|
|
286
|
-
var f = k2 / d2;
|
|
287
|
-
var fx = dx * f, fy = dy * f;
|
|
288
|
-
p.vx += fx; p.vy += fy; q.vx -= fx; q.vy -= fy;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
var springK = 0.02 * a + 0.002;
|
|
292
|
-
for (var e = 0; e < edges.length; e++) {
|
|
293
|
-
var s1 = byId[edges[e].a], s2 = byId[edges[e].b];
|
|
294
|
-
var ddx = s2.x - s1.x, ddy = s2.y - s1.y, d = Math.sqrt(ddx * ddx + ddy * ddy) + 0.01;
|
|
295
|
-
var rest = 34 + s1.r + s2.r;
|
|
296
|
-
var f2 = (d - rest) * springK;
|
|
297
|
-
var ux = ddx / d * f2, uy = ddy / d * f2;
|
|
298
|
-
s1.vx += ux; s1.vy += uy; s2.vx -= ux; s2.vy -= uy;
|
|
299
|
-
}
|
|
300
|
-
var cx = 0, cy = 0; nodes.forEach(function (m) { cx += m.x; cy += m.y; }); cx /= n; cy /= n;
|
|
301
|
-
nodes.forEach(function (m) {
|
|
302
|
-
m.vx += (cx - m.x) * 0.0015 * a + (W / 2 - cx) * 0.0005;
|
|
303
|
-
m.vy += (cy - m.y) * 0.0015 * a + (H / 2 - cy) * 0.0005;
|
|
304
|
-
if (m.fx != null) { m.x = m.fx; m.y = m.fy; m.vx = 0; m.vy = 0; return; }
|
|
305
|
-
m.vx *= 0.82; m.vy *= 0.82;
|
|
306
|
-
m.x += m.vx; m.y += m.vy;
|
|
307
|
-
});
|
|
308
|
-
state.alpha = Math.max(0, a - 0.008);
|
|
309
|
-
}
|
|
310
|
-
function loop() {
|
|
311
|
-
if (state.raf) return;
|
|
312
|
-
var step = function () {
|
|
313
|
-
state.raf = null;
|
|
314
|
-
if (state.alpha > 0.003 || state.drag) { tick(); draw(); state.raf = requestAnimationFrame(step); }
|
|
315
|
-
else { draw(); nodes.forEach(function (m) { k.pos[m.id] = {x: m.x, y: m.y, fx: m.fx, fy: m.fy}; }); }
|
|
316
|
-
};
|
|
317
|
-
state.raf = requestAnimationFrame(step);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Drawing ----------------------------------------------------------------------
|
|
321
|
-
function draw() {
|
|
322
|
-
ctx.save(); ctx.clearRect(0, 0, W, H);
|
|
323
|
-
ctx.translate(k.cam.x, k.cam.y); ctx.scale(k.cam.s, k.cam.s);
|
|
324
|
-
var hov = state.hover, nb = hov ? (adj[hov] || {}) : null;
|
|
325
|
-
var border = cssVar('--border', '#e5e5e8'), accent = cssVar('--accent', '#4b5563'), text = cssVar('--text', '#1c1b22');
|
|
326
|
-
ctx.lineWidth = 1 / k.cam.s;
|
|
327
|
-
edges.forEach(function (e) {
|
|
328
|
-
var a = byId[e.a], b = byId[e.b];
|
|
329
|
-
var hi = hov && (e.a === hov || e.b === hov);
|
|
330
|
-
ctx.strokeStyle = hi ? accent : (e.structural ? border : accent);
|
|
331
|
-
ctx.globalAlpha = hov ? (hi ? 1 : .15) : (e.structural ? .9 : .55);
|
|
332
|
-
ctx.lineWidth = (hi ? 1.8 : 1) / k.cam.s;
|
|
333
|
-
ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(b.x, b.y); ctx.stroke();
|
|
334
|
-
});
|
|
335
|
-
var labelOK = k.cam.s > 0.55;
|
|
336
|
-
nodes.forEach(function (m) {
|
|
337
|
-
var dim = hov && m.id !== hov && !nb[m.id];
|
|
338
|
-
ctx.globalAlpha = dim ? .18 : 1;
|
|
339
|
-
ctx.fillStyle = COLORS[m.kind] || COLORS.document;
|
|
340
|
-
ctx.beginPath(); ctx.arc(m.x, m.y, m.r, 0, Math.PI * 2); ctx.fill();
|
|
341
|
-
if (m.id === hov) { ctx.strokeStyle = accent; ctx.lineWidth = 2 / k.cam.s; ctx.beginPath(); ctx.arc(m.x, m.y, m.r + 4 / k.cam.s, 0, Math.PI * 2); ctx.stroke(); }
|
|
342
|
-
var showLabel = m.id === hov || (nb && nb[m.id]) || (k.labels && !hov && (m.kind !== 'document' || (labelOK && k.cam.s > 1.1)));
|
|
343
|
-
if (showLabel && (labelOK || m.id === hov || m.kind !== 'document')) {
|
|
344
|
-
ctx.fillStyle = text; ctx.globalAlpha = dim ? .18 : (m.kind === 'document' ? .75 : 1);
|
|
345
|
-
ctx.font = ((m.kind === 'entity' || m.kind === 'workspace' ? 13 : 11.5) / Math.max(k.cam.s, .8)) + 'px ' + cssVar('--font', 'system-ui');
|
|
346
|
-
ctx.fillText(m.title, m.x + m.r + 4 / k.cam.s, m.y + 4 / k.cam.s);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
ctx.restore();
|
|
350
|
-
var dl = root.querySelector('.graph-date'); if (dl) dl.textContent = k.dateIdx >= 0 ? dates[k.dateIdx] : '';
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// Interaction ------------------------------------------------------------------
|
|
354
|
-
function nodeAt(px, py) {
|
|
355
|
-
var w = toWorld(px, py), best = null, bd = 1e9;
|
|
356
|
-
nodes.forEach(function (m) { var dx = m.x - w.x, dy = m.y - w.y, d = dx * dx + dy * dy; var rr = (m.r + 6 / k.cam.s); if (d < rr * rr && d < bd) { bd = d; best = m; } });
|
|
357
|
-
return best;
|
|
358
|
-
}
|
|
359
|
-
function pt(ev) { var r = canvas.getBoundingClientRect(); return {x: ev.clientX - r.left, y: ev.clientY - r.top}; }
|
|
360
|
-
var pressed = null, moved = false;
|
|
361
|
-
canvas.addEventListener('mousedown', function (ev) {
|
|
362
|
-
var p = pt(ev), m = nodeAt(p.x, p.y);
|
|
363
|
-
pressed = {x: p.x, y: p.y, node: m, cam: {x: k.cam.x, y: k.cam.y}}; moved = false;
|
|
364
|
-
if (m) { state.drag = m; m.fx = m.x; m.fy = m.y; state.alpha = Math.max(state.alpha, .3); loop(); }
|
|
365
|
-
canvas.classList.add('grabbing');
|
|
366
|
-
});
|
|
367
|
-
window.addEventListener('mousemove', function (ev) {
|
|
368
|
-
var p = pt(ev);
|
|
369
|
-
if (pressed) {
|
|
370
|
-
if (Math.abs(p.x - pressed.x) + Math.abs(p.y - pressed.y) > 3) moved = true;
|
|
371
|
-
if (pressed.node) { var w = toWorld(p.x, p.y); pressed.node.fx = w.x; pressed.node.fy = w.y; state.alpha = Math.max(state.alpha, .3); loop(); }
|
|
372
|
-
else { k.cam.x = pressed.cam.x + (p.x - pressed.x); k.cam.y = pressed.cam.y + (p.y - pressed.y); draw(); }
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
var m = nodeAt(p.x, p.y), id = m ? m.id : null;
|
|
376
|
-
if (id !== state.hover) { state.hover = id; canvas.style.cursor = m ? 'pointer' : 'grab'; draw(); }
|
|
377
|
-
});
|
|
378
|
-
window.addEventListener('mouseup', function (ev) {
|
|
379
|
-
if (!pressed) return;
|
|
380
|
-
var m = pressed.node;
|
|
381
|
-
// A dropped node stays exactly where it was released — `fx`/`fy` keep pinning it, the same
|
|
382
|
-
// way Obsidian's graph pins a node once dragged (spec 066 C1). It moves again only if
|
|
383
|
-
// someone drags it again; nothing un-pins it on its own.
|
|
384
|
-
if (m) { if (!moved) { location.hash = href(m.id); } state.drag = null; }
|
|
385
|
-
pressed = null; canvas.classList.remove('grabbing'); loop();
|
|
386
|
-
});
|
|
387
|
-
canvas.addEventListener('wheel', function (ev) {
|
|
388
|
-
ev.preventDefault();
|
|
389
|
-
var p = pt(ev), w = toWorld(p.x, p.y);
|
|
390
|
-
var s = Math.min(4, Math.max(.1, k.cam.s * (ev.deltaY < 0 ? 1.12 : 1 / 1.12)));
|
|
391
|
-
k.cam = {s: s, x: p.x - w.x * s, y: p.y - w.y * s};
|
|
392
|
-
draw();
|
|
393
|
-
}, {passive: false});
|
|
394
|
-
canvas.addEventListener('dblclick', function () { fit(); });
|
|
395
|
-
canvas.addEventListener('mouseleave', function () { if (state.hover) { state.hover = null; draw(); } });
|
|
396
|
-
|
|
397
|
-
Array.prototype.forEach.call(root.querySelectorAll('[data-hide]'), function (c) {
|
|
398
|
-
c.onclick = function () { var kind = c.getAttribute('data-hide'); k.hide[kind] = !k.hide[kind]; c.classList.toggle('vio', !k.hide[kind]); rebuild(false); };
|
|
399
|
-
});
|
|
400
|
-
var lb = root.querySelector('[data-labels]');
|
|
401
|
-
if (lb) lb.onchange = function () { k.labels = !!lb.checked; draw(); };
|
|
402
|
-
var slider = root.querySelector('input[type=range]');
|
|
403
|
-
if (slider) slider.oninput = function () { k.dateIdx = parseInt(slider.value, 10); rebuild(false); };
|
|
404
|
-
var play = root.querySelector('[data-play]');
|
|
405
|
-
if (play) play.onclick = function () {
|
|
406
|
-
if (state.playing) { clearInterval(state.playing); state.playing = null; play.textContent = T('WIKI_GRAPH_PLAY', 'Play'); return; }
|
|
407
|
-
k.dateIdx = 0; slider.value = 0; rebuild(true); play.textContent = T('WIKI_GRAPH_PAUSE', 'Pause');
|
|
408
|
-
state.playing = setInterval(function () {
|
|
409
|
-
if (k.dateIdx >= dates.length - 1) { clearInterval(state.playing); state.playing = null; play.textContent = T('WIKI_GRAPH_PLAY', 'Play'); return; }
|
|
410
|
-
k.dateIdx++; slider.value = k.dateIdx; rebuild(false);
|
|
411
|
-
}, 500);
|
|
412
|
-
};
|
|
413
|
-
window.addEventListener('resize', function () { size(); draw(); });
|
|
414
|
-
|
|
415
|
-
rebuild(true);
|
|
416
|
-
// `_debug` is read only by evals/fixtures/wiki-graph-headless.js (spec 066's `canvas` mode),
|
|
417
|
-
// which has no browser to click and drag in. It exposes nothing a real caller uses.
|
|
418
|
-
return {
|
|
419
|
-
unmount: function () { if (state.playing) clearInterval(state.playing); },
|
|
420
|
-
_debug: {
|
|
421
|
-
nodes: function () { return nodes; },
|
|
422
|
-
state: state,
|
|
423
|
-
cam: function () { return k.cam; },
|
|
424
|
-
hide: function () { return k.hide; },
|
|
425
|
-
neighborsOf: function (id) { return Object.keys(adj[id] || {}); },
|
|
426
|
-
colors: COLORS,
|
|
427
|
-
edgeCount: function () { return edges.length; },
|
|
428
|
-
},
|
|
429
|
-
};
|
|
430
|
-
};
|
|
431
|
-
})();
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/* Overview: what is waiting for the person, as the page's first screen (spec 062).
|
|
2
|
-
|
|
3
|
-
It is its own block on purpose. `wiki-core` is the DOM-free logic the suite runs headlessly and
|
|
4
|
-
`wiki-view` is the shell; this one is the first screen's view, and it exposes one function so
|
|
5
|
-
the shell reaches it with a single line. Its icons live here too: the screen's four headings are
|
|
6
|
-
the only place they are used, and the shell's own map stays as it was. */
|
|
7
|
-
var WIKI_OVERVIEW = (function () {
|
|
8
|
-
var ICONS = {
|
|
9
|
-
grid: '<rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/>',
|
|
10
|
-
message: '<path d="M21 12a8 8 0 0 1-11 7.4L4 21l1.6-5A8 8 0 1 1 21 12z"/>',
|
|
11
|
-
gate: '<path d="M4 22V4a1 1 0 0 1 1-1h11l-2 4 2 4H5"/>',
|
|
12
|
-
clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',
|
|
13
|
-
calendar: '<rect x="3" y="4" width="18" height="17" rx="2"/><path d="M8 2v4M16 2v4M3 10h18"/>'
|
|
14
|
-
};
|
|
15
|
-
function svg(name, size) {
|
|
16
|
-
return '<svg width="' + (size || 18) + '" height="' + (size || 18) + '" viewBox="0 0 24 24" ' +
|
|
17
|
-
'fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" ' +
|
|
18
|
-
'stroke-linejoin="round">' + (ICONS[name] || ICONS.grid) + '</svg>';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/* How long ago, with the word the catalog gives it. The number is the builder's; the unit it is
|
|
22
|
-
counted in is a key, never a literal — the page speaks the brain's language. */
|
|
23
|
-
function ago(T, age) {
|
|
24
|
-
if (!age) return '';
|
|
25
|
-
var word = age.unit === 'min' ? T('WIKI_AGO_MIN', 'min')
|
|
26
|
-
: age.unit === 'h' ? T('WIKI_AGO_HOUR', 'h') : T('WIKI_AGO_DAY', 'd');
|
|
27
|
-
return age.n + ' ' + word;
|
|
28
|
-
}
|
|
29
|
-
function days(T, n) {
|
|
30
|
-
if (n === null || n === undefined) return '';
|
|
31
|
-
return n + ' ' + T('WIKI_AGO_DAY', 'd');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function labelChip(T, esc, label) {
|
|
35
|
-
if (label === 'asks') return '<span class="chip hot">' + esc(T('WIKI_THREAD_ASKS', 'asks you')) + '</span>';
|
|
36
|
-
if (label === 'gate1') return '<span class="chip wait">' + esc(T('WIKI_THREAD_GATE1', 'Gate 1')) + '</span>';
|
|
37
|
-
return '<span class="chip ok">' + esc(T('WIKI_THREAD_UNREAD', 'finished · unread')) + '</span>';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function threadRow(T, esc, href, t) {
|
|
41
|
-
var h = ['<div class="li">'];
|
|
42
|
-
h.push('<span style="width:8px;height:8px;border-radius:999px;background:var(--accent);display:inline-block;margin-top:7px;flex-shrink:0"></span>');
|
|
43
|
-
// A thread has no URL a browser can open, so it offers the two things that exist: its focus
|
|
44
|
-
// page in the wiki, and the command that resumes it in Claude Code, copied on click.
|
|
45
|
-
var cmd = 'claude --resume ' + t.id;
|
|
46
|
-
h.push('<div style="min-width:0;flex:1"><div class="t">' + esc(t.title) + '</div>');
|
|
47
|
-
h.push('<div class="d">' + esc(t.says) + '</div>');
|
|
48
|
-
h.push('<div class="d" style="margin-top:6px;display:flex;gap:10px;flex-wrap:wrap">' +
|
|
49
|
-
(t.focus ? '<a href="' + href(t.focus) + '">' + esc(t.focusLabel || t.focus) + '</a>' : '') +
|
|
50
|
-
'<a href="#" class="resume" data-resume="' + esc(cmd) + '" title="' + esc(cmd) + '">' + esc(T('WIKI_THREAD_RESUME', 'Copy the command to resume it')) + '</a>' +
|
|
51
|
-
'</div></div>');
|
|
52
|
-
h.push('<div style="display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0">');
|
|
53
|
-
h.push(labelChip(T, esc, t.label));
|
|
54
|
-
h.push('<span class="muted" style="font-size:12px">' + esc(ago(T, t.age)) + '</span></div>');
|
|
55
|
-
return h.join('') + '</div>';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function threads(T, esc, href, o) {
|
|
59
|
-
var h = ['<h2>' + svg('message') + ' ' + esc(T('WIKI_THREADS', 'Threads waiting for you')) +
|
|
60
|
-
' <span class="muted" style="font-weight:400;font-size:13px">' +
|
|
61
|
-
esc(T('WIKI_THREADS_WINDOW', 'last %s days · grouped by focus').replace('%s', o.days)) +
|
|
62
|
-
'</span></h2>'];
|
|
63
|
-
if (!o.sessions.available) {
|
|
64
|
-
h.push('<div class="note">' + esc(T('WIKI_NO_SESSIONS',
|
|
65
|
-
'No local Claude Code sessions to read on this machine.')) + '</div>');
|
|
66
|
-
return h.join('');
|
|
67
|
-
}
|
|
68
|
-
if (!o.threads.length) {
|
|
69
|
-
h.push('<div class="note">' + esc(T('WIKI_NO_THREADS', 'No thread is waiting for you.')) + '</div>');
|
|
70
|
-
return h.join('');
|
|
71
|
-
}
|
|
72
|
-
h.push('<div class="card" style="padding:4px 16px">');
|
|
73
|
-
var unread = 0;
|
|
74
|
-
o.threads.forEach(function (g) {
|
|
75
|
-
h.push('<div class="grp" style="padding:10px 0 2px">' +
|
|
76
|
-
(g.focus ? '<a href="' + href(g.focus) + '" style="color:inherit">' + esc(g.label) + '</a>' : esc(g.label || T('WIKI_NO_FOCUS', 'No focus'))) + '</div>');
|
|
77
|
-
g.threads.forEach(function (t) {
|
|
78
|
-
if (t.unreadByDefault) unread++;
|
|
79
|
-
h.push(threadRow(T, esc, href, t));
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
h.push('</div>');
|
|
83
|
-
/* The page says WHY a thread is here when the reason is a missing datum, not a fact: there is
|
|
84
|
-
no record of what the person read, so a finished turn is shown, and shown as unverified. */
|
|
85
|
-
if (unread) {
|
|
86
|
-
h.push('<div class="note" style="margin-top:10px">' + esc(T('WIKI_UNREAD_WHY',
|
|
87
|
-
'Claude Code keeps no record of what you opened: a finished thread is shown as unread for lack of that datum.')) +
|
|
88
|
-
'</div>');
|
|
89
|
-
}
|
|
90
|
-
return h.join('');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function gates(T, esc, o) {
|
|
94
|
-
var h = ['<div class="card"><h2 style="margin:0 0 8px">' + svg('gate') + ' ' +
|
|
95
|
-
esc(T('WIKI_GATES', 'Gates')) + '</h2>'];
|
|
96
|
-
if (!o.gates.length) {
|
|
97
|
-
h.push('<div class="d">' + esc(T('WIKI_NO_GATES', 'No gate is open.')) + '</div>');
|
|
98
|
-
}
|
|
99
|
-
o.gates.forEach(function (g) {
|
|
100
|
-
var chip = g.gate === '2'
|
|
101
|
-
? '<span class="chip wait">' + esc(T('WIKI_GATE_2', 'Gate 2 · merge')) + '</span>'
|
|
102
|
-
: '<span class="chip wait">' + esc(T('WIKI_GATE_1', 'Gate 1')) + '</span>';
|
|
103
|
-
var detail = esc(g.repo);
|
|
104
|
-
if (g.branch) detail += ' · ' + esc(g.branch);
|
|
105
|
-
if (g.days !== null && g.days !== undefined) detail += ' · ' + esc(days(T, g.days));
|
|
106
|
-
h.push('<div class="li"><div><div class="t">' + esc(g.title) + '</div>' +
|
|
107
|
-
'<div class="d">' + detail + '</div></div>' + chip + '</div>');
|
|
108
|
-
});
|
|
109
|
-
return h.join('') + '</div>';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function waiting(T, esc, href, rows) {
|
|
113
|
-
var h = ['<div class="card"><h2 style="margin:0 0 8px">' + svg('clock') + ' ' +
|
|
114
|
-
esc(T('WIKI_WAITING_OTHERS', 'Waiting on others')) + '</h2>'];
|
|
115
|
-
if (!rows.length) {
|
|
116
|
-
h.push('<div class="d">' + esc(T('WIKI_NO_WAITING', 'Nobody owes you an answer.')) + '</div>');
|
|
117
|
-
}
|
|
118
|
-
rows.forEach(function (r) {
|
|
119
|
-
var detail = r.reason ? esc(r.reason) + ' · ' : '';
|
|
120
|
-
h.push('<div class="li"><div><div class="t">' + esc(r.who) + '</div><div class="d">' +
|
|
121
|
-
detail + '<a href="' + href(r.path) + '">' + esc(r.title) + '</a></div></div>' +
|
|
122
|
-
'<span class="chip' + (r.days !== null && r.days >= 14 ? ' hot' : '') + '">' +
|
|
123
|
-
esc(days(T, r.days)) + '</span></div>');
|
|
124
|
-
});
|
|
125
|
-
return h.join('') + '</div>';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function week(T, esc, href, rows, span) {
|
|
129
|
-
var h = ['<h2>' + svg('calendar') + ' ' + esc(T('WIKI_THIS_WEEK', 'This week')) +
|
|
130
|
-
' <span class="muted" style="font-weight:400;font-size:13px">' +
|
|
131
|
-
esc(T('WIKI_WEEK_WINDOW', 'next %s days').replace('%s', span)) + '</span></h2>'];
|
|
132
|
-
if (!rows.length) {
|
|
133
|
-
return h.join('') + '<div class="note">' +
|
|
134
|
-
esc(T('WIKI_NO_WEEK', 'Nothing has a date this week.')) + '</div>';
|
|
135
|
-
}
|
|
136
|
-
h.push('<div class="card" style="padding:4px 16px">');
|
|
137
|
-
rows.forEach(function (r) {
|
|
138
|
-
var detail = '<a href="' + href(r.path) + '">' + esc(r.node) + '</a>';
|
|
139
|
-
if (r.reason) detail += ' · ' + esc(r.reason);
|
|
140
|
-
h.push('<div class="li"><div><div class="t">' + esc(r.text) + '</div><div class="d">' +
|
|
141
|
-
detail + '</div></div><span class="chip' + (r.days <= 1 ? ' hot' : ' wait') + '">' +
|
|
142
|
-
esc(r.date) + '</span></div>');
|
|
143
|
-
});
|
|
144
|
-
return h.join('') + '</div>';
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/* The screen. It takes what the shell already has —the payload, the workspace on screen, the
|
|
148
|
-
catalog and the two helpers— and gives back HTML: no DOM, no state of its own. */
|
|
149
|
-
function view(DATA, w, T, esc, href) {
|
|
150
|
-
var o = DATA.overview;
|
|
151
|
-
if (!o) return '<h1>' + esc(T('WIKI_OVERVIEW', 'Overview')) + '</h1>';
|
|
152
|
-
var slug = w ? w.slug : '';
|
|
153
|
-
var asks = 0;
|
|
154
|
-
o.threads.forEach(function (g) {
|
|
155
|
-
g.threads.forEach(function (t) { if (t.label !== 'unread') asks++; });
|
|
156
|
-
});
|
|
157
|
-
var wait = (o.waiting[slug] || []), days7 = (o.week_items[slug] || []);
|
|
158
|
-
var h = ['<h1>' + esc(T('WIKI_OVERVIEW', 'Overview')) + '</h1>'];
|
|
159
|
-
h.push('<div class="meta"><span>' + esc(w ? w.title : '') + '</span><span>·</span><span>' +
|
|
160
|
-
esc(o.today) + '</span>');
|
|
161
|
-
h.push('<span class="chip hot">' + asks + ' ' + esc(T('WIKI_COUNT_THREADS', 'threads wait for you')) + '</span>');
|
|
162
|
-
h.push('<span class="chip wait">' + o.gates.length + ' ' + esc(T('WIKI_COUNT_GATES', 'gates')) + '</span>');
|
|
163
|
-
h.push('<span class="chip">' + wait.length + ' ' + esc(T('WIKI_COUNT_WAITING', 'waiting on others')) + '</span>');
|
|
164
|
-
h.push('</div>');
|
|
165
|
-
h.push(threads(T, esc, href, o));
|
|
166
|
-
h.push('<div class="cards" style="margin-top:22px">' + gates(T, esc, o) +
|
|
167
|
-
waiting(T, esc, href, wait) + '</div>');
|
|
168
|
-
h.push(week(T, esc, href, days7, o.week));
|
|
169
|
-
return h.join('');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {view: view, icon: svg};
|
|
173
|
-
})();
|
|
174
|
-
if (typeof module !== 'undefined' && module.exports) { module.exports = WIKI_OVERVIEW; }
|