@kanyun-ai-infra/band-memory 0.0.0-stage → 0.1.3

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/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # 记忆
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > 项目记忆页:Agent 记下的约定、习惯和术语,人可以改;历史里看每一版、撤回或恢复
4
+
5
+ | | |
6
+ |---|---|
7
+ | 类别 | 设置分页 |
8
+ | 激活范围 | 设置页(随贡献挂载) |
9
+ | 包名 | `@kanyun-ai-infra/band-memory` |
10
+ | 插件协议 | `@kanyun-ai-infra/band-plugin-sdk`,版本见 [`package.json`](package.json) 的 `peerDependencies` |
11
+
12
+ ## 它做什么
13
+
14
+ 项目设置里的「记忆」分页。Agent 记下的约定、习惯和术语都在这里,人可以改;历史里看每一版,撤回或恢复。
15
+
16
+ ## 怎么用
17
+
18
+ 它由部署方案装,工坊不在 `views` 里写它。
19
+
20
+ ## 配置项
21
+
22
+ 无。
23
+
24
+ ## 它提供与消费的接口
25
+
26
+ | 方向 | 插槽 / 服务 | 说明 |
27
+ |---|---|---|
28
+ | 贡献到 | `settings/tabs` | `tab`(记忆) |
29
+
30
+ 插槽全名带 `@kanyun-ai-infra/band-` 前缀。完整声明见 [`plugin.yaml`](plugin.yaml)。
31
+
32
+ ## 想借鉴它的哪里
33
+
34
+ 写类似插件时,值得读的文件:
35
+
36
+ | 想学 | 看 |
37
+ |---|---|
38
+ | 设置分页怎么贡献 | [`src/index.tsx`](src/index.tsx) |
39
+ | 记忆的数据模型 | [`src/model.ts`](src/model.ts) |
40
+ | 组件测试 | [`src/index.test.tsx`](src/index.test.tsx) |
41
+
42
+ ## 单独拷出来跑
43
+
44
+ 这个目录导出到 [band-official-plugins](https://github.com/kanyun-ai-explore/band-official-plugins) 以后,只靠 npm 上的公开包就能装、构建、测试,不用 Band 主仓。要 Node 22.19+。
45
+
46
+ ```bash
47
+ git clone --depth 1 https://github.com/kanyun-ai-explore/band-official-plugins.git
48
+ cp -r band-official-plugins/plugins/memory my-plugin && cd my-plugin
49
+ npm install
50
+ npm run build
51
+ npm test
52
+ ```
53
+
54
+ 拿它改成自己的插件:把 `package.json` 和 `dev/workshop.yaml`(导出时补上的本地夹具工坊)里的 `@kanyun-ai-infra/band-memory` 换成你自己的包名(`@kanyun-ai-infra/band-` 前缀只留给官方插件),再用 `npx @kanyun-ai-infra/band-cli check .` 校验装配。
55
+
56
+ ## 文档
57
+
58
+ - [插槽与贡献](https://github.com/kanyun-ai-explore/band-official-plugins/blob/main/docs/protocol/slots.md)
59
+ - [插件开发起步](https://github.com/kanyun-ai-explore/band-official-plugins/blob/main/docs/plugins/index.md)
60
+
61
+ ## 许可
62
+
63
+ [Apache-2.0](https://github.com/kanyun-ai-explore/band-official-plugins/blob/main/LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,1054 @@
1
+ import { reactMount as Le, deletedProjectText as Oe, useCtxData as T, useMembers as Pe, useRoute as _e, parseMemoryItem as He, withImeGuard as ie, memoryItem as Ve, memberName as We } from "@kanyun-ai-infra/band-plugin-react";
2
+ import { definePlugin as qe, projectPath as Xe } from "@kanyun-ai-infra/band-plugin-sdk";
3
+ import { SettingsHead as k, SettingsNoAccess as P, isForbidden as Ge, SettingsLoading as W, ErrorNote as te, SettingsActions as ke, SettingsEmpty as Ue, SettingsRows as Ye, SettingsRow as Je, SettingsForm as Qe, SettingsField as Ze, memberOrder as en, Avatar as nn, instrumentOf as un } from "band-design";
4
+ import { Markdown as tn, MarkdownInput as rn } from "band-design/markdown";
5
+ import { useState as M, useEffect as _, useRef as Ne, useId as an, useMemo as ve } from "react";
6
+ import { memoryProblem as on, MEMORY_LIMITS as sn, MEMORY_INDEX as re } from "@kanyun-ai-infra/band-contracts";
7
+ import { jsx as u, jsxs as s, Fragment as C } from "react/jsx-runtime";
8
+ if (typeof document < "u" && document.head) {
9
+ const e = `/* src/memory.css */
10
+ .band-memory {
11
+ display: grid;
12
+ gap: 14px;
13
+ min-width: 0;
14
+ }
15
+ .band-memory-grid {
16
+ display: grid;
17
+ grid-template-columns: 220px minmax(0, 1fr);
18
+ gap: 14px;
19
+ align-items: start;
20
+ }
21
+ .band-memory-versions {
22
+ list-style: none;
23
+ margin: 0;
24
+ padding: 0;
25
+ display: grid;
26
+ gap: 2px;
27
+ }
28
+ .band-memory-version {
29
+ display: flex;
30
+ gap: 8px;
31
+ align-items: flex-start;
32
+ width: 100%;
33
+ border: 0;
34
+ background: none;
35
+ padding: 7px 10px;
36
+ border-radius: var(--r);
37
+ text-align: left;
38
+ color: inherit;
39
+ font: inherit;
40
+ font-size: var(--fs-row);
41
+ cursor: pointer;
42
+ transition: background var(--sixteenth) var(--ease);
43
+ }
44
+ :where(.band-memory-version) .av {
45
+ margin-top: 1px;
46
+ }
47
+ :where(.band-memory-version):hover {
48
+ background: var(--fill);
49
+ }
50
+ :where(.band-memory-version)[aria-current=true] {
51
+ background: var(--fill-2);
52
+ }
53
+ :where(.band-memory-version):focus-visible {
54
+ outline: none;
55
+ box-shadow: 0 0 0 2px var(--accent);
56
+ }
57
+ .band-memory-fname {
58
+ display: grid;
59
+ gap: 1px;
60
+ min-width: 0;
61
+ }
62
+ .band-memory-fname > span:first-child {
63
+ overflow: hidden;
64
+ text-overflow: ellipsis;
65
+ white-space: nowrap;
66
+ }
67
+ .band-memory-fname > span + span {
68
+ font-size: var(--fs-meta);
69
+ color: var(--muted);
70
+ }
71
+ .band-memory-link {
72
+ display: inline-flex;
73
+ align-items: center;
74
+ gap: 6px;
75
+ justify-self: start;
76
+ border: 0;
77
+ background: none;
78
+ padding: 6px 10px;
79
+ border-radius: var(--r);
80
+ color: var(--muted);
81
+ font: inherit;
82
+ font-size: var(--fs-ui);
83
+ cursor: pointer;
84
+ }
85
+ :where(.band-memory-link):hover:not(:disabled) {
86
+ background: var(--fill);
87
+ color: var(--ink);
88
+ }
89
+ :where(.band-memory-link):focus-visible {
90
+ outline: none;
91
+ box-shadow: 0 0 0 2px var(--accent);
92
+ }
93
+ .band-memory-link:where(:disabled) {
94
+ color: var(--muted);
95
+ opacity: 0.42;
96
+ cursor: default;
97
+ }
98
+ .band-memory-link {
99
+ padding: 2px 4px;
100
+ margin-left: -4px;
101
+ color: var(--accent-text);
102
+ }
103
+ .band-memory-hint {
104
+ display: grid;
105
+ gap: 4px;
106
+ padding: 8px 10px;
107
+ font-size: var(--fs-meta);
108
+ line-height: 1.6;
109
+ color: var(--muted);
110
+ }
111
+ .band-memory-hint code,
112
+ .band-memory-edithead code,
113
+ .band-memory-changehead code {
114
+ font-family: var(--mono);
115
+ font-size: var(--fs-meta);
116
+ }
117
+ .band-memory-over {
118
+ color: var(--bad);
119
+ }
120
+ input.band-memory-newinput {
121
+ font-family: var(--mono);
122
+ font-size: var(--fs-dense);
123
+ }
124
+ .band-memory-edit {
125
+ display: grid;
126
+ gap: 8px;
127
+ min-width: 0;
128
+ background: var(--panel);
129
+ border-radius: var(--r-lg);
130
+ box-shadow: var(--shadow-card);
131
+ padding: 12px 14px;
132
+ }
133
+ .band-memory-edithead {
134
+ display: flex;
135
+ justify-content: space-between;
136
+ align-items: baseline;
137
+ gap: 12px;
138
+ flex-wrap: wrap;
139
+ font-size: var(--fs-dense);
140
+ color: var(--muted);
141
+ }
142
+ .band-memory-edithead code,
143
+ .band-memory-edithead b {
144
+ color: var(--ink);
145
+ font-weight: 500;
146
+ }
147
+ .band-memory-view {
148
+ max-height: 60vh;
149
+ overflow: auto;
150
+ overscroll-behavior: contain;
151
+ padding: 12px 14px;
152
+ border-radius: var(--r);
153
+ background: var(--sunk);
154
+ }
155
+ .band-memory-editfoot {
156
+ display: flex;
157
+ align-items: center;
158
+ gap: 6px;
159
+ flex-wrap: wrap;
160
+ }
161
+ .band-memory-spacer {
162
+ flex: 1;
163
+ }
164
+ .band-memory-removed {
165
+ display: grid;
166
+ justify-items: start;
167
+ gap: 6px;
168
+ padding: 18px 14px;
169
+ border-radius: var(--r);
170
+ background: var(--bad-soft);
171
+ font-size: var(--fs-row);
172
+ }
173
+ .band-memory-removed span {
174
+ color: var(--muted);
175
+ }
176
+ .band-memory-err {
177
+ font-size: var(--fs-dense);
178
+ color: var(--bad);
179
+ }
180
+ .band-memory-note,
181
+ .band-memory-notice {
182
+ display: block;
183
+ font-size: var(--fs-ui);
184
+ color: var(--muted);
185
+ }
186
+ .band-memory-notice:where(.ok) {
187
+ color: var(--ok);
188
+ }
189
+ .band-memory-notice:where(.bad) {
190
+ color: var(--bad);
191
+ }
192
+ .band-memory-stale {
193
+ display: grid;
194
+ gap: 4px;
195
+ padding: 12px 14px;
196
+ border-radius: var(--r-lg);
197
+ background: var(--warn-soft);
198
+ font-size: var(--fs-row);
199
+ }
200
+ .band-memory-stale b {
201
+ font-weight: 500;
202
+ }
203
+ .band-memory-stale span {
204
+ color: var(--muted);
205
+ }
206
+ .band-memory-stale-acts {
207
+ display: flex;
208
+ gap: 6px;
209
+ justify-content: flex-end;
210
+ margin-top: 4px;
211
+ }
212
+ .band-memory-faint {
213
+ font-size: var(--fs-dense);
214
+ color: var(--muted);
215
+ }
216
+ .band-memory-history {
217
+ display: grid;
218
+ gap: 12px;
219
+ }
220
+ .band-memory-change {
221
+ display: grid;
222
+ gap: 6px;
223
+ }
224
+ .band-memory-changehead {
225
+ display: flex;
226
+ gap: 8px;
227
+ align-items: baseline;
228
+ font-size: var(--fs-dense);
229
+ color: var(--muted);
230
+ }
231
+ .band-memory-changehead code {
232
+ color: var(--ink);
233
+ }
234
+ .band-memory-diff {
235
+ font-family: var(--mono);
236
+ font-size: var(--fs-meta);
237
+ line-height: 1.7;
238
+ border-radius: var(--r);
239
+ background: var(--sunk);
240
+ padding: 6px 0;
241
+ overflow-x: auto;
242
+ }
243
+ .band-memory-line {
244
+ display: grid;
245
+ grid-template-columns: 22px minmax(0, 1fr);
246
+ padding-right: 10px;
247
+ white-space: pre-wrap;
248
+ word-break: break-word;
249
+ }
250
+ .band-memory-line > span:first-child {
251
+ text-align: center;
252
+ color: var(--muted);
253
+ user-select: none;
254
+ }
255
+ .band-memory-line:where(.add) {
256
+ background: var(--ok-soft);
257
+ }
258
+ .band-memory-line:where(.del) {
259
+ background: var(--bad-soft);
260
+ }
261
+ .band-memory-line:where(.del) > span:last-child {
262
+ text-decoration: line-through;
263
+ text-decoration-color: color-mix(in srgb, var(--bad) 50%, transparent);
264
+ }
265
+ .band-memory-fold {
266
+ padding: 2px 10px 2px 22px;
267
+ color: var(--muted);
268
+ }
269
+ .band-memory-state {
270
+ display: grid;
271
+ justify-items: center;
272
+ gap: 10px;
273
+ padding: 56px 16px;
274
+ text-align: center;
275
+ }
276
+ @media (max-width: 720px) {
277
+ .band-memory-grid {
278
+ grid-template-columns: minmax(0, 1fr);
279
+ }
280
+ }
281
+ `;
282
+ let n = document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-memory"]');
283
+ n || (n = document.createElement("style"), n.setAttribute("data-band-style", "@kanyun-ai-infra/band-memory"), document.head.prepend(n)), n.textContent = e;
284
+ }
285
+ function de(e) {
286
+ return [...new Set(e)].sort(
287
+ (n, t) => n === re ? -1 : t === re ? 1 : n.localeCompare(t)
288
+ );
289
+ }
290
+ function dn(e, n) {
291
+ return de([...e.map((t) => t.path), ...n.keys()]);
292
+ }
293
+ function ae(e, n, t) {
294
+ const a = t.get(e);
295
+ if (!a) return !1;
296
+ const o = n.find((d) => d.path === e);
297
+ return a.removed ? o !== void 0 : o === void 0 || o.content !== a.content;
298
+ }
299
+ function $e(e, n) {
300
+ return de([...n.keys()].filter((t) => ae(t, e, n)));
301
+ }
302
+ function ln(e, n) {
303
+ const t = [], a = [];
304
+ for (const o of $e(e, n)) {
305
+ const d = n.get(o);
306
+ d && (d.removed ? a.push(o) : t.push({ path: o, content: d.content }));
307
+ }
308
+ return { files: t, removed: a };
309
+ }
310
+ function cn(e, n) {
311
+ const t = new Map(e.map((a) => [a.path, a.content]));
312
+ for (const [a, o] of n)
313
+ o.removed ? t.delete(a) : t.set(a, o.content);
314
+ return de(t.keys()).map((a) => ({ path: a, content: t.get(a) ?? "" }));
315
+ }
316
+ function mn(e) {
317
+ const n = new TextEncoder();
318
+ return e.reduce((t, a) => t + n.encode(a.content).byteLength, 0);
319
+ }
320
+ function pn(e) {
321
+ const n = mn(e) / 1024, t = n === 0 ? "0" : n < 0.1 ? "0.1" : n.toFixed(1).replace(/\.0$/, "");
322
+ return `${e.length} 个文件 · ${t} KB / ${sn.maxTotalBytes / 1024} KB`;
323
+ }
324
+ function Fn(e, n) {
325
+ const t = e.trim().replace(/\.md$/i, "").toLowerCase().replace(/\s+/g, "-");
326
+ if (!t) return { ok: !1, message: "写个文件名" };
327
+ const a = t === "memory" ? re : `${t}.md`;
328
+ return /^(MEMORY|[a-z0-9-]+)\.md$/.test(a) ? n.includes(a) ? { ok: !1, message: `已经有 ${a} 了` } : { ok: !0, path: a } : { ok: !1, message: "文件名只用小写字母、数字和连字符" };
329
+ }
330
+ function fn(e, n) {
331
+ const t = /* @__PURE__ */ new Map(), a = [...e].sort((o, d) => d.version.version - o.version.version);
332
+ for (const o of a)
333
+ for (const d of o.changed)
334
+ n.includes(d) && !t.has(d) && t.set(d, o.version);
335
+ return t;
336
+ }
337
+ function Ce(e) {
338
+ switch (e.action) {
339
+ case "turn":
340
+ return "在回合里写入";
341
+ case "edit":
342
+ return "编辑";
343
+ case "revert":
344
+ return `撤回第 ${e.revertsVersion} 版的改动`;
345
+ case "restore":
346
+ return `恢复到第 ${e.revertsVersion} 版`;
347
+ }
348
+ }
349
+ var De = 800;
350
+ function hn(e, n) {
351
+ const t = Ae(e), a = Ae(n);
352
+ if (t.length * a.length > De * De)
353
+ return [
354
+ ...t.map((p) => ({ kind: "del", text: p })),
355
+ ...a.map((p) => ({ kind: "add", text: p }))
356
+ ];
357
+ const o = t.length, d = a.length, b = Array.from({ length: o + 1 }, () => new Uint16Array(d + 1));
358
+ for (let p = o - 1; p >= 0; p--) {
359
+ const B = b[p], A = b[p + 1];
360
+ for (let h = d - 1; h >= 0; h--)
361
+ B[h] = t[p] === a[h] ? (A[h + 1] ?? 0) + 1 : Math.max(A[h] ?? 0, B[h + 1] ?? 0);
362
+ }
363
+ const c = [];
364
+ let l = 0, m = 0;
365
+ for (; l < o && m < d; )
366
+ t[l] === a[m] ? (c.push({ kind: "same", text: t[l] }), l++, m++) : (b[l + 1]?.[m] ?? 0) >= (b[l]?.[m + 1] ?? 0) ? c.push({ kind: "del", text: t[l++] }) : c.push({ kind: "add", text: a[m++] });
367
+ for (; l < o; ) c.push({ kind: "del", text: t[l++] });
368
+ for (; m < d; ) c.push({ kind: "add", text: a[m++] });
369
+ return c;
370
+ }
371
+ function Ae(e) {
372
+ return e === void 0 || e === "" ? [] : e.replace(/\n$/, "").split(`
373
+ `);
374
+ }
375
+ function En(e, n = 2) {
376
+ const t = e.map(() => !1);
377
+ e.forEach((d, b) => {
378
+ if (d.kind !== "same")
379
+ for (let c = Math.max(0, b - n); c <= Math.min(e.length - 1, b + n); c++)
380
+ t[c] = !0;
381
+ });
382
+ const a = [];
383
+ let o = 0;
384
+ for (; o < e.length; )
385
+ if (t[o]) {
386
+ const d = [];
387
+ for (; o < e.length && t[o]; ) d.push(e[o++]);
388
+ a.push({ kind: "lines", lines: d });
389
+ } else {
390
+ let d = 0;
391
+ for (; o < e.length && !t[o]; )
392
+ d++, o++;
393
+ a.push({ kind: "fold", count: d });
394
+ }
395
+ return a;
396
+ }
397
+ function bn(e, n, t) {
398
+ const a = new Map(n.map((o) => [o.path, o.content]));
399
+ return t.filter((o) => e.get(o) !== a.get(o));
400
+ }
401
+ var R = (e) => String(e).padStart(2, "0");
402
+ function q(e) {
403
+ const n = new Date(e);
404
+ return Number.isNaN(n.getTime()) ? "" : `${R(n.getMonth() + 1)}-${R(n.getDate())} ${R(n.getHours())}:${R(n.getMinutes())}`;
405
+ }
406
+ var L = "@kanyun-ai-infra/band-settings/settings", oe = "memory", S = "Agent 在这个项目里记下的文件。可以改、看历史、撤回。", ue = "new", On = qe({
407
+ surfaces: {
408
+ tab: Le((e) => /* @__PURE__ */ u(yn, { ctx: e }))
409
+ }
410
+ });
411
+ function O(e, n) {
412
+ return {
413
+ project: e.project.id,
414
+ ...e.project.workshop ? { workshop: e.project.workshop } : {},
415
+ tab: oe,
416
+ ...n ? { item: n } : {}
417
+ };
418
+ }
419
+ function we(e, n) {
420
+ return Xe(e.project, "settings", ...n ? [oe, n] : [oe]);
421
+ }
422
+ var H = ".agent/memory/", Bn = 30, xe = 6, V = "memory.updated";
423
+ function yn({ ctx: e }) {
424
+ return e.memory ? e.project.deleted ? /* @__PURE__ */ s(C, { children: [
425
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S }),
426
+ /* @__PURE__ */ u(P, { title: Oe(e.project.deleted), children: "记忆跟着项目一起停用了,恢复后才能看记忆。" })
427
+ ] }) : e.project.canReadThreads ? e.project.access === "member" ? /* @__PURE__ */ u(Me, { ctx: e, api: e.memory }) : /* @__PURE__ */ u(gn, { ctx: e, api: e.memory }) : /* @__PURE__ */ s(C, { children: [
428
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S }),
429
+ /* @__PURE__ */ u(P, { title: "看不到这个项目的记忆", children: "记忆是从意见和回合里攒出来的,能读意见的人才能看。" })
430
+ ] }) : /* @__PURE__ */ s(C, { children: [
431
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S }),
432
+ /* @__PURE__ */ u(P, { title: "这个部署没有开项目记忆", children: "要用的话,请联系 Band 管理员。" })
433
+ ] });
434
+ }
435
+ function gn({ ctx: e, api: n }) {
436
+ const t = T(
437
+ e,
438
+ async () => {
439
+ try {
440
+ return await n.current(), "ok";
441
+ } catch (a) {
442
+ if (Ge(a)) return "forbidden";
443
+ throw a;
444
+ }
445
+ },
446
+ [n]
447
+ );
448
+ return t.data === "forbidden" ? /* @__PURE__ */ s(C, { children: [
449
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S }),
450
+ /* @__PURE__ */ u(P, { title: "看不到这个项目的记忆", children: "记忆是团队在项目里攒下的约定,项目成员才能看。" })
451
+ ] }) : t.data === void 0 && !t.error ? /* @__PURE__ */ s(C, { children: [
452
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S }),
453
+ /* @__PURE__ */ u(W, { text: "正在读取项目记忆…" })
454
+ ] }) : /* @__PURE__ */ u(Me, { ctx: e, api: n });
455
+ }
456
+ function vn({ title: e, children: n }) {
457
+ return /* @__PURE__ */ s("div", { className: "band-memory-state rest", children: [
458
+ /* @__PURE__ */ u("i", {}),
459
+ /* @__PURE__ */ u("b", { children: e }),
460
+ n && /* @__PURE__ */ u("span", { children: n })
461
+ ] });
462
+ }
463
+ function I(e, n) {
464
+ return We(e, n.author.id);
465
+ }
466
+ var se = "band-memory:draft:";
467
+ function Cn(e) {
468
+ try {
469
+ const n = globalThis.sessionStorage?.getItem(se + e);
470
+ if (n) {
471
+ const t = JSON.parse(n);
472
+ return {
473
+ drafts: new Map(t.drafts),
474
+ base: t.base ? { version: t.base.version, files: new Map(t.base.files) } : null
475
+ };
476
+ }
477
+ } catch {
478
+ }
479
+ return { drafts: /* @__PURE__ */ new Map(), base: null };
480
+ }
481
+ function Dn(e, n) {
482
+ try {
483
+ if (n.drafts.size === 0 && !n.base) {
484
+ globalThis.sessionStorage?.removeItem(se + e);
485
+ return;
486
+ }
487
+ globalThis.sessionStorage?.setItem(
488
+ se + e,
489
+ JSON.stringify({
490
+ drafts: [...n.drafts],
491
+ base: n.base ? { version: n.base.version, files: [...n.base.files] } : null
492
+ })
493
+ );
494
+ } catch {
495
+ }
496
+ }
497
+ function An(e) {
498
+ const [n, t] = M(() => Cn(e));
499
+ return [n, (o) => t((d) => {
500
+ const b = o(d);
501
+ return Dn(e, b), b;
502
+ })];
503
+ }
504
+ function Me({ ctx: e, api: n }) {
505
+ const t = Pe(e), o = _e(e).params.item, d = He(o), b = o === ue, c = !b && o !== void 0 && d === null ? o : null, l = T(e, () => n.current(), [n], V), m = T(e, () => n.versions(), [n], V), [{ drafts: p, base: B }, A] = An(e.project.id), h = (r) => A((f) => ({ ...f, drafts: typeof r == "function" ? r(f.drafts) : r })), F = (r) => A((f) => ({ ...f, base: r })), [N, v] = M(null), [w, X] = M(!1), [i, $] = M(!1), x = !(e.project.access === "member") || w, D = l.data?.files ?? wn, K = dn(D, p), j = $e(D, p), le = cn(D, p), U = j.length > 0 ? on(le) : null, ce = B !== null && j.length > 0 && (l.data?.version ?? 0) > B.version, me = ce && B ? bn(B.files, D, j) : [], Y = D.map((r) => r.path).join(`
506
+ `), pe = T(
507
+ e,
508
+ async () => {
509
+ const r = (await n.versions()).slice(0, Bn), f = Y ? Y.split(`
510
+ `) : [], E = [], y = new Set(f);
511
+ for (let g = 0; g < r.length && y.size > 0; g += xe) {
512
+ const Be = r.slice(g, g + xe);
513
+ (await Promise.all(Be.map((ee) => n.version(ee.version)))).forEach((ee, Re) => {
514
+ const ye = Be[Re];
515
+ if (!ye) return;
516
+ const ge = ee.changes.map((ne) => ne.path);
517
+ for (const ne of ge) y.delete(ne);
518
+ E.push({ version: ye, changed: ge });
519
+ });
520
+ }
521
+ return fn(E, f);
522
+ },
523
+ [n, Y],
524
+ V,
525
+ // 按路径取:增删、保存文件时上一份对没变的文件仍然对,留着免得每个文件的「谁写的」闪空
526
+ { keepPrevious: !0 }
527
+ ), J = j.length > 0, Se = !!l.data, je = B !== null;
528
+ _(() => {
529
+ Se && !J && je && A((r) => ({ ...r, base: null }));
530
+ }), _(() => {
531
+ if (!J) return;
532
+ const r = (f) => {
533
+ f.preventDefault();
534
+ };
535
+ return window.addEventListener("beforeunload", r), () => window.removeEventListener("beforeunload", r);
536
+ }, [J]), _(() => {
537
+ if (N?.tone !== "ok") return;
538
+ const r = setTimeout(() => v(null), 4e3);
539
+ return () => clearTimeout(r);
540
+ }, [N]);
541
+ const Ie = () => {
542
+ B || !l.data || F({ version: l.data.version, files: new Map(D.map((r) => [r.path, r.content])) });
543
+ }, z = (r, f) => {
544
+ Ie(), v(null), h((E) => {
545
+ const y = new Map(E);
546
+ return f ? y.set(r, f) : y.delete(r), y;
547
+ });
548
+ }, Fe = () => e.app.navigate({ page: L, params: O(e) }), fe = (r) => e.app.navigate({ page: L, params: O(e, r) }), he = (r) => e.app.navigate({
549
+ page: L,
550
+ params: O(e, Ve(m.data?.[0]?.version ?? 1))
551
+ }), Te = (r) => {
552
+ z(r, { content: `# ${r.replace(/\.md$/, "")}
553
+
554
+ `, created: !0 }), fe(r);
555
+ }, Ee = (r, f) => (l.reload(), m.reload(), r.ok ? (v({ tone: "ok", text: f(r.version, r.unchanged) }), !0) : (r.code === "CONFLICT" ? v({
556
+ tone: "bad",
557
+ text: `没存上:这期间记忆已经到第 ${r.latestVersion} 版了。你的修改还在,看清上面的提示再存。`
558
+ }) : r.code === "INVALID" ? v({ tone: "bad", text: `没存上:${r.message}` }) : (X(!0), v({ tone: "bad", text: "项目已归档或你已不是成员,记忆现在只读。" })), !1)), Ke = async (r) => {
559
+ if (!l.data || i || x || j.length === 0 || U) return;
560
+ const f = p.get(r)?.removed === !0;
561
+ $(!0);
562
+ try {
563
+ const E = await n.save({
564
+ baseVersion: B?.version ?? l.data.version,
565
+ ...ln(D, p)
566
+ });
567
+ Ee(
568
+ E,
569
+ (y, g) => g ? "内容和现在一样,没有存新版本" : `已存为第 ${y} 版`
570
+ ) && (h(/* @__PURE__ */ new Map()), F(null), f && Fe());
571
+ } catch (E) {
572
+ v({ tone: "bad", text: `没存上:${E instanceof Error ? E.message : String(E)}` });
573
+ } finally {
574
+ $(!1);
575
+ }
576
+ }, ze = async (r, f) => {
577
+ if (!(i || x)) {
578
+ $(!0);
579
+ try {
580
+ const E = r === "revert" ? await n.revert(f) : await n.restore(f);
581
+ Ee(
582
+ E,
583
+ (y, g) => g ? "内容和现在一样,没有存新版本" : r === "revert" ? `已撤回第 ${f} 版的改动,存为第 ${y} 版` : `已恢复到第 ${f} 版,存为第 ${y} 版`
584
+ );
585
+ } catch (E) {
586
+ v({ tone: "bad", text: `没成功:${E instanceof Error ? E.message : String(E)}` });
587
+ } finally {
588
+ $(!1);
589
+ }
590
+ }
591
+ }, Q = /* @__PURE__ */ s(C, { children: [
592
+ x && !w && /* @__PURE__ */ u("output", { className: "band-memory-note", children: "这个项目现在只能查看,记忆改不了。" }),
593
+ ce && B && l.data && /* @__PURE__ */ s("div", { className: "band-memory-stale", role: "alert", children: [
594
+ /* @__PURE__ */ s("b", { children: [
595
+ "你改的时候,记忆存到了第 ",
596
+ l.data.version,
597
+ " 版",
598
+ l.data.latest ? `(${I(t, l.data.latest)})` : "",
599
+ "。"
600
+ ] }),
601
+ /* @__PURE__ */ u("span", { children: me.length > 0 ? `${me.join("、")} 对方也改了,在最新版上继续会用你的内容覆盖它。` : "你改的文件对方没动,可以在最新版上继续。" }),
602
+ /* @__PURE__ */ s("span", { className: "band-memory-stale-acts", children: [
603
+ /* @__PURE__ */ u(
604
+ "button",
605
+ {
606
+ type: "button",
607
+ className: "btn sm",
608
+ onClick: () => {
609
+ h(/* @__PURE__ */ new Map()), F(null), v(null);
610
+ },
611
+ children: "丢掉我的修改"
612
+ }
613
+ ),
614
+ /* @__PURE__ */ u(
615
+ "button",
616
+ {
617
+ type: "button",
618
+ className: "btn primary sm",
619
+ onClick: () => {
620
+ F({
621
+ version: l.data?.version ?? 0,
622
+ files: new Map(D.map((r) => [r.path, r.content]))
623
+ }), v(null);
624
+ },
625
+ children: "在最新版上继续"
626
+ }
627
+ )
628
+ ] })
629
+ ] }),
630
+ N && /* @__PURE__ */ u("output", { className: `band-memory-notice ${N.tone}`, "aria-live": "polite", children: N.text })
631
+ ] });
632
+ if (!l.data)
633
+ return /* @__PURE__ */ s(C, { children: [
634
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S }),
635
+ l.error ? /* @__PURE__ */ s(te, { retry: l.reload, children: [
636
+ "记忆没取到:",
637
+ l.error
638
+ ] }) : /* @__PURE__ */ u(W, { text: "正在读取项目记忆…" })
639
+ ] });
640
+ if (d !== null)
641
+ return /* @__PURE__ */ s(C, { children: [
642
+ /* @__PURE__ */ u(k, { title: "记忆的历史", desc: "每存一次是一版;撤回和恢复都会存成新的一版。" }),
643
+ Q,
644
+ /* @__PURE__ */ u(
645
+ Nn,
646
+ {
647
+ api: n,
648
+ ctx: e,
649
+ members: t,
650
+ versions: m.data,
651
+ error: m.error,
652
+ reload: m.reload,
653
+ initial: d,
654
+ canWrite: !x,
655
+ busy: i,
656
+ onAct: ze
657
+ }
658
+ )
659
+ ] });
660
+ if (b)
661
+ return /* @__PURE__ */ s(C, { children: [
662
+ /* @__PURE__ */ u(k, { title: "新建文件", desc: "只填名字;建好后在这个文件里写内容。" }),
663
+ x ? /* @__PURE__ */ u("p", { className: "band-sf-muted", children: w ? "项目已归档或你已不是成员,记忆只读。" : "只有项目成员能新建记忆文件。" }) : /* @__PURE__ */ u(xn, { taken: K, onCreate: Te, onCancel: Fe })
664
+ ] });
665
+ if (c !== null) {
666
+ const r = p.get(c), f = D.find((g) => g.path === c);
667
+ if (!r && !f)
668
+ return /* @__PURE__ */ s(C, { children: [
669
+ /* @__PURE__ */ u(k, { title: c, desc: `位置 ${H} · 项目里的 Agent 共用` }),
670
+ /* @__PURE__ */ u("p", { className: "band-sf-muted", children: "这个文件不在了;可能已经被删掉。回到列表看现在的文件。" })
671
+ ] });
672
+ const E = r && !r.removed ? r.content : f?.content ?? "", y = pe.data?.get(c);
673
+ return /* @__PURE__ */ s(C, { children: [
674
+ /* @__PURE__ */ u(k, { title: c, desc: `位置 ${H} · 项目里的 Agent 共用` }),
675
+ Q,
676
+ /* @__PURE__ */ u(
677
+ kn,
678
+ {
679
+ path: c,
680
+ value: E,
681
+ removed: r?.removed === !0,
682
+ created: r?.created === !0,
683
+ dirty: ae(c, D, p),
684
+ meta: y ? `最近由 ${I(t, y)} 写入 · ${q(y.createdAt)}` : r?.created ? "新文件,还没保存" : "",
685
+ readOnly: x,
686
+ busy: i,
687
+ problem: U,
688
+ dirtyCount: j.length,
689
+ onChange: (g) => z(
690
+ c,
691
+ f?.content === g && !r?.created ? null : { ...r, content: g }
692
+ ),
693
+ onDiscard: () => z(c, null),
694
+ onRemove: () => z(c, { content: E, removed: !0 }),
695
+ onSave: () => void Ke(c)
696
+ },
697
+ c
698
+ ),
699
+ /* @__PURE__ */ u(ke, { children: /* @__PURE__ */ s(
700
+ "button",
701
+ {
702
+ type: "button",
703
+ className: "btn",
704
+ onClick: () => he(),
705
+ disabled: (m.data?.length ?? 0) === 0,
706
+ children: [
707
+ "看历史与差异",
708
+ m.data?.length ? ` · ${m.data.length} 版` : ""
709
+ ]
710
+ }
711
+ ) })
712
+ ] });
713
+ }
714
+ const be = x ? void 0 : /* @__PURE__ */ u(
715
+ "a",
716
+ {
717
+ className: "btn primary",
718
+ href: we(e, ue),
719
+ onClick: (r) => {
720
+ r.metaKey || r.ctrlKey || r.shiftKey || r.altKey || (r.preventDefault(), e.app.navigate({ page: L, params: O(e, ue) }));
721
+ },
722
+ children: "新建文件"
723
+ }
724
+ ), Z = m.data?.length ?? 0;
725
+ return /* @__PURE__ */ s(C, { children: [
726
+ /* @__PURE__ */ u(k, { title: "记忆", desc: S, action: K.length === 0 ? void 0 : be }),
727
+ Q,
728
+ K.length === 0 ? /* @__PURE__ */ u(Ue, { action: be, children: "还没有记忆。项目跑起来以后,Agent 会把大家的沟通习惯、约定和术语自己记下来,下次工作时先读。你不用做什么。" }) : /* @__PURE__ */ s(C, { children: [
729
+ /* @__PURE__ */ u(Ye, { label: "记忆文件", children: K.map((r) => {
730
+ const f = p.get(r), E = pe.data?.get(r), y = ae(r, D, p), g = f?.removed ? "保存后删除" : f?.created ? "新建 · 没保存" : y ? "改了 · 没保存" : E ? `${I(t, E)} · ${q(E.createdAt)}` : "";
731
+ return /* @__PURE__ */ u(
732
+ Je,
733
+ {
734
+ title: r,
735
+ mono: !0,
736
+ href: we(e, r),
737
+ meta: g ? [g] : void 0,
738
+ onOpen: () => fe(r)
739
+ },
740
+ r
741
+ );
742
+ }) }),
743
+ /* @__PURE__ */ s("div", { className: "band-memory-hint", children: [
744
+ /* @__PURE__ */ s("span", { children: [
745
+ "位置 ",
746
+ /* @__PURE__ */ u("code", { children: H }),
747
+ " · 项目里的 Agent 共用"
748
+ ] }),
749
+ /* @__PURE__ */ u("span", { className: U ? "band-memory-over" : void 0, children: pn(le) }),
750
+ /* @__PURE__ */ s(
751
+ "button",
752
+ {
753
+ type: "button",
754
+ className: "band-memory-link",
755
+ onClick: () => he(),
756
+ disabled: Z === 0,
757
+ children: [
758
+ "历史",
759
+ Z ? ` · ${Z} 版` : ""
760
+ ]
761
+ }
762
+ )
763
+ ] }),
764
+ /* @__PURE__ */ u("p", { className: "band-sf-muted", children: "只属于这个项目,换项目不带过去;别写密码和个人隐私。" })
765
+ ] })
766
+ ] });
767
+ }
768
+ var wn = [];
769
+ function xn({
770
+ taken: e,
771
+ onCreate: n,
772
+ onCancel: t
773
+ }) {
774
+ const [a, o] = M(""), [d, b] = M(null), c = Ne(null);
775
+ return _(() => {
776
+ c.current?.focus();
777
+ }, []), /* @__PURE__ */ s(Qe, { onSubmit: () => {
778
+ const m = Fn(a, e);
779
+ if (!m.ok) {
780
+ b(m.message);
781
+ return;
782
+ }
783
+ n(m.path);
784
+ }, children: [
785
+ /* @__PURE__ */ u(Ze, { label: "新文件名", required: !0, error: d, children: (m) => /* @__PURE__ */ s("span", { className: "field-group field-host", children: [
786
+ /* @__PURE__ */ u(
787
+ "input",
788
+ {
789
+ ...m,
790
+ ref: c,
791
+ className: "field bare band-memory-newinput",
792
+ value: a,
793
+ placeholder: "例如 conventions",
794
+ onChange: (p) => {
795
+ o(p.target.value), b(null);
796
+ },
797
+ onKeyDown: ie((p) => {
798
+ p.key === "Escape" && (p.preventDefault(), t());
799
+ })
800
+ }
801
+ ),
802
+ /* @__PURE__ */ u("span", { className: "field-affix", "aria-hidden": "true", children: ".md" })
803
+ ] }) }),
804
+ /* @__PURE__ */ s(ke, { end: !0, children: [
805
+ /* @__PURE__ */ u("button", { type: "button", className: "btn ghost", onClick: t, children: "取消" }),
806
+ /* @__PURE__ */ u("button", { type: "submit", className: "btn primary", children: "新建" })
807
+ ] })
808
+ ] });
809
+ }
810
+ function kn({
811
+ path: e,
812
+ value: n,
813
+ removed: t,
814
+ created: a,
815
+ dirty: o,
816
+ meta: d,
817
+ readOnly: b,
818
+ busy: c,
819
+ problem: l,
820
+ dirtyCount: m,
821
+ onChange: p,
822
+ onDiscard: B,
823
+ onRemove: A,
824
+ onSave: h
825
+ }) {
826
+ const F = an(), N = ie((w) => {
827
+ (w.metaKey || w.ctrlKey) && w.key.toLowerCase() === "s" && (w.preventDefault(), h());
828
+ }), v = m > 1 ? `保存 ${m} 个文件` : "保存";
829
+ return /* @__PURE__ */ s("section", { className: "band-memory-edit", "aria-labelledby": F, children: [
830
+ /* @__PURE__ */ s("div", { className: "band-memory-edithead", children: [
831
+ /* @__PURE__ */ s("code", { id: F, children: [
832
+ H,
833
+ e
834
+ ] }),
835
+ d && /* @__PURE__ */ u("span", { children: d })
836
+ ] }),
837
+ t ? /* @__PURE__ */ s("div", { className: "band-memory-removed", children: [
838
+ /* @__PURE__ */ u("b", { children: "保存后会删掉这个文件" }),
839
+ /* @__PURE__ */ u("span", { children: "删之前的内容留在历史里,需要时可以恢复。" }),
840
+ /* @__PURE__ */ u("button", { type: "button", className: "btn sm", onClick: B, children: "不删了" })
841
+ ] }) : b ? (
842
+ /* 只读时按 Markdown 显示(M3-47):与编辑时的预览同参(breaks + document),写的和看的是同一副样子 */
843
+ /* @__PURE__ */ u("div", { className: "band-memory-view", children: /* @__PURE__ */ u(tn, { text: n, breaks: !0, density: "document" }) })
844
+ ) : (
845
+ /* ⌘S 保存挂在包裹层:键盘事件从 MarkdownInput 的文本框冒泡上来(它自己的 onKeyDown 只管 ⌘⇧P 切预览) */
846
+ /* @__PURE__ */ u("div", { onKeyDown: N, children: /* @__PURE__ */ u(
847
+ rn,
848
+ {
849
+ value: n,
850
+ onChange: p,
851
+ label: `${e} 的内容`,
852
+ minRows: 10,
853
+ breaks: !0,
854
+ density: "document"
855
+ }
856
+ ) })
857
+ ),
858
+ l && /* @__PURE__ */ s("span", { className: "band-memory-err", role: "alert", children: [
859
+ "存不下:",
860
+ l
861
+ ] }),
862
+ !b && /* @__PURE__ */ s("div", { className: "band-memory-editfoot", children: [
863
+ !a && !t && /* @__PURE__ */ u("button", { type: "button", className: "btn ghost sm danger", onClick: A, children: "删除文件" }),
864
+ /* @__PURE__ */ u("span", { className: "band-memory-spacer" }),
865
+ /* @__PURE__ */ u(
866
+ "button",
867
+ {
868
+ type: "button",
869
+ className: "btn ghost sm",
870
+ onClick: B,
871
+ disabled: !o && !a,
872
+ children: a ? "不要这个文件" : "撤销修改"
873
+ }
874
+ ),
875
+ /* @__PURE__ */ u(
876
+ "button",
877
+ {
878
+ type: "button",
879
+ className: "btn primary sm",
880
+ onClick: h,
881
+ disabled: c || m === 0 || l !== null,
882
+ title: "⌘S / Ctrl+S",
883
+ children: c ? "保存中…" : v
884
+ }
885
+ )
886
+ ] })
887
+ ] });
888
+ }
889
+ function Nn({
890
+ api: e,
891
+ ctx: n,
892
+ members: t,
893
+ versions: a,
894
+ error: o,
895
+ reload: d,
896
+ initial: b,
897
+ canWrite: c,
898
+ busy: l,
899
+ onAct: m
900
+ }) {
901
+ const [p, B] = M(b), A = a?.[0]?.version, h = p !== null && a?.some((i) => i.version === p) ? p : A, F = T(
902
+ n,
903
+ async () => h === void 0 ? null : e.version(h),
904
+ [e, h],
905
+ V
906
+ ), N = ve(() => en(t), [t]), v = ve(
907
+ () => t.filter((i) => i.actor.kind === "agent").map((i) => i.actor.id),
908
+ [t]
909
+ ), w = Ne(null), X = ie((i) => {
910
+ if (!a?.length || h === void 0) return;
911
+ const $ = a.findIndex((D) => D.version === h), G = i.key === "ArrowDown" ? Math.min(a.length - 1, $ + 1) : i.key === "ArrowUp" ? Math.max(0, $ - 1) : i.key === "Home" ? 0 : i.key === "End" ? a.length - 1 : -1;
912
+ if (G < 0) return;
913
+ i.preventDefault();
914
+ const x = a[G]?.version;
915
+ x !== void 0 && (B(x), requestAnimationFrame(
916
+ () => w.current?.querySelector(`[data-version="${x}"]`)?.focus()
917
+ ));
918
+ });
919
+ return /* @__PURE__ */ u("div", { className: "band-memory-history", children: a ? a.length === 0 ? /* @__PURE__ */ u(vn, { title: "还没有历史", children: "第一次有人或 Agent 写入记忆以后,每存一次是一版。" }) : /* @__PURE__ */ s("div", { className: "band-memory-grid", children: [
920
+ /* @__PURE__ */ u(
921
+ "ul",
922
+ {
923
+ ref: w,
924
+ className: "band-memory-versions",
925
+ "aria-label": "版本",
926
+ onKeyDown: X,
927
+ children: a.map((i) => /* @__PURE__ */ u("li", { children: /* @__PURE__ */ s(
928
+ "button",
929
+ {
930
+ type: "button",
931
+ className: "band-memory-version",
932
+ "data-version": i.version,
933
+ "aria-current": i.version === h,
934
+ tabIndex: i.version === h ? 0 : -1,
935
+ onClick: () => B(i.version),
936
+ children: [
937
+ /* @__PURE__ */ u(
938
+ nn,
939
+ {
940
+ id: i.author.id,
941
+ name: I(t, i),
942
+ agent: i.author.kind === "agent",
943
+ ...i.author.kind === "agent" ? { instrument: un(i.author.id, v) } : {},
944
+ order: N,
945
+ size: "xs",
946
+ decorative: !0
947
+ }
948
+ ),
949
+ /* @__PURE__ */ s("span", { className: "band-memory-fname", children: [
950
+ /* @__PURE__ */ s("span", { children: [
951
+ "第 ",
952
+ i.version,
953
+ " 版",
954
+ i.version === A ? " · 当前" : ""
955
+ ] }),
956
+ /* @__PURE__ */ s("span", { children: [
957
+ I(t, i),
958
+ " ",
959
+ Ce(i),
960
+ " · ",
961
+ q(i.createdAt)
962
+ ] })
963
+ ] })
964
+ ]
965
+ }
966
+ ) }, i.version))
967
+ }
968
+ ),
969
+ F.error && (!F.data || F.data.version.version !== h) ? /* @__PURE__ */ u("div", { className: "band-memory-edit", children: /* @__PURE__ */ s(te, { retry: F.reload, children: [
970
+ "这一版没取到:",
971
+ F.error
972
+ ] }) }) : /* @__PURE__ */ u("section", { className: "band-memory-edit", "aria-live": "polite", children: !F.data || F.data.version.version !== h ? /* @__PURE__ */ u(W, { text: "正在读取这一版…" }) : /* @__PURE__ */ s(C, { children: [
973
+ /* @__PURE__ */ s("div", { className: "band-memory-edithead", children: [
974
+ /* @__PURE__ */ s("b", { children: [
975
+ "第 ",
976
+ F.data.version.version,
977
+ " 版 ·",
978
+ " ",
979
+ I(t, F.data.version),
980
+ " ",
981
+ Ce(F.data.version)
982
+ ] }),
983
+ /* @__PURE__ */ u("span", { children: q(F.data.version.createdAt) })
984
+ ] }),
985
+ F.data.version.rejectedFiles && /* @__PURE__ */ s("output", { className: "band-memory-note", children: [
986
+ "这次回合还改了 ",
987
+ F.data.version.rejectedFiles.join("、"),
988
+ ",和别的改动撞了,没采用;它交回的内容只留在这一版的记录里。"
989
+ ] }),
990
+ F.data.changes.length === 0 ? /* @__PURE__ */ u("span", { className: "band-memory-faint", children: "这一版文件内容没有变化。" }) : F.data.changes.map((i) => /* @__PURE__ */ s("div", { className: "band-memory-change", children: [
991
+ /* @__PURE__ */ s("div", { className: "band-memory-changehead", children: [
992
+ /* @__PURE__ */ u("code", { children: i.path }),
993
+ /* @__PURE__ */ u("span", { children: $n[i.change] })
994
+ ] }),
995
+ /* @__PURE__ */ u(Mn, { blocks: En(hn(i.before, i.after)) })
996
+ ] }, i.path)),
997
+ c && /* @__PURE__ */ s("div", { className: "band-memory-editfoot", children: [
998
+ /* @__PURE__ */ u("span", { className: "band-memory-faint", children: "撤回和恢复都会存成新的一版,原来的版本还在。" }),
999
+ /* @__PURE__ */ u("span", { className: "band-memory-spacer" }),
1000
+ /* @__PURE__ */ u(
1001
+ "button",
1002
+ {
1003
+ type: "button",
1004
+ className: "btn ghost sm",
1005
+ disabled: l,
1006
+ onClick: () => F.data && m("revert", F.data.version.version),
1007
+ children: "撤回这一版的改动"
1008
+ }
1009
+ ),
1010
+ F.data.version.version !== A && /* @__PURE__ */ u(
1011
+ "button",
1012
+ {
1013
+ type: "button",
1014
+ className: "btn sm",
1015
+ disabled: l,
1016
+ onClick: () => F.data && m("restore", F.data.version.version),
1017
+ children: "恢复到这一版"
1018
+ }
1019
+ )
1020
+ ] })
1021
+ ] }) })
1022
+ ] }) : o ? /* @__PURE__ */ s(te, { retry: d, children: [
1023
+ "历史没取到:",
1024
+ o
1025
+ ] }) : /* @__PURE__ */ u(W, { text: "正在读取历史…" }) });
1026
+ }
1027
+ var $n = { added: "新建", modified: "修改", removed: "删除" };
1028
+ function Mn({ blocks: e }) {
1029
+ return /* @__PURE__ */ u("div", { className: "band-memory-diff", children: e.map(
1030
+ (n, t) => n.kind === "fold" ? (
1031
+ // biome-ignore lint/suspicious/noArrayIndexKey: 折叠块没有身份,位置就是身份
1032
+ /* @__PURE__ */ s("div", { className: "band-memory-fold", children: [
1033
+ "… ",
1034
+ n.count,
1035
+ " 行没变"
1036
+ ] }, t)
1037
+ ) : n.lines.map((a, o) => /* @__PURE__ */ s(
1038
+ "div",
1039
+ {
1040
+ className: `band-memory-line ${a.kind}`,
1041
+ children: [
1042
+ /* @__PURE__ */ u("span", { "aria-hidden": "true", children: a.kind === "add" ? "+" : a.kind === "del" ? "−" : " " }),
1043
+ /* @__PURE__ */ u("span", { className: "sr-only", children: a.kind === "add" ? "加了:" : a.kind === "del" ? "删了:" : "" }),
1044
+ /* @__PURE__ */ u("span", { children: a.text || " " })
1045
+ ]
1046
+ },
1047
+ `${t}-${o}`
1048
+ ))
1049
+ ) });
1050
+ }
1051
+ export {
1052
+ yn as MemoryTab,
1053
+ On as default
1054
+ };
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@kanyun-ai-infra/band-memory",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "项目记忆页:Agent 记下的约定、习惯和术语,人可以改;历史里看每一版、撤回或恢复",
5
+ "keywords": [
6
+ "记忆",
7
+ "项目设置",
8
+ "约定"
9
+ ],
10
+ "license": "UNLICENSED",
11
+ "type": "module",
12
+ "files": [
13
+ "dist",
14
+ "plugin.yaml"
15
+ ],
16
+ "peerDependencies": {
17
+ "@kanyun-ai-infra/band-plugin-sdk": "^3.47.0",
18
+ "react": "^19.0.0",
19
+ "react-dom": "^19.0.0",
20
+ "@kanyun-ai-infra/band-settings": "*"
21
+ },
22
+ "peerDependenciesMeta": {
23
+ "@kanyun-ai-infra/band-settings": {
24
+ "optional": true
25
+ }
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/kanyun-ai-explore/band.git",
30
+ "directory": "plugins/memory"
31
+ },
32
+ "exports": {
33
+ ".": "./dist/index.js"
34
+ }
35
+ }
package/plugin.yaml ADDED
@@ -0,0 +1,10 @@
1
+ # 官方插件:项目记忆页(agent-memory §8)。往项目设置页(band-settings)的 tabs 贡献「记忆」分页:
2
+ # 文件列表 + 编辑、历史与差异、撤回与恢复。数据全走 ctx.memory。
3
+ entry: dist/index.js
4
+ contributes:
5
+ - slot: "@kanyun-ai-infra/band-settings/tabs"
6
+ id: tab
7
+ tab: memory
8
+ title: 记忆
9
+ group: Agent
10
+ order: 30