phasegate 0.32.0 → 0.44.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +87 -1
  2. package/README.ja.md +498 -660
  3. package/README.md +8 -11
  4. package/docs/folder_management_rules.md +251 -0
  5. package/docs/guide/cli-reference.md +15 -0
  6. package/package.json +3 -1
  7. package/scripts/delegate-sonnet.sh +105 -0
  8. package/scripts/harness/ci-governance/application/usecases/generate-ci-template-usecase.ts +6 -2
  9. package/scripts/harness/harness-api/infrastructure/adapters/validator-system-execution-adapter.ts +11 -2
  10. package/scripts/harness/integrations/pre-commit.ts +64 -130
  11. package/scripts/harness/main.ts +134 -9
  12. package/scripts/harness/phase2-extensions/infrastructure/adapters/git-log-document-age-adapter.ts +7 -1
  13. package/scripts/harness/quick-mode/infrastructure/adapters/git-diff-changed-files-adapter.ts +20 -1
  14. package/scripts/harness/regression-suite/composition-root.ts +4 -1
  15. package/scripts/harness/setup/skill-deployer.ts +99 -0
  16. package/scripts/harness/validator-system/application/dto/run-full-validation-input.ts +5 -0
  17. package/scripts/harness/validator-system/application/use-cases/run-full-validation-usecase.ts +40 -12
  18. package/scripts/harness/validator-system/composition-root.ts +2 -0
  19. package/scripts/harness/validator-system/domain/services/l4/drift-detection-service.ts +29 -2
  20. package/scripts/harness/validator-system/infrastructure/adapters/biome-ast-source-code-analyzer-adapter.ts +17 -0
  21. package/scripts/harness/validator-system/infrastructure/adapters/markdown-design-document-adapter.ts +65 -5
  22. package/scripts/harness/validator-system/presentation/handlers/run-validators-handler.ts +9 -0
  23. package/skills/environment-designer/SKILL.md +1 -1
  24. package/skills/implementation-planner/SKILL.md +1 -1
  25. package/skills/it-test-designer/SKILL.md +3 -3
  26. package/skills/it-test-logic-designer/SKILL.md +2 -2
  27. package/skills/mock-designer/SKILL.md +1 -1
  28. package/skills/scenario-test-designer/SKILL.md +3 -3
  29. package/skills/scenario-test-logic-designer/SKILL.md +2 -2
  30. package/skills/story-mapper/SKILL.md +1 -1
  31. package/skills/story-writer/SKILL.md +1 -1
  32. package/skills/unit-designer/SKILL.md +1 -1
  33. package/skills/unit-test-designer/SKILL.md +3 -3
  34. package/skills/unit-test-logic-designer/SKILL.md +2 -2
  35. package/templates/.claude/settings.json +3 -3
  36. package/templates/.husky/pre-commit +1 -1
  37. package/templates/phasegate.config.json +0 -30
package/README.md CHANGED
@@ -48,17 +48,11 @@ npm install --save-dev phasegate
48
48
  npx phasegate init --name my-project
