phasegate 0.91.0 → 0.107.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 (68) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/README.ja.md +15 -7
  3. package/README.md +24 -4
  4. package/docs/ADR/ADR-015-architecture-preset.md +183 -0
  5. package/docs/guide/codex-integration.md +7 -2
  6. package/docs/guide/installation.md +10 -2
  7. package/docs/guide/preset-selection.md +170 -0
  8. package/docs/guide/quick-vs-full-mode.md +3 -3
  9. package/docs/guide/retrofit-adoption.md +19 -2
  10. package/docs/guide/skills-overview.md +1 -1
  11. package/package.json +7 -1
  12. package/scripts/harness/agent-integration/application/usecases/handle-pre-tool-use-usecase.ts +108 -100
  13. package/scripts/harness/agent-integration/domain/ports/phase-gate-query-port.ts +3 -3
  14. package/scripts/harness/agent-integration/domain/value-objects/write-target-scope.ts +26 -30
  15. package/scripts/harness/agent-integration/infrastructure/adapters/file-system-story-reflection-query-adapter.ts +6 -2
  16. package/scripts/harness/biome-ast-engine/application/dto/analyze-import-graph-input.ts +3 -0
  17. package/scripts/harness/biome-ast-engine/application/dto/resolve-enabled-rules-output.ts +2 -0
  18. package/scripts/harness/biome-ast-engine/application/mappers/resolve-enabled-rules-output-mapper.ts +4 -1
  19. package/scripts/harness/biome-ast-engine/application/usecases/analyze-import-graph-usecase.ts +4 -1
  20. package/scripts/harness/biome-ast-engine/application/usecases/execute-lint-usecase.ts +2 -0
  21. package/scripts/harness/biome-ast-engine/application/usecases/resolve-enabled-rules-usecase.ts +31 -3
  22. package/scripts/harness/biome-ast-engine/composition-root.ts +10 -2
  23. package/scripts/harness/biome-ast-engine/domain/ports/rule-config-provider-port.ts +16 -0
  24. package/scripts/harness/biome-ast-engine/domain/ports/source-module-analyzer-port.ts +5 -1
  25. package/scripts/harness/biome-ast-engine/domain/services/lint-runner.ts +5 -1
  26. package/scripts/harness/biome-ast-engine/domain/value-objects/architecture-spec.ts +38 -0
  27. package/scripts/harness/biome-ast-engine/domain/value-objects/layer-boundary.ts +7 -8
  28. package/scripts/harness/biome-ast-engine/domain/value-objects/layer-name.ts +15 -23
  29. package/scripts/harness/biome-ast-engine/domain/value-objects/source-module-snapshot.ts +11 -4
  30. package/scripts/harness/biome-ast-engine/infrastructure/adapters/harness-config-provider-adapter.ts +29 -3
  31. package/scripts/harness/biome-ast-engine/infrastructure/adapters/typescript-source-module-analyzer-adapter.ts +22 -15
  32. package/scripts/harness/biome-ast-engine/infrastructure/mappers/source-module-snapshot-mapper.ts +26 -17
  33. package/scripts/harness/config-foundation/application/dto/resolved-config-output.ts +1 -0
  34. package/scripts/harness/config-foundation/application/usecases/load-resolved-config-use-case.ts +34 -2
  35. package/scripts/harness/config-foundation/application/usecases/migrate-schema-use-case.ts +89 -0
  36. package/scripts/harness/config-foundation/composition-root.ts +8 -0
  37. package/scripts/harness/config-foundation/domain/harness-config.ts +6 -0
  38. package/scripts/harness/config-foundation/domain/services/architecture-resolution-service.ts +257 -0
  39. package/scripts/harness/config-foundation/domain/value-objects/architecture-config.ts +66 -0
  40. package/scripts/harness/config-foundation/domain/value-objects/architecture-preset-catalog.ts +75 -0
  41. package/scripts/harness/config-foundation/infrastructure/schemas/harness-config-v3.schema.json +546 -0
  42. package/scripts/harness/config-foundation/infrastructure/validators/ajv-config-schema-validator.ts +18 -6
  43. package/scripts/harness/config-foundation/presentation/cli/migrate-schema-command-handler.ts +83 -0
  44. package/scripts/harness/integrations/pre-commit.ts +211 -52
  45. package/scripts/harness/main.ts +460 -340
  46. package/scripts/harness/phase-dependency-model/domain/ports/story-reflection-file-system-port.ts +2 -4
  47. package/scripts/harness/phase-dependency-model/domain/services/story-reflection-checker.ts +54 -17
  48. package/scripts/harness/phase-dependency-model/infrastructure/filesystem/file-system-story-reflection-adapter.ts +154 -36
  49. package/scripts/harness/setup/skill-deployer.ts +140 -102
  50. package/scripts/harness/skill-quality/domain/errors/skill-quality-error.ts +24 -23
  51. package/scripts/harness/skill-quality/domain/value-objects/commit-message.ts +23 -7
  52. package/scripts/harness/traceability-model/application/usecases/apply-work-item-migration-usecase.ts +52 -0
  53. package/scripts/harness/traceability-model/application/usecases/plan-work-item-migration-usecase.ts +29 -0
  54. package/scripts/harness/traceability-model/application/usecases/validate-design-story-annotations-usecase.ts +83 -18
  55. package/scripts/harness/traceability-model/composition-root.ts +48 -30
  56. package/scripts/harness/traceability-model/domain/ports/design-document-port.ts +9 -15
  57. package/scripts/harness/traceability-model/domain/ports/work-item-migration-apply-port.ts +11 -0
  58. package/scripts/harness/traceability-model/domain/ports/work-item-migration-source-port.ts +9 -0
  59. package/scripts/harness/traceability-model/domain/services/work-item-migration-planner.ts +162 -0
  60. package/scripts/harness/traceability-model/domain/value-objects/work-item-frontmatter.ts +57 -0
  61. package/scripts/harness/traceability-model/domain/value-objects/work-item-migration-candidate.ts +47 -0
  62. package/scripts/harness/traceability-model/infrastructure/gateways/file-system-work-item-migration-apply-gateway.ts +110 -0
  63. package/scripts/harness/traceability-model/infrastructure/gateways/file-system-work-item-migration-source-gateway.ts +182 -0
  64. package/scripts/harness/traceability-model/infrastructure/gateways/markdown-design-document-gateway.ts +29 -43
  65. package/scripts/harness/traceability-model/infrastructure/parsers/work-item-frontmatter-parser.ts +136 -0
  66. package/scripts/harness/traceability-model/presentation/cli/migrate-work-items-command-handler.ts +186 -0
  67. package/skills/quick-implementor/SKILL.md +17 -1
  68. package/templates/.husky/commit-msg +1 -0
