dsh-aurorix-agentbook 1.5.1 → 1.5.2

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/lib/web.js +190 -92
  2. package/package.json +1 -1
package/lib/web.js CHANGED
@@ -10,89 +10,147 @@ import { existsSync } from 'node:fs'
10
10
 
11
11
  const PAGE_TITLE = '记忆库'
12
12
 
13
- /** 页面 HTML。信息架构与 dsh-go 原生面板一致:分层计数 → 召回 → 保险箱 → 写一条 → 详情。 */
13
+ /** 页面 HTML。结构与 dsh-go 原生面板逐块对齐:插件内容 → 召回 → 存进记忆 → 保险箱 → 存进保险箱。 */
14
14
  export function pageHtml(locale = 'zh-CN') {
15
15
  const zh = !String(locale).toLowerCase().startsWith('en')
16
+ // 注意:这里只放字符串。函数塞进 JSON.stringify 会整个丢掉,之前 T.total 就是这么炸的。
16
17
  const t = zh
17
- ? { title:'记忆库', total:(n)=>`共 ${n} 条`, recall:'搜一条', recallPh:'关键词,回车或点右侧', vault:'保险箱', vaultPh:'按标识或用途筛选', write:'写一条', plane:'平面', wTitle:'标题', wBody:'正文', wRead:'读时机(什么时候该读这条)', save:'保存', detail:'详情', edit:'编辑', cancel:'取消', back:'返回', del:'删除', empty:'还没有记录', emptyHit:'没有匹配的记录', emptyVault:'保险箱是空的', loading:'读取中…', ok:'已保存', fail:'操作失败:', purpose:'用途', updated:'更新时间', id:'ID', bytes:'大小', verified:'校验' }
18
- : { title:'Memory', total:(n)=>`${n} records`, recall:'Search', recallPh:'keyword, Enter to search', vault:'Vault', vaultPh:'filter by ident or purpose', write:'Write', plane:'Plane', wTitle:'Title', wBody:'Body', wRead:'Read when', save:'Save', detail:'Detail', edit:'Edit', cancel:'Cancel', back:'Back', del:'Delete', empty:'Nothing yet', emptyHit:'No match', emptyVault:'Vault is empty', loading:'Loading…', ok:'Saved', fail:'Failed: ', purpose:'Purpose', updated:'Updated', id:'ID', bytes:'Size', verified:'Verified' }
18
+ ? {
19
+ title:'记忆库', sect:'插件内容', memories:'普通记忆', planes:'平面', tblHead1:'写入平面', tblHead2:'条数 / 状态',
20
+ recall:'召回', keyword:'关键词', keywordPh:'输入关键词…', go:'查', none:'暂无数据', hits:(n,tot)=>`命中 ${n} 条(共 ${tot} 条)`,
21
+ saveMem:'存进记忆', saveVault:'存进保险箱',
22
+ vault:'保险箱', vaultSub:'凭据单独存放,不进普通记忆', filter:'筛选', filterPh:'标识或用途…', filterBtn:'筛',
23
+ vaultCount:(shown,total)=>`共 ${total} 条,显示 ${shown} 条`, vaultEmpty:'保险箱是空的',
24
+ plane:'平面', titleField:'标题', bodyField:'正文', readWhen:'读时机(什么时候该读这条)', purpose:'用途',
25
+ save:'保存', detail:'详情', edit:'编辑', cancel:'取消', back:'返回',
26
+ total:(n)=>`共 ${n} 条`, fail:'操作失败:', needBoth:'标题与正文都要填', required:'必填',
27
+ planes_:{soul:'自身原则',rules:'硬规则',profile:'用户画像',explicit:'明确要点',long_term:'长期事实',episodic:'事件记录'},
28
+ vaultRow:'独立保险箱',
29
+ }
30
+ : {
31
+ title:'Memory', sect:'Plugin content', memories:'Memories', planes:'Planes', tblHead1:'Plane', tblHead2:'Count / state',
32
+ recall:'Recall', keyword:'Keyword', keywordPh:'type a keyword…', go:'Search', none:'No data', hits:(n,tot)=>`${n} hits (of ${tot})`,
33
+ saveMem:'Save to memory', saveVault:'Save to vault',
34
+ vault:'Vault', vaultSub:'Secrets live apart from ordinary memory', filter:'Filter', filterPh:'ident or purpose…', filterBtn:'Filter',
35
+ vaultCount:(shown,total)=>`${total} total, ${shown} shown`, vaultEmpty:'Vault is empty',
36
+ plane:'Plane', titleField:'Title', bodyField:'Body', readWhen:'Read when', purpose:'Purpose',
37
+ save:'Save', detail:'Detail', edit:'Edit', cancel:'Cancel', back:'Back',
38
+ total:(n)=>`${n} records`, fail:'Failed: ', needBoth:'Title and body are required', required:'required',
39
+ planes_:{soul:'Principles',rules:'Rules',profile:'Profile',explicit:'Explicit',long_term:'Long-term',episodic:'Episodes'},
40
+ vaultRow:'Vault',
41
+ }
42
+ const plain = { ...t }
43
+ delete plain.total
44
+ delete plain.hits
45
+ delete plain.vaultCount
19
46
 
20
47
  return `<!doctype html>
21
48
  <html lang="${zh ? 'zh-CN' : 'en'}"><head>
22
49
  <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
23
50
  <title>${t.title}</title>
24
51
  <style>
25
- :root{
26
- --bg:#0f1312;--card:#161c1b;--card2:#1c2423;--ink:#e9efee;--muted:#8d9c99;--line:#26302e;
27
- --accent:#5fd3c6;--accent-ink:#06201d;--accent-weak:#14302c;--danger:#f97066;
28
- }
29
- @media (prefers-color-scheme:light){:root{
30
- --bg:#f6f8f7;--card:#fff;--card2:#f2f5f4;--ink:#141a19;--muted:#66716f;--line:#e2e8e6;
31
- --accent:#0f766e;--accent-ink:#fff;--accent-weak:#e4f3f0;--danger:#c0261d;
32
- }}
33
- *{box-sizing:border-box}
34
- html,body{margin:0;background:var(--bg);color:var(--ink)}
52
+ :root{--bg:#0d1110;--panel:#141a19;--field:#1a2221;--ink:#e9efee;--muted:#899694;--line:#232c2b;--accent:#5fd3c6;--accent-ink:#04211e;--danger:#f97066}
53
+ @media (prefers-color-scheme:light){:root{--bg:#f4f7f6;--panel:#fff;--field:#f1f5f4;--ink:#121817;--muted:#65716f;--line:#e0e7e5;--accent:#0f766e;--accent-ink:#fff;--danger:#c0261d}}
54
+ *{box-sizing:border-box}html,body{margin:0;background:var(--bg);color:var(--ink)}
35
55
  body{font:15px/1.6 -apple-system,system-ui,"PingFang SC","Noto Sans CJK SC",sans-serif;-webkit-font-smoothing:antialiased}
36
- .wrap{max-width:820px;margin:0 auto;padding:20px 16px 80px}
37
- header{display:flex;align-items:baseline;gap:10px;margin-bottom:16px}
38
- h1{font-size:20px;font-weight:600;margin:0;letter-spacing:.01em}
39
- .total{color:var(--muted);font-size:13px;font-variant-numeric:tabular-nums}
40
- h2{font-size:14px;font-weight:600;margin:0 0 12px;color:var(--muted);letter-spacing:.02em}
41
- .card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:16px;margin-bottom:14px}
42
- .planes{display:flex;flex-wrap:wrap;gap:7px;margin-bottom:14px}
43
- .pill{background:var(--card);border:1px solid var(--line);border-radius:999px;padding:5px 11px;font-size:12.5px;color:var(--muted);font-variant-numeric:tabular-nums}
44
- .pill b{color:var(--ink);font-weight:600;margin-left:5px}
45
- .row{display:flex;gap:9px}
46
- input,textarea,select{width:100%;background:var(--card2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;color:var(--ink);font:inherit;outline:none}
56
+ .wrap{max-width:760px;margin:0 auto;padding:18px 16px 72px}
57
+ h1{font-size:19px;font-weight:600;margin:0 0 4px}
58
+ .sub{color:var(--muted);font-size:13px;margin:0 0 18px}
59
+ section{margin-bottom:26px}
60
+ .sect{font-size:15px;font-weight:600;padding-bottom:10px;border-bottom:1px solid var(--line);margin-bottom:14px}
61
+ .lab{display:block;font-size:13px;color:var(--muted);margin-bottom:7px}
62
+ .rowline{display:flex;justify-content:space-between;align-items:baseline;padding:9px 0}
63
+ .rowline span{color:var(--muted);font-size:13.5px}
64
+ .big{font-size:34px;font-weight:600;line-height:1.1;font-variant-numeric:tabular-nums;color:var(--accent);letter-spacing:-.02em}
65
+ .big.sm{font-size:26px}
66
+ table{width:100%;border-collapse:collapse;margin-top:12px;font-size:13.5px}
67
+ th{text-align:left;color:var(--muted);font-weight:400;font-size:12.5px;padding:6px 0;border-bottom:1px solid var(--line)}
68
+ th:last-child,td:last-child{text-align:right}
69
+ td{padding:9px 0;border-bottom:1px solid var(--line);color:var(--ink)}
70
+ td:last-child{color:var(--muted);font-variant-numeric:tabular-nums}
71
+ tr:last-child td{border-bottom:0}
72
+ .fieldwrap{position:relative;margin-bottom:12px}
73
+ input,textarea,select{width:100%;background:var(--field);border:1px solid var(--line);border-radius:11px;padding:11px 13px;color:var(--ink);font:inherit;outline:none}
47
74
  input:focus,textarea:focus,select:focus{border-color:var(--accent)}
48
- textarea{min-height:140px;resize:vertical;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:13.5px;line-height:1.65}
49
- button{background:var(--accent);color:var(--accent-ink);border:0;border-radius:10px;padding:10px 16px;font:inherit;font-weight:500;cursor:pointer;white-space:nowrap}
75
+ textarea{min-height:130px;resize:vertical;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:13.5px;line-height:1.65}
76
+ .cnt{position:absolute;right:11px;bottom:8px;font-size:11.5px;color:var(--muted);font-variant-numeric:tabular-nums;pointer-events:none}
77
+ button{background:var(--accent);color:var(--accent-ink);border:0;border-radius:11px;padding:11px 16px;font:inherit;font-weight:500;cursor:pointer}
78
+ button.wide{display:block;width:100%}
50
79
  button.ghost{background:transparent;color:var(--accent);border:1px solid var(--line)}
51
80
  button:disabled{opacity:.5;cursor:default}
52
- .field{margin-bottom:12px}
53
- .label{font-size:12.5px;color:var(--muted);margin-bottom:6px}
54
- .list{margin-top:12px}
55
- .item{padding:11px 12px;border-radius:10px;cursor:pointer;border:1px solid transparent}
56
- .item:hover{background:var(--card2);border-color:var(--line)}
57
- .item .t{font-weight:500;font-size:14.5px}
58
- .item .m{color:var(--muted);font-size:12.5px;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
59
- .hint{color:var(--muted);font-size:13px;padding:8px 0}
81
+ .hint{color:var(--muted);font-size:13.5px;padding:14px 0}
60
82
  .err{color:var(--danger);font-size:13px;margin-top:10px}
83
+ .item{display:flex;align-items:center;gap:11px;padding:12px 10px;border-bottom:1px solid var(--line);cursor:pointer;border-radius:8px}
84
+ .item:hover{background:var(--panel)}
85
+ .item:last-child{border-bottom:0}
86
+ .ico{width:22px;height:22px;flex:none;color:var(--muted)}
87
+ .txt{flex:1;min-width:0}
88
+ .t{font-size:14.5px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
89
+ .m{color:var(--muted);font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px}
90
+ .bytes{color:var(--muted);font-size:12.5px;font-variant-numeric:tabular-nums;flex:none}
91
+ .chev{color:var(--muted);font-size:17px;flex:none;opacity:.6}
92
+ details{border:1px solid var(--line);border-radius:12px;padding:0 14px;margin-bottom:22px;background:var(--panel)}
93
+ summary{cursor:pointer;padding:13px 0;font-size:14.5px;list-style:none;display:flex;justify-content:space-between;align-items:center}
94
+ summary::-webkit-details-marker{display:none}
95
+ summary::after{content:"▾";color:var(--muted);font-size:12px}
96
+ details[open] summary::after{transform:rotate(180deg)}
97
+ details .inner{padding:4px 0 16px;border-top:1px solid var(--line)}
61
98
  #detail{position:fixed;inset:0;background:var(--bg);overflow:auto;display:none;z-index:9}
62
99
  #detail.on{display:block}
63
- #detail .inner{max-width:820px;margin:0 auto;padding:20px 16px 80px}
64
- .dtitle{font-size:19px;font-weight:600;line-height:1.4;margin-bottom:14px}
65
- .meta{display:grid;grid-template-columns:auto 1fr;gap:7px 16px;font-size:13px;color:var(--muted);margin-bottom:16px;padding:12px 14px;background:var(--card);border:1px solid var(--line);border-radius:12px}
100
+ #detail .inner{max-width:760px;margin:0 auto;padding:18px 16px 72px}
101
+ .dtitle{font-size:18px;font-weight:600;line-height:1.45;margin-bottom:14px}
102
+ .meta{display:grid;grid-template-columns:auto 1fr;gap:7px 16px;font-size:13px;color:var(--muted);margin-bottom:16px;padding:12px 14px;background:var(--panel);border:1px solid var(--line);border-radius:12px}
66
103
  .meta b{font-weight:500}
67
- .body{white-space:pre-wrap;word-break:break-word;font-size:14.5px;line-height:1.75;background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px}
104
+ .body{white-space:pre-wrap;word-break:break-word;font-size:14.5px;line-height:1.75;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:15px}
68
105
  .acts{display:flex;gap:9px;flex-wrap:wrap;margin-top:18px}
69
106
  </style></head><body>
70
107
 
71
108
  <div class="wrap">
72
- <header><h1>${t.title}</h1><span class="total" id="total"></span></header>
73
- <div class="planes" id="planes"></div>
74
-
75
- <section class="card">
76
- <div class="row"><input id="q" placeholder="${t.recallPh}" autocomplete="off"><button id="go">${t.recall}</button></div>
77
- <div class="list" id="results"></div>
109
+ <h1>${t.title}</h1>
110
+ <p class="sub" id="sub"></p>
111
+
112
+ <section>
113
+ <div class="sect">${t.memories === 'Memories' ? 'Plugin content' : '插件内容'}</div>
114
+ <div class="rowline"><span>${t.memories}</span><b class="big" id="total">0</b></div>
115
+ <div class="rowline"><span>${t.planes}</span><b class="big sm" id="planeCount">0</b></div>
116
+ <table><thead><tr><th>${t.tblHead1}</th><th>${t.tblHead2}</th></tr></thead><tbody id="ptable"></tbody></table>
78
117
  </section>
79
118
 
80
- <section class="card">
81
- <h2>${t.vault}</h2>
82
- <div class="row"><input id="vq" placeholder="${t.vaultPh}" autocomplete="off"><button class="ghost" id="vgo">${t.recall}</button></div>
83
- <div class="list" id="vlist"></div>
119
+ <section>
120
+ <div class="sect">${t.recall}</div>
121
+ <label class="lab">${t.keyword}</label>
122
+ <div class="fieldwrap"><input id="q" maxlength="120" placeholder="${t.keywordPh}" autocomplete="off"><span class="cnt" id="qcnt">0/120</span></div>
123
+ <button class="wide" id="go">${t.go}</button>
124
+ <div id="results"><div class="hint">${t.none}</div></div>
84
125
  </section>
85
126
 
86
- <section class="card">
87
- <h2>${t.write}</h2>
88
- <div class="field"><div class="label">${t.plane}</div>
89
- <select id="wp"><option value="explicit">explicit</option><option value="long_term">long_term</option><option value="episodic">episodic</option><option value="rules">rules</option><option value="profile">profile</option><option value="soul">soul</option></select></div>
90
- <div class="field"><div class="label">${t.wTitle}</div><input id="wt"></div>
91
- <div class="field"><div class="label">${t.wBody}</div><textarea id="wb"></textarea></div>
92
- <div class="field"><div class="label">${t.wRead}</div><input id="wr"></div>
93
- <button id="wsave">${t.save}</button>
127
+ <details><summary>${t.saveMem}</summary><div class="inner">
128
+ <label class="lab">${t.plane}</label>
129
+ <select id="wp"><option>soul</option><option>rules</option><option>profile</option><option selected>explicit</option><option>long_term</option><option>episodic</option></select>
130
+ <label class="lab" style="margin-top:12px">${t.titleField}</label><input id="wt">
131
+ <label class="lab" style="margin-top:12px">${t.bodyField}</label><textarea id="wb"></textarea>
132
+ <label class="lab" style="margin-top:12px">${t.readWhen}</label><input id="wr">
133
+ <button style="margin-top:14px" id="wsave">${t.save}</button>
94
134
  <div class="err" id="werr"></div>
135
+ </div></details>
136
+
137
+ <section>
138
+ <div class="sect">${t.vault}</div>
139
+ <p class="sub">${t.vaultSub}</p>
140
+ <label class="lab">${t.filter}</label>
141
+ <div class="fieldwrap"><input id="vq" maxlength="120" placeholder="${t.filterPh}" autocomplete="off"><span class="cnt" id="vcnt">0/120</span></div>
142
+ <button class="wide ghost" id="vgo">${t.filterBtn}</button>
143
+ <div class="hint" id="vcount"></div>
144
+ <div id="vlist"></div>
95
145
  </section>
146
+
147
+ <details><summary>${t.saveVault}</summary><div class="inner">
148
+ <label class="lab">标识</label><input id="vi">
149
+ <label class="lab" style="margin-top:12px">${t.purpose}</label><input id="vp">
150
+ <label class="lab" style="margin-top:12px">${t.bodyField}</label><textarea id="vb"></textarea>
151
+ <button style="margin-top:14px" id="vsave">${t.save}</button>
152
+ <div class="err" id="verr"></div>
153
+ </div></details>
96
154
  </div>
97
155
 
98
156
  <div id="detail"><div class="inner">
@@ -110,11 +168,16 @@ button:disabled{opacity:.5;cursor:default}
110
168
  </div></div>
111
169
 
112
170
  <script>
113
- const T = ${JSON.stringify(t)};
171
+ const T = ${JSON.stringify(plain)};
172
+ const PLANE_NAMES = ${JSON.stringify(t.planes_)};
173
+ const ORDER = ['soul','rules','profile','explicit','long_term','episodic'];
114
174
  const $ = (id) => document.getElementById(id);
115
175
  const esc = (v) => String(v == null ? '' : v).replace(/[&<>"]/g, (c) => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
116
- let D = null; // 当前详情
117
- let EDITING = false;
176
+ const fmtTotal = (n) => ${JSON.stringify(zh ? '共 ' : '')} + n + ${JSON.stringify(zh ? ' 条' : ' records')};
177
+ const fmtHits = (n, tot) => ${JSON.stringify(zh ? '命中 ' : '')} + n + ${JSON.stringify(zh ? ' 条(共 ' : ' hits (of ')} + tot + ${JSON.stringify(zh ? ' 条)' : ')')};
178
+ const fmtVault = (shown, total) => ${JSON.stringify(zh ? '共 ' : '')} + total + ${JSON.stringify(zh ? ' 条,显示 ' : ' total, ')} + shown + ${JSON.stringify(zh ? ' 条' : ' shown')};
179
+
180
+ let D = null, EDITING = false, VAULT_ALL = [];
118
181
 
119
182
  async function api(name, body) {
120
183
  const opt = body === undefined ? {} : { method:'POST', headers:{'content-type':'application/json'}, body: JSON.stringify(body) };
@@ -124,38 +187,56 @@ async function api(name, body) {
124
187
  return JSON.parse(text);
125
188
  }
126
189
 
127
- function renderPlanes(planes, total) {
128
- const order = ['soul','rules','profile','explicit','long_term','episodic'];
129
- $('planes').innerHTML = order.map((k) => '<span class="pill">' + k + '<b>' + (planes[k] || 0) + '</b></span>').join('');
130
- $('total').textContent = T.total(total || 0);
190
+ function renderState(planes, total) {
191
+ $('total').textContent = total || 0;
192
+ const vals = ORDER.map((k) => planes[k] || 0);
193
+ $('planeCount').textContent = vals.filter((v) => v > 0).length;
194
+ const rows = ORDER.map((k) => '<tr><td>' + esc(PLANE_NAMES[k] || k) + '</td><td>' + (planes[k] || 0) + '</td></tr>');
195
+ rows.push('<tr><td>' + ${JSON.stringify(zh ? '凭据库' : 'Vault')} + '</td><td>' + ${JSON.stringify(zh ? '独立保险箱' : 'separate vault')} + '</td></tr>');
196
+ $('ptable').innerHTML = rows.join('');
197
+ $('sub').textContent = fmtTotal(total || 0);
131
198
  }
132
199
 
133
- function renderItems(el, rows, kind, emptyText) {
200
+ const DOC = '<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3.5h8l4 4V20a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4.5a1 1 0 0 1 1-1Z"/><path d="M14 3.5V8h4"/></svg>';
201
+
202
+ function renderMemoryList(el, rows, emptyText, onClick) {
134
203
  if (!rows || rows.length === 0) { el.innerHTML = '<div class="hint">' + esc(emptyText) + '</div>'; return; }
135
- el.innerHTML = rows.map((r, i) => '<div class="item" data-i="' + i + '"><div class="t">' + esc(r.title || r.ident || '(无标题)') +
136
- '</div><div class="m">' + esc((r.plane ? r.plane + ' · ' : '') + String(r.preview || r.purpose || '').slice(0, 90)) + '</div></div>').join('');
137
- [...el.querySelectorAll('.item')].forEach((node) => {
138
- node.onclick = () => openDetail(rows[Number(node.dataset.i)], kind);
139
- });
204
+ el.innerHTML = rows.map((r, i) =>
205
+ '<div class="item" data-i="' + i + '">' + DOC +
206
+ '<div class="txt"><div class="t">' + esc(r.title || '(无标题)') + '</div><div class="m">' + esc((r.plane || '') + ' · ' + String(r.preview || '').slice(0, 90)) + '</div></div>' +
207
+ '<div class="chev">›</div></div>').join('');
208
+ [...el.querySelectorAll('.item')].forEach((n) => { n.onclick = () => onClick(rows[Number(n.dataset.i)]); });
209
+ }
210
+
211
+ function renderVaultList(rows) {
212
+ const el = $('vlist');
213
+ if (!rows || rows.length === 0) { el.innerHTML = '<div class="hint">' + esc(T.vaultEmpty) + '</div>'; return; }
214
+ el.innerHTML = rows.map((r, i) =>
215
+ '<div class="item" data-v="' + i + '">' + DOC +
216
+ '<div class="txt"><div class="t">' + esc(r.ident) + '</div><div class="m">' + esc(r.purpose || '') + '</div></div>' +
217
+ '<div class="bytes">' + (r.bytes || 0) + 'B</div><div class="chev">›</div></div>').join('');
218
+ [...el.querySelectorAll('.item')].forEach((n) => { n.onclick = () => openDetail(rows[Number(n.dataset.v)], 'vault'); });
140
219
  }
141
220
 
142
221
  async function boot() {
143
222
  try {
144
223
  const s = await api('state');
145
- renderPlanes(s.planes, s.total);
146
- renderItems($('results'), s.hits, 'memory', T.empty);
224
+ renderState(s.planes, s.total);
225
+ renderMemoryList($('results'), s.hits, T.none, (row) => openDetail(row, 'memory'));
147
226
  const v = await api('vault-list', {});
148
- renderItems($('vlist'), v.items, 'vault', T.emptyVault);
149
- } catch (e) { $('results').innerHTML = '<div class="err">' + esc(T.fail + e.message) + '</div>'; }
227
+ VAULT_ALL = v.items || [];
228
+ $('vcount').textContent = fmtVault(VAULT_ALL.length, VAULT_ALL.length);
229
+ renderVaultList(VAULT_ALL);
230
+ } catch (e) {
231
+ $('results').innerHTML = '<div class="err">' + esc(T.fail + e.message) + '</div>';
232
+ }
150
233
  }
151
234
 
152
235
  async function openDetail(row, kind) {
153
236
  try {
154
237
  const d = await api('detail', { id: row.id || row.ident, kind });
155
238
  if (!d.ok) throw new Error(d.reason || 'read failed');
156
- D = d.detail; EDITING = false;
157
- show();
158
- $('detail').classList.add('on');
239
+ D = d.detail; EDITING = false; show(); $('detail').classList.add('on');
159
240
  } catch (e) { alert(T.fail + e.message); }
160
241
  }
161
242
 
@@ -163,19 +244,19 @@ function show() {
163
244
  const isVault = D.kind === 'vault';
164
245
  $('dt').textContent = D.title || '—';
165
246
  const rows = isVault
166
- ? [[T.id, D.id], [T.purpose, D.purpose || '—'], [T.bytes, (D.bytes || 0) + ' B']]
167
- : [[T.plane, D.plane || '—'], [T.updated, D.updated || '—'], [T.id, D.id]];
247
+ ? [[${JSON.stringify(zh ? '标识' : 'Ident')}, D.id], [T.purpose, D.purpose || '—'], [${JSON.stringify(zh ? '大小' : 'Size')}, (D.bytes || 0) + ' B']]
248
+ : [[T.plane, D.plane || '—'], [${JSON.stringify(zh ? 'ID' : 'ID')}, D.id]];
168
249
  $('dm').innerHTML = rows.map(([k, v]) => '<b>' + esc(k) + '</b><span>' + esc(v) + '</span>').join('');
169
250
  $('db').textContent = D.body || '';
170
251
  $('db').style.display = EDITING ? 'none' : '';
171
252
  $('de').style.display = EDITING ? '' : 'none';
172
253
  if (EDITING) {
173
254
  $('de').innerHTML = isVault
174
- ? '<div class="field"><div class="label">' + T.purpose + '</div><input id="ep" value="' + esc(D.purpose || '') + '"></div>' +
175
- '<div class="field"><div class="label">' + T.wBody + '</div><textarea id="eb">' + esc(D.body || '') + '</textarea></div>'
176
- : '<div class="field"><div class="label">' + T.wTitle + '</div><input id="et" value="' + esc(D.title || '') + '"></div>' +
177
- '<div class="field"><div class="label">' + T.wRead + '</div><input id="er" value="' + esc(D.readWhen || '') + '"></div>' +
178
- '<div class="field"><div class="label">' + T.wBody + '</div><textarea id="eb">' + esc(D.body || '') + '</textarea></div>';
255
+ ? '<label class="lab">' + T.purpose + '</label><input id="ep" value="' + esc(D.purpose || '') + '">' +
256
+ '<label class="lab" style="margin-top:12px">' + T.bodyField + '</label><textarea id="eb">' + esc(D.body || '') + '</textarea>'
257
+ : '<label class="lab">' + T.titleField + '</label><input id="et" value="' + esc(D.title || '') + '">' +
258
+ '<label class="lab" style="margin-top:12px">' + T.readWhen + '</label><input id="er" value="' + esc(D.readWhen || '') + '">' +
259
+ '<label class="lab" style="margin-top:12px">' + T.bodyField + '</label><textarea id="eb">' + esc(D.body || '') + '</textarea>';
179
260
  }
180
261
  $('dedit').style.display = EDITING ? 'none' : '';
181
262
  $('dsave').style.display = EDITING ? '' : 'none';
@@ -197,34 +278,51 @@ $('dsave').onclick = async () => {
197
278
  } catch (e) { $('derr').textContent = T.fail + e.message; }
198
279
  };
199
280
 
281
+ $('q').addEventListener('input', () => { $('qcnt').textContent = $('q').value.length + '/120'; });
282
+ $('vq').addEventListener('input', () => { $('vcnt').textContent = $('vq').value.length + '/120'; });
283
+
200
284
  $('go').onclick = async () => {
201
285
  const q = $('q').value.trim();
202
286
  try {
203
287
  const s = await api('search', { query: q });
204
- renderPlanes(s.planes, s.total);
205
- renderItems($('results'), s.hits, 'memory', q === '' ? T.empty : T.emptyHit);
288
+ renderState(s.planes, s.total);
289
+ if (q === '') { renderMemoryList($('results'), s.hits, T.none, (row) => openDetail(row, 'memory')); return; }
290
+ $('results').innerHTML = s.hits.length === 0 ? '<div class="hint">' + esc(T.none) + '</div>'
291
+ : '<div class="hint">' + fmtHits(s.hits.length, s.total) + '</div>' + s.hits.map((r, i) =>
292
+ '<div class="item" data-i="' + i + '">' + DOC + '<div class="txt"><div class="t">' + esc(r.title || '') +
293
+ '</div><div class="m">' + esc((r.plane || '') + ' · ' + String(r.preview || '').slice(0, 90)) + '</div></div><div class="chev">›</div></div>').join('');
294
+ [...$('results').querySelectorAll('.item')].forEach((n) => { n.onclick = () => openDetail(s.hits[Number(n.dataset.i)], 'memory'); });
206
295
  } catch (e) { $('results').innerHTML = '<div class="err">' + esc(T.fail + e.message) + '</div>'; }
207
296
  };
208
297
  $('q').addEventListener('keydown', (e) => { if (e.key === 'Enter') $('go').click(); });
209
298
 
210
299
  $('vgo').onclick = async () => {
211
- try {
212
- const v = await api('vault-list', { query: $('vq').value.trim() });
213
- renderItems($('vlist'), v.items, 'vault', T.emptyVault);
214
- } catch (e) { $('vlist').innerHTML = '<div class="err">' + esc(T.fail + e.message) + '</div>'; }
300
+ const q = $('vq').value.trim().toLowerCase();
301
+ const rows = q === '' ? VAULT_ALL : VAULT_ALL.filter((x) => ((x.ident || '') + ' ' + (x.purpose || '')).toLowerCase().includes(q));
302
+ $('vcount').textContent = fmtVault(rows.length, VAULT_ALL.length);
303
+ renderVaultList(rows);
215
304
  };
216
305
 
217
306
  $('wsave').onclick = async () => {
218
307
  const title = $('wt').value.trim(), body = $('wb').value;
219
- if (title === '' || body.trim() === '') { $('werr').textContent = T.fail + '标题与正文都要填'; return; }
308
+ if (title === '' || body.trim() === '') { $('werr').textContent = T.fail + T.needBoth; return; }
220
309
  try {
221
310
  const r = await api('write', { plane: $('wp').value, title, body, readWhen: $('wr').value.trim() });
222
311
  if (!r.ok) { $('werr').textContent = T.fail + (r.reason || ''); return; }
223
- $('werr').textContent = ''; $('wt').value = ''; $('wb').value = ''; $('wr').value = '';
224
- boot();
312
+ $('werr').textContent = ''; $('wt').value = ''; $('wb').value = ''; $('wr').value = ''; boot();
225
313
  } catch (e) { $('werr').textContent = T.fail + e.message; }
226
314
  };
227
315
 
316
+ $('vsave').onclick = async () => {
317
+ const ident = $('vi').value.trim(), body = $('vb').value;
318
+ if (ident === '' || body === '') { $('verr').textContent = T.fail + T.needBoth; return; }
319
+ try {
320
+ const r = await api('vault-save', { ident, purpose: $('vp').value.trim(), body });
321
+ if (!r.ok) { $('verr').textContent = T.fail + (r.reason || ''); return; }
322
+ $('verr').textContent = ''; $('vi').value = ''; $('vp').value = ''; $('vb').value = ''; boot();
323
+ } catch (e) { $('verr').textContent = T.fail + e.message; }
324
+ };
325
+
228
326
  boot();
229
327
  </script></body></html>`
230
328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aurorix-agentbook",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "dsh-aurorix-agentbook:给 dsh-go 接通 Aurorix 记忆库——原生界面(状态条/胶囊/菜单/面板/保险箱)加宿主侧提示词注入、分层快照与四个工具。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",