kld-sdd 1.0.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.
- package/README.md +178 -0
- package/bin/kld-sdd-init.js +13 -0
- package/index.js +13 -0
- package/lib/init.js +607 -0
- package/package.json +33 -0
- package/templates/openspec/design.md +154 -0
- package/templates/openspec/propose.md +87 -0
- package/templates/openspec/spec.md +148 -0
- package/templates/openspec/task.md +184 -0
- package/templates/opsx-commands/design.md +164 -0
- package/templates/opsx-commands/propose.md +106 -0
- package/templates/opsx-commands/spec.md +145 -0
- package/templates/opsx-commands/task.md +179 -0
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# kld-sdd
|
|
2
|
+
|
|
3
|
+
KLD SDD OpenSpec 项目初始化工具 - 内置标准模版,一键初始化
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🚀 自动检测并安装 `openspec`
|
|
8
|
+
- 📄 内置 openSpec 四文档标准模版(propose/spec/design/task)
|
|
9
|
+
- 🛠️ 自动配置多种 AI 编辑器 (Cursor, Claude Code)
|
|
10
|
+
- 📁 创建团队配置目录结构
|
|
11
|
+
- 🔄 自动应用团队共享配置
|
|
12
|
+
- 📝 智能更新 `.gitignore`
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
### 全局安装(推荐)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g kld-sdd
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 使用 npx(无需安装)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx kld-sdd
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 使用方法
|
|
29
|
+
|
|
30
|
+
### 基本用法
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 完整初始化流程(自动安装 openspec + 复制模版 + 配置编辑器)
|
|
34
|
+
kld-sdd-init
|
|
35
|
+
|
|
36
|
+
# 跳过 openspec init 步骤
|
|
37
|
+
kld-sdd-init --skip-openspec
|
|
38
|
+
|
|
39
|
+
# 跳过复制内置模版
|
|
40
|
+
kld-sdd-init --skip-template
|
|
41
|
+
|
|
42
|
+
# 仅配置指定编辑器
|
|
43
|
+
kld-sdd-init --tool cursor
|
|
44
|
+
|
|
45
|
+
# 显示帮助
|
|
46
|
+
kld-sdd-init --help
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 在项目中使用
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 进入项目目录
|
|
53
|
+
cd your-project
|
|
54
|
+
|
|
55
|
+
# 运行初始化
|
|
56
|
+
kld-sdd-init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 项目结构
|
|
60
|
+
|
|
61
|
+
初始化后会创建以下目录结构:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
your-project/
|
|
65
|
+
├── openspec-templates/ # ✅ 内置 openSpec 四文档模版
|
|
66
|
+
│ ├── propose.md
|
|
67
|
+
│ ├── spec.md
|
|
68
|
+
│ ├── design.md
|
|
69
|
+
│ └── task.md
|
|
70
|
+
├── team-configs/ # 团队共享配置
|
|
71
|
+
│ ├── cursor-commands/ # Cursor 自定义命令
|
|
72
|
+
│ ├── claude-commands/ # Claude Code 自定义命令
|
|
73
|
+
│ └── README.md
|
|
74
|
+
├── team-schemas/ # 团队自定义 schemas
|
|
75
|
+
├── .cursor/commands/ # Cursor 命令(自动配置)
|
|
76
|
+
├── .claude/commands/openspec/ # Claude 命令(自动配置)
|
|
77
|
+
└── .gitignore # 自动更新
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 内置模版
|
|
81
|
+
|
|
82
|
+
kld-sdd 内置了符合 openSpec 标准的四文档模版:
|
|
83
|
+
|
|
84
|
+
| 模版文件 | 定位 | 质量红线 |
|
|
85
|
+
|---------|------|---------|
|
|
86
|
+
| `propose.md` | 业务意图(Why)与上下文总览 | 逻辑链路闭环,模块影响明确 |
|
|
87
|
+
| `spec.md` | 业务场景与技术契约的"唯一真理" | 严禁模糊描述;约束必须量化 |
|
|
88
|
+
| `design.md` | 业务维度的具体技术实现方案 | 严禁全局中间件;支持任务拆解 |
|
|
89
|
+
| `task.md` | AI编码引擎的极小执行单元 | 5分钟可实现;100%覆盖spec/design |
|
|
90
|
+
|
|
91
|
+
## 团队配置 workflow
|
|
92
|
+
|
|
93
|
+
1. **架构师/TL** 将团队规范放入 `team-configs/` 目录
|
|
94
|
+
2. **新成员** 克隆项目后运行 `kld-sdd-init`
|
|
95
|
+
3. **自动完成**:安装 openspec → 复制模版 → 应用团队配置
|
|
96
|
+
|
|
97
|
+
## 支持的 AI 编辑器
|
|
98
|
+
|
|
99
|
+
| 编辑器 | 配置目录 | 状态 |
|
|
100
|
+
|-------|---------|------|
|
|
101
|
+
| Cursor | `.cursor/commands/` | ✅ 支持 |
|
|
102
|
+
| Claude Code | `.claude/commands/openspec/` | ✅ 支持 |
|
|
103
|
+
|
|
104
|
+
## 配置说明
|
|
105
|
+
|
|
106
|
+
### team-configs 目录
|
|
107
|
+
|
|
108
|
+
将团队自定义命令文件放入对应目录:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
team-configs/
|
|
112
|
+
├── cursor-commands/
|
|
113
|
+
│ ├── opsx-propose.md
|
|
114
|
+
│ ├── opsx-spec-fill.md
|
|
115
|
+
│ └── opsx-check.md
|
|
116
|
+
└── claude-commands/
|
|
117
|
+
├── opsx-propose.md
|
|
118
|
+
└── opsx-check.md
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### .gitignore 配置
|
|
122
|
+
|
|
123
|
+
工具会自动添加以下配置:
|
|
124
|
+
|
|
125
|
+
```gitignore
|
|
126
|
+
# KLD SDD 个人配置 (保留团队配置)
|
|
127
|
+
.cursor/commands/personal-*
|
|
128
|
+
.claude/commands/personal-*
|
|
129
|
+
|
|
130
|
+
# 但保留团队配置的占位目录
|
|
131
|
+
!.cursor/commands/team-*
|
|
132
|
+
!.claude/commands/team-*
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 程序化 API
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
const { main, detectTools, applyTeamConfig, getTemplatePath } = require('kld-sdd');
|
|
139
|
+
|
|
140
|
+
// 检测已安装的编辑器
|
|
141
|
+
const tools = detectTools();
|
|
142
|
+
console.log(tools); // ['cursor', 'claude']
|
|
143
|
+
|
|
144
|
+
// 应用指定工具的团队配置
|
|
145
|
+
applyTeamConfig('cursor');
|
|
146
|
+
|
|
147
|
+
// 获取内置模版路径
|
|
148
|
+
const templatePath = getTemplatePath();
|
|
149
|
+
|
|
150
|
+
// 运行完整初始化流程
|
|
151
|
+
main();
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## 与 npm scripts 集成
|
|
155
|
+
|
|
156
|
+
在 `package.json` 中添加:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"scripts": {
|
|
161
|
+
"setup": "kld-sdd-init",
|
|
162
|
+
"setup:quick": "kld-sdd-init --skip-openspec",
|
|
163
|
+
"postinstall": "kld-sdd-init --skip-openspec"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 最佳实践
|
|
169
|
+
|
|
170
|
+
1. **将 team-configs 纳入版本控制**,确保团队配置同步
|
|
171
|
+
2. **新成员 onboarding** 只需运行 `npm install && npm run setup`
|
|
172
|
+
3. **配置变更后** 重新运行 `kld-sdd-init` 即可更新
|
|
173
|
+
4. **个人配置** 使用 `personal-` 前缀,避免与团队配置冲突
|
|
174
|
+
5. **参考模版** 在 `openspec-templates/` 中查看标准格式
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT
|