@@ -0,0 +1,186 @@
1
+ // @unit traceability-model
2
+ // @layer presentation
3
+
4
+ import type { ApplyWorkItemMigrationUseCase } from "../../application/usecases/apply-work-item-migration-usecase.js";
5
+ import type { PlanWorkItemMigrationUseCase } from "../../application/usecases/plan-work-item-migration-usecase.js";
6
+ import type {
7
+ WorkItemMigrationApplyResult,
8
+ WorkItemMigrationCandidate,
9
+ WorkItemMigrationPlan,
10
+ } from "../../domain/value-objects/work-item-migration-candidate.js";
11
+
12
+ export interface MigrateWorkItemsCommandInput {
13
+ readonly dryRun?: boolean;
14
+ readonly apply?: boolean;
15
+ readonly json?: boolean;
16
+ }
17
+
18
+ export interface MigrateWorkItemsCommandOutput {
19
+ readonly exitCode: 0 | 1 | 2;
20
+ readonly text: string;
21
+ }
22
+
23
+ type PlanUseCase = Pick<PlanWorkItemMigrationUseCase, "execute">;
24
+ type ApplyUseCase = Pick<ApplyWorkItemMigrationUseCase, "execute">;
25
+
26
+ export interface MigrateWorkItemsCommandHandlerDeps {
27
+ readonly planWorkItemMigrationUseCase: PlanUseCase;
28
+ readonly applyWorkItemMigrationUseCase?: ApplyUseCase;
29
+ }
30
+
31
+ export class MigrateWorkItemsCommandHandler {
32
+ private readonly planUseCase: PlanUseCase;
33
+ private readonly applyUseCase?: ApplyUseCase;
34
+
35
+ constructor(deps: MigrateWorkItemsCommandHandlerDeps) {
36
+ this.planUseCase = deps.planWorkItemMigrationUseCase;
37
+ this.applyUseCase = deps.applyWorkItemMigrationUseCase;
38
+ }
39
+
40
+ async execute(input: MigrateWorkItemsCommandInput): Promise<Readonly<MigrateWorkItemsCommandOutput>> {
41
+ if (input.apply && input.dryRun) {
42
+ return Object.freeze({
43
+ exitCode: 2,
44
+ text: "Error: --apply and --dry-run cannot be used together.",
45
+ });
46
+ }
47
+
48
+ if (input.apply) {
49
+ return this.executeApply(input);
50
+ }
51
+
52
+ if (!input.dryRun) {
53
+ return Object.freeze({
54
+ exitCode: 2,
55
+ text: "Error: either --dry-run or --apply is required for migrate work-items.",
56
+ });
57
+ }
58
+
59
+ try {
60
+ const plan = await this.planUseCase.execute();
61
+ const hasConflict = plan.candidates.some((candidate) => candidate.conflict);
62
+ return Object.freeze({
63
+ exitCode: hasConflict ? 1 : 0,
64
+ text: input.json ? this.formatJson(plan) : this.formatHuman(plan),
65
+ });
66
+ } catch {
67
+ return Object.freeze({
68
+ exitCode: 2,
69
+ text: "Error: failed to plan work item migration unexpectedly.",
70
+ });
71
+ }
72
+ }
73
+
74
+ private formatJson(plan: WorkItemMigrationPlan): string {
75
+ return JSON.stringify(
76
+ {
77
+ candidates: plan.candidates,
78
+ warnings: plan.warnings,
79
+ },
80
+ null,
81
+ 2,
82
+ );
83
+ }
84
+
85
+ private async executeApply(input: MigrateWorkItemsCommandInput): Promise<Readonly<MigrateWorkItemsCommandOutput>> {
86
+ if (!this.applyUseCase) {
87
+ return Object.freeze({
88
+ exitCode: 2,
89
+ text: "Error: --apply is not configured for migrate work-items.",
90
+ });
91
+ }
92
+
93
+ try {
94
+ const result = await this.applyUseCase.execute();
95
+ return Object.freeze({
96
+ exitCode: result.blocked ? 1 : 0,
97
+ text: input.json ? this.formatApplyJson(result) : this.formatApplyHuman(result),
98
+ });
99
+ } catch {
100
+ return Object.freeze({
101
+ exitCode: 2,
102
+ text: "Error: failed to apply work item migration unexpectedly.",
103
+ });
104
+ }
105
+ }
106
+
107
+ private formatApplyJson(result: WorkItemMigrationApplyResult): string {
108
+ return JSON.stringify(
109
+ {
110
+ applied: result.applied,
111
+ skipped: result.skipped,
112
+ warnings: result.warnings,
113
+ blocked: result.blocked,
114
+ },
115
+ null,
116
+ 2,
117
+ );
118
+ }
119
+
120
+ private formatApplyHuman(result: WorkItemMigrationApplyResult): string {
121
+ const lines = [
122
+ "WorkItem migration apply",
123
+ `applied: ${result.applied.length}`,
124
+ `skipped: ${result.skipped.length}`,
125
+ `warnings: ${result.warnings.length}`,
126
+ `blocked: ${result.blocked ? "yes" : "no"}`,
127
+ "",
128
+ ];
129
+
130
+ for (const applied of result.applied) {
131
+ lines.push(`- applied ${applied.legacyId} -> ${applied.nextId}`);
132
+ lines.push(` target: ${applied.targetPath}`);
133
+ lines.push(` description: ${applied.descriptionPath}`);
134
+ lines.push("");
135
+ }
136
+
137
+ for (const skipped of result.skipped) {
138
+ lines.push(`- skipped ${skipped.legacyId} -> ${skipped.nextId}`);
139
+ lines.push(` reason: conflict`);
140
+ lines.push(` target: ${skipped.targetPath}`);
141
+ lines.push("");
142
+ }
143
+
144
+ if (result.warnings.length > 0) {
145
+ lines.push("Warnings:");
146
+ for (const warning of result.warnings) {
147
+ lines.push(` - ${warning}`);
148
+ }
149
+ }
150
+
151
+ return lines.join("\n").trimEnd();
152
+ }
153
+
154
+ private formatHuman(plan: WorkItemMigrationPlan): string {
155
+ const lines = [
156
+ "WorkItem migration dry-run",
157
+ `candidates: ${plan.candidates.length}`,
158
+ `warnings: ${plan.warnings.length}`,
159
+ "",
160
+ ];
161
+
162
+ for (const candidate of plan.candidates) {
163
+ lines.push(...this.formatCandidate(candidate), "");
164
+ }
165
+
166
+ if (plan.warnings.length > 0) {
167
+ lines.push("Warnings:");
168
+ for (const warning of plan.warnings) {
169
+ lines.push(` - ${warning}`);
170
+ }
171
+ }
172
+
173
+ return lines.join("\n").trimEnd();
174
+ }
175
+
176
+ private formatCandidate(candidate: WorkItemMigrationCandidate): string[] {
177
+ return [
178
+ `- ${candidate.legacyId} -> ${candidate.nextId}`,
179
+ ` source: ${candidate.sourcePath}`,
180
+ ` target: ${candidate.targetPath}`,
181
+ ` scope: ${candidate.scope}`,
182
+ ` description: ${candidate.descriptionFileName ?? "missing"}`,
183
+ ` conflict: ${candidate.conflict ? "yes" : "no"}`,
184
+ ];
185
+ }
186
+ }
@@ -18,6 +18,20 @@ Quick Mode下での軽微変更実装スキル。story-implementorの緩和版
18
18
  | `test` | テスト追加・修正(新機能のテストではない) |
