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.
Description
_count_package_files()insrc/apm_cli/commands/deps/_utils.pylooks for.apm/contexts/(plural, line 103):But
_get_detailed_context_counts()in the same file maps the'contexts'key to.apm/context/(singular, line 138):This means:
.apm/context/(singular) will have its files counted by_get_detailed_context_countsbut missed by_count_package_files.apm/contexts/(plural) will have its files counted by_count_package_filesbut missed by_get_detailed_context_countsImpact
_count_package_filesfeeds intoapm deps listtotals, while_get_detailed_context_countsfeeds intoapm viewdetail 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.