Skip to content

feat: v2.4.4 Phase 1 — add --apply-plan for merge-plan.json dry-run#14

Merged
aliksir merged 1 commit into
masterfrom
feature/v2.4.4-phase1-apply-plan
May 24, 2026
Merged

feat: v2.4.4 Phase 1 — add --apply-plan for merge-plan.json dry-run#14
aliksir merged 1 commit into
masterfrom
feature/v2.4.4-phase1-apply-plan

Conversation

@aliksir

@aliksir aliksir commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

v2.4.4 Phase 1 として --apply-plan <path> フラグを追加。--merge-twice --execute が生成した merge-plan.json を読み取り、各 candidate の action ('merge' / 'skip' / 'ignore') を集計して dry-run サマリを出力する。ファイル変更は一切しない

なぜ段階導入か

  • Phase 1 (本 PR): スキーマバリデーション + dry-run サマリのみ
  • Phase 2 (v2.4.5+): 実マージロジック(file append / delete / git commit)

Phase 1 で JSON スキーマとバリデーションを確定させることで、Phase 2 で実マージロジックを安全に積み上げる。破壊操作 CLI の段階導入パターン(第210回 dev-lessons 教訓 `[cli-design][destructive-ops][lesson-skill-loop]`)に従う。

変更内容

  • `skill-loop.js`: +doApplyPlan / +validatePlanSchema / +--apply-plan parser
  • `README.md` / `README.ja.md`: +v2.4.4 Phase 1 セクション(使用例 + バリデーション規則)
  • `test/skill-loop.test.mjs`:
    • +9 件の新規テスト (T16-T24)
    • +Nit-1 対応: T14 内に `stdoutJson.candidates.length === plan.totalCandidates` assert 追加
    • +Nit-2 対応: `--json --execute --jaccard-min 0.99` 3 フラグ組合せテスト追加
  • `test/fixtures/`: 新規 3 ファイル (`sample-plan-{all-merge,mixed,tbd-residual}.json`)
  • `package.json`: version 2.4.3 → 2.4.4

バリデーション規則

ケース 期待挙動
`action: 'TBD'` 残存 exit 1(手動レビュー強制)
必須フィールド欠落 exit 1
不正 JSON exit 1
ファイル不在 exit 1
不正 action 値 (e.g. 'delete') exit 1

Test Plan

  • 自動テスト 107/107 PASS(既存 95 + 新規 12)
  • 手動確認: `--apply-plan sample-plan-mixed.json` → merge:1 / skip:1 / ignore:1 サマリ正常
  • 手動確認: `--apply-plan --json sample-plan-mixed.json` → 構造化 JSON 出力(mode='apply-plan' / dryRun=true)
  • 手動確認: TBD 残存 fixture → exit 1
  • C3 [critical]: `--apply-plan` 実行で fixture mtime 不変 → 実マージ未実施保証

Refs

🤖 Generated with Claude Code

Add `--apply-plan <path>` CLI flag that reads a merge-plan.json
(generated by --merge-twice --execute) and outputs a dry-run summary
of merge/skip/ignore counts without modifying any files.

Why phased:
- Phase 1: schema validation + dry-run summary only (this PR)
- Phase 2 (v2.4.5+): actual merge logic with file append/delete/commit

This locks the JSON schema and validation so Phase 2 can build safely
on top without re-architecting validation/parsing.

Changes:
- skill-loop.js: +doApplyPlan / +validatePlanSchema / +--apply-plan parser
- README.md / README.ja.md: +v2.4.4 Phase 1 section with usage examples
- test/skill-loop.test.mjs: +9 tests for --apply-plan, +Nit-1 (T14 length
  assert), +Nit-2 (--json --execute --jaccard-min 3-flag combo)
- test/fixtures/: +3 sample-plan-*.json fixtures
- package.json: version 2.4.3 -> 2.4.4

Validation rejects 'TBD' as action (forces manual review). exit 1 on
missing fields, invalid JSON, or file not found.

Tests: 107/107 PASS (existing 95 + new 12)
Refs: feature/v2.4.4-phase1-apply-plan

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aliksir aliksir marked this pull request as ready for review May 24, 2026 09:28
@aliksir aliksir merged commit 4db1fc2 into master May 24, 2026
1 check passed
@aliksir aliksir deleted the feature/v2.4.4-phase1-apply-plan branch May 24, 2026 09:28
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