@jspg-ai/coding-bb 0.0.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/README.md +41 -0
- package/cbb/dev-standards/rules/cbb-ai-behavior.md +104 -0
- package/cbb/dev-standards/rules/cbb-coding-rule.md +50 -0
- package/cbb/dev-standards/rules/cbb-priority.md +56 -0
- package/cbb/dev-standards/skills/architecture-specs/SKILL.md +129 -0
- package/cbb/dev-standards/skills/coding-specs/SKILL.md +376 -0
- package/cbb/dev-standards/skills/coding-specs/references/concurrency.md +53 -0
- package/cbb/dev-standards/skills/coding-specs/references/config-center.md +16 -0
- package/cbb/dev-standards/skills/coding-specs/references/distributed.md +42 -0
- package/cbb/dev-standards/skills/coding-specs/references/es-coding.md +60 -0
- package/cbb/dev-standards/skills/coding-specs/references/scheduled-task.md +25 -0
- package/cbb/dev-standards/skills/coding-specs/references/security.md +11 -0
- package/cbb/dev-standards/skills/coding-specs/references/unit-testing.md +43 -0
- package/cbb/dev-standards/skills/es-design-specs/SKILL.md +104 -0
- package/cbb/dev-standards/skills/mysql-design-specs/SKILL.md +89 -0
- package/cbb/lib/install/claude-code.js +20 -0
- package/cbb/lib/install/cleanup.js +64 -0
- package/cbb/lib/install/init.js +1875 -0
- package/cbb/lib/install/qoder.js +20 -0
- package/cbb/lib/install/workspaces.js +232 -0
- package/cbb/lib/openspec/index.js +554 -0
- package/cbb/lib/superpowers/index.js +265 -0
- package/cbb/lib/utils/check-update.js +147 -0
- package/cbb/lib/utils/checkbox.js +383 -0
- package/cbb/lib/utils/gitignore.js +69 -0
- package/cbb/lib/utils/output.js +64 -0
- package/cbb/lib/utils/settings.js +119 -0
- package/cbb/lib/utils/version.js +135 -0
- package/cbb/lib/wiki/api-client.js +358 -0
- package/cbb/lib/wiki/cli.js +427 -0
- package/cbb/lib/wiki/convert.js +464 -0
- package/cbb/lib/wiki/index.js +218 -0
- package/cbb/lib/wiki/mermaid-guard.js +103 -0
- package/cbb/lib/wiki/split.js +131 -0
- package/cbb/tools/cbb-decompile-jar/SKILL.md +220 -0
- package/cbb/tools/cbb-decompile-jar/scripts/decompile.py +863 -0
- package/cbb/tools/cbb-design-to-wiki/SKILL.md +180 -0
- package/cbb/tools/cbb-mvn-guide/SKILL.md +281 -0
- package/cbb/tools/cbb-mvn-guide/scripts/mvn_jdk_manager.py +378 -0
- package/cbb/tools/cbb-mvn-guide/scripts/mvn_pom_jdk_reader.py +197 -0
- package/cbb/tools/cbb-plantuml-authoring/SKILL.md +448 -0
- package/cbb/tools/cbb-plantuml-authoring/references/drawing-templates.md +479 -0
- package/cbb/tools/cbb-wiki-ops/SKILL.md +134 -0
- package/cbb/tools/cbb-wiki-ops/scripts/check-auth.js +44 -0
- package/cbb/worktrees/_shared/scripts/find-target-worktree.js +96 -0
- package/cbb/worktrees/_shared/scripts/find-workspace-root.js +67 -0
- package/cbb/worktrees/_shared/scripts/push-core.js +136 -0
- package/cbb/worktrees/_shared/scripts/silence-popup.js +23 -0
- package/cbb/worktrees/commands/close.md +64 -0
- package/cbb/worktrees/commands/extend.md +65 -0
- package/cbb/worktrees/commands/init.md +55 -0
- package/cbb/worktrees/commands/push.md +42 -0
- package/cbb/worktrees/skills/openspec-close-worktree/SKILL.md +449 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/check-env.js +76 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/check-unarchived.js +48 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/delete-branches.js +136 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/discover-apps.js +76 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/find-target-worktree.js +96 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/find-workspace-root.js +67 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/remove-worktrees.js +124 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/safety-check.js +174 -0
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/silence-popup.js +23 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/SKILL.md +390 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-env.js +95 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-repos.js +98 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/create-branches-and-worktrees.js +135 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/find-target-worktree.js +96 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/find-workspace-root.js +67 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/install-ai.js +150 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/list-available-apps.js +88 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/push-core.js +136 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/silence-popup.js +23 -0
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/sync-repos.js +93 -0
- package/cbb/worktrees/skills/openspec-init-worktree/SKILL.md +539 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/auto-open.js +136 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/check-env-deep.js +87 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/check-env.js +90 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/check-repos.js +171 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/create-branches.js +103 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/create-worktrees.js +154 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/find-workspace-root.js +67 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/generate-app-options.js +93 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/install-ai.js +177 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/parse-config.js +67 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/push-branches.js +101 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/push-core.js +136 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/silence-popup.js +23 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/sync-repos.js +95 -0
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/update-gitignore.js +134 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/SKILL.md +307 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/commit-worktrees.js +269 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/find-target-worktree.js +96 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/find-workspace-root.js +67 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/push-core.js +136 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/push-worktrees.js +159 -0
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/silence-popup.js +23 -0
- package/config/cbb.yaml +6 -0
- package/config/config.sample.json +16 -0
- package/config/openspec/config.yaml +28 -0
- package/config/openspec/schemas/spec-driven/schema.yaml +247 -0
- package/config/openspec/schemas/spec-driven/templates/design.md +475 -0
- package/config/openspec/schemas/spec-driven/templates/proposal.md +58 -0
- package/config/openspec/schemas/spec-driven/templates/spec.md +8 -0
- package/config/openspec/schemas/spec-driven/templates/tasks.md +9 -0
- package/config/workspaces.json +15 -0
- package/openspec/.version +6 -0
- package/openspec/commands/apply.md +182 -0
- package/openspec/commands/archive.md +223 -0
- package/openspec/commands/bulk-archive.md +334 -0
- package/openspec/commands/continue.md +112 -0
- package/openspec/commands/explore.md +206 -0
- package/openspec/commands/ff.md +111 -0
- package/openspec/commands/new.md +70 -0
- package/openspec/commands/onboard.md +555 -0
- package/openspec/commands/propose.md +157 -0
- package/openspec/commands/sync.md +256 -0
- package/openspec/commands/update.md +85 -0
- package/openspec/commands/verify.md +169 -0
- package/openspec/skills/openspec-apply-change/SKILL.md +187 -0
- package/openspec/skills/openspec-archive-change/SKILL.md +181 -0
- package/openspec/skills/openspec-bulk-archive-change/SKILL.md +338 -0
- package/openspec/skills/openspec-continue-change/SKILL.md +117 -0
- package/openspec/skills/openspec-explore/SKILL.md +342 -0
- package/openspec/skills/openspec-ff-change/SKILL.md +116 -0
- package/openspec/skills/openspec-new-change/SKILL.md +76 -0
- package/openspec/skills/openspec-onboard/SKILL.md +560 -0
- package/openspec/skills/openspec-propose/SKILL.md +162 -0
- package/openspec/skills/openspec-sync-specs/SKILL.md +261 -0
- package/openspec/skills/openspec-update-change/SKILL.md +90 -0
- package/openspec/skills/openspec-verify-change/SKILL.md +174 -0
- package/package.json +46 -0
- package/superpowers/.version +6 -0
- package/superpowers/skills/brainstorming/SKILL.md +250 -0
- package/superpowers/skills/brainstorming/scripts/frame-template.html +213 -0
- package/superpowers/skills/brainstorming/scripts/helper.js +167 -0
- package/superpowers/skills/brainstorming/scripts/server.cjs +723 -0
- package/superpowers/skills/brainstorming/scripts/start-server.sh +209 -0
- package/superpowers/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/superpowers/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/superpowers/skills/brainstorming/visual-companion.md +299 -0
- package/superpowers/skills/dispatching-parallel-agents/SKILL.md +167 -0
- package/superpowers/skills/executing-plans/SKILL.md +64 -0
- package/superpowers/skills/finishing-a-development-branch/SKILL.md +225 -0
- package/superpowers/skills/receiving-code-review/SKILL.md +205 -0
- package/superpowers/skills/requesting-code-review/SKILL.md +95 -0
- package/superpowers/skills/requesting-code-review/code-reviewer.md +181 -0
- package/superpowers/skills/subagent-driven-development/SKILL.md +568 -0
- package/superpowers/skills/subagent-driven-development/implementer-prompt.md +154 -0
- package/superpowers/skills/subagent-driven-development/re-review-prompt.md +115 -0
- package/superpowers/skills/subagent-driven-development/scripts/review-package +46 -0
- package/superpowers/skills/subagent-driven-development/scripts/sdd-workspace +40 -0
- package/superpowers/skills/subagent-driven-development/scripts/task-brief +41 -0
- package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +207 -0
- package/superpowers/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/superpowers/skills/systematic-debugging/SKILL.md +283 -0
- package/superpowers/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/superpowers/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/superpowers/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/superpowers/skills/systematic-debugging/find-polluter.sh +72 -0
- package/superpowers/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/superpowers/skills/systematic-debugging/test-academic.md +14 -0
- package/superpowers/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/superpowers/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/superpowers/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/superpowers/skills/test-driven-development/SKILL.md +320 -0
- package/superpowers/skills/test-driven-development/writing-good-tests.md +198 -0
- package/superpowers/skills/using-git-worktrees/SKILL.md +167 -0
- package/superpowers/skills/using-superpowers/SKILL.md +63 -0
- package/superpowers/skills/using-superpowers/references/antigravity-tools.md +23 -0
- package/superpowers/skills/using-superpowers/references/codex-tools.md +108 -0
- package/superpowers/skills/using-superpowers/references/gemini-tools.md +63 -0
- package/superpowers/skills/using-superpowers/references/hermes-tools.md +56 -0
- package/superpowers/skills/using-superpowers/references/pi-tools.md +16 -0
- package/superpowers/skills/verification-before-completion/SKILL.md +120 -0
- package/superpowers/skills/writing-plans/SKILL.md +171 -0
- package/superpowers/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/superpowers/skills/writing-skills/SKILL.md +679 -0
- package/superpowers/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/superpowers/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/superpowers/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/superpowers/skills/writing-skills/persuasion-principles.md +187 -0
- package/superpowers/skills/writing-skills/render-graphs.js +169 -0
- package/superpowers/skills/writing-skills/testing-skills-with-subagents.md +384 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @jspg-ai/coding-bb
|
|
2
|
+
|
|
3
|
+
整合业界热门且高价值的工具、框架与技能,为 AI CODING AGENT 提供统一的行为准则与工作流,辅助开发者将需求高效落地为符合规范的代码。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 功能特性
|
|
8
|
+
|
|
9
|
+
- **编码规范**:提供 API、模型、代码风格、错误处理、日志等核心规范
|
|
10
|
+
- **数据库规范**:MySQL 表设计、索引、SQL、事务等规范
|
|
11
|
+
- **ES 规范**:Elasticsearch 索引设计、查询优化等规范
|
|
12
|
+
- **架构规范**:分层架构、模块组织、中间件选型等规范
|
|
13
|
+
- **OpenSpec 工作流**:完整的需求→设计→实现→验证→归档工作流
|
|
14
|
+
- **Worktree 管理**:多仓库联动开发环境,支持 git worktree 隔离
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 快速安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 全局安装(公开包,无需登录)
|
|
22
|
+
npm install -g @jspg-ai/coding-bb
|
|
23
|
+
|
|
24
|
+
# 新建目录,初始化业务空间(唯一主命令,首次运行自动安装用户级组件)
|
|
25
|
+
cbb setup
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 文档导航
|
|
31
|
+
|
|
32
|
+
| 文档 | 说明 |
|
|
33
|
+
|------|------|
|
|
34
|
+
| [快速开始](docs/快速开始.md) | 安装、初始化、更新、卸载完整指南 |
|
|
35
|
+
| [CLI 参考](docs/CLI参考.md) | CLI 命令一览(人用 / Agent 用 / 自动) |
|
|
36
|
+
| [Skills 参考](docs/Skills参考.md) | 编码规范与 OpenSpec 工作流命令一览 |
|
|
37
|
+
| [开发工作流](docs/开发工作流.md) | OpenSpec 工作流完整说明 |
|
|
38
|
+
| [项目结构](docs/项目结构.md) | 源码目录结构速览(维护者) |
|
|
39
|
+
| [AGENTS.md](AGENTS.md) | 项目架构与仓库内容分层说明 |
|
|
40
|
+
| [NPM 发布指南](docs/NPM发布指南.md) | 版本发布流程(维护者) |
|
|
41
|
+
| [版本历史](docs/版本历史.md) | 版本变更记录 |
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: always_on
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# AI 行为准则
|
|
6
|
+
|
|
7
|
+
七条行为准则,减少 AI 编码常见错误。源自 [Andrej Karpathy 对 LLM 编码缺陷的观察](https://x.com/karpathy/status/2015883857489522876)。
|
|
8
|
+
|
|
9
|
+
**权衡:** 这些准则倾向于谨慎而非速度。对于简单任务(如修 typo、改文案),按常识判断即可。
|
|
10
|
+
|
|
11
|
+
## 1. 先想后写
|
|
12
|
+
|
|
13
|
+
**不假设,不隐藏困惑,主动呈现权衡。**
|
|
14
|
+
|
|
15
|
+
实现前:
|
|
16
|
+
- 明确声明假设,不确定时主动询问
|
|
17
|
+
- 若存在多种解释,呈现出来而非自己默默选一种
|
|
18
|
+
- 若有更简单的方案,说出来,必要时 push back
|
|
19
|
+
- 若有不明确的地方,停下来,说出困惑,请求澄清
|
|
20
|
+
|
|
21
|
+
## 2. 简洁至上
|
|
22
|
+
|
|
23
|
+
**用最少代码解决问题,不加推测性内容。**
|
|
24
|
+
|
|
25
|
+
- 不实现用户未要求的功能
|
|
26
|
+
- 不为单次使用的代码创建抽象
|
|
27
|
+
- 不添加用户未要求的"灵活性"或"可配置性"
|
|
28
|
+
- 不为不可能发生的场景写错误处理
|
|
29
|
+
- 写了 200 行却发现 50 行就能搞定 → 重写
|
|
30
|
+
|
|
31
|
+
自问:"资深工程师会说过度设计吗?"如果会,简化。
|
|
32
|
+
|
|
33
|
+
## 3. 外科手术式修改
|
|
34
|
+
|
|
35
|
+
**只改必须改的,只清理自己造成的烂摊子。**
|
|
36
|
+
|
|
37
|
+
编辑已有代码时:
|
|
38
|
+
- 不顺手"改进"相邻代码、注释或格式
|
|
39
|
+
- 不重构没坏的东西
|
|
40
|
+
- 匹配现有风格,即使你更习惯另一种写法
|
|
41
|
+
- 发现无关的死代码,口头提及即可,不要删除
|
|
42
|
+
|
|
43
|
+
当你的改动产生孤儿代码时:
|
|
44
|
+
- 删除因你的改动而不再使用的 import / 变量 / 函数
|
|
45
|
+
- 不删除已有的死代码,除非用户要求
|
|
46
|
+
|
|
47
|
+
**检验标准:** 每一行改动都应该能追溯到用户的需求。
|
|
48
|
+
|
|
49
|
+
## 4. 目标驱动执行
|
|
50
|
+
|
|
51
|
+
**定义成功标准,循环直到验证通过。**
|
|
52
|
+
|
|
53
|
+
将命令式任务转换为可验证的目标:
|
|
54
|
+
|
|
55
|
+
| 而非… | 转换为… |
|
|
56
|
+
|--------|---------|
|
|
57
|
+
| "加个校验" | "先写无效输入的测试,再让测试通过" |
|
|
58
|
+
| "修这个 bug" | "先写能复现的测试,再修到测试通过" |
|
|
59
|
+
| "重构 X" | "确保重构前后测试全部通过" |
|
|
60
|
+
|
|
61
|
+
多步任务先给简短计划:
|
|
62
|
+
```
|
|
63
|
+
1. [步骤] → 验证: [检查项]
|
|
64
|
+
2. [步骤] → 验证: [检查项]
|
|
65
|
+
3. [步骤] → 验证: [检查项]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
清晰的成功标准让 AI 可以独立循环验证,模糊的标准("搞一下")需要反复澄清。
|
|
69
|
+
|
|
70
|
+
## 5. 失败要大声说出来
|
|
71
|
+
|
|
72
|
+
**悄悄绕过失败比直接失败更糟糕。**
|
|
73
|
+
|
|
74
|
+
- 有步骤被跳过,"完成"就是错的——说出来
|
|
75
|
+
- 有测试被跳过,"测试通过"就是错的——说出来
|
|
76
|
+
- 不确定就直接说不确定,不假装确认
|
|
77
|
+
- 默认暴露不确定性,不掩盖
|
|
78
|
+
|
|
79
|
+
**检验标准:** 任何跳过的步骤、不确定的结论、未验证的结果,都以标记形式呈现,不悄悄带过。
|
|
80
|
+
|
|
81
|
+
## 6. 不认同也要说出来
|
|
82
|
+
|
|
83
|
+
当项目现有约定明显有问题时:
|
|
84
|
+
|
|
85
|
+
- 照样遵循,保持一致——不悄悄另起炉灶
|
|
86
|
+
- 明确提出来——指出风险,给出替代方案
|
|
87
|
+
- 让用户做决策,不要替用户做选择
|
|
88
|
+
|
|
89
|
+
**检验标准:** 你的代码放进现有代码中,读不出"换了一个人写的"。发现的问题以建议形式呈现,而非悄悄用另一种方式实现。
|
|
90
|
+
|
|
91
|
+
## 7. 先批准,后动工
|
|
92
|
+
|
|
93
|
+
**任何实现动作前,先陈述方案并获得用户批准。**
|
|
94
|
+
|
|
95
|
+
- 动手前说出打算怎么做(方案、涉及文件、验证方式),等用户确认
|
|
96
|
+
- 仪式随任务缩放:小改动两三句话说清即可;大改动走 openspec 工作流(propose → specs → design)
|
|
97
|
+
- "太简单不需要方案"是最危险的念头——简单意味着方案短,而不是没有方案
|
|
98
|
+
- 中途发现复杂度超出预期:停下来重新说明,不要闷头扩大改动范围
|
|
99
|
+
|
|
100
|
+
**检验标准:** 用户从未因"AI 直接改了代码没打招呼"而感到意外。
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
**这些准则生效的标志:** diff 中不必要的改动减少、不会因过度设计而重写、澄清问题在实现前而非出错后提出。
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: always_on
|
|
3
|
+
---
|
|
4
|
+
# 编码规范
|
|
5
|
+
|
|
6
|
+
## 一. 代码结构
|
|
7
|
+
|
|
8
|
+
- 方法禁止超过 **100 行**,超过必须拆分为语义明确的子方法
|
|
9
|
+
- 主方法只做步骤编排,涉及业务规则判断、状态变更或外部调用的循环/分支逻辑必须抽取为独立方法;仅做参数校验、数据组装、简单赋值等非业务逻辑可保留
|
|
10
|
+
- 命名贴合业务含义,同一工程避免同名类,同一概念命名一致,禁止望文不知义的缩写(反例:`aeh` 表示"运费估算处理")
|
|
11
|
+
- 类注释必须包含:说明、作者、版本、引入版本、相关类
|
|
12
|
+
- 公共方法(public、REST、RPC)注释必须包含:入参要求和取值范围、出参结果、异常场景;私有/内部方法只要求写核心功能说明
|
|
13
|
+
- 数据模型必须使用对应后缀:`Request`(入参)、`Response`(出参)、`DTO`(服务间传输)、`PO`(持久化对象)、`Param`(查询/操作参数)
|
|
14
|
+
|
|
15
|
+
## 二. 架构约束
|
|
16
|
+
|
|
17
|
+
- Controller 和 Facade 层禁止编写业务逻辑,仅限处理参数校验、权限检查、异常捕获与封装、日志埋点、结果组装等通用横切关注点;所有业务规则判断、状态流转、数据编排必须下沉到实现层,如Service层
|
|
18
|
+
- Service 层访问外部系统必须通过 Repo 层封装,禁止直接调用外部 API
|
|
19
|
+
|
|
20
|
+
## 三. API 规范
|
|
21
|
+
|
|
22
|
+
- REST 接口中 long/double 类型字段必须使用字符串输出,避免 JS 精度丢失
|
|
23
|
+
- REST 和 API 接口禁止直接抛异常,统一拦截封装成错误码返回;捕获异常后必须处理,禁止空捕获
|
|
24
|
+
|
|
25
|
+
## 四. 数据安全
|
|
26
|
+
|
|
27
|
+
- 以下字段必须加密传输和存储,加密方式沿用当前项目已有方案,多种方案共存或无先例时需与用户确认:身份证号、手机号、银行卡号、邮箱、住址
|
|
28
|
+
- 密码、密钥等敏感信息必须存储在 Lion 配置中心,禁止硬编码
|
|
29
|
+
- 日志中禁止输出未脱敏的敏感信息
|
|
30
|
+
- 后台敏感操作(删除/修改)必须记录审计日志:操作人、时间、操作内容,有请求上下文时记录来源 IP
|
|
31
|
+
- 三方资源限制使用频率
|
|
32
|
+
|
|
33
|
+
## 五. 数据库规范
|
|
34
|
+
|
|
35
|
+
- MyBatis 禁止使用 `${}`,必须使用 `#{}`(防止 SQL 注入)
|
|
36
|
+
- 默认读从库;写链路中强依赖的数据查询必须走主库
|
|
37
|
+
- 分布式锁不能加在数据库事务内,正确顺序:**加锁 → 开启事务 → 执行业务 → 提交事务 → 释放锁**(具体使用方法见 ironman-lock skill)
|
|
38
|
+
|
|
39
|
+
## 六. 兼容性规范
|
|
40
|
+
|
|
41
|
+
- 对外契约和数据格式的变更必须保持向后兼容:仅允许新增可选字段,禁止删除、重命名、改类型或变更已有定义的语义
|
|
42
|
+
- 适用范围:REST/API 接口(避免影响调用方)、数据库表结构与存储格式(避免影响已部署服务)、MQ 消息结构(生产者与消费者双向兼容)、Redis key 命名与 value 序列化格式(变更时版本化 key 或清空旧缓存,避免新老实例读写不一致)、ES 索引 mapping(字段类型或 analyzer 变更需新建索引 + reindex + 别名切换平滑迁移,避免查询与写入异常)
|
|
43
|
+
|
|
44
|
+
## 七. 枚举规范
|
|
45
|
+
|
|
46
|
+
- 枚举只能新增,禁止修改和删除已有枚举值
|
|
47
|
+
|
|
48
|
+
## 八. 单元测试
|
|
49
|
+
|
|
50
|
+
- 单元测试必须覆盖增量业务逻辑,目标 **100%** 增量业务逻辑行覆盖,且全部运行通过
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: always_on
|
|
3
|
+
---
|
|
4
|
+
# 规范优先级
|
|
5
|
+
|
|
6
|
+
全局规范与项目现有约定冲突时,按以下优先级处理:
|
|
7
|
+
|
|
8
|
+
| 优先级 | 来源 | 说明 |
|
|
9
|
+
|--------|------|------|
|
|
10
|
+
| 1(最高) | 项目现有约定 | 包括代码中实际观察到的风格,以及项目目录下的显式规范(lint 配置、CLAUDE.md 等)。两者冲突时以显式规范为准 |
|
|
11
|
+
| 2(最低) | 本规范库 | 统一规范,作为默认兜底。已吸收语言/框架官方惯例(如 PEP 8、Effective Go 等)作为基线 |
|
|
12
|
+
|
|
13
|
+
**豁免**:以下情况不属于"沿用"范围,发现问题必须指出:
|
|
14
|
+
|
|
15
|
+
- 会导致运行时错误或数据损坏的明显 bug
|
|
16
|
+
- 安全缺陷(如 SQL 注入、敏感信息明文存储、XSS 风险等)
|
|
17
|
+
- 已废弃的 API
|
|
18
|
+
- 会导致严重性能退化的模式(如 N+1 查询、全表扫描后内存过滤、大事务长连接等)
|
|
19
|
+
- 违反合规/法律要求的处理方式(如数据保留、隐私保护等)
|
|
20
|
+
- 会导致可维护性灾难的模式(如单体方法超 500 行、循环嵌套深度 > 4 层等)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 执行原则
|
|
25
|
+
|
|
26
|
+
### 首次进入项目
|
|
27
|
+
|
|
28
|
+
生成或修改代码前必须:
|
|
29
|
+
|
|
30
|
+
1. **探测现有风格** — 检查目标文件所在目录的代码风格
|
|
31
|
+
2. **识别架构模式** — 确认项目使用的分包模式、命名约定、注解风格
|
|
32
|
+
3. **保持一致性** — 新代码遵循项目风格,而非套用全局规范
|
|
33
|
+
|
|
34
|
+
> 目录内风格不一致时,以目录内多数文件的风格为准;仍无法判断时,以项目显式规范为准。
|
|
35
|
+
|
|
36
|
+
### 冲突处理
|
|
37
|
+
|
|
38
|
+
| 场景 | 处理方式 |
|
|
39
|
+
|------|----------|
|
|
40
|
+
| 项目已有分层架构 | 沿用现有分层,不强制统一为某种架构 |
|
|
41
|
+
| 项目已有命名风格 | 保持统一,不自创新风格 |
|
|
42
|
+
| 项目已用某中间件 | 继续使用,不强行切换 |
|
|
43
|
+
| 项目内存在多种风格混用 | 以当前文件风格为准,不引入第三种风格;当前文件无明确风格时以目录内多数文件风格为准 |
|
|
44
|
+
| 项目无先例可循(如首次使用 Redis、首次写 MQ 消费者) | 使用本规范库作为默认起点 |
|
|
45
|
+
| 全局规范更新 | 以项目实际安装的版本为准,不自动覆盖 |
|
|
46
|
+
| 全新项目 | 使用本规范库作为起点 |
|
|
47
|
+
| 已有项目中的新模块 | 沿用项目现有约定,不另起风格 |
|
|
48
|
+
|
|
49
|
+
> **显式规范与代码风格冲突时的处理**:显式规范优先用于新代码;不要求对已有代码做大规模 reformat。判断标准:涉及命名约定、架构分层、中间件选型等**结构性决策**时以显式规范为准;仅涉及缩进、换行等**格式细节**时以当前文件风格为准。
|
|
50
|
+
|
|
51
|
+
### 重构场景
|
|
52
|
+
|
|
53
|
+
当本次需求涉及架构重构时:
|
|
54
|
+
|
|
55
|
+
- 以重构目标为准,而非沿用旧模式
|
|
56
|
+
- 重构范围必须明确界定,不在范围内的代码保持现有风格
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-specs
|
|
3
|
+
description: "架构与中间件规范。方案设计、编码实现、Code Review 三个阶段均须参照——涵盖 OpenSpec propose/apply/verify、Superpowers 头脑风暴/writing-plans/executing-plans/requesting-code-review/receiving-code-review、编写技术方案或架构设计、直接编码、直接代码审查。内容包括模块划分与分包(app/api/service/web/spi)、分层架构设计(Controller→Service→Repo→DAO)、中间件选型与使用(RPC/MQ/Redis/Config/SQL)、Spring Boot + MyBatis 技术栈、依赖管理、服务注册与发现、灰度发布、限流降级。仅限后端架构设计与中间件选型场景,不适用于前端架构或纯业务逻辑实现。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 架构与中间件规范
|
|
7
|
+
|
|
8
|
+
提供分层架构、模块组织、中间件选型等完整规范。
|
|
9
|
+
|
|
10
|
+
## 使用场景
|
|
11
|
+
|
|
12
|
+
当你需要:
|
|
13
|
+
- 设计系统架构
|
|
14
|
+
- 划分模块和分包
|
|
15
|
+
- 选型中间件(MQ、Redis、配置中心)
|
|
16
|
+
- 了解技术栈要求
|
|
17
|
+
|
|
18
|
+
## 规范内容
|
|
19
|
+
|
|
20
|
+
### 分层架构规范
|
|
21
|
+
|
|
22
|
+
采用 Controller → Service → Repo → DAO 四层架构,各层职责和约束详见 `/coding-specs`。
|
|
23
|
+
|
|
24
|
+
#### 模块组织
|
|
25
|
+
|
|
26
|
+
标准模块结构:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
xxx-api/ → RPC 接口定义(Facade、DTO)
|
|
30
|
+
xxx-web/ → REST 控制器和应用启动
|
|
31
|
+
xxx-service/ → 业务逻辑实现
|
|
32
|
+
xxx-spi/ → 服务提供者接口(可选)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
RPC 接口:Facade 接口和 DTO 放在 xxx-api,实现类放在 xxx-service。
|
|
36
|
+
|
|
37
|
+
#### 工程分模块
|
|
38
|
+
|
|
39
|
+
- 简单工程(业务模块 <= 3):REST+RPC 实现可以在一个模块中
|
|
40
|
+
- 多个应用/模块共用的部分必须独立成模块
|
|
41
|
+
- 无意义的模块划分会导致依赖管理复杂
|
|
42
|
+
|
|
43
|
+
#### 分包策略
|
|
44
|
+
|
|
45
|
+
**API 模块第一层包:**
|
|
46
|
+
- `exception` — 对外暴露的自定义异常
|
|
47
|
+
- `util` — 对外提供的基础工具类
|
|
48
|
+
- `[Business module]` — 按业务模块分包(facade / dto / request)
|
|
49
|
+
|
|
50
|
+
### 中间件选型规范
|
|
51
|
+
|
|
52
|
+
#### 数据存储
|
|
53
|
+
|
|
54
|
+
| 场景 | 中间件 | 客户端 |
|
|
55
|
+
|------|--------|--------|
|
|
56
|
+
| 核心业务数据持久化 | MySQL(ES/Redis 不可独立作为数据存储) | ironman-sql |
|
|
57
|
+
| 全文检索/复杂查询 | Elasticsearch | ebatis |
|
|
58
|
+
| 分布式缓存 | Redis | ironman-redis |
|
|
59
|
+
|
|
60
|
+
#### 消息队列
|
|
61
|
+
|
|
62
|
+
| 场景 | 中间件 | 说明 |
|
|
63
|
+
|------|--------|------|
|
|
64
|
+
| 业务系统消息通信 | RocketMQ | 通过 ironman-mq |
|
|
65
|
+
| 大数据处理场景 | Kafka | - |
|
|
66
|
+
| 延迟处理 | Delay 服务 | 范围 1s~7d,消息体 < 4K,QPS < 1000 |
|
|
67
|
+
|
|
68
|
+
核心链路不可以强依赖 Kafka,建议使用 RocketMQ 替代。
|
|
69
|
+
|
|
70
|
+
#### Ironman 中间件
|
|
71
|
+
|
|
72
|
+
| 能力 | 中间件 | 使用指导 |
|
|
73
|
+
|------|--------|----------|
|
|
74
|
+
| 配置中心 | IronMan Config(ironman-config) | 详见 `/mb-ironman-config` skill |
|
|
75
|
+
| RPC 框架 | IronMan RPC(ironman-rpc) | 详见 `/mb-ironman-rpc` skill |
|
|
76
|
+
| 数据库访问 | IronMan SQL(ironman-sql) | 详见 `/mb-ironman-sql` skill |
|
|
77
|
+
| Redis 访问 | IronMan Redis(ironman-redis) | 详见 `/mb-ironman-redis` skill |
|
|
78
|
+
| 分布式锁 | IronMan Lock(ironman-lock),支持 Redis(AP) 和 Zookeeper(CP) | 详见 `/ironman-lock` skill |
|
|
79
|
+
| 多级缓存 | IronMan Cache(ironman-cache) | — |
|
|
80
|
+
| 幂等控制 | IronMan Idempotent(ironman-idempotent) | — |
|
|
81
|
+
|
|
82
|
+
#### 通用能力
|
|
83
|
+
|
|
84
|
+
| 能力 | 中间件 |
|
|
85
|
+
|------|--------|
|
|
86
|
+
| 敏感信息加密 | Thaad |
|
|
87
|
+
| 定时任务 | YmmJob |
|
|
88
|
+
| 监控告警 | Hubble + Cat |
|
|
89
|
+
| 流控降级 | Sentinel |
|
|
90
|
+
| 网关 | Hango |
|
|
91
|
+
| 全局唯一 ID | Number-Generating(建议使用 String 类型) |
|
|
92
|
+
|
|
93
|
+
#### 三方框架
|
|
94
|
+
|
|
95
|
+
| 类别 | 产品 |
|
|
96
|
+
|------|------|
|
|
97
|
+
| 基础框架 | SpringBoot |
|
|
98
|
+
| ORM | MyBatis-Plus(必须通过 Ironman-SQL 封装使用,禁止裸用) |
|
|
99
|
+
| 对象映射 | MapStruct |
|
|
100
|
+
| 代码生成 | Lombok |
|
|
101
|
+
| 本地缓存 | Caffeine |
|
|
102
|
+
| 单元测试 | JUnit + Mockito |
|
|
103
|
+
| JSON 处理 | Jackson |
|
|
104
|
+
| 工具类 | Hutool、Apache Commons |
|
|
105
|
+
| 日志 | SLF4J + Log4j2 |
|
|
106
|
+
| Excel 处理 | Apache POI |
|
|
107
|
+
| HTTP 客户端 | OkHttp |
|
|
108
|
+
|
|
109
|
+
#### 技术栈要求
|
|
110
|
+
|
|
111
|
+
**必须使用**:
|
|
112
|
+
- IronMan 中间件体系(Config、RPC、SQL、Redis、Lock、Cache)
|
|
113
|
+
- MySQL 作为核心数据持久化存储
|
|
114
|
+
- MyBatis-Plus(通过 Ironman-SQL 封装)作为 ORM 框架
|
|
115
|
+
|
|
116
|
+
**禁止**:
|
|
117
|
+
- ES/Redis 独立作为数据存储
|
|
118
|
+
- 裸用 MyBatis-Plus(绕过 Ironman-SQL 直接使用原生 MP 或原生 MyBatis)
|
|
119
|
+
- 使用 `${}` 进行 SQL 参数绑定(SQL 注入风险)
|
|
120
|
+
|
|
121
|
+
## 检查清单
|
|
122
|
+
|
|
123
|
+
使用本技能时,会检查:
|
|
124
|
+
- [ ] 是否遵循四层架构
|
|
125
|
+
- [ ] 模块划分是否合理
|
|
126
|
+
- [ ] 是否使用 IronMan 中间件体系
|
|
127
|
+
- [ ] 是否使用 MySQL + Ironman-SQL(MyBatis-Plus)
|
|
128
|
+
- [ ] 中间件选型是否合理
|
|
129
|
+
|