|
| 1 | +# Remove Diff Command |
| 2 | + |
| 3 | +## Problem |
| 4 | + |
| 5 | +The `openspec diff` command adds unnecessary complexity to the OpenSpec CLI for several reasons: |
| 6 | + |
| 7 | +1. **Redundant functionality**: The `openspec show` command already provides comprehensive visualization of changes through structured JSON output and markdown rendering |
| 8 | +2. **Maintenance burden**: The diff command requires a separate dependency (jest-diff) and additional code complexity (~227 lines) |
| 9 | +3. **Limited value**: Developers can achieve better diff visualization using existing tools: |
| 10 | + - Git diff for actual file changes |
| 11 | + - The `show` command for structured change viewing |
| 12 | + - Standard diff utilities for comparing spec files directly |
| 13 | +4. **Inconsistent with verb-noun pattern**: The command doesn't follow the preferred verb-first command structure that other commands are migrating to |
| 14 | + |
| 15 | +## Solution |
| 16 | + |
| 17 | +Remove the `openspec diff` command entirely and guide users to more appropriate alternatives: |
| 18 | + |
| 19 | +1. **For viewing change content**: Use `openspec show <change-name>` which provides: |
| 20 | + - Structured JSON output with `--json` flag |
| 21 | + - Markdown rendering for human-readable format |
| 22 | + - Delta-only views with `--deltas-only` flag |
| 23 | + - Full spec content visualization |
| 24 | + |
| 25 | +2. **For comparing files**: Use standard tools: |
| 26 | + - `git diff` for version control comparisons |
| 27 | + - System diff utilities for file-by-file comparisons |
| 28 | + - IDE diff viewers for visual comparisons |
| 29 | + |
| 30 | +## Benefits |
| 31 | + |
| 32 | +- **Reduced complexity**: Removes ~227 lines of code and the jest-diff dependency |
| 33 | +- **Clearer user journey**: Directs users to the canonical `show` command for viewing changes |
| 34 | +- **Lower maintenance**: Fewer commands to maintain and test |
| 35 | +- **Better alignment**: Focuses on the core OpenSpec workflow without redundant features |
| 36 | + |
| 37 | +## Implementation |
| 38 | + |
| 39 | +### Files to Remove |
| 40 | +- `/src/core/diff.ts` - The entire diff command implementation |
| 41 | +- `/openspec/specs/cli-diff/spec.md` - The diff command specification |
| 42 | + |
| 43 | +### Files to Update |
| 44 | +- `/src/cli/index.ts` - Remove diff command registration (lines 8, 84-96) |
| 45 | +- `/package.json` - Remove jest-diff dependency |
| 46 | +- `/README.md` - Remove diff command documentation |
| 47 | +- `/openspec/README.md` - Remove diff command references |
| 48 | +- Various documentation files mentioning `openspec diff` |
| 49 | + |
| 50 | +### Migration Guide for Users |
| 51 | + |
| 52 | +Users currently using `openspec diff` should transition to: |
| 53 | + |
| 54 | +```bash |
| 55 | +# Before |
| 56 | +openspec diff add-feature |
| 57 | + |
| 58 | +# After - view the change proposal |
| 59 | +openspec show add-feature |
| 60 | + |
| 61 | +# After - view only the deltas |
| 62 | +openspec show add-feature --json --deltas-only |
| 63 | + |
| 64 | +# After - use git for file comparisons |
| 65 | +git diff openspec/specs openspec/changes/add-feature/specs |
| 66 | +``` |
| 67 | + |
| 68 | +## Risks |
| 69 | + |
| 70 | +- **User disruption**: Existing users may have workflows depending on the diff command |
| 71 | + - Mitigation: Provide clear migration guide and deprecation period |
| 72 | + |
| 73 | +- **Loss of visual diff**: The colored, unified diff format will no longer be available |
| 74 | + - Mitigation: Users can use git diff or other tools for visual comparisons |
| 75 | + |
| 76 | +## Success Metrics |
| 77 | + |
| 78 | +- Successful removal with no broken dependencies |
| 79 | +- Documentation updated to reflect the change |
| 80 | +- Tests passing without the diff command |
| 81 | +- Reduced package size from removing jest-diff dependency |
0 commit comments