Skip to content

feat: Auto-Yesにターミナル出力のStop条件(正規表現)を追加#315

Merged
Kewton merged 3 commits intodevelopfrom
feature/314-worktree
Feb 19, 2026
Merged

feat: Auto-Yesにターミナル出力のStop条件(正規表現)を追加#315
Kewton merged 3 commits intodevelopfrom
feature/314-worktree

Conversation

@Kewton
Copy link
Owner

@Kewton Kewton commented Feb 19, 2026

Summary

  • Auto-Yesモードにターミナル出力ベースのStop条件(正規表現)機能を追加
  • ユーザーが指定した正規表現パターンにターミナル出力がマッチした場合、Auto-Yesを自動停止
  • rm -rfDROP TABLEforce push などの危険な操作への自動応答を防止

主な変更点

設定層

  • auto-yes-config.ts: MAX_STOP_PATTERN_LENGTH=500validateStopPattern() 共通バリデーション、AutoYesStopReason 型(クライアント/サーバー共用)

ビジネスロジック層

  • auto-yes-manager.ts: AutoYesStatestopPattern/stopReason フィールド追加、disableAutoYes() 専用関数、checkStopCondition() 独立関数、executeRegexWithTimeout() タイムアウト保護

セキュリティ

  • safe-regex2 ライブラリによるReDoSパターン(カタストロフィックバックトラッキング)検出・拒否
  • executeRegexWithTimeout() による同期タイムアウト保護
  • validateStopPattern() のエラーメッセージは固定文字列のみ(XSS防止)
  • current-output/route.tsisValidWorktreeId() チェック追加

API

  • auto-yes/route.ts POST: stopPattern バリデーション・受け渡し
  • current-output/route.ts GET: stopReason フィールド返却

UI

  • AutoYesConfirmDialog: Stop条件入力フィールド(リアルタイムバリデーション)
  • AutoYesToggle: AutoYesToggleParams オブジェクト引数パターン(ISP/OCP準拠)
  • WorktreeDetailRefactored: Stop条件マッチ時のトースト通知(重複防止)

i18n

  • locales/ja/autoYes.json / locales/en/autoYes.json: 6翻訳キー追加

テスト結果

変更ファイル数

  • ソースコード: 10ファイル(+826/-52行)
  • テスト: 4ファイル(+461行)
  • dev-reports: 55ファイル(レビュー・設計・進捗レポート)
  • ドキュメント: 2ファイル(CLAUDE.md, implementation-history.md)

レビュープロセス

  • マルチステージIssueレビュー: 8ステージ完了(42件指摘対応済み)
  • マルチステージ設計レビュー: 4ステージ完了(47件指摘対応済み)
  • 設計方針書: dev-reports/design/issue-314-auto-yes-stop-condition-design-policy.md

Test plan

  • npx vitest run tests/unit/config/auto-yes-config.test.ts tests/unit/lib/auto-yes-manager.test.ts で115テストパス確認
  • npx tsc --noEmit で型エラー0件確認
  • npm run lint でESLintエラー0件確認
  • Auto-Yes確認ダイアログにStop条件入力フィールドが表示される
  • 不正な正規表現入力時にバリデーションエラーが表示される
  • ReDoSパターン (a+)+$ がバリデーションで拒否される

Closes #314

🤖 Generated with Claude Code

Kewton and others added 3 commits February 19, 2026 21:14
Add terminal output-based stop condition using regex patterns. When
the terminal output matches the user-specified pattern, Auto-Yes is
automatically disabled with a toast notification.

Implementation:
- Add safe-regex2 dependency for ReDoS prevention
- Add validateStopPattern() with length, safe-regex2, and syntax checks
- Add disableAutoYes() centralized disable function with reason tracking
- Add checkStopCondition() and executeRegexWithTimeout() for pattern matching
- Insert checkStopCondition() into pollAutoYes() pipeline
- Add stopPattern to auto-yes/route.ts POST with server-side validation
- Add stopReason to current-output/route.ts response
- Add worktreeId validation to current-output/route.ts GET handler
- Add stop pattern input UI to AutoYesConfirmDialog with real-time validation
- Update AutoYesToggle with AutoYesToggleParams object parameter pattern
- Update WorktreeDetailRefactored with stopReason toast notification
- Add i18n translations (ja/en) for 6 new keys
- Add 40+ new test cases across config, manager, and component tests

Security: safe-regex2 ReDoS prevention, fixed error messages (XSS),
structured logging, isValidWorktreeId() on current-output route

Resolves #314

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…used default exports

Move AutoYesStopReason type from auto-yes-manager.ts (server-only) to
auto-yes-config.ts (shared) for DRY compliance. This eliminates the inline
literal union duplication in WorktreeDetailRefactored.tsx and ensures
type consistency across server and client components.

Remove unused default exports from AutoYesConfirmDialog.tsx and
AutoYesToggle.tsx since only named exports are consumed.

Improvements:
- DRY: AutoYesStopReason defined once in shared config, re-exported for backward compat
- Unused code removal: default exports that were never imported
- Type safety: client-side CurrentOutputResponse.stopReason now uses shared type

Quality Metrics:
- ESLint errors: 0 -> 0
- TypeScript errors: 0 -> 0
- Tests: 115/115 passed -> 115/115 passed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added auto-yes-config.ts module documentation (MAX_STOP_PATTERN_LENGTH,
  validateStopPattern, AutoYesStopReason)
- Updated auto-yes-manager.ts documentation with Issue #314 new functions
  (disableAutoYes, checkStopCondition, executeRegexWithTimeout)
- Added Issue #314 entry to implementation-history.md
- Added design policy, multi-stage review reports, and pm-auto-dev reports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Kewton Kewton merged commit da0523b into develop Feb 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant