ecc_infisense 0.0.1 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecc_infisense",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Claude Code plugin for C/C++ development — component management, release workflow, and coding conventions",
5
5
  "author": "ECC InfiSense Contributors",
6
6
  "languages": [
package/README.md CHANGED
@@ -13,9 +13,9 @@ C++ 编码规范。
13
13
  | 能力 | 原生 Claude Code | 搭配 ECC InfiSense |
14
14
  |------|-------------------|------------------------|
15
15
  | 构建系统感知 | 通用文件编辑 | 自动检测 CMake/Make/Meson/Bazel,了解构建命令 |
16
- | 规则 | 通用建议 | 4 条规则覆盖智能体委派、开发工作流、Git 规范、钩子开发 |
16
+ | 规则 | 通用建议 | 13 条规则覆盖智能体委派、开发工作流、Git 规范、钩子开发、组件编写、文档同步、C/C++ 编码风格/内存安全/错误处理/现代特性 |
17
17
  | 会话连续性 | 无持久化 | 会话钩子在压缩 (Compaction) 和重启时自动保存/恢复上下文 |
18
- | 组件管理 | 无 | `/component-creator` 创建、分析、重命名插件组件 |
18
+ | 组件管理 | 无 | `/component` 创建、分析、重命名插件组件 |
19
19
  | 版本发布 | 手动操作 | `/release` 自动检测变更、提交、发布到 npm |
20
20
 
21
21
  ## 功能概览
@@ -23,10 +23,10 @@ C++ 编码规范。
23
23
  | 组件 | 数量 | 说明 |
24
24
  |------|------|------|
25
25
  | 智能体 (Agent) | 3 | 组件设计、插件索引和发布管理的专用子智能体 |
26
- | 技能 (Skill) | 2 | 组件模板和发布工作流的知识库 |
27
- | 命令 (Command) | 3 | 组件创建、帮助索引和版本发布的斜杠命令 |
28
- | 钩子匹配器 (Hook Matcher) | 4 | 覆盖 PreToolUse、PreCompact、SessionStart 和 SessionEnd 事件 |
29
- | 规则 (Rule) | 4 | 位于 `common/` 目录下的常驻准则 |
26
+ | 技能 (Skill) | 4 | 组件模板、发布工作流、C 规范、C++ 规范的知识库 |
27
+ | 命令 (Command) | 4 | 组件管理、插件概览、版本发布和质量评分的斜杠命令 |
28
+ | 钩子匹配器 (Hook Matcher) | 6 | 覆盖 PreToolUse、PostToolUse(x2)、PreCompact、SessionStart 和 SessionEnd 事件 |
29
+ | 规则 (Rule) | 13 | 位于 `common/`(6)、`c/`(3)、`cpp/`(4) 目录下的常驻准则 |
30
30
  | 指南 (Guide) | 1 | ECC InfiSense 使用指南 |
31
31
 
32
32
  ## 安装
@@ -56,8 +56,8 @@ cd ecc-infisense
56
56
 
57
57
  | 组件 | 安装路径 | 数量 |
58
58
  |------|---------|------|
59
- | 规则 (Rules) | `~/.claude/rules/common/` | 4 |
60
- | 命令 (Commands) | `~/.claude/commands/` | 3 |
59
+ | 规则 (Rules) | `~/.claude/rules/common/` | 6 |
60
+ | 命令 (Commands) | `~/.claude/commands/` | 4 |
61
61
  | 智能体 (Agents) | `~/.claude/agents/` | 3 |
62
62
  | 技能 (Skills) | `~/.claude/skills/` | 2 |
63
63
  | 钩子 (Hooks) | `~/.claude/settings.json` (合并) | 4 |
@@ -67,7 +67,7 @@ cd ecc-infisense
67
67
  安装完成后,在 Claude Code 会话中运行:
68
68
 
69
69
  ```
70
- > /infi-ecc-helper
70
+ > /infi-overview
71
71
  ```
72
72
 
73
73
  如果插件已激活,将显示所有已安装组件的分类索引。
@@ -92,10 +92,10 @@ cd /path/to/your/cpp/project
92
92
  claude
93
93
 
94
94
  # 查看所有可用命令
95
- > /infi-ecc-helper
95
+ > /infi-overview
96
96
 
97
97
  # 创建新组件
98
- > /infi-component-creator create
98
+ > /infi-component create
99
99
 
100
100
  # 提交变更
101
101
  > /infi-release git-update
@@ -103,10 +103,10 @@ claude
103
103
 
104
104
  ## 使用示例
105
105
 
106
- ### /infi-ecc-helper -- 查看插件概览
106
+ ### /infi-overview -- 查看插件概览
107
107
 
108
108
  ```
109
- > /infi-ecc-helper
109
+ > /infi-overview
110
110
 
111
111
  动态扫描插件目录,生成分类索引:
112
112
  - 按 category (plugin/cpp) 分组
@@ -114,10 +114,10 @@ claude
114
114
  - 包含快速上手工作流
115
115
  ```
116
116
 
117
- ### /infi-component-creator -- 组件管理
117
+ ### /infi-component -- 组件管理
118
118
 
119
119
  ```
120
- > /infi-component-creator
120
+ > /infi-component
121
121
 
122
122
  三种模式:
123
123
  1. create — 从功能描述生成命令/智能体/技能
@@ -136,22 +136,36 @@ claude
136
136
  3. status — 查看当前版本和未发布变更
137
137
  ```
138
138
 
139
+ ### /infi-quality -- 质量评分
140
+
141
+ ```
142
+ > /infi-quality
143
+
144
+ 四种模式:
145
+ 1. score — 评分单个组件或全部组件(0-100 多维度)
146
+ 2. compare — 对比两个组件的重叠度
147
+ 3. report — 全量评分报告(含汇总和改进建议)
148
+ 4. optimize — 评分后自动修改文件,修复弱项维度
149
+ ```
150
+
139
151
  ## 架构
140
152
 
141
153
  ```
142
154
  ecc-infisense/
143
155
  agents/ # 3 个专用插件子智能体
144
- commands/ # 3 个斜杠命令
156
+ commands/ # 4 个斜杠命令
145
157
  docs/ # 指南文档
146
158
  GUIDE.md # ECC InfiSense 使用指南
147
159
  hooks/ # 事件驱动的自动化
148
160
  rules/ # 常驻准则
149
- common/ # 通用规则(4 个文件)
161
+ common/ # 通用规则(6 个文件)
162
+ c/ # C 语言规则
163
+ cpp/ # C++ 语言规则
150
164
  scripts/ # Node.js 工具脚本
151
165
  ci/ # CI 验证脚本
152
166
  hooks/ # 钩子运行器实现
153
167
  lib/ # 共享库代码
154
- skills/ # 2 个工作流技能
168
+ skills/ # 4 个工作流技能
155
169
  tests/ # 测试套件
156
170
  .claude-plugin/ # 插件元数据
157
171
  plugin.json
@@ -189,14 +203,17 @@ category: plugin
189
203
  |------|------|
190
204
  | `component-templates` | ECC InfiSense 组件创建模板与规范(agent、skill、command、rule) |
191
205
  | `release-workflow` | 发布管理约定:提交规范、变更日志格式、版本管理和安全检查 |
206
+ | `c-conventions` | C 语言编码规范知识库:命名模式、格式示例、内存安全惯用法、错误处理模式 |
207
+ | `cpp-conventions` | C++ 编码规范知识库:命名模式、RAII 惯用法、错误处理模式、现代 C++ 用法 |
192
208
 
193
209
  ## 命令 (Command)
194
210
 
195
211
  | 命令 | 说明 |
196
212
  |------|------|
197
- | `/component-creator` | 创建新组件,分析已有组件的重叠、缺口,或重命名组件 |
198
- | `/ecc-helper` | 查看 ECC InfiSense 插件概览:所有命令、智能体和技能分类索引 |
213
+ | `/component` | 创建新组件,分析已有组件的重叠、缺口,或重命名组件 |
214
+ | `/overview` | 查看 ECC InfiSense 插件概览:所有命令、智能体和技能分类索引 |
199
215
  | `/release` | Git 提交 + npm 发布 + 版本管理 |
216
+ | `/quality` | 组件质量评分、对比、报告和自动优化 |
200
217
 
201
218
  ## 钩子系统
202
219
 
@@ -205,6 +222,8 @@ category: plugin
205
222
  | 事件 | 匹配器 | 钩子脚本 | 用途 |
206
223
  |------|--------|----------|------|
207
224
  | `PreToolUse` | `Edit\|Write` | `suggest-compact.js` | 上下文过大时建议压缩 |
225
+ | `PostToolUse` | `Edit\|Write` | `doc-sync-reminder.js` | 组件文件修改后提醒同步文档 |
226
+ | `PostToolUse` | `Edit\|Write` | `component-check.js` | 组件文件创建或修改后提醒运行 spec 分析 |
208
227
  | `PreCompact` | `*` | `pre-compact.js` | 压缩前保存上下文 |
209
228
  | `SessionStart` | `*` | `session-start.js` | 恢复上一次会话上下文 |
210
229
  | `SessionEnd` | `*` | `session-end.js` | 保存会话状态 |
@@ -242,14 +261,23 @@ category: plugin
242
261
 
243
262
  规则是 Claude Code 在每次交互中始终遵循的准则。
244
263
 
245
- ### 规则(4 条)
264
+ ### 规则(13 条)
246
265
 
247
266
  | 规则 | 说明 |
248
267
  |------|------|
249
- | `agents` | 智能体委派和职责边界 |
268
+ | `agent-delegation` | 智能体委派和职责边界 |
250
269
  | `development-workflow` | 工作流规则 |
251
270
  | `git-workflow` | 分支策略和提交规范 |
252
- | `hooks` | 钩子执行和安全防护 |
271
+ | `hook-authoring` | 钩子执行和安全防护 |
272
+ | `component-authoring` | 组件编写约束和模板引用规范 |
273
+ | `doc-sync` | 组件变更时强制同步文档的准则 |
274
+ | `c/coding-style` | C 语言编码风格(Google C Style) |
275
+ | `c/memory-safety` | C 语言内存安全约束 |
276
+ | `c/error-handling` | C 语言错误处理约束 |
277
+ | `cpp/coding-style` | C++ 编码风格(Google C++ Style) |
278
+ | `cpp/memory-safety` | C++ 内存安全与 RAII 约束 |
279
+ | `cpp/error-handling` | C++ 错误处理约束(禁止异常) |
280
+ | `cpp/modern-cpp` | C++17/20 现代特性使用约束 |
253
281
 
254
282
  ## 文档
255
283
 
@@ -265,11 +293,11 @@ category: plugin
265
293
 
266
294
  ### 问:如何添加自定义规则?
267
295
 
268
- 在 `rules/common/` 中创建一个 Markdown 文件。参照现有规则的格式。
296
+ 在 `rules/{common,c,cpp}/` 中创建一个 Markdown 文件。参照现有规则的格式。
269
297
 
270
298
  ### 问:如何创建新的插件组件?
271
299
 
272
- 使用 `/infi-component-creator create` 命令,提供功能描述,插件会自动决定需要
300
+ 使用 `/infi-component create` 命令,提供功能描述,插件会自动决定需要
273
301
  哪些组件类型(命令/智能体/技能/规则)并生成文件。
274
302
 
275
303
  ## 开发
@@ -289,6 +317,28 @@ npm test
289
317
  5. `scripts/ci/validate-hooks.js` -- 验证钩子配置
290
318
  6. `tests/run-all.js` -- 运行功能测试
291
319
 
320
+ ### 组件质量评分
321
+
322
+ 除结构合规性验证外,还可对组件内容质量进行多维度评分(0-100):
323
+
324
+ ```bash
325
+ # 评分全部组件
326
+ node scripts/ci/score-components.js --all
327
+
328
+ # 评分单个文件
329
+ node scripts/ci/score-components.js rules/c/coding-style.md
330
+
331
+ # 对比两个组件的重叠度
332
+ node scripts/ci/score-components.js --overlap rules/c/coding-style.md rules/cpp/coding-style.md
333
+
334
+ # 输出 JSON 用于前后对比
335
+ node scripts/ci/score-components.js rules/c/coding-style.md --json > before.json
336
+ ```
337
+
338
+ **Rule 评分维度:** sizing (行数)、density (约束密度)、uniqueness (唯一性)、tone (命令式语气)、structure (结构完整性)
339
+
340
+ **Skill 评分维度:** sizing (行数)、coverage (规则覆盖率)、examples (正反例)、compilable (代码可编译)、sections (必要章节)
341
+
292
342
  ## 贡献
293
343
 
294
344
  详细指南请参阅 [CONTRIBUTING.md](CONTRIBUTING.md)。
@@ -81,8 +81,8 @@ For skills, group by domain (quality pipeline, testing, build, design, security,
81
81
  ### Quick Start Section
82
82
 
83
83
  Always include a quick-start section with the most common workflows:
84
- - 查看概览: `/infi-ecc-helper`
85
- - 创建组件: `/infi-component-creator create`
84
+ - 查看概览: `/infi-overview`
85
+ - 创建组件: `/infi-component create`
86
86
  - 提交变更: `/infi-release git-update`
87
87
  - 发布版本: `/infi-release publish minor`
88
88
 
@@ -142,8 +142,8 @@ ECC InfiSense — Claude Code C/C++ 开发工具套件
142
142
 
143
143
  ━━━ 快速上手 ━━━
144
144
 
145
- 查看概览: /infi-ecc-helper
146
- 创建组件: /infi-component-creator create
145
+ 查看概览: /infi-overview
146
+ 创建组件: /infi-component create
147
147
  提交变更: /infi-release git-update
148
148
  发布版本: /infi-release publish minor
149
149
 
@@ -3,14 +3,14 @@ description: Create new components or analyze existing ones for overlap, gaps, a
3
3
  category: plugin
4
4
  ---
5
5
 
6
- # Component Creator
6
+ # Component Management
7
7
 
8
8
  Create new ECC InfiSense components from a feature description, analyze existing components
9
9
  for orphans, overlaps, and spec violations, or rename components for clarity.
10
10
 
11
11
  ## Usage
12
12
 
13
- `/infi-component-creator [create|analyze|rename] [description]`
13
+ `/infi-component [create|analyze|rename] [description]`
14
14
 
15
15
  If mode is omitted, present an interactive menu using AskUserQuestion:
16
16
 
@@ -3,14 +3,14 @@ description: Show ECC InfiSense plugin overview — available commands, agents,
3
3
  category: plugin
4
4
  ---
5
5
 
6
- # ECC InfiSense Helper
6
+ # Plugin Overview
7
7
 
8
8
  Display a categorized index of all available ECC InfiSense components by dynamically
9
9
  scanning plugin directories. The index is always up-to-date with the actual filesystem.
10
10
 
11
11
  ## Usage
12
12
 
13
- `/infi-ecc-helper`
13
+ `/infi-overview`
14
14
 
15
15
  No arguments. Produces a formatted overview of all installed components.
16
16
 
@@ -40,5 +40,5 @@ Output the generated index directly to the user. The index includes:
40
40
 
41
41
  - Agent: `plugin-inspector` — dynamic directory scanning and index generation
42
42
  - Skill: `component-templates` — component type definitions and conventions
43
- - Related: `/infi-component-creator` — create new components
43
+ - Related: `/infi-component` — create new components
44
44
  - Related: `/infi-release` — version management and publishing
@@ -0,0 +1,166 @@
1
+ ---
2
+ description: Score, compare, report, and optimize component quality.
3
+ category: plugin
4
+ ---
5
+
6
+ # Quality Scoring & Optimization
7
+
8
+ Evaluate and improve ECC InfiSense component quality through multi-dimensional
9
+ scoring. Runs `scripts/ci/score-components.js` for scoring, then optionally
10
+ edits files to fix weak dimensions.
11
+
12
+ ## Usage
13
+
14
+ `/infi-quality [score|compare|report|optimize] [args]`
15
+
16
+ If mode is omitted, present an interactive menu using AskUserQuestion:
17
+
18
+ ```
19
+ Which quality workflow do you want to run?
20
+
21
+ 1. score — Score a single component or all components
22
+ 2. compare — Compare overlap between two components
23
+ 3. report — Full scoring report with summary and improvement suggestions
24
+ 4. optimize — Score then auto-fix weak dimensions in component files
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 1. score
30
+
31
+ Score one or all components on a 0-100 scale across multiple dimensions.
32
+
33
+ **Single file:**
34
+
35
+ ```
36
+ /infi-quality score rules/c/coding-style.md
37
+ ```
38
+
39
+ Run: `node scripts/ci/score-components.js <file>`
40
+
41
+ **All components:**
42
+
43
+ ```
44
+ /infi-quality score --all
45
+ ```
46
+
47
+ Run: `node scripts/ci/score-components.js --all`
48
+
49
+ Display the per-dimension breakdown and overall score. Highlight any dimension
50
+ below 60% of its max as needing improvement.
51
+
52
+ ---
53
+
54
+ ## 2. compare
55
+
56
+ Compare overlap between two components to decide whether to merge or keep both.
57
+
58
+ ```
59
+ /infi-quality compare rules/c/coding-style.md rules/cpp/coding-style.md
60
+ ```
61
+
62
+ Run: `node scripts/ci/score-components.js --overlap <fileA> <fileB>`
63
+
64
+ Display the overlap percentage, shared content areas, and a recommendation
65
+ (merge / keep separate / refactor shared content into a skill).
66
+
67
+ ---
68
+
69
+ ## 3. report
70
+
71
+ Full scoring report across all components with actionable improvement suggestions.
72
+
73
+ ```
74
+ /infi-quality report
75
+ ```
76
+
77
+ Run: `node scripts/ci/score-components.js --all --json`
78
+
79
+ Parse the JSON output and generate:
80
+
81
+ 1. **Summary table** — component name, overall score, lowest dimension
82
+ 2. **Top improvements** — list the 5 lowest-scoring dimensions across all
83
+ components with specific suggestions
84
+ 3. **Comparison with previous run** — if user provides a previous JSON file,
85
+ show score deltas
86
+
87
+ ---
88
+
89
+ ## 4. optimize
90
+
91
+ Score a component, then automatically edit it to improve weak dimensions.
92
+
93
+ **Single file:**
94
+
95
+ ```
96
+ /infi-quality optimize rules/c/coding-style.md
97
+ ```
98
+
99
+ **All components below threshold:**
100
+
101
+ ```
102
+ /infi-quality optimize --all
103
+ /infi-quality optimize --all --threshold 80
104
+ ```
105
+
106
+ Default threshold is 70. Only components scoring below the threshold are optimized.
107
+
108
+ ### Workflow
109
+
110
+ 1. **Score** — run `node scripts/ci/score-components.js <file>` (or `--all --json`)
111
+ 2. **Identify weak dimensions** — any dimension below 60% of its max weight
112
+ 3. **Plan fixes** — show the user which dimensions will be improved and what
113
+ changes are planned. Wait for confirmation before editing.
114
+ 4. **Edit** — apply targeted fixes to the file using the Edit tool
115
+ 5. **Re-score** — run scoring again to verify improvement
116
+ 6. **Report delta** — show before/after comparison for each dimension
117
+
118
+ ### Optimization Actions by Dimension
119
+
120
+ #### Rule dimensions
121
+
122
+ | Dimension | Trigger | Action |
123
+ |-----------|---------|--------|
124
+ | sizing | < 30 or > 50 lines | Trim redundant lines or split overly terse points into clearer items |
125
+ | density | constraint ratio < 0.3 | Convert explanatory prose into constraint bullet points or table rows; remove filler sentences |
126
+ | uniqueness | duplicate constraints found | Remove constraints that are identical to another rule; rephrase near-duplicates to differentiate |
127
+ | tone | < 50% imperative | Rewrite soft phrasing to imperative: "should" → "必须", "avoid" → "禁止", "prefer" → "优先" |
128
+ | structure | missing elements | Add frontmatter if absent; add cross-reference to corresponding skill; convert lists to tables where appropriate |
129
+
130
+ #### Skill dimensions
131
+
132
+ | Dimension | Trigger | Action |
133
+ |-----------|---------|--------|
134
+ | sizing | < 100 or > 600 lines | Expand thin sections with more examples, or extract verbose sections into sub-files |
135
+ | coverage | rule keywords missing | Add code examples or explanation paragraphs covering the missing rule keywords |
136
+ | examples | Good without Bad | Add a `// Bad` counterpart next to every `// Good` example that lacks one |
137
+ | compilable | syntax errors in code blocks | Fix compilation errors in code blocks (missing includes, typos, invalid syntax) |
138
+ | sections | missing required sections | Add `## Quick Reference`, `## When to Use`, or `## When NOT to Use` sections with appropriate content |
139
+ | token-efficiency | tokens > 3000 | Compress code blocks (merge duplicate includes, combine Good/Bad pairs), trim redundant explanatory text |
140
+
141
+ ### Safety
142
+
143
+ - Never remove content without showing the user what will be deleted
144
+ - Always show a before/after diff summary before confirming
145
+ - If the user declines a specific optimization, skip it and proceed to the next
146
+ - Run `npm test` after all edits to ensure nothing is broken
147
+
148
+ ---
149
+
150
+ ## Scoring Dimensions
151
+
152
+ **Rule components:** sizing (line count), density (constraint density),
153
+ uniqueness, tone (imperative voice), structure (completeness)
154
+
155
+ **Skill components:** sizing (line count), coverage (rule coverage),
156
+ examples (positive/negative), compilable (code compiles), sections (required
157
+ sections), token-efficiency (token cost within limit)
158
+
159
+ ---
160
+
161
+ ## Cross-References
162
+
163
+ - Script: `scripts/ci/score-components.js` — CLI entry point
164
+ - Library: `scripts/lib/quality-scorer.js` — scoring engine
165
+ - Related: `/infi-component analyze` — structural health check (quality does content scoring)
166
+ - Related: `/infi-overview` — view current plugin overview
@@ -79,5 +79,5 @@ Delegate to `release-executor` agent to display:
79
79
 
80
80
  - Agent: `release-executor` — executes all three release workflows
81
81
  - Skill: `release-workflow` — commit conventions, path-scope mapping, changelog format
82
- - Related: `/infi-component-creator` — create components before releasing
83
- - Related: `/infi-ecc-helper` — view current plugin overview
82
+ - Related: `/infi-component` — create components before releasing
83
+ - Related: `/infi-overview` — view current plugin overview
package/hooks/hooks.json CHANGED
@@ -13,6 +13,28 @@
13
13
  "description": "Suggest manual compaction at logical intervals"
14
14
  }
