@wendongfly/myhi 1.3.107 → 1.3.109
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/dist/chat.html +57 -15
- package/dist/grid.html +16 -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.
|
|
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
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
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/dist/grid.html
CHANGED
|
@@ -83,12 +83,24 @@
|
|
|
83
83
|
return { layout: 'auto', panes: [] };
|
|
84
84
|
}
|
|
85
85
|
function saveState() {
|
|
86
|
-
|
|
86
|
+
// 存【稳定标识】而不是易变 id——myhi 会话 id 每次重启都重新 randomUUID,存 id 重启后必失效
|
|
87
|
+
state.panes = paneEls.map(p => p._key || null);
|
|
87
88
|
localStorage.setItem(LS_KEY, JSON.stringify(state));
|
|
88
89
|
}
|
|
89
90
|
function esc(s){ return String(s==null?'':s).replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); }
|
|
90
91
|
function sName(s){ return s.title || s.name || s.summary || (s.id||s.sessionId||'').slice(0,12) || '未命名'; }
|
|
91
92
|
function sId(s){ return s.id || s.sessionId; }
|
|
93
|
+
function sessById(id){ return sessions.find(s => sId(s) === id); }
|
|
94
|
+
// 稳定标识:claudeSessionId(agent 会话,--resume 用,重启不变) / createdAt(持久化,稳定)
|
|
95
|
+
function keyOf(s){ return s ? { cid: s.claudeSessionId || null, createdAt: s.createdAt || null, cwd: s.cwd || null } : null; }
|
|
96
|
+
// 把稳定标识映射回【当前】会话 id(重启后 id 变了也能找回同一个会话);找不到返回 ''
|
|
97
|
+
function resolveKey(key){
|
|
98
|
+
if (!key) return '';
|
|
99
|
+
if (typeof key === 'string') return sessById(key) ? key : ''; // 兼容旧格式(曾直接存 id)
|
|
100
|
+
for (const s of sessions) if (key.cid && s.claudeSessionId && s.claudeSessionId === key.cid) return sId(s);
|
|
101
|
+
for (const s of sessions) if (key.createdAt && s.createdAt === key.createdAt && (!key.cwd || s.cwd === key.cwd)) return sId(s);
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
92
104
|
|
|
93
105
|
// ── 布局 ──
|
|
94
106
|
function applyLayout() {
|
|
@@ -142,6 +154,7 @@
|
|
|
142
154
|
}
|
|
143
155
|
function setPaneSession(pane, sid, keepSelect) {
|
|
144
156
|
pane._sid = sid || '';
|
|
157
|
+
pane._key = sid ? keyOf(sessById(sid)) : null; // 记住稳定标识,供重启后找回
|
|
145
158
|
if (!keepSelect) pane._sel.value = sid || '';
|
|
146
159
|
// 只重建这一格的 iframe,其它格不受影响
|
|
147
160
|
if (pane._iframe) { pane._iframe.remove(); pane._iframe = null; }
|
|
@@ -181,7 +194,8 @@
|
|
|
181
194
|
(async function init() {
|
|
182
195
|
await refreshSessions(false);
|
|
183
196
|
const initial = (state.panes && state.panes.length) ? state.panes : [];
|
|
184
|
-
|
|
197
|
+
// 用稳定标识映射回当前 id;找不到→空格(可下拉重选),不再加载死会话报「未找到」
|
|
198
|
+
for (const key of initial) addPane(resolveKey(key), true);
|
|
185
199
|
applyLayout();
|
|
186
200
|
})();
|
|
187
201
|
</script>
|
package/package.json
CHANGED