phasegate 0.44.0 → 0.62.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/README.ja.md +32 -0
- package/README.md +33 -0
- package/docs/guide/codex-integration.md +162 -0
- package/docs/guide/quick-vs-full-mode.md +141 -0
- package/package.json +1 -1
- package/scripts/harness/agent-integration/domain/services/bash-write-target-extractor.ts +60 -0
- package/scripts/harness/agent-integration/presentation/phasegate-status-context.ts +299 -0
- package/scripts/harness/agent-integration/presentation/session-start-hook.ts +54 -0
- package/scripts/harness/agent-integration/presentation/user-prompt-submit-hook.ts +70 -0
- package/scripts/harness/integrations/pre-commit.ts +128 -28
- package/scripts/harness/main.ts +52 -9
- package/scripts/harness/phase2-extensions/application/dto/check-initial-creation-expiration-input.ts +9 -0
- package/scripts/harness/phase2-extensions/application/dto/check-initial-creation-expiration-output.ts +17 -0
- package/scripts/harness/phase2-extensions/application/usecases/check-initial-creation-expiration-usecase.ts +103 -0
- package/scripts/harness/phase2-extensions/composition-root.ts +22 -0
- package/scripts/harness/phase2-extensions/domain/aggregates/initial-creation-expiration-rule.ts +103 -0
- package/scripts/harness/phase2-extensions/domain/ports/frontmatter-reader-port.ts +17 -0
- package/scripts/harness/phase2-extensions/domain/ports/initial-creation-age-port.ts +9 -0
- package/scripts/harness/phase2-extensions/domain/ports/initial-creation-expiration-config-port.ts +9 -0
- package/scripts/harness/phase2-extensions/domain/services/initial-creation-expiration-check-service.ts +54 -0
- package/scripts/harness/phase2-extensions/domain/value-objects/initial-creation-age.ts +54 -0
- package/scripts/harness/phase2-extensions/infrastructure/adapters/git-log-initial-creation-age-adapter.ts +77 -0
- package/scripts/harness/phase2-extensions/infrastructure/adapters/harness-config-initial-creation-expiration-adapter.ts +57 -0
- package/scripts/harness/phase2-extensions/infrastructure/adapters/markdown-frontmatter-reader-adapter.ts +56 -0
- package/scripts/harness/phase2-extensions/presentation/formatters/initial-creation-expiration-result-formatter.ts +23 -0
- package/scripts/harness/phase2-extensions/presentation/handlers/check-initial-creation-expiration-handler.ts +38 -0
- package/scripts/harness/setup/skill-deployer.ts +30 -0
- package/scripts/harness/traceability-model/composition-root.ts +14 -0
- package/scripts/harness/traceability-model/domain/value-objects/project-relative-path.ts +3 -0
- package/scripts/harness/traceability-model/infrastructure/parsers/markdown-story-annotation-parser.ts +39 -4
- package/scripts/harness/traceability-model/presentation/cli/validate-metadata-command-handler.ts +103 -9
- package/skills/domain-designer/SKILL.md +34 -0
- package/skills/it-test-logic-designer/SKILL.md +16 -0
- package/skills/logical-designer/SKILL.md +34 -0
- package/skills/quick-implementor/SKILL.md +10 -1
- package/skills/scenario-test-logic-designer/SKILL.md +16 -0
- package/skills/story-implementor/SKILL.md +58 -0
- package/skills/unit-designer/SKILL.md +41 -0
- package/skills/unit-test-logic-designer/SKILL.md +18 -0
- package/templates/.codex/hooks.json +63 -0
- package/templates/logical_design.template.md +79 -0
- package/templates/source.template.ts +18 -0
- package/templates/test.template.ts +37 -0
|
@@ -108,6 +108,64 @@ model: codex
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
+
## ⚠️ 生成ファイルへのメタデータ付与(必須)
|
|
112
|
+
|
|
113
|
+
**新規ソースファイルを作成する際、ファイル先頭に必ず `@unit` / `@layer` メタデータを記述する。これは L1 Biome ルール (`L1-001: require-unit-comment`, `L1-002: require-layer-comment`) の要件であり、欠落した状態での生成は許容されない。**
|
|
114
|
+
|
|
115
|
+
### TypeScript / JavaScript ファイル
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// @unit <対象Unit名 — logical_design.md の Unit ID を使用>
|
|
119
|
+
// @layer <domain | application | infrastructure | presentation>
|
|
120
|
+
|
|
121
|
+
// 以下、実装コード
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `@unit` の決定方法
|
|
125
|
+
|
|
126
|
+
- `docs/product/construction/{unit}/logical_design.md` の Unit ID をそのまま引用する
|
|
127
|
+
- ストーリー固有実装の場合は、該当ストーリーが属する Unit の ID を使用
|
|
128
|
+
- **複数 Unit にまたがる場合は story-implementor のスコープ違反** — `implementation-readiness-checker` に差し戻し、Unit 分割を検討する
|
|
129
|
+
|
|
130
|
+
### `@layer` の決定方法
|
|
131
|
+
|
|
132
|
+
生成ファイルの配置パスから機械的に決定する:
|
|
133
|
+
|
|
134
|
+
| 配置パス | `@layer` の値 |
|
|
135
|
+
|---------|-------------|
|
|
136
|
+
| `**/domain/**` | `domain` |
|
|
137
|
+
| `**/application/**` | `application` |
|
|
138
|
+
| `**/infrastructure/**` | `infrastructure` |
|
|
139
|
+
| `**/presentation/**` | `presentation` |
|
|
140
|
+
|
|
141
|
+
Clean Architecture の 4 層構成に従わないプロジェクトは、プロジェクト側で層名を定義した上で phasegate のルール設定に同期させること。
|
|
142
|
+
|
|
143
|
+
### テストファイルの場合
|
|
144
|
+
|
|
145
|
+
テストファイル(`**/__tests__/**`, `*.test.ts`, `*.spec.ts`)には `@unit` / `@layer` に加えて **`@story` タグを付与する**:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// @unit <被テストコードと同じ Unit ID>
|
|
149
|
+
// @layer <被テストコードと同じ layer>
|
|
150
|
+
// @story <HXX-XX 形式のストーリーID>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- `@story` は `docs/inception/{unit}/{story_id}/` の `story_id` を使用
|
|
154
|
+
- 複数ストーリーをカバーするテストは `// @story H09-01, H09-02` のように列挙
|
|
155
|
+
- US↔テストの逆引きが機械的に可能になることが目的(test-coverage-checker / nyquist が集計に使用)
|
|
156
|
+
|
|
157
|
+
### 検証
|
|
158
|
+
|
|
159
|
+
実装完了後、以下で L1 違反が無いことを確認する:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npx phasegate lint
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`L1-001` / `L1-002` で違反が検出された場合、本スキル終了前に必ず解決すること。スキルを抜けた後で付け直すのはアンチパターン(直後の L1 有効化時に全違反がまとめて噴出する)。
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
111
169
|
## ⚠️ 2フェーズ実行ルール
|
|
112
170
|
|
|
113
171
|
**このスキルは必ず2フェーズに分けて実行する。Phase 1で実装計画を作成し、人間の承認を得てからPhase 2でTDD実装を行う。Phase 1とPhase 2を同時に実行してはならない。**
|
|
@@ -154,6 +154,47 @@ Unit分割の方針・グルーピングの根拠・不明点を整理し、人
|
|
|
154
154
|
|
|
155
155
|
---
|
|
156
156
|
|
|
157
|
+
## 🔗 成果物のトレーサビリティメタデータ(必須)
|
|
158
|
+
|
|
159
|
+
Phase 2 で生成する Unit 定義文書には、以下 2 種類のメタデータを emit する。`MetadataValidator.validateDesignDocument` が検証対象とし、ISSUE-008 Phase B-2/B-3 完了後は `npx phasegate validate-metadata` / pre-commit で自動チェックされる。
|
|
160
|
+
|
|
161
|
+
### 1. YAML frontmatter(新規作成時)
|
|
162
|
+
|
|
163
|
+
`docs/product/units/{unit_name}.md` の先頭に以下を付与する。既存 Unit 定義の改訂時は省略してよい。`integration_contract.md` は Unit 横断のため任意。
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
---
|
|
167
|
+
traceability:
|
|
168
|
+
initial_creation: true
|
|
169
|
+
---
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`initial_creation: true` は「新規作成であり、後述の `@story-id` 注釈が必須」であることを示す。
|
|
173
|
+
|
|
174
|
+
### 2. `@story-id` インライン注釈
|
|
175
|
+
|
|
176
|
+
ユーザーストーリーに紐づく機能要件・エンドポイント定義の直前に `@story-id HXX-XX` を独立行で記述する。
|
|
177
|
+
|
|
178
|
+
```markdown
|
|
179
|
+
@story-id H03-02
|
|
180
|
+
### 機能要件: 注文確定
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
形式ルール:
|
|
184
|
+
- **独立行** — 他のテキストと混在させない
|
|
185
|
+
- **直後に設計要素** — 空行を挟まない
|
|
186
|
+
- **StoryCatalog 存在** — `HXX-XX` は `docs/product/user_stories.md` に存在する ID
|
|
187
|
+
- **複数ストーリー時** — 注釈行を連続で並べ、最後の直後に設計要素を置く
|
|
188
|
+
|
|
189
|
+
### 3. Phase 3 レビューでの BLOCK 確認
|
|
190
|
+
|
|
191
|
+
Phase 3 レビューで以下を BLOCK 基準として確認する:
|
|
192
|
+
- 新規作成文書に `initial_creation: true` frontmatter が付与されているか
|
|
193
|
+
- 担当ストーリーに対応する機能要件の直前に `@story-id` が配置されているか
|
|
194
|
+
- 上記形式ルールに準拠しているか
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
157
198
|
## Phase 3: レビュー(Opus review)
|
|
158
199
|
|
|
159
200
|
### 実行主体
|
|
@@ -189,6 +189,24 @@ TDD実装フェーズ
|
|
|
189
189
|
|
|
190
190
|
---
|
|
191
191
|
|
|
192
|
+
## 🔗 テストファイルのトレーサビリティメタデータ(必須)
|
|
193
|
+
|
|
194
|
+
Phase 2 で設計するテストファイル(`*.test.ts` / `*.spec.ts`)の疑似コード冒頭には、ファイル先頭コメントブロックに `// @story HXX-XX` を emit するよう明記する。`MetadataValidator.validateTest` が検証対象とし、ISSUE-008 Phase C-2 以降は `npx phasegate validate-metadata` / pre-commit で自動チェックされる。
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// @unit <被テストコードと同じ Unit ID>
|
|
198
|
+
// @layer <被テストコードと同じ layer>
|
|
199
|
+
// @story H03-02
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
形式ルール:
|
|
203
|
+
- `@unit` / `@layer` と同じヘッダーコメントブロックに配置
|
|
204
|
+
- `HXX-XX` は `docs/product/user_stories.md` に存在する ID(StoryCatalog)
|
|
205
|
+
- 複数ストーリーをカバーするテストは `// @story H03-01, H03-02` のようにカンマ区切りで列挙
|
|
206
|
+
- 目的: US↔テストの逆引きを機械化(test-coverage-checker / nyquist の集計入力)
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
192
210
|
## 注意事項
|
|
193
211
|
|
|
194
212
|
- **テストコードは生成しない**(設計文書のみ)— 実装は `story-implementor` が行う
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "startup|resume",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "npx phasegate hook session-start",
|
|
10
|
+
"statusMessage": "phasegate: loading session context"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"UserPromptSubmit": [
|
|
16
|
+
{
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "npx phasegate hook user-prompt-submit",
|
|
21
|
+
"statusMessage": "phasegate: refreshing status"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"PreToolUse": [
|
|
27
|
+
{
|
|
28
|
+
"matcher": "Bash",
|
|
29
|
+
"hooks": [
|
|
30
|
+
{
|
|
31
|
+
"type": "command",
|
|
32
|
+
"command": "npx phasegate hook pre-tool-use",
|
|
33
|
+
"statusMessage": "phasegate: pre-tool-use check"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"PostToolUse": [
|
|
39
|
+
{
|
|
40
|
+
"matcher": "Bash",
|
|
41
|
+
"hooks": [
|
|
42
|
+
{
|
|
43
|
+
"type": "command",
|
|
44
|
+
"command": "npx phasegate hook post-tool-use",
|
|
45
|
+
"statusMessage": "phasegate: post-tool-use lint"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"Stop": [
|
|
51
|
+
{
|
|
52
|
+
"hooks": [
|
|
53
|
+
{
|
|
54
|
+
"type": "command",
|
|
55
|
+
"command": "npx phasegate hook stop",
|
|
56
|
+
"statusMessage": "phasegate: completion check",
|
|
57
|
+
"timeout": 30
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
traceability:
|
|
3
|
+
initial_creation: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 論理設計: <Unit名>
|
|
7
|
+
|
|
8
|
+
> **対応ストーリー**: <HXX-XX, HYY-YY>
|
|
9
|
+
> **作成日**: <YYYY-MM-DD>
|
|
10
|
+
> **Unit**: <UNIT_NAME>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 概要
|
|
15
|
+
|
|
16
|
+
<このUnitが解決するビジネス課題を 2〜3 行で記述>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ドメインモデル
|
|
21
|
+
|
|
22
|
+
@story-id <HXX-XX>
|
|
23
|
+
### <集約 / エンティティ / 値オブジェクト名>
|
|
24
|
+
|
|
25
|
+
<不変条件・責務・関連の説明>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ユースケース
|
|
30
|
+
|
|
31
|
+
@story-id <HXX-XX>
|
|
32
|
+
### UC-001: <ユースケース名>
|
|
33
|
+
|
|
34
|
+
**As a** <役割>
|
|
35
|
+
**I want to** <達成したいこと>
|
|
36
|
+
**So that** <得られる価値>
|
|
37
|
+
|
|
38
|
+
#### 事前条件
|
|
39
|
+
- <前提>
|
|
40
|
+
|
|
41
|
+
#### 基本フロー
|
|
42
|
+
1. <ステップ>
|
|
43
|
+
|
|
44
|
+
#### 例外フロー
|
|
45
|
+
- <エラーケース>
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 層構成(Clean Architecture)
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
domain/ : Entity / ValueObject / Port / Domain Service
|
|
53
|
+
application/ : UseCase / DTO
|
|
54
|
+
infrastructure/ : Gateway / Adapter
|
|
55
|
+
presentation/ : CLI Handler / Controller
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## トレーサビリティメタデータの使い方
|
|
61
|
+
|
|
62
|
+
このテンプレートが emit する 2 種類のメタデータ:
|
|
63
|
+
|
|
64
|
+
### 1. YAML frontmatter (`initial_creation: true`)
|
|
65
|
+
- 文書の**新規作成時のみ**付与する
|
|
66
|
+
- `@story-id` インライン注釈が必須であることを示すフラグ
|
|
67
|
+
- 2 回目以降の改訂では frontmatter を削除(または `false` に変更)して構わない
|
|
68
|
+
|
|
69
|
+
### 2. `@story-id` インライン注釈
|
|
70
|
+
- ユーザーストーリーに紐づく設計要素の**直前に独立行で記述**
|
|
71
|
+
- 形式: `@story-id HXX-XX`
|
|
72
|
+
- ルール:
|
|
73
|
+
- 独立行(他のテキストと混在させない)
|
|
74
|
+
- 直後に設計要素(空行を挟まない)
|
|
75
|
+
- `HXX-XX` は `docs/product/user_stories.md` に存在する ID
|
|
76
|
+
- 複数ストーリー時は連続並列で並べ、最後の直後に設計要素
|
|
77
|
+
|
|
78
|
+
これらは `MetadataValidator.validateDesignDocument` で検証され、
|
|
79
|
+
ISSUE-008 Phase B-2 / B-3 以降は `npx phasegate validate-metadata` / pre-commit で自動チェックされる。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @unit <UNIT_NAME>
|
|
2
|
+
// @layer <LAYER>
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* phasegate ソースファイルテンプレート
|
|
6
|
+
*
|
|
7
|
+
* 使い方:
|
|
8
|
+
* 1. `<UNIT_NAME>` を `docs/product/construction/` 配下の Unit ID に置換
|
|
9
|
+
* (例: traceability-model, harness-api)
|
|
10
|
+
* 2. `<LAYER>` を以下のいずれかに置換
|
|
11
|
+
* - domain : Entity / ValueObject / Port / Domain Service
|
|
12
|
+
* - application : UseCase / DTO / Application Service
|
|
13
|
+
* - infrastructure : Gateway / Adapter(外部 I/O 接続)
|
|
14
|
+
* - presentation : CLI Handler / Controller / Formatter
|
|
15
|
+
* 3. 配置ディレクトリと `@layer` 値を一致させる(L1-004 ルール)
|
|
16
|
+
*
|
|
17
|
+
* このメタデータは L1 Biome ルール(L1-001 / L1-002)で検証される。
|
|
18
|
+
*/
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @unit <UNIT_NAME>
|
|
2
|
+
// @layer test
|
|
3
|
+
// @story <STORY_ID>
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* phasegate テストファイルテンプレート
|
|
7
|
+
*
|
|
8
|
+
* 使い方:
|
|
9
|
+
* 1. `<UNIT_NAME>` を被テスト実装と同じ Unit ID に置換
|
|
10
|
+
* 2. `<STORY_ID>` を本テストがカバーする User Story ID に置換
|
|
11
|
+
* (例: H03-02。複数カバーする場合は `H03-01, H03-02` のようにカンマ区切り)
|
|
12
|
+
* 3. `<TestSubject>` を対象のクラス / 関数名に置換
|
|
13
|
+
* 4. `target` / `context` は project の test-helpers から import される describe エイリアス
|
|
14
|
+
*
|
|
15
|
+
* このメタデータは `MetadataValidator.validateTest` で検証される:
|
|
16
|
+
* - `@story` が存在すること
|
|
17
|
+
* - `HXX-XX` 形式であること
|
|
18
|
+
* - `docs/product/user_stories.md`(StoryCatalog)に存在する ID であること
|
|
19
|
+
*
|
|
20
|
+
* pre-commit 経路で自動チェックされる(ISSUE-008 Phase C-3)。
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { describe, expect, it } from 'vitest';
|
|
24
|
+
import { target, context } from '../helpers/test-helpers.js';
|
|
25
|
+
|
|
26
|
+
target('<TestSubject>', () => {
|
|
27
|
+
context('<前提条件・シナリオ>', () => {
|
|
28
|
+
it('<期待される挙動を日本語で記述>', () => {
|
|
29
|
+
// Arrange
|
|
30
|
+
const input = 'TODO';
|
|
31
|
+
// Act
|
|
32
|
+
const actual = input;
|
|
33
|
+
// Assert
|
|
34
|
+
expect(actual).toBe('TODO');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|