truemap-cli 0.5.0 → 0.5.1
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 +3 -3
- package/kit/truemap.css +4 -0
- package/package.json +1 -1
- package/skills/truemap/SKILL.md +3 -2
- package/src/changes.js +10 -1
- package/src/check.js +4 -1
- package/src/cli.js +59 -8
- package/src/common.js +12 -1
- package/src/guide.md +28 -6
- package/src/plan.js +1 -1
- package/src/server.js +103 -25
- package/src/theme.js +46 -0
- package/src/ui/sdk.js +137 -20
- package/src/ui/workspace.css +39 -0
- package/src/ui/workspace.html +8 -6
- package/src/ui/workspace.js +109 -39
package/src/theme.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Dark mode follows the system unless the user picks one. The stylesheets keep plain
|
|
2
|
+
// `@media (prefers-color-scheme: dark)` blocks; this turns each into rules that also answer to a choice:
|
|
3
|
+
// <html data-theme="dark"> always dark <html data-theme="light"> always light
|
|
4
|
+
// For a shadow root, the host carries the choice as a class instead (tm-dark / tm-light).
|
|
5
|
+
|
|
6
|
+
function blocks(css) {
|
|
7
|
+
// top-level `@media (prefers-color-scheme: dark) { ... }` blocks, with their positions
|
|
8
|
+
const out = [];
|
|
9
|
+
const re = /@media\s*\(\s*prefers-color-scheme\s*:\s*dark\s*\)\s*\{/g;
|
|
10
|
+
let m;
|
|
11
|
+
while ((m = re.exec(css))) {
|
|
12
|
+
let depth = 1; let i = re.lastIndex;
|
|
13
|
+
for (; i < css.length && depth; i++) { if (css[i] === '{') depth++; else if (css[i] === '}') depth--; }
|
|
14
|
+
out.push({ start: m.index, bodyStart: re.lastIndex, end: i });
|
|
15
|
+
re.lastIndex = i;
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function scopeRules(body, pick) {
|
|
21
|
+
// `sel, sel { decls }` pairs (no nested blocks inside a colour-scheme block)
|
|
22
|
+
return body.replace(/([^{}]+)\{([^{}]*)\}/g, (all, sels, decls) => `${sels.split(',').map((x) => pick(x.trim())).filter(Boolean).join(', ')} {${decls}}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** CSS for a document: dark when chosen, or when the system is dark and light was not chosen. */
|
|
26
|
+
export function themeable(css, { host = false } = {}) {
|
|
27
|
+
const found = blocks(css);
|
|
28
|
+
if (!found.length) return css;
|
|
29
|
+
const on = host ? ':host(.tm-dark)' : ':root[data-theme="dark"]';
|
|
30
|
+
const notOff = host ? ':host(:not(.tm-light))' : ':root:not([data-theme="light"])';
|
|
31
|
+
const scope = (prefix) => (sel) => {
|
|
32
|
+
if (!sel) return '';
|
|
33
|
+
if (!host && sel.startsWith(':root')) return prefix + sel.slice(5);
|
|
34
|
+
if (!host && /^html\b/.test(sel)) return prefix.replace(':root', 'html') + sel.slice(4);
|
|
35
|
+
return `${prefix} ${sel}`;
|
|
36
|
+
};
|
|
37
|
+
let out = ''; let at = 0; const forced = [];
|
|
38
|
+
for (const b of found) {
|
|
39
|
+
const body = css.slice(b.bodyStart, b.end - 1);
|
|
40
|
+
out += css.slice(at, b.bodyStart) + scopeRules(body, scope(notOff)) + '}';
|
|
41
|
+
forced.push(scopeRules(body, scope(on)));
|
|
42
|
+
at = b.end;
|
|
43
|
+
}
|
|
44
|
+
const scheme = host ? '' : ':root[data-theme="light"] { color-scheme: light; }\n:root[data-theme="dark"] { color-scheme: dark; }\n';
|
|
45
|
+
return `${out}${css.slice(at)}\n/* the user's choice */\n${scheme}${forced.join('\n')}\n`;
|
|
46
|
+
}
|
package/src/ui/sdk.js
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
const drawWires = () => { window.truemapDiagram?.draw(); window.truemapWires?.draw(); markWires(); };
|
|
52
52
|
let wireTimer = null;
|
|
53
|
-
const scheduleWires = () => { clearTimeout(wireTimer); wireTimer = setTimeout(() => { drawWires(); placePins(); }, 40); };
|
|
53
|
+
const scheduleWires = () => { clearTimeout(wireTimer); wireTimer = setTimeout(() => { drawWires(); placePins(); placePlanAct(); }, 40); };
|
|
54
54
|
|
|
55
55
|
// ---------- focus: the agent (or a chat link) points at boxes ----------
|
|
56
56
|
let focusSet = []; let focusNote = null; let hotBox = null;
|
|
@@ -155,6 +155,19 @@
|
|
|
155
155
|
for (const w of document.querySelectorAll('.tm-dg-edge, .tm-dg-head, .tm-dg-label')) w.classList.toggle('is-sel', !!el?.id && (w.dataset.from === el.id || w.dataset.to === el.id));
|
|
156
156
|
if (!el && document.activeElement?.matches?.('.tm-node, .tm-step')) document.activeElement.blur();
|
|
157
157
|
}
|
|
158
|
+
// Click a box: a small card beside it with what it is and a comment field, so your eyes stay on the map.
|
|
159
|
+
// If the inspector is already open on the right, it follows the box.
|
|
160
|
+
function openBox(box) {
|
|
161
|
+
// a second click on the selected box lets go of it
|
|
162
|
+
if (selected === box) { select(null); post({ type: 'deselect' }); return; }
|
|
163
|
+
select(box);
|
|
164
|
+
post({ type: 'peek-if-open', page: pagePath(), box: boxInfo(box) });
|
|
165
|
+
}
|
|
166
|
+
function cardFor(box) {
|
|
167
|
+
select(box);
|
|
168
|
+
const existing = [...notes.values()].find((n) => n.el === box);
|
|
169
|
+
openCard({ target: box, noteId: existing?.id || null });
|
|
170
|
+
}
|
|
158
171
|
function peek(el) {
|
|
159
172
|
select(el);
|
|
160
173
|
const r = el.getBoundingClientRect();
|
|
@@ -279,9 +292,17 @@
|
|
|
279
292
|
shadow.innerHTML = `<style>
|
|
280
293
|
:host { all: initial; }
|
|
281
294
|
* { box-sizing: border-box; }
|
|
282
|
-
.card { position: absolute; width:
|
|
295
|
+
.card { position: absolute; z-index: 10; width: 360px; background: #fff; color: #141413; border: 1px solid #d2d2cb; border-radius: 10px;
|
|
283
296
|
box-shadow: 0 12px 32px -12px rgba(20,20,19,.28); font: 14px/1.45 "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif; padding: 12px; }
|
|
284
|
-
.what { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin: 0 2px
|
|
297
|
+
.what { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin: 0 2px 6px; }
|
|
298
|
+
.card.viewing { width: 320px; }
|
|
299
|
+
.card.viewing textarea, .card.viewing .suggest, .card.viewing [data-act="add"], .card.viewing [data-act="cancel"], .card.viewing .hint { display: none; }
|
|
300
|
+
.card:not(.viewing) [data-act="comment"] { display: none; }
|
|
301
|
+
.card.viewing .foot { justify-content: flex-start; margin-top: 4px; }
|
|
302
|
+
.card.viewing .sum { margin-bottom: 6px; }
|
|
303
|
+
.sum { margin: 0 2px 10px; font-size: 13px; line-height: 1.45; color: #4a4a45; }
|
|
304
|
+
.sum .flag { margin-top: 4px; font-size: 12px; color: #a35f00; }
|
|
305
|
+
@media (prefers-color-scheme: dark) { .sum { color: #c4c4bd; } .sum .flag { color: #e0a548; } }
|
|
285
306
|
.what b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
|
286
307
|
.what code { font: 11.5px "Commit Mono", ui-monospace, Consolas, monospace; color: #9a9a92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
|
|
287
308
|
textarea { width: 100%; min-height: 72px; max-height: 220px; resize: none; font: inherit; color: inherit; background: #fafaf9; border: 1px solid #e6e6e1; border-radius: 7px; padding: 9px 10px; outline: none; }
|
|
@@ -290,6 +311,8 @@
|
|
|
290
311
|
.suggest button { all: unset; cursor: pointer; font-size: 12.5px; color: #141413; }
|
|
291
312
|
.suggest button:hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
292
313
|
.foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
|
|
314
|
+
.foot .btn { white-space: nowrap; }
|
|
315
|
+
.foot [data-act="details"] { padding-left: 2px; text-decoration: underline; text-underline-offset: 3px; }
|
|
293
316
|
.hint { flex: 1; font-size: 11.5px; color: #9a9a92; line-height: 1.3; }
|
|
294
317
|
.btn { all: unset; cursor: pointer; font: 500 13px/1 "Instrument Sans", system-ui, sans-serif; padding: 8px 11px; border-radius: 6px; color: #6c6c65; }
|
|
295
318
|
.btn:hover { background: #f2f2ef; color: #141413; }
|
|
@@ -320,9 +343,66 @@
|
|
|
320
343
|
.btn.primary { background: #f2f2ee; color: #141413; }
|
|
321
344
|
.pin { border-color: #161615; }
|
|
322
345
|
}
|
|
323
|
-
|
|
346
|
+
.planact { position: absolute; display: flex; gap: 4px; padding: 4px; background: #fff; border: 1px solid #d2d2cb; border-radius: 999px; box-shadow: 0 8px 22px -10px rgba(20,20,19,.4); pointer-events: auto; z-index: 3; animation: pa-in .22s cubic-bezier(.2,.8,.3,1.2) both; }
|
|
347
|
+
@keyframes pa-in { from { opacity: 0; transform: translateY(4px) scale(.92); } to { opacity: 1; transform: none; } }
|
|
348
|
+
.planact button { all: unset; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; color: #141413; transition: transform .12s ease, background-color .12s ease; }
|
|
349
|
+
.planact button:hover { background: #f2f2ef; transform: scale(1.1); }
|
|
350
|
+
.planact button.ok { background: #141413; color: #fff; }
|
|
351
|
+
.planact button.ok:hover { background: #3a3a36; }
|
|
352
|
+
.planact button:focus-visible { outline: 2px solid #141413; outline-offset: 2px; }
|
|
353
|
+
.planact svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
|
|
354
|
+
.planact .wait { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #2f7a4f; }
|
|
355
|
+
.planact .wait.revise { color: #6c6c65; animation: pa-pulse 1.4s ease-in-out infinite; }
|
|
356
|
+
@keyframes pa-pulse { 50% { opacity: .35; } }
|
|
357
|
+
@media (prefers-reduced-motion: reduce) { .planact, .planact .wait.revise { animation: none; } .planact button { transition: none; } }
|
|
358
|
+
@media (prefers-color-scheme: dark) {
|
|
359
|
+
.planact { background: #1b1b1a; border-color: #44443f; }
|
|
360
|
+
.planact button { color: #f2f2ee; } .planact button:hover { background: #252523; }
|
|
361
|
+
.planact button.ok { background: #f2f2ee; color: #141413; }
|
|
362
|
+
.planact .wait { color: #7cc49c; }
|
|
363
|
+
}
|
|
364
|
+
</style><div id="rings"></div><div id="pins"></div><div id="slot"></div><div id="planact"></div>`;
|
|
365
|
+
{ const st = shadow.querySelector('style'); if (typeof tmThemeable === 'function') st.textContent = tmThemeable(st.textContent, { host: true }); }
|
|
366
|
+
const applyTheme = (t) => {
|
|
367
|
+
if (t === 'light' || t === 'dark') document.documentElement.setAttribute('data-theme', t); else document.documentElement.removeAttribute('data-theme');
|
|
368
|
+
host.classList.toggle('tm-dark', t === 'dark'); host.classList.toggle('tm-light', t === 'light');
|
|
369
|
+
};
|
|
370
|
+
applyTheme(document.documentElement.getAttribute('data-theme'));
|
|
324
371
|
const pinsEl = shadow.getElementById('pins');
|
|
325
372
|
const slot = shadow.getElementById('slot');
|
|
373
|
+
const planActEl = shadow.getElementById('planact');
|
|
374
|
+
let planNow = null;
|
|
375
|
+
const ICON = {
|
|
376
|
+
ok: '<svg viewBox="0 0 16 16"><path d="M3 8.5 6.5 12 13 4.5"/></svg>',
|
|
377
|
+
no: '<svg viewBox="0 0 16 16"><path d="M4 4l8 8M12 4l-8 8"/></svg>',
|
|
378
|
+
ask: '<svg viewBox="0 0 16 16"><path d="M3 3.5h10v7H7.5L4.5 13v-2.5H3z"/></svg>',
|
|
379
|
+
};
|
|
380
|
+
// The plan's actions sit next to the boxes it adds or changes, where your eyes already are.
|
|
381
|
+
function placePlanAct() {
|
|
382
|
+
planActEl.innerHTML = '';
|
|
383
|
+
const p = planNow;
|
|
384
|
+
if (!p || !['review', 'revise', 'approved'].includes(p.status)) return;
|
|
385
|
+
const els = [...document.querySelectorAll('[data-plan]')].filter((el) => el.isConnected && el.getBoundingClientRect().width);
|
|
386
|
+
if (!els.length) return;
|
|
387
|
+
mount();
|
|
388
|
+
const rs = els.map((el) => el.getBoundingClientRect());
|
|
389
|
+
const u = { l: Math.min(...rs.map((r) => r.left)) + scrollX, t: Math.min(...rs.map((r) => r.top)) + scrollY, r: Math.max(...rs.map((r) => r.right)) + scrollX, b: Math.max(...rs.map((r) => r.bottom)) + scrollY };
|
|
390
|
+
const box = document.createElement('div'); box.className = 'planact'; box.setAttribute('role', 'group'); box.setAttribute('aria-label', 'Plan');
|
|
391
|
+
if (p.status === 'review') box.innerHTML = `<button class="ok" data-pa="approve" title="Approve the plan" aria-label="Approve the plan">${ICON.ok}</button><button data-pa="reject" title="Reject the plan" aria-label="Reject the plan">${ICON.no}</button><button data-pa="ask" title="Ask or comment on the plan" aria-label="Ask or comment on the plan">${ICON.ask}</button>`;
|
|
392
|
+
else box.innerHTML = p.status === 'revise' ? `<span class="wait revise" title="Waiting for the revised plan">${ICON.ask}</span>` : `<span class="wait" title="Approved">${ICON.ok}</span>`;
|
|
393
|
+
box.title = p.title;
|
|
394
|
+
planActEl.appendChild(box);
|
|
395
|
+
const vw = document.documentElement.clientWidth; const w = box.offsetWidth; const h = box.offsetHeight;
|
|
396
|
+
let left = u.r + 10; let top = u.t - h / 2;
|
|
397
|
+
if (left + w > scrollX + vw - 8) { left = Math.max(scrollX + 8, u.r - w); top = u.t - h - 14; }
|
|
398
|
+
if (top < scrollY + 4) top = u.b + 10;
|
|
399
|
+
box.style.left = `${left}px`; box.style.top = `${top}px`;
|
|
400
|
+
box.onclick = (e) => {
|
|
401
|
+
const act = e.target.closest('[data-pa]')?.dataset.pa; if (!act) return;
|
|
402
|
+
if (act === 'ask') { const r = box.getBoundingClientRect(); openCard({ text: p.title, rect: docRect(r), planComment: true }); return; }
|
|
403
|
+
post({ type: 'plan-act', act });
|
|
404
|
+
};
|
|
405
|
+
}
|
|
326
406
|
rings = shadow.getElementById('rings');
|
|
327
407
|
const mount = () => { if (!host.isConnected) document.body.appendChild(host); };
|
|
328
408
|
|
|
@@ -342,24 +422,40 @@
|
|
|
342
422
|
}
|
|
343
423
|
function docRect(r) { return { left: r.left + scrollX, top: r.top + scrollY, right: r.right + scrollX, bottom: r.bottom + scrollY, width: r.width, height: r.height }; }
|
|
344
424
|
|
|
345
|
-
function openCard({ target = null, text = null, rect, noteId = null }) {
|
|
425
|
+
function openCard({ target = null, text = null, rect, noteId = null, planComment = false, view = false }) {
|
|
346
426
|
closeCard(); hideSelectBtn(); mount(); setHover(null);
|
|
347
427
|
const existing = noteId ? notes.get(noteId) : null;
|
|
348
428
|
const sel = getSelection();
|
|
349
429
|
const range = existing ? existing.range || null : (text && sel?.rangeCount ? sel.getRangeAt(0).cloneRange() : null);
|
|
350
|
-
const label = existing?.label || (target ? labelOf(target) : clean(text, 60));
|
|
430
|
+
const label = existing?.label || (target ? clean(target.getAttribute('data-name'), 60) || labelOf(target) : clean(text, 60));
|
|
351
431
|
const src = existing?.src ?? (target ? target.closest('[data-src]')?.getAttribute('data-src') || '' : (text && rangeSrc()) || '');
|
|
352
432
|
const el = document.createElement('div');
|
|
353
|
-
el.className = 'card'; el.setAttribute('role', 'dialog'); el.setAttribute('aria-label', 'Comment');
|
|
354
|
-
el.innerHTML = `<div class="what"><b></b><code></code></div><textarea rows="3"></textarea>
|
|
433
|
+
el.className = view ? 'card viewing' : 'card'; el.setAttribute('role', 'dialog'); el.setAttribute('aria-label', view ? 'About this box' : 'Comment');
|
|
434
|
+
el.innerHTML = `<div class="what"><b></b><code></code></div><div class="sum"></div><textarea rows="3"></textarea>
|
|
355
435
|
<div class="suggest"></div>
|
|
356
|
-
<div class="foot"
|
|
436
|
+
<div class="foot">${view ? '<button class="btn primary" data-act="comment" type="button" title="Or double-click the box">Comment</button>' : ''}${target ? '<button class="btn" data-act="details" type="button">Details</button>' : ''}<span class="hint"></span>${existing ? `<button class="btn danger" data-act="remove" type="button">${T.remove}</button>` : `<button class="btn" data-act="cancel" type="button">${T.cancel}</button>`}<button class="btn primary" data-act="add" type="button">${planComment ? 'Send' : existing ? T.save : T.add}</button></div>`;
|
|
357
437
|
el.querySelector('b').textContent = text ? `“${label}”` : label;
|
|
358
|
-
el.querySelector('code').textContent = src;
|
|
359
|
-
|
|
438
|
+
el.querySelector('code').textContent = target?.getAttribute('data-tag') || src;
|
|
439
|
+
// what it is, in a line or two; what a plan or a change says about it
|
|
440
|
+
if (target) {
|
|
441
|
+
const det = target.querySelector(':scope > .tm-detail');
|
|
442
|
+
const first = clean(det?.querySelector('p')?.textContent || target.querySelector('.tm-node-desc')?.textContent || '', 220);
|
|
443
|
+
const extra = [
|
|
444
|
+
target.getAttribute('data-plan-note') && `Plan: ${clean(target.getAttribute('data-plan-note'), 160)}`,
|
|
445
|
+
target.getAttribute('data-plan') === 'new' && 'New in this plan',
|
|
446
|
+
target.getAttribute('data-tm-delta') && `Changed: ${target.getAttribute('data-tm-delta')} lines`,
|
|
447
|
+
target.getAttribute('data-tm-mark') && (target.getAttribute('data-tm-mark') === 'broken' ? 'No longer matches the code' : 'The code changed since this box was checked'),
|
|
448
|
+
].filter(Boolean);
|
|
449
|
+
const sumEl = el.querySelector('.sum');
|
|
450
|
+
sumEl.textContent = first;
|
|
451
|
+
for (const x of extra) { const d = document.createElement('div'); d.className = 'flag'; d.textContent = x; sumEl.appendChild(d); }
|
|
452
|
+
if (!first && !extra.length) sumEl.remove();
|
|
453
|
+
} else el.querySelector('.sum').remove();
|
|
454
|
+
el.querySelector('.hint').textContent = ''; el.querySelector('[data-act="add"]').title = T.hint;
|
|
360
455
|
const ta = el.querySelector('textarea'); ta.placeholder = T.placeholder; ta.value = existing?.text || '';
|
|
361
456
|
const sug = el.querySelector('.suggest');
|
|
362
|
-
if (
|
|
457
|
+
if (planComment) { el.querySelector('b').textContent = `Plan: ${label}`; ta.placeholder = 'Ask a question or say what should change'; }
|
|
458
|
+
if (!existing && !planComment) for (const [lbl, prompt] of T.suggest) {
|
|
363
459
|
const b = document.createElement('button'); b.type = 'button'; b.textContent = lbl;
|
|
364
460
|
b.onclick = () => { ta.value = prompt; ta.focus(); };
|
|
365
461
|
sug.appendChild(b);
|
|
@@ -367,7 +463,7 @@
|
|
|
367
463
|
slot.appendChild(el);
|
|
368
464
|
// position: below the target, kept inside the viewport
|
|
369
465
|
const r = rect || docRect(target.getBoundingClientRect());
|
|
370
|
-
const w =
|
|
466
|
+
const w = 360; const vw = document.documentElement.clientWidth;
|
|
371
467
|
let left = Math.min(Math.max(8 + scrollX, r.left), scrollX + vw - w - 12);
|
|
372
468
|
let top = r.bottom + 10;
|
|
373
469
|
const h = el.offsetHeight || 220;
|
|
@@ -392,7 +488,9 @@
|
|
|
392
488
|
};
|
|
393
489
|
el.addEventListener('click', (e) => {
|
|
394
490
|
const act = e.target.closest('[data-act]')?.dataset.act;
|
|
395
|
-
if (act === 'add') finish(
|
|
491
|
+
if (act === 'add') finish(planComment);
|
|
492
|
+
else if (act === 'details') peek(target);
|
|
493
|
+
else if (act === 'comment') { el.classList.remove('viewing'); el.setAttribute('aria-label', 'Comment'); ta.focus({ preventScroll: true }); }
|
|
396
494
|
else if (act === 'cancel') closeCard();
|
|
397
495
|
else if (act === 'remove') { removeNote(noteId, true); closeCard(); }
|
|
398
496
|
});
|
|
@@ -400,7 +498,8 @@
|
|
|
400
498
|
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeCard(); }
|
|
401
499
|
else if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && e.keyCode !== 229) { e.preventDefault(); finish(e.ctrlKey || e.metaKey); }
|
|
402
500
|
});
|
|
403
|
-
setTimeout(() => ta.focus({ preventScroll: true }), 0);
|
|
501
|
+
if (!view) setTimeout(() => ta.focus({ preventScroll: true }), 0);
|
|
502
|
+
else el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); closeCard(); } });
|
|
404
503
|
}
|
|
405
504
|
|
|
406
505
|
function rangeSrc() {
|
|
@@ -503,7 +602,7 @@
|
|
|
503
602
|
}
|
|
504
603
|
if (inner && inner !== box && box.contains(inner)) return;
|
|
505
604
|
e.preventDefault(); e.stopPropagation();
|
|
506
|
-
|
|
605
|
+
openBox(box);
|
|
507
606
|
return;
|
|
508
607
|
}
|
|
509
608
|
if (String(getSelection?.() || '').trim().length > 1) return;
|
|
@@ -514,6 +613,17 @@
|
|
|
514
613
|
openCard({ target: el, noteId: existing?.id || null });
|
|
515
614
|
}, true);
|
|
516
615
|
|
|
616
|
+
// A double click on a box goes straight to writing a comment (a single click only looks).
|
|
617
|
+
document.addEventListener('dblclick', (e) => {
|
|
618
|
+
if (!e.isTrusted || e.composedPath().includes(host)) return;
|
|
619
|
+
const t = e.target instanceof Element ? e.target : null;
|
|
620
|
+
const box = t?.closest(boxSel);
|
|
621
|
+
if (!box || t.closest('a[href],button,input,select,textarea,label,summary,.tm-ask,[role=tab]')) return;
|
|
622
|
+
e.preventDefault();
|
|
623
|
+
getSelection()?.removeAllRanges();
|
|
624
|
+
cardFor(box);
|
|
625
|
+
}, true);
|
|
626
|
+
|
|
517
627
|
document.addEventListener('mouseup', (e) => {
|
|
518
628
|
if (!e.isTrusted || e.composedPath().includes(host)) return;
|
|
519
629
|
setTimeout(() => {
|
|
@@ -534,7 +644,7 @@
|
|
|
534
644
|
const typing = e.target instanceof Element && e.target.closest('input,textarea,select,[contenteditable]');
|
|
535
645
|
if (e.key === 'Escape' && card) { closeCard(); return; }
|
|
536
646
|
if (e.key === 'Escape' && (focusSet.length || focusNote)) { clearFocus(); post({ type: 'focus-cleared' }); return; }
|
|
537
|
-
if ((e.key === 'Enter' || e.key === ' ') && !annotating && e.target instanceof Element && e.target.matches?.('.tm-node, .tm-step') && !typing) { e.preventDefault();
|
|
647
|
+
if ((e.key === 'Enter' || e.key === ' ') && !annotating && e.target instanceof Element && e.target.matches?.('.tm-node, .tm-step') && !typing) { e.preventDefault(); cardFor(e.target); return; }
|
|
538
648
|
});
|
|
539
649
|
|
|
540
650
|
// ---------- decisions: <form class="tm-ask" data-tm-ask="question"> ----------
|
|
@@ -565,6 +675,7 @@
|
|
|
565
675
|
window.addEventListener('message', (e) => {
|
|
566
676
|
if (e.source !== parentWin || e.origin !== PARENT || !e.data || !e.data.__truemap) return;
|
|
567
677
|
const d = e.data;
|
|
678
|
+
if (d.type === 'theme') { applyTheme(d.theme); return; }
|
|
568
679
|
if (d.type === 'marks') {
|
|
569
680
|
document.querySelectorAll('[data-tm-mark]').forEach((el) => el.removeAttribute('data-tm-mark'));
|
|
570
681
|
for (const m of d.items || []) {
|
|
@@ -599,6 +710,7 @@
|
|
|
599
710
|
} else if (d.type === 'select') {
|
|
600
711
|
select(d.id ? document.getElementById(d.id) : null);
|
|
601
712
|
} else if (d.type === 'plan') {
|
|
713
|
+
planNow = d.plan || null;
|
|
602
714
|
// A plan drawn on the map: what it touches, adds (dashed, in its group) and removes.
|
|
603
715
|
for (const el of document.querySelectorAll('[data-plan-overlay], [data-plan-revised]')) { el.removeAttribute('data-plan'); el.removeAttribute('data-plan-note'); el.removeAttribute('data-plan-overlay'); el.removeAttribute('data-plan-revised'); }
|
|
604
716
|
clearFocus();
|
|
@@ -614,26 +726,28 @@
|
|
|
614
726
|
};
|
|
615
727
|
if (p) { for (const t of p.touch || []) markPlan(t.box, 'change', t.what); for (const r of p.remove || []) markPlan(r.box, 'remove', r.why); }
|
|
616
728
|
for (const id of p?.revised || []) findItems([id])[0]?.setAttribute('data-plan-revised', '');
|
|
729
|
+
setTimeout(placePlanAct, 60);
|
|
617
730
|
for (const b of document.querySelectorAll('.tm-node, .tm-step')) { if (!b.hasAttribute('tabindex') && !b.matches('a[href]')) b.setAttribute('tabindex', '0'); }
|
|
618
731
|
markWires();
|
|
619
732
|
} else if (d.type === 'changes') {
|
|
620
733
|
// Review mode: changed boxes carry their +/- lines; the rest of the map goes quiet.
|
|
621
734
|
document.documentElement.toggleAttribute('data-tm-changes', !!d.on);
|
|
622
|
-
for (const el of document.querySelectorAll('[data-tm-change], [data-tm-unbuilt]')) { el.removeAttribute('data-tm-change'); el.removeAttribute('data-tm-delta'); el.removeAttribute('data-tm-unbuilt'); }
|
|
735
|
+
for (const el of document.querySelectorAll('[data-tm-change], [data-tm-unbuilt]')) { el.removeAttribute('data-tm-change'); el.removeAttribute('data-tm-delta'); el.removeAttribute('data-tm-unbuilt'); el.removeAttribute('data-tm-new'); }
|
|
623
736
|
for (const u of d.unbuilt || []) { const el = findItems([u.src || u.box, u.box])[0]; if (el) el.setAttribute('data-tm-unbuilt', ''); }
|
|
624
737
|
const names = [];
|
|
625
738
|
for (const it of d.items || []) {
|
|
626
739
|
for (const el of document.querySelectorAll('[data-src]')) {
|
|
627
740
|
if (el.getAttribute('data-src') !== it.src) continue;
|
|
628
741
|
el.setAttribute('data-tm-change', '');
|
|
629
|
-
el.setAttribute('data-tm-delta', it.add == null ? 'binary' : [it.add ? '+' + it.add : '', it.del ? '−' + it.del : ''].filter(Boolean).join(' ') || '±0');
|
|
742
|
+
el.setAttribute('data-tm-delta', (it.isNew ? 'New ' : '') + (it.add == null ? 'binary' : [it.add ? '+' + it.add : '', it.del ? '−' + it.del : ''].filter(Boolean).join(' ') || '±0'));
|
|
743
|
+
el.toggleAttribute('data-tm-new', !!it.isNew);
|
|
630
744
|
names.push({ src: it.src, name: clean(el.getAttribute('data-name'), 60) || labelOf(el) });
|
|
631
745
|
}
|
|
632
746
|
}
|
|
633
747
|
if (names.length) post({ type: 'changes-names', items: names });
|
|
634
748
|
} else if (d.type === 'open-box') {
|
|
635
749
|
const el = d.id ? document.getElementById(d.id) : [...document.querySelectorAll('[data-src]')].find((x) => x.getAttribute('data-src') === d.src);
|
|
636
|
-
if (el) { reveal([el], 'nearest'); peek(el); }
|
|
750
|
+
if (el) { reveal([el], 'nearest'); select(el); peek(el); }
|
|
637
751
|
} else if (d.type === 'clear-focus') {
|
|
638
752
|
clearFocus();
|
|
639
753
|
} else if (d.type === 'highlight') {
|
|
@@ -654,6 +768,9 @@
|
|
|
654
768
|
window.truemapDiagram?.interact();
|
|
655
769
|
const ready = () => {
|
|
656
770
|
drawWires();
|
|
771
|
+
// index.html#runs: arriving from a draft's box link lights that box on the map
|
|
772
|
+
const hashId = decodeURIComponent((location.hash || '').slice(1));
|
|
773
|
+
if (hashId && /^[\w-]+$/.test(hashId) && document.getElementById(hashId)) setTimeout(() => applyFocus([hashId], '', '', 'center'), 250);
|
|
657
774
|
// Boxes are reachable from the keyboard too.
|
|
658
775
|
for (const b of document.querySelectorAll('.tm-node, .tm-step')) { if (!b.hasAttribute('tabindex') && !b.matches('a[href]')) b.setAttribute('tabindex', '0'); }
|
|
659
776
|
if ('ResizeObserver' in window) new ResizeObserver(scheduleWires).observe(document.body);
|
package/src/ui/workspace.css
CHANGED
|
@@ -402,3 +402,42 @@ code { font-family: var(--code); font-size: 0.9em; }
|
|
|
402
402
|
.send.quiet { background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); }
|
|
403
403
|
.code-box pre span em { display: inline-block; width: 1.4em; font-style: normal; color: var(--faint); user-select: none; }
|
|
404
404
|
.code-box pre span.add em { color: var(--fine); } .code-box pre span.del em { color: var(--broken); }
|
|
405
|
+
.ch-why { margin: -6px 4px 14px; font-size: 12px; color: var(--muted); line-height: 1.45; }
|
|
406
|
+
/* the map, one click away; drafts as a numbered record */
|
|
407
|
+
.map-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--bg); padding: 4px 10px 4px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
|
|
408
|
+
.map-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; }
|
|
409
|
+
.map-btn:hover { color: var(--ink); background: var(--surface); }
|
|
410
|
+
.map-btn.on { color: var(--ink); border-color: var(--ink); }
|
|
411
|
+
.menu-label { padding: 8px 8px 4px; font-size: 12px; color: var(--faint); }
|
|
412
|
+
.pi-num { flex: none; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 6px; background: var(--surface); color: var(--ink); font: 600 11px/20px var(--font); text-align: center; }
|
|
413
|
+
/* what changed in a turn, as a card in the conversation */
|
|
414
|
+
.cc { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
|
|
415
|
+
.cc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
|
|
416
|
+
.cc-head b { font-weight: 600; color: var(--ink); }
|
|
417
|
+
.cc-rows { display: grid; gap: 2px; margin-top: 8px; }
|
|
418
|
+
.cc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 5px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
|
|
419
|
+
.cc-row:hover { background: var(--surface); }
|
|
420
|
+
.cc-row b { font-weight: 500; color: var(--ink); }
|
|
421
|
+
.cc-warn { margin: 8px 0 0; font-size: 12.5px; color: var(--changed); }
|
|
422
|
+
.cc-loose { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
|
|
423
|
+
.cc-loose summary { cursor: pointer; }
|
|
424
|
+
.cc-loose div { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
|
|
425
|
+
.cc-loose code { font-size: 12px; color: var(--text); background: none !important; padding: 0 !important; }
|
|
426
|
+
.cc-loose .text-btn { margin-top: 6px; }
|
|
427
|
+
.cc-hint { margin: 8px 0 0 !important; font-size: 12px; color: var(--faint); }
|
|
428
|
+
.panel-head { justify-content: flex-end; }
|
|
429
|
+
.nav-btns { display: inline-flex; gap: 0; margin-right: 4px; }
|
|
430
|
+
.icon-btn.nav { width: 26px; height: 26px; }
|
|
431
|
+
.icon-btn.nav svg { width: 15px; height: 15px; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
|
|
432
|
+
.icon-btn.nav:disabled { opacity: .35; cursor: default; background: none; }
|
|
433
|
+
.cc-new { margin-left: 6px; font-size: 11px; font-weight: 500; padding: 0 6px; border-radius: 6px; background: color-mix(in oklab, var(--fine) 16%, transparent); color: var(--fine); }
|
|
434
|
+
.more-theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; font-size: 13px; font-weight: 500; color: var(--ink); }
|
|
435
|
+
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--surface); }
|
|
436
|
+
.seg button { border: 0; background: none; padding: 4px 9px; border-radius: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
|
|
437
|
+
.seg button:hover { color: var(--ink); }
|
|
438
|
+
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 20, 19, .14); }
|
|
439
|
+
.msg a.pic { display: block; width: fit-content; max-width: 100%; margin: 6px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); line-height: 0; }
|
|
440
|
+
.msg a.pic img { display: block; max-width: 100%; max-height: 280px; object-fit: contain; background: var(--surface); }
|
|
441
|
+
.msg a.pic.broken { line-height: 1.4; padding: 8px 10px; font-size: 12.5px; color: var(--faint); }
|
|
442
|
+
.msg a.pic.broken::before { content: "Image not found"; }
|
|
443
|
+
.msg a.pic.broken img { display: none; }
|
package/src/ui/workspace.html
CHANGED
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
<div class="menu proj-menu" id="projMenu" role="menu" hidden></div>
|
|
24
24
|
</div>
|
|
25
25
|
<span class="slash" aria-hidden="true">/</span>
|
|
26
|
-
<button class="
|
|
27
|
-
<
|
|
26
|
+
<span class="nav-btns"><button class="icon-btn nav" id="navBack" type="button" title="Back (Alt+Left)" aria-label="Back" disabled><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5 5.5 8l4.5 4.5"/></svg></button><button class="icon-btn nav" id="navFwd" type="button" title="Forward (Alt+Right)" aria-label="Forward" disabled><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 10.5 8 6 12.5"/></svg></button></span>
|
|
27
|
+
<button class="map-btn" id="crumbHome" type="button" title="The map of the whole system"><svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2" y="2.5" width="12" height="3.5" rx="1"/><rect x="2" y="7.5" width="5" height="6" rx="1"/><rect x="9" y="7.5" width="5" height="6" rx="1"/></svg>Map</button>
|
|
28
|
+
<span class="crumb-sep" id="crumbSep" aria-hidden="true" hidden></span>
|
|
28
29
|
<div class="switcher">
|
|
29
30
|
<button class="page-btn" id="pageBtn" type="button" aria-haspopup="menu" aria-expanded="false" title="Pages (Ctrl+K)">
|
|
30
31
|
<span class="page-name" id="pageTitle">No pages yet</span>
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
<div class="menu more-menu" id="moreMenu" role="menu" hidden>
|
|
50
51
|
<div class="more-file"><span class="more-label">This page</span><div class="more-path"><code id="moreFile">No page open</code><button class="text-btn" id="copyPath" type="button">Copy path</button></div></div>
|
|
51
52
|
<button class="more-item" id="exportPage" type="button" role="menuitem"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 3.5v9M6 9l4 4 4-4M4 16.5h12"/></svg><span>Export as one HTML file<small>To share it; opens without truemap</small></span></button>
|
|
53
|
+
<div class="more-theme"><span>Appearance</span><span class="seg" id="themeSeg" role="group" aria-label="Appearance"><button type="button" data-theme-pick="">System</button><button type="button" data-theme-pick="light">Light</button><button type="button" data-theme-pick="dark">Dark</button></span></div>
|
|
52
54
|
<div class="menu-gap"></div>
|
|
53
55
|
<button class="more-item" id="endConv" type="button" role="menuitem"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M8 4.5H5a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h3M12.5 6.5 16 10l-3.5 3.5M16 10H8"/></svg><span>End conversation<small id="endHint">Lets the agent go back to the terminal</small></span></button>
|
|
54
56
|
</div>
|
|
@@ -74,14 +76,14 @@
|
|
|
74
76
|
</section>
|
|
75
77
|
<div class="convo">
|
|
76
78
|
<div class="panel-head">
|
|
77
|
-
<div class="ptabs" role="tablist">
|
|
78
|
-
<button class="ptab" id="tabConvo" type="button" role="tab" aria-selected="true">Conversation</button>
|
|
79
|
-
<button class="ptab" id="tabChanges" type="button" role="tab" aria-selected="false">Changes<span class="ptab-n" id="changesCount" hidden></span></button>
|
|
79
|
+
<div class="ptabs" role="tablist" hidden>
|
|
80
|
+
<button class="ptab" id="tabConvo" type="button" role="tab" aria-selected="true" title="Talk with the agent working in your terminal">Conversation</button>
|
|
81
|
+
<button class="ptab" id="tabChanges" type="button" role="tab" aria-selected="false" title="What changed in the code, shown on the map box by box">Changes<span class="ptab-n" id="changesCount" hidden></span></button>
|
|
80
82
|
</div>
|
|
81
83
|
<span class="agent-state" id="agent" data-state="offline"><i aria-hidden="true"></i><span id="agentLabel">Not listening</span><span class="elapsed" id="elapsed" hidden></span></span>
|
|
82
84
|
</div>
|
|
83
85
|
<div class="msgs" id="msgs" aria-live="polite"></div>
|
|
84
|
-
<div class="changes" id="changes"></div>
|
|
86
|
+
<div class="changes" id="changes" hidden></div>
|
|
85
87
|
<div class="notice" id="notice" hidden></div>
|
|
86
88
|
<form class="composer" id="composer" autocomplete="off">
|
|
87
89
|
<ol class="notes" id="notes" hidden></ol>
|