microsoft / microsoft/amplifier

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

Open
#195 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.1k
Forks
261
Avg merge
3h 28m
Merged PRs (30d)
13

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with amplifier_app_cli/utils/update_executor.py and amplifier_app_cli/commands/reset.py, then inspect the InstallStateManager API from dependency #194. Run the existing test suite and verify that update invalidates stale modules and reset --remove cache clears install state without direct install-state.json manipulation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.