gsi-protocol-installer 1.0.2__tar.gz

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.
@@ -0,0 +1,74 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+ venv/
24
+ ENV/
25
+ env/
26
+ .venv
27
+
28
+ # PyPI (important!)
29
+ .pypirc
30
+ !.pypirc.example
31
+
32
+ # TypeScript / JavaScript
33
+ node_modules/
34
+ npm-debug.log*
35
+ yarn-debug.log*
36
+ yarn-error.log*
37
+ .npm
38
+ .eslintcache
39
+ *.tsbuildinfo
40
+
41
+ # IDEs
42
+ .vscode/
43
+ .idea/
44
+ *.swp
45
+ *.swo
46
+ *~
47
+ .DS_Store
48
+
49
+ # Testing
50
+ .pytest_cache/
51
+ .coverage
52
+ htmlcov/
53
+ .tox/
54
+ .hypothesis/
55
+ *.cover
56
+
57
+ # Generated files during workflow
58
+ features/*.generated.*
59
+ structure/*.generated.*
60
+ implementation/*.generated.*
61
+ verification/*.generated.*
62
+
63
+ # Temporary files
64
+ *.tmp
65
+ *.bak
66
+ *.log
67
+
68
+ # OS
69
+ .DS_Store
70
+ Thumbs.db
71
+
72
+ # Virtual environments for testing
73
+ test_env/
74
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 James
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ # Include essential files
2
+ include LICENSE
3
+ include README.md
4
+ include pyproject.toml
5
+ include gsi_installer.py
6
+
7
+ # Exclude unnecessary files
8
+ exclude .gitignore
9
+ exclude .git
10
+ recursive-exclude * __pycache__
11
+ recursive-exclude * *.py[co]
12
+ recursive-exclude * .DS_Store
@@ -0,0 +1,488 @@
1
+ Metadata-Version: 2.4
2
+ Name: gsi-protocol-installer
3
+ Version: 1.0.2
4
+ Summary: Installer for GSI-Protocol workflow commands (Claude Code & Codex)
5
+ Project-URL: Homepage, https://github.com/CodeMachine0121/GSI-Protocol
6
+ Project-URL: Documentation, https://github.com/CodeMachine0121/GSI-Protocol/blob/main/README.md
7
+ Project-URL: Repository, https://github.com/CodeMachine0121/GSI-Protocol
8
+ Project-URL: Issues, https://github.com/CodeMachine0121/GSI-Protocol/issues
9
+ Project-URL: Changelog, https://github.com/CodeMachine0121/GSI-Protocol/blob/main/CODEX_SUPPORT_CHANGELOG.md
10
+ Author-email: James Hsueh <asdfg55887@gmail.com>
11
+ Maintainer: GSI-Protocol Contributors
12
+ License: MIT
13
+ License-File: LICENSE
14
+ Keywords: ai,bdd,claude,codex,gherkin,gsi-protocol,sdd,spec-driven-development,workflow
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Environment :: Console
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Software Development :: Code Generators
25
+ Classifier: Topic :: Software Development :: Quality Assurance
26
+ Classifier: Topic :: Software Development :: Testing
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+
30
+ # GSI-Protocol(中文)
31
+
32
+ > **Gherkin → 架構 → 實作**
33
+ >
34
+ > 一個語言無關的工作流程,使用 AI 代理和 BDD 原則建立可驗證的軟體功能。
35
+
36
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
37
+
38
+ ## 🎯 什麼是 GSI-Protocol?
39
+
40
+ GSI-Protocol 是一個 AI 驅動的工作流程插件,實作了**規格驅動開發(SDD)**。它透過嚴格的四階段流程,將模糊的需求轉化為經過驗證、可用於生產環境的程式碼。
41
+
42
+ **支援平台:**
43
+ - ✅ Claude Code
44
+ - ✅ Codex (OpenAI)
45
+
46
+ ### 核心理念
47
+
48
+ **"規格 → 架構 → 實作 → 驗證"**
49
+
50
+ 將業務邏輯、技術架構、程式撰寫和品質保證分離到不同階段,以最小化 AI 幻覺並最大化精確度。
51
+
52
+ ### 主要特性
53
+
54
+ - 🌍 **語言無關**:支援 Python、TypeScript、Go、Java、Rust、C# 等等
55
+ - 🎯 **框架獨立**:不綁定任何特定函式庫或框架
56
+ - 📝 **基於 BDD**:使用 Gherkin 撰寫清晰、可測試的規格
57
+ - 🏗️ **專案感知**:自動掃描並遵循既有專案架構
58
+ - ✅ **可驗證**:自動根據規格進行驗證
59
+ - 🔄 **模組化**:可獨立執行各階段或完整工作流程
60
+
61
+ ---
62
+
63
+ ## 📦 快速開始
64
+
65
+ ### 安裝
66
+
67
+ **選項 1:使用 uvx(最推薦,無需安裝)**
68
+
69
+ ```bash
70
+ uvx gsi-protocol-installer
71
+ ```
72
+
73
+ **選項 2:使用 pipx**
74
+
75
+ ```bash
76
+ pipx run gsi-protocol-installer
77
+ ```
78
+
79
+ **選項 3:直接執行 Python**
80
+
81
+ ```bash
82
+ # 下載並執行
83
+ wget https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/gsi_installer.py
84
+ python3 gsi_installer.py
85
+
86
+ # 或使用 curl
87
+ curl -O https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/gsi_installer.py
88
+ python3 gsi_installer.py
89
+ ```
90
+
91
+ 安裝程式會引導您:
92
+ 1. 選擇 AI 平台(Claude Code、Codex 或兩者)
93
+ 2. 選擇安裝位置(全域或當前專案)
94
+ 3. 自動完成安裝
95
+
96
+ **選項 4:手動全域安裝**
97
+
98
+ **Claude Code:**
99
+ ```bash
100
+ mkdir -p ~/.claude/commands
101
+ cd ~/.claude/commands
102
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-auto.md -o sdd-auto.md
103
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-spec.md -o sdd-spec.md
104
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-arch.md -o sdd-arch.md
105
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-impl.md -o sdd-impl.md
106
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-verify.md -o sdd-verify.md
107
+ ```
108
+
109
+ **Codex (OpenAI):**
110
+ ```bash
111
+ mkdir -p ~/.codex/prompts
112
+ cd ~/.codex/prompts
113
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-auto.md -o sdd-auto.md
114
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-spec.md -o sdd-spec.md
115
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-arch.md -o sdd-arch.md
116
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-impl.md -o sdd-impl.md
117
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-verify.md -o sdd-verify.md
118
+ ```
119
+
120
+ 完成後,可在任何專案中使用 `/sdd-auto`、`/sdd-spec` 等全域指令。
121
+
122
+ > 📖 查看 [安裝指南](docs/INSTALL.md) 了解詳細說明
123
+
124
+ ### 第一次使用(2 分鐘)
125
+
126
+ ```bash
127
+ # 使用 uvx 安裝
128
+ uvx gsi-protocol-installer
129
+
130
+ # 選擇平台和安裝位置後,進入您的專案
131
+ cd your-project
132
+
133
+ # 自動模式 - 生成所有內容
134
+ /sdd-auto Create a shopping cart in TypeScript with add, remove, checkout functions
135
+
136
+ # 手動模式 - 逐步執行
137
+ /sdd-spec Create a shopping cart with add, remove, checkout
138
+ /sdd-arch features/shopping_cart.feature
139
+ /sdd-impl features/shopping_cart.feature
140
+ /sdd-verify features/shopping_cart.feature
141
+ ```
142
+
143
+ ---
144
+
145
+ ## 📚 文件
146
+
147
+ | 文件 | 說明 |
148
+ |----------|-------------|
149
+ | **[快速入門指南](docs/QUICKSTART.md)** | 5 分鐘教學 |
150
+ | **[安裝指南](docs/INSTALL.md)** | 詳細安裝說明 |
151
+ | **[Python 安裝器](docs/PYTHON_INSTALLER.md)** | uvx 安裝方式(推薦) |
152
+ | **[平台支援](docs/PLATFORM_SUPPORT.md)** | Claude Code vs Codex 比較 |
153
+ | **[指令參考](docs/COMMANDS.md)** | 完整指令文件 |
154
+ | **[語言指南](docs/LANGUAGE_GUIDE.md)** | 多語言支援指南 |
155
+ | **[工作流程定義](docs/expected_workflow.md)** | 詳細方法論 |
156
+ | **[貢獻指南](CONTRIBUTING.md)** | 如何貢獻 |
157
+
158
+ ---
159
+
160
+ ## 🔄 工作流程概覽
161
+
162
+ ### 四個階段
163
+
164
+ ```
165
+ Phase 1:規格(PM)
166
+
167
+ Gherkin .feature 檔案
168
+
169
+ Phase 2:架構(架構師)
170
+
171
+ 架構設計文件(繁中 Markdown)
172
+
173
+ Phase 3:實作(工程師)
174
+
175
+ 可運行的程式碼(依專案架構)
176
+
177
+ Phase 4:驗證(QA)
178
+
179
+ ✅ 驗證結論報告
180
+ ```
181
+
182
+ ### 指令
183
+
184
+ | 指令 | 用途 | 何時使用 |
185
+ |---------|---------|-------------|
186
+ | `/sdd-auto` | 自動執行全部 4 個階段 | 快速原型、簡單功能 |
187
+ | `/sdd-spec` | 生成 Gherkin 規格 | 定義需求 |
188
+ | `/sdd-arch` | 設計資料模型與介面 | 審查結構 |
189
+ | `/sdd-impl` | 實作邏輯 | 撰寫程式碼 |
190
+ | `/sdd-verify` | 根據規格驗證 | 測試實作 |
191
+
192
+ ---
193
+
194
+ ## 💡 範例
195
+
196
+ ### 輸入
197
+
198
+ ```
199
+ /sdd-auto Implement a VIP discount system in Python where VIP users get 20% off purchases over $100
200
+ ```
201
+
202
+ ### 輸出
203
+
204
+ **階段 1:規格** (`features/vip_discount.feature`)
205
+ ```gherkin
206
+ Feature: VIP Discount
207
+ Scenario: Apply discount to VIP user
208
+ Given user is VIP
209
+ When user makes a purchase of 1000 USD
210
+ Then final price should be 800 USD
211
+ ```
212
+
213
+ **Phase 2:架構** (`docs/features/vip_discount/architecture.md`)
214
+ ```markdown
215
+ # VIP 折扣系統 - 架構設計
216
+
217
+ ## 1. 專案上下文
218
+ - 程式語言:Python
219
+ - 架構模式:Service Layer
220
+
221
+ ## 3. 資料模型
222
+ - UserType(列舉):VIP, NORMAL
223
+ - DiscountResult(實體):final_price, discount
224
+
225
+ ## 4. 服務介面
226
+ - calculate_discount(amount, user_type) → DiscountResult
227
+ ```
228
+
229
+ **Phase 3:實作** (依 architecture.md 指定位置)
230
+ ```python
231
+ # src/services/discount_service.py
232
+ def calculate_discount(amount: float, user_type: UserType) -> DiscountResult:
233
+ if user_type == UserType.VIP and amount >= 100:
234
+ discount = amount * 0.2
235
+ return DiscountResult(amount - discount, discount)
236
+ return DiscountResult(amount, 0)
237
+ ```
238
+
239
+ **Phase 4:驗證結論** (`docs/features/vip_discount/conclusion.md`)
240
+ ```markdown
241
+ ## 3. 摘要
242
+ - 架構:2/2 通過
243
+ - 情境:2/2 通過
244
+ - **狀態:** ✅ 完成
245
+ ```
246
+
247
+ ---
248
+
249
+ ## 🌐 多語言支援
250
+
251
+ 相同的工作流程,不同的語言:
252
+
253
+ <details>
254
+ <summary><b>Python</b></summary>
255
+
256
+ ```python
257
+ from dataclasses import dataclass
258
+ from abc import ABC, abstractmethod
259
+
260
+ @dataclass
261
+ class User:
262
+ id: str
263
+ type: UserType
264
+
265
+ class IUserService(ABC):
266
+ @abstractmethod
267
+ def authenticate(self, credentials: Credentials) -> User:
268
+ pass
269
+ ```
270
+ </details>
271
+
272
+ <details>
273
+ <summary><b>TypeScript</b></summary>
274
+
275
+ ```typescript
276
+ interface User {
277
+ id: string;
278
+ type: UserType;
279
+ }
280
+
281
+ interface IUserService {
282
+ authenticate(credentials: Credentials): User;
283
+ }
284
+ ```
285
+ </details>
286
+
287
+ <details>
288
+ <summary><b>Go</b></summary>
289
+
290
+ ```go
291
+ type User struct {
292
+ ID string
293
+ Type UserType
294
+ }
295
+
296
+ type UserService interface {
297
+ Authenticate(credentials Credentials) (User, error)
298
+ }
299
+ ```
300
+ </details>
301
+
302
+ 更多語言請參閱 [語言指南](docs/LANGUAGE_GUIDE.md),包含 Rust、Java、C# 等。
303
+
304
+ ---
305
+
306
+ ## 🎓 使用案例
307
+
308
+ ### 1. API 開發
309
+ ```bash
310
+ /sdd-spec Design a RESTful API for blog posts (CRUD operations)
311
+ /sdd-arch features/blog_api.feature
312
+ # 獲得清晰的 API 契約和資料結構
313
+ ```
314
+
315
+ ### 2. 功能實作
316
+ ```bash
317
+ /sdd-auto Implement user authentication with JWT tokens in TypeScript
318
+ # 幾分鐘內獲得可運行、已測試的程式碼
319
+ ```
320
+
321
+ ### 3. 遺留程式碼重構
322
+ ```bash
323
+ /sdd-spec The payment module should support credit card, PayPal, and crypto
324
+ # 在重構前定義清晰的需求
325
+ ```
326
+
327
+ ### 4. 團隊協作
328
+ ```bash
329
+ # PM:定義需求
330
+ /sdd-spec User registration with email verification
331
+
332
+ # 架構師:審查並設計
333
+ /sdd-arch features/user_registration.feature
334
+
335
+ # 工程師:實作
336
+ /sdd-impl features/user_registration.feature
337
+
338
+ # QA:驗證
339
+ /sdd-verify features/user_registration.feature
340
+ ```
341
+
342
+ ---
343
+
344
+ ## 📁 專案結構
345
+
346
+ 執行 SDD 工作流程後的輸出:
347
+
348
+ ```
349
+ your-project/
350
+ ├── features/ # Phase 1: Gherkin 規格
351
+ │ └── {feature}.feature
352
+ ├── docs/
353
+ │ └── features/
354
+ │ └── {feature}/
355
+ │ ├── architecture.md # Phase 2: 架構設計(繁中)
356
+ │ └── conclusion.md # Phase 4: 驗證結論
357
+ └── src/ # Phase 3: 實作程式碼
358
+ ├── models/ # 依專案既有架構
359
+ │ └── {Feature}Model.{ext}
360
+ └── services/
361
+ └── {Feature}Service.{ext}
362
+ ```
363
+
364
+ GSI-Protocol 儲存庫結構:
365
+
366
+ ```
367
+ GSI-Protocol/
368
+ ├── README.md # 本檔案
369
+ ├── CONTRIBUTING.md # 貢獻指南
370
+ ├── LICENSE # MIT 授權
371
+ ├── gsi_installer.py # Python 安裝器
372
+ ├── pyproject.toml # Python 專案配置
373
+ ├── .claude/
374
+ │ └── commands/ # Claude Code slash 指令
375
+ │ ├── sdd-auto.md # 自動工作流程
376
+ │ ├── sdd-spec.md # Phase 1
377
+ │ ├── sdd-arch.md # Phase 2
378
+ │ ├── sdd-impl.md # Phase 3
379
+ │ └── sdd-verify.md # Phase 4
380
+ ├── .codex/
381
+ │ └── prompts/ # Codex (OpenAI) prompts
382
+ │ ├── sdd-auto.md # 自動工作流程
383
+ │ ├── sdd-spec.md # Phase 1
384
+ │ ├── sdd-arch.md # Phase 2
385
+ │ ├── sdd-impl.md # Phase 3
386
+ │ └── sdd-verify.md # Phase 4
387
+ ├── docs/ # 文件
388
+ │ ├── QUICKSTART.md # 快速入門指南
389
+ │ ├── INSTALL.md # 安裝指南
390
+ │ ├── PYTHON_INSTALLER.md # Python 安裝器說明
391
+ │ ├── PLATFORM_SUPPORT.md # 平台支援說明
392
+ │ ├── COMMANDS.md # 指令參考
393
+ │ ├── LANGUAGE_GUIDE.md # 語言支援
394
+ │ └── expected_workflow.md # 工作流程細節
395
+ └── prompts/ # 代理提示(參考)
396
+ ├── pm_agent.md
397
+ ├── architect_agent.md
398
+ ├── engineer_agent.md
399
+ └── qa_agent.md
400
+ ```
401
+
402
+ ---
403
+
404
+ ## 🚀 優勢
405
+
406
+ ### 對開發者
407
+ - ✅ **更快開發**:自動生成樣板程式碼和結構
408
+ - ✅ **更高品質**:系統化方法減少 bug
409
+ - ✅ **清晰需求**:Gherkin 規格消除歧義
410
+
411
+ ### 對團隊
412
+ - ✅ **共同語言**:所有人都能理解的 BDD 規格
413
+ - ✅ **更好溝通**:PM、架構師、工程師、QA 各有明確階段
414
+ - ✅ **可維護程式碼**:每一行都可追溯到需求
415
+
416
+ ### 對專案
417
+ - ✅ **語言彈性**:切換語言不需改變方法論
418
+ - ✅ **框架無關**:使用任何函式庫或框架
419
+ - ✅ **可擴展**:適用於簡單功能到複雜系統
420
+
421
+ ---
422
+
423
+ ## 🔧 需求
424
+
425
+ - **AI 平台(擇一或兩者):**
426
+ - Claude Code CLI,或
427
+ - Codex (OpenAI)
428
+ - **安裝工具:**
429
+ - Python 3.10+
430
+ - uvx/pipx(推薦)或 pip
431
+ - Git
432
+ - 目標語言執行環境(Python 3.8+、Node.js 16+、Go 1.19+ 等)
433
+
434
+ ---
435
+
436
+ ## 📖 了解更多
437
+
438
+ - 📝 [快速入門(5 分鐘)](docs/QUICKSTART.md)
439
+ - 📚 [完整文件](docs/)
440
+ - 🌍 [語言支援](docs/LANGUAGE_GUIDE.md)
441
+ - 💬 [GitHub 討論](https://github.com/CodeMachine0121/GSI-Protocol/discussions)
442
+
443
+ ---
444
+
445
+ ## 🤝 貢獻
446
+
447
+ 我們歡迎貢獻!請參閱 [CONTRIBUTING.md](CONTRIBUTING.md) 了解指南。
448
+
449
+ ### 貢獻方式
450
+ - 🐛 回報 bug
451
+ - 💡 建議功能
452
+ - 📝 改善文件
453
+ - 🌍 新增語言範例
454
+ - 🔧 提交 pull request
455
+
456
+ ---
457
+
458
+ ## 📄 授權
459
+
460
+ MIT 授權 - 詳見 [LICENSE](LICENSE) 檔案。
461
+
462
+ ---
463
+
464
+ ## 🙏 致謝
465
+
466
+ 使用以下工具建置:
467
+ - [Claude Code](https://claude.ai/claude-code) - AI 驅動開發
468
+ - [Codex (OpenAI)](https://openai.com/blog/openai-codex) - AI 程式碼生成
469
+ - [Gherkin](https://cucumber.io/docs/gherkin/) - BDD 規格語言
470
+ - 靈感來自測試驅動開發和行為驅動開發原則
471
+
472
+ ---
473
+
474
+ ## 📞 支援
475
+
476
+ - 📖 [文件](docs/)
477
+ - 💬 [GitHub Issues](https://github.com/CodeMachine0121/GSI-Protocol/issues)
478
+ - 💡 [討論](https://github.com/CodeMachine0121/GSI-Protocol/discussions)
479
+
480
+ ---
481
+
482
+ <div align="center">
483
+
484
+ **[⬆ 回到頂端](#gsi-protocol中文)**
485
+
486
+ 由開發者打造,為開發者服務 ❤️
487
+
488
+ </div>
@@ -0,0 +1,459 @@
1
+ # GSI-Protocol(中文)
2
+
3
+ > **Gherkin → 架構 → 實作**
4
+ >
5
+ > 一個語言無關的工作流程,使用 AI 代理和 BDD 原則建立可驗證的軟體功能。
6
+
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## 🎯 什麼是 GSI-Protocol?
10
+
11
+ GSI-Protocol 是一個 AI 驅動的工作流程插件,實作了**規格驅動開發(SDD)**。它透過嚴格的四階段流程,將模糊的需求轉化為經過驗證、可用於生產環境的程式碼。
12
+
13
+ **支援平台:**
14
+ - ✅ Claude Code
15
+ - ✅ Codex (OpenAI)
16
+
17
+ ### 核心理念
18
+
19
+ **"規格 → 架構 → 實作 → 驗證"**
20
+
21
+ 將業務邏輯、技術架構、程式撰寫和品質保證分離到不同階段,以最小化 AI 幻覺並最大化精確度。
22
+
23
+ ### 主要特性
24
+
25
+ - 🌍 **語言無關**:支援 Python、TypeScript、Go、Java、Rust、C# 等等
26
+ - 🎯 **框架獨立**:不綁定任何特定函式庫或框架
27
+ - 📝 **基於 BDD**:使用 Gherkin 撰寫清晰、可測試的規格
28
+ - 🏗️ **專案感知**:自動掃描並遵循既有專案架構
29
+ - ✅ **可驗證**:自動根據規格進行驗證
30
+ - 🔄 **模組化**:可獨立執行各階段或完整工作流程
31
+
32
+ ---
33
+
34
+ ## 📦 快速開始
35
+
36
+ ### 安裝
37
+
38
+ **選項 1:使用 uvx(最推薦,無需安裝)**
39
+
40
+ ```bash
41
+ uvx gsi-protocol-installer
42
+ ```
43
+
44
+ **選項 2:使用 pipx**
45
+
46
+ ```bash
47
+ pipx run gsi-protocol-installer
48
+ ```
49
+
50
+ **選項 3:直接執行 Python**
51
+
52
+ ```bash
53
+ # 下載並執行
54
+ wget https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/gsi_installer.py
55
+ python3 gsi_installer.py
56
+
57
+ # 或使用 curl
58
+ curl -O https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/gsi_installer.py
59
+ python3 gsi_installer.py
60
+ ```
61
+
62
+ 安裝程式會引導您:
63
+ 1. 選擇 AI 平台(Claude Code、Codex 或兩者)
64
+ 2. 選擇安裝位置(全域或當前專案)
65
+ 3. 自動完成安裝
66
+
67
+ **選項 4:手動全域安裝**
68
+
69
+ **Claude Code:**
70
+ ```bash
71
+ mkdir -p ~/.claude/commands
72
+ cd ~/.claude/commands
73
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-auto.md -o sdd-auto.md
74
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-spec.md -o sdd-spec.md
75
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-arch.md -o sdd-arch.md
76
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-impl.md -o sdd-impl.md
77
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.claude/commands/sdd-verify.md -o sdd-verify.md
78
+ ```
79
+
80
+ **Codex (OpenAI):**
81
+ ```bash
82
+ mkdir -p ~/.codex/prompts
83
+ cd ~/.codex/prompts
84
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-auto.md -o sdd-auto.md
85
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-spec.md -o sdd-spec.md
86
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-arch.md -o sdd-arch.md
87
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-impl.md -o sdd-impl.md
88
+ curl -sSL https://raw.githubusercontent.com/CodeMachine0121/GSI-Protocol/main/.codex/prompts/sdd-verify.md -o sdd-verify.md
89
+ ```
90
+
91
+ 完成後,可在任何專案中使用 `/sdd-auto`、`/sdd-spec` 等全域指令。
92
+
93
+ > 📖 查看 [安裝指南](docs/INSTALL.md) 了解詳細說明
94
+
95
+ ### 第一次使用(2 分鐘)
96
+
97
+ ```bash
98
+ # 使用 uvx 安裝
99
+ uvx gsi-protocol-installer
100
+
101
+ # 選擇平台和安裝位置後,進入您的專案
102
+ cd your-project
103
+
104
+ # 自動模式 - 生成所有內容
105
+ /sdd-auto Create a shopping cart in TypeScript with add, remove, checkout functions
106
+
107
+ # 手動模式 - 逐步執行
108
+ /sdd-spec Create a shopping cart with add, remove, checkout
109
+ /sdd-arch features/shopping_cart.feature
110
+ /sdd-impl features/shopping_cart.feature
111
+ /sdd-verify features/shopping_cart.feature
112
+ ```
113
+
114
+ ---
115
+
116
+ ## 📚 文件
117
+
118
+ | 文件 | 說明 |
119
+ |----------|-------------|
120
+ | **[快速入門指南](docs/QUICKSTART.md)** | 5 分鐘教學 |
121
+ | **[安裝指南](docs/INSTALL.md)** | 詳細安裝說明 |
122
+ | **[Python 安裝器](docs/PYTHON_INSTALLER.md)** | uvx 安裝方式(推薦) |
123
+ | **[平台支援](docs/PLATFORM_SUPPORT.md)** | Claude Code vs Codex 比較 |
124
+ | **[指令參考](docs/COMMANDS.md)** | 完整指令文件 |
125
+ | **[語言指南](docs/LANGUAGE_GUIDE.md)** | 多語言支援指南 |
126
+ | **[工作流程定義](docs/expected_workflow.md)** | 詳細方法論 |
127
+ | **[貢獻指南](CONTRIBUTING.md)** | 如何貢獻 |
128
+
129
+ ---
130
+
131
+ ## 🔄 工作流程概覽
132
+
133
+ ### 四個階段
134
+
135
+ ```
136
+ Phase 1:規格(PM)
137
+
138
+ Gherkin .feature 檔案
139
+
140
+ Phase 2:架構(架構師)
141
+
142
+ 架構設計文件(繁中 Markdown)
143
+
144
+ Phase 3:實作(工程師)
145
+
146
+ 可運行的程式碼(依專案架構)
147
+
148
+ Phase 4:驗證(QA)
149
+
150
+ ✅ 驗證結論報告
151
+ ```
152
+
153
+ ### 指令
154
+
155
+ | 指令 | 用途 | 何時使用 |
156
+ |---------|---------|-------------|
157
+ | `/sdd-auto` | 自動執行全部 4 個階段 | 快速原型、簡單功能 |
158
+ | `/sdd-spec` | 生成 Gherkin 規格 | 定義需求 |
159
+ | `/sdd-arch` | 設計資料模型與介面 | 審查結構 |
160
+ | `/sdd-impl` | 實作邏輯 | 撰寫程式碼 |
161
+ | `/sdd-verify` | 根據規格驗證 | 測試實作 |
162
+
163
+ ---
164
+
165
+ ## 💡 範例
166
+
167
+ ### 輸入
168
+
169
+ ```
170
+ /sdd-auto Implement a VIP discount system in Python where VIP users get 20% off purchases over $100
171
+ ```
172
+
173
+ ### 輸出
174
+
175
+ **階段 1:規格** (`features/vip_discount.feature`)
176
+ ```gherkin
177
+ Feature: VIP Discount
178
+ Scenario: Apply discount to VIP user
179
+ Given user is VIP
180
+ When user makes a purchase of 1000 USD
181
+ Then final price should be 800 USD
182
+ ```
183
+
184
+ **Phase 2:架構** (`docs/features/vip_discount/architecture.md`)
185
+ ```markdown
186
+ # VIP 折扣系統 - 架構設計
187
+
188
+ ## 1. 專案上下文
189
+ - 程式語言:Python
190
+ - 架構模式:Service Layer
191
+
192
+ ## 3. 資料模型
193
+ - UserType(列舉):VIP, NORMAL
194
+ - DiscountResult(實體):final_price, discount
195
+
196
+ ## 4. 服務介面
197
+ - calculate_discount(amount, user_type) → DiscountResult
198
+ ```
199
+
200
+ **Phase 3:實作** (依 architecture.md 指定位置)
201
+ ```python
202
+ # src/services/discount_service.py
203
+ def calculate_discount(amount: float, user_type: UserType) -> DiscountResult:
204
+ if user_type == UserType.VIP and amount >= 100:
205
+ discount = amount * 0.2
206
+ return DiscountResult(amount - discount, discount)
207
+ return DiscountResult(amount, 0)
208
+ ```
209
+
210
+ **Phase 4:驗證結論** (`docs/features/vip_discount/conclusion.md`)
211
+ ```markdown
212
+ ## 3. 摘要
213
+ - 架構:2/2 通過
214
+ - 情境:2/2 通過
215
+ - **狀態:** ✅ 完成
216
+ ```
217
+
218
+ ---
219
+
220
+ ## 🌐 多語言支援
221
+
222
+ 相同的工作流程,不同的語言:
223
+
224
+ <details>
225
+ <summary><b>Python</b></summary>
226
+
227
+ ```python
228
+ from dataclasses import dataclass
229
+ from abc import ABC, abstractmethod
230
+
231
+ @dataclass
232
+ class User:
233
+ id: str
234
+ type: UserType
235
+
236
+ class IUserService(ABC):
237
+ @abstractmethod
238
+ def authenticate(self, credentials: Credentials) -> User:
239
+ pass
240
+ ```
241
+ </details>
242
+
243
+ <details>
244
+ <summary><b>TypeScript</b></summary>
245
+
246
+ ```typescript
247
+ interface User {
248
+ id: string;
249
+ type: UserType;
250
+ }
251
+
252
+ interface IUserService {
253
+ authenticate(credentials: Credentials): User;
254
+ }
255
+ ```
256
+ </details>
257
+
258
+ <details>
259
+ <summary><b>Go</b></summary>
260
+
261
+ ```go
262
+ type User struct {
263
+ ID string
264
+ Type UserType
265
+ }
266
+
267
+ type UserService interface {
268
+ Authenticate(credentials Credentials) (User, error)
269
+ }
270
+ ```
271
+ </details>
272
+
273
+ 更多語言請參閱 [語言指南](docs/LANGUAGE_GUIDE.md),包含 Rust、Java、C# 等。
274
+
275
+ ---
276
+
277
+ ## 🎓 使用案例
278
+
279
+ ### 1. API 開發
280
+ ```bash
281
+ /sdd-spec Design a RESTful API for blog posts (CRUD operations)
282
+ /sdd-arch features/blog_api.feature
283
+ # 獲得清晰的 API 契約和資料結構
284
+ ```
285
+
286
+ ### 2. 功能實作
287
+ ```bash
288
+ /sdd-auto Implement user authentication with JWT tokens in TypeScript
289
+ # 幾分鐘內獲得可運行、已測試的程式碼
290
+ ```
291
+
292
+ ### 3. 遺留程式碼重構
293
+ ```bash
294
+ /sdd-spec The payment module should support credit card, PayPal, and crypto
295
+ # 在重構前定義清晰的需求
296
+ ```
297
+
298
+ ### 4. 團隊協作
299
+ ```bash
300
+ # PM:定義需求
301
+ /sdd-spec User registration with email verification
302
+
303
+ # 架構師:審查並設計
304
+ /sdd-arch features/user_registration.feature
305
+
306
+ # 工程師:實作
307
+ /sdd-impl features/user_registration.feature
308
+
309
+ # QA:驗證
310
+ /sdd-verify features/user_registration.feature
311
+ ```
312
+
313
+ ---
314
+
315
+ ## 📁 專案結構
316
+
317
+ 執行 SDD 工作流程後的輸出:
318
+
319
+ ```
320
+ your-project/
321
+ ├── features/ # Phase 1: Gherkin 規格
322
+ │ └── {feature}.feature
323
+ ├── docs/
324
+ │ └── features/
325
+ │ └── {feature}/
326
+ │ ├── architecture.md # Phase 2: 架構設計(繁中)
327
+ │ └── conclusion.md # Phase 4: 驗證結論
328
+ └── src/ # Phase 3: 實作程式碼
329
+ ├── models/ # 依專案既有架構
330
+ │ └── {Feature}Model.{ext}
331
+ └── services/
332
+ └── {Feature}Service.{ext}
333
+ ```
334
+
335
+ GSI-Protocol 儲存庫結構:
336
+
337
+ ```
338
+ GSI-Protocol/
339
+ ├── README.md # 本檔案
340
+ ├── CONTRIBUTING.md # 貢獻指南
341
+ ├── LICENSE # MIT 授權
342
+ ├── gsi_installer.py # Python 安裝器
343
+ ├── pyproject.toml # Python 專案配置
344
+ ├── .claude/
345
+ │ └── commands/ # Claude Code slash 指令
346
+ │ ├── sdd-auto.md # 自動工作流程
347
+ │ ├── sdd-spec.md # Phase 1
348
+ │ ├── sdd-arch.md # Phase 2
349
+ │ ├── sdd-impl.md # Phase 3
350
+ │ └── sdd-verify.md # Phase 4
351
+ ├── .codex/
352
+ │ └── prompts/ # Codex (OpenAI) prompts
353
+ │ ├── sdd-auto.md # 自動工作流程
354
+ │ ├── sdd-spec.md # Phase 1
355
+ │ ├── sdd-arch.md # Phase 2
356
+ │ ├── sdd-impl.md # Phase 3
357
+ │ └── sdd-verify.md # Phase 4
358
+ ├── docs/ # 文件
359
+ │ ├── QUICKSTART.md # 快速入門指南
360
+ │ ├── INSTALL.md # 安裝指南
361
+ │ ├── PYTHON_INSTALLER.md # Python 安裝器說明
362
+ │ ├── PLATFORM_SUPPORT.md # 平台支援說明
363
+ │ ├── COMMANDS.md # 指令參考
364
+ │ ├── LANGUAGE_GUIDE.md # 語言支援
365
+ │ └── expected_workflow.md # 工作流程細節
366
+ └── prompts/ # 代理提示(參考)
367
+ ├── pm_agent.md
368
+ ├── architect_agent.md
369
+ ├── engineer_agent.md
370
+ └── qa_agent.md
371
+ ```
372
+
373
+ ---
374
+
375
+ ## 🚀 優勢
376
+
377
+ ### 對開發者
378
+ - ✅ **更快開發**:自動生成樣板程式碼和結構
379
+ - ✅ **更高品質**:系統化方法減少 bug
380
+ - ✅ **清晰需求**:Gherkin 規格消除歧義
381
+
382
+ ### 對團隊
383
+ - ✅ **共同語言**:所有人都能理解的 BDD 規格
384
+ - ✅ **更好溝通**:PM、架構師、工程師、QA 各有明確階段
385
+ - ✅ **可維護程式碼**:每一行都可追溯到需求
386
+
387
+ ### 對專案
388
+ - ✅ **語言彈性**:切換語言不需改變方法論
389
+ - ✅ **框架無關**:使用任何函式庫或框架
390
+ - ✅ **可擴展**:適用於簡單功能到複雜系統
391
+
392
+ ---
393
+
394
+ ## 🔧 需求
395
+
396
+ - **AI 平台(擇一或兩者):**
397
+ - Claude Code CLI,或
398
+ - Codex (OpenAI)
399
+ - **安裝工具:**
400
+ - Python 3.10+
401
+ - uvx/pipx(推薦)或 pip
402
+ - Git
403
+ - 目標語言執行環境(Python 3.8+、Node.js 16+、Go 1.19+ 等)
404
+
405
+ ---
406
+
407
+ ## 📖 了解更多
408
+
409
+ - 📝 [快速入門(5 分鐘)](docs/QUICKSTART.md)
410
+ - 📚 [完整文件](docs/)
411
+ - 🌍 [語言支援](docs/LANGUAGE_GUIDE.md)
412
+ - 💬 [GitHub 討論](https://github.com/CodeMachine0121/GSI-Protocol/discussions)
413
+
414
+ ---
415
+
416
+ ## 🤝 貢獻
417
+
418
+ 我們歡迎貢獻!請參閱 [CONTRIBUTING.md](CONTRIBUTING.md) 了解指南。
419
+
420
+ ### 貢獻方式
421
+ - 🐛 回報 bug
422
+ - 💡 建議功能
423
+ - 📝 改善文件
424
+ - 🌍 新增語言範例
425
+ - 🔧 提交 pull request
426
+
427
+ ---
428
+
429
+ ## 📄 授權
430
+
431
+ MIT 授權 - 詳見 [LICENSE](LICENSE) 檔案。
432
+
433
+ ---
434
+
435
+ ## 🙏 致謝
436
+
437
+ 使用以下工具建置:
438
+ - [Claude Code](https://claude.ai/claude-code) - AI 驅動開發
439
+ - [Codex (OpenAI)](https://openai.com/blog/openai-codex) - AI 程式碼生成
440
+ - [Gherkin](https://cucumber.io/docs/gherkin/) - BDD 規格語言
441
+ - 靈感來自測試驅動開發和行為驅動開發原則
442
+
443
+ ---
444
+
445
+ ## 📞 支援
446
+
447
+ - 📖 [文件](docs/)
448
+ - 💬 [GitHub Issues](https://github.com/CodeMachine0121/GSI-Protocol/issues)
449
+ - 💡 [討論](https://github.com/CodeMachine0121/GSI-Protocol/discussions)
450
+
451
+ ---
452
+
453
+ <div align="center">
454
+
455
+ **[⬆ 回到頂端](#gsi-protocol中文)**
456
+
457
+ 由開發者打造,為開發者服務 ❤️
458
+
459
+ </div>
@@ -0,0 +1,289 @@
1
+ """
2
+ GSI-Protocol Installer
3
+
4
+ A simple CLI tool to install GSI-Protocol workflow commands for Claude Code and/or Codex.
5
+
6
+ Usage:
7
+ uvx gsi-protocol-installer
8
+ # or
9
+ pipx run gsi-protocol-installer
10
+ """
11
+
12
+ import os
13
+ import sys
14
+ from pathlib import Path
15
+ from typing import Optional
16
+ import shutil
17
+ import tempfile
18
+ import subprocess
19
+
20
+
21
+ class Colors:
22
+ """ANSI color codes for terminal output."""
23
+ HEADER = '\033[95m'
24
+ OKBLUE = '\033[94m'
25
+ OKCYAN = '\033[96m'
26
+ OKGREEN = '\033[92m'
27
+ WARNING = '\033[93m'
28
+ FAIL = '\033[91m'
29
+ ENDC = '\033[0m'
30
+ BOLD = '\033[1m'
31
+
32
+
33
+ def print_header():
34
+ """Print installation header."""
35
+ print(f"\n{Colors.BOLD}🚀 GSI-Protocol Installer{Colors.ENDC}")
36
+ print("=" * 60)
37
+ print()
38
+
39
+
40
+ def print_success(message: str):
41
+ """Print success message."""
42
+ print(f"{Colors.OKGREEN}✓{Colors.ENDC} {message}")
43
+
44
+
45
+ def print_error(message: str):
46
+ """Print error message."""
47
+ print(f"{Colors.FAIL}✗{Colors.ENDC} {message}")
48
+
49
+
50
+ def print_warning(message: str):
51
+ """Print warning message."""
52
+ print(f"{Colors.WARNING}⚠{Colors.ENDC} {message}")
53
+
54
+
55
+ def print_info(message: str):
56
+ """Print info message."""
57
+ print(f"{Colors.OKCYAN}ℹ{Colors.ENDC} {message}")
58
+
59
+
60
+ def prompt_choice(question: str, choices: list[str], default: int = 1) -> int:
61
+ """Prompt user for a choice."""
62
+ print(f"\n{Colors.BOLD}{question}{Colors.ENDC}")
63
+ for i, choice in enumerate(choices, 1):
64
+ print(f"{i}) {choice}")
65
+
66
+ while True:
67
+ try:
68
+ response = input(f"Enter choice [1-{len(choices)}] (default: {default}): ").strip()
69
+ if not response:
70
+ return default
71
+ choice = int(response)
72
+ if 1 <= choice <= len(choices):
73
+ return choice
74
+ print_error(f"Please enter a number between 1 and {len(choices)}")
75
+ except ValueError:
76
+ print_error("Please enter a valid number")
77
+ except KeyboardInterrupt:
78
+ print("\n\nInstallation cancelled.")
79
+ sys.exit(0)
80
+
81
+
82
+ def prompt_yes_no(question: str, default: bool = False) -> bool:
83
+ """Prompt user for yes/no."""
84
+ default_str = "Y/n" if default else "y/N"
85
+ while True:
86
+ try:
87
+ response = input(f"{question} [{default_str}]: ").strip().lower()
88
+ if not response:
89
+ return default
90
+ if response in ['y', 'yes']:
91
+ return True
92
+ if response in ['n', 'no']:
93
+ return False
94
+ print_error("Please enter 'y' or 'n'")
95
+ except KeyboardInterrupt:
96
+ print("\n\nInstallation cancelled.")
97
+ sys.exit(0)
98
+
99
+
100
+ def download_commands(repo_url: str = "https://github.com/CodeMachine0121/GSI-Protocol.git") -> Path:
101
+ """Download command files from GitHub."""
102
+ print_info("Downloading GSI-Protocol from GitHub...")
103
+
104
+ temp_dir = Path(tempfile.mkdtemp())
105
+
106
+ try:
107
+ # Clone the repository
108
+ result = subprocess.run(
109
+ ["git", "clone", "--depth", "1", repo_url, str(temp_dir / "gsi-protocol")],
110
+ capture_output=True,
111
+ text=True,
112
+ check=True
113
+ )
114
+ print_success("Downloaded successfully")
115
+ return temp_dir / "gsi-protocol"
116
+ except subprocess.CalledProcessError as e:
117
+ print_error(f"Failed to download: {e.stderr}")
118
+ sys.exit(1)
119
+ except FileNotFoundError:
120
+ print_error("Git is not installed. Please install git first.")
121
+ sys.exit(1)
122
+
123
+
124
+ def install_commands(source_dir: Path, platform: str, location: str) -> int:
125
+ """Install commands to the specified location."""
126
+ installed_count = 0
127
+
128
+ if location == "global":
129
+ if platform in ["claude", "both"]:
130
+ target_dir = Path.home() / ".claude" / "commands"
131
+ target_dir.mkdir(parents=True, exist_ok=True)
132
+
133
+ source = source_dir / ".claude" / "commands"
134
+ for file in source.glob("sdd-*.md"):
135
+ shutil.copy2(file, target_dir / file.name)
136
+ installed_count += 1
137
+
138
+ print_success(f"Installed {installed_count} Claude Code commands to {target_dir}")
139
+
140
+ if platform in ["codex", "both"]:
141
+ target_dir = Path.home() / ".codex" / "prompts"
142
+ target_dir.mkdir(parents=True, exist_ok=True)
143
+
144
+ source = source_dir / ".codex" / "prompts"
145
+ for file in source.glob("sdd-*.md"):
146
+ shutil.copy2(file, target_dir / file.name)
147
+ installed_count += 1
148
+
149
+ print_success(f"Installed {len(list((target_dir).glob('sdd-*.md')))} Codex prompts to {target_dir}")
150
+
151
+ else: # project
152
+ if platform in ["claude", "both"]:
153
+ target_dir = Path.cwd() / ".claude" / "commands"
154
+
155
+ if target_dir.exists():
156
+ if not prompt_yes_no(f"⚠️ {target_dir} already exists. Overwrite?", default=False):
157
+ print_warning("Skipping Claude Code installation")
158
+ else:
159
+ target_dir.mkdir(parents=True, exist_ok=True)
160
+ source = source_dir / ".claude" / "commands"
161
+ for file in source.glob("sdd-*.md"):
162
+ shutil.copy2(file, target_dir / file.name)
163
+ installed_count += 1
164
+ print_success(f"Installed {installed_count} Claude Code commands to {target_dir}")
165
+ else:
166
+ target_dir.mkdir(parents=True, exist_ok=True)
167
+ source = source_dir / ".claude" / "commands"
168
+ for file in source.glob("sdd-*.md"):
169
+ shutil.copy2(file, target_dir / file.name)
170
+ installed_count += 1
171
+ print_success(f"Installed {installed_count} Claude Code commands to {target_dir}")
172
+
173
+ if platform in ["codex", "both"]:
174
+ target_dir = Path.cwd() / ".codex" / "prompts"
175
+
176
+ if target_dir.exists():
177
+ if not prompt_yes_no(f"⚠️ {target_dir} already exists. Overwrite?", default=False):
178
+ print_warning("Skipping Codex installation")
179
+ else:
180
+ target_dir.mkdir(parents=True, exist_ok=True)
181
+ source = source_dir / ".codex" / "prompts"
182
+ for file in source.glob("sdd-*.md"):
183
+ shutil.copy2(file, target_dir / file.name)
184
+ installed_count += 1
185
+ print_success(f"Installed {len(list((target_dir).glob('sdd-*.md')))} Codex prompts to {target_dir}")
186
+ else:
187
+ target_dir.mkdir(parents=True, exist_ok=True)
188
+ source = source_dir / ".codex" / "prompts"
189
+ for file in source.glob("sdd-*.md"):
190
+ shutil.copy2(file, target_dir / file.name)
191
+ installed_count += 1
192
+ print_success(f"Installed {len(list((target_dir).glob('sdd-*.md')))} Codex prompts to {target_dir}")
193
+
194
+ return installed_count
195
+
196
+
197
+ def detect_installation_type() -> str:
198
+ """Detect if we're in a git repository."""
199
+ try:
200
+ subprocess.run(
201
+ ["git", "rev-parse", "--git-dir"],
202
+ capture_output=True,
203
+ check=True
204
+ )
205
+ return "project"
206
+ except (subprocess.CalledProcessError, FileNotFoundError):
207
+ return "unknown"
208
+
209
+
210
+ def main():
211
+ """Main installation flow."""
212
+ print_header()
213
+
214
+ # Step 1: Choose platform
215
+ platform_choice = prompt_choice(
216
+ "Select AI platform(s) to install:",
217
+ [
218
+ "Claude Code only",
219
+ "Codex (OpenAI) only",
220
+ "Both Claude Code and Codex"
221
+ ],
222
+ default=3
223
+ )
224
+
225
+ platform_map = {1: "claude", 2: "codex", 3: "both"}
226
+ platform = platform_map[platform_choice]
227
+
228
+ # Step 2: Choose installation location
229
+ detected = detect_installation_type()
230
+
231
+ if detected == "project":
232
+ print_success("Git repository detected")
233
+ location_choice = prompt_choice(
234
+ "Choose installation type:",
235
+ [
236
+ "Install to current project",
237
+ "Install globally to home directory"
238
+ ],
239
+ default=1
240
+ )
241
+ else:
242
+ print_info("Not in a git repository")
243
+ location_choice = prompt_choice(
244
+ "Choose installation type:",
245
+ [
246
+ "Install to current directory",
247
+ "Install globally to home directory"
248
+ ],
249
+ default=2
250
+ )
251
+
252
+ location = "project" if location_choice == 1 else "global"
253
+
254
+ # Step 3: Download
255
+ print()
256
+ source_dir = download_commands()
257
+
258
+ # Step 4: Install
259
+ print()
260
+ installed_count = install_commands(source_dir, platform, location)
261
+
262
+ # Step 5: Cleanup
263
+ shutil.rmtree(source_dir.parent)
264
+
265
+ # Step 6: Success message
266
+ print()
267
+ print("=" * 60)
268
+ print_success(f"Installation complete! Total files installed: {installed_count}")
269
+ print()
270
+ print("You can now use SDD commands:")
271
+ print(" /sdd-auto <requirement>")
272
+ print(" /sdd-spec <requirement>")
273
+ print(" /sdd-arch <feature.feature>")
274
+ print(" /sdd-impl <feature.feature>")
275
+ print(" /sdd-verify <feature.feature>")
276
+ print()
277
+ print(f"📖 Documentation: {Colors.OKCYAN}https://github.com/CodeMachine0121/GSI-Protocol{Colors.ENDC}")
278
+ print()
279
+
280
+
281
+ if __name__ == "__main__":
282
+ try:
283
+ main()
284
+ except KeyboardInterrupt:
285
+ print("\n\nInstallation cancelled.")
286
+ sys.exit(0)
287
+ except Exception as e:
288
+ print_error(f"Unexpected error: {e}")
289
+ sys.exit(1)
@@ -0,0 +1,55 @@
1
+ [project]
2
+ name = "gsi-protocol-installer"
3
+ version = "1.0.2"
4
+ description = "Installer for GSI-Protocol workflow commands (Claude Code & Codex)"
5
+ authors = [
6
+ {name = "James Hsueh", email = "asdfg55887@gmail.com"}
7
+ ]
8
+ maintainers = [
9
+ {name = "GSI-Protocol Contributors"}
10
+ ]
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ license = {text = "MIT"}
14
+ keywords = ["gsi-protocol", "sdd", "bdd", "gherkin", "claude", "codex", "ai", "workflow", "spec-driven-development"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Code Generators",
25
+ "Topic :: Software Development :: Testing",
26
+ "Topic :: Software Development :: Quality Assurance",
27
+ "Environment :: Console",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/CodeMachine0121/GSI-Protocol"
32
+ Documentation = "https://github.com/CodeMachine0121/GSI-Protocol/blob/main/README.md"
33
+ Repository = "https://github.com/CodeMachine0121/GSI-Protocol"
34
+ Issues = "https://github.com/CodeMachine0121/GSI-Protocol/issues"
35
+ Changelog = "https://github.com/CodeMachine0121/GSI-Protocol/blob/main/CODEX_SUPPORT_CHANGELOG.md"
36
+
37
+ [project.scripts]
38
+ gsi-install = "gsi_installer:main"
39
+
40
+ [build-system]
41
+ requires = ["hatchling"]
42
+ build-backend = "hatchling.build"
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["."]
46
+ only-include = ["gsi_installer.py"]
47
+
48
+ [tool.hatch.build.targets.sdist]
49
+ only-include = [
50
+ "gsi_installer.py",
51
+ "pyproject.toml",
52
+ "README.md",
53
+ "LICENSE",
54
+ "MANIFEST.in"
55
+ ]