Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/apm_cli/compilation/claude_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ def _generate_claude_content(
sections.append(f"## Files matching `{pattern}`")
sections.append("")

for instruction in pattern_instructions:
for instruction in sorted(
pattern_instructions,
key=lambda i: portable_relpath(i.file_path, self.base_dir),
):
content = instruction.content.strip()
if content:
# Add source attribution comment
Expand Down
5 changes: 3 additions & 2 deletions src/apm_cli/compilation/context_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ def _get_all_files(self) -> List[Path]:
self._file_list_cache = []
for root, dirs, files in os.walk(self.base_dir):
# Skip hidden and excluded directories for performance
dirs[:] = [d for d in dirs if not d.startswith('.') and d not in DEFAULT_EXCLUDED_DIRNAMES]
for file in files:
# Sort to guarantee deterministic traversal order across filesystems
dirs[:] = sorted(d for d in dirs if not d.startswith('.') and d not in DEFAULT_EXCLUDED_DIRNAMES)
for file in sorted(files):
if not file.startswith('.'):
self._file_list_cache.append(Path(root) / file)
return self._file_list_cache
Expand Down
5 changes: 4 additions & 1 deletion src/apm_cli/compilation/distributed_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,10 @@ def _generate_agents_content(
sections.append(f"## Files matching `{pattern}`")
sections.append("")

for instruction in pattern_instructions:
for instruction in sorted(
pattern_instructions,
key=lambda i: portable_relpath(i.file_path, self.base_dir),
):
content = instruction.content.strip()
if content:
# Add source attribution for individual instructions
Expand Down
6 changes: 3 additions & 3 deletions src/apm_cli/compilation/template_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def build_conditional_sections(instructions: List[Instruction]) -> str:

sections = []

for pattern, pattern_instructions in pattern_groups.items():
for pattern, pattern_instructions in sorted(pattern_groups.items()):
sections.append(f"## Files matching `{pattern}`")
sections.append("")

# Combine content from all instructions for this pattern
for instruction in pattern_instructions:
for instruction in sorted(pattern_instructions, key=lambda i: portable_relpath(i.file_path, Path.cwd())):
content = instruction.content.strip()
if content:
# Add source file comment before the content
Expand Down
Loading