@wendongfly/myhi 1.3.107 → 1.3.108

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 (2) hide show
  1. package/dist/chat.html +57 -15
  2. package/package.json +1 -1
package/dist/chat.html CHANGED
@@ -298,8 +298,22 @@
298
298
  .mem-file-header:hover { background: var(--border); }
299
299
  .mem-file-header .arrow { transition: transform 0.15s; font-size: 0.6rem; }
300
300
  .mem-file-header .arrow.open { transform: rotate(90deg); }
301
- .mem-file-body { display: none; padding: 0.5rem 0.6rem; background: var(--bg); font-family: 'SF Mono','Consolas',monospace; font-size: 0.72rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--text2); max-height: 300px; overflow-y: auto; }
301
+ .mem-file-body { display: none; padding: 0.55rem 0.7rem; background: var(--bg); font-size: 0.8rem; line-height: 1.6; word-break: break-word; color: var(--text2); max-height: 52vh; overflow-y: auto; }
302
302
  .mem-file-body.open { display: block; }
303
+ /* markdown 渲染样式(记忆正文,隐藏了 frontmatter) */
304
+ .mem-file-body.md h1, .mem-file-body.md h2, .mem-file-body.md h3 { font-size: 0.88rem; margin: 0.5rem 0 0.3rem; color: var(--text); }
305
+ .mem-file-body.md ul, .mem-file-body.md ol { margin: 0.3rem 0; padding-left: 1.2rem; }
306
+ .mem-file-body.md li { margin: 0.15rem 0; }
307
+ .mem-file-body.md p { margin: 0.35rem 0; }
308
+ .mem-file-body.md code { background: var(--surface2); padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.75rem; font-family: 'SF Mono','Consolas',monospace; }
309
+ .mem-file-body.md pre { background: var(--surface2); padding: 0.5rem 0.6rem; border-radius: 6px; overflow-x: auto; }
310
+ .mem-file-body.md pre code { background: none; padding: 0; }
311
+ .mem-file-body.md a { color: var(--blue); }
312
+ .mem-file-body.md strong { color: var(--text); }
313
+ .mem-title { color: var(--blue); font-weight: 600; }
314
+ .mem-desc { display: block; color: var(--muted); font-size: 0.68rem; font-weight: 400; margin-top: 0.12rem; line-height: 1.4; white-space: normal; }
315
+ /* PC 上记忆面板加宽,别挤在窄底 sheet 里 */
316
+ @media (min-width: 900px) { #memory-sheet .action-sheet-box { max-width: 820px; } }
303
317
  .slash-inp { width: 100%; padding: 0.65rem 0.8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 0.9rem; outline: none; }
304
318
  .slash-inp:focus { border-color: var(--purple); }
305
319
 
@@ -3568,20 +3582,48 @@
3568
3582
  return;
3569
3583
  }
3570
3584
 
3571
- for (const f of files) {
3572
- const card = document.createElement('div');
3573
- card.className = 'mem-file';
3574
- const header = document.createElement('div');
3575
- header.className = 'mem-file-header';
3576
- header.innerHTML = `<span class="arrow">▶</span> ${escHtml(f.name)}`;
3577
- const body = document.createElement('div');
3578
- body.className = 'mem-file-body';
3579
- body.textContent = f.content;
3580
- header.onclick = () => { body.classList.toggle('open'); header.querySelector('.arrow').classList.toggle('open'); };
3581
- card.appendChild(header);
3582
- card.appendChild(body);
3583
- container.appendChild(card);
3584
- }
3585
+ // 拆掉开头的 --- frontmatter --- ,提取 description,正文单独渲染 markdown
3586
+ const parseFM = (content) => {
3587
+ const m = content.match(/^?---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
3588
+ if (!m) return { desc: '', body: content };
3589
+ const dm = m[1].match(/^description:\s*(.+)$/m);
3590
+ return { desc: dm ? dm[1].trim() : '', body: content.slice(m[0].length) };
3591
+ };
3592
+ const cleanName = (n) => n.replace(/^.*\//, '').replace(/\.md$/i, '');
3593
+
3594
+ // 搜索框
3595
+ const search = document.createElement('input');
3596
+ search.className = 'slash-inp';
3597
+ search.placeholder = '搜索记忆(文件名 / 内容)…';
3598
+ search.style.cssText = 'margin-bottom:0.5rem;width:100%;box-sizing:border-box';
3599
+ const listWrap = document.createElement('div');
3600
+ container.appendChild(search);
3601
+ container.appendChild(listWrap);
3602
+
3603
+ const renderList = (kw) => {
3604
+ kw = (kw || '').trim().toLowerCase();
3605
+ listWrap.innerHTML = '';
3606
+ let shown = 0;
3607
+ for (const f of files) {
3608
+ if (kw && !(f.name.toLowerCase().includes(kw) || (f.content || '').toLowerCase().includes(kw))) continue;
3609
+ shown++;
3610
+ const { desc, body: md } = parseFM(f.content || '');
3611
+ const card = document.createElement('div');
3612
+ card.className = 'mem-file';
3613
+ const header = document.createElement('div');
3614
+ header.className = 'mem-file-header';
3615
+ header.innerHTML = `<span class="arrow">▶</span><span style="flex:1;min-width:0"><span class="mem-title">${escHtml(cleanName(f.name))}</span>${desc ? '<span class="mem-desc">' + escHtml(desc) + '</span>' : ''}</span>`;
3616
+ const body = document.createElement('div');
3617
+ body.className = 'mem-file-body md';
3618
+ body.innerHTML = renderMarkdown(md.trim());
3619
+ header.onclick = () => { body.classList.toggle('open'); header.querySelector('.arrow').classList.toggle('open'); };
3620
+ card.appendChild(header); card.appendChild(body);
3621
+ listWrap.appendChild(card);
3622
+ }
3623
+ if (!shown) listWrap.innerHTML = '<div style="color:var(--muted);text-align:center;padding:1.2rem 0;font-size:0.8rem">没有匹配的记忆</div>';
3624
+ };
3625
+ search.addEventListener('input', () => renderList(search.value));
3626
+ renderList('');
3585
3627
  } catch (e) {
3586
3628
  container.innerHTML = '';
3587
3629
  container.appendChild(makeBar());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wendongfly/myhi",
3
- "version": "1.3.107",
3
+ "version": "1.3.108",
4
4
  "description": "Web-based terminal sharing with chat UI — control your terminal from phone via LAN/Tailscale",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",