@aramassa/ai-rules 0.8.1 → 0.9.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/agents/agent-creation.agent.md +2 -2
- package/artifact/instructions/package-management.md +29 -0
- package/artifact/instructions/rules/development/cli-design.md +286 -0
- package/artifact/instructions/rules/development/npm-package-rollup-build.md +883 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +136 -18
- package/package.json +2 -1
- package/presets/README.md +268 -14
- package/presets/agents.yaml +5 -1
- package/presets/basic.yaml +37 -0
- package/presets/github-workflow.yaml +36 -0
- package/presets/monorepo/typescript.yaml +12 -0
- package/presets/openai.yaml +17 -0
- package/presets/python.yaml +25 -0
- package/presets/test-best-practices.yaml +46 -0
- package/presets/typescript.yaml +27 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
type: agent
|
|
3
|
-
name:
|
|
3
|
+
name: AgentCreation
|
|
4
4
|
description: Specialized assistant for creating GitHub Copilot custom agent profiles with proper structure, tools configuration, and best practices based on official documentation
|
|
5
5
|
target: github-copilot
|
|
6
6
|
tools:
|
|
@@ -50,7 +50,7 @@ You are a specialized assistant for creating GitHub Copilot custom agent profile
|
|
|
50
50
|
|
|
51
51
|
```yaml
|
|
52
52
|
---
|
|
53
|
-
name:
|
|
53
|
+
name: UniqueAgentIdentifier
|
|
54
54
|
description: Clear explanation of agent's purpose and capabilities
|
|
55
55
|
---
|
|
56
56
|
```
|
|
@@ -44,6 +44,35 @@ human-instruction: |-
|
|
|
44
44
|
|
|
45
45
|
(名称はエコシステムに合わせて「モジュール」「パッケージ」等に読み替えて構いません)
|
|
46
46
|
|
|
47
|
+
### CLI エントリポイントのファイル命名規則
|
|
48
|
+
|
|
49
|
+
CLI アプリケーションを作成する際は、以下のファイル命名規則に従ってください。
|
|
50
|
+
|
|
51
|
+
#### 標準ファイル名
|
|
52
|
+
|
|
53
|
+
CLI のエントリポイントファイルは **`cli.*`** という名前を使用すること:
|
|
54
|
+
|
|
55
|
+
- **推奨パターン**: `cli.{拡張子}`
|
|
56
|
+
- 例: `cli.ts`, `cli.js`, `cli.py`, `cli.rb`, `cli.go`, `cli.rs`
|
|
57
|
+
|
|
58
|
+
#### 配置場所
|
|
59
|
+
|
|
60
|
+
- **パッケージルート**: `src/cli.*` または `lib/cli.*`
|
|
61
|
+
- **モノレポ構成**: `packages/{パッケージ名}/src/cli.*`
|
|
62
|
+
|
|
63
|
+
#### 命名規則の理由
|
|
64
|
+
|
|
65
|
+
- **一貫性**: プロジェクト間で統一された命名により、CLI エントリポイントの識別が容易
|
|
66
|
+
- **自動化**: `**/cli.*` パターンによる自動的なルール適用とツール連携
|
|
67
|
+
- **明確性**: ファイル名から CLI エントリポイントであることが即座に判別可能
|
|
68
|
+
|
|
69
|
+
#### 例外
|
|
70
|
+
|
|
71
|
+
以下の場合は、エコシステムの慣習に従って別の命名を使用することができます:
|
|
72
|
+
|
|
73
|
+
- Python: `__main__.py` または `{パッケージ名}/__main__.py`
|
|
74
|
+
- 複数の CLI コマンドを持つ場合: `cli/` ディレクトリ配下にコマンド別ファイル
|
|
75
|
+
|
|
47
76
|
### ローカルスクリプト/CLI の実行
|
|
48
77
|
|
|
49
78
|
ローカルの CLI やスクリプトを実行する前に、ビルド工程や生成物が必要な場合は必ず事前に準備(ビルド/インストール/リンク)してください。多くのエコシステムでは、実行コマンドがビルド済みの成果物やインストール済みのエントリポイントを前提にしています。
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: development-rules
|
|
3
|
+
category: cli-design, best-practices, configuration-management
|
|
4
|
+
focus: environment-file-support
|
|
5
|
+
applyTo: "**/cli.*"
|
|
6
|
+
human-instruction: |-
|
|
7
|
+
## CLI Environment File Support Guidelines
|
|
8
|
+
|
|
9
|
+
これは言語非依存のCLI設計ガイドラインです。すべてのCLIアプリケーションは、
|
|
10
|
+
環境変数ファイル(.env file)のサポートを標準機能として実装すべきです。
|
|
11
|
+
|
|
12
|
+
このルールにより、セキュリティ、保守性、開発者体験が大幅に向上します。
|
|
13
|
+
実装時は各言語のエコシステムに応じた適切なライブラリを使用してください。
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# CLI Environment File Support Guidelines
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
すべてのCLIアプリケーションは、設定管理の一環として環境変数ファイルをサポートすべきです。これにより、セキュリティ、保守性、開発者体験が大幅に向上します。
|
|
21
|
+
|
|
22
|
+
このガイドラインは言語非依存の原則を定義しており、TypeScript、Python、Rust、Goなど、どの言語でCLIを実装する場合にも適用されます。
|
|
23
|
+
|
|
24
|
+
## 主な要件
|
|
25
|
+
|
|
26
|
+
### 1. Environment File Option
|
|
27
|
+
|
|
28
|
+
CLIは必ず `--env-file` オプション(または同等の機能)を提供すること。
|
|
29
|
+
|
|
30
|
+
**基本要件**:
|
|
31
|
+
- ✅ 相対パスと絶対パスの両方をサポート
|
|
32
|
+
- ✅ オプション指定は任意(デフォルトでは不要)
|
|
33
|
+
- ✅ 複数の環境ファイルを順次読み込める(推奨)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 基本的な使用例
|
|
37
|
+
my-cli command --env-file .env
|
|
38
|
+
my-cli command --env-file .env.production
|
|
39
|
+
my-cli command --env-file ~/.config/my-app/.env
|
|
40
|
+
|
|
41
|
+
# 複数ファイルの読み込み(推奨)
|
|
42
|
+
my-cli command --env-file .env.base --env-file .env.local
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Variable Priority Order
|
|
46
|
+
|
|
47
|
+
環境変数の優先順位を明確に定義し、ドキュメント化すること。
|
|
48
|
+
|
|
49
|
+
**推奨優先順位(高→低)**:
|
|
50
|
+
1. **CLI引数で直接指定された値**(`--var KEY=value`)
|
|
51
|
+
2. **設定ファイル内の変数定義**
|
|
52
|
+
3. **`--env-file`で指定された.envファイル**
|
|
53
|
+
4. **システムの環境変数**
|
|
54
|
+
5. **デフォルト値**
|
|
55
|
+
|
|
56
|
+
**重要**: この優先順位により、ユーザーは状況に応じて柔軟に設定を上書きできます。
|
|
57
|
+
|
|
58
|
+
### 3. Error Handling
|
|
59
|
+
|
|
60
|
+
**Required Error Handling**:
|
|
61
|
+
- ✅ ファイルが存在しない場合: 明確なエラーメッセージ(パスを含む)
|
|
62
|
+
- ✅ ファイルが読み取れない場合: 権限エラーを適切に報告
|
|
63
|
+
- ✅ パースエラー: エラーが発生した行を特定
|
|
64
|
+
- ✅ 相対パスのサポート: カレントディレクトリからの解決
|
|
65
|
+
|
|
66
|
+
**良いエラーメッセージの例**:
|
|
67
|
+
```
|
|
68
|
+
Error: Environment file not found: .env.production
|
|
69
|
+
Searched in: /path/to/current/directory/.env.production
|
|
70
|
+
|
|
71
|
+
Tip: Create the file or specify a different path with --env-file
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**エラーハンドリングの原則**:
|
|
75
|
+
- **オプション指定なし**: エラーを出さない(.envファイルの使用は任意)
|
|
76
|
+
- **オプション指定あり**: ファイルが存在しない場合はエラー
|
|
77
|
+
- **パースエラー**: 問題のある行番号と内容を明示
|
|
78
|
+
|
|
79
|
+
### 4. File Format Support
|
|
80
|
+
|
|
81
|
+
標準的な.envファイル形式をサポート:
|
|
82
|
+
|
|
83
|
+
**必須サポート**:
|
|
84
|
+
- ✅ コメント(`#`)
|
|
85
|
+
- ✅ 空行の許容
|
|
86
|
+
- ✅ 引用符のサポート(シングル・ダブル)
|
|
87
|
+
- ✅ トリムされた値(前後の空白削除)
|
|
88
|
+
|
|
89
|
+
**推奨サポート**:
|
|
90
|
+
- 🔶 基本的な変数展開(`${VAR}`)
|
|
91
|
+
- 🔶 デフォルト値の指定(`${VAR:-default}`)
|
|
92
|
+
|
|
93
|
+
```env
|
|
94
|
+
# コメント
|
|
95
|
+
API_KEY=your_secret_key_here
|
|
96
|
+
DATABASE_URL=postgresql://user:pass@localhost/db
|
|
97
|
+
APP_NAME="My Application"
|
|
98
|
+
|
|
99
|
+
# 変数展開(推奨)
|
|
100
|
+
BASE_PATH=/var/app
|
|
101
|
+
LOG_PATH=${BASE_PATH}/logs
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Security Considerations
|
|
105
|
+
|
|
106
|
+
### 1. Sensitive Data Protection
|
|
107
|
+
|
|
108
|
+
**必須対策**:
|
|
109
|
+
- ✅ API key、パスワード、トークンをログに出力しない
|
|
110
|
+
- ✅ `.env`ファイルを`.gitignore`に追加
|
|
111
|
+
- ✅ `.env.example`サンプルファイルを提供
|
|
112
|
+
- ✅ 機密データは環境変数名で判定(API_KEY, PASSWORD, TOKEN, SECRETなどを含む)
|
|
113
|
+
|
|
114
|
+
**ログ出力時の安全な処理**:
|
|
115
|
+
```
|
|
116
|
+
✅ Good:
|
|
117
|
+
API_KEY: [REDACTED]
|
|
118
|
+
DATABASE_PASSWORD: [REDACTED]
|
|
119
|
+
APP_NAME: My Application
|
|
120
|
+
|
|
121
|
+
❌ Bad:
|
|
122
|
+
API_KEY: sk-1234567890abcdef
|
|
123
|
+
DATABASE_PASSWORD: mypassword123
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 2. Validation and Sanitization
|
|
127
|
+
|
|
128
|
+
**推奨検証**:
|
|
129
|
+
- 環境変数の値を適切に検証(型、形式、範囲)
|
|
130
|
+
- 機密データは長さのみチェック(内容は検証しない)
|
|
131
|
+
- URL形式、メールアドレス、数値範囲などの検証
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// 良い例: 機密データの検証
|
|
135
|
+
function validateApiKey(key: string): boolean {
|
|
136
|
+
// 長さのみチェック(実際の値は検証しない)
|
|
137
|
+
return key.length >= 32;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 良い例: 非機密データの検証
|
|
141
|
+
function validateUrl(url: string): boolean {
|
|
142
|
+
try {
|
|
143
|
+
new URL(url);
|
|
144
|
+
return true;
|
|
145
|
+
} catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Documentation Requirements
|
|
152
|
+
|
|
153
|
+
### 1. Usage Examples
|
|
154
|
+
|
|
155
|
+
CLI のドキュメント(README.md、--help など)に以下を含めること:
|
|
156
|
+
|
|
157
|
+
**必須内容**:
|
|
158
|
+
- 基本的な使用方法
|
|
159
|
+
- 優先順位の説明
|
|
160
|
+
- エラーケースの例
|
|
161
|
+
|
|
162
|
+
### 2. .env.example Template
|
|
163
|
+
|
|
164
|
+
プロジェクトルートに `.env.example` を配置し、必要な設定項目を明示:
|
|
165
|
+
|
|
166
|
+
```env
|
|
167
|
+
# .env.example - Configuration template for My CLI
|
|
168
|
+
|
|
169
|
+
# API Configuration
|
|
170
|
+
API_KEY=your_api_key_here
|
|
171
|
+
API_ENDPOINT=https://api.example.com
|
|
172
|
+
|
|
173
|
+
# Database Configuration
|
|
174
|
+
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
|
|
175
|
+
|
|
176
|
+
# Application Settings
|
|
177
|
+
APP_NAME=My Application
|
|
178
|
+
LOG_LEVEL=info
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Testing Requirements
|
|
182
|
+
|
|
183
|
+
env-file機能のテストを必ず含めること:
|
|
184
|
+
|
|
185
|
+
**必須テストケース**:
|
|
186
|
+
- ✅ 正常な読み込み
|
|
187
|
+
- ✅ ファイルが存在しない場合のエラー
|
|
188
|
+
- ✅ CLI変数の優先順位
|
|
189
|
+
- ✅ 複数の変数ソースの統合
|
|
190
|
+
- ✅ パースエラーのハンドリング
|
|
191
|
+
- ✅ 相対パス・絶対パスの解決
|
|
192
|
+
|
|
193
|
+
## Best Practices Summary
|
|
194
|
+
|
|
195
|
+
### ✅ DO
|
|
196
|
+
|
|
197
|
+
- Provide `--env-file` option for all CLIs
|
|
198
|
+
- Document variable priority clearly
|
|
199
|
+
- Show helpful error messages with file paths
|
|
200
|
+
- Support relative and absolute paths
|
|
201
|
+
- Provide `.env.example` template
|
|
202
|
+
- Add `.env` to `.gitignore`
|
|
203
|
+
- Validate sensitive values appropriately
|
|
204
|
+
- Test env file loading scenarios
|
|
205
|
+
- Redact sensitive values in logs and error messages
|
|
206
|
+
- Support standard .env file format
|
|
207
|
+
|
|
208
|
+
### ❌ DON'T
|
|
209
|
+
|
|
210
|
+
- Require env file when not explicitly specified
|
|
211
|
+
- Log sensitive environment variable values
|
|
212
|
+
- Commit `.env` files to version control
|
|
213
|
+
- Give vague error messages
|
|
214
|
+
- Ignore file permission errors
|
|
215
|
+
- Hard-code default sensitive values
|
|
216
|
+
- Skip validation of critical variables
|
|
217
|
+
- Show full sensitive values in any output
|
|
218
|
+
|
|
219
|
+
## Migration Guide
|
|
220
|
+
|
|
221
|
+
既存のCLIに env-file サポートを追加する場合の段階的アプローチ:
|
|
222
|
+
|
|
223
|
+
### Phase 1: Add --env-file Option (Basic)
|
|
224
|
+
- `--env-file` オプションを追加(オプショナル)
|
|
225
|
+
- 基本的なファイル読み込み機能を実装
|
|
226
|
+
|
|
227
|
+
### Phase 2: Implement Priority Logic
|
|
228
|
+
- 優先順位ロジックを実装
|
|
229
|
+
- システム環境変数 → env-file → CLI引数の順
|
|
230
|
+
|
|
231
|
+
### Phase 3: Enhance Error Handling
|
|
232
|
+
- エラーメッセージを改善
|
|
233
|
+
- ファイルパス、行番号を含める
|
|
234
|
+
|
|
235
|
+
### Phase 4: Add Documentation and Tests
|
|
236
|
+
- README.mdに使用例を追加
|
|
237
|
+
- テストケースを追加
|
|
238
|
+
|
|
239
|
+
### Phase 5: Provide .env.example
|
|
240
|
+
- `.env.example`を作成
|
|
241
|
+
- `.gitignore`に`.env`を追加
|
|
242
|
+
|
|
243
|
+
## Related Standards
|
|
244
|
+
|
|
245
|
+
### 12-Factor App 準拠
|
|
246
|
+
|
|
247
|
+
このガイドラインは、12-Factor Appの以下の原則に準拠しています:
|
|
248
|
+
|
|
249
|
+
- **III. Config**: 環境変数による設定の外部化
|
|
250
|
+
- **X. Dev/prod parity**: 開発と本番の環境の一致
|
|
251
|
+
- **XII. Admin processes**: 管理プロセスの実行環境の統一
|
|
252
|
+
|
|
253
|
+
### Language-Specific Implementation
|
|
254
|
+
|
|
255
|
+
このルールの具体的な実装は、各言語専用のドキュメントで詳細化されています:
|
|
256
|
+
|
|
257
|
+
- **Python CLI**: `python-cli.md` - python-dotenv の使用
|
|
258
|
+
- **TypeScript CLI**: dotenv パッケージの使用
|
|
259
|
+
- **Rust CLI**: dotenvy クレートの使用
|
|
260
|
+
- **Go CLI**: godotenv パッケージの使用
|
|
261
|
+
|
|
262
|
+
各言語のエコシステムに応じた適切なライブラリを使用してください。
|
|
263
|
+
|
|
264
|
+
## Rationale
|
|
265
|
+
|
|
266
|
+
### このルールが必要な理由
|
|
267
|
+
|
|
268
|
+
1. **セキュリティ向上**:
|
|
269
|
+
- API keyやパスワードなどの機密情報をコードやコマンドライン履歴に残さない
|
|
270
|
+
- バージョン管理システムから機密情報を除外
|
|
271
|
+
|
|
272
|
+
2. **環境管理の簡素化**:
|
|
273
|
+
- 開発/ステージング/本番環境の設定を簡単に切り替え可能
|
|
274
|
+
- チームメンバー間で設定を共有しやすい
|
|
275
|
+
|
|
276
|
+
3. **チーム協業の改善**:
|
|
277
|
+
- `.env.example`により必要な設定項目が明確
|
|
278
|
+
- オンボーディングの効率化
|
|
279
|
+
|
|
280
|
+
4. **12-Factor App準拠**:
|
|
281
|
+
- 業界標準のベストプラクティスへの準拠
|
|
282
|
+
- クラウドネイティブアプリケーションの原則に従う
|
|
283
|
+
|
|
284
|
+
5. **開発者体験向上**:
|
|
285
|
+
- 長いコマンドライン引数を毎回入力する必要がなくなる
|
|
286
|
+
- 設定の再利用が容易
|