@wendongfly/myhi 1.3.112 → 1.3.114
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 +90 -4
- package/dist/index.js +1 -1
- package/dist/index.min.js +121 -121
- package/package.json +1 -1
package/dist/chat.html
CHANGED
|
@@ -313,7 +313,10 @@
|
|
|
313
313
|
.mem-title { color: var(--blue); font-weight: 600; }
|
|
314
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
315
|
/* PC 上记忆面板加宽,别挤在窄底 sheet 里 */
|
|
316
|
-
|
|
316
|
+
/* 记忆面板改成近全屏大面板(居中而非贴底),不再挤在窄弹窗里 */
|
|
317
|
+
#memory-sheet.action-sheet.open { align-items: center; }
|
|
318
|
+
#memory-sheet .action-sheet-box { width: 94vw; max-width: 980px; border-radius: 14px 14px 14px 14px; padding-bottom: 0.75rem; }
|
|
319
|
+
#memory-content { flex: 1; min-height: 0; }
|
|
317
320
|
.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; }
|
|
318
321
|
.slash-inp:focus { border-color: var(--purple); }
|
|
319
322
|
|
|
@@ -609,7 +612,7 @@
|
|
|
609
612
|
|
|
610
613
|
<div id="memory-sheet" class="action-sheet">
|
|
611
614
|
<div class="action-sheet-backdrop" onclick="closeMemorySheet()"></div>
|
|
612
|
-
<div class="action-sheet-box" style="max-height:
|
|
615
|
+
<div class="action-sheet-box" style="height:90vh;max-height:90vh;display:flex;flex-direction:column">
|
|
613
616
|
<div class="action-sheet-title">Claude 记忆</div>
|
|
614
617
|
<div id="memory-content" style="flex:1;overflow-y:auto;padding:0.3rem 0;font-size:0.78rem;color:var(--text2);scrollbar-width:thin">
|
|
615
618
|
<div style="text-align:center;color:var(--muted);padding:2rem 0">加载中...</div>
|
|
@@ -3612,8 +3615,14 @@
|
|
|
3612
3615
|
`background:${_memScope===val?'var(--purple)':'var(--bg)'};color:${_memScope===val?'#fff':'var(--muted)'}">${label}</button>`;
|
|
3613
3616
|
const makeBar = () => {
|
|
3614
3617
|
const bar = document.createElement('div');
|
|
3615
|
-
bar.style.cssText = 'display:flex;gap:0.4rem;margin-bottom:0.55rem';
|
|
3616
|
-
|
|
3618
|
+
bar.style.cssText = 'display:flex;flex-direction:column;gap:0.4rem;margin-bottom:0.55rem';
|
|
3619
|
+
const row1 = document.createElement('div');
|
|
3620
|
+
row1.style.cssText = 'display:flex;gap:0.4rem';
|
|
3621
|
+
row1.innerHTML = segBtn('project', '本项目') + segBtn('all', '全部(含全局/其它项目)');
|
|
3622
|
+
const row2 = document.createElement('div');
|
|
3623
|
+
row2.style.cssText = 'display:flex;gap:0.4rem';
|
|
3624
|
+
row2.innerHTML = '<button onclick="analyzeMemory()" style="flex:1;padding:0.42rem;border-radius:7px;cursor:pointer;font-size:0.76rem;border:1px solid var(--blue2);background:var(--blue2);color:#fff;font-weight:600">🤖 让 AI 过一遍(找过时/重复/废弃)</button>';
|
|
3625
|
+
bar.appendChild(row1); bar.appendChild(row2);
|
|
3617
3626
|
return bar;
|
|
3618
3627
|
};
|
|
3619
3628
|
|
|
@@ -3659,16 +3668,32 @@
|
|
|
3659
3668
|
if (kw && !(f.name.toLowerCase().includes(kw) || (f.content || '').toLowerCase().includes(kw))) continue;
|
|
3660
3669
|
shown++;
|
|
3661
3670
|
const { desc, body: md } = parseFM(f.content || '');
|
|
3671
|
+
const deletable = f.name.startsWith('memory/') || f.name.startsWith('~/.claude/memory/');
|
|
3672
|
+
const editable = deletable || f.name.endsWith('CLAUDE.md') || f.name.endsWith('settings.json');
|
|
3662
3673
|
const card = document.createElement('div');
|
|
3663
3674
|
card.className = 'mem-file';
|
|
3664
3675
|
const header = document.createElement('div');
|
|
3665
3676
|
header.className = 'mem-file-header';
|
|
3666
3677
|
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>`;
|
|
3678
|
+
const acts = document.createElement('span');
|
|
3679
|
+
acts.style.cssText = 'display:flex;gap:0.35rem;flex-shrink:0;align-items:center';
|
|
3680
|
+
if (editable) {
|
|
3681
|
+
const eb = document.createElement('span'); eb.textContent = '✏️'; eb.title = '编辑'; eb.style.cssText = 'cursor:pointer;font-size:0.82rem';
|
|
3682
|
+
eb.onclick = (ev) => { ev.stopPropagation(); startEditMemory(card, f); };
|
|
3683
|
+
acts.appendChild(eb);
|
|
3684
|
+
}
|
|
3685
|
+
if (deletable) {
|
|
3686
|
+
const db = document.createElement('span'); db.textContent = '🗑'; db.title = '删除'; db.style.cssText = 'cursor:pointer;font-size:0.82rem';
|
|
3687
|
+
db.onclick = (ev) => { ev.stopPropagation(); delMemory(f.name); };
|
|
3688
|
+
acts.appendChild(db);
|
|
3689
|
+
}
|
|
3690
|
+
header.appendChild(acts);
|
|
3667
3691
|
const body = document.createElement('div');
|
|
3668
3692
|
body.className = 'mem-file-body md';
|
|
3669
3693
|
body.innerHTML = renderMarkdown(md.trim());
|
|
3670
3694
|
header.onclick = () => { body.classList.toggle('open'); header.querySelector('.arrow').classList.toggle('open'); };
|
|
3671
3695
|
card.appendChild(header); card.appendChild(body);
|
|
3696
|
+
card._file = f; card._body = body;
|
|
3672
3697
|
listWrap.appendChild(card);
|
|
3673
3698
|
}
|
|
3674
3699
|
if (!shown) listWrap.innerHTML = '<div style="color:var(--muted);text-align:center;padding:1.2rem 0;font-size:0.8rem">没有匹配的记忆</div>';
|
|
@@ -3689,6 +3714,67 @@
|
|
|
3689
3714
|
document.getElementById('memory-sheet').classList.remove('open');
|
|
3690
3715
|
};
|
|
3691
3716
|
|
|
3717
|
+
// 让 AI 按规则过一遍记忆(只分析给建议,不改文件)
|
|
3718
|
+
window.analyzeMemory = function() {
|
|
3719
|
+
const scopeTxt = _memScope === 'all' ? '所有项目 + 全局' : '本项目';
|
|
3720
|
+
const prompt = [
|
|
3721
|
+
`请帮我过一遍并分析【${scopeTxt}】的记忆文件(在 ~/.claude/ 下:本项目记忆在对应当前工作目录 cwd 编码后的 projects/<编码>/memory/ 里,`,
|
|
3722
|
+
`全局在 ~/.claude/memory/;先 ls 找到目录再逐个读,可用子代理并行读)。`,
|
|
3723
|
+
`【只分析、给建议,先别改动任何文件】——我会在「记忆」面板里自己确认后维护。判断规则:`,
|
|
3724
|
+
`1) 过时:记忆里的文件/路径/版本/参数/节点状态与现状不符(不确定就标"需核实");`,
|
|
3725
|
+
`2) 重复/重叠:多条讲同一件事、可合并;`,
|
|
3726
|
+
`3) 已废弃/已完成:project_* 里已结束或标注"已弃/完成"的,建议降级为 reference 或删除;`,
|
|
3727
|
+
`4) 索引膨胀:MEMORY.md 有无可精简的行。`,
|
|
3728
|
+
`输出一个表格:文件名 | 类别(过时/重复/废弃/保留) | 原因 | 建议(删除/合并到X/更新/保留);最后一句总结:建议删 N 条、合并 M 组、更新 K 条。`,
|
|
3729
|
+
].join('');
|
|
3730
|
+
closeMemorySheet();
|
|
3731
|
+
if (currentSession?.mode === 'agent') {
|
|
3732
|
+
if (!isController && canTakeControl()) socket.emit('take-control', { sessionId: SESSION_ID });
|
|
3733
|
+
addInputMessage('🤖 让 AI 过一遍记忆(找过时/重复/废弃)');
|
|
3734
|
+
socket.emit('agent:query', { prompt });
|
|
3735
|
+
showThinking();
|
|
3736
|
+
} else {
|
|
3737
|
+
addStatusMessage('该功能仅在 agent(Claude) 会话可用');
|
|
3738
|
+
}
|
|
3739
|
+
};
|
|
3740
|
+
|
|
3741
|
+
// 编辑记忆文件:把该卡片正文换成 textarea(原始 markdown)+ 保存/取消
|
|
3742
|
+
window.startEditMemory = function(card, f) {
|
|
3743
|
+
const wrap = document.createElement('div');
|
|
3744
|
+
wrap.className = 'mem-file-body open';
|
|
3745
|
+
const ta = document.createElement('textarea');
|
|
3746
|
+
ta.value = f.content || '';
|
|
3747
|
+
ta.spellcheck = false;
|
|
3748
|
+
ta.style.cssText = 'width:100%;box-sizing:border-box;min-height:12rem;font-family:\'SF Mono\',Consolas,monospace;font-size:0.75rem;line-height:1.5;background:var(--surface2);color:var(--text);border:1px solid var(--border);border-radius:6px;padding:0.5rem;resize:vertical';
|
|
3749
|
+
const btns = document.createElement('div');
|
|
3750
|
+
btns.style.cssText = 'display:flex;gap:0.5rem;margin-top:0.4rem';
|
|
3751
|
+
const save = document.createElement('button'); save.textContent = '保存';
|
|
3752
|
+
save.style.cssText = 'flex:2;padding:0.45rem;border:none;border-radius:7px;background:var(--blue2);color:#fff;cursor:pointer;font-weight:600';
|
|
3753
|
+
const cancel = document.createElement('button'); cancel.textContent = '取消';
|
|
3754
|
+
cancel.style.cssText = 'flex:1;padding:0.45rem;border:1px solid var(--border);border-radius:7px;background:var(--bg);color:var(--muted);cursor:pointer';
|
|
3755
|
+
save.onclick = async () => {
|
|
3756
|
+
try {
|
|
3757
|
+
const r = await fetch('/api/memory/save', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ sessionId: SESSION_ID, name: f.name, content: ta.value }) });
|
|
3758
|
+
const d = await r.json();
|
|
3759
|
+
if (d.ok) { addStatusMessage('记忆已保存: ' + f.name); showMemory(); } else { alert('保存失败: ' + (d.error||'')); }
|
|
3760
|
+
} catch (e) { alert('保存出错: ' + e.message); }
|
|
3761
|
+
};
|
|
3762
|
+
cancel.onclick = () => showMemory();
|
|
3763
|
+
btns.appendChild(save); btns.appendChild(cancel);
|
|
3764
|
+
wrap.appendChild(ta); wrap.appendChild(btns);
|
|
3765
|
+
card._body.replaceWith(wrap); card._body = wrap;
|
|
3766
|
+
ta.focus();
|
|
3767
|
+
};
|
|
3768
|
+
|
|
3769
|
+
window.delMemory = async function(name) {
|
|
3770
|
+
if (!confirm('删除记忆文件「' + name.replace(/^.*\//,'') + '」?不可撤销。')) return;
|
|
3771
|
+
try {
|
|
3772
|
+
const r = await fetch('/api/memory/delete', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ sessionId: SESSION_ID, name }) });
|
|
3773
|
+
const d = await r.json();
|
|
3774
|
+
if (d.ok) { addStatusMessage('已删除记忆: ' + name); showMemory(); } else { alert('删除失败: ' + (d.error||'')); }
|
|
3775
|
+
} catch (e) { alert('删除出错: ' + e.message); }
|
|
3776
|
+
};
|
|
3777
|
+
|
|
3692
3778
|
// ── Agent 模式快捷功能 ──────────────────────────
|
|
3693
3779
|
let _totalAgentCost = 0;
|
|
3694
3780
|
// 追踪 result 消息中的费用
|