Repository navigation
feat(shared,cli): add ProjectSettingsSchema and settings load infrastructure - #594
Conversation
…ructure Implements spec-000035 (req-000029: プロジェクト設定ファイルによるワークフローカスタマイズ) - Add ProjectSettingsSchema with 7 sub-schemas to @reqord/shared - Add project-settings repository for reading setting.yaml - Add project-settings-service with default merge and validation - Include comprehensive tests (schema, repository, service) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @kicchann's task in 2m 1s —— View job コードレビュー
総評全体的に設計は明瞭で、Zod スキーマ・リポジトリ・サービスの3層構造が適切に分離されています。テストカバレッジも十分で、デフォルト値補完・バリデーションエラー・エラーフォールバックなど、仕様の主要な要件が網羅されています。 いくつか指摘事項があります。 [要検討]
|
There was a problem hiding this comment.
Pull request overview
Adds the initial setting.yaml foundation by defining a project-level settings schema in @reqord/shared and introducing CLI-side infrastructure to read, validate, and load settings with defaults.
Changes:
- Added
ProjectSettingsSchema(plus sub-schemas) to@reqord/sharedwith defaults and invariant enforcement via Zod. - Implemented CLI repository + service to read
.reqord/settings/setting.yamland validate it against the shared schema. - Added unit tests for both schema behavior (defaults/validation) and CLI loading behavior (repo + service).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/schemas/project-settings.ts | Introduces Zod schemas/types for project settings with defaults and invariant constraints. |
| packages/shared/src/schemas/project-settings.test.ts | Tests defaulting, stripping unknown keys, and validation error cases for the settings schema. |
| packages/shared/src/schemas/index.ts | Exports the new settings schemas/types from the shared package schema index. |
| packages/cli/src/repositories/project-settings.ts | Reads raw YAML from .reqord/settings/setting.yaml (returns {} when missing/empty). |
| packages/cli/src/repositories/project-settings.test.ts | Verifies repository behavior with real filesystem YAML files and parse errors. |
| packages/cli/src/services/project-settings-service.ts | Loads settings via repo + Zod validation and provides a default settings helper. |
| packages/cli/src/services/project-settings-service.test.ts | Validates service behavior for defaults, partial merges via schema defaults, and error paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| raw = await projectSettingsRepo.readRawProjectSettings(cwd); | ||
| } catch (error) { | ||
| console.warn( | ||
| `[reqord] Could not read setting.yaml: ${error instanceof Error ? error.message : String(error)}. Using default settings.`, | ||
| ); | ||
| return getDefaultProjectSettings(); | ||
| } | ||
| const result = ProjectSettingsSchema.safeParse(raw); | ||
| if (!result.success) { | ||
| console.warn( | ||
| `[reqord] Invalid setting.yaml: ${result.error.message}. Using default settings.`, | ||
| ); | ||
| return getDefaultProjectSettings(); |
There was a problem hiding this comment.
loadProjectSettings falls back to default settings on both read errors and schema validation failures. This makes a misconfigured setting.yaml (e.g. invariants.versioning: false) easy to miss and conflicts with the success criterion that setting invariants to false should result in a validation error. Consider throwing (or returning a typed error) on validation failures at least, and only defaulting when the file is missing/empty.
There was a problem hiding this comment.
@copilot ありがとうございます。
これは design.md セクション4.3の仕様通りの実装です(「パース失敗時は警告を出しデフォルト設定を返す」)。setting.yaml の欠損・破損でも CLI が動作継続できることを意図しています。
invariants 違反時にエラーとして伝播させるかどうかは、将来の spec で検討する余地がありますが、現時点では spec-000035 のスコープ外として対応を見送ります。
| if (!result.success) { | ||
| console.warn( | ||
| `[reqord] Invalid setting.yaml: ${result.error.message}. Using default settings.`, | ||
| ); |
There was a problem hiding this comment.
The warning for invalid settings uses result.error.message, which is often hard to read for nested Zod objects. The repo already exports formatZodError from @reqord/shared and uses it in other validation errors; consider using it here (even in warnings) so users can quickly pinpoint the invalid field/path.
| it("invariants未指定の場合は全項目がtrueで補完される", () => { | ||
| const result = ProjectSettingsSchema.parse({}); | ||
| expect(result.invariants.versioning).toBe(true); | ||
| expect(result.invariants.cyclicDependencyCheck).toBe(true); | ||
| expect(result.invariants.statusTransitionRules).toBe(true); | ||
| expect(result.invariants.schemaValidation).toBe(true); | ||
| }); |
There was a problem hiding this comment.
This test duplicates the earlier "空オブジェクトを渡すと全フィールドがデフォルト値で補完される" case (it parses {} again and asserts the same invariants defaults). Consider changing this to cover a distinct scenario (e.g. parse({ invariants: {} })) or removing it to keep the suite focused.
- Use formatZodError for readable validation error messages (Copilot C2) - Remove unused initial value from raw variable (Claude L2) - Add afterEach vi.restoreAllMocks() for test stability (Claude L1) - Change duplicate test to cover explicit empty invariants object (Copilot C3) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@claude レビューありがとうございます。指摘3件への対応状況です (a13a804): [要検討]
|
|
Claude finished @kicchann's task in 50s —— View job 修正内容の確認
コミット [要検討]
|
Specification
spec-000035: 設定スキーマ定義とロード基盤(setting.yaml)
Requirement
req-000029: プロジェクト設定ファイル(setting.yaml)によるワークフローカスタマイズ
Success Criteria
Changes
packages/shared/src/schemas/project-settings.ts- ProjectSettingsSchema + 7 sub-schemas (Zod)packages/shared/src/schemas/project-settings.test.ts- Schema tests (12 cases)packages/shared/src/schemas/index.ts- Export additionspackages/cli/src/repositories/project-settings.ts- setting.yaml readerpackages/cli/src/repositories/project-settings.test.ts- Repository tests (4 cases, real FS)packages/cli/src/services/project-settings-service.ts- Load API with default mergepackages/cli/src/services/project-settings-service.test.ts- Service tests (6 cases)Note: This spec implements the schema definition and load infrastructure only. Applying settings to actual CLI commands is handled by spec-000036 through spec-000041.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com