Skip to content

Refactor prompt integration and add agent integration#31

Merged
danielmeppiel merged 3 commits intomainfrom
agents-support
Nov 17, 2025
Merged

Refactor prompt integration and add agent integration#31
danielmeppiel merged 3 commits intomainfrom
agents-support

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

@danielmeppiel danielmeppiel commented Nov 17, 2025

This pull request introduces full support for the new .agent.md format (replacing .chatmode.md) for defining AI agent personas and workflows, along with automatic integration of these agent files into the VSCode-compatible .github/agents/ directory. The documentation has been updated throughout to clarify the new agent format, legacy support, and the integration process. Additionally, several important bug fixes were made to the integration and uninstall logic to prevent accidental removal of unrelated files.

Agent Format and Integration Updates:

  • Added automatic sync of .agent.md files to .github/agents/ with -apm suffix, matching the prompt integration pattern.
  • Updated all documentation (README.md, docs/getting-started.md, docs/integrations.md, docs/primitives.md) to reflect .agent.md as the new standard, with clear notes about legacy .chatmode.md support and migration paths. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]

Bug Fixes:

  • Fixed a sync_integration URL normalization bug that caused uninstalling one package to remove prompts/agents from all packages instead of just the uninstalled one. The fix ensures both metadata and dependency lists use normalized owner/repo format for comparison. Comprehensive test coverage for multi-package scenarios was added.
  • Uninstall command now correctly removes only the relevant apm_modules/owner/repo/ directory, not the parent apm_modules/owner/.

CLI and Integration Enhancements:

  • Updated CLI logic to support agent integration: imports AgentIntegrator, tracks agent integration counts, and updates install summary reporting. [1] [2] [3]
  • Improved install and uninstall flows to handle cases where packages are already present in apm.yml and to provide clearer user feedback. [1] [2]

Changelog:

  • Added a new section for version 0.5.4 summarizing these changes.

Copilot AI review requested due to automatic review settings November 17, 2025 11:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds full .agent.md agent integration support (replacing .chatmode.md) with automatic sync to .github/agents/, and fixes a critical bug in sync_integration that would remove ALL integrated files when uninstalling a single package.

Key Changes

  • Agent Integration: New AgentIntegrator class mirrors PromptIntegrator, supporting both .agent.md (new) and .chatmode.md (legacy) formats with -apm suffix naming
  • Critical Bug Fix: URL normalization in sync_integration now correctly matches metadata URLs (https://github.com/owner/repo) with dependency short forms (owner/repo) to prevent accidental bulk deletion
  • Uninstall Fix: Correctly removes apm_modules/owner/repo/ instead of apm_modules/owner/

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/apm_cli/integration/agent_integrator.py New agent integrator with frontmatter metadata, hash-based modification detection, and sync cleanup
src/apm_cli/integration/prompt_integrator.py Refactored to use YAML frontmatter instead of HTML comments, added content hash tracking
src/apm_cli/cli.py Integrated agent sync in install/uninstall commands, fixed package path calculation, added agent count tracking
src/apm_cli/primitives/discovery.py Added .agent.md patterns to discovery alongside .chatmode.md legacy support
tests/unit/integration/test_agent_integrator.py Comprehensive test suite for agent integration (813 lines)
tests/unit/integration/test_sync_integration_url_normalization.py Tests for URL normalization bug fix with multi-package scenarios
tests/unit/integration/test_prompt_integrator.py Updated for frontmatter format
docs/primitives.md Updated to document .agent.md as primary format with legacy .chatmode.md support
docs/integrations.md Added agent integration documentation
.gitignore Removed apm_modules/ entry (likely unintentional)

Comment thread src/apm_cli/integration/agent_integrator.py
Comment thread src/apm_cli/integration/prompt_integrator.py
Comment thread src/apm_cli/integration/agent_integrator.py
Comment thread src/apm_cli/integration/agent_integrator.py Outdated
Comment thread tests/unit/integration/test_agent_integrator.py Outdated
Comment thread tests/unit/integration/test_agent_integrator.py Outdated
Comment thread tests/unit/integration/test_agent_integrator.py Outdated
Comment thread tests/unit/integration/test_sync_integration_url_normalization.py Outdated
- Add missing ContentHash field to metadata extraction in both integrators
- Extract URL normalization logic to shared utility function
- Remove unused imports (shutil, pytest, os, patch)
- Add comprehensive tests for normalize_repo_url utility

All 393 tests passing (377 + 16 new utility tests)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/apm_cli/integration/utils.py
import frontmatter

from .utils import normalize_repo_url
import hashlib
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate import of hashlib module. Line 6 already imports hashlib, so line 11 is redundant and should be removed.

Suggested change
import hashlib

Copilot uses AI. Check for mistakes.
- Remove trailing slashes before processing .git suffix
- Ensures consistent URL matching regardless of trailing slash
- Add 2 additional tests for trailing slash edge cases
- All 395 tests passing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants