sumulige-claude 1.2.0 → 1.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.
Files changed (68) hide show
  1. package/.claude/.kickoff-hint.txt +3 -2
  2. package/.claude/CLAUDE.md +138 -0
  3. package/.claude/README.md +234 -43
  4. package/.claude/boris-optimizations.md +167 -0
  5. package/.claude/commands/todos.md +6 -41
  6. package/.claude/hooks/code-formatter.cjs +2 -7
  7. package/.claude/hooks/conversation-logger.cjs +222 -0
  8. package/.claude/hooks/multi-session.cjs +3 -9
  9. package/.claude/hooks/project-kickoff.cjs +198 -20
  10. package/.claude/hooks/rag-skill-loader.cjs +0 -7
  11. package/.claude/hooks/session-restore.cjs +0 -0
  12. package/.claude/hooks/session-save.cjs +0 -0
  13. package/.claude/hooks/thinking-silent.cjs +3 -9
  14. package/.claude/hooks/todo-manager.cjs +142 -269
  15. package/.claude/hooks/verify-work.cjs +4 -10
  16. package/.claude/rag/skill-index.json +128 -8
  17. package/.claude/settings.json +115 -0
  18. package/.claude/skills/123-skill/SKILL.md +61 -0
  19. package/.claude/skills/123-skill/examples/basic.md +3 -0
  20. package/.claude/skills/123-skill/metadata.yaml +30 -0
  21. package/.claude/skills/123-skill/templates/default.md +3 -0
  22. package/.claude/skills/SKILLS.md +145 -0
  23. package/.claude/skills/code-reviewer-123/SKILL.md +61 -0
  24. package/.claude/skills/code-reviewer-123/examples/basic.md +3 -0
  25. package/.claude/skills/code-reviewer-123/metadata.yaml +30 -0
  26. package/.claude/skills/code-reviewer-123/templates/default.md +3 -0
  27. package/.claude/skills/examples/README.md +47 -0
  28. package/.claude/skills/examples/basic-task.md +67 -0
  29. package/.claude/skills/examples/bug-fix-workflow.md +92 -0
  30. package/.claude/skills/examples/feature-development.md +81 -0
  31. package/.claude/skills/manus-kickoff/SKILL.md +128 -0
  32. package/.claude/skills/manus-kickoff/examples/basic.md +84 -0
  33. package/.claude/skills/manus-kickoff/metadata.yaml +33 -0
  34. package/.claude/skills/manus-kickoff/templates/PROJECT_KICKOFF.md +89 -0
  35. package/.claude/skills/manus-kickoff/templates/PROJECT_PROPOSAL.md +227 -0
  36. package/.claude/skills/manus-kickoff/templates/TASK_PLAN.md +121 -0
  37. package/.claude/skills/my-skill/SKILL.md +61 -0
  38. package/.claude/skills/my-skill/examples/basic.md +3 -0
  39. package/.claude/skills/my-skill/metadata.yaml +30 -0
  40. package/.claude/skills/my-skill/templates/default.md +3 -0
  41. package/.claude/skills/template/metadata.yaml +30 -0
  42. package/.claude/skills/test-skill-name/SKILL.md +61 -0
  43. package/.claude/skills/test-skill-name/examples/basic.md +3 -0
  44. package/.claude/skills/test-skill-name/metadata.yaml +30 -0
  45. package/.claude/skills/test-skill-name/templates/default.md +3 -0
  46. package/.claude/templates/PROJECT_KICKOFF.md +89 -0
  47. package/.claude/templates/PROJECT_PROPOSAL.md +227 -0
  48. package/.claude/templates/TASK_PLAN.md +121 -0
  49. package/.claude-plugin/marketplace.json +2 -2
  50. package/AGENTS.md +30 -6
  51. package/CHANGELOG.md +18 -0
  52. package/CLAUDE-template.md +114 -0
  53. package/README.md +16 -1
  54. package/config/official-skills.json +2 -2
  55. package/jest.config.js +3 -1
  56. package/lib/commands.js +1626 -1207
  57. package/lib/marketplace.js +1 -0
  58. package/package.json +1 -1
  59. package/project-paradigm.md +313 -0
  60. package/prompts/how-to-find.md +163 -0
  61. package/tests/commands.test.js +940 -17
  62. package/tests/config-schema.test.js +425 -0
  63. package/tests/marketplace.test.js +330 -214
  64. package/tests/sync-external.test.js +214 -0
  65. package/tests/update-registry.test.js +251 -0
  66. package/tests/utils.test.js +12 -8
  67. package/tests/web-search.test.js +392 -0
  68. package/thinkinglens-silent.md +138 -0
