@aramassa/ai-rules 0.9.5 → 0.9.7

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,462 @@
1
+ ---
2
+ type: prompt
3
+ category: github-copilot
4
+ focus: agent-environment
5
+ applyTo: ".github/workflows/copilot-setup-steps.yml"
6
+ human-instruction: |-
7
+ ## GitHub Copilot Coding Agent 環境カスタマイズについて
8
+
9
+ このルールは、GitHub Copilot Coding Agent の開発環境をカスタマイズする方法を説明しています。
10
+ 以下の点で人間の判断が重要です:
11
+
12
+ - **環境要件の分析**: プロジェクトに必要なツールや依存関係の特定
13
+ - **セキュリティの考慮**: シークレットや認証情報の適切な管理
14
+ - **パフォーマンス最適化**: ランナーサイズやキャッシュ戦略の選択
15
+ - **コスト管理**: larger runners や self-hosted runners の費用対効果の判断
16
+
17
+ AIは設定ファイルの生成を支援できますが、プロジェクト固有の要件やセキュリティポリシーの判断は人間が行う必要があります。
18
+ ---
19
+
20
+ # GitHub Copilot Coding Agent 環境カスタマイズガイド
21
+
22
+ ## 概要
23
+
24
+ GitHub Copilot Coding Agent は、独自のエフェメラルな開発環境(GitHub Actions によって提供)でタスクを実行します。この環境をカスタマイズすることで、エージェントがより効果的にコードの探索、変更、テスト、リンティングなどを実行できるようになります。
25
+
26
+ 本ドキュメントは、GitHub 公式ドキュメントに基づいて作成されています:
27
+ https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
28
+
29
+ ## Copilot 環境のカスタマイズについて
30
+
31
+ ### 基本概念
32
+
33
+ Copilot Coding Agent は、タスク実行時に以下の環境を利用します:
34
+
35
+ - **エフェメラル環境**: タスクごとに作成され、完了後に破棄される一時的な環境
36
+ - **GitHub Actions ベース**: GitHub Actions のランナー上で実行される
37
+ - **独立した環境**: 各タスクは隔離された環境で実行される
38
+
39
+ ### カスタマイズ可能な項目
40
+
41
+ 以下の項目をカスタマイズできます:
42
+
43
+ 1. **ツールや依存関係のプリインストール**
44
+ 2. **環境変数の設定**
45
+ 3. **より大きな GitHub ホステッドランナーへのアップグレード**
46
+ 4. **Git Large File Storage (LFS) の有効化**
47
+ 5. **セルフホステッドランナーの使用(ARC 経由)**
48
+
49
+ ## ツールや依存関係のプリインストール
50
+
51
+ ### 概要
52
+
53
+ Copilot はプロジェクトのビルド、コンパイル、自動テスト、リンターの実行などを行うため、プロジェクトの依存関係をインストールする必要があります。Copilot は自動的にこれらを発見してインストールしようとしますが、以下の理由でプリインストールが推奨されます:
54
+
55
+ - **速度**: 試行錯誤によるインストールは時間がかかる
56
+ - **信頼性**: LLM の非決定的な性質により、インストールが不安定になる可能性
57
+ - **制限事項**: プライベートな npm レジストリなど、Copilot が自動的にアクセスできない依存関係がある
58
+
59
+ ### プリインストールの設定方法
60
+
61
+ `.github/workflows/copilot-setup-steps.yml` ファイルを作成し、カスタムセットアップステップを定義します:
62
+
63
+ ```yaml
64
+ name: Copilot setup steps
65
+
66
+ on:
67
+ workflow_dispatch:
68
+
69
+ jobs:
70
+ copilot-setup-steps:
71
+ runs-on: ubuntu-latest
72
+ permissions:
73
+ contents: read
74
+ steps:
75
+ - uses: actions/checkout@v4
76
+
77
+ # Node.js プロジェクトの例
78
+ - name: Setup Node.js
79
+ uses: actions/setup-node@v4
80
+ with:
81
+ node-version: '20'
82
+ cache: 'npm'
83
+
84
+ - name: Install dependencies
85
+ run: npm ci
86
+
87
+ # Python プロジェクトの例
88
+ - name: Setup Python
89
+ uses: actions/setup-python@v5
90
+ with:
91
+ python-version: '3.11'
92
+ cache: 'pip'
93
+
94
+ - name: Install Python dependencies
95
+ run: pip install -r requirements.txt
96
+
97
+ # カスタムツールのインストール例
98
+ - name: Install custom tools
99
+ run: |
100
+ sudo apt-get update
101
+ sudo apt-get install -y your-custom-tool
102
+ ```
103
+
104
+ ### プライベート npm レジストリへの認証
105
+
106
+ プライベート npm レジストリを使用する場合:
107
+
108
+ ```yaml
109
+ - name: Setup .npmrc
110
+ run: |
111
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
112
+ echo "@your-scope:registry=https://your-private-registry.com/" >> ~/.npmrc
113
+
114
+ - name: Install dependencies
115
+ run: npm ci
116
+ ```
117
+
118
+ ### ベストプラクティス
119
+
120
+ - **キャッシュの活用**: `cache` オプションを使用して依存関係のダウンロード時間を短縮
121
+ - **必要最小限のインストール**: 実際に必要なツールのみをインストール
122
+ - **バージョン固定**: ツールのバージョンを明示的に指定して、一貫性を確保
123
+
124
+ ## 環境変数の設定
125
+
126
+ ### 概要
127
+
128
+ Copilot の環境で使用するツールや依存関係を設定・認証するために、環境変数を設定できます。
129
+
130
+ ### 設定方法
131
+
132
+ #### 1. GitHub Actions の変数またはシークレットを作成
133
+
134
+ **機密情報を含む場合**(パスワード、API キーなど):
135
+ - GitHub Actions のシークレットを使用
136
+
137
+ **機密情報を含まない場合**:
138
+ - GitHub Actions の変数を使用
139
+
140
+ #### 2. リポジトリ設定での作成手順
141
+
142
+ 1. GitHub のリポジトリページに移動
143
+ 2. **Settings** をクリック
144
+ 3. サイドバーの **Secrets and variables** > **Actions** をクリック
145
+ 4. **Variables** タブまたは **Secrets** タブを選択
146
+ 5. **New repository variable** または **New repository secret** をクリック
147
+ 6. 変数名とを入力
148
+ - **Environment**: `copilot` を選択(重要)
149
+ 7. **Add variable** または **Add secret** をクリック
150
+
151
+ #### 3. ワークフローでの使用例
152
+
153
+ ```yaml
154
+ jobs:
155
+ copilot-setup-steps:
156
+ runs-on: ubuntu-latest
157
+ environment: copilot # 環境を指定
158
+ steps:
159
+ - uses: actions/checkout@v4
160
+
161
+ - name: Configure tool with environment variables
162
+ env:
163
+ API_KEY: ${{ secrets.API_KEY }}
164
+ API_ENDPOINT: ${{ vars.API_ENDPOINT }}
165
+ run: |
166
+ echo "API_ENDPOINT=$API_ENDPOINT" >> $GITHUB_ENV
167
+ # ツールの設定
168
+ tool configure --api-key "$API_KEY"
169
+ ```
170
+
171
+ ### セキュリティのベストプラクティス
172
+
173
+ - **シークレットの使用**: 機密情報は必ず GitHub Actions のシークレットとして保存
174
+ - **環境の指定**: `environment: copilot` を明示的に指定
175
+ - **最小権限の原則**: 必要最小限の権限のみを付与
176
+ - **シークレットのローテーション**: 定期的にシークレットを更新
177
+
178
+ ## より大きな GitHub ホステッドランナーへのアップグレード
179
+
180
+ ### 概要
181
+
182
+ デフォルトでは、Copilot は標準的な GitHub Actions ランナー(限られたリソース)で動作します。より大きなランナーを使用することで、以下のメリットがあります:
183
+
184
+ - **より多くの RAM、CPU、ディスクスペース**
185
+ - **高度なネットワーク制御**
186
+ - **パフォーマンスの向上**(依存関係のダウンロードやテスト実行時)
187
+
188
+ ### 設定方法
189
+
190
+ #### 1. Larger runners の追加
191
+
192
+ GitHub のドキュメントを参照: [Larger runners](https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners)
193
+
194
+ #### 2. Copilot 環境での有効化
195
+
196
+ リポジトリ設定で、`copilot` 環境に larger runners へのアクセスを許可します:
197
+
198
+ 1. **Settings** > **Environments** > **copilot** に移動
199
+ 2. **Deployment protection rules** で larger runners を選択
200
+ 3. 変更を保存
201
+
202
+ #### 3. ワークフローでの指定
203
+
204
+ ```yaml
205
+ jobs:
206
+ copilot-setup-steps:
207
+ runs-on: ubuntu-latest-4-cores # larger runner を指定
208
+ # または
209
+ # runs-on: ubuntu-latest-8-cores
210
+ # runs-on: ubuntu-latest-16-cores
211
+ steps:
212
+ - uses: actions/checkout@v4
213
+ # ... その他のステップ
214
+ ```
215
+
216
+ ### 考慮事項
217
+
218
+ - **コスト**: Larger runners は標準ランナーよりもコストが高い
219
+ - **必要性の評価**: パフォーマンス問題が実際に発生している場合にのみ使用を検討
220
+ - **適切なサイズ選択**: プロジェクトの要件に応じた適切なサイズを選択
221
+
222
+ ## セルフホステッドランナーの使用(ARC)
223
+
224
+ ### 概要
225
+
226
+ ARC (Actions Runner Controller) を使用して、セルフホステッドランナーで Copilot Coding Agent を実行できます。
227
+
228
+ ### 前提条件
229
+
230
+ - ARC マネージドスケールセットが環境にセットアップされている
231
+ - Ubuntu x64 Linux ランナー(Windows や macOS は非対応)
232
+ - 永続的なランナーは推奨されない(オートスケーリングシナリオ向け)
233
+
234
+ ### 設定手順
235
+
236
+ #### 1. ARC スケールセットのセットアップ
237
+
238
+ GitHub Actions Runner Controller のドキュメントを参照:
239
+ [Actions Runner Controller](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller)
240
+
241
+ #### 2. ワークフローでの指定
242
+
243
+ ```yaml
244
+ jobs:
245
+ copilot-setup-steps:
246
+ runs-on: arc-scale-set-name # ARC スケールセット名を指定
247
+ steps:
248
+ - uses: actions/checkout@v4
249
+ # ... その他のステップ
250
+ ```
251
+
252
+ #### 3. ファイアウォールの無効化
253
+
254
+ セルフホステッドランナーを使用する場合、リポジトリ設定で Copilot coding agent の統合ファイアウォールを無効化する必要があります。
255
+
256
+ **⚠️ 警告**: ファイアウォールを無効化すると、Copilot と セルフホステッド環境間の隔離が減少します。代替のネットワークセキュリティ制御を実装する必要があります。
257
+
258
+ ### セキュリティの考慮事項
259
+
260
+ #### 必須エンドポイント
261
+
262
+ セルフホステッドランナーから以下のエンドポイントへのアクセスを許可する必要があります:
263
+
264
+ - `api.githubcopilot.com`
265
+ - `uploads.github.com`
266
+ - `user-images.githubusercontent.com`
267
+
268
+ その他、GitHub Actions セルフホステッドランナーに必要なホストの完全なリストについては、[Self-hosted runners reference](https://docs.github.com/en/actions/reference/runners/self-hosted-runners#accessible-domains-by-function) を参照してください。
269
+
270
+ #### セキュリティ対策
271
+
272
+ - **ネットワーク通信制御**: ホスティング環境に厳格なネットワーク通信制御を実装
273
+ - **最小権限**: ランナーに必要最小限の権限のみを付与
274
+ - **監視**: ランナーの活動を継続的に監視
275
+ - **隔離**: 可能な限り、Copilot 専用の隔離された環境でランナーを実行
276
+
277
+ ## Git Large File Storage (LFS) の有効化
278
+
279
+ ### 概要
280
+
281
+ Git LFS を使用してリポジトリに大きなファイルを保存している場合、Copilot の環境で Git LFS をインストールし、LFS オブジェクトをフェッチする必要があります。
282
+
283
+ ### 設定方法
284
+
285
+ `copilot-setup-steps` ジョブに `actions/checkout` ステップを追加し、`lfs` オプションを `true` に設定します:
286
+
287
+ ```yaml
288
+ name: Copilot setup steps
289
+
290
+ on:
291
+ workflow_dispatch:
292
+
293
+ jobs:
294
+ copilot-setup-steps:
295
+ runs-on: ubuntu-latest
296
+ permissions:
297
+ contents: read # actions/checkout に必要
298
+ steps:
299
+ - uses: actions/checkout@v5
300
+ with:
301
+ lfs: true # Git LFS を有効化
302
+
303
+ # ... その他のセットアップステップ
304
+ ```
305
+
306
+ ### 注意事項
307
+
308
+ - **帯域幅とストレージ**: Git LFS のファイルは GitHub の LFS 帯域幅とストレージクォータを消費します
309
+ - **パフォーマンス**: 大きなファイルのダウンロードには時間がかかる可能性があります
310
+ - **必要性の確認**: プロジェクトで実際に LFS ファイルが必要な場合にのみ有効化
311
+
312
+ ## ワークフロー全体の例
313
+
314
+ ### 基本的な Node.js プロジェクト
315
+
316
+ ```yaml
317
+ name: Copilot setup steps
318
+
319
+ on:
320
+ workflow_dispatch:
321
+
322
+ jobs:
323
+ copilot-setup-steps:
324
+ runs-on: ubuntu-latest
325
+ environment: copilot
326
+ permissions:
327
+ contents: read
328
+ steps:
329
+ - uses: actions/checkout@v5
330
+ with:
331
+ lfs: false # LFS が不要な場合
332
+
333
+ - name: Setup Node.js
334
+ uses: actions/setup-node@v4
335
+ with:
336
+ node-version: '20'
337
+ cache: 'npm'
338
+
339
+ - name: Install dependencies
340
+ run: npm ci
341
+
342
+ - name: Build project
343
+ run: npm run build
344
+ ```
345
+
346
+ ### 複雑なプロジェクト(複数言語、カスタムツール)
347
+
348
+ ```yaml
349
+ name: Copilot setup steps
350
+
351
+ on:
352
+ workflow_dispatch:
353
+
354
+ jobs:
355
+ copilot-setup-steps:
356
+ runs-on: ubuntu-latest-4-cores # larger runner を使用
357
+ environment: copilot
358
+ permissions:
359
+ contents: read
360
+ steps:
361
+ - uses: actions/checkout@v5
362
+ with:
363
+ lfs: true # Git LFS を有効化
364
+
365
+ # Node.js セットアップ
366
+ - name: Setup Node.js
367
+ uses: actions/setup-node@v4
368
+ with:
369
+ node-version: '20'
370
+ cache: 'npm'
371
+
372
+ # Python セットアップ
373
+ - name: Setup Python
374
+ uses: actions/setup-python@v5
375
+ with:
376
+ python-version: '3.11'
377
+ cache: 'pip'
378
+
379
+ # カスタムツールのインストール
380
+ - name: Install system dependencies
381
+ run: |
382
+ sudo apt-get update
383
+ sudo apt-get install -y build-essential libpq-dev
384
+
385
+ # プライベートレジストリへの認証
386
+ - name: Setup .npmrc
387
+ run: |
388
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
389
+
390
+ # 依存関係のインストール
391
+ - name: Install Node.js dependencies
392
+ run: npm ci
393
+
394
+ - name: Install Python dependencies
395
+ run: pip install -r requirements.txt
396
+
397
+ # 環境変数の設定
398
+ - name: Configure environment
399
+ env:
400
+ DATABASE_URL: ${{ secrets.DATABASE_URL }}
401
+ API_KEY: ${{ secrets.API_KEY }}
402
+ run: |
403
+ echo "ENVIRONMENT=development" >> $GITHUB_ENV
404
+
405
+ # ビルド
406
+ - name: Build project
407
+ run: npm run build
408
+ ```
409
+
410
+ ## トラブルシューティング
411
+
412
+ ### よくある問題と解決策
413
+
414
+ #### 1. 依存関係のインストールが失敗する
415
+
416
+ **原因**:
417
+ - プライベートレジストリへの認証が不足
418
+ - ネットワーク制限
419
+
420
+ **解決策**:
421
+ - シークレットと認証設定を確認
422
+ - 必要なエンドポイントへのアクセスを許可
423
+
424
+ #### 2. パフォーマンスが遅い
425
+
426
+ **原因**:
427
+ - 標準ランナーのリソースが不足
428
+ - キャッシュが有効化されていない
429
+
430
+ **解決策**:
431
+ - Larger runners へのアップグレードを検討
432
+ - 依存関係のキャッシュを有効化
433
+
434
+ #### 3. セルフホステッドランナーで接続エラー
435
+
436
+ **原因**:
437
+ - ファイアウォールの設定が不適切
438
+ - 必要なエンドポイントへのアクセスがブロックされている
439
+
440
+ **解決策**:
441
+ - Copilot 用のファイアウォールを無効化
442
+ - 必要なエンドポイントをホワイトリストに追加
443
+
444
+ ## 関連ドキュメント
445
+
446
+ - [Customizing or disabling the firewall for GitHub Copilot coding agent](https://docs.github.com/en/copilot/customizing-copilot/customizing-or-disabling-the-firewall-for-copilot-coding-agent)
447
+ - [Larger runners](https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners)
448
+ - [Actions Runner Controller](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller)
449
+ - [Self-hosted runners reference](https://docs.github.com/en/actions/reference/runners/self-hosted-runners)
450
+ - [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions)
451
+
452
+ ## まとめ
453
+
454
+ GitHub Copilot Coding Agent の環境カスタマイズにより、以下が実現できます:
455
+
456
+ ✅ **高速化**: 依存関係のプリインストールによる実行時間の短縮
457
+ ✅ **信頼性向上**: 確実な依存関係のインストール
458
+ ✅ **柔軟性**: プロジェクト固有の要件への対応
459
+ ✅ **セキュリティ**: 適切な認証と環境変数の管理
460
+ ✅ **パフォーマンス最適化**: Larger runners やセルフホステッドランナーの活用
461
+
462
+ プロジェクトの要件に応じて、適切なカスタマイズを実施してください。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aramassa/ai-rules",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
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",
@@ -0,0 +1,16 @@
1
+ description: 計画済みの修正をrepoルールに沿って適用するワークフロー。skel先行更新、構造検証、テスト運用、docs更新、PR/Issueコメントによる進捗共有を標準化します。
2
+
3
+ config:
4
+ baseDir: .github/prompts
5
+
6
+ recipe:
7
+ - title: "prompt apply-fix ワークフロー"
8
+ out: "apply-fix.prompt.md"
9
+ type: "prompt"
10
+ filters:
11
+ category: "workflow"
12
+ focus: "implementation-application"
13
+ frontmatter:
14
+ description: "計画済みの修正をrepoルールに沿って適用。skel先行更新、構造検証、テスト運用、docs更新、PR/Issueコメントで進捗共有を標準化。"
15
+ agent: "agent"
16
+ applyTo: "**/*"
@@ -0,0 +1,16 @@
1
+ description: 実装完了後のワークフローを自動化。e2eテスト実行、PR本文更新、Checksへの登録を効率的に実施します。
2
+
3
+ config:
4
+ baseDir: .github/prompts
5
+
6
+ recipe:
7
+ - title: "prompt fix-implementation ワークフロー"
8
+ out: "fix-implementation.prompt.md"
9
+ type: "prompt"
10
+ filters:
11
+ category: "workflow"
12
+ focus: "implementation-completion"
13
+ frontmatter:
14
+ description: "実装完了後のワークフローを自動化。e2eテスト実行、PR本文更新、Checksへの登録を効率的に実施。"
15
+ agent: "agent"
16
+ applyTo: "**/*"
@@ -0,0 +1,15 @@
1
+ description: GitHub Copilot Coding Agent の環境カスタマイズに関するプロンプトです。
2
+
3
+ config:
4
+ baseDir: .github/prompts
5
+
6
+ recipe:
7
+ - title: "GitHub Copilot Agent Environment Customization"
8
+ out: "copilot-agent-environment.prompt.md"
9
+ type: "prompt"
10
+ filters:
11
+ category: "github-copilot"
12
+ focus: "agent-environment"
13
+ frontmatter:
14
+ description: "GitHub Copilot Coding Agent の開発環境をカスタマイズするための包括的なガイド。依存関係のプリインストール、環境変数、larger runners、Git LFS などを網羅。"
15
+ applyTo: ".github/workflows/copilot-setup-steps.yml"
@@ -12,4 +12,5 @@ recipe:
12
12
  focus: "plan-to-implementation"
13
13
  frontmatter:
14
14
  description: "VS Code Plan モードから Agent Coding への移行を自動化。計画完成後の Git/GitHub 操作を簡略化し、効率的な開発ワークフローを実現。"
15
+ agent: "agent"
15
16
  applyTo: "**/*"