From 92428b198fa4cdb51e2f20809f7026b7c7034c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A8=B1=E5=85=83=E8=B1=AA?= <146086744+edenfunf@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:03:35 +0800 Subject: [PATCH] fix(deps): use .apm/context/ (singular) in _count_package_files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _count_package_files() scanned .apm/contexts/ (plural), which does not exist. The canonical directory is .apm/context/ (singular), consistent with _get_detailed_context_counts() in the same file and the discovery pattern in primitives/discovery.py. Result: apm deps list always reported 0 context files even for packages with many .context.md files in .apm/context/. apm view showed the correct count via _get_detailed_context_counts, making the two commands disagree. Verified: pytest tests/unit/ — 3907 passed on Python 3.13, Windows 11 Fixes #704 --- src/apm_cli/commands/deps/_utils.py | 2 +- tests/unit/test_deps_utils.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/apm_cli/commands/deps/_utils.py b/src/apm_cli/commands/deps/_utils.py index 01c70127..403c832e 100644 --- a/src/apm_cli/commands/deps/_utils.py +++ b/src/apm_cli/commands/deps/_utils.py @@ -100,7 +100,7 @@ def _count_package_files(package_path: Path) -> tuple[int, int]: return 0, workflow_count context_count = 0 - context_dirs = ['instructions', 'chatmodes', 'contexts'] + context_dirs = ['instructions', 'chatmodes', 'context'] for context_dir in context_dirs: context_path = apm_dir / context_dir diff --git a/tests/unit/test_deps_utils.py b/tests/unit/test_deps_utils.py index eb3bc2ae..0e161f2e 100644 --- a/tests/unit/test_deps_utils.py +++ b/tests/unit/test_deps_utils.py @@ -3,9 +3,7 @@ Covers the pure helpers that scan, count, and describe installed packages. """ -import tempfile from pathlib import Path -from unittest.mock import patch import pytest @@ -233,10 +231,10 @@ def test_chatmodes_counted_as_context(self, tmp_path): assert ctx == 1 def test_contexts_dir_counted(self, tmp_path): - """Files in .apm/contexts/ are counted as context.""" + """Files in .apm/context/ (singular) are counted as context.""" apm = _make_apm_dir(tmp_path) - (apm / "contexts").mkdir() - (apm / "contexts" / "c.md").write_text("# c") + (apm / "context").mkdir() + (apm / "context" / "c.md").write_text("# c") ctx, _ = _count_package_files(tmp_path) assert ctx == 1