Skip to content

[app-cli] Use InstallStateManager API instead of direct JSON manipulation #195

@colombod

Description

@colombod

Parent Issue

Part of #193 - Consolidate install-state.json manipulation with InstallStateManager

Depends on: #194 (foundation API must be merged first)

Summary

Update amplifier-app-cli to use the new InstallStateManager API from amplifier-foundation instead of directly manipulating install-state.json.

Scope: amplifier-app-cli

Files to Update

  1. amplifier_app_cli/utils/update_executor.py

    • Replace _invalidate_modules_with_missing_deps() function
    • Use InstallStateManager.invalidate_modules_with_missing_deps() instead
  2. amplifier_app_cli/commands/reset.py

    • Replace direct JSON file deletion/manipulation
    • Use InstallStateManager.clear() instead

Files That Can Be Simplified

  1. amplifier_app_cli/paths.py
    • get_install_state_path() may no longer be needed if all access goes through InstallStateManager
    • Or keep it but only for constructing the InstallStateManager instance

Changes Required

update_executor.py

Replace:

def _invalidate_modules_with_missing_deps() -> tuple[int, int]:
    # ~60 lines of direct JSON manipulation
    ...

With:

def _invalidate_modules_with_missing_deps() -> tuple[int, int]:
    from amplifier_foundation.modules.install_state import InstallStateManager
    cache_dir = get_cache_dir()  # or however you get the cache path
    mgr = InstallStateManager(cache_dir)
    return mgr.invalidate_modules_with_missing_deps()

reset.py

Replace direct file operations with:

from amplifier_foundation.modules.install_state import InstallStateManager
mgr = InstallStateManager(cache_dir)
mgr.clear()
mgr.save()

Acceptance Criteria

  • update_executor.py uses InstallStateManager.invalidate_modules_with_missing_deps()
  • reset.py uses InstallStateManager.clear()
  • No direct JSON manipulation of install-state.json remains
  • All existing tests pass
  • amplifier update still correctly invalidates stale modules
  • amplifier reset --remove cache still correctly clears install state

Benefits

  • Single source of truth for install state logic
  • Consistent behavior between proactive healing and explicit invalidation
  • Easier to maintain and evolve the install state format

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions