speccrew 0.1.1 → 0.1.2
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.ar.md +98 -91
- package/README.bn.md +122 -0
- package/README.bs.md +321 -0
- package/README.da.md +321 -0
- package/README.de.md +321 -0
- package/README.el.md +122 -0
- package/README.en.md +92 -85
- package/README.es.md +96 -89
- package/README.fr.md +321 -0
- package/README.it.md +321 -0
- package/README.ja.md +321 -0
- package/README.ko.md +321 -0
- package/README.md +92 -109
- package/README.no.md +321 -0
- package/README.pl.md +321 -0
- package/README.pt-BR.md +321 -0
- package/README.ru.md +321 -0
- package/README.th.md +239 -0
- package/README.tr.md +239 -0
- package/README.uk.md +239 -0
- package/README.vi.md +122 -0
- package/README.zh-TW.md +321 -0
- package/bin/cli.js +5 -1
- package/bin/postinstall.js +157 -0
- package/docs/GETTING-STARTED.ar.md +452 -0
- package/docs/GETTING-STARTED.bn.md +449 -0
- package/docs/GETTING-STARTED.bs.md +449 -0
- package/docs/GETTING-STARTED.da.md +448 -0
- package/docs/GETTING-STARTED.de.md +448 -0
- package/docs/GETTING-STARTED.el.md +449 -0
- package/docs/GETTING-STARTED.en.md +448 -0
- package/docs/GETTING-STARTED.es.md +448 -0
- package/docs/GETTING-STARTED.fr.md +448 -0
- package/docs/GETTING-STARTED.it.md +448 -0
- package/docs/GETTING-STARTED.ja.md +448 -0
- package/docs/GETTING-STARTED.ko.md +448 -0
- package/docs/GETTING-STARTED.md +448 -0
- package/docs/GETTING-STARTED.no.md +449 -0
- package/docs/GETTING-STARTED.pl.md +449 -0
- package/docs/GETTING-STARTED.pt-BR.md +449 -0
- package/docs/GETTING-STARTED.ru.md +449 -0
- package/docs/GETTING-STARTED.th.md +449 -0
- package/docs/GETTING-STARTED.tr.md +449 -0
- package/docs/GETTING-STARTED.uk.md +449 -0
- package/docs/GETTING-STARTED.vi.md +449 -0
- package/docs/GETTING-STARTED.zh-TW.md +448 -0
- package/lib/commands/init.js +238 -41
- package/lib/commands/uninstall.js +150 -32
- package/lib/commands/update.js +159 -24
- package/lib/ide-adapters.js +257 -3
- package/lib/utils.js +23 -7
- package/package.json +7 -2
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# SpecCrew - AI 驅動的軟體工程化框架
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="./README.md">简体中文</a> |
|
|
5
|
+
<a href="./README.zh-TW.md">繁體中文</a> |
|
|
6
|
+
<a href="./README.en.md">English</a> |
|
|
7
|
+
<a href="./README.ko.md">한국어</a> |
|
|
8
|
+
<a href="./README.de.md">Deutsch</a> |
|
|
9
|
+
<a href="./README.es.md">Español</a> |
|
|
10
|
+
<a href="./README.fr.md">Français</a> |
|
|
11
|
+
<a href="./README.it.md">Italiano</a> |
|
|
12
|
+
<a href="./README.da.md">Dansk</a> |
|
|
13
|
+
<a href="./README.ja.md">日本語</a> |
|
|
14
|
+
<a href="./README.pl.md">Polski</a> |
|
|
15
|
+
<a href="./README.ru.md">Русский</a> |
|
|
16
|
+
<a href="./README.bs.md">Bosanski</a> |
|
|
17
|
+
<a href="./README.ar.md">العربية</a> |
|
|
18
|
+
<a href="./README.no.md">Norsk</a> |
|
|
19
|
+
<a href="./README.pt-BR.md">Português (Brasil)</a> |
|
|
20
|
+
<a href="./README.th.md">ไทย</a> |
|
|
21
|
+
<a href="./README.tr.md">Türkçe</a> |
|
|
22
|
+
<a href="./README.uk.md">Українська</a> |
|
|
23
|
+
<a href="./README.bn.md">বাংলা</a> |
|
|
24
|
+
<a href="./README.el.md">Ελληνικά</a> |
|
|
25
|
+
<a href="./README.vi.md">Tiếng Việt</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="https://www.npmjs.com/package/speccrew"><img src="https://img.shields.io/npm/v/speccrew.svg" alt="npm version"></a>
|
|
30
|
+
<a href="https://www.npmjs.com/package/speccrew"><img src="https://img.shields.io/npm/dm/speccrew.svg" alt="npm downloads"></a>
|
|
31
|
+
<a href="https://github.com/charlesmu99/speccrew/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/speccrew.svg" alt="license"></a>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
> 讓任何軟體專案快速實現工程化落地的虛擬 AI 開發團隊
|
|
35
|
+
|
|
36
|
+
## 什麼是 SpecCrew?
|
|
37
|
+
|
|
38
|
+
SpecCrew 是一套嵌入式的虛擬 AI 開發團隊框架。它將專業的軟體工程流程(PRD → Feature Design → System Design → Dev → Test)轉化為可複用的 Agent 工作流,幫助開發團隊實現規範驅動開發(SDD),特別適合已有專案。
|
|
39
|
+
|
|
40
|
+
通過將 Agent 和 Skill 整合到現有專案,即可快速初始化專案文檔體系和虛擬軟體團隊,按照標準工程流程分步實現功能的新增和修改。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 解決 8 個核心問題
|
|
45
|
+
|
|
46
|
+
### 1. AI 忽略現有專案文檔(知識斷層)
|
|
47
|
+
**問題**:現有 SDD 或 Vibe Coding 方法依賴 AI 即時總結專案,容易遺漏關鍵上下文,導致開發結果偏離預期。
|
|
48
|
+
|
|
49
|
+
**解決**:`knowledge/` 知識庫作為專案的「事實來源」,沉澱架構設計、功能模組、業務流程等核心資訊,確保需求源頭不偏差。
|
|
50
|
+
|
|
51
|
+
### 2. 需求文檔直接轉技術文檔(內容遺漏)
|
|
52
|
+
**問題**:從 PRD 直接跳到詳細設計,容易遺漏需求細節,開發出的功能與需求脫節。
|
|
53
|
+
|
|
54
|
+
**解決**:增加 **Feature Design 文檔**環節,不考慮技術細節,只聚焦需求骨架:
|
|
55
|
+
- 包含哪些頁面和元件?
|
|
56
|
+
- 頁面操作流程
|
|
57
|
+
- 後端處理邏輯
|
|
58
|
+
- 資料儲存結構
|
|
59
|
+
|
|
60
|
+
開發階段只需基於特定技術棧「填肉」,確保功能「貼著骨頭(需求)」生長。
|
|
61
|
+
|
|
62
|
+
### 3. Agent 搜尋範圍不確定(不確定性)
|
|
63
|
+
**問題**:複雜專案中,AI 大範圍搜尋程式碼和文檔,結果不確定,難以保證一致性。
|
|
64
|
+
|
|
65
|
+
**解決**:明確的文檔目錄結構和模板,基於每個 Agent 所需內容設計,實現 **逐級披露、按需載入**,確保確定性。
|
|
66
|
+
|
|
67
|
+
### 4. 環節缺失、任務遺漏(流程斷裂)
|
|
68
|
+
**問題**:缺乏完整的工程流程覆蓋,容易遺漏關鍵步驟,品質難以保證。
|
|
69
|
+
|
|
70
|
+
**解決**:覆蓋軟體工程全環節:
|
|
71
|
+
```
|
|
72
|
+
PRD(需求)→ Feature Design(功能設計)→ API Contract(契約)
|
|
73
|
+
→ System Design(系統設計)→ Dev(開發)→ Test(測試)
|
|
74
|
+
```
|
|
75
|
+
- 每個環節產出物是下一環節的輸入
|
|
76
|
+
- 每步需人工確認後方可執行
|
|
77
|
+
- 所有 Agent 執行都有 todo 清單,完成後自檢
|
|
78
|
+
|
|
79
|
+
### 5. 團隊協作效率低(知識孤島)
|
|
80
|
+
**問題**:AI 程式設計經驗難以在團隊間共享,重複踩坑。
|
|
81
|
+
|
|
82
|
+
**解決**:所有 Agents、Skills 和相關文檔與原始碼一起進入 Git 版本管控:
|
|
83
|
+
- 一人優化,團隊共享
|
|
84
|
+
- 知識沉澱在程式碼庫中
|
|
85
|
+
- 提升團隊協同效率
|
|
86
|
+
|
|
87
|
+
### 7. 單 Agent 上下文過長(效能瓶頸)
|
|
88
|
+
**問題**:大型複雜任務超出單 Agent 上下文視窗,導致理解偏差、輸出品質下降。
|
|
89
|
+
|
|
90
|
+
**解決**:**子 Agent 自動調派機制**:
|
|
91
|
+
- 複雜任務自動識別並拆分為子任務
|
|
92
|
+
- 每個子任務由獨立子 Agent 執行,上下文隔離
|
|
93
|
+
- 父 Agent 協調彙總,確保整體一致性
|
|
94
|
+
- 避免單 Agent 上下文膨脹,保障輸出品質
|
|
95
|
+
|
|
96
|
+
### 8. 需求迭代混亂(管理困難)
|
|
97
|
+
**問題**:多個需求混雜在同一分支,相互影響,難以追蹤和回滾。
|
|
98
|
+
|
|
99
|
+
**解決**:**每個需求作為獨立專案**:
|
|
100
|
+
- 每個需求建立獨立迭代目錄 `iterations/iXXX-[需求名]/`
|
|
101
|
+
- 完整隔離:文檔、設計、程式碼、測試獨立管理
|
|
102
|
+
- 快速迭代:小粒度交付,快速驗證,快速上線
|
|
103
|
+
- 靈活歸檔:完成後歸檔至 `archive/`,歷史清晰可追溯
|
|
104
|
+
|
|
105
|
+
### 6. 文檔更新滯後(知識腐化)
|
|
106
|
+
**問題**:專案演進後文檔過時,AI 基於錯誤資訊工作。
|
|
107
|
+
|
|
108
|
+
**解決**:Agent 具有自動更新文檔的能力,即時同步專案變化,保持知識庫即時準確。
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 核心工作流程
|
|
113
|
+
|
|
114
|
+
```mermaid
|
|
115
|
+
graph LR
|
|
116
|
+
A[PRD<br/>需求文檔] --> B[Feature Design<br/>功能設計]
|
|
117
|
+
B --> C[API Contract<br/>介面契約]
|
|
118
|
+
C --> D[System Design<br/>系統設計]
|
|
119
|
+
D --> E[Dev<br/>開發實現]
|
|
120
|
+
E --> F[System Test<br/>系統測試]
|
|
121
|
+
F --> G[Archive<br/>歸檔]
|
|
122
|
+
|
|
123
|
+
H[Knowledge<br/>知識庫] -.-> A
|
|
124
|
+
H -.-> B
|
|
125
|
+
H -.-> D
|
|
126
|
+
H -.-> E
|
|
127
|
+
|
|
128
|
+
E -.-> H
|
|
129
|
+
F -.-> H
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 各階段說明
|
|
133
|
+
|
|
134
|
+
| 階段 | Agent | 輸入 | 輸出 | 人工確認 |
|
|
135
|
+
|------|-------|------|------|----------|
|
|
136
|
+
| PRD | PM | 使用者需求 | 產品需求文檔 | ✅ 必需 |
|
|
137
|
+
| Feature Design | Feature Designer | PRD | 功能設計文檔 + 介面契約 | ✅ 必需 |
|
|
138
|
+
| System Design | System Designer | Feature Spec | 前端/後端設計文檔 | ✅ 必需 |
|
|
139
|
+
| Dev | Dev | Design | 程式碼 + 任務記錄 | ✅ 必需 |
|
|
140
|
+
| System Test | Test Manager | Dev 產出 + Feature Spec | 測試案例 + 測試程式碼 + 測試報告 + Bug 報告 | ✅ 必需 |
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 與現有方案對比
|
|
145
|
+
|
|
146
|
+
| 維度 | Vibe Coding | Ralph 循環 | **SpecCrew** |
|
|
147
|
+
|------|-------------|------------|-------------|
|
|
148
|
+
| 文檔依賴 | 忽略現有文檔 | 依賴 AGENTS.md | **結構化知識庫** |
|
|
149
|
+
| 需求傳遞 | 直接編碼 | PRD → 程式碼 | **PRD → Feature Design → System Design → 程式碼** |
|
|
150
|
+
| 人工介入 | ❌ | 啟動時 | **每階段確認** |
|
|
151
|
+
| 流程完整性 | ❌ | 中等 | **完整工程流程** |
|
|
152
|
+
| 團隊協作 | 難共享 | 個人效率 | **團隊知識共享** |
|
|
153
|
+
| 上下文管理 | 單實例 | 單實例循環 | **子 Agent 自動調派** |
|
|
154
|
+
| 迭代管理 | 混雜 | 任務列表 | **需求即專案,獨立迭代** |
|
|
155
|
+
| 確定性 | ❌ | 中等 | **高(逐級披露)** |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 快速開始
|
|
160
|
+
|
|
161
|
+
### 前置條件
|
|
162
|
+
|
|
163
|
+
- Node.js >= 16.0.0
|
|
164
|
+
- 支援的 IDE:Qoder(預設)、Cursor、Claude Code
|
|
165
|
+
|
|
166
|
+
> **注意**:Cursor 和 Claude Code 的適配尚未在實際 IDE 環境中測試(程式碼層面已實現並通過 E2E 驗證,但未在真實 Cursor/Claude Code 中實測)。
|
|
167
|
+
|
|
168
|
+
### 1. 安裝 SpecCrew
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm install -g speccrew
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 2. 初始化專案
|
|
175
|
+
|
|
176
|
+
進入你的專案根目錄,執行初始化命令:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
cd /path/to/your-project
|
|
180
|
+
|
|
181
|
+
# 預設使用 Qoder
|
|
182
|
+
speccrew init
|
|
183
|
+
|
|
184
|
+
# 或指定 IDE
|
|
185
|
+
speccrew init --ide qoder
|
|
186
|
+
speccrew init --ide cursor
|
|
187
|
+
speccrew init --ide claude
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
初始化完成後,專案中會生成:
|
|
191
|
+
- `.qoder/agents/` / `.cursor/agents/` / `.claude/agents/` — 7 個 Agent 角色定義
|
|
192
|
+
- `.qoder/skills/` / `.cursor/skills/` / `.claude/skills/` — 38 個 Skill 工作流
|
|
193
|
+
- `speccrew-workspace/` — 工作區(迭代目錄、知識庫、文檔模板)
|
|
194
|
+
- `.speccrewrc` — SpecCrew 配置檔案
|
|
195
|
+
|
|
196
|
+
後續如需更新指定 IDE 的 Agents 和 Skills:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
speccrew update --ide cursor
|
|
200
|
+
speccrew update --ide claude
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 3. 開始開發流程
|
|
204
|
+
|
|
205
|
+
按照標準工程流程逐步推進:
|
|
206
|
+
|
|
207
|
+
1. **PRD**:由產品經理 Agent 分析需求,生成產品需求文檔
|
|
208
|
+
2. **Feature Design**:由功能設計師 Agent 生成功能設計文檔 + API 契約
|
|
209
|
+
3. **System Design**:由系統設計師 Agent 按端(前端/後端/移動端/桌面端)生成系統設計文檔
|
|
210
|
+
4. **Dev**:由系統開發者 Agent 按端並行實現開發
|
|
211
|
+
5. **System Test**:由測試管理員 Agent 協調三階段測試(案例設計 → 程式碼生成 → 執行報告)
|
|
212
|
+
6. **Archive**:歸檔迭代
|
|
213
|
+
|
|
214
|
+
> 每個階段產出物需人工確認後方可進入下一階段。
|
|
215
|
+
|
|
216
|
+
### 4. 其他 CLI 命令
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
speccrew list # 列出已安裝的 agents 和 skills
|
|
220
|
+
speccrew doctor # 診斷環境和安裝狀態
|
|
221
|
+
speccrew update # 更新 agents 和 skills 到最新版本
|
|
222
|
+
speccrew uninstall # 解除安裝 SpecCrew(--all 同時刪除工作區)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
📖 **詳細使用指南**:安裝完成後,查看 [快速開始文檔](docs/GETTING-STARTED.zh-TW.md) 了解完整的工作流程和各 Agent 對話指南。
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 目錄結構
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
your-project/
|
|
233
|
+
├── .qoder/ # IDE 配置目錄(Qoder 範例)
|
|
234
|
+
│ ├── agents/ # 7 個角色 Agent
|
|
235
|
+
│ │ ├── speccrew-team-leader.md # 團隊領導:全局調度與迭代管理
|
|
236
|
+
│ │ ├── speccrew-product-manager.md # 產品經理:需求分析與 PRD
|
|
237
|
+
│ │ ├── speccrew-feature-designer.md # 功能設計師:Feature Design + API 契約
|
|
238
|
+
│ │ ├── speccrew-system-designer.md # 系統設計師:按端生成系統設計
|
|
239
|
+
│ │ ├── speccrew-system-developer.md # 系統開發者:按端並行開發
|
|
240
|
+
│ │ ├── speccrew-test-manager.md # 測試管理員:三階段測試協調
|
|
241
|
+
│ │ └── speccrew-task-worker.md # 任務工人:並行子任務執行
|
|
242
|
+
│ └── skills/ # 38 個 Skill(按職能分組)
|
|
243
|
+
│ ├── speccrew-pm-*/ # 產品管理(需求分析、需求評估)
|
|
244
|
+
│ ├── speccrew-fd-*/ # 功能設計(Feature Design、API 契約)
|
|
245
|
+
│ ├── speccrew-sd-*/ # 系統設計(前端/後端/移動端/桌面端)
|
|
246
|
+
│ ├── speccrew-dev-*/ # 開發實現(前端/後端/移動端/桌面端)
|
|
247
|
+
│ ├── speccrew-test-*/ # 測試(案例設計/程式碼生成/執行報告)
|
|
248
|
+
│ ├── speccrew-knowledge-bizs-*/ # 業務知識庫(API分析/UI分析/模組分類等)
|
|
249
|
+
│ ├── speccrew-knowledge-techs-*/ # 技術知識庫(技術棧生成/規約/索引等)
|
|
250
|
+
│ ├── speccrew-knowledge-graph-*/ # 知識圖譜(讀寫查詢)
|
|
251
|
+
│ └── speccrew-*/ # 工具類(診斷/時間戳/工作流等)
|
|
252
|
+
│
|
|
253
|
+
└── speccrew-workspace/ # 工作區(初始化時生成)
|
|
254
|
+
├── docs/ # 管理性文檔
|
|
255
|
+
│ ├── configs/ # 配置檔案(平台映射、技術棧映射等)
|
|
256
|
+
│ ├── rules/ # 規則配置
|
|
257
|
+
│ └── solutions/ # 解決方案文檔
|
|
258
|
+
│
|
|
259
|
+
├── iterations/ # 迭代專案(動態生成)
|
|
260
|
+
│ └── {序號}-{類型}-{名稱}/
|
|
261
|
+
│ ├── 00.docs/ # 原始需求文檔
|
|
262
|
+
│ ├── 01.product-requirement/ # 產品需求文檔
|
|
263
|
+
│ ├── 02.feature-design/ # 功能設計
|
|
264
|
+
│ ├── 03.system-design/ # 系統設計
|
|
265
|
+
│ ├── 04.development/ # 開發階段
|
|
266
|
+
│ ├── 05.system-test/ # 系統測試
|
|
267
|
+
│ └── 06.delivery/ # 交付階段
|
|
268
|
+
│
|
|
269
|
+
├── iteration-archives/ # 迭代歸檔
|
|
270
|
+
│
|
|
271
|
+
└── knowledges/ # 知識庫
|
|
272
|
+
├── base/ # 基礎/元資料
|
|
273
|
+
│ ├── diagnosis-reports/ # 診斷報告
|
|
274
|
+
│ ├── sync-state/ # 同步狀態
|
|
275
|
+
│ └── tech-debts/ # 技術債
|
|
276
|
+
├── bizs/ # 業務知識
|
|
277
|
+
│ └── {platform-type}/{module-name}/
|
|
278
|
+
└── techs/ # 技術知識
|
|
279
|
+
└── {platform-id}/
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 核心設計原則
|
|
285
|
+
|
|
286
|
+
1. **規範驅動**:先寫規範,再由規範「長出」程式碼
|
|
287
|
+
2. **逐級披露**:Agent 從最小入口開始,按需獲取資訊
|
|
288
|
+
3. **人工確認**:每階段產出需人工確認,避免 AI 跑偏
|
|
289
|
+
4. **上下文隔離**:大任務拆分為小粒度、上下文隔離的子任務
|
|
290
|
+
5. **子 Agent 協作**:複雜任務自動調派子 Agent,避免單 Agent 上下文膨脹
|
|
291
|
+
6. **快速迭代**:每個需求作為獨立專案,快速交付、快速驗證
|
|
292
|
+
7. **知識共享**:所有配置與原始碼一起 Git 管控
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 適用場景
|
|
297
|
+
|
|
298
|
+
### ✅ 推薦使用
|
|
299
|
+
- 需要規範流程的中大型專案
|
|
300
|
+
- 團隊協作的軟體開發
|
|
301
|
+
- 遺留專案的工程化改造
|
|
302
|
+
- 需要長期維護的產品
|
|
303
|
+
|
|
304
|
+
### ❌ 不太適合
|
|
305
|
+
- 個人快速原型驗證
|
|
306
|
+
- 探索性、需求極不確定的專案
|
|
307
|
+
- 一次性腳本或工具
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 更多資訊
|
|
312
|
+
|
|
313
|
+
- **Agent 知識地圖**: [speccrew-workspace/docs/agent-knowledge-map.md](./speccrew-workspace/docs/agent-knowledge-map.md)
|
|
314
|
+
- **npm**: https://www.npmjs.com/package/speccrew
|
|
315
|
+
- **GitHub**: https://github.com/charlesmu99/speccrew
|
|
316
|
+
- **Gitee**: https://gitee.com/amutek/speccrew
|
|
317
|
+
- **Qoder IDE**: https://qoder.com/
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
> **SpecCrew 不是取代開發者,而是自動化那些枯燥的部分,讓團隊能專注於更有價值的工作。**
|
package/bin/cli.js
CHANGED
|
@@ -40,7 +40,11 @@ switch (command) {
|
|
|
40
40
|
require('../lib/commands/doctor').run(projectRoot, args);
|
|
41
41
|
break;
|
|
42
42
|
case 'uninstall':
|
|
43
|
-
require('../lib/commands/uninstall').run(projectRoot, args)
|
|
43
|
+
require('../lib/commands/uninstall').run(projectRoot, args).then((result) => {
|
|
44
|
+
if (!result) {
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
44
48
|
break;
|
|
45
49
|
case 'list':
|
|
46
50
|
require('../lib/commands/list').run(projectRoot, args);
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
// Get package version
|
|
8
|
+
function getPackageVersion() {
|
|
9
|
+
try {
|
|
10
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
11
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
12
|
+
return packageJson.version;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return 'unknown';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Get npm package root directory
|
|
19
|
+
function getPackageRoot() {
|
|
20
|
+
return path.resolve(__dirname, '..');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check if a path is a speccrew file (starts with speccrew-)
|
|
24
|
+
function isSpeccrewFile(name) {
|
|
25
|
+
return name.startsWith('speccrew-');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Count agents and skills in the package
|
|
29
|
+
function countPackageResources(packageRoot) {
|
|
30
|
+
let agentCount = 0;
|
|
31
|
+
let skillCount = 0;
|
|
32
|
+
|
|
33
|
+
const agentsDir = path.join(packageRoot, '.speccrew', 'agents');
|
|
34
|
+
const skillsDir = path.join(packageRoot, '.speccrew', 'skills');
|
|
35
|
+
|
|
36
|
+
if (fs.existsSync(agentsDir)) {
|
|
37
|
+
const entries = fs.readdirSync(agentsDir, { withFileTypes: true });
|
|
38
|
+
agentCount = entries.filter(e => isSpeccrewFile(e.name)).length;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (fs.existsSync(skillsDir)) {
|
|
42
|
+
const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
43
|
+
skillCount = entries.filter(e => isSpeccrewFile(e.name)).length;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { agentCount, skillCount };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Detect IDE directories in the project
|
|
50
|
+
function detectIDE(projectRoot) {
|
|
51
|
+
const ideConfigs = [
|
|
52
|
+
{ id: 'qoder', name: 'Qoder', baseDir: '.qoder' },
|
|
53
|
+
{ id: 'cursor', name: 'Cursor', baseDir: '.cursor' },
|
|
54
|
+
{ id: 'claude', name: 'Claude', baseDir: '.claude' },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const detected = [];
|
|
58
|
+
for (const config of ideConfigs) {
|
|
59
|
+
const basePath = path.join(projectRoot, config.baseDir);
|
|
60
|
+
if (fs.existsSync(basePath)) {
|
|
61
|
+
detected.push(config);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return detected;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Ask user for confirmation
|
|
68
|
+
function askConfirm(message) {
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
const rl = readline.createInterface({
|
|
71
|
+
input: process.stdin,
|
|
72
|
+
output: process.stdout,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
rl.question(message, (answer) => {
|
|
76
|
+
rl.close();
|
|
77
|
+
const normalized = answer.trim().toLowerCase();
|
|
78
|
+
resolve(normalized === '' || normalized === 'y' || normalized === 'yes');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Main postinstall logic
|
|
84
|
+
async function main() {
|
|
85
|
+
const version = getPackageVersion();
|
|
86
|
+
const packageRoot = getPackageRoot();
|
|
87
|
+
|
|
88
|
+
// Get the project directory where npm install was run
|
|
89
|
+
const initCwd = process.env.INIT_CWD;
|
|
90
|
+
|
|
91
|
+
// If INIT_CWD is not set or doesn't exist, just show welcome message
|
|
92
|
+
if (!initCwd || !fs.existsSync(initCwd)) {
|
|
93
|
+
console.log(`\nSpecCrew v${version}\n`);
|
|
94
|
+
console.log("Run 'speccrew init' in your project directory to get started.\n");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Count resources in the package
|
|
99
|
+
const { agentCount, skillCount } = countPackageResources(packageRoot);
|
|
100
|
+
|
|
101
|
+
// Detect IDE in the project directory
|
|
102
|
+
const detectedIDEs = detectIDE(initCwd);
|
|
103
|
+
|
|
104
|
+
// Display welcome banner
|
|
105
|
+
console.log(`\nSpecCrew v${version}\n`);
|
|
106
|
+
|
|
107
|
+
// Display installation summary
|
|
108
|
+
console.log('Installation Summary:');
|
|
109
|
+
console.log(` Project: ${initCwd}`);
|
|
110
|
+
|
|
111
|
+
if (detectedIDEs.length === 0) {
|
|
112
|
+
console.log(' IDE: Not detected (use --ide to specify)');
|
|
113
|
+
} else if (detectedIDEs.length === 1) {
|
|
114
|
+
console.log(` IDE: ${detectedIDEs[0].name} (${detectedIDEs[0].baseDir}/)`);
|
|
115
|
+
} else {
|
|
116
|
+
console.log(` IDE: ${detectedIDEs.map(i => i.name).join(', ')}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log(` Agents: ${agentCount} agents`);
|
|
120
|
+
console.log(` Skills: ${skillCount} skills`);
|
|
121
|
+
console.log(` Workspace: speccrew-workspace/`);
|
|
122
|
+
console.log(` Docs: README + Getting Started guides\n`);
|
|
123
|
+
|
|
124
|
+
// Non-interactive environment check
|
|
125
|
+
if (!process.stdin.isTTY) {
|
|
126
|
+
console.log("Run 'speccrew init' in your project directory to complete installation.\n");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// No IDE detected - prompt user to specify
|
|
131
|
+
if (detectedIDEs.length === 0) {
|
|
132
|
+
console.log('No supported IDE detected in your project directory.');
|
|
133
|
+
console.log("Run 'speccrew init --ide <name>' to specify an IDE.");
|
|
134
|
+
console.log('Supported IDEs: qoder, cursor, claude\n');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Ask for confirmation
|
|
139
|
+
try {
|
|
140
|
+
const confirmed = await askConfirm('Proceed with installation? (Y/n) ');
|
|
141
|
+
|
|
142
|
+
if (confirmed) {
|
|
143
|
+
// Import and run init
|
|
144
|
+
const { runInit } = require('../lib/commands/init.js');
|
|
145
|
+
await runInit({ projectRoot: initCwd, skipConfirm: true });
|
|
146
|
+
} else {
|
|
147
|
+
console.log('\nInstallation skipped. You can run \'speccrew init\' later in your project directory.\n');
|
|
148
|
+
}
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.log(`\nInstallation skipped. You can run 'speccrew init' later in your project directory.\n`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Run main with error handling - postinstall failures should not block npm install
|
|
155
|
+
main().catch(() => {
|
|
156
|
+
console.log('\nPostinstall hook encountered an issue. You can run \'speccrew init\' manually.\n');
|
|
157
|
+
});
|