MCPcopy Create free account
hub / github.com/Lap-Platform/LAP / cmd_diff

Function cmd_diff

lap/cli/main.py:1609–1664  ·  view source on GitHub ↗

Diff two LAP files or compare installed skill vs registry latest.

(args)

Source from the content-addressed store, hash-verified

1607
1608
1609def cmd_diff(args):
1610 """Diff two LAP files or compare installed skill vs registry latest."""
1611 from lap.core.parser import parse_lap
1612 from lap.core.differ import diff_specs, generate_changelog, check_compatibility
1613
1614 # Smart overload: single arg that doesn't look like a file path = skill name
1615 if args.new is None:
1616 name = args.old
1617 if name.endswith('.lap') or '/' in name or '\\' in name:
1618 error("Need two files to diff. Usage: lapsh diff old.lap new.lap")
1619 _diff_skill(name, args)
1620 return
1621
1622 # Existing two-file diff behavior
1623 old_path, new_path = Path(args.old), Path(args.new)
1624 if not old_path.exists():
1625 error(f"File not found: {args.old}")
1626 if not new_path.exists():
1627 error(f"File not found: {args.new}")
1628
1629 old_spec = parse_lap(old_path.read_text(encoding='utf-8'))
1630 new_spec = parse_lap(new_path.read_text(encoding='utf-8'))
1631
1632 if args.format == "changelog":
1633 print(generate_changelog(old_spec, new_spec, version=args.version or "0.0.0"))
1634 return
1635
1636 diff = diff_specs(old_spec, new_spec)
1637 compat = check_compatibility(old_spec, new_spec)
1638
1639 if HAS_RICH:
1640 status = "[bold red]BREAKING[/]" if compat.severity == "MAJOR" else "[bold green]COMPATIBLE[/]"
1641 console.print(f"\nSemver: [bold]{compat.severity}[/] -- {status}\n")
1642
1643 if diff.breaking_changes:
1644 console.print("[bold red]Breaking Changes:[/]")
1645 for c in diff.breaking_changes:
1646 console.print(f" [red]x[/] {c.detail}")
1647 console.print()
1648
1649 if diff.non_breaking_changes:
1650 console.print("[bold green]Non-breaking Changes:[/]")
1651 for c in diff.non_breaking_changes:
1652 console.print(f" [green]o[/] {c.detail}")
1653 console.print()
1654
1655 if not diff.changes:
1656 console.print("[dim]No changes detected.[/]")
1657 else:
1658 print(f"\nSemver: {compat.severity}")
1659 for c in diff.breaking_changes:
1660 print(f" BREAKING: {c.detail}")
1661 for c in diff.non_breaking_changes:
1662 print(f" {c.detail}")
1663 if not diff.changes:
1664 print("No changes detected.")
1665
1666

Calls 6

parse_lapFunction · 0.90
generate_changelogFunction · 0.90
diff_specsFunction · 0.90
check_compatibilityFunction · 0.90
_diff_skillFunction · 0.85
errorFunction · 0.70