dsh-better-memo 0.2.0 → 0.2.1
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/CHANGELOG.md +16 -0
- package/README.md +8 -8
- package/client.js +173 -101
- package/index.js +9 -4
- package/lib/store.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 — 2026-11-20
|
|
4
|
+
|
|
5
|
+
视觉与手感修(用户:黑的看不清、UI 有点丑、点设置页外面也该收起)。
|
|
6
|
+
|
|
7
|
+
- **浮窗卡片与设置页固定浅色**:不再跟宿主深色主题走,卡片/设置页底色 `#fff`、正文 `#1f2328`、次要文字 `#57606a`,边框与阴影全部按浅色重配;输入框、下拉、开关行同步改浅色底(`#f2f5f9`),不再出现「白底白字」或「黑底黑字」。
|
|
8
|
+
- **顶栏胶囊同样改白底**(原来深灰底 + 继承宿主文字色,深色主题下几乎看不清)。
|
|
9
|
+
- **卡片重排**:行改成扁平列表 + 悬停高亮,去掉每行的方框;归属用彩色圆点 + 同色系小药丸标签(会话蓝 / 共享绿 / 私人橙);标题与摘要两行;底部一行灰字提示「点一行即可复制;齿轮里管理全部」;计数改成浅色药丸。
|
|
10
|
+
- **点设置页外的区域也会收起设置页**(原来只有 ESC 和关闭按钮),用 `mousedown` 判定,从设置页内部拖到外面不会误触。
|
|
11
|
+
- **胶囊只在真会话里出现**:欢迎页 / 新建但还没说话的会话不显示这个按钮(读 `sessions.list` 的 `retainedBy.mainView` 且跳过 `blank` 会话,订阅列表变化后即时显隐)。
|
|
12
|
+
- 胶囊与同行图标按钮对齐:高 28、圆角 8、`top:11px`(原来 28 高但 `top:6px`、圆角 14,比同行高出一截)。
|
|
13
|
+
- 三档文案改为「本会话 / 全局共享 / 仅用户」(分组标题、下拉选项、提示语同步)。
|
|
14
|
+
- `memo_edit` 的 `add` 显式拒绝 `scope=user`:schema 早已把 user 排除,但直接调用会绕过枚举写出 user 条目,现在返回错误。
|
|
15
|
+
- `memo_edit` 的 `add` 不给 `scope` 时不再报错,**默认写到本会话**(`session`);要跨会话共享才显式写 `profile`。
|
|
16
|
+
- 每条备忘录都记下来源会话 `sessionId`(写 `profile` 时也记),`memo_list` 与面板接口返回里都带这个字段。
|
|
17
|
+
- 版本号 0.2.1(client 与 package 同步)。
|
|
18
|
+
|
|
3
19
|
## 0.2.0 — 2026-11-20
|
|
4
20
|
|
|
5
21
|
改成浮窗卡片(用户口径:不要整页)。
|
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
| 作用域 | 谁收得到 | AI 能看 | AI 能写 |
|
|
6
6
|
|---|---|---|---|
|
|
7
|
-
| **本会话** `session` |
|
|
8
|
-
|
|
|
9
|
-
|
|
|
7
|
+
| **本会话** `session` | 只有这一个会话(**写备忘录时的默认档**) | ✅ | ✅ |
|
|
8
|
+
| **全局共享** `profile` | 这个 profile 的所有会话 | ✅ | ✅ |
|
|
9
|
+
| **仅用户** `user` | 只有你自己 | ❌ 永远不返回 | ❌ 只有你能写 |
|
|
10
10
|
|
|
11
11
|
## 安装
|
|
12
12
|
|
|
@@ -19,13 +19,13 @@ dsh plugin --profile <你的 profile> add dsh-better-memo
|
|
|
19
19
|
## 用
|
|
20
20
|
|
|
21
21
|
1. **顶栏胶囊**(窗口右上角,`备忘录`):点一下弹出浮窗卡片。
|
|
22
|
-
2. **浮窗卡片**:一条一条,左边彩色圆点区分三档(蓝=本会话 /
|
|
22
|
+
2. **浮窗卡片**:一条一条,左边彩色圆点区分三档(蓝=本会话 / 绿=全局共享 / 黄=仅用户)。**点一条 = 复制到剪贴板**(格式 `标题\n正文`),右下角浮出「已复制」。点卡片外面、按 ESC、或再点胶囊都能关。
|
|
23
23
|
3. **齿轮 → 设置页**:卡片右上角的齿轮点进去是整页模式,可以做全部管理(新增、勾完成、行内改、两次确认删),顶部有开关 **「在会话 tab 行显示「备忘录」入口」**,**默认关**。打开后会话 tab 行才出现「备忘录」座位,关掉立刻消失,不用重启。
|
|
24
24
|
|
|
25
25
|
## 给 AI 的两个工具
|
|
26
26
|
|
|
27
|
-
- **`memo_list`** —— 返回本会话该查收的条目:本会话的 `session` + 本 profile 的 `profile
|
|
28
|
-
- **`memo_edit`** —— `op=add|update|delete`。`add`
|
|
27
|
+
- **`memo_list`** —— 返回本会话该查收的条目:本会话的 `session` + 本 profile 的 `profile`,已勾完成的会过滤掉。**`仅用户` 的条目永远不会出现在这里。**
|
|
28
|
+
- **`memo_edit`** —— `op=add|update|delete`。`add` 不必给 `scope`:**默认就是 `session`,归写它的那个会话**;要跨会话共享才显式写 `profile`。`update`/`delete` 要 `id`。只能改自己看得到的条目,跨会话或 `user` 条目会被拒。不论哪一档,条目都会记下来源会话 `sessionId`(写 `profile` 时也一样),方便区分是谁记的。
|
|
29
29
|
|
|
30
30
|
会话开始时若用户提到「备忘录 / 备忘 / 记一下 / 待办」,会先调 `memo_list`(插件自带这段系统提示,一般不用再写)。
|
|
31
31
|
|
|
@@ -38,8 +38,8 @@ dsh plugin --profile <你的 profile> add dsh-better-memo
|
|
|
38
38
|
## 已知限制
|
|
39
39
|
|
|
40
40
|
- **复制依赖窗口焦点**:用的是 `navigator.clipboard.writeText`,失败时退回 `document.execCommand('copy')`;两个都失败会明确显示「复制失败」,不会假装成功。窗口失焦的后台环境两个都会失败(这是浏览器的规矩,不是插件 bug)。
|
|
41
|
-
-
|
|
42
|
-
-
|
|
41
|
+
- 顶栏胶囊与同一行图标按钮同高同圆角(高 28、圆角 8、`top:11px; right:150px`)。**只在真正打开了一个会话时才显示**:欢迎页 / 新会话尚未进入对话时没有这个按钮。如果没有 `shell.overlay` 槽(个别环境),入口会退化成右下角的固定圆钮。
|
|
42
|
+
- 单机单文件,没有多端同步;全局共享档只在本 profile 内共享。
|
|
43
43
|
- 没有提醒/定时:这不是提醒插件,是备忘录。
|
|
44
44
|
|
|
45
45
|
## License
|
package/client.js
CHANGED
|
@@ -33,7 +33,7 @@ window.__ModuleLoader__.load({
|
|
|
33
33
|
const ReactDOMClient = require('react-dom/client');
|
|
34
34
|
|
|
35
35
|
const NS = 'better-memo';
|
|
36
|
-
const VERSION = '0.2.
|
|
36
|
+
const VERSION = '0.2.1';
|
|
37
37
|
const SLOT = 'conversation.view';
|
|
38
38
|
const SEAT_ID = 'better-memo-seat';
|
|
39
39
|
const TOPBAR_SLOT = 'shell.overlay';
|
|
@@ -52,11 +52,11 @@ window.__ModuleLoader__.load({
|
|
|
52
52
|
const RETRY_MS = 250;
|
|
53
53
|
|
|
54
54
|
const FALLBACK_LIMITS = { title: 120, body: 4000, entries: 500 };
|
|
55
|
-
const GROUP_LABEL = { session: '
|
|
55
|
+
const GROUP_LABEL = { session: '本会话:', profile: '全局共享:', user: '仅用户:' };
|
|
56
56
|
const SCOPE_TAG = { session: '会话', profile: '共享', user: '私人' };
|
|
57
57
|
const HINT_TEXT =
|
|
58
|
-
'
|
|
59
|
-
'
|
|
58
|
+
'本会话只在本会话里出现;全局共享会出现在同一 profile 的所有会话;' +
|
|
59
|
+
'仅用户只有你自己在这个面板里看得到,AI 读不到,也改不了。';
|
|
60
60
|
|
|
61
61
|
/** One style element per page, injected once; guarded by this flag inside the factory. */
|
|
62
62
|
let styleInjected = false;
|
|
@@ -65,91 +65,103 @@ window.__ModuleLoader__.load({
|
|
|
65
65
|
let an accidental backtick truncate the file and break the whole bundle. */
|
|
66
66
|
const CSS = [
|
|
67
67
|
/* ---- management UI (unchanged from 0.1.0) ---- */
|
|
68
|
-
'.bm-panel{display:flex;flex-direction:column;gap:
|
|
68
|
+
'.bm-panel{display:flex;flex-direction:column;gap:16px;padding:16px 18px 20px;font-size:13px;color:inherit;box-sizing:border-box;animation:bm-enter-frames 200ms cubic-bezier(.22,1,.36,1) both}',
|
|
69
69
|
'.bm-panel *{box-sizing:border-box}',
|
|
70
70
|
'.bm-head{display:flex;align-items:center;gap:6px}',
|
|
71
71
|
'.bm-title{font-size:15px;font-weight:600;margin:0}',
|
|
72
72
|
'.bm-version{font-size:11px;color:var(--dsw-alias-label-secondary,#8a8f98);margin-left:2px}',
|
|
73
73
|
'.bm-head-spacer{flex:1 1 auto}',
|
|
74
|
-
'.bm-btn{font:inherit;font-size:12px;line-height:1;border-radius:
|
|
75
|
-
'.bm-btn:hover{border-color:var(--dsw-alias-border-
|
|
74
|
+
'.bm-btn{font:inherit;font-size:12px;line-height:1;border-radius:8px;border:1px solid var(--dsw-alias-border-l3,rgba(15,23,42,.16));background:var(--bm-surface,#fff);color:inherit;padding:7px 12px;cursor:pointer;transition:background 120ms ease,border-color 120ms ease}',
|
|
75
|
+
'.bm-btn:hover{background:var(--bm-hover,#eff3f8);border-color:var(--dsw-alias-border-l4,rgba(15,23,42,.22))}',
|
|
76
76
|
'.bm-btn:disabled{opacity:.45;cursor:not-allowed}',
|
|
77
77
|
'.bm-btn-primary{background:var(--dsw-alias-accent,#3b82f6);border-color:transparent;color:#fff}',
|
|
78
|
-
'.bm-btn-
|
|
79
|
-
'.bm-btn-
|
|
78
|
+
'.bm-btn-primary:hover{background:#2560d8;border-color:transparent}',
|
|
79
|
+
'.bm-btn-ghost{border-color:transparent;background:transparent;color:var(--dsw-alias-label-secondary,#8a8f98);padding:6px 8px}',
|
|
80
|
+
'.bm-btn-ghost:hover{background:var(--bm-hover,#eff3f8);color:var(--dsw-alias-label-primary,#1f2328)}',
|
|
81
|
+
'.bm-btn-danger{color:var(--dsw-alias-danger,#e5484d);border-color:rgba(209,36,47,.35);background:#fff}',
|
|
80
82
|
'.bm-hint{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#8a8f98)}',
|
|
81
|
-
'.bm-form{display:flex;flex-direction:column;gap:
|
|
83
|
+
'.bm-form{display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;background:var(--bm-surface-2,#f6f8fa);border:1px solid var(--bm-line,rgba(15,23,42,.09))}',
|
|
82
84
|
'.bm-form-top{display:flex;gap:8px;align-items:center}',
|
|
83
85
|
'.bm-field{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--dsw-alias-label-secondary,#8a8f98)}',
|
|
84
|
-
'.bm-input{font:inherit;font-size:13px;width:100%;border-radius:8px;border:1px solid var(--dsw-alias-border-
|
|
85
|
-
'.bm-input:focus{outline:none;border-color:var(--dsw-alias-accent,#3b82f6)}',
|
|
86
|
-
'.bm-select{font:inherit;font-size:13px;border-radius:8px;border:1px solid var(--dsw-alias-border-
|
|
87
|
-
'.bm-textarea{resize:vertical;min-height:
|
|
86
|
+
'.bm-input{font:inherit;font-size:13px;width:100%;border-radius:8px;border:1px solid var(--dsw-alias-border-l3,rgba(15,23,42,.16));background:#fff;color:inherit;padding:8px 10px;transition:border-color 120ms ease,box-shadow 120ms ease}',
|
|
87
|
+
'.bm-input:focus{outline:none;border-color:var(--dsw-alias-accent,#3b82f6);box-shadow:0 0 0 3px rgba(47,111,237,.14)}',
|
|
88
|
+
'.bm-select{font:inherit;font-size:13px;border-radius:8px;border:1px solid var(--dsw-alias-border-l3,rgba(15,23,42,.16));background:#fff;color:inherit;padding:6px 8px}',
|
|
89
|
+
'.bm-textarea{resize:vertical;min-height:62px;line-height:19px}',
|
|
88
90
|
'.bm-form-actions{display:flex;justify-content:flex-end;gap:8px}',
|
|
89
91
|
'.bm-note{margin:0;font-size:11px;color:var(--dsw-alias-label-tertiary,#9aa0a6)}',
|
|
90
|
-
'.bm-groups{display:flex;flex-direction:column;gap:
|
|
91
|
-
'.bm-group{display:flex;flex-direction:column;gap:
|
|
92
|
-
'.bm-group-head{font-size:
|
|
93
|
-
'.bm-empty{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary,#9aa0a6);padding:
|
|
94
|
-
'.bm-list{display:flex;flex-direction:column;gap:
|
|
95
|
-
'.bm-row{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border-radius:
|
|
92
|
+
'.bm-groups{display:flex;flex-direction:column;gap:18px}',
|
|
93
|
+
'.bm-group{display:flex;flex-direction:column;gap:4px}',
|
|
94
|
+
'.bm-group-head{font-size:11.5px;font-weight:600;letter-spacing:.02em;color:var(--dsw-alias-label-secondary,#8a8f98);margin:0 0 2px;text-transform:none}',
|
|
95
|
+
'.bm-empty{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary,#9aa0a6);padding:6px 2px}',
|
|
96
|
+
'.bm-list{display:flex;flex-direction:column;gap:2px;margin:0;padding:0;list-style:none}',
|
|
97
|
+
'.bm-row{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border-radius:10px;border:1px solid transparent;background:transparent;animation:bm-item-frames 240ms cubic-bezier(.22,1,.36,1) both;transition:background 120ms ease,border-color 120ms ease}',
|
|
98
|
+
'.bm-row:hover{background:var(--bm-hover,#eff3f8);border-color:var(--bm-line,rgba(15,23,42,.09))}',
|
|
96
99
|
'.bm-row-out{animation:bm-out-frames 160ms cubic-bezier(.4,0,1,1) forwards;pointer-events:none}',
|
|
97
100
|
'.bm-row-head{display:flex;align-items:flex-start;gap:8px}',
|
|
98
101
|
'.bm-check{display:flex;align-items:flex-start;gap:8px;flex:1 1 auto;min-width:0;cursor:pointer}',
|
|
99
|
-
'.bm-check input{margin:2px 0 0}',
|
|
100
|
-
'.bm-row-title{font-size:13px;font-weight:500;word-break:break-word}',
|
|
102
|
+
'.bm-check input{margin:2px 0 0;accent-color:var(--dsw-alias-accent,#3b82f6)}',
|
|
103
|
+
'.bm-row-title{font-size:13px;font-weight:500;line-height:18px;word-break:break-word}',
|
|
101
104
|
'.bm-done{text-decoration:line-through;color:var(--dsw-alias-label-tertiary,#9aa0a6)}',
|
|
102
|
-
'.bm-row-body{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#8a8f98);white-space:pre-wrap;word-break:break-word;max-height:120px;overflow:auto}',
|
|
103
|
-
'.bm-row-actions{display:flex;
|
|
105
|
+
'.bm-row-body{margin:0;padding-left:26px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#8a8f98);white-space:pre-wrap;word-break:break-word;max-height:120px;overflow:auto}',
|
|
106
|
+
'.bm-row-actions{display:flex;flex:0 0 auto;gap:2px;opacity:.55;transition:opacity 120ms ease}',
|
|
107
|
+
'.bm-row:hover .bm-row-actions,.bm-row:focus-within .bm-row-actions{opacity:1}',
|
|
108
|
+
'.bm-row-act{font-size:11.5px;padding:4px 8px;border-radius:6px}',
|
|
104
109
|
'.bm-edit{display:flex;flex-direction:column;gap:6px}',
|
|
105
110
|
'.bm-edit-actions{display:flex;justify-content:flex-end;gap:6px}',
|
|
106
|
-
'.bm-error{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;border:1px solid
|
|
111
|
+
'.bm-error{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;border:1px solid rgba(209,36,47,.32);background:rgba(209,36,47,.06);color:#b3252f;font-size:12px}',
|
|
107
112
|
'.bm-error-spacer{flex:1 1 auto}',
|
|
108
113
|
'.bm-loading{margin:0;font-size:12px;color:var(--dsw-alias-label-secondary,#8a8f98)}',
|
|
109
114
|
/* ---- entry capsule ---- */
|
|
110
|
-
'.bm-capsule{position:fixed;top:
|
|
111
|
-
'.bm-capsule:hover{border-color:
|
|
112
|
-
'.bm-capsule[data-bm-open="1"]{border-color
|
|
113
|
-
'.bm-capsule-floating{top:auto;right:16px;bottom:16px;height:40px;min-width:40px;padding:0 14px;border-radius:20px;box-shadow:0
|
|
114
|
-
'.bm-capsule-label{font-weight:500;white-space:nowrap}',
|
|
115
|
-
'.bm-capsule-count{min-width:16px;height:16px;padding:0 4px;border-radius:8px;background
|
|
115
|
+
'.bm-capsule{position:fixed;top:11px;right:150px;z-index:2147483000;display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 12px;border-radius:8px;border:1px solid rgba(15,23,42,.14);background:#fff;color:#1f2328;font:inherit;font-size:12px;line-height:1;cursor:pointer;pointer-events:auto;-webkit-app-region:no-drag;box-shadow:0 1px 3px rgba(16,24,40,.10);transition:background 120ms ease,border-color 120ms ease}',
|
|
116
|
+
'.bm-capsule:hover{background:#f2f5f9;border-color:rgba(15,23,42,.22)}',
|
|
117
|
+
'.bm-capsule[data-bm-open="1"]{border-color:#2f6fed;background:#fff}',
|
|
118
|
+
'.bm-capsule-floating{top:auto;right:16px;bottom:16px;height:40px;min-width:40px;padding:0 14px;border-radius:20px;box-shadow:0 8px 22px rgba(16,24,40,.18)}',
|
|
119
|
+
'.bm-capsule-label{font-weight:500;white-space:nowrap;color:#1f2328}',
|
|
120
|
+
'.bm-capsule-count{min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:#2f6fed;color:#fff;font-size:10px;line-height:16px;text-align:center}',
|
|
121
|
+
/* ---- popout surfaces: light and high contrast whatever the host theme is ---- */
|
|
122
|
+
'.bm-card,.bm-page{--bm-fg:#1f2328;--bm-fg2:#57606a;--bm-fg3:#8b949e;--bm-line:rgba(15,23,42,.09);--bm-line-2:rgba(15,23,42,.14);--bm-hover:#eff3f8;--bm-surface:#fff;--bm-surface-2:#f6f8fa;--bm-accent:#2f6fed;color-scheme:light;--dsw-alias-bg-base:#fff;--dsw-alias-bg-l1:#fff;--dsw-alias-bg-l2:#f2f5f9;--dsw-alias-label-primary:#1f2328;--dsw-alias-label-secondary:#57606a;--dsw-alias-label-tertiary:#8b949e;--dsw-alias-border-l2:rgba(15,23,42,.10);--dsw-alias-border-l3:rgba(15,23,42,.16);--dsw-alias-border-l4:rgba(15,23,42,.22);--dsw-alias-accent:#2f6fed;--dsw-alias-danger:#d1242f}',
|
|
116
123
|
/* ---- floating card ---- */
|
|
117
|
-
'.bm-card{position:fixed;top:40px;right:150px;width:
|
|
124
|
+
'.bm-card{position:fixed;top:40px;right:150px;width:332px;max-height:58vh;z-index:2147483100;display:flex;flex-direction:column;border-radius:14px;border:1px solid var(--bm-line-2);background:var(--bm-surface);color:var(--bm-fg);box-shadow:0 12px 32px rgba(16,24,40,.14),0 2px 6px rgba(16,24,40,.08);overflow:hidden;pointer-events:auto;-webkit-app-region:no-drag;animation:bm-enter-frames 200ms cubic-bezier(.22,1,.36,1) both}',
|
|
118
125
|
'.bm-card-floating{top:auto;right:16px;bottom:64px}',
|
|
119
126
|
'.bm-card-out{animation:bm-out-frames 160ms cubic-bezier(.4,0,1,1) forwards;pointer-events:none}',
|
|
120
|
-
'.bm-card-head{display:flex;align-items:center;gap:
|
|
121
|
-
'.bm-card-title{font-size:
|
|
122
|
-
'.bm-card-count{
|
|
127
|
+
'.bm-card-head{display:flex;align-items:center;gap:8px;padding:11px 12px 11px 14px;border-bottom:1px solid var(--bm-line)}',
|
|
128
|
+
'.bm-card-title{font-size:13.5px;font-weight:600;letter-spacing:.01em;color:var(--bm-fg)}',
|
|
129
|
+
'.bm-card-count{min-width:18px;padding:1px 6px;border-radius:9px;background:var(--bm-surface-2);color:var(--bm-fg2);font-size:11px;line-height:15px;text-align:center}',
|
|
123
130
|
'.bm-card-spacer{flex:1 1 auto}',
|
|
124
|
-
'.bm-card-gear{display:inline-flex;align-items:center;justify-content:center;width:
|
|
125
|
-
'.bm-card-gear:hover{background:var(--
|
|
126
|
-
'.bm-card-body{display:flex;flex-direction:column;gap:
|
|
127
|
-
'.bm-card-
|
|
128
|
-
'.bm-card-
|
|
129
|
-
'.bm-card-
|
|
130
|
-
'.bm-card-item:
|
|
131
|
-
'.bm-card-
|
|
132
|
-
'.bm-card-
|
|
133
|
-
'.bm-card-dot
|
|
134
|
-
'.bm-card-dot[data-bm-scope="
|
|
135
|
-
'.bm-card-
|
|
136
|
-
'.bm-card-
|
|
137
|
-
'.bm-card-item-
|
|
138
|
-
'.bm-card-
|
|
139
|
-
'.bm-card-
|
|
140
|
-
|
|
141
|
-
'.bm-
|
|
142
|
-
'.bm-
|
|
143
|
-
'.bm-
|
|
131
|
+
'.bm-card-gear{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border-radius:8px;border:1px solid transparent;background:transparent;color:var(--bm-fg3);cursor:pointer;transition:background 120ms ease,color 120ms ease}',
|
|
132
|
+
'.bm-card-gear:hover{background:var(--bm-hover);color:var(--bm-fg)}',
|
|
133
|
+
'.bm-card-body{display:flex;flex-direction:column;gap:2px;padding:6px;overflow:auto}',
|
|
134
|
+
'.bm-card-foot{padding:8px 14px 10px;border-top:1px solid var(--bm-line);font-size:11px;color:var(--bm-fg3)}',
|
|
135
|
+
'.bm-card-empty{margin:0;padding:22px 8px;text-align:center;font-size:12px;color:var(--bm-fg3)}',
|
|
136
|
+
'.bm-card-error{display:flex;align-items:center;gap:8px;margin:4px;padding:10px;border-radius:8px;border:1px solid rgba(209,36,47,.32);background:rgba(209,36,47,.06);color:#b3252f;font-size:12px}',
|
|
137
|
+
'.bm-card-item{display:flex;align-items:flex-start;gap:9px;width:100%;text-align:left;padding:9px 10px;border-radius:10px;border:1px solid transparent;background:transparent;color:var(--bm-fg);font:inherit;cursor:pointer;animation:bm-item-frames 240ms cubic-bezier(.22,1,.36,1) both;transition:background 120ms ease,border-color 120ms ease}',
|
|
138
|
+
'.bm-card-item:hover{background:var(--bm-hover);border-color:var(--bm-line)}',
|
|
139
|
+
'.bm-card-item:active{background:#e8eef7}',
|
|
140
|
+
'.bm-card-dot{flex:0 0 auto;width:7px;height:7px;margin-top:6px;border-radius:50%;background:var(--bm-fg3);box-shadow:0 0 0 3px rgba(15,23,42,.08)}',
|
|
141
|
+
'.bm-card-dot[data-bm-scope="session"]{background:#2f6fed;box-shadow:0 0 0 3px rgba(47,111,237,.14)}',
|
|
142
|
+
'.bm-card-dot[data-bm-scope="profile"]{background:#12a150;box-shadow:0 0 0 3px rgba(18,161,80,.14)}',
|
|
143
|
+
'.bm-card-dot[data-bm-scope="user"]{background:#e08700;box-shadow:0 0 0 3px rgba(224,135,0,.16)}',
|
|
144
|
+
'.bm-card-item-text{display:flex;flex-direction:column;gap:2px;flex:1 1 auto;min-width:0}',
|
|
145
|
+
'.bm-card-item-title{font-size:13px;font-weight:500;line-height:17px;color:var(--bm-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
146
|
+
'.bm-card-item-sub{font-size:11.5px;line-height:15px;color:var(--bm-fg2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
147
|
+
'.bm-card-tag{flex:0 0 auto;align-self:center;padding:2px 7px;border-radius:999px;font-size:10.5px;line-height:14px;color:var(--bm-fg2);background:var(--bm-surface-2);border:1px solid var(--bm-line)}',
|
|
148
|
+
'.bm-card-tag[data-bm-scope="session"]{color:#2559c4;background:rgba(47,111,237,.09);border-color:rgba(47,111,237,.18)}',
|
|
149
|
+
'.bm-card-tag[data-bm-scope="profile"]{color:#0d7f42;background:rgba(18,161,80,.09);border-color:rgba(18,161,80,.18)}',
|
|
150
|
+
'.bm-card-tag[data-bm-scope="user"]{color:#a86200;background:rgba(224,135,0,.10);border-color:rgba(224,135,0,.20)}',
|
|
151
|
+
'.bm-card-toast{position:absolute;right:12px;bottom:12px;padding:7px 13px;border-radius:999px;background:var(--bm-accent);color:#fff;font-size:12px;line-height:1;box-shadow:0 8px 20px rgba(16,24,40,.22);animation:bm-fade-frames 120ms ease both}',
|
|
152
|
+
/* ---- settings page ---- */
|
|
153
|
+
'.bm-overlay-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;background:rgba(16,24,40,.32);pointer-events:auto;-webkit-app-region:no-drag}',
|
|
154
|
+
'.bm-page{display:flex;flex-direction:column;width:min(720px,92vw);height:min(80vh,80vh);max-height:80vh;border-radius:16px;border:1px solid var(--bm-line-2);background:var(--bm-surface);color:var(--bm-fg);box-shadow:0 24px 64px rgba(16,24,40,.22),0 4px 12px rgba(16,24,40,.10);overflow:hidden;animation:bm-enter-frames 200ms cubic-bezier(.22,1,.36,1) both}',
|
|
155
|
+
'.bm-page-head{display:flex;align-items:center;gap:8px;padding:12px 14px;border-bottom:1px solid var(--bm-line)}',
|
|
144
156
|
'.bm-page-back{font-size:12px}',
|
|
145
|
-
'.bm-page-title{font-size:14px;font-weight:600}',
|
|
157
|
+
'.bm-page-title{font-size:14px;font-weight:600;color:var(--bm-fg)}',
|
|
146
158
|
'.bm-page-spacer{flex:1 1 auto}',
|
|
147
159
|
'.bm-page-close{font-size:18px;line-height:1;padding:4px 10px}',
|
|
148
|
-
'.bm-page-switch{display:flex;align-items:center;gap:10px;padding:
|
|
149
|
-
'.bm-switch{display:inline-flex;align-items:center;gap:8px;font-size:12.5px;cursor:pointer}',
|
|
160
|
+
'.bm-page-switch{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--bm-line);flex-wrap:wrap;background:var(--bm-surface-2)}',
|
|
161
|
+
'.bm-switch{display:inline-flex;align-items:center;gap:8px;font-size:12.5px;color:var(--bm-fg);cursor:pointer}',
|
|
150
162
|
'.bm-switch input{cursor:pointer;margin:0}',
|
|
151
|
-
'.bm-switch-error{font-size:11px;color
|
|
152
|
-
'.bm-page-body{flex:1 1 auto;overflow:auto;min-height:0}',
|
|
163
|
+
'.bm-switch-error{font-size:11px;color:#d1242f}',
|
|
164
|
+
'.bm-page-body{flex:1 1 auto;overflow:auto;min-height:0;background:var(--bm-surface)}',
|
|
153
165
|
/* ---- keyframes ---- */
|
|
154
166
|
'@keyframes bm-enter-frames{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}',
|
|
155
167
|
'@keyframes bm-item-frames{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}',
|
|
@@ -256,7 +268,12 @@ window.__ModuleLoader__.load({
|
|
|
256
268
|
return { showTabEntry: settings !== null && settings.showTabEntry === true };
|
|
257
269
|
}
|
|
258
270
|
|
|
259
|
-
/**
|
|
271
|
+
/**
|
|
272
|
+
* The id of the session currently shown in the main view, or '' when the
|
|
273
|
+
* view is not on a real conversation. A session that exists but is still
|
|
274
|
+
* blank (`session.blank === true`) counts as "no conversation": the host
|
|
275
|
+
* renders the welcome screen for it, and the capsule stays hidden there.
|
|
276
|
+
*/
|
|
260
277
|
function currentSessionId(ctx) {
|
|
261
278
|
try {
|
|
262
279
|
const sessions = typeof ctx.get === 'function' ? ctx.get('sessions') : undefined;
|
|
@@ -267,6 +284,7 @@ window.__ModuleLoader__.load({
|
|
|
267
284
|
const ids = Object.keys(byId);
|
|
268
285
|
for (let index = 0; index < ids.length; index += 1) {
|
|
269
286
|
const record = byId[ids[index]];
|
|
287
|
+
if (record && record.blank === true) continue;
|
|
270
288
|
const retained = record && record.retainedBy ? record.retainedBy : null;
|
|
271
289
|
if (retained && (retained.mainView | 0) > 0) return ids[index];
|
|
272
290
|
}
|
|
@@ -595,8 +613,8 @@ window.__ModuleLoader__.load({
|
|
|
595
613
|
},
|
|
596
614
|
[
|
|
597
615
|
h('option', { key: 'session', value: 'session', disabled: !hasSession }, '本会话'),
|
|
598
|
-
h('option', { key: 'profile', value: 'profile' }, '
|
|
599
|
-
h('option', { key: 'user', value: 'user' }, '
|
|
616
|
+
h('option', { key: 'profile', value: 'profile' }, '全局共享'),
|
|
617
|
+
h('option', { key: 'user', value: 'user' }, '仅用户'),
|
|
600
618
|
],
|
|
601
619
|
),
|
|
602
620
|
]),
|
|
@@ -632,7 +650,7 @@ window.__ModuleLoader__.load({
|
|
|
632
650
|
: h(
|
|
633
651
|
'p',
|
|
634
652
|
{ key: 'note', className: 'bm-note' },
|
|
635
|
-
'
|
|
653
|
+
'这个视图没带会话,只能用「全局共享」或「仅用户」。',
|
|
636
654
|
),
|
|
637
655
|
h('div', { key: 'actions', className: 'bm-form-actions' }, [
|
|
638
656
|
h(
|
|
@@ -712,6 +730,7 @@ window.__ModuleLoader__.load({
|
|
|
712
730
|
]),
|
|
713
731
|
);
|
|
714
732
|
} else {
|
|
733
|
+
const confirming = confirmId === entry.id;
|
|
715
734
|
children.push(
|
|
716
735
|
h('div', { key: 'head', className: 'bm-row-head' }, [
|
|
717
736
|
h('label', { key: 'label', className: 'bm-check' }, [
|
|
@@ -730,42 +749,39 @@ window.__ModuleLoader__.load({
|
|
|
730
749
|
displayTitleOf(entry),
|
|
731
750
|
),
|
|
732
751
|
]),
|
|
752
|
+
h('div', { key: 'actions', className: 'bm-row-actions' }, [
|
|
753
|
+
h(
|
|
754
|
+
'button',
|
|
755
|
+
{
|
|
756
|
+
key: 'edit',
|
|
757
|
+
type: 'button',
|
|
758
|
+
className: 'bm-btn bm-btn-ghost bm-row-act',
|
|
759
|
+
'data-bm-edit': entry.id,
|
|
760
|
+
onClick: function () {
|
|
761
|
+
startEdit(entry);
|
|
762
|
+
},
|
|
763
|
+
},
|
|
764
|
+
'改',
|
|
765
|
+
),
|
|
766
|
+
h(
|
|
767
|
+
'button',
|
|
768
|
+
{
|
|
769
|
+
key: 'delete',
|
|
770
|
+
type: 'button',
|
|
771
|
+
className: confirming ? 'bm-btn bm-btn-danger bm-row-act' : 'bm-btn bm-btn-ghost bm-row-act',
|
|
772
|
+
'data-bm-delete': entry.id,
|
|
773
|
+
onClick: function () {
|
|
774
|
+
requestDelete(entry);
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
confirming ? '确定删?' : '删',
|
|
778
|
+
),
|
|
779
|
+
]),
|
|
733
780
|
]),
|
|
734
781
|
);
|
|
735
782
|
if (typeof entry.body === 'string' && entry.body !== '') {
|
|
736
783
|
children.push(h('div', { key: 'body', className: 'bm-row-body' }, entry.body));
|
|
737
784
|
}
|
|
738
|
-
const confirming = confirmId === entry.id;
|
|
739
|
-
children.push(
|
|
740
|
-
h('div', { key: 'actions', className: 'bm-row-actions' }, [
|
|
741
|
-
h(
|
|
742
|
-
'button',
|
|
743
|
-
{
|
|
744
|
-
key: 'edit',
|
|
745
|
-
type: 'button',
|
|
746
|
-
className: 'bm-btn',
|
|
747
|
-
'data-bm-edit': entry.id,
|
|
748
|
-
onClick: function () {
|
|
749
|
-
startEdit(entry);
|
|
750
|
-
},
|
|
751
|
-
},
|
|
752
|
-
'改',
|
|
753
|
-
),
|
|
754
|
-
h(
|
|
755
|
-
'button',
|
|
756
|
-
{
|
|
757
|
-
key: 'delete',
|
|
758
|
-
type: 'button',
|
|
759
|
-
className: confirming ? 'bm-btn bm-btn-danger' : 'bm-btn',
|
|
760
|
-
'data-bm-delete': entry.id,
|
|
761
|
-
onClick: function () {
|
|
762
|
-
requestDelete(entry);
|
|
763
|
-
},
|
|
764
|
-
},
|
|
765
|
-
confirming ? '确定删?' : '删',
|
|
766
|
-
),
|
|
767
|
-
]),
|
|
768
|
-
);
|
|
769
785
|
}
|
|
770
786
|
|
|
771
787
|
return h(
|
|
@@ -793,7 +809,7 @@ window.__ModuleLoader__.load({
|
|
|
793
809
|
}),
|
|
794
810
|
);
|
|
795
811
|
return h('section', { key: key, className: 'bm-group', 'data-bm-group': key }, [
|
|
796
|
-
h('div', { key: 'head', className: 'bm-group-head' }, GROUP_LABEL[key] +
|
|
812
|
+
h('div', { key: 'head', className: 'bm-group-head' }, GROUP_LABEL[key] + String(entries.length)),
|
|
797
813
|
list,
|
|
798
814
|
]);
|
|
799
815
|
}
|
|
@@ -853,6 +869,7 @@ window.__ModuleLoader__.load({
|
|
|
853
869
|
injectStyle();
|
|
854
870
|
|
|
855
871
|
const getSessionId = props && typeof props.getSessionId === 'function' ? props.getSessionId : function () { return ''; };
|
|
872
|
+
const subscribeSessions = props && typeof props.subscribe === 'function' ? props.subscribe : null;
|
|
856
873
|
const seat = props && props.seat ? props.seat : null;
|
|
857
874
|
const variant = props && props.variant === 'floating' ? 'floating' : 'topbar';
|
|
858
875
|
|
|
@@ -865,7 +882,12 @@ window.__ModuleLoader__.load({
|
|
|
865
882
|
const [settingsSaving, setSettingsSaving] = React.useState(false);
|
|
866
883
|
const [settingsError, setSettingsError] = React.useState(null);
|
|
867
884
|
const [toast, setToast] = React.useState(null);
|
|
868
|
-
const [sessionId, setSessionId] = React.useState(
|
|
885
|
+
const [sessionId, setSessionId] = React.useState(function () {
|
|
886
|
+
return getSessionId();
|
|
887
|
+
});
|
|
888
|
+
const [hasSession, setHasSession] = React.useState(function () {
|
|
889
|
+
return getSessionId() !== '';
|
|
890
|
+
});
|
|
869
891
|
|
|
870
892
|
const cardRef = React.useRef(null);
|
|
871
893
|
const capsuleRef = React.useRef(null);
|
|
@@ -889,6 +911,7 @@ window.__ModuleLoader__.load({
|
|
|
889
911
|
React.useEffect(function () {
|
|
890
912
|
const sid = getSessionId();
|
|
891
913
|
setSessionId(sid);
|
|
914
|
+
setHasSession(sid !== '');
|
|
892
915
|
requestState(sid)
|
|
893
916
|
.then(function (next) {
|
|
894
917
|
setPayload(next);
|
|
@@ -905,6 +928,30 @@ window.__ModuleLoader__.load({
|
|
|
905
928
|
};
|
|
906
929
|
}, []);
|
|
907
930
|
|
|
931
|
+
/* The capsule belongs to a conversation. On the new-session / welcome
|
|
932
|
+
screen there is no session in the main view, so it stays hidden. */
|
|
933
|
+
React.useEffect(function () {
|
|
934
|
+
if (subscribeSessions === null) return undefined;
|
|
935
|
+
const sync = function () {
|
|
936
|
+
const next = getSessionId();
|
|
937
|
+
setSessionId(function (prev) {
|
|
938
|
+
return prev === next ? prev : next;
|
|
939
|
+
});
|
|
940
|
+
setHasSession(next !== '');
|
|
941
|
+
if (next === '') setPhase('closed');
|
|
942
|
+
};
|
|
943
|
+
sync();
|
|
944
|
+
let stop = null;
|
|
945
|
+
try {
|
|
946
|
+
stop = subscribeSessions(sync);
|
|
947
|
+
} catch (thrown) {
|
|
948
|
+
stop = null;
|
|
949
|
+
}
|
|
950
|
+
return function () {
|
|
951
|
+
if (typeof stop === 'function') stop();
|
|
952
|
+
};
|
|
953
|
+
}, []);
|
|
954
|
+
|
|
908
955
|
React.useEffect(
|
|
909
956
|
function () {
|
|
910
957
|
if (toast === null) return undefined;
|
|
@@ -998,7 +1045,8 @@ window.__ModuleLoader__.load({
|
|
|
998
1045
|
[phase, closing],
|
|
999
1046
|
);
|
|
1000
1047
|
|
|
1001
|
-
/* ESC backs out of the page.
|
|
1048
|
+
/* ESC backs out of the page; a click on the area outside the page does the same.
|
|
1049
|
+
mousedown (not click) so a drag that starts inside the page never counts. */
|
|
1002
1050
|
React.useEffect(
|
|
1003
1051
|
function () {
|
|
1004
1052
|
if (phase !== 'page') return undefined;
|
|
@@ -1008,9 +1056,17 @@ window.__ModuleLoader__.load({
|
|
|
1008
1056
|
backToCard();
|
|
1009
1057
|
}
|
|
1010
1058
|
}
|
|
1059
|
+
function onDown(event) {
|
|
1060
|
+
const backdrop = document.querySelector('[data-bm-backdrop="1"]');
|
|
1061
|
+
if (!backdrop) return;
|
|
1062
|
+
if (backdrop.contains(event.target) && event.target !== backdrop) return;
|
|
1063
|
+
backToCard();
|
|
1064
|
+
}
|
|
1011
1065
|
document.addEventListener('keydown', onKey, true);
|
|
1066
|
+
document.addEventListener('mousedown', onDown, true);
|
|
1012
1067
|
return function () {
|
|
1013
1068
|
document.removeEventListener('keydown', onKey, true);
|
|
1069
|
+
document.removeEventListener('mousedown', onDown, true);
|
|
1014
1070
|
};
|
|
1015
1071
|
},
|
|
1016
1072
|
[phase],
|
|
@@ -1101,7 +1157,7 @@ window.__ModuleLoader__.load({
|
|
|
1101
1157
|
h('span', { key: 't', className: 'bm-card-item-title' }, displayTitleOf(item.entry)),
|
|
1102
1158
|
sub !== '' ? h('span', { key: 's', className: 'bm-card-item-sub' }, sub) : null,
|
|
1103
1159
|
]),
|
|
1104
|
-
h('span', { key: 'tag', className: 'bm-card-tag' }, SCOPE_TAG[item.scope] || item.scope),
|
|
1160
|
+
h('span', { key: 'tag', className: 'bm-card-tag', 'data-bm-scope': item.scope }, SCOPE_TAG[item.scope] || item.scope),
|
|
1105
1161
|
];
|
|
1106
1162
|
items.push(
|
|
1107
1163
|
h(
|
|
@@ -1156,6 +1212,9 @@ window.__ModuleLoader__.load({
|
|
|
1156
1212
|
),
|
|
1157
1213
|
]),
|
|
1158
1214
|
h('div', { key: 'body', className: 'bm-card-body' }, cardBody()),
|
|
1215
|
+
count > 0
|
|
1216
|
+
? h('div', { key: 'foot', className: 'bm-card-foot' }, '点一行即可复制;齿轮里管理全部')
|
|
1217
|
+
: null,
|
|
1159
1218
|
toast !== null ? h('div', { key: 'toast', className: 'bm-card-toast', role: 'status' }, toast) : null,
|
|
1160
1219
|
],
|
|
1161
1220
|
);
|
|
@@ -1209,6 +1268,8 @@ window.__ModuleLoader__.load({
|
|
|
1209
1268
|
]);
|
|
1210
1269
|
}
|
|
1211
1270
|
|
|
1271
|
+
if (hasSession === false) return null;
|
|
1272
|
+
|
|
1212
1273
|
let overlay = null;
|
|
1213
1274
|
if (phase === 'card') overlay = cardNode();
|
|
1214
1275
|
else if (phase === 'page') overlay = pageNode();
|
|
@@ -1324,7 +1385,7 @@ window.__ModuleLoader__.load({
|
|
|
1324
1385
|
host.setAttribute('data-better-memo-overlay', '');
|
|
1325
1386
|
document.body.appendChild(host);
|
|
1326
1387
|
const root = ReactDOMClient.createRoot(host);
|
|
1327
|
-
root.render(h(OverlayEntry, { seat: deps.seat, getSessionId: deps.getSessionId, variant: 'floating' }));
|
|
1388
|
+
root.render(h(OverlayEntry, { seat: deps.seat, getSessionId: deps.getSessionId, subscribe: deps.subscribe, variant: 'floating' }));
|
|
1328
1389
|
} catch (thrown) {
|
|
1329
1390
|
console.error('[better-memo] floating entry failed', thrown);
|
|
1330
1391
|
}
|
|
@@ -1338,6 +1399,17 @@ window.__ModuleLoader__.load({
|
|
|
1338
1399
|
getSessionId: function () {
|
|
1339
1400
|
return currentSessionId(ctx);
|
|
1340
1401
|
},
|
|
1402
|
+
/* Sessions list changes decide whether a conversation is on screen at
|
|
1403
|
+
all; the capsule hides itself while the welcome screen is up. */
|
|
1404
|
+
subscribe: function (listener) {
|
|
1405
|
+
try {
|
|
1406
|
+
const sessions = typeof ctx.get === 'function' ? ctx.get('sessions') : undefined;
|
|
1407
|
+
if (!sessions || !sessions.list || typeof sessions.list.subscribe !== 'function') return null;
|
|
1408
|
+
return sessions.list.subscribe(listener);
|
|
1409
|
+
} catch (thrown) {
|
|
1410
|
+
return null;
|
|
1411
|
+
}
|
|
1412
|
+
},
|
|
1341
1413
|
};
|
|
1342
1414
|
|
|
1343
1415
|
let overlayMounted = false;
|
|
@@ -1361,7 +1433,7 @@ window.__ModuleLoader__.load({
|
|
|
1361
1433
|
slots.register(
|
|
1362
1434
|
{ name: TOPBAR_SLOT, id: CAPSULE_ID, order: 0, label: function () { return '备忘录'; } },
|
|
1363
1435
|
function () {
|
|
1364
|
-
return h(OverlayEntry, { seat: seat, getSessionId: deps.getSessionId, variant: 'topbar' });
|
|
1436
|
+
return h(OverlayEntry, { seat: seat, getSessionId: deps.getSessionId, subscribe: deps.subscribe, variant: 'topbar' });
|
|
1365
1437
|
},
|
|
1366
1438
|
);
|
|
1367
1439
|
overlayMounted = true;
|
package/index.js
CHANGED
|
@@ -55,6 +55,7 @@ function shape(entry) {
|
|
|
55
55
|
return {
|
|
56
56
|
id: entry.id,
|
|
57
57
|
scope: entry.scope,
|
|
58
|
+
sessionId: entry.sessionId,
|
|
58
59
|
title: entry.title,
|
|
59
60
|
body: entry.body,
|
|
60
61
|
done: entry.done,
|
|
@@ -217,13 +218,13 @@ export function apply(ctx, config = {}) {
|
|
|
217
218
|
ctx.tools.register({
|
|
218
219
|
name: 'memo_edit',
|
|
219
220
|
description:
|
|
220
|
-
'新增 / 修改 / 删除备忘录。op=add 需要
|
|
221
|
-
'op=update / op=delete 需要 id。只能改自己看得到的 session / profile 条目,user 条目改不了。',
|
|
221
|
+
'新增 / 修改 / 删除备忘录。op=add 需要 title 或 body,scope 默认 session(归本会话),' +
|
|
222
|
+
'要共享才写 profile;op=update / op=delete 需要 id。只能改自己看得到的 session / profile 条目,user 条目改不了。',
|
|
222
223
|
parameters: schema(
|
|
223
224
|
{
|
|
224
225
|
op: { type: 'string', enum: ['add', 'update', 'delete'], description: '要做的操作。' },
|
|
225
226
|
id: { type: 'string', description: 'update / delete 用的条目 id(memo_list 返回的那个)。' },
|
|
226
|
-
scope: { type: 'string', enum: AGENT_SCOPES, description: 'add
|
|
227
|
+
scope: { type: 'string', enum: AGENT_SCOPES, description: 'add 用:默认 session,只给本会话;写 profile 才会给本 profile 所有会话。' },
|
|
227
228
|
title: { type: 'string', description: `一句话标题,最多 ${LIMITS.title} 字。` },
|
|
228
229
|
body: { type: 'string', description: `正文,最多 ${LIMITS.body} 字。` },
|
|
229
230
|
done: { type: 'boolean', description: 'update 用:是否标记为已完成。' },
|
|
@@ -239,8 +240,12 @@ export function apply(ctx, config = {}) {
|
|
|
239
240
|
const op = args?.op;
|
|
240
241
|
try {
|
|
241
242
|
if (op === 'add') {
|
|
243
|
+
const scope = args?.scope === undefined ? 'session' : args?.scope;
|
|
244
|
+
if (AGENT_SCOPES.includes(scope) === false) {
|
|
245
|
+
return { ok: false, error: `scope must be one of ${AGENT_SCOPES.join('|')} (you cannot write "user")` };
|
|
246
|
+
}
|
|
242
247
|
const entry = addEntry(db, {
|
|
243
|
-
scope
|
|
248
|
+
scope,
|
|
244
249
|
sessionId,
|
|
245
250
|
profile,
|
|
246
251
|
title: args?.title,
|
package/lib/store.js
CHANGED
|
@@ -174,7 +174,7 @@ export function addEntry(db, input) {
|
|
|
174
174
|
const entry = {
|
|
175
175
|
id: newId(),
|
|
176
176
|
scope,
|
|
177
|
-
sessionId:
|
|
177
|
+
sessionId: str(input.sessionId, 128) || null,
|
|
178
178
|
profile: scope === 'session' ? str(input.profile, 64) || 'default' : str(input.profile, 64) || 'default',
|
|
179
179
|
title,
|
|
180
180
|
body,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-better-memo",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A popout memo card for DeepSeek Harness: top-bar capsule, one-line memos you copy with a click, three scopes (this session / this profile / you only) and agent tools to read and edit them. 浮窗备忘录:顶栏胶囊、点一条即复制、三档归属。",
|
|
6
6
|
"type": "module",
|