feat(cli): skillforge diff <a> <b> — structural SKILL.md comparison - #15
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces ChangesDiff Feature Implementation
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant diffSkills
participant FileOps
participant FrontmatterValidator
participant DiffEngine
User->>CLI: skillforge diff <a> <b>
CLI->>diffSkills: diffSkills(pathA, pathB)
diffSkills->>FileOps: read both files concurrently
FileOps-->>diffSkills: file contents
diffSkills->>FrontmatterValidator: parse and validate YAML frontmatter
FrontmatterValidator-->>diffSkills: validated frontmatter or error
diffSkills->>DiffEngine: compute frontmatter diff (added/removed/changed)
diffSkills->>DiffEngine: extract and diff headings (added/removed/reordered)
diffSkills->>DiffEngine: compute body line deltas (normalized)
DiffEngine-->>diffSkills: DiffResult with all computed deltas
diffSkills-->>CLI: DiffResult
alt Identical
CLI->>User: exit 0
else Differ
CLI->>User: print report + exit 1
else Error
CLI->>User: error message + exit 2
end
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
`skillforge diff ` — structural comparison of two SKILL.md files. Ninth piece of the authoring workflow after `init`, `validate`, `lint`, `pack`, `install`, `update`, `format`, and `inspect`. A plain `diff` on a SKILL.md is noisy: a reordered heading, a one-word frontmatter change, and a re-wrapped paragraph all look like sprawling churn. `diff` pulls the structural signal out.
```sh
Human-readable mode
skillforge diff ./code-review-v1/SKILL.md ./code-review-v2/SKILL.md
diff …v1/SKILL.md → …v2/SKILL.md
frontmatter: 1 headings: 2 body lines: +6 -3
FRONTMATTER
~ version: 0.1.0 → 0.2.0
HEADINGS
+ Examples
~ When to use it (position 1 → 2)
BODY
+6 -3 lines (coarse)
Machine-readable mode for CI
skillforge diff ./v1/SKILL.md ./v2/SKILL.md --json
```
Why
When skill authors maintain multiple versions of a skill — or review a contributor's update — they need a structured diff: what frontmatter fields changed, what sections were added/removed, what content moved. A plain `diff` makes a one-line description tweak look like a whole-paragraph rewrite. `skillforge diff` produces the tidy structural view.
Result shape
```ts
interface DiffResult {
pathA: string;
pathB: string;
frontmatter: {
added: Record<string, unknown>;
removed: Record<string, unknown>;
changed: Array<{ key: string; before: unknown; after: unknown }>;
};
bodyHeadings: {
added: string[];
removed: string[];
reordered: Array<{ heading: string; from: number; to: number }>;
};
bodyLinesDelta: { added: number; removed: number };
identical: boolean;
}
```
Semantics
CLI output taste
Exit codes
Matches `mcp-devtools diff` convention — CI scripts can distinguish "noisy" from "broken".
Surface
Gates
On `diff` vs `format` / `inspect`
`format` fixes envelope drift. `inspect` reads a single skill. `diff` compares two skills. The three compose: format both files, inspect each, then diff. Each does one thing.
Don't refactor
No changes to `format` / `lint` / `inspect`. No new runtime deps. Uses `gray-matter` (already a dep).
Declaration of AI-Tools / LLMs usage
Summary by CodeRabbit
New Features
skillforge diff <a> <b>command to structurally compare two SKILL.md files, detecting frontmatter field changes, heading additions/removals/reordering, and body content deltas. Supports--jsonoutput and returns distinct exit codes.Documentation
Tests