49
49
  ```
50
50
 
51
- This deploys 28 skills to `.claude/skills/` and generates `phasegate.config.json`.
51
+ This deploys 28 skills, design principles docs (`docs/principles/*.md`, `docs/folder_management_rules.md`), and generates `phasegate.config.json`.
52
52
 
53
- ### 3. Copy design principles
53
+ Optional: add `--with-husky` to also install a `.husky/pre-commit` hook that runs L2 validators.
54
54
 
55
- ```bash
56
- cp node_modules/phasegate/docs/folder_management_rules.md docs/
57
- mkdir -p docs/principles
58
- cp node_modules/phasegate/docs/principles/*.md docs/principles/
59
- ```
60
-
61
- ### 4. Start the AIDLC
55
+ ### 3. Start the AIDLC
62
56
 
63
57
  Launch your AI agent and run the `/product-architect` skill to begin.
64
58
 
@@ -275,6 +269,9 @@ npx phasegate <command> [options]
275
269
  | `phasegate:status` | Display overall harness health summary |
276
270
  | `phasegate:check-phase --unit <id>` | Check current phase for a Unit |
277
271
  | `list-errors --layer <L0-L4>` | List error definitions with fix examples |
272
+ | `hook <pre-tool-use\|post-tool-use\|stop>` | Run a Claude Code hook (reads JSON from stdin) |
273
+ | `pre-commit` | Run L2 pre-commit validators on staged files |
274
+ | `delegate-sonnet [...args]` | Delegate task to Sonnet 4.6 (transparent wrapper) |
278
275
 
279
276
  See the [Japanese README](README.ja.md) for the complete CLI reference.
280
277
 
@@ -301,7 +298,7 @@ Additional resources:
301
298
 
302
299
  ## Contributing
303
300
 
304
- Contributions are welcome. Please read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before submitting a pull request.
301
+ Contributions are welcome. See [DEVELOPMENT.md](DEVELOPMENT.md) for internal architecture, regression tests, and release procedures.
305
302
 
306
303
  ---
307
304
 
@@ -311,4 +308,4 @@ Contributions are welcome. Please read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
311
308
 
312
309
  ---
313
310
 
314
- [Japanese version / 日本語版](README.ja.md)
311
+ [Japanese version / 日本語版](README.ja.md) | [Developer Guide](DEVELOPMENT.md) | [開発者ガイド](DEVELOPMENT.ja.md)
@@ -0,0 +1,251 @@
1
+ # docs ディレクトリ管理ガイド
2
+
3
+ 本ドキュメントは`docs/`配下のドキュメント管理方針を定義します。
4
+
5
+ ---
6
+
7
+ ## ディレクトリ構造
8
+
9
+ ```
10
+ docs/
11
+ ├── ADR/ # Architecture Decision Records
12
+ ├── basic_input/ # 入力サンプル・テンプレート
13
+ ├── principles/ # 開発原則・ルール
14
+ ├── inception/ # 計画ドキュメント + 作業単位(US・issue)の設計
15
+ └── product/ # 共有設計ドキュメント(確定版)
16
+ ```
17
+
18
+ ---
19
+
20
+ ## 各ディレクトリの役割
21
+
22
+ ### ADR/
23
+ アーキテクチャ決定記録。技術選定や設計方針の決定理由を記録する。
24
+
25
+ ### basic_input/
26
+ 入力データのサンプルやテンプレートを格納する。
27
+
28
+ ### principles/
29
+ 開発原則、テストルール、アーキテクチャ哲学など、プロジェクト全体で遵守すべきルールを定義する。
30
+
31
+ ### inception/
32
+ **計画ドキュメント**と**作業単位(US・issue)の設計**を格納する。inception 配下のドキュメントは一時的な作業用であり、設計成果物は `product/` に反映される。
33
+
34
+ ```
35
+ inception/
36
+ ├── _shared/ # 横断的な計画(複数Unitにまたがるもの)
37
+ ├── _operation/ # 運用・デプロイ関連の計画
38
+ ├── issues/ # 横断的なissue(複数Unitにまたがるもの)
39
+ │ └── {ISSUE-XXX}/
40
+ │ ├── issue_description.md # 問題の記述
41
+ │ ├── logical_design.md # 論理設計
42
+ │ └── ...
43
+ ├── {Unit名}/ # Unit毎の階層
44
+ │ ├── *_plan.md # Unit全体の計画
45
+ │ ├── {US-XXX}/ # ストーリー単位の計画・設計
46
+ │ │ ├── *_plan.md # 実装計画
47
+ │ │ ├── uiux_design.md # UI/UX設計
48
+ │ │ └── ... # その他ストーリー固有のドキュメント
49
+ │ └── issues/ # Unit固有のissue(バグ・不整合)
50
+ │ └── {ISSUE-XXX}/
51
+ │ ├── issue_description.md # 問題の記述
52
+ │ ├── logical_design.md # 論理設計
53
+ │ └── tdd_implementation_plan.md
54
+ ```
55
+
56
+ ### product/
57
+ **確定した設計ドキュメント**を格納する。作業単位(US-XXX / ISSUE-XXX)のドキュメントは含まない。
58
+
59
+ > **設計思想(product docs ハブモデル)**:
60
+ >
61
+ > `product/` はUnit単位で確定済みの仕様を集約する **ハブ** である。
62
+ >
63
+ > ```
64
+ > inception/{unit}/{作業単位}/ 一時設計(US・issue ごと)
65
+ > ↓ 設計成果物の反映(累積更新)
66
+ > product/construction/{unit}/ 正式設計(常に最新、Unitの真実のソース)
67
+ > ↕ フェーズゲート
68
+ > scripts/harness/{unit}/*.ts 実装ファイル
69
+ > ```
70
+ >
71
+ > - **inception → product**: US・issue の設計成果が確定したら product docs を累積更新する
72
+ > - **product → source**: ソースファイルのフェーズゲートは product docs(Unit単位)の存在で判定する
73
+ > - **ソースファイルと US/issue は直接紐付けない**: PJ のライフサイクルが進むほどにバグ修正や US 追加で一つのソースファイルに紐づくドキュメント数が増大し、依存関係が複雑になるため。product docs が常に最新に保たれることで、inception の一時ドキュメントと実装が間接的に紐づく
74
+ > - **US/issue 単位で正として管理しない**: 整合性維持のコストが非常に大きくなるため、作業単位の設計は inception にアーカイブ的に保持し、確定した仕様のみを product に集約する
75
+
76
+ ```
77
+ product/
78
+ ├── product_overview.md # プロダクト概要
79
+ ├── user_stories.md # ユーザーストーリー一覧
80
+ ├── user_story_mapping.md # ストーリーマッピング
81
+ ├── construction/ # Unit毎の設計(確定版・累積更新)
82
+ │ └── {Unit名}/
83
+ │ ├── domain_model.md # ドメインモデル
84
+ │ ├── logical_design.md # 論理設計
85
+ │ ├── uiux_design.md # UI/UX設計(Unit全体で1ファイル)
86
+ │ ├── unit_test_design.md # ユニットテストケース設計
87
+ │ ├── it_test_design.md # ITテストケース設計
88
+ │ ├── unit_test_logic.md # ユニットテストロジック設計
89
+ │ ├── it_test_logic.md # ITテストロジック設計
90
+ │ └── coverage_report.md # テストカバレッジレポート
91
+ └── units/ # Unit設計ドキュメント
92
+ ├── {unit_name}_unit.md # Unit定義
93
+ └── integration_contract.md # 統合契約
94
+ ```
95
+
96
+ > **`construction/{Unit名}/` のドキュメントは累積更新される「生きたドキュメント」です。**
97
+ > ストーリー実装のたびに、新しい仕様を既存ファイルに追記・更新します。
98
+
99
+ ---
100
+
101
+ ## 重要なルール
102
+
103
+ ### 1. productには作業単位(US・issue)の設計を入れない
104
+
105
+ ```
106
+ # NG: product配下にUS-XXX/ISSUE-XXXディレクトリを作成
107
+ product/construction/withholding_tax/US-217/
108
+ product/construction/withholding_tax/issues/ISSUE-001/
109
+
110
+ # OK: inception配下に作成
111
+ inception/withholding_tax/US-217/
112
+ inception/withholding_tax/issues/ISSUE-001/
113
+ ```
114
+
115
+ ### 2. 仕様変更時は既存のproductドキュメントを更新する
116
+
117
+ US 実装や issue 修正で仕様が確定したら、`product/`配下の既存ドキュメント(domain_model.md等)を累積更新する。新規ファイルを作成するのではなく、既存ファイルに変更を追記する。product docs は常に最新の状態を維持する「生きたドキュメント」である。
118
+
119
+ ### 3. ストーリー・issue単位の計画・設計は必ずinception配下に作成する
120
+
121
+ ```
122
+ # 新しいストーリーUS-999の計画を作成する場合
123
+ inception/{該当Unit}/US-999/
124
+ ├── logical_design_plan.md
125
+ ├── scenario_test_plan.md
126
+ ├── scenario_test_design.md
127
+ ├── scenario_test_logic.md
128
+ ├── uiux_design_plan.md
129
+ └── tdd_implementation_plan.md
130
+
131
+ # Unit固有のissue(バグ・不整合)を起票する場合
132
+ inception/{該当Unit}/issues/ISSUE-999/
133
+ ├── issue_description.md
134
+ ├── logical_design.md
135
+ └── tdd_implementation_plan.md
136
+
137
+ # 横断的なissue(複数Unitにまたがる)を起票する場合
138
+ inception/issues/ISSUE-999/
139
+ ├── issue_description.md
140
+ └── logical_design.md
141
+ ```
142
+
143
+ ---
144
+
145
+ ## ドキュメント作成フロー
146
+
147
+ AIDLCプロセスは **US(新機能)** と **issue(バグ・不整合)** の2つの起点を持つ。いずれも inception で計画を立て、product docs を更新し、実装に反映する流れは共通である。
148
+
149
+ ### US と issue の違い
150
+
151
+ | 起点 | フロー | inception 配置先 |
152
+ |------|--------|-----------------|
153
+ | **US(新機能)** | Phase 1 → Phase 2 → Phase 3 の全フローを上位から順に実行 | `inception/{unit}/{US-XXX}/` |
154
+ | **issue(バグ・不整合)** | 原因フェーズを特定し、そのフェーズから下位に向けてドキュメント・実装をアップデート | `inception/{unit}/issues/{ISSUE-XXX}/` |
155
+
156
+ #### issue の処理フロー
157
+
158
+ 1. **issue 起票**: `inception/{unit}/issues/{ISSUE-XXX}/issue_description.md` に問題の記述・原因分析を記載
159
+ 2. **原因フェーズの特定**: バグや仕様の認識違いがどのフェーズに起因するかを判定
160
+ - ドメイン設計に起因 → domain_model から下位に向けてリファクタ
161
+ - 論理設計に起因 → logical_design から下位に向けてリファクタ
162
+ - テスト設計に起因 → test_design から下位に向けてリファクタ
163
+ - 実装のみに起因 → 実装の修正のみ
164
+ 3. **inception で計画**: 特定したフェーズから下位のフェーズに向けて、inception 配下に計画・設計文書を作成
165
+ 4. **product docs 更新**: 設計成果物を `product/construction/{unit}/` の該当ドキュメントに累積更新
166
+ 5. **TDD 実装**: テスト設計→実装の順序で修正を適用
167
+
168
+ > **issue が既存仕様に存在しない追加機能であった場合**: issue ではなく **US を新規作成** し、unit へのマッピングからドメイン設計→TDD 実装まで、下記の Phase 1〜3 の全フローに沿って実施する。
169
+
170
+ ---
171
+
172
+ ### US のドキュメント作成フロー
173
+
174
+ US は3つのフェーズで構成される。各フェーズでドキュメントの配置先が異なる。
175
+
176
+ ### Phase 1: プロダクト全体設計(横断的・初回)
177
+
178
+ プロダクトの全体像を定義し、ストーリー・Unitの構造を確立する。
179
+
180
+ | Step | スキル | 計画(inception) | 成果物(product) |
181
+ |------|--------|-------------------|-------------------|
182
+ | Step 0 | product-architect | `_shared/product_overview_plan.md` | `product_overview.md` |
183
+ | Step 1.1 | story-writer | `_shared/story_writer_plan.md` | `user_stories.md` |
184
+ | Step 1.5 | story-mapper | `_shared/story_mapping_plan.md` | `user_story_mapping.md` |
185
+ | Step 2 | unit-designer | `_shared/unit_design_plan.md` | `units/{unit_name}.md` + `units/integration_contract.md` |
186
+
187
+ ### Phase 2: Unit横断設計(Unit単位)
188
+
189
+ 各Unitの設計を確定させる。成果物は`product/construction/{unit}/`に配置される累積更新ドキュメント。
190
+
191
+ | Step | スキル | 計画(inception/{unit}/) | 成果物(product/construction/{unit}/) |
192
+ |------|--------|--------------------------|----------------------------------------|
193
+ | Step 3 | domain-designer | `domain_model_plan.md` | `domain_model.md` |
194
+ | Step 4 | logical-designer(横断) | `logical_design_plan.md` | `logical_design.md` |
195
+ | Step 5 | scenario-test-designer | → Phase 3で実行 | - |
196
+ | Step 5 | it-test-designer | `it_test_design_plan.md` | `it_test_design.md` |
197
+ | Step 5 | unit-test-designer | `unit_test_design_plan.md` | `unit_test_design.md` |
198
+ | - | test-coverage-checker | `test_coverage_plan.md` | `coverage_report.md` |
199
+ | Step 6 | unit-test-logic-designer | `unit_test_logic_plan.md` | `unit_test_logic.md` |
200
+ | Step 6 | it-test-logic-designer | `it_test_logic_plan.md` | `it_test_logic.md` |
201
+
202
+ ### Phase 3: ストーリー実装(US単位)/ issue 修正
203
+
204
+ 個別ストーリーの設計・テスト・実装。計画・成果物は`inception/{unit}/{US-XXX}/`に配置。
205
+ issue の場合は `inception/{unit}/issues/{ISSUE-XXX}/` に配置し、原因フェーズから下位に向けて同様のドキュメントを作成する。
206
+
207
+ | Step | スキル | 計画(inception/{unit}/{US-XXX}/) | 成果物配置先 |
208
+ |------|--------|-----------------------------------|-------------|
209
+ | Step 4 | logical-designer(固有) | `logical_design_plan.md` | `logical_design.md`(同ディレクトリ) |
210
+ | Step 5 | scenario-test-designer | `scenario_test_plan.md` | `scenario_test_design.md`(同ディレクトリ) |
211
+ | Step 6 | scenario-test-logic-designer | `scenario_test_logic_plan.md` | `scenario_test_logic.md`(同ディレクトリ) |
212
+ | Step 7 | uiux-designer | `uiux_design_plan.md` | `product/construction/{unit}/uiux_design.md`(※累積更新) |
213
+ | Step 8 | story-implementor | `tdd_implementation_plan.md` | コード(TDD実装) |
214
+ | 実装完了後 | - | - | `product/construction/{unit}/` の各ドキュメントを更新 |
215
+
216
+ > **uiux_design.mdについて**: 計画はストーリー単位(`inception/{unit}/{US-XXX}/`)に作成するが、
217
+ > 成果物は`product/construction/{unit}/uiux_design.md`にUnit全体で1ファイルとして累積更新する。
218
+ > これはUI/UXの全体一貫性を保つためで、他のproduct/construction配下のドキュメントと同じルールに従う。
219
+
220
+ ### 横断的な計画
221
+
222
+ 複数Unitにまたがる計画は `inception/_shared/` に作成する。
223
+
224
+ ### 運用関連
225
+
226
+ デプロイ、IaC、運用手順は `inception/_operation/` に作成する。
227
+
228
+ ---
229
+
230
+ ## ファイル命名規則
231
+
232
+ | 種別 | 命名パターン | 例 |
233
+ |-----|------------|---|
234
+ | issue記述 | `issue_description.md` | - |
235
+ | 計画 | `*_plan.md` | `domain_model_plan.md` |
236
+ | ドメインモデル | `domain_model.md` | - |
237
+ | 論理設計 | `logical_design.md` | - |
238
+ | UI/UX設計 | `uiux_design.md` | - |
239
+ | シナリオテスト設計 | `scenario_test_design.md` | - |
240
+ | ITテスト設計 | `it_test_design.md` | - |
241
+ | ユニットテスト設計 | `unit_test_design.md` | - |
242
+ | テストロジック設計 | `*_test_logic.md` | `unit_test_logic.md` |
243
+ | カバレッジレポート | `coverage_report.md` | - |
244
+ | Unit定義 | `{unit_name}_unit.md` | `withholding_tax_unit.md` |
245
+ | 統合契約 | `integration_contract.md` | - |
246
+
247
+ ---
248
+
249
+ ## 関連ドキュメント
250
+ - [アーキテクチャ哲学](./principles/architecture-philosophy.md)
251
+ - [テストルール](./principles/testing-rules.md)
@@ -66,6 +66,21 @@ Commands exposed as npm scripts (`npm run <command>`).
66
66
  | `render-errors` | `--format human\|agent\|ci` | Render errors |
67
67
  | `validate-fix` | `--code <code>` | Validate fix code example |
68
68
 
69
+ ### `list-errors` と `render-errors` の使い分け
70
+
71
+ ISSUE-005 P3-10 で明確化された境界:
72
+
73
+ - **`list-errors`** — **定義駆動**。`HarnessError` Value Object の**静的な定義**を出力する。
74
+ コードを実行しないため、常に安定した結果を返す。`--format json` と組み合わせて**異なる
75
+ バージョン間の定義差分を比較**する用途に向く。
76
+ - **`render-errors`** — **ランタイム駆動**。実行時に蓄積されたエラーの**蓄積履歴**を整形する。
77
+ まだエラーが記録されていない環境では空を返すため、テストデータや実行痕跡を前提とする。
78
+ CI ログ向けの詳細フォーマット (`--format ci`) やエージェント送信向けの構造化 (`--format agent`)
79
+ に向く。
80
+
81
+ **差分比較を行いたい場合は `list-errors --format json`** を使い、`render-errors` は runtime 観測用と
82
+ 位置付けること。
83
+
69
84
  ---
70
85
 
71
86
  ## Skill Quality
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phasegate",
3
- "version": "0.32.0",
3
+ "version": "0.44.0",
4
4
  "packageManager": "pnpm@10.30.1",
5
5
  "description": "Phasegate — AI-agnostic quality defense toolkit. Enforces structural integrity between design intent and code.",
6
6
  "license": "Apache-2.0",
@@ -31,11 +31,13 @@
31
31
  "!scripts/harness/__tests__/**",
32
32
  "scripts/harness/**/*.json",