15
15
  ],
16
+ "PostToolUse": [
17
+ {
18
+ "matcher": "Edit|Write",
19
+ "hooks": [
20
+ {
21
+ "type": "command",
22
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/hooks/doc-sync-reminder.js\""
23
+ }
24
+ ],
25
+ "description": "Remind to sync CLAUDE.md, README.md, docs/GUIDE.md when component files are modified"
26
+ },
27
+ {
28
+ "matcher": "Edit|Write",
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/hooks/component-check.js\""
33
+ }
34
+ ],
35
+ "description": "Remind to run /infi-component analyze when component files are created or modified"
36
+ }
37
+ ],
16
38
  "PreCompact": [
17
39
  {
18
40
  "matcher": "*",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecc_infisense",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Claude Code plugin for C/C++ development — agents, skills, hooks, commands, and rules for component management, release workflow, and C++ coding conventions",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -0,0 +1,48 @@
1
+ ---
2
+ paths: "*.c,*.h"
3
+ ---
4
+
5
+ # C Coding Style
6
+
7
+ For detailed patterns and examples, consult `c-conventions` skill.
8
+
9
+ 基于 Google C Style,适用于所有 C 源文件。
10
+
11
+ ## Naming
12
+
13
+ | 元素 | 风格 |
14
+ |------|------|
15
+ | 函数 | snake_case |
16
+ | 变量(局部) | snake_case |
17
+ | 全局变量 | g_ 前缀 + snake_case |
18
+ | 静态变量 | s_ 前缀 + snake_case |
19
+ | 宏 / 常量 | UPPER_SNAKE_CASE |
20
+ | 类型(struct/enum/typedef) | snake_case_t 后缀 |
21
+ | 结构体成员 | snake_case,无前缀 |
22
+
23
+ ## Formatting
24
+
25
+ | 项目 | 规则 |
26
+ |------|------|
27
+ | 缩进 | 2 空格,禁止 Tab |
28
+ | 大括号 | K&R 风格,左大括号同行 |
29
+ | 行宽 | 最大 80 列 |
30
+ | 指针星号 | 靠变量,禁止靠类型 |
31
+ | 函数之间 | 1 个空行 |
32
+ | 运算符两侧 | 必须加空格 |
33
+
34
+ ## Headers
35
+
36
+ | 项目 | 规则 |
37
+ |------|------|
38
+ | include guard | ifndef 宏(PROJECT_PATH_FILE_H_ 格式),禁止 pragma once |
39
+ | 后缀 | .h |
40
+ | include 顺序 | 自身头文件 → 项目头文件 → 第三方 → 系统头文件 |
41
+ | 每组之间 | 空 1 行 |
42
+
43
+ ## General
44
+
45
+ - 每个函数不超过 40 行(不含空行和注释),超过必须拆分
46
+ - 函数参数不超过 5 个,超过用结构体封装
47
+ - 禁止 goto
48
+ - 输出参数必须用指针
@@ -0,0 +1,33 @@
1
+ ---
2
+ paths: "*.c,*.h"
3
+ ---
4
+
5
+ # C Error Handling
6
+
7
+ For detailed patterns and examples, consult `c-conventions` skill.
8
+
9
+ C 语言错误处理约束,基于 Google C Style。
10
+
11
+ ## Return Codes
12
+
13
+ | 约束 | 规则 |
14
+ |------|------|
15
+ | 错误类型 | 优先使用 enum 定义错误码,禁止裸整数 |
16
+ | 成功值 | 成功返回 0 或正值,错误返回负值或特定错误枚举 |
17
+ | 调用方检查 | 调用返回错误码的函数后必须检查返回值 |
18
+ | errno | 仅在调用标准库函数后检查 errno,禁止自定义函数使用 errno |
19
+
20
+ ## Error Propagation
21
+
22
+ | 约束 | 规则 |
23
+ |------|------|
24
+ | 向上传递 | 内部函数错误必须向上传递,禁止静默吞掉 |
25
+ | 清理路径 | 函数内多个资源获取时,错误后必须按逆序清理已获取资源 |
26
+ | 日志记录 | 错误最终处理点必须记录日志,中间传递层不重复记录 |
27
+
28
+ ## Prohibited
29
+
30
+ - 禁止忽略函数返回值(除显式标注为无需检查的函数)
31
+ - 禁止使用 setjmp/longjmp 做错误处理
32
+ - 禁止用 assert 处理运行时可能发生的错误,assert 仅用于不变量
33
+ - 禁止在错误路径上泄漏资源
@@ -0,0 +1,34 @@
1
+ ---
2
+ paths: "*.c,*.h"
3
+ ---
4
+
5
+ # C Memory Safety
6
+
7
+ For detailed patterns and examples, consult `c-conventions` skill.
8
+
9
+ C 语言内存安全约束,基于 Google C Style 和 CERT C。
10
+
11
+ ## Allocation
12
+
13
+ | 约束 | 规则 |
14
+ |------|------|
15
+ | 返回值检查 | malloc/calloc/realloc 返回值必须检查 NULL |
16
+ | 配对释放 | 每个 malloc 必须有且仅有一个对应的 free |
17
+ | 释放后置空 | free 后必须将指针置为 NULL |
18
+ | realloc 安全 | 必须用临时变量接收 realloc 返回值,失败时保留原指针 |
19
+
20
+ ## Ownership
21
+
22
+ | 约束 | 规则 |
23
+ |------|------|
24
+ | 单一所有者 | 每块动态内存有且仅有一个所有者负责释放 |
25
+ | 文档化 | 函数返回动态内存时必须在注释中说明调用方需释放 |
26
+ | 数组边界 | 数组访问前必须检查索引范围 |
27
+ | 缓冲区长度 | 字符串操作必须使用带长度参数的版本(strncpy 而非 strcpy) |
28
+
29
+ ## Prohibited
30
+
31
+ - 禁止使用已释放的指针(use-after-free)
32
+ - 禁止返回局部变量的指针
33
+ - 禁止对栈上对象调用 free
34
+ - 禁止在头文件中定义全局可变状态
@@ -0,0 +1,35 @@
1
+ # Agent Delegation Guide
2
+
3
+ For component templates and naming conventions, consult `component-templates` skill.
4
+
5
+ ## When to Delegate
6
+
7
+ | 场景 | 规则 |
8
+ |------|------|
9
+ | 多文件操作、组件设计、插件分析、发布管理 | 必须委派给对应智能体 |
10
+ | 单文件编辑、上下文充分的简单任务 | 禁止委派,直接执行 |
11
+
12
+ ## Agent Selection
13
+
14
+ | Agent | 职责 | 使用条件 |
15
+ |-------|------|----------|
16
+ | `@component-designer` | 设计、分析、重命名组件 | 必须用于 create/analyze/rename 操作 |
17
+ | `@plugin-inspector` | 扫描目录,生成分类索引 | 必须用于 `/infi-overview` |
18
+ | `@release-executor` | Git 提交、npm 发布、版本状态 | 必须用于 `/infi-release` |
19
+
20
+ ## Coordination Patterns
21
+
22
+ | 命令 | 必须委派给 |
23
+ |------|-----------|
24
+ | `/infi-component` | `component-designer` |
25
+ | `/infi-overview` | `plugin-inspector` |
26
+ | `/infi-release` | `release-executor` |
27
+
28
+ - 顺序工作流:设计组件 → 创建 → 发布,禁止跳过中间步骤
29
+
30
+ ## Best Practices
31
+
32
+ - 必须在委派时包含文件路径、错误信息或设计约束
33
+ - 必须使用具体描述:"分析 agents/ 目录中的孤儿组件",禁止模糊描述
34
+ - 多智能体工作流中,必须在智能体之间共享结果
35
+ - 智能体输出仅作为起点,必须根据上下文进行验证和调整