19
19
  | `config` | 設定変更、依存バージョン更新 |
20
20
 
21
+ ### WI-aware trivial path(ISSUE-026 Phase D)
22
+
23
+ 作業対象に `WI-XXX` が明示されている場合、最初に `docs/inception/{unit}/WI-XXX/description.md` または `docs/inception/_cross/WI-XXX/description.md` のfrontmatterを確認する。
24
+
25
+ | WI type | Quick Modeでの扱い |
26
+ |---------|-------------------|
27
+ | `fix` | 適用候補。既存仕様の局所修正として扱う |
28
+ | `chore` | 適用候補。依存更新・運用・ドキュメント整備として扱う |
29
+ | `story` | 適用不可。`story-implementor` にエスカレーション |
30
+ | `issue` | 適用不可。product反映が必要な可能性が高いため `story-implementor` にエスカレーション |
31
+ | `refactor` | 適用不可。設計影響を伴う可能性が高いため `story-implementor` にエスカレーション |
32
+
33
+ `type: fix | chore` でも、API契約変更・新ドメインモデル追加・レイヤー構造変更・複数Unitにまたがる実装変更が見えた場合は、通常の除外ルールを優先して `story-implementor` に切り替える。
34
+
21
35
  ### 適用除外(フルハーネス必須 → story-implementor を使用)
22
36
 
23
37
  - 新機能追加
@@ -82,10 +96,12 @@ pnpm test # 全テスト グリーンを確認
82
96
 
83
97
  ### Step 5: コミット
84
98
 
85
- Atomic commit で変更をコミットする。コミットメッセージに `[quick]` プレフィックスを付与。
99
+ Atomic commit で変更をコミットする。コミットメッセージに `[quick]` プレフィックスを付与。作業対象WIがある場合は `Work-Item: WI-XXX` trailer を必ず含める。
86
100
 
87
101
  ```
88
102
  [quick] fix: {変更内容の要約}
103
+
104
+ Work-Item: WI-XXX
89
105
  ```
90
106
 
91
107
  ---
@@ -0,0 +1 @@
1
+ npx phasegate commit-msg "$1"