33
33
  "!scripts/harness/__tests__/**/*.json",
34
+ "scripts/delegate-sonnet.sh",
34
35
  "skills/**",
35
36
  "templates/**",
36
37
  "docs/ADR/**",
37
38
  "docs/principles/**",
38
39
  "docs/guide/**",
40
+ "docs/folder_management_rules.md",
39
41
  "LICENSE",
40
42
  "CHANGELOG.md"
41
43
  ],
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env bash
2
+ # delegate-sonnet.sh — Sonnet 4.6 にタスクを委任するラッパースクリプト
3
+ #
4
+ # Usage:
5
+ # bash scripts/delegate-sonnet.sh --prompt "プロンプト" --output "出力パス"
6
+ # bash scripts/delegate-sonnet.sh --prompt-file /tmp/prompt.md --output "出力パス"
7
+ #
8
+ # Options:
9
+ # --prompt 委任プロンプト(直接指定、2000文字以下推奨)
10
+ # --prompt-file 委任プロンプトファイル(長文の場合)
11
+ # --output 出力ファイルパス
12
+ # --max-turns 最大ターン数(デフォルト: 30)
13
+ # --dry-run プロンプトを表示するだけで実行しない
14
+
15
+ set -euo pipefail
16
+
17
+ # --- 引数パース ---
18
+ PROMPT=""
19
+ PROMPT_FILE=""
20
+ OUTPUT_PATH=""
21
+ MAX_TURNS=30
22
+ DRY_RUN=false
23
+
24
+ while [[ $# -gt 0 ]]; do
25
+ case $1 in
26
+ --prompt)
27
+ PROMPT="$2"
28
+ shift 2
29
+ ;;
30
+ --prompt-file)
31
+ PROMPT_FILE="$2"
32
+ shift 2
33
+ ;;
34
+ --output)
35
+ OUTPUT_PATH="$2"
36
+ shift 2
37
+ ;;
38
+ --max-turns)
39
+ MAX_TURNS="$2"
40
+ shift 2
41
+ ;;
42
+ --dry-run)
43
+ DRY_RUN=true
44
+ shift
45
+ ;;
46
+ *)
47
+ echo "Unknown option: $1" >&2
48
+ exit 1
49
+ ;;
50
+ esac
51
+ done
52
+
53
+ # --- バリデーション ---
54
+ if [[ -z "$PROMPT" && -z "$PROMPT_FILE" ]]; then
55
+ echo "Error: --prompt or --prompt-file is required" >&2
56
+ exit 1
57
+ fi
58
+
59
+ if [[ -z "$OUTPUT_PATH" ]]; then
60
+ echo "Error: --output is required" >&2
61
+ exit 1
62
+ fi
63
+
64
+ if [[ -n "$PROMPT_FILE" && ! -f "$PROMPT_FILE" ]]; then
65
+ echo "Error: Prompt file not found: $PROMPT_FILE" >&2
66
+ exit 1
67
+ fi
68
+
69
+ # --- プロンプト構築 ---
70
+ if [[ -n "$PROMPT_FILE" ]]; then
71
+ FINAL_PROMPT=$(cat "$PROMPT_FILE")
72
+ else
73
+ FINAL_PROMPT="$PROMPT"
74
+ fi
75
+
76
+ # 出力指示を付加
77
+ FINAL_PROMPT="${FINAL_PROMPT}
78
+
79
+ ---
80
+ ## 出力制約
81
+ - 出力は必ず ${OUTPUT_PATH} に書き出すこと
82
+ - 出力以外のファイルを変更しないこと
83
+ - 判断を含む作業(設計判断、優先順位決定、トレードオフ選択)は行わず、
84
+ 展開・列挙・構造化に徹すること"
85
+
86
+ # --- 実行 ---
87
+ if [[ "$DRY_RUN" == "true" ]]; then
88
+ echo "=== DRY RUN ==="
89
+ echo "Model: claude-sonnet-4-6"
90
+ echo "Output: $OUTPUT_PATH"
91
+ echo "Max turns: $MAX_TURNS"
92
+ echo "---"
93
+ echo "$FINAL_PROMPT"
94
+ exit 0
95
+ fi
96
+
97
+ echo "[delegate-sonnet] Delegating to Sonnet 4.6..."
98
+ echo "[delegate-sonnet] Output: $OUTPUT_PATH"
99
+
100
+ claude --model claude-sonnet-4-6 \
101
+ -p "$FINAL_PROMPT" \
102
+ --max-turns "$MAX_TURNS" \
103
+ --output-format text
104
+
105
+ echo "[delegate-sonnet] Done. Output written to: $OUTPUT_PATH"
@@ -9,7 +9,7 @@ import type { TemplateGenerator } from '../../domain/services/template-generator
9
9
  import type { GenerateCiTemplateInput } from '../dto/generate-ci-template-input.js';