@@ -0,0 +1,392 @@
1
+ /**
2
+ * Web Search 模块单元测试
3
+ * 测试 Bing HTML 解析功能(不涉及网络请求)
4
+ */
5
+
6
+ // Only test the static methods that don't require network calls
7
+ // We'll extract the logic for testing
8
+
9
+ // ============================================================================
10
+ // Test Data (Bing HTML responses)
11
+ // ============================================================================
12
+
13
+ const BING_HTML_RESPONSE = `
14
+ <li class="b_algo">
15
+ <h2><a href="https://example.com/page1">Example Page 1</a></h2>
16
+ <p>This is a description of the first page.</p>
17
+ </li>
18
+ <li class="b_algo">
19
+ <h2><a href="https://example.com/page2">Example Page 2</a></h2>
20
+ <p>This is a description of the second page.</p>
21
+ </li>
22
+ <li class="b_algo">
23
+ <h2><a href="https://example.com/page3">&quot;Quoted&quot; Title &amp; More</a></h2>
24
+ <p>Description with <strong>bold</strong> text and <b>more</b>.</p>
25
+ </li>
26
+ <li class="b_algo">
27
+ <h2><a href="https://www.bing.com/ck/a?!&amp;p=xxx&amp;u=aHR0cHM6Ly9leGFtcGxlLmNvbQ==">Bing Redirect</a></h2>
28
+ <p>Redirected page description.</p>
29
+ </li>
30
+ `;
31
+
32
+ // ============================================================================
33
+ // Helper Functions (copied from web-search.js for testing)
34
+ // ============================================================================
35
+
36
+ function decodeHTML(text) {
37
+ const entities = {
38
+ '&amp;': '&',
39
+ '&lt;': '<',
40
+ '&gt;': '>',
41
+ '&quot;': '"',
42
+ '&#39;': "'",
43
+ '&apos;': "'",
44
+ '&nbsp;': ' ',
45
+ '&middot;': '·'
46
+ };
47
+
48
+ return text.replace(/&[^;]+;/g, (entity) => {
49
+ return entities[entity] || entity;
50
+ });
51
+ }
52
+
53
+ function parseHTML(html, maxResults = 5) {
54
+ const results = [];
55
+
56
+ const algoRegex = /<li[^>]*class="b_algo"[^>]*>([\s\S]*?)<\/li>/g;
57
+ let match;
58
+ let count = 0;
59
+
60
+ while ((match = algoRegex.exec(html)) !== null && count < maxResults) {
61
+ const block = match[1];
62
+ count++;
63
+
64
+ let title = '';
65
+ const titleMatch = block.match(/<h2><a[^>]*>([^<]+)<\/a>/);
66
+ if (titleMatch) {
67
+ title = decodeHTML(titleMatch[1]);
68
+ }
69
+
70
+ if (!title) {
71
+ const altTitleMatch = block.match(/<a[^>]*h="[^"]*"[^>]*>([^<]*(?:<strong>[^<]*<\/strong>[^<]*)*)<\/a>/);
72
+ if (altTitleMatch) {
73
+ title = decodeHTML(altTitleMatch[1].replace(/<strong>/g, '').replace(/<\/strong>/g, ''));
74
+ }
75
+ }
76
+
77
+ let url = '';
78
+ const urlMatch = block.match(/<a[^>]*href="([^"]+)"/);
79
+ if (urlMatch) {
80
+ url = urlMatch[1];
81
+ url = url.replace(/&amp;/g, '&');
82
+
83
+ if (url.includes('bing.com/ck/a')) {
84
+ const uMatch = url.match(/[?&]u=([^&]+)/);
85
+ if (uMatch) {
86
+ let encodedUrl = uMatch[1];
87
+ try {
88
+ let decodedUrl = decodeURIComponent(encodedUrl);
89
+ decodedUrl = decodeURIComponent(decodedUrl);
90
+
91
+ if (decodedUrl.startsWith('a1')) {
92
+ const base64Part = decodedUrl.substring(2);
93
+ decodedUrl = Buffer.from(base64Part, 'base64').toString('utf-8');
94
+ }
95
+
96
+ url = decodedUrl;
97
+ } catch (e) {
98
+ try {
99
+ if (encodedUrl.startsWith('a1')) {
100
+ const base64Part = encodedUrl.substring(2);
101
+ url = Buffer.from(base64Part, 'base64').toString('utf-8');
102
+ } else {
103
+ url = decodeURIComponent(encodedUrl);
104
+ }
105
+ } catch (e2) {}
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ let snippet = '';
112
+ const snippetMatch = block.match(/<p[^>]*>([\s\S]*?)<\/p>/);
113
+ if (snippetMatch) {
114
+ snippet = decodeHTML(snippetMatch[1]
115
+ .replace(/<strong>/g, '').replace(/<\/strong>/g, '')
116
+ .replace(/<b>/g, '').replace(/<\/b>/g, '')
117
+ .replace(/<[^>]+>/g, ' ')
118
+ .replace(/\s+/g, ' ')
119
+ .trim());
120
+ }
121
+
122
+ if (!url || url.startsWith('#')) continue;
123
+
124
+ results.push({
125
+ title: title || 'Untitled',
126
+ url,
127
+ excerpt: snippet || 'No description available.',
128
+ source: 'bing'
129
+ });
130
+ }
131
+
132
+ return results;
133
+ }
134
+
135
+ function dedupeResults(results) {
136
+ const seen = new Set();
137
+ return results.filter(result => {
138
+ const normalizedUrl = result.url
139
+ .replace(/^https?:\/\//, '')
140
+ .replace(/\/$/, '')
141
+ .toLowerCase();
142
+
143
+ if (seen.has(normalizedUrl)) return false;
144
+ seen.add(normalizedUrl);
145
+ return true;
146
+ });
147
+ }
148
+
149
+ // ============================================================================
150
+ // Tests
151
+ // ============================================================================
152
+
153
+ describe('Web Search Module - HTML Parsing', () => {
154
+ describe('decodeHTML', () => {
155
+ it('should decode &amp;', () => {
156
+ expect(decodeHTML('Hello &amp; World')).toBe('Hello & World');
157
+ });
158
+
159
+ it('should decode &lt;', () => {
160
+ expect(decodeHTML('A &lt; B')).toBe('A < B');
161
+ });
162
+
163
+ it('should decode &gt;', () => {
164
+ expect(decodeHTML('A &gt; B')).toBe('A > B');
165
+ });
166
+
167
+ it('should decode &quot;', () => {
168
+ expect(decodeHTML('&quot;text&quot;')).toBe('"text"');
169
+ });
170
+
171
+ it('should decode &#39;', () => {
172
+ expect(decodeHTML('&#39;text&#39;')).toBe("'text'");
173
+ });
174
+
175
+ it('should decode &apos;', () => {
176
+ expect(decodeHTML('&apos;text&apos;')).toBe("'text'");
177
+ });
178
+
179
+ it('should decode &nbsp;', () => {
180
+ expect(decodeHTML('A&nbsp;B')).toBe('A B');
181
+ });
182
+
183
+ it('should decode &middot;', () => {
184
+ expect(decodeHTML('A&middot;B')).toBe('A·B');
185
+ });
186
+
187
+ it('should decode multiple entities', () => {
188
+ expect(decodeHTML('&lt;&amp;&gt;')).toBe('<&>');
189
+ });
190
+
191
+ it('should leave unknown entities unchanged', () => {
192
+ expect(decodeHTML('&unknown;')).toBe('&unknown;');
193
+ });
194
+
195
+ it('should handle text without entities', () => {
196
+ expect(decodeHTML('Plain text')).toBe('Plain text');
197
+ });
198
+
199
+ it('should handle empty string', () => {
200
+ expect(decodeHTML('')).toBe('');
201
+ });
202
+ });
203
+
204
+ describe('dedupeResults', () => {
205
+ it('should remove duplicate URLs', () => {
206
+ const results = [
207
+ { url: 'https://example.com/page', title: 'First' },
208
+ { url: 'https://example.com/page/', title: 'Second' },
209
+ { url: 'https://EXAMPLE.COM/page', title: 'Third' }
210
+ ];
211
+
212
+ const deduped = dedupeResults(results);
213
+ expect(deduped).toHaveLength(1);
214
+ });
215
+
216
+ it('should preserve unique URLs', () => {
217
+ const results = [
218
+ { url: 'https://example.com/page1', title: 'First' },
219
+ { url: 'https://example.com/page2', title: 'Second' }
220
+ ];
221
+
222
+ const deduped = dedupeResults(results);
223
+ expect(deduped).toHaveLength(2);
224
+ });
225
+
226
+ it('should normalize URLs for comparison', () => {
227
+ const results = [
228
+ { url: 'https://example.com/page', title: 'First' },
229
+ { url: 'https://example.com/page/', title: 'Second' },
230
+ { url: 'https://EXAMPLE.COM/PAGE', title: 'Third' }
231
+ ];
232
+
233
+ const deduped = dedupeResults(results);
234
+ expect(deduped).toHaveLength(1);
235
+ });
236
+
237
+ it('should preserve result order', () => {
238
+ const results = [
239
+ { url: 'https://example.com/page1', title: 'First' },
240
+ { url: 'https://example.com/page2', title: 'Second' }
241
+ ];
242
+
243
+ const deduped = dedupeResults(results);
244
+ expect(deduped[0].title).toBe('First');
245
+ expect(deduped[1].title).toBe('Second');
246
+ });
247
+
248
+ it('should handle empty array', () => {
249
+ const deduped = dedupeResults([]);
250
+ expect(deduped).toEqual([]);
251
+ });
252
+ });
253
+
254
+ describe('parseHTML', () => {
255
+ it('should parse Bing result blocks', () => {
256
+ const results = parseHTML(BING_HTML_RESPONSE, 5);
257
+ expect(results).toHaveLength(4);
258
+ });
259
+
260
+ it('should extract titles', () => {
261
+ const results = parseHTML(BING_HTML_RESPONSE, 5);
262
+ expect(results[0].title).toBe('Example Page 1');
263
+ expect(results[1].title).toBe('Example Page 2');
264
+ expect(results[2].title).toBe('"Quoted" Title & More');
265
+ });
266
+
267
+ it('should extract URLs', () => {
268
+ const results = parseHTML(BING_HTML_RESPONSE, 5);
269
+ expect(results[0].url).toBe('https://example.com/page1');
270
+ expect(results[1].url).toBe('https://example.com/page2');
271
+ expect(results[2].url).toBe('https://example.com/page3');
272
+ });
273
+
274
+ it('should extract snippets', () => {
275
+ const results = parseHTML(BING_HTML_RESPONSE, 5);
276
+ expect(results[0].excerpt).toBe('This is a description of the first page.');
277
+ expect(results[1].excerpt).toBe('This is a description of the second page.');
278
+ expect(results[2].excerpt).toBe('Description with bold text and more.');
279
+ });
280
+
281
+ it('should add source field', () => {
282
+ const results = parseHTML(BING_HTML_RESPONSE, 5);
283
+ expect(results[0].source).toBe('bing');
284
+ });
285
+
286
+ it('should decode HTML entities in titles', () => {
287
+ const html = `
288
+ <li class="b_algo">
289
+ <h2><a href="https://example.com">&quot;Test&quot; &amp; More</a></h2>
290
+ <p>Description here.</p>
291
+ </li>
292
+ `;
293
+ const results = parseHTML(html, 5);
294
+ expect(results[0].title).toBe('"Test" & More');
295
+ });
296
+
297
+ it('should respect maxResults limit', () => {
298
+ const results = parseHTML(BING_HTML_RESPONSE, 2);
299
+ expect(results).toHaveLength(2);
300
+ });
301
+
302
+ it('should handle empty HTML', () => {
303
+ const results = parseHTML('', 5);
304
+ expect(results).toEqual([]);
305
+ });
306
+
307
+ it('should handle malformed HTML gracefully', () => {
308
+ const malformed = '<li class="b_algo">incomplete';
309
+ const results = parseHTML(malformed, 5);
310
+ expect(Array.isArray(results)).toBe(true);
311
+ });
312
+
313
+ it('should skip results with invalid URLs', () => {
314
+ const html = `
315
+ <li class="b_algo">
316
+ <h2><a href="#">No URL</a></h2>
317
+ <p>Description.</p>
318
+ </li>
319
+ `;
320
+ const results = parseHTML(html, 5);
321
+ expect(results).toHaveLength(0);
322
+ });
323
+
324
+ it('should provide default title when not found', () => {
325
+ const html = `
326
+ <li class="b_algo">
327
+ <a href="https://example.com"></a>
328
+ <p>Description.</p>
329
+ </li>
330
+ `;
331
+ const results = parseHTML(html, 5);
332
+ expect(results[0].title).toBe('Untitled');
333
+ });
334
+
335
+ it('should provide default excerpt when not found', () => {
336
+ const html = `
337
+ <li class="b_algo">
338
+ <h2><a href="https://example.com">Title</a></h2>
339
+ </li>
340
+ `;
341
+ const results = parseHTML(html, 5);
342
+ expect(results[0].excerpt).toBe('No description available.');
343
+ });
344
+
345
+ it('should decode &amp; in URLs', () => {
346
+ const html = `
347
+ <li class="b_algo">
348
+ <h2><a href="https://example.com?param1=value1&amp;param2=value2">Title</a></h2>
349
+ <p>Description.</p>
350
+ </li>
351
+ `;
352
+ const results = parseHTML(html, 5);
353
+ expect(results[0].url).toBe('https://example.com?param1=value1&param2=value2');
354
+ });
355
+
356
+ it('should handle Bing redirect URLs with base64 encoding (a1 prefix)', () => {
357
+ // Bing uses a1 prefix + base64 encoding for redirect URLs
358
+ // a1 + base64('https://example.com') = a1aHR0cHM6Ly9leGFtcGxlLmNvbQ==
359
+ // When URL encoded: a1aHR0cHM6Ly9leGFtcGxlLmNvbQ%3D%3D
360
+ const html = `
361
+ <li class="b_algo">
362
+ <h2><a href="https://www.bing.com/ck/a?!&amp;p=xxx&amp;u=a1aHR0cHM6Ly9leGFtcGxlLmNvbQ%3D%3D">Bing Redirect</a></h2>
363
+ <p>Description.</p>
364
+ </li>
365
+ `;
366
+ const results = parseHTML(html, 5);
367
+ expect(results[0].url).toBe('https://example.com');
368
+ });
369
+
370
+ it('should handle direct URL encoding (without a1 prefix)', () => {
371
+ // Some Bing redirects use direct URL encoding
372
+ const html = `
373
+ <li class="b_algo">
374
+ <h2><a href="https://www.bing.com/ck/a?!&amp;p=xxx&amp;u=https%3A%2F%2Fexample.com">Bing Redirect</a></h2>
375
+ <p>Description.</p>
376
+ </li>
377
+ `;
378
+ const results = parseHTML(html, 5);
379
+ expect(results[0].url).toBe('https://example.com');
380
+ });
381
+ });
382
+ });
383
+
384
+ describe('Web Search Module - Constants', () => {
385
+ it('should define SEARCH_TIMEOUT', () => {
386
+ expect(10000).toBeDefined();
387
+ });
388
+
389
+ it('should define MAX_RESULTS', () => {
390
+ expect(5).toBeDefined();
391
+ });
392
+ });
@@ -0,0 +1,138 @@
1
+ # ThinkingLens 无感知模式
2
+
3
+ > 完全自动、完全静默的对话追踪
4
+ > 最后更新:2026-01-11
5
+
6
+ ---
7
+
8
+ ## 特点
9
+
10
+ ✅ **完全静默** - 对话期间零输出、零打扰
11
+ ✅ **自动追踪** - 每次 Prompt 自动记录
12
+ ✅ **智能识别** - 自动识别关键操作
13
+ ✅ **按需查看** - 想看的时候再看
14
+
15
+ ---
16
+
17
+ ## 工作原理
18
+
19
+ ```
20
+ 你: "帮我实现数据分析"
21
+
22
+ [Hook 静默执行 - 1ms]
23
+ ↓ (无输出)
24
+ AI: "好的,我来实现..."
25
+ ```
26
+
27
+ 后台自动记录:
28
+ - 对话时间
29
+ - 操作类型(代码编辑、关键决策等)
30
+ - 输入长度
31
+ - 上下文信息
32
+
33
+ ---
34
+
35
+ ## 使用方法
36
+
37
+ ### 1. 自动追踪(已启用)
38
+
39
+ 什么都不用做!系统在后台静默运行。
40
+
41
+ ### 2. 查看摘要(按需)
42
+
43
+ ```bash
44
+ .claude/hooks/tl-summary.sh
45
+ ```
46
+
47
+ 输出示例:
48
+ ```
49
+ 📅 今日对话摘要
50
+ ────────────────────────────────────────
51
+ 会话 ID: s-20260111-evolvemind
52
+ 开始时间: 2026-01-11 10:30:00
53
+ 对话轮次: 15
54
+
55
+ 📊 操作统计:
56
+ 💬 normal: 10
57
+ 📝 code-edit: 4
58
+ ⚡ potential-action: 1
59
+
60
+ 🕐 最近活动:
61
+ 15:20 📝 Edit
62
+ 15:15 💬 UserPromptSubmit
63
+ 15:10 ⚡ 完成数据分析功能
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 文件位置
69
+
70
+ ```
71
+ .claude/
72
+ ├── hooks/
73
+ │ ├── thinking-silent.js # 无感知追踪 Hook ✅ 当前使用
74
+ │ ├── tl-summary.sh # 查看摘要命令
75
+ │ └── ...
76
+ └── thinking-routes/
77
+ └── .conversation-flow.json # 对话流数据
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 配置
83
+
84
+ 在 `.claude/settings.json` 中:
85
+
86
+ ```json
87
+ {
88
+ "hooks": {
89
+ "UserPromptSubmit": [
90
+ {
91
+ "hooks": [{
92
+ "type": "command",
93
+ "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/thinking-silent.js",
94
+ "timeout": 1
95
+ }]
96
+ }
97
+ ]
98
+ }
99
+ }
100
+ ```
101
+
102
+ ---
103
+
104
+ ## 数据隐私
105
+
106
+ - 数据只保存在本地项目
107
+ - 不会上传到任何外部服务
108
+ - 你可以随时删除 `.conversation-flow.json`
109
+
110
+ ---
111
+
112
+ ## 迁移到新项目
113
+
114
+ 只需复制 2 个文件:
115
+
116
+ ```bash
117
+ # 1. 复制 Hook
118
+ cp .claude/hooks/thinking-silent.js /新项目/.claude/hooks/
119
+
120
+ # 2. 更新 settings.json
121
+ # 添加 UserPromptSubmit hook 配置
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 常见问题
127
+
128
+ **Q: 会影响性能吗?**
129
+ A: 不会,每次执行耗时 < 1ms
130
+
131
+ **Q: 会占用多少空间?**
132
+ A: 每次对话约 100-500 字节,可忽略
133
+
134
+ **Q: 如何清空记录?**
135
+ A: 删除 `.claude/thinking-routes/.conversation-flow.json`
136
+
137
+ **Q: 对话会保存到云端吗?**
138
+ A: 不会,只保存在本地