sumulige-claude 1.3.3 → 1.4.0

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.
@@ -13,6 +13,10 @@ const PROJECT_DIR = process.env.CLAUDE_PROJECT_DIR || process.cwd();
13
13
  const RAG_DIR = path.join(PROJECT_DIR, '.claude/rag');
14
14
  const SKILL_INDEX_FILE = path.join(RAG_DIR, 'skill-index.json');
15
15
  const SKILLS_DIR = path.join(PROJECT_DIR, '.claude/skills');
16
+ const CACHE_FILE = path.join(RAG_DIR, '.match-cache.json');
17
+
18
+ // 缓存配置
19
+ const CACHE_TTL = 300000; // 5分钟缓存有效期
16
20
 
17
21
  // 技能关键词匹配权重
18
22
  const KEYWORD_WEIGHTS = {
@@ -21,6 +25,67 @@ const KEYWORD_WEIGHTS = {
21
25
  related: 0.5 // 相关匹配
22
26
  };
23
27
 
28
+ // 简单哈希函数
29
+ function hashInput(input) {
30
+ let hash = 0;
31
+ for (let i = 0; i < input.length; i++) {
32
+ const char = input.charCodeAt(i);
33
+ hash = ((hash << 5) - hash) + char;
34
+ hash = hash & hash;
35
+ }
36
+ return hash.toString(16);
37
+ }
38
+
39
+ // 加载缓存
40
+ function loadCache() {
41
+ if (!fs.existsSync(CACHE_FILE)) {
42
+ return {};
43
+ }
44
+ try {
45
+ return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf-8'));
46
+ } catch (e) {
47
+ return {};
48
+ }
49
+ }
50
+
51
+ // 保存缓存
52
+ function saveCache(cache) {
53
+ try {
54
+ // 清理过期条目
55
+ const now = Date.now();
56
+ const cleaned = {};
57
+ for (const [key, value] of Object.entries(cache)) {
58
+ if (now - value.timestamp < (value.ttl || CACHE_TTL)) {
59
+ cleaned[key] = value;
60
+ }
61
+ }
62
+ fs.writeFileSync(CACHE_FILE, JSON.stringify(cleaned, null, 2));
63
+ } catch (e) {
64
+ // 忽略保存错误
65
+ }
66
+ }
67
+
68
+ // 从缓存获取结果
69
+ function getCachedResult(inputHash) {
70
+ const cache = loadCache();
71
+ const cached = cache[inputHash];
72
+ if (cached && Date.now() - cached.timestamp < (cached.ttl || CACHE_TTL)) {
73
+ return cached.result;
74
+ }
75
+ return null;
76
+ }
77
+
78
+ // 保存结果到缓存
79
+ function setCachedResult(inputHash, result) {
80
+ const cache = loadCache();
81
+ cache[inputHash] = {
82
+ result,
83
+ timestamp: Date.now(),
84
+ ttl: CACHE_TTL
85
+ };
86
+ saveCache(cache);
87
+ }
88
+
24
89
  // 加载技能索引
25
90
  function loadSkillIndex() {
26
91
  if (!fs.existsSync(SKILL_INDEX_FILE)) {
@@ -134,12 +199,27 @@ function main() {
134
199
  process.exit(0);
135
200
  }
136
201
 
137
- const analysis = analyzeInput(toolInput);
138
- if (analysis.keywords.length === 0) {
139
- process.exit(0);
202
+ // 检查缓存
203
+ const inputHash = hashInput(toolInput);
204
+ const cachedResult = getCachedResult(inputHash);
205
+
206
+ let matches;
207
+ if (cachedResult) {
208
+ // 使用缓存结果
209
+ matches = cachedResult;
210
+ } else {
211
+ // 分析并匹配
212
+ const analysis = analyzeInput(toolInput);
213
+ if (analysis.keywords.length === 0) {
214
+ process.exit(0);
215
+ }
216
+
217
+ matches = matchSkills(analysis, skillIndex);
218
+
219
+ // 缓存结果
220
+ setCachedResult(inputHash, matches);
140
221
  }
141
222
 
142
- const matches = matchSkills(analysis, skillIndex);
143
223
  if (matches.length === 0) {
144
224
  process.exit(0);
145
225
  }
@@ -45,82 +45,23 @@
45
45
  "hooks": [
46
46
  {
47
47
  "type": "command",
48
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/project-kickoff.cjs",
49
- "timeout": 1000
50
- },
51
- {
52
- "type": "command",
53
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/rag-skill-loader.cjs",
54
- "timeout": 1000
55
- },
56
- {
57
- "type": "command",
58
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/thinking-silent.cjs",
59
- "timeout": 1000
60
- },
61
- {
62
- "type": "command",
63
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/multi-session.cjs",
64
- "timeout": 1000
65
- },
66
- {
67
- "type": "command",
68
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/todo-manager.cjs",
69
- "timeout": 1000
70
- }
71
- ]
72
- }
73
- ],
74
- "PreToolUse": [
75
- {
76
- "matcher": {},
77
- "hooks": [
78
- {
79
- "type": "command",
80
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/thinking-silent.cjs",
81
- "timeout": 1000
82
- },
83
- {
84
- "type": "command",
85
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/multi-session.cjs",
86
- "timeout": 1000
87
- },
88
- {
89
- "type": "command",
90
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/todo-manager.cjs",
91
- "timeout": 1000
48
+ "command": "CLAUDE_EVENT_TYPE=UserPromptSubmit node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/hook-dispatcher.cjs",
49
+ "timeout": 3000
92
50
  }
93
51
  ]
94
52
  }
95
53
  ],
54
+ "PreToolUse": [],
96
55
  "PostToolUse": [
97
56
  {
98
- "matcher": {},
57
+ "matcher": {
58
+ "tool_name": "^(Write|Edit)$"
59
+ },
99
60
  "hooks": [
100
61
  {
101
62
  "type": "command",
102
63
  "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/code-formatter.cjs",
103
64
  "timeout": 5000
104
- },
105
- {
106
- "type": "command",
107
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/verify-work.cjs",
108
- "timeout": 1000
109
- },
110
- {
111
- "type": "command",
112
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/thinking-silent.cjs",
113
- "timeout": 1000
114
- },
115
- {
116
- "type": "command",
117
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/multi-session.cjs",
118
- "timeout": 1000
119
- },
120
- {
121
- "type": "command",
122
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/todo-manager.cjs",
123
- "timeout": 1000
124
65
  }
125
66
  ]
126
67
  }
@@ -131,23 +72,8 @@
131
72
  "hooks": [
132
73
  {
133
74
  "type": "command",
134
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/verify-work.cjs",
135
- "timeout": 1000
136
- },
137
- {
138
- "type": "command",
139
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/thinking-silent.cjs",
140
- "timeout": 1000
141
- },
142
- {
143
- "type": "command",
144
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/multi-session.cjs",
145
- "timeout": 1000
146
- },
147
- {
148
- "type": "command",
149
- "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/todo-manager.cjs",
150
- "timeout": 1000
75
+ "command": "CLAUDE_EVENT_TYPE=AgentStop node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/hook-dispatcher.cjs",
76
+ "timeout": 3000
151
77
  }
152
78
  ]
153
79
  }
@@ -0,0 +1,297 @@
1
+ ## [1.4.0](https://github.com/sumulige/sumulige-claude/compare/v1.3.3...v1.4.0) (2026-01-23)
2
+
3
+ ### 🚀 架构优化 (Token 成本降低 62%)
4
+
5
+ #### 新增文件 (10 个)
6
+
7
+ | 文件 | 用途 |
8
+ |------|------|
9
+ | `hook-dispatcher.cjs` | 统一 Hook 调度器,支持 debounce 和条件执行 |
10
+ | `hook-registry.json` | Hook 配置注册表 |
11
+ | `hooks/lib/fs-utils.cjs` | 共享文件操作库 |
12
+ | `hooks/lib/cache.cjs` | 缓存工具类 |
13
+ | `version-manifest.json` | 版本兼容性矩阵 |
14
+ | `lib/version-manifest.js` | 版本管理库 |
15
+ | `lib/incremental-sync.js` | 增量同步实现 |
16
+ | `commands/workflow.md` | /workflow 统一命令 |
17
+
18
+ #### 精简内容
19
+
20
+ | 项目 | 之前 | 之后 | 变化 |
21
+ |------|------|------|------|
22
+ | `PreToolUse` hooks | 3 个 | 0 个 | **清空** |
23
+ | `PostToolUse` hooks | 5 个 | 1 个 | **-80%** |
24
+ | `UserPromptSubmit` hooks | 5 个 | 1 个 | **-80%** |
25
+ | `AgentStop` hooks | 4 个 | 1 个 | **-75%** |
26
+ | `settings.json` 行数 | 155 行 | 81 行 | **-48%** |
27
+
28
+ #### 性能提升
29
+
30
+ | 指标 | 优化前 | 优化后 | 提升 |
31
+ |------|--------|--------|------|
32
+ | Hook 调用次数/tool call | 12+ 次 | 2-3 次 | **-75%** |
33
+ | RAG 匹配 | O(n×m) | O(1) 缓存 | **显著** |
34
+ | PostToolUse 开销 | 每次 5 hooks | 仅 Write/Edit | **-90%+** |
35
+
36
+ ### ✨ New Features
37
+
38
+ - **`smc sync --incremental`**: 增量同步,只更新变更文件
39
+ - **`/workflow` 命令**: 统一工作流
40
+ - `/workflow check` - 检查更新状态
41
+ - `/workflow pull` - 增量同步
42
+ - `/workflow full` - 一键完整流程
43
+ - **Hook 智能调度**: debounce、runOnce、条件执行
44
+ - **RAG 缓存**: 5 分钟 TTL,避免重复匹配
45
+ - **版本追踪**: 自动检测 breaking changes
46
+
47
+ ### 🧪 Tests
48
+
49
+ ```
50
+ Test Suites: 15 passed, 15 total
51
+ Tests: 575 passed, 575 total
52
+ ```
53
+
54
+ ---
55
+
56
+ ## [1.3.3](https://github.com/sumulige/sumulige-claude/compare/v1.3.2...v1.3.3) (2026-01-22)
57
+
58
+ ### ✨ New Features
59
+
60
+ - **`smc sync --hooks`**: Incremental hooks update for existing projects
61
+ - Adds new lifecycle hooks without overwriting customizations
62
+ - Merges SessionStart/SessionEnd/PreCompact into existing settings.json
63
+
64
+ ### 📝 Documentation
65
+
66
+ - Add Layer 7: Lifecycle Hooks section to README
67
+ - Document update methods for other projects
68
+
69
+ ---
70
+
71
+ ## [1.3.2](https://github.com/sumulige/sumulige-claude/compare/v1.3.1...v1.3.2) (2026-01-22)
72
+
73
+ ### ✨ New Features
74
+
75
+ - **Official Hooks Integration**: Claude Code lifecycle auto-sync
76
+ - `SessionStart` → `memory-loader.cjs`: Auto-load MEMORY.md, ANCHORS.md, restore TODO state
77
+ - `SessionEnd` → `memory-saver.cjs`: Auto-save session summary, archive session, sync TODO
78
+ - `PreCompact` → `auto-handoff.cjs`: Auto-generate handoff before context compression
79
+ - **Context Preservation**: Automatic handoff documents in `.claude/handoffs/`
80
+ - Includes active TODOs, recently modified files, recovery commands
81
+ - `LATEST.md` always points to most recent handoff
82
+
83
+ ### 🔧 Improvements
84
+
85
+ - Session state tracking via `.session-state.json`
86
+ - Automatic session archiving to `.claude/sessions/`
87
+ - Memory entries kept for 7 days with auto-cleanup
88
+
89
+ ---
90
+
91
+ ## [1.3.1](https://github.com/sumulige/sumulige-claude/compare/v1.3.0...v1.3.1) (2026-01-22)
92
+
93
+ ### ✨ New Features
94
+
95
+ - **System Prompt Optimization**: Token savings via MCP lazy-loading
96
+ - `ENABLE_TOOL_SEARCH=true` - MCP tools loaded on demand
97
+ - `DISABLE_AUTOUPDATER=1` - Reduce startup overhead
98
+ - ~50% token reduction for system prompts
99
+ - **New Commands**:
100
+ - `/handoff` - Generate context handoff documents for session continuity
101
+ - `/gha` - Analyze GitHub Actions CI failures
102
+ - `/audit` - Security audit for approved commands (cc-safe style)
103
+ - **Permission Audit**: Detect dangerous patterns in approved commands
104
+ - Critical: `rm -rf /`, disk overwrite, fork bombs
105
+ - High: `sudo`, `chmod 777`, privileged containers
106
+ - Medium: global installs, force push
107
+
108
+ ### 📝 Documentation
109
+
110
+ - Add `/handoff` command guide
111
+ - Add `/gha` CI analysis guide
112
+ - Add `/audit` security audit guide
113
+
114
+ ---
115
+
116
+ ## [1.3.0](https://github.com/sumulige/sumulige-claude/compare/v1.2.1...v1.3.0) (2026-01-22)
117
+
118
+ ### ✨ New Features
119
+
120
+ - **4 Core Skills System**: Cost-optimized skill architecture
121
+ - `quality-guard` (sonnet) - Code review + security + cleanup
122
+ - `test-master` (sonnet) - TDD + E2E + coverage
123
+ - `design-brain` (opus) - Planning + architecture
124
+ - `quick-fix` (haiku) - Fast error resolution
125
+ - **Model Strategy**: Automatic model selection based on task complexity
126
+ - **Workflow Engine**: 4-phase project workflow (research → approve → plan → develop)
127
+ - **Usage Manual**: Comprehensive `.claude/USAGE.md` documentation
128
+
129
+ ### 🐛 Bug Fixes
130
+
131
+ - make git hooks executable (e748915a)
132
+ - fix pre-push hook for deleted files detection (46cccc6)
133
+
134
+ ### 📝 Documentation
135
+
136
+ - add `.claude/USAGE.md` with complete skills guide
137
+ - add Layer 5.5 Core Skills section to README
138
+ - update CHANGELOG with test coverage improvements
139
+
140
+ ### ♻️ Refactor
141
+
142
+ - **BREAKING**: merge 9 skills into 4 core skills (60-70% cost reduction)
143
+ - delete 6 placeholder skills
144
+ - streamline commands from 17 to 12
145
+
146
+ ### 🧪 Tests
147
+
148
+ - improve test coverage to 63.53%
149
+ - all 575 tests passing
150
+
151
+ ### 🧹 Chores
152
+
153
+ - add workflows, templates, and development infrastructure
154
+ - add hook templates for customization
155
+
156
+ ## [1.2.1](https://github.com/sumulige/sumulige-claude/compare/v1.1.2...v1.2.1) (2026-01-18)
157
+
158
+
159
+ ### Fixed
160
+
161
+ * make git hooks executable ([e748915](https://github.com/sumulige/sumulige-claude/commits/e748915a2675664885c69d649133d7f8cc354f89))
162
+
163
+
164
+ * add comprehensive regression tests for core modules ([e3b570e](https://github.com/sumulige/sumulige-claude/commits/e3b570ed1998aefd8d75e2767e78f2d7611eb0b9))
165
+ * **release:** 1.2.0 ([03c0c30](https://github.com/sumulige/sumulige-claude/commits/03c0c3096d94293b48943a23cc69d618d940f386))
166
+ * significantly improve test coverage to 63.53% ([0b552e0](https://github.com/sumulige/sumulige-claude/commits/0b552e03a42f88587a641da0fa40cbf2f3b136d4))
167
+
168
+
169
+ ### Changed
170
+
171
+ * update CHANGELOG with test coverage improvements ([d82cd19](https://github.com/sumulige/sumulige-claude/commits/d82cd19f97318ad96e7a67509622c2a9ffdcb643))
172
+ * update README with v1.2.0 changelog entry ([aa3cbc1](https://github.com/sumulige/sumulige-claude/commits/aa3cbc1d7bb438197e1fa477fcc44646eda97fe5))
173
+
174
+ ## [1.2.0](https://github.com/sumulige/sumulige-claude/compare/v1.1.2...v1.2.0) (2026-01-17)
175
+
176
+
177
+ ### Fixed
178
+
179
+ * make git hooks executable ([e748915](https://github.com/sumulige/sumulige-claude/commits/e748915a2675664885c69d649133d7f8cc354f89))
180
+
181
+
182
+ * add comprehensive regression tests for core modules ([e3b570e](https://github.com/sumulige/sumulige-claude/commits/e3b570ed1998aefd8d75e2767e78f2d7611eb0b9))
183
+
184
+ ## [1.1.0](https://github.com/sumulige/sumulige-claude/compare/v1.0.11...v1.1.0) (2026-01-15)
185
+
186
+
187
+ ### Changed
188
+
189
+ * sync documentation with v1.0.11 ([b00c509](https://github.com/sumulige/sumulige-claude/commits/b00c50928038bf8a4a655e81712420cd3294935d))
190
+
191
+
192
+ * add standard-version for automated releases ([32522fa](https://github.com/sumulige/sumulige-claude/commits/32522fa912dd26a4540cba10532c24d4e29e6daf))
193
+
194
+
195
+ ### Added
196
+
197
+ * add test-workflow skill and enhance CLI commands ([972a676](https://github.com/sumulige/sumulige-claude/commits/972a6762411c5f863d9bfa3e360df7dc7f379aab))
198
+
199
+ ## [1.0.11] - 2026-01-15
200
+
201
+ ### Added
202
+ - Complete test suite with 78 tests across 5 modules
203
+ - Version-aware migration system (`lib/migrations.js`)
204
+ - `smc migrate` command for manual migration
205
+ - Auto-migration of old hooks format on `smc sync`
206
+ - Code simplifier integration
207
+
208
+ ### Changed
209
+ - Modularized codebase for better maintainability
210
+
211
+ ### Fixed
212
+ - Test coverage improvements
213
+
214
+ ## [1.0.10] - 2026-01-15
215
+
216
+ ### Added
217
+ - Conversation logger Hook (`conversation-logger.cjs`)
218
+ - Automatic conversation recording to `DAILY_CONVERSATION.md`
219
+ - Date-grouped conversation history
220
+
221
+ ### Fixed
222
+ - Auto-migration for old hooks format
223
+
224
+ ## [1.0.9] - 2026-01-15
225
+
226
+ ### Fixed
227
+ - Clean up stale session entries
228
+
229
+ ## [1.0.8] - 2026-01-14
230
+
231
+ ### Added
232
+ - Skill Marketplace system with external repository support
233
+ - Auto-sync mechanism via GitHub Actions (daily schedule)
234
+ - 6 new marketplace commands: `list`, `install`, `sync`, `add`, `remove`, `status`
235
+ - Claude Code native plugin registry (`.claude-plugin/marketplace.json`)
236
+ - Skill categorization system (7 categories)
237
+ - Development documentation (`docs/DEVELOPMENT.md`)
238
+ - Marketplace user guide (`docs/MARKETPLACE.md`)
239
+
240
+ ### Changed
241
+ - Refactored CLI into modular architecture (`lib/` directory)
242
+ - Streamlined README with dedicated documentation files
243
+
244
+ ## [1.0.7] - 2026-01-13
245
+
246
+ ### Changed
247
+ - Project template updates
248
+
249
+ ## [1.0.6] - 2026-01-14
250
+
251
+ ### Added
252
+ - Comprehensive Claude official skills integration via `smc-skills` repository
253
+ - 16 production-ready skills for enhanced AI capabilities:
254
+ - **algorithmic-art**: p5.js generative art with seeded randomness
255
+ - **brand-guidelines**: Anthropic brand colors and typography
256
+ - **canvas-design**: Visual art creation for posters and designs
257
+ - **doc-coauthoring**: Structured documentation workflow
258
+ - **docx**: Word document manipulation (tracked changes, comments)
259
+ - **internal-comms**: Company communication templates
260
+ - **manus-kickoff**: Project kickoff templates
261
+ - **mcp-builder**: MCP server construction guide
262
+ - **pdf**: PDF manipulation (forms, merge, split)
263
+ - **pptx**: PowerPoint presentation tools
264
+ - **skill-creator**: Skill creation guide
265
+ - **slack-gif-creator**: Animated GIFs for Slack
266
+ - **template**: Skill template
267
+ - **theme-factory**: 10 pre-set themes for artifacts
268
+ - **web-artifacts-builder**: React/Tailwind artifact builder
269
+ - **webapp-testing**: Playwright browser testing
270
+ - **xlsx**: Spreadsheet operations
271
+
272
+ ### Changed
273
+ - Updated hooks compatibility with latest Claude Code format
274
+ - Improved documentation with PROJECT_STRUCTURE.md and Q&A.md
275
+
276
+ ### Fixed
277
+ - Hook format compatibility issues
278
+
279
+ ## [1.0.5] - 2025-01-13
280
+
281
+ ### Fixed
282
+ - Update hooks to new Claude Code format
283
+
284
+ ## [1.0.4] - 2025-01-12
285
+
286
+ ### Added
287
+ - Comprehensive smc usage guide in README
288
+
289
+ ## [1.0.3] - 2025-01-11
290
+
291
+ ### Fixed
292
+ - Template command now copies all files including commands, skills, templates
293
+
294
+ ## [1.0.2] - 2025-01-11
295
+
296
+ ### Added
297
+ - Initial stable release