@aramassa/ai-rules 0.5.2 → 0.6.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/artifact/instructions/git-rules.md +79 -0
- package/artifact/instructions/planning.md +109 -0
- package/artifact/instructions/rules/development/github-actions-npm-troubleshooting.md +611 -0
- package/artifact/instructions/rules/development/planning-workflow.md +792 -0
- package/artifact/instructions/rules/package-publish/npm.md +666 -0
- package/artifact/instructions/rules/test/e2e-cli-execution.md +104 -0
- package/artifact/instructions/rules/test/github-actions-test.md +402 -0
- package/dist/cli.js +46 -4
- package/package.json +2 -2
- package/presets/README.md +23 -0
- package/presets/basic.yaml +2 -0
- package/presets/chatmodes.yaml +2 -0
- package/presets/chrome-extension.yaml +2 -0
- package/presets/docs-ai.yaml +2 -0
- package/presets/electron.yaml +2 -0
- package/presets/github-actions/npm-publish.yaml +18 -0
- package/presets/infrastructure-ansible.yaml +2 -0
- package/presets/monorepo/nodejs.yaml +2 -0
- package/presets/monorepo/typescript.yaml +2 -0
- package/presets/prompts/prompt-creation.yaml +2 -0
- package/presets/prompts/todo-planning.yaml +2 -0
- package/presets/typescript.yaml +2 -0
- package/schemas/recipe.schema.json +4 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: test
|
|
3
|
+
category: e2e-test
|
|
4
|
+
focus: cli-execution
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# docs-ai/e2e-test ガイドライン
|
|
8
|
+
|
|
9
|
+
`docs-ai/e2e-test/` ディレクトリは、**プロダクトの E2E テスト・動作確認手順をコマンドライン形式で AI 向けに記録する場所**です。人間が読む `docs/` とは役割が異なり、「どのコマンドを叩けばプロダクトの動作確認ができるか」を機械的にたどれることを重視します。
|
|
10
|
+
|
|
11
|
+
## ドキュメントの目的
|
|
12
|
+
|
|
13
|
+
- プロダクトの **E2E テスト手順**を、再現性の高い形で記録する
|
|
14
|
+
- 「どのコマンドを叩けば最低限の動作確認ができるか」を明示する
|
|
15
|
+
- 将来の回帰テストや動作確認の際の **チェックリスト** として活用する
|
|
16
|
+
|
|
17
|
+
## ファイル命名とスコープの書き方
|
|
18
|
+
|
|
19
|
+
- ファイル名は、テストする機能やシナリオが分かる名前にする
|
|
20
|
+
- 例: `mcp-server-basic-e2e.md`, `confluence-sync-e2e.md` など
|
|
21
|
+
- ファイル先頭の frontmatter / 見出しで、以下を明記する
|
|
22
|
+
- 対象機能(例: `MCPサーバー基本動作`, `CLIツール基本機能`)
|
|
23
|
+
- 目的(E2E テストコマンド集 など)
|
|
24
|
+
|
|
25
|
+
## 構成ルール
|
|
26
|
+
|
|
27
|
+
各ファイルは、概ね次のような構成に揃えます(厳密でなくてOKですが、できるだけ寄せる):
|
|
28
|
+
|
|
29
|
+
1. **前提**
|
|
30
|
+
- 実行場所(例: `cd /repos/ly-work-tools`)
|
|
31
|
+
- 必要なツール(Node.js / npm / そのほか)
|
|
32
|
+
- 初期セットアップ手順(`npm install` など)
|
|
33
|
+
2. **全体ビルド・全体テスト**
|
|
34
|
+
- モノレポ全体の build / test を実行するコマンド
|
|
35
|
+
3. **パッケージ単位の確認**
|
|
36
|
+
- `common` / `core` / `cli` など、影響がありそうなパッケージごとの build / test
|
|
37
|
+
4. **コマンドライン動作確認**
|
|
38
|
+
- CLI やサーバなどを **実際に叩くコマンド** を記載
|
|
39
|
+
- 正常系だけでなく、代表的なエラーケースの確認も含める
|
|
40
|
+
5. **クリーンアップ手順**
|
|
41
|
+
- グローバルインストールしたものを戻す操作
|
|
42
|
+
- 一時ファイル、開発用サーバプロセスの停止など
|
|
43
|
+
6. **関連ドキュメントとの整合性チェック(任意)**
|
|
44
|
+
- `docs/` や `packages/*/README.md` に書かれている利用例と、ここに記載したコマンドが大きく乖離していないかを目視確認するポイントをメモ
|
|
45
|
+
|
|
46
|
+
## コマンド記述のスタイル
|
|
47
|
+
|
|
48
|
+
- **コピペでそのまま実行できること** を最優先に書く
|
|
49
|
+
- 可能な限り、以下のように `cd` から書く
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cd /repos/ly-work-tools
|
|
53
|
+
npm run build
|
|
54
|
+
npm test
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- 各ブロックの前に、簡単なコメントで目的を書く
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# cli パッケージ単体ビルド
|
|
61
|
+
npm run build --workspace=packages/cli
|
|
62
|
+
|
|
63
|
+
# cli パッケージ単体テスト
|
|
64
|
+
npm test --workspace=packages/cli
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- エラー動作の確認では、終了コードも分かるようにするとなお良い
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# 0 除算でエラーになることを確認
|
|
71
|
+
node packages/cli/dist/index.js calculate divide 10 0 ; echo "exit code: $?"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## クリーンアップに関するルール
|
|
75
|
+
|
|
76
|
+
コマンドライン確認の手順の中で、環境に影響を与える操作を行った場合は、**必ず対応するクリーンアップ手順も同じファイルに書きます。**
|
|
77
|
+
|
|
78
|
+
### 例: `npm link` でグローバル CLI を登録した場合
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# グローバルにリンク
|
|
82
|
+
npm link --workspace=packages/cli
|
|
83
|
+
|
|
84
|
+
# bin 経由の動作確認
|
|
85
|
+
ly-tools echo "CLI via bin"
|
|
86
|
+
|
|
87
|
+
# 確認後にリンク解除(任意)
|
|
88
|
+
# ※ npm の仕様上、workspace フラグ付き unlink はエラーになるため、
|
|
89
|
+
# グローバルからはパッケージ名で unlink する
|
|
90
|
+
npm unlink -g @ly-work-tools/cli
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
その他、ローカルに残るプロセス・一時ディレクトリなどがあれば、
|
|
94
|
+
|
|
95
|
+
- 「どこに何ができるのか」
|
|
96
|
+
- 「どうすれば元に戻せるか」
|
|
97
|
+
|
|
98
|
+
を明示的に書いてください。
|
|
99
|
+
|
|
100
|
+
## 期待する運用イメージ
|
|
101
|
+
|
|
102
|
+
- 新しい機能を実装したときや、既存機能を変更したときに、対応する E2E テスト手順を `docs-ai/e2e-test/xxx-e2e.md` に追加・更新する
|
|
103
|
+
- 開発者や AI エージェントが、「この機能ってどうやって動作確認すればいいんだっけ?」と思ったときに、このディレクトリを開けば一通りの手順が分かる状態を目指します。
|
|
104
|
+
- すべてのコードは何らかの形で CLI から実行可能で、その入力と出力をチェックすれば動作が問題ないことを確認できるようにします。
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: test
|
|
3
|
+
category: github-actions
|
|
4
|
+
focus: test-workflow
|
|
5
|
+
applyTo: ".github/workflows/*.{yml,yaml}"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# GitHub Actions テストワークフロー標準
|
|
9
|
+
|
|
10
|
+
## 概要
|
|
11
|
+
|
|
12
|
+
GitHub Actions でテストワークフローを作成する際の統一的な書き方を定めたルールです。
|
|
13
|
+
一貫性のあるCI/CD設定により、メンテナンス性と信頼性を向上させます。
|
|
14
|
+
|
|
15
|
+
## 基本方針
|
|
16
|
+
|
|
17
|
+
### ワークフロー構成の原則
|
|
18
|
+
|
|
19
|
+
- **明確なトリガー設定**: どのブランチ・イベントでテストを実行するか明示する
|
|
20
|
+
- **適切なNode.jsバージョン指定**: プロジェクトで使用する Node.js バージョンをマトリックスで管理
|
|
21
|
+
- **段階的な実行**: 依存関係のインストール → ビルド → テスト の順序を守る
|
|
22
|
+
- **検証の網羅性**: ビルド成果物の動作確認を含める
|
|
23
|
+
|
|
24
|
+
## ワークフロー構造
|
|
25
|
+
|
|
26
|
+
### 必須要素
|
|
27
|
+
|
|
28
|
+
GitHub Actions のテストワークフローには、以下の要素を必ず含めてください:
|
|
29
|
+
|
|
30
|
+
#### 1. ワークフロー名とトリガー
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
name: Test
|
|
34
|
+
|
|
35
|
+
on:
|
|
36
|
+
push:
|
|
37
|
+
branches: [main, develop, feature/*, codex/**, copilot/**]
|
|
38
|
+
workflow_dispatch:
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- `name`: ワークフロー名は `Test` など、目的が明確な名前にする
|
|
42
|
+
- `on.push.branches`: テストを実行する対象ブランチを明示する
|
|
43
|
+
- メインブランチ(`main`, `develop`)
|
|
44
|
+
- フィーチャーブランチパターン(`feature/*`, `codex/**`, `copilot/**`)
|
|
45
|
+
- `workflow_dispatch`: 手動実行を可能にする
|
|
46
|
+
|
|
47
|
+
#### 2. ジョブ定義
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
jobs:
|
|
51
|
+
test:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
strategy:
|
|
54
|
+
matrix:
|
|
55
|
+
node-version: [20.x]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `runs-on`: `ubuntu-latest` を使用(特別な理由がない限り)
|
|
59
|
+
- `strategy.matrix`: Node.js バージョンをマトリックスで管理
|
|
60
|
+
- プロジェクトで使用する Node.js のメジャーバージョンを指定
|
|
61
|
+
- 複数バージョンでテストする場合は配列に追加(例: `[18.x, 20.x]`)
|
|
62
|
+
|
|
63
|
+
#### 3. ステップ構成
|
|
64
|
+
|
|
65
|
+
テストワークフローのステップは、以下の順序で構成します:
|
|
66
|
+
|
|
67
|
+
##### 3.1 リポジトリのチェックアウト
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
- uses: actions/checkout@v4
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- 常に最新の安定版アクション(v4)を使用
|
|
74
|
+
- 特別な理由がない限り追加オプションは不要
|
|
75
|
+
|
|
76
|
+
##### 3.2 Node.js のセットアップ
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
80
|
+
uses: actions/setup-node@v4
|
|
81
|
+
with:
|
|
82
|
+
node-version: ${{ matrix.node-version }}
|
|
83
|
+
cache: "npm"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- アクション名にはマトリックス変数を含めて、どのバージョンを使用しているか明示
|
|
87
|
+
- `cache: "npm"` で依存関係をキャッシュし、実行時間を短縮
|
|
88
|
+
- `node-version` はマトリックスの値を使用
|
|
89
|
+
|
|
90
|
+
##### 3.3 認証設定(必要な場合)
|
|
91
|
+
|
|
92
|
+
プライベートパッケージや GitHub Packages を使用する場合:
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
- name: Setup npmrc
|
|
96
|
+
uses: ./.github/actions/setup-npmrc
|
|
97
|
+
with:
|
|
98
|
+
github_token: ${{ secrets.GH_TOKEN }}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- カスタムアクションやシークレットを使用して認証を設定
|
|
102
|
+
- パブリックパッケージのみの場合は不要
|
|
103
|
+
|
|
104
|
+
##### 3.4 依存関係のインストール
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
- name: Install dependencies
|
|
108
|
+
run: npm ci
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- **必ず `npm ci` を使用**(`npm install` ではない)
|
|
112
|
+
- `npm ci` は package-lock.json に基づいて厳密にインストールするため、再現性が高い
|
|
113
|
+
- 既存の node_modules を削除してからインストールするため、クリーンな状態を保証
|
|
114
|
+
|
|
115
|
+
##### 3.5 ビルド
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
- name: Build
|
|
119
|
+
run: npm run build:ci
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- プロジェクトの CI 用ビルドスクリプトを実行
|
|
123
|
+
- スクリプト名は `build:ci` または `build` を使用
|
|
124
|
+
- テスト前に必ずビルドを完了させる
|
|
125
|
+
|
|
126
|
+
##### 3.6 テスト実行
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
- name: Run tests
|
|
130
|
+
run: npm run test:ci
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- CI 用のテストスクリプトを実行
|
|
134
|
+
- スクリプト名は `test:ci` または `test` を使用
|
|
135
|
+
- 通常は `vitest run` や `jest --ci` など、ウォッチモードを無効にした実行
|
|
136
|
+
|
|
137
|
+
##### 3.7 成果物の検証(推奨)
|
|
138
|
+
|
|
139
|
+
ビルド成果物が正しく動作することを検証します:
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
- name: Verify CLI executable
|
|
143
|
+
run: |
|
|
144
|
+
./dist/cli.js --help
|
|
145
|
+
|
|
146
|
+
- name: Test CLI functionality
|
|
147
|
+
run: |
|
|
148
|
+
# Create a test directory with some markdown files
|
|
149
|
+
mkdir -p test-workspace/docs
|
|
150
|
+
echo "# Test Document" > test-workspace/docs/test.md
|
|
151
|
+
echo "This is a test document" >> test-workspace/docs/test.md
|
|
152
|
+
|
|
153
|
+
# Test the extract command
|
|
154
|
+
./dist/cli.js extract --src test-workspace/docs --out test-output.md
|
|
155
|
+
|
|
156
|
+
# Verify the output file was created
|
|
157
|
+
if [ -f test-output.md ]; then
|
|
158
|
+
echo "✅ CLI extract command works correctly"
|
|
159
|
+
cat test-output.md
|
|
160
|
+
else
|
|
161
|
+
echo "❌ CLI extract command failed"
|
|
162
|
+
exit 1
|
|
163
|
+
fi
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- CLI ツールの場合: ヘルプ表示や基本コマンドの実行を確認
|
|
167
|
+
- API/ライブラリの場合: 簡単なインポートや使用例を実行
|
|
168
|
+
- 検証は実際のユースケースに近い形で行う
|
|
169
|
+
|
|
170
|
+
## ワークスペース構成の場合
|
|
171
|
+
|
|
172
|
+
モノレポ(workspace)構成の場合の追加考慮事項:
|
|
173
|
+
|
|
174
|
+
### ワークスペース全体のテスト
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
- name: Run all workspace tests
|
|
178
|
+
run: npm run test:all
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- `package.json` の scripts に `test:all: "npm run test --workspaces"` を定義
|
|
182
|
+
- 全パッケージのテストを一括実行
|
|
183
|
+
|
|
184
|
+
### 個別パッケージのビルド・テスト
|
|
185
|
+
|
|
186
|
+
必要に応じて、特定のパッケージのみをビルド・テストすることもできます:
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
- name: Build core package
|
|
190
|
+
run: npm run build --workspace=packages/core
|
|
191
|
+
|
|
192
|
+
- name: Test core package
|
|
193
|
+
run: npm test --workspace=packages/core
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## ベストプラクティス
|
|
197
|
+
|
|
198
|
+
### 1. キャッシュの活用
|
|
199
|
+
|
|
200
|
+
依存関係のキャッシュを有効にして、実行時間を短縮します:
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
- uses: actions/setup-node@v4
|
|
204
|
+
with:
|
|
205
|
+
node-version: ${{ matrix.node-version }}
|
|
206
|
+
cache: "npm" # ← 必須
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 2. 明確なステップ名
|
|
210
|
+
|
|
211
|
+
各ステップには、何を実行しているか明確に分かる名前を付けます:
|
|
212
|
+
|
|
213
|
+
```yaml
|
|
214
|
+
# ✅ 良い例
|
|
215
|
+
- name: Install dependencies
|
|
216
|
+
run: npm ci
|
|
217
|
+
|
|
218
|
+
# ❌ 悪い例
|
|
219
|
+
- name: Install
|
|
220
|
+
run: npm ci
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 3. エラー時の動作
|
|
224
|
+
|
|
225
|
+
デフォルトでは、ステップが失敗すると後続のステップはスキップされます。
|
|
226
|
+
これは通常望ましい動作なので、特別な理由がない限り変更しないでください。
|
|
227
|
+
|
|
228
|
+
### 4. 環境変数の設定
|
|
229
|
+
|
|
230
|
+
環境変数が必要な場合は、適切なスコープで設定します:
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
# ジョブ全体で使用する場合
|
|
234
|
+
jobs:
|
|
235
|
+
test:
|
|
236
|
+
env:
|
|
237
|
+
NODE_ENV: test
|
|
238
|
+
|
|
239
|
+
# 特定のステップのみで使用する場合
|
|
240
|
+
- name: Run tests
|
|
241
|
+
run: npm test
|
|
242
|
+
env:
|
|
243
|
+
CI: true
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### 5. シークレットの使用
|
|
247
|
+
|
|
248
|
+
機密情報は必ず GitHub Secrets として管理し、直接記述しないでください:
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
# ✅ 良い例
|
|
252
|
+
with:
|
|
253
|
+
github_token: ${{ secrets.GH_TOKEN }}
|
|
254
|
+
|
|
255
|
+
# ❌ 悪い例(絶対にしないこと)
|
|
256
|
+
with:
|
|
257
|
+
github_token: ghp_xxxxxxxxxxxx
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## アンチパターン
|
|
261
|
+
|
|
262
|
+
### ❌ 避けるべきパターン
|
|
263
|
+
|
|
264
|
+
1. **`npm install` の使用**
|
|
265
|
+
```yaml
|
|
266
|
+
# ❌ 避ける
|
|
267
|
+
- run: npm install
|
|
268
|
+
|
|
269
|
+
# ✅ 推奨
|
|
270
|
+
- run: npm ci
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
2. **ビルドのスキップ**
|
|
274
|
+
```yaml
|
|
275
|
+
# ❌ 避ける
|
|
276
|
+
- name: Run tests
|
|
277
|
+
run: npm test # ビルドせずにテスト
|
|
278
|
+
|
|
279
|
+
# ✅ 推奨
|
|
280
|
+
- name: Build
|
|
281
|
+
run: npm run build:ci
|
|
282
|
+
- name: Run tests
|
|
283
|
+
run: npm run test:ci
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
3. **不明確なブランチパターン**
|
|
287
|
+
```yaml
|
|
288
|
+
# ❌ 避ける
|
|
289
|
+
on:
|
|
290
|
+
push: # 全ブランチで実行(意図しないブランチでもCI実行)
|
|
291
|
+
|
|
292
|
+
# ✅ 推奨
|
|
293
|
+
on:
|
|
294
|
+
push:
|
|
295
|
+
branches: [main, develop, feature/*]
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
4. **バージョン指定の欠如**
|
|
299
|
+
```yaml
|
|
300
|
+
# ❌ 避ける
|
|
301
|
+
- uses: actions/checkout # バージョン未指定
|
|
302
|
+
|
|
303
|
+
# ✅ 推奨
|
|
304
|
+
- uses: actions/checkout@v4 # 明示的なバージョン指定
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## テンプレート
|
|
308
|
+
|
|
309
|
+
### 基本的なテストワークフロー
|
|
310
|
+
|
|
311
|
+
```yaml
|
|
312
|
+
name: Test
|
|
313
|
+
|
|
314
|
+
on:
|
|
315
|
+
push:
|
|
316
|
+
branches: [main, develop, feature/*, codex/**, copilot/**]
|
|
317
|
+
workflow_dispatch:
|
|
318
|
+
|
|
319
|
+
jobs:
|
|
320
|
+
test:
|
|
321
|
+
runs-on: ubuntu-latest
|
|
322
|
+
strategy:
|
|
323
|
+
matrix:
|
|
324
|
+
node-version: [20.x]
|
|
325
|
+
steps:
|
|
326
|
+
- uses: actions/checkout@v4
|
|
327
|
+
|
|
328
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
329
|
+
uses: actions/setup-node@v4
|
|
330
|
+
with:
|
|
331
|
+
node-version: ${{ matrix.node-version }}
|
|
332
|
+
cache: "npm"
|
|
333
|
+
|
|
334
|
+
- name: Install dependencies
|
|
335
|
+
run: npm ci
|
|
336
|
+
|
|
337
|
+
- name: Build
|
|
338
|
+
run: npm run build:ci
|
|
339
|
+
|
|
340
|
+
- name: Run tests
|
|
341
|
+
run: npm run test:ci
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### CLI ツールのテストワークフロー
|
|
345
|
+
|
|
346
|
+
```yaml
|
|
347
|
+
name: Test
|
|
348
|
+
|
|
349
|
+
on:
|
|
350
|
+
push:
|
|
351
|
+
branches: [main, develop, feature/*, codex/**, copilot/**]
|
|
352
|
+
workflow_dispatch:
|
|
353
|
+
|
|
354
|
+
jobs:
|
|
355
|
+
test:
|
|
356
|
+
runs-on: ubuntu-latest
|
|
357
|
+
strategy:
|
|
358
|
+
matrix:
|
|
359
|
+
node-version: [20.x]
|
|
360
|
+
steps:
|
|
361
|
+
- uses: actions/checkout@v4
|
|
362
|
+
|
|
363
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
364
|
+
uses: actions/setup-node@v4
|
|
365
|
+
with:
|
|
366
|
+
node-version: ${{ matrix.node-version }}
|
|
367
|
+
cache: "npm"
|
|
368
|
+
|
|
369
|
+
- name: Install dependencies
|
|
370
|
+
run: npm ci
|
|
371
|
+
|
|
372
|
+
- name: Build
|
|
373
|
+
run: npm run build:ci
|
|
374
|
+
|
|
375
|
+
- name: Run tests
|
|
376
|
+
run: npm run test:ci
|
|
377
|
+
|
|
378
|
+
- name: Verify CLI executable
|
|
379
|
+
run: |
|
|
380
|
+
./dist/cli.js --help
|
|
381
|
+
|
|
382
|
+
- name: Test CLI functionality
|
|
383
|
+
run: |
|
|
384
|
+
# 実際のユースケースに基づいた動作確認
|
|
385
|
+
mkdir -p test-workspace
|
|
386
|
+
./dist/cli.js [your-command] --option value
|
|
387
|
+
# 結果の検証
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## 関連ルール
|
|
391
|
+
|
|
392
|
+
- [GitHub Actions Testing Policy](./github-actions-no-tests.md) - ワークフローファイル自体のテストに関するポリシー
|
|
393
|
+
- [テストタイムアウト設定](./timeout-configuration.md) - テスト実行時のタイムアウト設定
|
|
394
|
+
|
|
395
|
+
## 参考資料
|
|
396
|
+
|
|
397
|
+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
|
|
398
|
+
- [actions/setup-node](https://github.com/actions/setup-node)
|
|
399
|
+
- [actions/checkout](https://github.com/actions/checkout)
|
|
400
|
+
- [npm ci vs npm install](https://docs.npmjs.com/cli/v9/commands/npm-ci)
|
|
401
|
+
|
|
402
|
+
このルールに従うことで、GitHub Actions のテストワークフローを一貫性のある、メンテナンスしやすい形で管理できます。
|
package/dist/cli.js
CHANGED
|
@@ -18461,7 +18461,25 @@ async function findYamlFilesRecursively(dir, baseDir = dir) {
|
|
|
18461
18461
|
return yamlFiles;
|
|
18462
18462
|
}
|
|
18463
18463
|
/**
|
|
18464
|
-
*
|
|
18464
|
+
* Extracts description from a preset YAML file
|
|
18465
|
+
* Reads the top-level 'description' field from the preset
|
|
18466
|
+
*/
|
|
18467
|
+
async function extractPresetDescription(presetPath) {
|
|
18468
|
+
try {
|
|
18469
|
+
const content = await fs.readFile(presetPath, "utf-8");
|
|
18470
|
+
const data = YAML.parse(content);
|
|
18471
|
+
// Return the description field if it exists
|
|
18472
|
+
if (data?.description && typeof data.description === "string") {
|
|
18473
|
+
return data.description.trim();
|
|
18474
|
+
}
|
|
18475
|
+
}
|
|
18476
|
+
catch {
|
|
18477
|
+
// Ignore file reading or parsing errors
|
|
18478
|
+
}
|
|
18479
|
+
return undefined;
|
|
18480
|
+
}
|
|
18481
|
+
/**
|
|
18482
|
+
* Lists available package presets with descriptions
|
|
18465
18483
|
*/
|
|
18466
18484
|
async function listPresets() {
|
|
18467
18485
|
const packageRoot = findPackageRoot();
|
|
@@ -18474,12 +18492,36 @@ async function listPresets() {
|
|
|
18474
18492
|
return;
|
|
18475
18493
|
}
|
|
18476
18494
|
// eslint-disable-next-line no-console
|
|
18477
|
-
console.log("Available presets
|
|
18478
|
-
|
|
18495
|
+
console.log("Available presets:\n");
|
|
18496
|
+
for (const file of yamlFiles) {
|
|
18479
18497
|
const presetName = file.replace(/\.(yaml|yml)$/, "");
|
|
18498
|
+
const presetPath = path.join(presetsDir, file);
|
|
18499
|
+
const description = await extractPresetDescription(presetPath);
|
|
18480
18500
|
// eslint-disable-next-line no-console
|
|
18481
18501
|
console.log(` :${presetName}`);
|
|
18482
|
-
|
|
18502
|
+
if (description) {
|
|
18503
|
+
// Indent and wrap description text
|
|
18504
|
+
const maxWidth = 70;
|
|
18505
|
+
const words = description.split(" ");
|
|
18506
|
+
let currentLine = " ";
|
|
18507
|
+
words.forEach((word) => {
|
|
18508
|
+
if (currentLine.length + word.length + 1 > maxWidth) {
|
|
18509
|
+
// eslint-disable-next-line no-console
|
|
18510
|
+
console.log(currentLine);
|
|
18511
|
+
currentLine = " " + word;
|
|
18512
|
+
}
|
|
18513
|
+
else {
|
|
18514
|
+
currentLine += (currentLine === " " ? "" : " ") + word;
|
|
18515
|
+
}
|
|
18516
|
+
});
|
|
18517
|
+
if (currentLine.trim()) {
|
|
18518
|
+
// eslint-disable-next-line no-console
|
|
18519
|
+
console.log(currentLine);
|
|
18520
|
+
}
|
|
18521
|
+
// eslint-disable-next-line no-console
|
|
18522
|
+
console.log("");
|
|
18523
|
+
}
|
|
18524
|
+
}
|
|
18483
18525
|
}
|
|
18484
18526
|
catch (error) {
|
|
18485
18527
|
// eslint-disable-next-line no-console
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aramassa/ai-rules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "This repository collects guidelines and instructions for developing AI agents. It contains documents covering communication rules, coding standards, testing strategies, and general operational practices.",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"packages/extract",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/Aramassa/ai-rules#readme",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@aramassa/skel-extractor": "^0.0.
|
|
50
|
+
"@aramassa/skel-extractor": "^0.0.5",
|
|
51
51
|
"@rollup/plugin-alias": "^5.1.1",
|
|
52
52
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
53
53
|
"@rollup/plugin-json": "^6.1.0",
|
package/presets/README.md
CHANGED
|
@@ -109,6 +109,29 @@ npx @aramassa/ai-rules extract --recipe presets/chatmodes.yaml --src artifact/ch
|
|
|
109
109
|
- 構造化されたプランニングプロセスが必要なプロジェクト
|
|
110
110
|
- 継続的なinstruction改善を行うプロジェクト
|
|
111
111
|
|
|
112
|
+
### `npm-publish.yaml`
|
|
113
|
+
|
|
114
|
+
npmパッケージのGitHub Actions公開ワークフローを実装するための設定です。
|
|
115
|
+
|
|
116
|
+
**含まれる内容:**
|
|
117
|
+
|
|
118
|
+
- npm Package Publishing Workflow Rules - GitHub PackagesとnpmjsへのDual Registry公開ワークフロー
|
|
119
|
+
- Package Management Rules - パッケージ管理とビルドプロセス
|
|
120
|
+
- Basic Communication Rules - 基本的なコミュニケーションルール
|
|
121
|
+
|
|
122
|
+
**使用方法:**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npx @aramassa/ai-rules extract --recipe presets/npm-publish.yaml --src artifact/instructions
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**対象プロジェクト:**
|
|
129
|
+
|
|
130
|
+
- npm パッケージを公開するプロジェクト
|
|
131
|
+
- GitHub Packages と npmjs.org への Dual Registry 公開が必要なプロジェクト
|
|
132
|
+
- GitHub Actions を使用した自動パッケージ公開を行うプロジェクト
|
|
133
|
+
- セマンティックバージョニングとリリース管理が必要なプロジェクト
|
|
134
|
+
|
|
112
135
|
## カスタムプリセットの作成
|
|
113
136
|
|
|
114
137
|
新しいプリセットを作成する場合は、以下の手順で行ってください:
|
package/presets/basic.yaml
CHANGED
package/presets/chatmodes.yaml
CHANGED
package/presets/docs-ai.yaml
CHANGED
package/presets/electron.yaml
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
description: npmパッケージのGitHub Actions公開ワークフローを実装するための設定です。
|
|
2
|
+
|
|
3
|
+
recipe:
|
|
4
|
+
- import: :basic
|
|
5
|
+
- title: npm Package Publishing Workflow Rules
|
|
6
|
+
frontmatter:
|
|
7
|
+
"@type": true
|
|
8
|
+
"@category": true
|
|
9
|
+
"@framework": true
|
|
10
|
+
description: |
|
|
11
|
+
Implementation rules for npm package publishing workflows with GitHub Actions.
|
|
12
|
+
Covers dual registry publishing (GitHub Packages and npmjs.org), version management,
|
|
13
|
+
build processes, artifact handling, and secret configuration for automated publishing.
|
|
14
|
+
applyTo: ".github/workflows/**/*.yml"
|
|
15
|
+
out: ./.github/instructions/npm-publish.instructions.md
|
|
16
|
+
type: development-rules
|
|
17
|
+
category: package-publish
|
|
18
|
+
framework: npm
|