@vincent119/go-copilot-rules 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/.agent_agy/INSTALLATION.md +786 -0
- package/.agent_agy/README.md +243 -0
- package/.agent_agy/SKILLS_INDEX.md +516 -0
- package/.agent_agy/rules/go-core.copilot-instructions.md +251 -0
- package/.agent_agy/skills/go-api-design/SKILL.md +535 -0
- package/.agent_agy/skills/go-ci-tooling/SKILL.md +533 -0
- package/.agent_agy/skills/go-configuration/SKILL.md +609 -0
- package/.agent_agy/skills/go-database/SKILL.md +412 -0
- package/.agent_agy/skills/go-ddd/SKILL.md +374 -0
- package/.agent_agy/skills/go-dependency-injection/SKILL.md +546 -0
- package/.agent_agy/skills/go-domain-events/SKILL.md +525 -0
- package/.agent_agy/skills/go-examples/SKILL.md +690 -0
- package/.agent_agy/skills/go-graceful-shutdown/SKILL.md +708 -0
- package/.agent_agy/skills/go-grpc/SKILL.md +484 -0
- package/.agent_agy/skills/go-http-advanced/SKILL.md +494 -0
- package/.agent_agy/skills/go-observability/SKILL.md +684 -0
- package/.agent_agy/skills/go-testing-advanced/SKILL.md +573 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/cli/install.js +344 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# copilot-rules-kit
|
|
2
|
+
|
|
3
|
+
集中維護的 **AI 助手產出規範套件**(for GitHub Copilot / VS Code Agent / 其他 LLM 協作工具)。
|
|
4
|
+
目標:在多個專案之間 **統一生成規範、術語詞彙、與文件模板**,確保產出 **正確性、可維護性、與一致性**。
|
|
5
|
+
|
|
6
|
+
> 適用情境:公司/團隊以 **git submodule** 或 **git subtree** 導入本套件至各個專案,並以 **tag 版本** 管理升級與回滾。
|
|
7
|
+
|
|
8
|
+
- Repo:`https://github.com/vincent119/copilot-rules-kit`
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 快速開始(Go Copilot Skills)
|
|
13
|
+
|
|
14
|
+
如果你只需要安裝 **Go 開發規範與 Skills**(`.agent_agy/` 目錄),請使用:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# NPX 一鍵安裝(推薦)
|
|
18
|
+
npx @vincent119/go-copilot-rules
|
|
19
|
+
|
|
20
|
+
# 或使用安裝腳本
|
|
21
|
+
bash <(curl -s https://raw.githubusercontent.com/vincent119/copilot-rules-kit/main/scripts/quick-install.sh)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**支援的安裝選項**:
|
|
25
|
+
- `--vscode` - 安裝到 VS Code Copilot 預設路徑(`.agent_agy/`)
|
|
26
|
+
- `--cursor` - 安裝到 Cursor 預設路徑(`.cursor/skills/`)
|
|
27
|
+
- `--skills "go-ddd,go-grpc"` - 只安裝特定 Skills
|
|
28
|
+
- `--help` - 查看所有選項
|
|
29
|
+
|
|
30
|
+
📖 **完整文件**:[.agent_agy/INSTALLATION.md](.agent_agy/INSTALLATION.md)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 內容構成(中央規範倉庫)
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
copilot-rules-kit/
|
|
38
|
+
├── CHANGELOG.md
|
|
39
|
+
├── LICENSE
|
|
40
|
+
├── README.md
|
|
41
|
+
├── copilot-chat-instructions.yaml
|
|
42
|
+
├── copilot-instructions.md
|
|
43
|
+
├── copilot-instructions.yaml
|
|
44
|
+
├── instructions/
|
|
45
|
+
│ ├── bash.instructions.md
|
|
46
|
+
│ ├── go.instructions.md
|
|
47
|
+
│ ├── helm.instructions.md
|
|
48
|
+
│ ├── pulumi.instructions.md
|
|
49
|
+
│ ├── python.instructions.md
|
|
50
|
+
│ ├── ts.instructions.md
|
|
51
|
+
│ └── yaml.instructions.md
|
|
52
|
+
├── scripts/
|
|
53
|
+
│ ├── merge_copilot_instructions.py
|
|
54
|
+
│ ├── setup-copilot-submodule.sh
|
|
55
|
+
│ ├── setup-copilot-subtree.sh
|
|
56
|
+
│ ├── setup-pre-commit.sh
|
|
57
|
+
│ └── vocabulary_scan.py
|
|
58
|
+
└── standards/
|
|
59
|
+
├── copilot-commit-message-instructions.md
|
|
60
|
+
├── copilot-common.md
|
|
61
|
+
├── copilot-instructions-extended.md
|
|
62
|
+
├── copilot-pull-request-description-instructions.md
|
|
63
|
+
└── copilot-vocabulary.yaml
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 消費端導入位置(推薦)
|
|
69
|
+
|
|
70
|
+
> **建議導入位置:直接放在 `.github/` 目錄下**
|
|
71
|
+
> 優點:Copilot 可直接讀取 `.github/copilot-instructions.md`;與 GitHub 生態一致。
|
|
72
|
+
|
|
73
|
+
### A. 以 Git Submodule 導入(推薦:清楚版本邊界、易回滾)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 於消費端專案根目錄執行,直接導入到 .github/
|
|
77
|
+
git submodule add https://github.com/vincent119/copilot-rules-kit.git .github
|
|
78
|
+
git submodule update --init --recursive
|
|
79
|
+
|
|
80
|
+
#(可選)鎖定到特定版本 tag(例:v1.0.3)
|
|
81
|
+
cd .github && git fetch --tags && git checkout v1.0.3 && cd -
|
|
82
|
+
git add .gitmodules .github
|
|
83
|
+
git commit -m "chore: add copilot-rules-kit@v1.0.3 as submodule"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**升版到新 tag:**
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cd .github
|
|
90
|
+
git fetch --tags
|
|
91
|
+
git checkout v1.0.4
|
|
92
|
+
cd -
|
|
93
|
+
git add .github
|
|
94
|
+
git commit -m "chore: upgrade copilot-rules-kit to v1.0.4"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**CI 注意事項:**
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# CI 若需存取規範檔,請先同步子模組
|
|
101
|
+
git submodule update --init --recursive
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### B. 以 Git Subtree 導入(倉庫不帶 submodule 依賴)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
git subtree add --prefix .github https://github.com/vincent119/copilot-rules-kit.git main --squash
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**從上游拉取最新(同分支或 tag):**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
git subtree pull --prefix .github https://github.com/vincent119/copilot-rules-kit.git main --squash
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 腳本使用說明(可於消費端直接使用)
|
|
119
|
+
|
|
120
|
+
### 1) `scripts/setup-copilot-submodule.sh`
|
|
121
|
+
|
|
122
|
+
**用途**:一鍵將本套件以 **submodule** 形式導入到消費端的 `.github/`,並鎖定到指定版本。
|
|
123
|
+
|
|
124
|
+
**用法**:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# 預設導入到 .github 並鎖定 v1.0.3
|
|
128
|
+
bash scripts/setup-copilot-submodule.sh
|
|
129
|
+
|
|
130
|
+
# 自訂導入目錄與版本
|
|
131
|
+
bash scripts/setup-copilot-submodule.sh .github v1.0.4
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**行為**:
|
|
135
|
+
|
|
136
|
+
- 新增子模組 → 初始化遞迴 → 抓取 tags → 切換至指定 tag
|
|
137
|
+
- 將 `.gitmodules` 與目標目錄加入版本控制並建立提交
|
|
138
|
+
|
|
139
|
+
### 2) `scripts/setup-copilot-subtree.sh`
|
|
140
|
+
|
|
141
|
+
**用途**:一鍵以 **subtree** 方式導入到 `.github/`。
|
|
142
|
+
|
|
143
|
+
**用法**:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# 導入 main 分支
|
|
147
|
+
bash scripts/setup-copilot-subtree.sh
|
|
148
|
+
|
|
149
|
+
# 指定前置目錄與來源 ref(分支或 tag)
|
|
150
|
+
bash scripts/setup-copilot-subtree.sh .github v1.0.3
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**行為**:
|
|
154
|
+
|
|
155
|
+
- 以 `--squash` 壓縮上游歷史,保持消費端歷史乾淨
|
|
156
|
+
|
|
157
|
+
### 3) `scripts/vocabulary_scan.py`
|
|
158
|
+
|
|
159
|
+
**用途**:依 `standards/copilot-vocabulary.yaml` 執行術語掃描,提示黑名單或建議用語。
|
|
160
|
+
|
|
161
|
+
**用法**:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python3 .github/scripts/vocabulary_scan.py \
|
|
165
|
+
--vocab .github/standards/copilot-vocabulary.yaml \
|
|
166
|
+
--paths "docs/**/*.md" "src/**/*.go" "src/**/*.ts"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**輸出**:
|
|
170
|
+
|
|
171
|
+
- 發現黑名單:`[DISALLOWED] <詞> in <檔案>`
|
|
172
|
+
- 提示建議改寫:`[SUGGEST] <錯> → <正> in <檔案>`---
|
|
173
|
+
|
|
174
|
+
## 授權
|
|
175
|
+
|
|
176
|
+
MIT(詳見 `LICENSE`)。
|
package/cli/install.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
// 顏色定義
|
|
8
|
+
const colors = {
|
|
9
|
+
reset: '\x1b[0m',
|
|
10
|
+
red: '\x1b[31m',
|
|
11
|
+
green: '\x1b[32m',
|
|
12
|
+
yellow: '\x1b[33m',
|
|
13
|
+
blue: '\x1b[34m',
|
|
14
|
+
cyan: '\x1b[36m'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function log(message, color = 'reset') {
|
|
18
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function detectIDE() {
|
|
22
|
+
const cwd = process.cwd();
|
|
23
|
+
const homeDir = require('os').homedir();
|
|
24
|
+
|
|
25
|
+
// 檢查是否在專案目錄中
|
|
26
|
+
if (fs.existsSync(path.join(cwd, '.kiro'))) {
|
|
27
|
+
return { name: 'kiro', defaultPath: '.kiro/skills' };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (fs.existsSync(path.join(cwd, '.cursor'))) {
|
|
31
|
+
return { name: 'cursor', defaultPath: '.cursor/skills' };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (fs.existsSync(path.join(cwd, '.vscode'))) {
|
|
35
|
+
return { name: 'vscode', defaultPath: '.agent_agy' };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 檢查是否有全域 Kiro 配置
|
|
39
|
+
if (fs.existsSync(path.join(homeDir, '.kiro'))) {
|
|
40
|
+
return { name: 'kiro-global', defaultPath: path.join(homeDir, '.kiro/skills') };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 預設為 VS Code
|
|
44
|
+
return { name: 'vscode', defaultPath: '.agent_agy' };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseArgs() {
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
const options = {
|
|
50
|
+
path: null,
|
|
51
|
+
mode: 'full', // full, core-only, skills-only
|
|
52
|
+
skills: null,
|
|
53
|
+
ide: null,
|
|
54
|
+
help: false
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
const arg = args[i];
|
|
59
|
+
|
|
60
|
+
switch (arg) {
|
|
61
|
+
case '--help':
|
|
62
|
+
case '-h':
|
|
63
|
+
options.help = true;
|
|
64
|
+
break;
|
|
65
|
+
case '--vscode':
|
|
66
|
+
options.ide = 'vscode';
|
|
67
|
+
options.path = '.agent_agy';
|
|
68
|
+
break;
|
|
69
|
+
case '--cursor':
|
|
70
|
+
options.ide = 'cursor';
|
|
71
|
+
options.path = '.cursor/skills';
|
|
72
|
+
break;
|
|
73
|
+
case '--kiro':
|
|
74
|
+
options.ide = 'kiro';
|
|
75
|
+
options.path = '.kiro/skills';
|
|
76
|
+
break;
|
|
77
|
+
case '--kiro-global':
|
|
78
|
+
options.ide = 'kiro-global';
|
|
79
|
+
const homeDir = require('os').homedir();
|
|
80
|
+
options.path = path.join(homeDir, '.kiro/skills');
|
|
81
|
+
break;
|
|
82
|
+
case '--path':
|
|
83
|
+
options.path = args[++i];
|
|
84
|
+
break;
|
|
85
|
+
case '--core-only':
|
|
86
|
+
options.mode = 'core-only';
|
|
87
|
+
break;
|
|
88
|
+
case '--skills-only':
|
|
89
|
+
options.mode = 'skills-only';
|
|
90
|
+
break;
|
|
91
|
+
case '--skills':
|
|
92
|
+
options.skills = args[++i];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return options;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function showHelp() {
|
|
101
|
+
console.log(`
|
|
102
|
+
${colors.blue}╔══════════════════════════════════════════════════════╗${colors.reset}
|
|
103
|
+
${colors.blue}║ Go Copilot Rules 安裝器 ║${colors.reset}
|
|
104
|
+
${colors.blue}║ 專注於 Go 開發的 Copilot Skills 集合 ║${colors.reset}
|
|
105
|
+
${colors.blue}╚══════════════════════════════════════════════════════╝${colors.reset}
|
|
106
|
+
|
|
107
|
+
${colors.yellow}用法:${colors.reset}
|
|
108
|
+
npx @vincent119/go-copilot-rules [選項]
|
|
109
|
+
|
|
110
|
+
${colors.yellow}選項:${colors.reset}
|
|
111
|
+
--vscode 安裝到 VS Code 預設位置 (.agent_agy/)
|
|
112
|
+
--cursor 安裝到 Cursor 預設位置 (.cursor/skills/)
|
|
113
|
+
--kiro 安裝到 Kiro 專案位置 (.kiro/skills/)
|
|
114
|
+
--kiro-global 安裝到 Kiro 全域位置 (~/.kiro/skills/)
|
|
115
|
+
--path <dir> 安裝到自訂路徑
|
|
116
|
+
--core-only 只安裝核心規範(不包含 Skills)
|
|
117
|
+
--skills-only 只安裝 Skills(不包含核心規範)
|
|
118
|
+
--skills <list> 只安裝特定 Skills(逗號分隔)
|
|
119
|
+
--help, -h 顯示此幫助訊息
|
|
120
|
+
|
|
121
|
+
${colors.yellow}範例:${colors.reset}
|
|
122
|
+
# 自動偵測並安裝(預設)
|
|
123
|
+
npx @vincent119/go-copilot-rules
|
|
124
|
+
|
|
125
|
+
# 安裝到 VS Code
|
|
126
|
+
npx @vincent119/go-copilot-rules --vscode
|
|
127
|
+
|
|
128
|
+
# 安裝到 Cursor
|
|
129
|
+
npx @vincent119/go-copilot-rules --cursor
|
|
130
|
+
|
|
131
|
+
# 安裝到 Kiro (專案)
|
|
132
|
+
npx @vincent119/go-copilot-rules --kiro
|
|
133
|
+
|
|
134
|
+
# 安裝到 Kiro (全域)
|
|
135
|
+
npx @vincent119/go-copilot-rules --kiro-global
|
|
136
|
+
|
|
137
|
+
# 只安裝特定 Skills
|
|
138
|
+
npx @vincent119/go-copilot-rules --skills "go-ddd,go-grpc,go-observability"
|
|
139
|
+
|
|
140
|
+
# 安裝到自訂路徑
|
|
141
|
+
npx @vincent119/go-copilot-rules --path ~/.my-copilot-rules
|
|
142
|
+
|
|
143
|
+
${colors.yellow}支援的 Skills:${colors.reset}
|
|
144
|
+
go-ddd DDD 架構設計
|
|
145
|
+
go-grpc gRPC 完整規範
|
|
146
|
+
go-testing-advanced 進階測試策略
|
|
147
|
+
go-database Database Migration
|
|
148
|
+
go-observability 日誌與可觀測性
|
|
149
|
+
go-graceful-shutdown 優雅關機模式
|
|
150
|
+
go-http-advanced HTTP 進階實作
|
|
151
|
+
go-api-design API 設計與版本管理
|
|
152
|
+
go-dependency-injection 依賴注入模式
|
|
153
|
+
go-configuration 設定管理
|
|
154
|
+
go-ci-tooling CI/CD 與工具配置
|
|
155
|
+
go-domain-events Domain Events 實作
|
|
156
|
+
go-examples 實作範例庫
|
|
157
|
+
|
|
158
|
+
${colors.cyan}更多資訊:${colors.reset}
|
|
159
|
+
https://github.com/vincent119/copilot-rules-kit
|
|
160
|
+
`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function copyRecursive(src, dest) {
|
|
164
|
+
const exists = fs.existsSync(src);
|
|
165
|
+
const stats = exists && fs.statSync(src);
|
|
166
|
+
const isDirectory = exists && stats.isDirectory();
|
|
167
|
+
|
|
168
|
+
if (isDirectory) {
|
|
169
|
+
if (!fs.existsSync(dest)) {
|
|
170
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
171
|
+
}
|
|
172
|
+
fs.readdirSync(src).forEach(childItemName => {
|
|
173
|
+
copyRecursive(
|
|
174
|
+
path.join(src, childItemName),
|
|
175
|
+
path.join(dest, childItemName)
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
fs.copyFileSync(src, dest);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function install(options) {
|
|
184
|
+
const packageRoot = path.dirname(__dirname);
|
|
185
|
+
const sourceDir = path.join(packageRoot, '.agent_agy');
|
|
186
|
+
|
|
187
|
+
// 如果沒有指定路徑,自動偵測
|
|
188
|
+
if (!options.path) {
|
|
189
|
+
const detected = detectIDE();
|
|
190
|
+
options.path = detected.defaultPath;
|
|
191
|
+
log(`ℹ️ 偵測到 ${detected.name},使用路徑: ${options.path}`, 'cyan');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const targetDir = path.resolve(process.cwd(), options.path);
|
|
195
|
+
|
|
196
|
+
log('', 'reset');
|
|
197
|
+
log('╔══════════════════════════════════════════════════════╗', 'blue');
|
|
198
|
+
log('║ Go Copilot Rules 安裝器 ║', 'blue');
|
|
199
|
+
log('╚══════════════════════════════════════════════════════╝', 'blue');
|
|
200
|
+
log('', 'reset');
|
|
201
|
+
|
|
202
|
+
log('📋 安裝配置:', 'blue');
|
|
203
|
+
log(` • 模式: ${options.mode}`, 'green');
|
|
204
|
+
log(` • 目標: ${targetDir}`, 'green');
|
|
205
|
+
if (options.skills) {
|
|
206
|
+
log(` • Skills: ${options.skills}`, 'green');
|
|
207
|
+
}
|
|
208
|
+
log('', 'reset');
|
|
209
|
+
|
|
210
|
+
// 備份現有目錄
|
|
211
|
+
if (fs.existsSync(targetDir)) {
|
|
212
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
|
|
213
|
+
const backupDir = `${targetDir}.backup.${timestamp}`;
|
|
214
|
+
log(`⚠️ 目標目錄已存在,備份到 ${backupDir}`, 'yellow');
|
|
215
|
+
fs.renameSync(targetDir, backupDir);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 建立目標目錄
|
|
219
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
220
|
+
|
|
221
|
+
// 根據模式複製檔案
|
|
222
|
+
log('📦 安裝檔案...', 'blue');
|
|
223
|
+
|
|
224
|
+
switch (options.mode) {
|
|
225
|
+
case 'full':
|
|
226
|
+
log(' 複製完整規範(核心 + 所有 Skills)', 'cyan');
|
|
227
|
+
copyRecursive(sourceDir, targetDir);
|
|
228
|
+
break;
|
|
229
|
+
|
|
230
|
+
case 'core-only':
|
|
231
|
+
log(' 複製核心規範', 'cyan');
|
|
232
|
+
const rulesDir = path.join(targetDir, 'rules');
|
|
233
|
+
fs.mkdirSync(rulesDir, { recursive: true });
|
|
234
|
+
copyRecursive(path.join(sourceDir, 'rules'), rulesDir);
|
|
235
|
+
|
|
236
|
+
// 複製 README
|
|
237
|
+
const readmeSrc = path.join(sourceDir, 'README.md');
|
|
238
|
+
if (fs.existsSync(readmeSrc)) {
|
|
239
|
+
fs.copyFileSync(readmeSrc, path.join(targetDir, 'README.md'));
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
|
|
243
|
+
case 'skills-only':
|
|
244
|
+
log(' 複製所有 Skills', 'cyan');
|
|
245
|
+
const skillsDir = path.join(targetDir, 'skills');
|
|
246
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
247
|
+
copyRecursive(path.join(sourceDir, 'skills'), skillsDir);
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 如果指定了特定 Skills
|
|
252
|
+
if (options.skills) {
|
|
253
|
+
log('📋 複製選定的 Skills...', 'blue');
|
|
254
|
+
const skillsDir = path.join(targetDir, 'skills');
|
|
255
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
256
|
+
|
|
257
|
+
const skillList = options.skills.split(',').map(s => s.trim());
|
|
258
|
+
skillList.forEach(skill => {
|
|
259
|
+
const skillSrc = path.join(sourceDir, 'skills', skill);
|
|
260
|
+
if (fs.existsSync(skillSrc)) {
|
|
261
|
+
const skillDest = path.join(skillsDir, skill);
|
|
262
|
+
copyRecursive(skillSrc, skillDest);
|
|
263
|
+
log(` • ${skill}`, 'green');
|
|
264
|
+
} else {
|
|
265
|
+
log(` • ${skill} (不存在,跳過)`, 'red');
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 複製文件
|
|
271
|
+
['INSTALLATION.md', 'SKILLS_INDEX.md'].forEach(file => {
|
|
272
|
+
const src = path.join(sourceDir, file);
|
|
273
|
+
if (fs.existsSync(src)) {
|
|
274
|
+
fs.copyFileSync(src, path.join(targetDir, file));
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// 統計安裝結果
|
|
279
|
+
log('', 'reset');
|
|
280
|
+
log('✅ 安裝完成!', 'green');
|
|
281
|
+
log('', 'reset');
|
|
282
|
+
|
|
283
|
+
// 顯示已安裝內容
|
|
284
|
+
if (options.mode !== 'skills-only') {
|
|
285
|
+
const rulesPath = path.join(targetDir, 'rules');
|
|
286
|
+
if (fs.existsSync(rulesPath)) {
|
|
287
|
+
const coreFiles = fs.readdirSync(rulesPath).filter(f => f.endsWith('.md'));
|
|
288
|
+
log(`📊 核心規範: ${coreFiles.length} 個檔案`, 'green');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (options.mode !== 'core-only') {
|
|
293
|
+
const skillsPath = path.join(targetDir, 'skills');
|
|
294
|
+
if (fs.existsSync(skillsPath)) {
|
|
295
|
+
log('📊 已安裝的 Skills:', 'green');
|
|
296
|
+
const skills = fs.readdirSync(skillsPath).filter(f => {
|
|
297
|
+
return fs.statSync(path.join(skillsPath, f)).isDirectory();
|
|
298
|
+
});
|
|
299
|
+
skills.forEach(skill => {
|
|
300
|
+
log(` • ${skill}`, 'green');
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// 下一步提示
|
|
306
|
+
log('', 'reset');
|
|
307
|
+
log('💡 下一步:', 'yellow');
|
|
308
|
+
|
|
309
|
+
if (options.ide === 'cursor') {
|
|
310
|
+
log(' 1. 重新啟動 Cursor', 'reset');
|
|
311
|
+
log(' 2. 在 Chat 輸入: @go-ddd 如何設計 Aggregate Root?', 'blue');
|
|
312
|
+
} else {
|
|
313
|
+
log(' 1. 打開 VS Code / Cursor', 'reset');
|
|
314
|
+
log(' 2. 在 Copilot Chat 輸入: \'這個專案有哪些 Skills?\'', 'blue');
|
|
315
|
+
log(' 3. 測試觸發: \'如何實作 DDD Aggregate Root?\'', 'blue');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
log('', 'reset');
|
|
319
|
+
log(`📚 查看完整文件: ${targetDir}/INSTALLATION.md`, 'cyan');
|
|
320
|
+
log('', 'reset');
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 主程式
|
|
324
|
+
function main() {
|
|
325
|
+
const options = parseArgs();
|
|
326
|
+
|
|
327
|
+
if (options.help) {
|
|
328
|
+
showHelp();
|
|
329
|
+
process.exit(0);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
try {
|
|
333
|
+
install(options);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
log('', 'reset');
|
|
336
|
+
log('❌ 安裝失敗', 'red');
|
|
337
|
+
log(`錯誤: ${error.message}`, 'red');
|
|
338
|
+
log('', 'reset');
|
|
339
|
+
log('如需協助,請訪問: https://github.com/vincent119/copilot-rules-kit/issues', 'cyan');
|
|
340
|
+
process.exit(1);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vincent119/go-copilot-rules",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Professional Go development rules and skills for GitHub Copilot, Cursor, and other AI coding assistants",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"copilot",
|
|
7
|
+
"github-copilot",
|
|
8
|
+
"cursor",
|
|
9
|
+
"ai-coding",
|
|
10
|
+
"golang",
|
|
11
|
+
"go",
|
|
12
|
+
"copilot-skills",
|
|
13
|
+
"copilot-rules",
|
|
14
|
+
"ddd",
|
|
15
|
+
"grpc",
|
|
16
|
+
"testing",
|
|
17
|
+
"best-practices"
|
|
18
|
+
],
|
|
19
|
+
"author": "vincent119",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/vincent119/copilot-rules-kit.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/vincent119/copilot-rules-kit#readme",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/vincent119/copilot-rules-kit/issues"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"go-copilot-rules": "./cli/install.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
".agent_agy/",
|
|
34
|
+
"cli/",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "echo \"No tests yet\" && exit 0"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|