@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: es-design-specs
|
|
3
|
+
description: "Elasticsearch 索引设计规范。方案设计、编码实现、Code Review 三个阶段均须参照——涵盖 OpenSpec propose/apply/verify、Superpowers 头脑风暴/writing-plans/executing-plans/requesting-code-review/receiving-code-review、编写技术方案或详细设计、直接编码、直接代码审查。内容包括索引结构设计、mapping 定义、字段类型选择、索引命名、分片与副本配置、dynamic mapping 控制、别名管理、索引生命周期管理。仅限 ES 索引结构设计场景,ES 查询编写与 bulk 操作参见 coding-specs。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Elasticsearch 索引设计规范
|
|
7
|
+
|
|
8
|
+
提供 ES 索引结构设计、mapping 定义、分片策略等规范。
|
|
9
|
+
|
|
10
|
+
## 使用场景
|
|
11
|
+
|
|
12
|
+
当你需要:
|
|
13
|
+
- 设计 ES 索引结构
|
|
14
|
+
- 定义索引 mapping 和 setting
|
|
15
|
+
- 规划分片和副本策略
|
|
16
|
+
- 选择字段类型
|
|
17
|
+
|
|
18
|
+
## 规范内容
|
|
19
|
+
|
|
20
|
+
### 集群配置
|
|
21
|
+
|
|
22
|
+
- 集群命名格式:`es7-应用名称`,使用中划线 `-`,禁止下划线和特殊字符
|
|
23
|
+
- 集群节点数 >= 3
|
|
24
|
+
- 核心链路必须使用 KnowSearch + EBatis 实现多集群互备
|
|
25
|
+
|
|
26
|
+
### 索引设计
|
|
27
|
+
|
|
28
|
+
- 索引名使用小写字母,禁止以 `_` 开头,禁止特殊字符
|
|
29
|
+
- 必须明确指定 mapping 和 setting,禁止使用默认值
|
|
30
|
+
- 禁用 dynamic mapping
|
|
31
|
+
- 使用索引别名访问
|
|
32
|
+
|
|
33
|
+
#### Mapping 模板
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mappings": {
|
|
38
|
+
"dynamic": "strict",
|
|
39
|
+
"properties": {
|
|
40
|
+
"id": { "type": "long" },
|
|
41
|
+
"order_no": { "type": "keyword" },
|
|
42
|
+
"cargo_status": { "type": "integer" },
|
|
43
|
+
"company_name": {
|
|
44
|
+
"type": "text",
|
|
45
|
+
"analyzer": "ik_max_word",
|
|
46
|
+
"fields": {
|
|
47
|
+
"keyword": { "type": "keyword", "ignore_above": 256 }
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"freight_amount": { "type": "long" },
|
|
51
|
+
"create_time": {
|
|
52
|
+
"type": "date",
|
|
53
|
+
"format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
|
|
54
|
+
},
|
|
55
|
+
"update_time": {
|
|
56
|
+
"type": "date",
|
|
57
|
+
"format": "yyyy-MM-dd HH:mm:ss||epoch_millis"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"settings": {
|
|
62
|
+
"number_of_shards": 3,
|
|
63
|
+
"number_of_replicas": 1,
|
|
64
|
+
"refresh_interval": "1s"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 字段类型选择
|
|
70
|
+
|
|
71
|
+
| 场景 | 推荐类型 |
|
|
72
|
+
|------|---------|
|
|
73
|
+
| 数值范围匹配 | numeric |
|
|
74
|
+
| 仅 term 查询 | keyword(优先) |
|
|
75
|
+
| 全文搜索 | text + keyword(multi-field) |
|
|
76
|
+
| 日期 | date(统一格式) |
|
|
77
|
+
|
|
78
|
+
### 分片策略
|
|
79
|
+
|
|
80
|
+
- 单分片大小建议 10~50GB
|
|
81
|
+
- 总分片数不超过 `(节点数 × 3)`
|
|
82
|
+
- 副本数:生产环境至少 1 个副本
|
|
83
|
+
|
|
84
|
+
### 常见反模式
|
|
85
|
+
|
|
86
|
+
- **禁止 wildcard 前缀查询**:`*keyword` 性能极差,改用 keyword 类型 + term 查询
|
|
87
|
+
- **禁止深度聚合**:聚合桶数超过 10000 时需优化分片策略或减少聚合维度
|
|
88
|
+
- **禁止大结果集排序**:排序字段无 doc values 时会触发 fielddata 加载,导致 OOM
|
|
89
|
+
- **禁止频繁更新**:ES 更新成本高(标记删除 + 重建),高频更新场景考虑合并写入
|
|
90
|
+
|
|
91
|
+
### 数据实时性
|
|
92
|
+
|
|
93
|
+
ES 默认 `refresh_interval` 为 1 秒,数据写入 1 秒后才能被搜索到。批量导入场景可临时调大(如 `30s`)以提升写入性能。
|
|
94
|
+
|
|
95
|
+
## 检查清单
|
|
96
|
+
|
|
97
|
+
设计 ES 索引时,请确认以下各项:
|
|
98
|
+
- [ ] 集群命名是否符合规范
|
|
99
|
+
- [ ] 索引设计是否明确指定 mapping
|
|
100
|
+
- [ ] 是否禁用 dynamic mapping
|
|
101
|
+
- [ ] 分片大小是否在 10~50GB 范围内
|
|
102
|
+
- [ ] 字段类型选择是否合理
|
|
103
|
+
- [ ] 是否避免 wildcard 前缀查询
|
|
104
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mysql-design-specs
|
|
3
|
+
description: "【必须调用】MySQL 数据库设计规范。方案设计、编码实现、Code Review 三个阶段均须参照——涵盖 OpenSpec propose/apply/verify、Superpowers 头脑风暴/writing-plans/executing-plans/requesting-code-review/receiving-code-review、编写技术方案或详细设计、直接编码、直接代码审查。强制触发信号:CREATE TABLE、bigint(20)、tinyint(4)、is_valid、PRIMARY KEY、UNIQUE KEY、建表、加字段、加索引、设计表结构、DDL、表结构——无论是主动建表、在文档/Wiki/方案中编写 DDL、还是从其他地方复制 DDL,都必须校验。内容包括 Zebra 分库分表规范和业务表设计惯例。SQL 编写与事务控制参见 coding-specs。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 数据库规范
|
|
7
|
+
|
|
8
|
+
提供数据库表设计、索引设计等规范。
|
|
9
|
+
|
|
10
|
+
## 强制触发规则
|
|
11
|
+
|
|
12
|
+
**本 skill 的调用不是"建议"而是"强制"**——即使 DDL 是你从别处复制粘贴的、即使它嵌入在 Wiki 文档中而非 .sql 文件,只要内容包含 `CREATE TABLE` 或 DDL 定义,就必须先 invoke 本 skill 验证。不要假设已有的 DDL 就是符合规范的。
|
|
13
|
+
|
|
14
|
+
## 使用场景
|
|
15
|
+
|
|
16
|
+
当你需要:
|
|
17
|
+
- 设计数据库表结构
|
|
18
|
+
- 设计索引
|
|
19
|
+
- 编写 DDL 语句(建表、加字段、改字段、加索引)
|
|
20
|
+
- **更新包含 DDL 的 Wiki 文档或技术方案**
|
|
21
|
+
- **在任何文件中出现或修改 CREATE TABLE 语句**
|
|
22
|
+
|
|
23
|
+
## 规范内容
|
|
24
|
+
|
|
25
|
+
### 表设计
|
|
26
|
+
|
|
27
|
+
#### 必备字段
|
|
28
|
+
|
|
29
|
+
```sql
|
|
30
|
+
CREATE TABLE `myb_business_entity` (
|
|
31
|
+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
|
|
32
|
+
-- 业务字段 --
|
|
33
|
+
`deleted` tinyint NOT NULL DEFAULT 0 COMMENT '0-未删除,1-已删除',
|
|
34
|
+
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
35
|
+
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
|
36
|
+
PRIMARY KEY (`id`),
|
|
37
|
+
KEY `idx_updatetime` (`update_time`),
|
|
38
|
+
KEY `idx_createtime` (`create_time`)
|
|
39
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='业务实体描述';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### 字段约束
|
|
43
|
+
|
|
44
|
+
- 主键必须使用 `bigint unsigned`
|
|
45
|
+
- 必须有 `create_time` 和 `update_time` 字段
|
|
46
|
+
- 状态字段必须使用 `tinyint`,禁止使用字符串
|
|
47
|
+
- 逻辑删除使用 `deleted` 字段,类型为 `tinyint`
|
|
48
|
+
|
|
49
|
+
#### 字段规范
|
|
50
|
+
|
|
51
|
+
- 小数类型使用 `decimal`,禁止 `float` 和 `double`
|
|
52
|
+
- 字符串长度 < 5000 使用 `varchar`,>= 5000 使用 `text`
|
|
53
|
+
- 字符串长度几乎相等时使用 `char` 定长类型
|
|
54
|
+
- **整数类型(bigint、int、tinyint、smallint、mediumint)禁止设置显示宽度**,如 `bigint(20)` 应写为 `bigint`,`tinyint(2)` 应写为 `tinyint`(MySQL 8.0.17+ 已忽略显示宽度,写宽度反而造成误导)
|
|
55
|
+
- 字段允许为空时必须有默认值
|
|
56
|
+
- 字段和表必须有 COMMENT
|
|
57
|
+
- 新增非空字段必须提供默认值或对历史数据刷数
|
|
58
|
+
|
|
59
|
+
#### 命名规范
|
|
60
|
+
|
|
61
|
+
- 表名必须以业务域缩写开头,如 `myb_xx_xx`、`yzg_xx_xx`、`ka_xx_xx`
|
|
62
|
+
- 表名、字段名使用小写字母或小写+数字组合
|
|
63
|
+
- 禁止数字开头、禁止表名复数、禁止两个下划线中间只出现数字
|
|
64
|
+
- 禁用 MySQL 保留字
|
|
65
|
+
|
|
66
|
+
### 索引设计
|
|
67
|
+
|
|
68
|
+
| 索引类型 | 前缀 | 示例 |
|
|
69
|
+
|----------|------|------|
|
|
70
|
+
| 主键索引 | pk_ | pk_id |
|
|
71
|
+
| 唯一索引 | uk_ | uk_email |
|
|
72
|
+
| 普通索引 | idx_ | idx_user_name |
|
|
73
|
+
|
|
74
|
+
- 联合索引遵循最左前缀原则,高选择性字段放前面
|
|
75
|
+
- 字段区分度 < 10% 不创建单独索引
|
|
76
|
+
- TEXT/BLOB 禁止创建索引
|
|
77
|
+
- 非字典类数据查询必须走索引
|
|
78
|
+
- 禁止重复索引和无效索引
|
|
79
|
+
|
|
80
|
+
## 检查清单
|
|
81
|
+
|
|
82
|
+
设计数据库表结构或编写 DDL 时,请确认以下各项:
|
|
83
|
+
- [ ] 主键是否使用 bigint unsigned
|
|
84
|
+
- [ ] 是否有 create_time 和 update_time
|
|
85
|
+
- [ ] 状态字段是否使用 tinyint
|
|
86
|
+
- [ ] 整数类型(bigint/int/tinyint/smallint/mediumint)是否去掉了显示宽度
|
|
87
|
+
- [ ] 索引设计是否合理
|
|
88
|
+
- [ ] 字段类型和命名是否符合规范
|
|
89
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code 适配器
|
|
3
|
+
*
|
|
4
|
+
* 将编码规范分发到 .claude/rules/ 目录
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
name: 'claude-code',
|
|
12
|
+
displayName: 'Claude Code',
|
|
13
|
+
rulesDir: '.claude/rules',
|
|
14
|
+
skillsDir: '.claude/skills',
|
|
15
|
+
commandsDir: '.claude/commands/opsx',
|
|
16
|
+
// 用户级 settings,写入全局生效,不污染项目目录
|
|
17
|
+
settingsFile: path.join(os.homedir(), '.claude', 'settings.json'),
|
|
18
|
+
settingsFileIsUserLevel: true,
|
|
19
|
+
hookEvents: ['UserPromptSubmit'],
|
|
20
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 升级 / 卸载时清单驱动的文件清理决策。
|
|
5
|
+
*
|
|
6
|
+
* 独立成模块是为了便于单元测试(init.js 是脚本式入口,不便直接 require)。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 受保护、任何清单驱动的清理都不得删除的路径。
|
|
11
|
+
*
|
|
12
|
+
* 背景:旧版本(commit 5bab2e9 之前)会生成 AGENTS.md / CLAUDE.md,
|
|
13
|
+
* 并把整文件路径写入安装清单(.cbb/.managed-by-cbb)。当时若用户已有
|
|
14
|
+
* 自有的 CLAUDE.md,旧逻辑会把本包的路由片段“合并”进去后再登记到清单。
|
|
15
|
+
*
|
|
16
|
+
* 5bab2e9 移除了这两类文件的生成,新版本不再把它们加入新清单。
|
|
17
|
+
* 于是升级时“清理旧清单中、新清单里没有的路径”这一逻辑会把这两个文件
|
|
18
|
+
* 当作废弃文件直接删除——连同用户自有的文档内容一并销毁(数据丢失)。
|
|
19
|
+
*
|
|
20
|
+
* 由于本包已不再追踪它当初注入了哪一段内容,无法安全地“只移除本包部分”,
|
|
21
|
+
* 因此最稳妥的做法是:这两个根目录的用户文档文件在任何清单清理中都不删除,
|
|
22
|
+
* 由用户自行决定是否保留。
|
|
23
|
+
*/
|
|
24
|
+
const PROTECTED_FROM_CLEANUP = new Set(['CLAUDE.md', 'AGENTS.md']);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 计算需要从磁盘删除的清单路径。
|
|
28
|
+
*
|
|
29
|
+
* @param {Iterable<string>} managedPaths 旧清单中记录的全部相对路径
|
|
30
|
+
* @param {Set<string>} keepSet 本次仍由本包管理、或已被智能处理(应保留)的路径
|
|
31
|
+
* @returns {string[]} 应当删除的相对路径(已排除 keepSet 与受保护文件)
|
|
32
|
+
*/
|
|
33
|
+
function pathsToDelete(managedPaths, keepSet) {
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const p of managedPaths) {
|
|
36
|
+
if (keepSet.has(p)) continue;
|
|
37
|
+
if (PROTECTED_FROM_CLEANUP.has(p)) continue;
|
|
38
|
+
result.push(p);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 计算清单中“受保护、本次不会被删除”的路径,用于在卸载时提示用户自行处理。
|
|
45
|
+
*
|
|
46
|
+
* @param {Iterable<string>} managedPaths 旧清单中记录的全部相对路径
|
|
47
|
+
* @param {Set<string>} keepSet 本次仍由本包管理、或已被智能处理的路径
|
|
48
|
+
* @returns {string[]} 受保护且不在 keepSet 中的相对路径
|
|
49
|
+
*/
|
|
50
|
+
function protectedKeptPaths(managedPaths, keepSet) {
|
|
51
|
+
const result = [];
|
|
52
|
+
for (const p of managedPaths) {
|
|
53
|
+
if (keepSet.has(p)) continue;
|
|
54
|
+
if (!PROTECTED_FROM_CLEANUP.has(p)) continue;
|
|
55
|
+
result.push(p);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
PROTECTED_FROM_CLEANUP,
|
|
62
|
+
pathsToDelete,
|
|
63
|
+
protectedKeptPaths,
|
|
64
|
+
};
|