feat: CLI update command (PR-I2 of 2-PR sequence)#290
Conversation
Implements the `update` subcommand that refreshes shipped artifacts (skill, agent, MCP entry) after pip upgrade. Features: - Host detection: scans project + user config files for java-codebase-rag MCP entries - Artifact refresh: overwrites skill/agent files from package data, updates MCP command path - Index update: runs incremental LanceDB update if index exists - Dry-run mode: previews changes without writing files Changes: - Add `detect_configured_hosts()` function to scan for configured hosts - Add `refresh_artifacts()` function to refresh skill, agent, and MCP files - Add `run_update()` orchestrator for the update pipeline - Add `update` subcommand to CLI with --force and --dry-run flags - Add 12 new tests for update functionality Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add MCP server name constant (_MCP_SERVER_NAME) to replace hardcoded strings - Add exit code constants (EXIT_SUCCESS, EXIT_PARTIAL, EXIT_FATAL) - Remove duplicate _INCREMENT_WARNING_LINES, import from cli.py instead These changes address code quality issues identified during review: - Eliminate stringly-typed code with constants - Reduce duplication by sharing constants across modules - Improve maintainability with named exit codes Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Review: PR-I2Tests pass (65/65), ruff is clean, and the scope matches the plan. A few issues to address: Critical
Fix: catch ImportantDuplication between The JSON read / compare / atomic-write logic is nearly identical. The only real differences are the
If some artifacts failed to refresh (warnings printed at lines 1137-1141), but the function then hits an early return at line 1155, 1164, or 1172, it returns 0 despite partial failures. The exit code should reflect partial failure (1) when any artifact failed. Minor
VerdictFix the |
Critical: - Fix SystemExit leak in _refresh_mcp_config: catch SystemExit from resolve_mcp_command and return ArtifactResult instead of crashing - Add outer SystemExit handler for robustness Important: - Fix run_update partial failure handling: return exit code 1 when any artifact refresh fails, instead of returning 0 - Track has_artifact_failures and use it in all early returns New Test: - Add test_update_missing_mcp_binary_returns_partial_failure to verify MCP binary missing case Also: - Use EXIT_* constants consistently instead of raw 0/1/2 literals Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Implements the
updatesubcommand that refreshes shipped artifacts (skill, agent, MCP entry) after pip upgrade.Features
Changes
detect_configured_hosts()function to scan for configured hostsrefresh_artifacts()function to refresh skill, agent, and MCP filesrun_update()orchestrator for the update pipelineupdatesubcommand to CLI with--forceand--dry-runflagsTest plan
ruff check .is cleanupdate --helpprints usageupdateafterinstallcompletes with exit 0update --dry-runreports what would change without writingupdatewith no configured hosts exits with code 2Part of
This implements PR-I2 from
plans/active/PLAN-CLI-INSTALL.md.🤖 Generated with Claude Code