Skip to content

[BUG] _count_package_files and _get_detailed_context_counts disagree on contexts directory name #704

@sergio-sisternes-epam

Description

@sergio-sisternes-epam

Description

_count_package_files() in src/apm_cli/commands/deps/_utils.py looks for .apm/contexts/ (plural, line 103):

context_dirs = ['instructions', 'chatmodes', 'contexts']

But _get_detailed_context_counts() in the same file maps the 'contexts' key to .apm/context/ (singular, line 138):

context_directories = {
    'instructions': 'instructions',
    'chatmodes': 'chatmodes',
    'contexts': 'context'  # Note: directory is 'context', not 'contexts'
}

This means:

  • A package with .apm/context/ (singular) will have its files counted by _get_detailed_context_counts but missed by _count_package_files
  • A package with .apm/contexts/ (plural) will have its files counted by _count_package_files but missed by _get_detailed_context_counts

Impact

_count_package_files feeds into apm deps list totals, while _get_detailed_context_counts feeds into apm view detail breakdown. The two commands could show inconsistent numbers for the same package.

Discovered in

PR #682 -- the new tests correctly test each function's actual behavior, which made this inconsistency visible.

Suggested fix

Align both functions on the same directory name. Check which name is canonical (likely context/ singular based on the comment in _get_detailed_context_counts), and update the other function to match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedDirection approved, safe to start workbugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions