clavarium 0.2.118-next.1 → 0.2.119-next.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.
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.118-next.1",
3
+ "version": "0.2.119-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.118-next.1",
9
+ "version": "0.2.119-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
- "clavarium-binder": "0.1.28-next.1",
14
+ "clavarium-binder": "0.1.30-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
- "clavarium-parley": "0.17.12-next.1",
16
+ "clavarium-parley": "0.17.13-next.1",
17
17
  "clavarium-tether": "0.1.0-next.29",
18
18
  "mermaid": "11.17.2",
19
19
  "node-pty": "^1.1.0",
@@ -716,9 +716,9 @@
716
716
  }
717
717
  },
718
718
  "node_modules/clavarium-binder": {
719
- "version": "0.1.28-next.1",
720
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.28-next.1.tgz",
721
- "integrity": "sha512-/6YAE9OE+qAbzUxVPmPH83uIwqxfRXpASQN8dAAmh7dpQRHPXKtGIG6iz1hSYvvVru9Cx93y/niQWU0raxzE2A==",
719
+ "version": "0.1.30-next.1",
720
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.30-next.1.tgz",
721
+ "integrity": "sha512-9OZ6z9PXqKmeOomgi7Bilja+NiZM0HsqRbM04F4tLIV/Hfx3oJN/FogpoK2WWYXfDHvCSp91NncHW/0yDDvXWg==",
722
722
  "license": "MIT",
723
723
  "bin": {
724
724
  "binder": "bin/binder.mjs",
@@ -742,9 +742,9 @@
742
742
  }
743
743
  },
744
744
  "node_modules/clavarium-parley": {
745
- "version": "0.17.12-next.1",
746
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.12-next.1.tgz",
747
- "integrity": "sha512-G20876winm0zAtnxHcJIRqWwl8XnOyg+SYPu2S6xieRYnocgSTdQew9zOoBWmNMirvyyXqI/p8bN0IBQ1caS+w==",
745
+ "version": "0.17.13-next.1",
746
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.13-next.1.tgz",
747
+ "integrity": "sha512-+/aFyaa0UNnQvSM+N1JrmdvAtKWzL5sxC9xwfc6zufwNoQA13Qhx0WoK8NqbeeFbYtHXPH7zamJeA+c3Z+HfiQ==",
748
748
  "license": "MIT",
749
749
  "bin": {
750
750
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.118-next.1",
3
+ "version": "0.2.119-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -44,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-binder": "0.1.28-next.1",
47
+ "clavarium-binder": "0.1.30-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
- "clavarium-parley": "0.17.12-next.1",
49
+ "clavarium-parley": "0.17.13-next.1",
50
50
  "clavarium-tether": "0.1.0-next.29",
51
51
  "mermaid": "11.17.2",
52
52
  "node-pty": "^1.1.0",
package/web/app.js CHANGED
@@ -2562,6 +2562,8 @@
2562
2562
  },
2563
2563
  /* A reaction to one of its messages: wherever the chat may be written in. */
2564
2564
  ...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
2565
+ /* A message attached to a card (#180), from its menu: its id, as the card opens it again. */
2566
+ ...(!DEVICE ? { card: (m) => attachToCard({ kind: 'message', ref: m.id, title: String(m.short || m.text || '').replace(/\s+/g, ' ').trim().slice(0, 80) }) } : {}),
2565
2567
  /* The buttons of a line of the machine: what this screen may do. */
2566
2568
  act: (id) => { if (id === 'seen-done') return; if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id.startsWith('allow:')) void decideTether(id.slice('allow:'.length), 'yes'); else if (id.startsWith('deny:')) void decideTether(id.slice('deny:'.length), 'no'); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
2567
2569
  /* What it opens over the thread (a picture, its media, a search...) is a step of this page's: one Back closes it. */
@@ -4834,6 +4836,56 @@
4834
4836
  if (!repo || !rest) return;
4835
4837
  void openGit(repo, kind === 'commit' ? { commit: rest } : { branch: rest });
4836
4838
  }
4839
+ /* ATTACH TO A CARD (#180): from where a thing is (a file shown, a message of the chat), a card
4840
+ picked among the binders this page may write in -- by its title, typed or scrolled -- and
4841
+ the thing attached to it, as the agent attaches with `binder attach`. */
4842
+ async function attachToCard({ kind, ref, title }) {
4843
+ document.getElementById('attach-pick')?.remove();
4844
+ const box = document.createElement('div'); box.id = 'attach-pick'; box.setAttribute('role', 'dialog'); box.setAttribute('aria-modal', 'true'); box.setAttribute('aria-label', 'Attach to a card');
4845
+ const card = document.createElement('div'); card.className = 'attach-card';
4846
+ const head = document.createElement('div'); head.className = 'row';
4847
+ const h = document.createElement('b'); h.textContent = 'Attach to a card';
4848
+ const sp = document.createElement('span'); sp.className = 'sp';
4849
+ const x = document.createElement('button'); x.type = 'button'; x.textContent = '\u00d7'; x.setAttribute('aria-label', 'Close');
4850
+ head.append(h, sp, x);
4851
+ const what = document.createElement('p'); what.className = 'dim attach-what'; what.textContent = title || ref;
4852
+ const find = document.createElement('input'); find.type = 'search'; find.placeholder = 'Find a card'; find.setAttribute('aria-label', 'Find a card');
4853
+ const list = document.createElement('div'); list.className = 'attach-list';
4854
+ const said = document.createElement('p'); said.className = 'attach-said'; said.hidden = true;
4855
+ card.append(head, what, find, list, said); box.append(card); document.body.append(box);
4856
+ const close = () => { box.remove(); document.removeEventListener('keydown', esc, true); };
4857
+ const esc = (e) => { if (e.key === 'Escape') { e.stopPropagation(); close(); } };
4858
+ document.addEventListener('keydown', esc, true);
4859
+ x.onclick = close; box.addEventListener('pointerdown', (e) => { if (e.target === box) close(); });
4860
+ list.textContent = 'Loading...';
4861
+ /* The cards of every binder this page may change, the conversation's own binder first. */
4862
+ const lists = ((await binderCall('lists', {})).data ?? []).filter((l) => !l.archived && l.access === 'write');
4863
+ const own = (l) => Object.keys(l.grants ?? {}).includes(`conversation:${current}`);
4864
+ lists.sort((a, b) => Number(own(b)) - Number(own(a)));
4865
+ const cards = [];
4866
+ for (const l of lists.slice(0, 12)) { const r = await binderCall('show', { list: l.id }); for (const rec of r.data?.records ?? []) cards.push({ list: l, rec }); }
4867
+ const draw = () => {
4868
+ const q = find.value.trim().toLowerCase();
4869
+ const shown = cards.filter(({ rec, list: l }) => !q || `#${rec.n} ${rec.title} ${l.title}`.toLowerCase().includes(q)).slice(0, 80);
4870
+ list.replaceChildren(...(shown.length ? shown.map(({ rec, list: l }) => {
4871
+ const b = document.createElement('button'); b.type = 'button'; b.className = 'attach-item';
4872
+ const t = document.createElement('span'); t.textContent = `#${rec.n} ${rec.title}`;
4873
+ const w = document.createElement('small'); w.textContent = l.title;
4874
+ b.append(t, w);
4875
+ b.onclick = async () => {
4876
+ for (const o of list.querySelectorAll('button')) o.disabled = true;
4877
+ const r = await binderCall('attach', { id: rec.id, kind, ref, ...(title ? { title } : {}) });
4878
+ said.hidden = false; said.textContent = r.ok ? `Attached to #${rec.n} ${rec.title}.` : (r.text || 'Not attached.');
4879
+ said.classList.toggle('bad', !r.ok);
4880
+ if (r.ok) setTimeout(close, 1400); else for (const o of list.querySelectorAll('button')) o.disabled = false;
4881
+ };
4882
+ return b;
4883
+ }) : [Object.assign(document.createElement('p'), { className: 'dim', textContent: cards.length ? 'No card by that name.' : 'No binder you can write in.' })]));
4884
+ };
4885
+ find.addEventListener('input', draw);
4886
+ draw();
4887
+ find.focus();
4888
+ }
4837
4889
  /* Read again every screen of a binder when the binders changed. Taken as seen only once every
4838
4890
  screen read it again: one that failed (the server restarting) is read again at the next turn. */
