memory-lucia 2.0.1 → 2.0.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.
@@ -0,0 +1,364 @@
1
+ # Memory V2 API Reference
2
+
3
+ Complete API documentation for the Memory V2 system.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Initialization](#initialization)
8
+ - [Priority Module](#priority-module)
9
+ - [Learning Module](#learning-module)
10
+ - [Decision Module](#decision-module)
11
+ - [Evolution Module](#evolution-module)
12
+ - [Dashboard](#dashboard)
13
+ - [Version Management](#version-management)
14
+
15
+ ---
16
+
17
+ ## Initialization
18
+
19
+ ```javascript
20
+ const MemoryAPI = require('./api');
21
+
22
+ // Create instance
23
+ const api = new MemoryAPI('./memory-v2.db');
24
+
25
+ // Initialize database
26
+ await api.init();
27
+
28
+ // Close when done
29
+ await api.close();
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Priority Module
35
+
36
+ ### analyzePriority(message)
37
+ Analyze a message and return priority assessment.
38
+
39
+ **Parameters:**
40
+ - `message` (string): The message to analyze
41
+
42
+ **Returns:**
43
+ ```javascript
44
+ {
45
+ priority_level: 'critical' | 'high' | 'medium' | 'low',
46
+ reasoning: string,
47
+ category: string
48
+ }
49
+ ```
50
+
51
+ ### storePriority(msgId, convId, analysis)
52
+ Store priority analysis in database.
53
+
54
+ **Parameters:**
55
+ - `msgId` (string): Message ID
56
+ - `convId` (string): Conversation ID
57
+ - `analysis` (object): Result from analyzePriority
58
+
59
+ **Returns:** `Promise<{id: number}>`
60
+
61
+ ### getHighPriority(limit = 10)
62
+ Get recent high/critical priority items.
63
+
64
+ **Parameters:**
65
+ - `limit` (number): Maximum results
66
+
67
+ **Returns:** `Promise<Array>`
68
+
69
+ ### getPriorityStats()
70
+ Get priority distribution statistics.
71
+
72
+ **Returns:**
73
+ ```javascript
74
+ {
75
+ critical: number,
76
+ high: number,
77
+ medium: number,
78
+ low: number,
79
+ total: number
80
+ }
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Learning Module
86
+
87
+ ### startLearning(msgId, convId, message)
88
+ Start tracking a new learning topic.
89
+
90
+ **Parameters:**
91
+ - `msgId` (string): Message ID
92
+ - `convId` (string): Conversation ID
93
+ - `message` (string): Message describing the learning topic
94
+
95
+ **Returns:**
96
+ ```javascript
97
+ {
98
+ id: number,
99
+ topic: string,
100
+ status: 'active',
101
+ progress: 0
102
+ }
103
+ ```
104
+
105
+ ### updateLearningProgress(learningId, updates)
106
+ Update learning progress.
107
+
108
+ **Parameters:**
109
+ - `learningId` (number): Learning record ID
110
+ - `updates` (object):
111
+ - `progress` (number): 0-100
112
+ - `status` (string): 'active' | 'paused' | 'completed' | 'abandoned'
113
+
114
+ ### addMilestone(learningId, milestone)
115
+ Add a milestone to a learning record.
116
+
117
+ **Parameters:**
118
+ - `learningId` (number): Learning record ID
119
+ - `milestone` (object):
120
+ - `title` (string): Milestone title
121
+ - `description` (string): Optional description
122
+
123
+ ### getActiveLearning(limit = 5)
124
+ Get currently active learning topics.
125
+
126
+ **Parameters:**
127
+ - `limit` (number): Maximum results
128
+
129
+ **Returns:** `Promise<Array>`
130
+
131
+ ### getLearningStats()
132
+ Get learning statistics.
133
+
134
+ **Returns:**
135
+ ```javascript
136
+ {
137
+ active: number,
138
+ completed: number,
139
+ total: number,
140
+ avg_progress: number
141
+ }
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Decision Module
147
+
148
+ ### recordDecision(msgId, convId, decisionData)
149
+ Record a new decision.
150
+
151
+ **Parameters:**
152
+ - `msgId` (string): Message ID
153
+ - `convId` (string): Conversation ID
154
+ - `decisionData` (object):
155
+ - `summary` (string): Decision summary (required)
156
+ - `context` (string): Decision context
157
+ - `expectedOutcome` (string): Expected result
158
+ - `reviewDate` (string): ISO date for review
159
+
160
+ **Returns:** `Promise<{id: number}>`
161
+
162
+ ### updateDecisionOutcome(decisionId, outcome)
163
+ Update the actual outcome of a decision.
164
+
165
+ **Parameters:**
166
+ - `decisionId` (number): Decision ID
167
+ - `outcome` (object):
168
+ - `actualOutcome` (string): What actually happened
169
+ - `status` (string): 'implemented' | 'validated' | 'rejected'
170
+
171
+ ### getPendingDecisions()
172
+ Get decisions pending review or implementation.
173
+
174
+ **Returns:** `Promise<Array>`
175
+
176
+ ### scheduleReview(decisionId, reviewDate)
177
+ Schedule a review for a decision.
178
+
179
+ **Parameters:**
180
+ - `decisionId` (number): Decision ID
181
+ - `reviewDate` (string): ISO date string
182
+
183
+ ---
184
+
185
+ ## Evolution Module
186
+
187
+ ### recordSkillUsage(skillName, category, result)
188
+ Record skill usage.
189
+
190
+ **Parameters:**
191
+ - `skillName` (string): Name of the skill
192
+ - `category` (string): Skill category
193
+ - `result` (string): 'success' | 'failure'
194
+
195
+ ### getTopSkills(limit = 10)
196
+ Get most frequently used skills.
197
+
198
+ **Parameters:**
199
+ - `limit` (number): Maximum results
200
+
201
+ **Returns:** `Promise<Array>`
202
+
203
+ ### getSkillStats(skillName)
204
+ Get statistics for a specific skill.
205
+
206
+ **Parameters:**
207
+ - `skillName` (string): Skill name
208
+
209
+ **Returns:**
210
+ ```javascript
211
+ {
212
+ skill_name: string,
213
+ category: string,
214
+ usage_count: number,
215
+ success_count: number,
216
+ success_rate: number,
217
+ last_used_at: string
218
+ }
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Dashboard
224
+
225
+ ### getDashboard()
226
+ Get unified dashboard of all memory data.
227
+
228
+ **Returns:**
229
+ ```javascript
230
+ {
231
+ summary: {
232
+ total_priorities: number,
233
+ total_learning: number,
234
+ total_decisions: number,
235
+ total_skills: number
236
+ },
237
+ recent: {
238
+ priorities: Array,
239
+ learning: Array,
240
+ decisions: Array
241
+ },
242
+ stats: {
243
+ priorities: Object,
244
+ learning: Object,
245
+ skills: Array
246
+ }
247
+ }
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Version Management
253
+
254
+ ### createBackup(label)
255
+ Create a database backup.
256
+
257
+ **Parameters:**
258
+ - `label` (string): Optional label for the backup
259
+
260
+ **Returns:** `Promise<{backupPath: string}>`
261
+
262
+ ### listBackups()
263
+ List all available backups.
264
+
265
+ **Returns:** `Promise<Array>`
266
+
267
+ ### restoreBackup(backupPath)
268
+ Restore from a backup.
269
+
270
+ **Parameters:**
271
+ - `backupPath` (string): Path to backup file
272
+
273
+ **Returns:** `Promise<boolean>`
274
+
275
+ ### cleanupBackups(keepCount = 10)
276
+ Clean up old backups, keeping only the specified number.
277
+
278
+ **Parameters:**
279
+ - `keepCount` (number): Number of backups to keep
280
+
281
+ ---
282
+
283
+ ## Database Views
284
+
285
+ The following SQL views are available for direct queries:
286
+
287
+ ### v_pending_decisions
288
+ Decisions that need attention (pending, overdue, or due soon).
289
+
290
+ ### v_skill_summary
291
+ Skill usage statistics with success rates.
292
+
293
+ ### v_weekly_learning_report
294
+ Learning activity summary for the past week.
295
+
296
+ ### v_high_priority
297
+ Combined view of high priority items and pending decisions.
298
+
299
+ ---
300
+
301
+ ## Error Handling
302
+
303
+ All API methods return Promises and may throw:
304
+
305
+ ```javascript
306
+ try {
307
+ const result = await api.storePriority(msgId, convId, analysis);
308
+ } catch (err) {
309
+ console.error('API Error:', err.message);
310
+ }
311
+ ```
312
+
313
+ Common errors:
314
+ - Database not initialized
315
+ - Invalid parameters
316
+ - Constraint violations
317
+ - File system errors (backups)
318
+
319
+ ---
320
+
321
+ ## Examples
322
+
323
+ ### Complete Workflow
324
+
325
+ ```javascript
326
+ const MemoryAPI = require('./api');
327
+ const api = new MemoryAPI('./memory-v2.db');
328
+
329
+ async function example() {
330
+ await api.init();
331
+
332
+ // Record a decision
333
+ const decision = await api.recordDecision('msg-123', 'conv-456', {
334
+ summary: 'Use SQLite for local storage',
335
+ context: 'Need embedded database for skill',
336
+ expectedOutcome: 'Simpler deployment'
337
+ });
338
+
339
+ // Start learning
340
+ const learning = await api.startLearning('msg-124', 'conv-456',
341
+ 'Learning SQLite advanced features'
342
+ );
343
+
344
+ // Update progress
345
+ await api.updateLearningProgress(learning.id, { progress: 50 });
346
+
347
+ // Record skill usage
348
+ await api.recordSkillUsage('memory-v2', 'storage', 'success');
349
+
350
+ // Get dashboard
351
+ const dashboard = await api.getDashboard();
352
+ console.log(dashboard);
353
+
354
+ await api.close();
355
+ }
356
+
357
+ example();
358
+ ```
359
+
360
+ ---
361
+
362
+ ## License
363
+
364
+ MIT
package/GITHUB-SETUP.md DELETED
@@ -1,81 +0,0 @@
1
- # GitHub 发布步骤
2
-
3
- ## 🚀 创建 GitHub 仓库
4
-
5
- ### 方式 1: 命令行 (推荐)
6
-
7
- ```bash
8
- cd C:\Users\snowya\.openclaw\workspace-chief_of_staff\memory-v2-skill
9
-
10
- # 初始化 git
11
- git init
12
-
13
- # 添加所有文件
14
- git add .
15
-
16
- # 提交
17
- git commit -m "Initial commit: Memory Lucia v2.0.0"
18
-
19
- # 创建 GitHub 仓库 (需要安装 gh CLI)
20
- # 或者手动在 https://github.com/new 创建
21
-
22
- # 关联远程仓库
23
- git remote add origin https://github.com/snowya/memory-lucia.git
24
-
25
- # 推送
26
- git push -u origin main
27
- ```
28
-
29
- ### 方式 2: 网页操作
30
-
31
- 1. 访问 https://github.com/new
32
- 2. 填写信息:
33
- - **Repository name**: `memory-lucia`
34
- - **Description**: `Advanced memory system for OpenClaw agents`
35
- - **Public** (勾选)
36
- - **Add a README file** (不要勾选,已有 README)
37
- 3. 点击 **Create repository**
38
- 4. 按页面提示推送代码
39
-
40
- ## 📦 创建 Release
41
-
42
- 1. 访问 https://github.com/snowya/memory-lucia/releases
43
- 2. 点击 **"Create a new release"**
44
- 3. 填写信息:
45
- - **Tag**: `v2.0.0`
46
- - **Title**: `Memory Lucia v2.0.0`
47
- - **Description**:
48
- ```markdown
49
- ## Memory Lucia v2.0.0
50
-
51
- Advanced memory system for OpenClaw agents.
52
-
53
- ### Features
54
- - Priority Analysis
55
- - Learning Tracking
56
- - Decision Recording
57
- - Skill Evolution
58
- - Version Management
59
-
60
- ### Installation
61
- ```bash
62
- npm install memory-lucia
63
- ```
64
-
65
- ### Links
66
- - npm: https://www.npmjs.com/package/memory-lucia
67
- ```
68
- 4. 点击 **Publish release**
69
-
70
- ## ✅ 完成检查
71
-
72
- - [ ] GitHub 仓库已创建
73
- - [ ] 代码已推送
74
- - [ ] Release 已发布
75
- - [ ] README 中的链接可点击
76
- - [ ] npm 页面显示 GitHub 链接
77
-
78
- ## 🔗 相关链接
79
-
80
- - GitHub: https://github.com/snowya/memory-lucia
81
- - npm: https://www.npmjs.com/package/memory-lucia
@@ -1,169 +0,0 @@
1
- # Memory V2 Skill - NPM 发布指南
2
-
3
- > 将 Memory V2 发布为 npm 包,供 ClawHub Skill 使用
4
-
5
- ---
6
-
7
- ## 📋 发现:ClawHub Skill 格式
8
-
9
- **ClawHub 上的 Skill 只有 SKILL.md**,代码通过 npm 安装。
10
-
11
- ### 标准结构
12
-
13
- ```
14
- clawhub-skill/
15
- └── SKILL.md # 只有描述文件
16
- ```
17
-
18
- ### npm 包结构
19
-
20
- ```
21
- memory-v2/ # npm 包
22
- ├── package.json
23
- ├── README.md
24
- ├── LICENSE
25
- ├── api/
26
- │ └── index.js # 主入口
27
- ├── modules/ # 核心模块
28
- └── ...
29
- ```
30
-
31
- ---
32
-
33
- ## 🚀 发布流程
34
-
35
- ### 步骤 1: 准备 npm 包
36
-
37
- ```bash
38
- cd memory-v2-skill
39
-
40
- # 1. 确保 package.json 正确
41
- # 2. 更新版本号
42
- npm version 2.0.0
43
-
44
- # 3. 创建 .npmignore
45
- echo "tests/" > .npmignore
46
- echo "backups/" >> .npmignore
47
- echo "*.db" >> .npmignore
48
-
49
- # 4. 发布到 npm
50
- npm publish
51
- ```
52
-
53
- ### 步骤 2: 创建 ClawHub Skill
54
-
55
- 创建 `clawhub-memory-v2/` 目录,只包含 SKILL.md:
56
-
57
- ```yaml
58
- ---
59
- name: memory-v2
60
- description: |
61
- Advanced memory system for OpenClaw agents with priority analysis,
62
- learning tracking, decision recording, and skill evolution.
63
- Use when: (1) Tracking learning progress and milestones, (2) Recording decisions with outcomes,
64
- (3) Analyzing message priorities, (4) Monitoring skill usage and growth.
65
- Requires: npm install memory-v2-skill
66
- ---
67
-
68
- # Memory V2
69
-
70
- ## Installation
71
-
72
- ```bash
73
- npm install memory-v2-skill
74
- ```
75
-
76
- ## Usage
77
-
78
- ```javascript
79
- const MemoryAPI = require('memory-v2-skill');
80
-
81
- const api = new MemoryAPI('./memory-v2.db');
82
- await api.init();
83
-
84
- // Track learning
85
- await api.startLearning(msgId, convId, message);
86
-
87
- // Record decision
88
- await api.recordDecision(msgId, convId, decisionData);
89
-
90
- // Get dashboard
91
- const dashboard = await api.getDashboard();
92
- ```
93
-
94
- ## API
95
-
96
- See: https://github.com/YOUR_USERNAME/memory-v2-skill#api
97
- ```
98
-
99
- ### 步骤 3: 打包并提交
100
-
101
- ```bash
102
- # 打包 ClawHub Skill
103
- cd clawhub-memory-v2
104
- zip ../memory-v2.skill SKILL.md
105
-
106
- # 提交到 ClawHub
107
- # 上传 memory-v2.skill 文件
108
- ```
109
-
110
- ---
111
-
112
- ## 📦 两种发布方式对比
113
-
114
- | 方式 | 适用场景 | 复杂度 |
115
- |------|---------|--------|
116
- | **npm + ClawHub** | 正式发布,用户易安装 | 高 |
117
- | **GitHub 直接安装** | 快速分享,开发者使用 | 低 |
118
-
119
- ---
120
-
121
- ## 🎯 推荐方案:GitHub 直接安装
122
-
123
- 对于 Memory V2,推荐直接 GitHub 安装:
124
-
125
- ### 用户使用
126
-
127
- ```bash
128
- # 克隆到 skills 目录
129
- cd ~/.openclaw/skills
130
- git clone https://github.com/YOUR_USERNAME/memory-v2-skill.git memory-v2
131
-
132
- # 安装依赖
133
- cd memory-v2
134
- npm install
135
-
136
- # 使用
137
- const MemoryAPI = require('memory-v2');
138
- ```
139
-
140
- ### 优点
141
- - 无需 npm 账号
142
- - 无需打包
143
- - 用户可直接修改
144
- - 适合自用和分享
145
-
146
- ---
147
-
148
- ## ✅ 当前状态
149
-
150
- 您的 `memory-v2-skill/` 已经可以直接使用:
151
-
152
- ```bash
153
- # 本地测试
154
- cd memory-v2-skill
155
- npm install
156
- node -e "const M = require('./api'); console.log('OK')"
157
-
158
- # 打包 (zip 格式)
159
- zip -r memory-v2.skill . -x "*.db" "node_modules/*"
160
- ```
161
-
162
- **用户安装后可以直接使用!**
163
-
164
- ---
165
-
166
- ## 📚 参考
167
-
168
- - npm 发布: https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry
169
- - ClawHub: https://clawhub.com
package/PUBLISH-STEPS.md DELETED
@@ -1,102 +0,0 @@
1
- # Memory Lucia 发布步骤
2
-
3
- ## 🚀 一键发布
4
-
5
- 在 `memory-v2-skill` 目录下执行:
6
-
7
- ### Windows
8
- ```bash
9
- publish.bat
10
- ```
11
-
12
- ### Linux/Mac
13
- ```bash
14
- bash publish.sh
15
- ```
16
-
17
- ---
18
-
19
- ## 📋 手动发布步骤
20
-
21
- ### 步骤 1: 进入目录
22
- ```bash
23
- cd C:\Users\snowya\.openclaw\workspace-chief_of_staff\memory-v2-skill
24
- ```
25
-
26
- ### 步骤 2: 登录 npm
27
- ```bash
28
- npm login --auth-type=legacy
29
- ```
30
-
31
- **输入信息:**
32
- - Username: `712724810@qq.com`
33
- - Password: `Q6Ymk#x_4dqM#T@`
34
- - Email: `712724810@qq.com`
35
- - Enter one-time password: (如果开启 2FA,输入验证码)
36
-
37
- ### 步骤 3: 发布
38
- ```bash
39
- npm publish --access=public
40
- ```
41
-
42
- ---
43
-
44
- ## ✅ 验证发布
45
-
46
- 发布成功后,访问:
47
- https://www.npmjs.com/package/memory-lucia
48
-
49
- ---
50
-
51
- ## 📦 用户使用
52
-
53
- 发布后,用户可以直接安装:
54
-
55
- ```bash
56
- npm install memory-lucia
57
- ```
58
-
59
- ```javascript
60
- const MemoryAPI = require('memory-lucia');
61
- const api = new MemoryAPI('./memory.db');
62
- await api.init();
63
- ```
64
-
65
- ---
66
-
67
- ## 🔧 如果发布失败
68
-
69
- ### 错误 1: 包名已存在
70
- ```bash
71
- # 修改 package.json 中的 name
72
- # 或者使用 scoped name: @yourname/memory-lucia
73
- ```
74
-
75
- ### 错误 2: 未登录
76
- ```bash
77
- npm login --auth-type=legacy
78
- # 重新登录
79
- ```
80
-
81
- ### 错误 3: 版本已存在
82
- ```bash
83
- # 更新版本号
84
- npm version patch # 2.0.0 -> 2.0.1
85
- npm publish
86
- ```
87
-
88
- ---
89
-
90
- ## 📊 发布信息
91
-
92
- | 属性 | 值 |
93
- |------|-----|
94
- | 包名 | `memory-lucia` |
95
- | 版本 | `2.0.0` |
96
- | 大小 | 14.4 KB |
97
- | 主入口 | `api/index.js` |
98
- | 依赖 | `sqlite3` |
99
-
100
- ---
101
-
102
- **执行 `publish.bat` 或 `publish.sh` 即可发布!**
@@ -1,13 +0,0 @@
1
- @echo off
2
- echo 🚀 Publishing memory-lucia to npm...
3
- echo.
4
- echo This package requires 2FA authentication.
5
- echo.
6
- echo Please enter your 6-digit 2FA code from your Authenticator app:
7
- set /p OTP="2FA Code: "
8
- echo.
9
- echo Publishing with OTP: %OTP%
10
- npm publish --access=public --otp=%OTP%
11
- echo.
12
- echo ✅ Done!
13
- pause