Repository navigation
feat(cli): integrate ProjectSettings into all CLI commands (spec-000036~041) - #598
Conversation
…36~041) Implement 6 specifications for req-000029 project settings customization: - spec-000036: Approval prerequisites customization (designMdCheck, descriptionMdCheck, customFiles) - spec-000037: Status transition PR toggle (draftToApproved, approvedToImplemented, toDraft) - spec-000038: Branch naming prefix customization (toApprovedPrefix, toImplementedPrefix, toDraftPrefix) - spec-000039: Feedback validation blocking with severity threshold - spec-000040: Consistency check level (warning/error for spec-not-implemented) - spec-000041: Auto draft revert control (always/major-only/never) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @kicchann's task in 3m 2s —— View job コードレビュー結果タスクリスト
総評6つのSpec(spec-000036〜041)に対応する大規模な機能追加です。 🐛 バグ(要修正)1.
|
There was a problem hiding this comment.
Pull request overview
This PR extends the CLI to load and pass ProjectSettings through command/service layers, enabling spec-driven toggles for approval prerequisites, PR-vs-direct status transitions, branch naming, feedback blocking, consistency-check severity, and auto draft reversion behavior (spec-000036~041).
Changes:
- Introduces settings-driven branching for PR creation vs direct commits during status transitions (approve/implement/draft-to-draft flows) and customizable branch prefixes.
- Adds settings-controlled approval prerequisite checks (design/description + custom required files) and feedback-based approval blocking by severity threshold.
- Adds auto-revert-to-draft modes (
always/major-only/never) and consistency-check escalation for spec-not-implemented warnings.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cli/src/services/version-service.ts | Extends auto-revert logic to support settings-driven modes and bump-type gating. |
| packages/cli/src/services/version-service.test.ts | Adds coverage for the new auto-revert modes and bump-type behavior. |
| packages/cli/src/services/status-transition-service.ts | New shared helper for PR-based vs direct-commit status transitions. |
| packages/cli/src/services/status-transition-service.test.ts | Tests ordering and behavior for PR/direct-commit transition flows. |
| packages/cli/src/services/specification-service.ts | Makes spec approval prerequisites settings-driven (design.md + custom required files). |
| packages/cli/src/services/specification-service.test.ts | Adds tests for settings-driven prerequisite behavior (designMdCheck/customFiles). |
| packages/cli/src/services/requirement-service.ts | Adds settings-aware auto-revert and requirement approval prerequisite checks (description/custom files). |
| packages/cli/src/services/requirement-service.test.ts | Updates auto-revert expectations and adds tests for requirement prerequisites. |
| packages/cli/src/services/feedback-validation.ts | New helper to determine whether unresolved feedback blocks approval based on settings. |
| packages/cli/src/services/feedback-validation.test.ts | Thorough tests for feedback blocking thresholds and defaults. |
| packages/cli/src/services/draft-reversion-service.ts | Adds settings-based PR toggle and branch prefix customization for revert-to-draft. |
| packages/cli/src/services/draft-reversion-service.test.ts | Updates tests for new revert-to-draft signature and PR/direct-commit branches. |
| packages/cli/src/services/approval-service.ts | Adds settings-based PR toggle and branch prefix customization for approval flow. |
| packages/cli/src/services/approval-service.test.ts | Updates/extends tests for PR toggle and custom branch prefix behavior. |
| packages/cli/src/repositories/requirement.ts | Adds loadFile() used for custom prerequisite file checks. |
| packages/cli/src/commands/spec/spec-approval-flow.integration.test.ts | Integrates settings + feedback mocks into spec approval flow integration tests. |
| packages/cli/src/commands/spec/implement.ts | Uses settings to choose PR-based vs direct-commit “approved → implemented” flow (via status-transition service). |
| packages/cli/src/commands/spec/draft.ts | Loads settings and passes them into revert-to-draft flow. |
| packages/cli/src/commands/spec/draft.test.ts | Updates tests for settings being loaded/passed to revert-to-draft. |
| packages/cli/src/commands/spec/approve.ts | Loads settings, uses settings-driven prerequisite checks and feedback blocking, passes settings into approval service. |
| packages/cli/src/commands/spec/approve.test.ts | Updates tests for settings load/passing and prerequisite invocation changes. |
| packages/cli/src/commands/req/update.ts | Loads settings and forwards them to requirement updates for auto-revert control. |
| packages/cli/src/commands/req/update.test.ts | New test coverage ensuring settings are passed to updateRequirement. |
| packages/cli/src/commands/req/implement.ts | Adds settings-driven consistency escalation and PR-based vs direct-commit transition. |
| packages/cli/src/commands/req/implement.test.ts | Adds coverage for specNotImplementedLevel behavior and settings integration. |
| packages/cli/src/commands/req/draft.ts | Loads settings and passes them into revert-to-draft flow. |
| packages/cli/src/commands/req/draft.test.ts | Updates tests for settings being loaded/passed to revert-to-draft. |
| packages/cli/src/commands/req/approve.ts | Loads settings, runs requirement prerequisites, applies feedback blocking, passes settings into approval service. |
| packages/cli/src/commands/req/approve.test.ts | Updates tests for settings load/passing and prerequisite invocation changes. |
Comments suppressed due to low confidence (2)
packages/cli/src/commands/req/approve.ts:117
- startApproval may return an empty result when settings.statusTransitionPr.draftToApproved is false. This command prints
Branch: ${result.branchName}/PR: ${result.prUrl}and states approval is confirmed when the PR is merged, which will produceundefinedoutput and incorrect messaging in the direct-commit mode. Update the success output to branch on settings.statusTransitionPr.draftToApproved (e.g., print PR info only in PR flow, and print a direct-commit completion message otherwise).
const result = await startApproval(cwd, target, customHandler, settings, {
dryRun: options.dryRun,
});
if (options.dryRun) {
return;
}
console.log(chalk.green(`Approval PR created: ${id}`));
console.log(`Approval will be confirmed when the PR is merged`);
console.log(` Branch: ${result.branchName}`);
console.log(` PR: ${result.prUrl}`);
packages/cli/src/commands/spec/approve.ts:139
- startApproval may return an empty result when settings.statusTransitionPr.draftToApproved is false. This command prints
Branch: ${result.branchName}/PR: ${result.prUrl}and states approval is confirmed when the PR is merged, which will produceundefinedoutput and incorrect messaging in the direct-commit mode. Update the success output to branch on settings.statusTransitionPr.draftToApproved (e.g., print PR info only in PR flow, and print a direct-commit completion message otherwise).
// 6. Start approval
const result = await startApproval(cwd, target, customHandler, settings, {
dryRun: options.dryRun,
});
if (options.dryRun) {
return;
}
console.log(chalk.green(`Approval PR created: ${id}`));
console.log(`Approval will be confirmed when the PR is merged`);
console.log(` Branch: ${result.branchName}`);
console.log(` PR: ${result.prUrl}`);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (const fb of unresolvedFeedbacks) { | ||
| console.log( | ||
| chalk.yellow( | ||
| ` - #${fb.githubIssue} (${fb.type ?? "unclassified"}, severity: ${fb.severity ?? "medium"})`, |
There was a problem hiding this comment.
The warning output defaults severity to "medium" when fb.severity is undefined, but the blocking logic (and the blocked-path output) treats missing severity as "low". This can misreport the actual severity level to users. Use a consistent default (ideally "low") when formatting severity in the warning list, or reuse the same normalization as shouldBlockApproval.
| ` - #${fb.githubIssue} (${fb.type ?? "unclassified"}, severity: ${fb.severity ?? "medium"})`, | |
| ` - #${fb.githubIssue} (${fb.type ?? "unclassified"}, severity: ${fb.severity ?? "low"})`, |
There was a problem hiding this comment.
Fixed in d9dbcfa — same fix as req/approve.ts, changed default to "low".
| } | ||
| } | ||
| throw new AppError( | ||
| "未実装のspecificationがあります", |
There was a problem hiding this comment.
The consistency-check block throws an AppError with a Japanese-only message ("未実装のspecificationがあります") while the rest of this command's user-facing errors are English. This will lead to inconsistent CLI UX. Consider switching to an English message consistent with the other errors here (and ideally include actionable detail, e.g., how many / which specs are not implemented).
| "未実装のspecificationがあります", | |
| `${specWarnings.length} specification(s) are not implemented. See the consistency check errors above for details.`, |
There was a problem hiding this comment.
Fixed in d9dbcfa — changed to English message: "Some specifications are not yet implemented".
| buildBranchName: (t, _s) => | ||
| `${_s.branchNaming.toImplementedPrefix}/${t.id}-implement-v${t.version}`, |
There was a problem hiding this comment.
In buildBranchName, the settings parameter is named _s (conventionally meaning “unused”) but it is actually used. Rename it to settings (or similar) to avoid confusion and improve readability.
| buildBranchName: (t, _s) => | |
| `${_s.branchNaming.toImplementedPrefix}/${t.id}-implement-v${t.version}`, | |
| buildBranchName: (t, settings) => | |
| `${settings.branchNaming.toImplementedPrefix}/${t.id}-implement-v${t.version}`, |
| // 4. Custom files check | ||
| for (const fileName of settings.approvalPrerequisites.customFiles) { | ||
| const content = await specRepo.loadFile(cwd, specId, fileName); | ||
| if (content == null) { | ||
| errors.push(`Required file "${fileName}" does not exist in the specification directory.`); | ||
| } |
There was a problem hiding this comment.
settings.approvalPrerequisites.customFiles entries are used as-is as filenames. Without validation, a setting like "../..." could traverse directories when passed to specRepo.loadFile. Consider validating that each entry is a simple filename (no path separators / "..") before reading, and fail with a clear error if invalid.
There was a problem hiding this comment.
Fixed in d9dbcfa — added validation rejecting filenames containing ".." or starting with "/".
| // 2. Custom files check (req-directory) | ||
| for (const fileName of settings.approvalPrerequisites.customFiles) { | ||
| const content = await reqRepo.loadFile(cwd, reqId, fileName); | ||
| if (content == null) { | ||
| errors.push(`Required file "${fileName}" does not exist in the requirement directory.`); | ||
| } |
There was a problem hiding this comment.
settings.approvalPrerequisites.customFiles entries are used as-is as filenames. Without validation, a setting like "../..." could traverse directories when passed to reqRepo.loadFile. Consider validating that each entry is a simple filename (no path separators / "..") before reading, and fail with a clear error if invalid.
There was a problem hiding this comment.
Fixed in d9dbcfa — same path traversal validation added here.
| // 2. Dry-run mode | ||
| if (options?.dryRun) { | ||
| const prTitle = handler.buildPrTitle(target); | ||
| console.log(`[dry-run] Create branch: ${branchName}`); | ||
| console.log(`[dry-run] Status change: draft → approved`); | ||
| console.log(`[dry-run] Create PR: ${prTitle}`); | ||
| return { branchName, prNumber: 0, prUrl: "" }; | ||
| return settings.statusTransitionPr.draftToApproved | ||
| ? { branchName, prNumber: 0, prUrl: "" } | ||
| : {}; |
There was a problem hiding this comment.
In dry-run mode, the log output always says it will "Create branch" and "Create PR", even when settings.statusTransitionPr.draftToApproved is false (direct-commit flow). This makes dry-run misleading; consider branching the dry-run logs the same way as the real execution (PR flow vs direct commit), and only mentioning PR creation when draftToApproved is enabled.
There was a problem hiding this comment.
Fixed in d9dbcfa — dry-run now branches between PR flow and direct commit flow, only showing branch/PR messages when draftToApproved is enabled.
| for (const fb of unresolvedFeedbacks) { | ||
| console.log( | ||
| chalk.yellow( | ||
| ` - #${fb.githubIssue} (${fb.type ?? "unclassified"}, severity: ${fb.severity ?? "medium"})`, |
There was a problem hiding this comment.
The warning output defaults severity to "medium" when fb.severity is undefined, but the blocking logic (and the blocked-path output) treats missing severity as "low". This can misreport the actual severity level to users. Use a consistent default (ideally "low") when formatting severity in the warning list, or reuse the same normalization as shouldBlockApproval.
| ` - #${fb.githubIssue} (${fb.type ?? "unclassified"}, severity: ${fb.severity ?? "medium"})`, | |
| ` - #${fb.githubIssue} (${fb.type ?? "unclassified"}, severity: ${fb.severity ?? "low"})`, |
There was a problem hiding this comment.
Fixed in d9dbcfa — changed default from "medium" to "low" to match the blocking logic in shouldBlockApproval.
| export async function loadFile( | ||
| cwd: string, | ||
| id: string, | ||
| filename: string, | ||
| ): Promise<string | null> { | ||
| const filePath = fs.joinPath(getRequirementsDir(cwd), id, filename); | ||
|
|
||
| if (!(await fs.exists(filePath))) { | ||
| return null; | ||
| } | ||
|
|
||
| return fs.readText(filePath); |
There was a problem hiding this comment.
loadFile() joins the user-controlled filename directly into the path. This allows path traversal (e.g., "../..."), which could make the CLI read arbitrary files outside the requirement directory when used with approvalPrerequisites.customFiles. Consider validating filename (reject path separators / ".." segments) or normalizing and enforcing that the resolved path stays under the expected base directory.
There was a problem hiding this comment.
Validation is now done at the service layer (checkReqApprovalPrerequisites / checkSpecApprovalPrerequisites) before calling loadFile, rejecting filenames with ".." or leading "/".
- Change Japanese error message to English in req implement command - Fix _s parameter naming to s in req implement callbacks - Add path traversal validation for customFiles in prerequisites - Fix dry-run output when draftToApproved=false in approval service - Make buildBranchName settings parameter required (not optional) - Fix commit message using updated target in status transition service - Fix spec title fallback in draft reversion service (was using id) - Fix test mock: showRequirement should reject for missing requirement - Move loadProjectSettings to top of command handlers for consistency - Fix approve command output for direct commit mode (no PR) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
All review feedback addressed in d9dbcfa: Bugs (fixed)
Design concerns (fixed) Test fix Additional fixes from Copilot review
|
|
@copilot @claude All review feedback addressed in d9dbcfa: Bugs (fixed)
Design concerns (fixed) Test fix Additional fixes from Copilot review
|
|
Claude finished @kicchann's task in 1m 22s —— View job 修正確認レビュータスクリスト
修正確認結果すべてのレビュー指摘事項が ✅ 確認済み(修正OK)
🔍 軽微な観察事項(ブロッカーではない)
async function executeDirectCommit(...) {
await callbacks.updateStatus(cwd); // 新バージョンを返すが捨てている
await gitRepo.add(cwd, target.files);
await gitRepo.commit(cwd, callbacks.buildCommitMessage(target)); // ← 旧 target
...
}現状の 総評全てのレビュー指摘事項(Claude レビュー 6件 + Copilot レビュー 5件)が適切に修正されています。コードの品質・安全性・一貫性が向上しており、マージ準備ができていると判断します。 |
Summary
approvalPrerequisitesでdesign.md/description.mdチェック・カスタムファイルチェックを設定で制御statusTransitionPrでapprove/implement/draft各遷移のPR作成をトグル可能にbranchNamingでPRブランチプレフィックスを変更可能にfeedbackValidationで未解決feedback時の承認ブロック・severity閾値を制御consistencyCheckでspec未実装時のwarning/error切替を制御autoRevert.onContentChangeでalways/major-only/neverを選択可能に新規ファイル
feedback-validation.ts— severity比較に基づく承認ブロック判定status-transition-service.ts— PR/直接コミットの共通ステータス遷移ヘルパー変更パターン
loadProjectSettings()を1回呼び出し、サービス層に引数として渡す統一パターンsettings: ProjectSettingsを追加Test plan
pnpm test)pnpm type-check)🤖 Generated with Claude Code