4839
4891
  async function catchUpBinders() {
@@ -7464,6 +7516,9 @@
7464
7516
  /* Text in a folder this conversation may write in: editable here. */
7465
7517
  $('preview-edit').hidden = Boolean(from) || !editable(name, size) || !canWrite(tab);
7466
7518
  $('preview-edit').onclick = () => { void editFile(tab, inner, name); };
7519
+ /* A file of the shared folders: attached to a card from here (#180). */
7520
+ $('preview-attach').hidden = Boolean(from) || DEVICE;
7521
+ $('preview-attach').onclick = () => void attachToCard({ kind: 'file', ref: tab === 'work' ? `/work/${inner}` : `/resources/${tab}/${inner}`, title: name });
7467
7522
  /* A file read from the machine's disk says so, whatever else is said. */
7468
7523
  const origin = from ? 'Read from the disk of the machine: this file is not kept here, and goes with the machine.' : '';
7469
7524
  const note = (text) => { const all = [text, text === 'Loading...' ? '' : origin].filter(Boolean).join(' '); $('preview-note').textContent = all; $('preview-note').hidden = !all; };
package/web/index.html CHANGED
@@ -1071,7 +1071,7 @@
1071
1071
  <!-- A file, shown over whatever is on the screen; closing it leaves you where you were. -->
1072
1072
  <div id="viewer" role="dialog" aria-modal="true" aria-labelledby="preview-name" hidden>
1073
1073
  <div id="viewer-card">
1074
- <div class="row"><b id="preview-name"></b><span class="sp"></span><button type="button" id="preview-where" hidden>Show in Files</button><button type="button" id="preview-edit" hidden>Edit</button><button type="button" id="preview-copy" hidden>Copy</button><a id="preview-download" class="button">Download</a><button type="button" id="preview-close" aria-label="Close" title="Close">&times;</button></div>
1074
+ <div class="row"><b id="preview-name"></b><span class="sp"></span><button type="button" id="preview-where" hidden>Show in Files</button><button type="button" id="preview-attach" hidden title="Attach to a card">📎 Card</button><button type="button" id="preview-edit" hidden>Edit</button><button type="button" id="preview-copy" hidden>Copy</button><a id="preview-download" class="button">Download</a><button type="button" id="preview-close" aria-label="Close" title="Close">&times;</button></div>
1075
1075
  <p id="preview-note" class="hint" hidden></p>
1076
1076
  <div id="preview-body"></div>
1077
1077
  </div>
package/web/style.css CHANGED
@@ -1876,3 +1876,15 @@ details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wr
1876
1876
  }
1877
1877
  /* The review on a light screen: line numbers and the "changed" tag readable (diff2html's own greys are too pale). */
1878
1878
  :root[data-theme="light"] .rv-diff { --d2h-dim-color: #5d6b7a; --d2h-change-label-color: #8a5d00; }
1879
+
1880
+ /* Attach to a card (#180): a card picked by its title, over whatever is shown. */
1881
+ #attach-pick { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: max(6vh, env(safe-area-inset-top)) 12px 12px; background: rgba(8, 11, 15, 0.55); }
1882
+ #attach-pick .attach-card { display: flex; flex-direction: column; gap: 8px; width: min(520px, 100%); max-height: 80vh; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .5); }
1883
+ #attach-pick .row { display: flex; align-items: center; gap: 8px; }
1884
+ #attach-pick .sp { flex: 1; }
1885
+ #attach-pick .attach-what { margin: 0; overflow-wrap: anywhere; }
1886
+ #attach-pick .attach-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
1887
+ #attach-pick .attach-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%; }
1888
+ #attach-pick .attach-item small { color: var(--dim); }
1889
+ #attach-pick .attach-said { margin: 0; font-weight: 600; }
1890
+ #attach-pick .attach-said.bad { color: var(--bad, #c0392b); }