feat: add smart-merge to enhance command#784
Conversation
Use the same 3-way comparison infrastructure as the upgrade command to intelligently merge files during enhance. Only overwrites files the user hasn't modified, preserves user customizations, and detects conflicts. - Extract shared merge utilities from upgrade.py into cli/utils/merge.py - Add --force flag to bypass smart-merge and use brute-force overwrite - Add --dry-run flag to preview changes without applying them - Auto-fallback to brute-force when no saved metadata exists - Add 15 new tests covering smart-merge, fallback, and edge cases
Summary of ChangesHello @eliasecchig, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable smart-merge capability to the enhance command, significantly improving the user experience when updating projects. The refactoring of shared logic from the upgrade command into a new cli/utils/merge.py module is a great step towards better code organization and reuse. The addition of --force and --dry-run flags provides useful control over the enhancement process. The new tests are comprehensive and cover various scenarios, including success cases, conflicts, and fallback mechanisms. I have one suggestion to improve the readability of a loop, but overall this is a solid contribution.
…te_args Use while/index pattern instead of manual index management for clearer intent
Add tests to verify the most important safety guarantees: - Agent code (app/agent.py, app/tools/*.py) is NEVER modified - Config files (.env, config.yaml) are always preserved (user secrets) - User's custom dependencies are kept when merging pyproject.toml These tests ensure we never lose user code during enhance.
…o smart-merge - Create shared backup utility (backup.py) used by both create and enhance - Move backups from in-project .backup_* dirs to ~/.agent-starter-pack/backups/ - Add backup step to smart-merge path before applying changes - Remove .backup_* from ignore/exclude patterns (no longer needed) - Update docs with new backup location
- Change gitignore pattern from 'backup*' to 'backup*/' so it only matches backup directories, not source files like backup.py - Use fnmatch in backup ignore patterns to correctly match globs like *.egg-info - Apply ruff formatting fixes - Remove unused strip_ansi() calls in tests
These flags don't exist in older ASP versions. When re-executing enhance via uvx with a lower locked version, omit them to avoid crashes. Pass them through when the locked version is the same or newer.
Summary
enhancecommand.backup_*directories to~/.agent-starter-pack/backups/create --in-folderandenhance(smart-merge)cli/utils/merge.pyfor reuse across commandsChanges
Smart-merge (3-way comparison)
enhancecompares current project against old + new templates--dry-runflag previews changes without applying--forceflag bypasses smart-merge for brute-force overwriteExternal backups
agent_starter_pack/cli/utils/backup.pywithcreate_project_backup()~/.agent-starter-pack/backups/<project>_<timestamp>/.git,.venv,node_modules,__pycache__, etc.--in-folder) and enhance (smart-merge) use the same backup utilityOther
starter_pack_*file preservation logic (replaced by smart-merge).backup_*from gitignore patterns and file exclusion listscli/utils/merge.pyHow smart-merge works
pyproject.toml([tool.agent-starter-pack])current_projectvsold_templatevsnew_template:current == old→ user didn't modify → safe to overwrite with newcurrent != oldandold == new→ user modified, template unchanged → preservecurrent != oldandold != new→ both changed → conflict (prompt or auto-keep)~/.agent-starter-pack/backups/before applying changes