10
10
  import type { GenerateCiTemplateOutput } from '../dto/generate-ci-template-output.js';
11
11
  import { CiTemplate } from '../../domain/aggregates/ci-template.js';
12
- import { isTemplateType } from '../../domain/types/template-type.js';
12
+ import { isTemplateType, TEMPLATE_TYPES } from '../../domain/types/template-type.js';
13
13
 
14
14
  export class GenerateCiTemplateUseCase {
15
15
  constructor(private readonly templateGenerator: TemplateGenerator) {}
@@ -18,6 +18,10 @@ export class GenerateCiTemplateUseCase {
18
18
  const { presetId, templateType } = input;
19
19
 
20
20
  if (!isTemplateType(templateType)) {
21
+ const validValues = TEMPLATE_TYPES.map((t) => `'${t}'`).join(', ');
22
+ const hint = /github|gitlab|circle|jenkins|travis|actions/i.test(String(templateType))
23
+ ? ` (Hint: --type specifies the template purpose, not the CI platform. Use one of: ${validValues})`
24
+ : ` (valid: ${validValues})`;
21
25
  return {
22
26
  templateType: templateType as any,
23
27
  presetRef: presetId,
@@ -26,7 +30,7 @@ export class GenerateCiTemplateUseCase {
26
30
  failOnWarning: false,
27
31
  validationErrors: [{
28
32
  code: 'CI_TEMPLATE_INVALID_TYPE',
29
- message: `INV-1: Invalid templateType: ${templateType}`,
33
+ message: `INV-1: Invalid templateType: ${templateType}${hint}`,
30
34
  }],
31
35
  };
32
36
  }
@@ -45,8 +45,17 @@ export class ValidatorSystemExecutionAdapter implements ValidatorExecutionPort {
45
45
  },
46
46
 
47
47
  async runDriftDetection(): Promise<DriftItem[]> {
48
- // validator-system does not implement drift detection
49
- return [];
48
+ // ISSUE-005 P1-5: L4-001 の DriftDetectionService を直接呼び出し、
49
+ // phasegate:detect-drift と validate --layer L4 の結果を一致させる
50
+ const { createValidatorSystemModule } = await import('../../../validator-system/composition-root.js');
51
+ const mod = createValidatorSystemModule();
52
+ const reports = await mod.driftDetectionService.detect();
53
+ return reports.map((r) => ({
54
+ direction: r.direction,
55
+ unit: r.unitName,
56
+ element: r.element,
57
+ recommendation: r.recommendation,
58
+ }));
50
59
  },
51
60
  };
52
61
  }