Skip to content

richfrem/agent-plugins-skills / plugins/agent-extension-authoring/.apm/skills/packaging-with-apm

packaging-with-apm

Flagged

Packages, installs and distributes agent extensions with APM (Agent Package Manager). Use when the user wants to create a new APM package, convert or migrate an existing plugin to APM and check it installs cleanly, compile a package into AGENTS.md, CLAUDE.md or GEMINI.md, install, update, pin or roll back packages globally or per project, or create a plugin marketplace catalog (marketplace.json). Not for authoring a single skill, plugin, sub-agent or rule (use the authoring-* skills).

FileKindSize
SKILL.mdskill md5.3 KB
evals/evals.jsonconfig2.7 KB
examples/marketplace.jsonconfig45 B
references/acceptance-criteria.mdmarkdown4.6 KB
references/agent-package-manager-overview.mdmarkdown28.7 KB
references/apm-alignment-fixes.mdmarkdown5.3 KB
references/diagrams/packaging-with-apm-flow.mmdother590 B
references/fallback-tree.mdmarkdown1.8 KB
references/legacy-plugin-conversion-guide.mdmarkdown15.4 KB
references/marketplace-architecture.mdmarkdown1.5 KB
references/marketplace-schema.mdmarkdown2.5 KB
references/marketplace.mdmarkdown11.5 KB
references/modes/compile-apm-package.mdmarkdown1.7 KB
references/modes/convert-plugin-to-apm.mdmarkdown7.3 KB
references/modes/create-apm-package.mdmarkdown1.7 KB
references/modes/install-apm-package.mdmarkdown4.3 KB
references/modes/manage-marketplace.mdmarkdown2.1 KB
requirements-dev.inother657 B
requirements-dev.txtmarkdown3.3 KB
requirements.inother148 B
requirements.txtmanifest171 B
scripts/apm_build_pipeline.pyscript35.1 KB
scripts/apm_consumer.pyscript11.3 KB
scripts/apply_symlink_repairs.pyscript1.7 KB
scripts/apply_symlink_repairs.shscript40 B
scripts/audit_marketplace_sources.pyscript2.5 KB
scripts/check_for_broken_symlinks.pyexecutablescript6.6 KB
scripts/convert_symlinks_to_manifest.pyscript6.7 KB
scripts/decouple_agent_paths.pyscript9.1 KB
scripts/fix_inside_plugin_symlinks.pyscript11.3 KB
scripts/materialize_copies.pyscript5.3 KB
scripts/migrate_to_apm.pyscript16.4 KB
scripts/scaffold_apm.pyscript8.6 KB
scripts/validate_apm_package.pyscript5.7 KB
tests/test_apm_build_pipeline.pyscript10.2 KB
tests/test_apm_consumer.pyscript4.8 KB
tests/test_audit_decoupled_state.pyscript8.6 KB
tests/test_convert_symlinks_to_manifest.pyscript5.3 KB
tests/test_decouple_agent_paths.pyscript4.8 KB
tests/test_scaffold_apm.pyscript1.7 KB

tests/test_audit_decoupled_state.py

View on GitHub
#!/usr/bin/env python3
"""
test_audit_decoupled_state.py
=============================

Regression test suite ensuring that the repository has been fully decoupled from
hardcoded `.agents/` install assumptions and legacy installer plumbing:
1. No active scripts or markdown files invoke skills via `python* .agents/skills/...`.
2. No remaining references point to deleted legacy plumbing (`plugins/plugin-manager`, `bootstrap.py`).
3. No legacy `uvx plugin-add` commands remain in active documentation.
4. Copy-manifest (`symlinks.json`) entries are healthy with 0 drift.
5. All 8 plugin roots are valid without symlinks.
"""

import json
import re
import subprocess
import unittest
from pathlib import Path

def find_repo_root(path: Path) -> Path:
    for p in [path] + list(path.parents):
        if (p / ".git").exists() or (p / "pyproject.toml").exists():
            return p
    return path.parents[5]


REPO_ROOT = find_repo_root(Path(__file__).resolve())


class TestNoStaleAgentReferences(unittest.TestCase):
    """Enforces that no stale operational `.agents/` references remain in the repository."""

    # Files that are explicitly permitted to reference APM / client internals:
    ALLOWED_HOST_SPEC_FILES = {
        "antigravity-directory-spec.md",
        "agent-package-manager-overview.md",
        "install-apm-package-acceptance-criteria.md",
        "optimize-context-deduplication-topology.md",
        "deduplication-topology.md",
        "symlink_manager.py",
        "optimize_context.py",
        "decouple_agent_paths.py",
        "test_decouple_agent_paths.py",
        "test_audit_decoupled_state.py",
        "INSTALL.md",
        "AGENTS.md",
        "architecture.md",
        "apm_migration_plan.md",
        "apm_phase2_decouple_worklist.md",
        "fix-plugin-paths.prompt.md",
    }

    # Historical ledgers where past incidents or commit history are permanently recorded:
    HISTORICAL_LEDGERS = {
        "map-debt.md",
        "evolution-log.md",
        "CHANGELOG.md",
        "backlog.md",
        "001_cross_plugin_script_dependencies.md",
        "002_multi_skill_script_centralization.md",
        "003_plugin_skill_resource_sharing_via_mirrored_folder_structure_and_file_level_symlinks.md",
        "004_self_contained_plugins_no_cross_plugin_dependencies.md",
        "006_python_native_plugin_bootstrap_installer.md",
        "010_apm_package_management_and_copy_manifest_architecture.md",
    }

    def test_no_hardcoded_python_execution_in_agents(self) -> None:
        """Assert no markdown or script runs `python .agents/skills/...` directly."""
        pattern = re.compile(r"python[3]?\s+(\.\./)*\.agents/skills/")
        violations = []

        for p in REPO_ROOT.rglob("*"):
            if not p.is_file():
                continue
            if any(part in p.parts for part in (".git", ".pytest_cache", "build", "temp", "node_modules", "tests", "archive", "work-tasks", "issue-payloads")):
                continue
            if p.name in self.HISTORICAL_LEDGERS or p.name in self.ALLOWED_HOST_SPEC_FILES:
                continue
            if p.suffix in (".md", ".py", ".sh", ".json"):
                try:
                    text = p.read_text(encoding="utf-8", errors="ignore")
                    for idx, line in enumerate(text.splitlines(), 1):
                        if pattern.search(line):
                            violations.append(f"{p.relative_to(REPO_ROOT)}:{idx}: {line.strip()}")
                except Exception:
                    pass

        self.assertEqual(
            violations,
            [],
            f"Found hardcoded operational executions of .agents/skills:\n" + "\n".join(violations),
        )

    def test_no_references_to_deleted_plugin_manager(self) -> None:
        """Assert no active code or documentation points to the deleted `plugins/plugin-manager`."""
        pattern = re.compile(r"plugins/plugin-manager")
        violations = []

        for p in REPO_ROOT.rglob("*"):
            if not p.is_file():
                continue
            if any(part in p.parts for part in (".git", ".pytest_cache", "build", "temp", "node_modules", "tests", "archive", "work-tasks", "issue-payloads")):
                continue
            if p.name in self.HISTORICAL_LEDGERS or p.name in self.ALLOWED_HOST_SPEC_FILES:
                continue
            # Ignore test files that intentionally assert removal
            if p.name == "test_audit_decoupled_state.py":
                continue
            if p.suffix in (".md", ".py", ".sh", ".json", ".yaml", ".yml"):
                try:
                    text = p.read_text(encoding="utf-8", errors="ignore")
                    for idx, line in enumerate(text.splitlines(), 1):
                        if pattern.search(line):
                            violations.append(f"{p.relative_to(REPO_ROOT)}:{idx}: {line.strip()}")
                except Exception:
                    pass

        self.assertEqual(
            violations,
            [],
            f"Found references to deleted plugins/plugin-manager:\n" + "\n".join(violations),
        )

    def test_no_legacy_uvx_plugin_add_commands(self) -> None:
        """Assert no active documentation instructs users to run `uvx ... plugin-add`."""
        pattern = re.compile(r"plugin-add\s+richfrem/agent-plugins-skills")
        violations = []

        for p in REPO_ROOT.rglob("*"):
            if not p.is_file():
                continue
            if any(part in p.parts for part in (".git", ".pytest_cache", "build", "temp", "node_modules", "tests", "archive", "work-tasks", "issue-payloads")):
                continue
            if p.name in self.HISTORICAL_LEDGERS:
                continue
            if p.suffix in (".md", ".txt"):
                try:
                    text = p.read_text(encoding="utf-8", errors="ignore")
                    for idx, line in enumerate(text.splitlines(), 1):
                        if pattern.search(line):
                            violations.append(f"{p.relative_to(REPO_ROOT)}:{idx}: {line.strip()}")
                except Exception:
                    pass

        self.assertEqual(
            violations,
            [],
            f"Found legacy uvx plugin-add commands in documentation:\n" + "\n".join(violations),
        )

    def test_copy_manifest_zero_drift(self) -> None:
        """Assert that materialize_copies.py --check reports 0 drift across all 2,289 files."""
        script = (
            REPO_ROOT
            / "plugins"
            / "agent-extension-authoring"
            / ".apm"
            / "skills"
            / "packaging-with-apm"
            / "scripts"
            / "materialize_copies.py"
        )
        if not script.exists():
            script = (
                REPO_ROOT
                / "plugins"
                / "agent-extension-authoring"
                / "skills"
                / "packaging-with-apm"
                / "scripts"
                / "materialize_copies.py"
            )
        proc = subprocess.run(
            ["python3", str(script), "--path", str(REPO_ROOT), "--check"],
            capture_output=True,
            text=True,
            check=False,
        )
        self.assertEqual(proc.returncode, 0, f"materialize_copies --check failed:\n{proc.stdout}\n{proc.stderr}")
        self.assertIn("drifted=0", proc.stdout)
        self.assertIn("missing_source=0", proc.stdout)

    def test_no_stale_ownership_file_references_in_instructions(self) -> None:
        """Assert no active SKILL.md or agent markdown instructs agents to check .agents/ownership/."""
        pattern = re.compile(r"\.agents/ownership/")
        violations = []

        for p in (REPO_ROOT / "plugins").rglob("*.md"):
            if any(part in p.parts for part in (".git", ".pytest_cache", "build", "temp", "node_modules", "tests", "research", "design-artifacts")):
                continue
            if p.name in self.HISTORICAL_LEDGERS or p.name in self.ALLOWED_HOST_SPEC_FILES:
                continue
            try:
                text = p.read_text(encoding="utf-8", errors="ignore")
                for idx, line in enumerate(text.splitlines(), 1):
                    # Skip historical notes or explicit prohibitions
                    if pattern.search(line) and "retired" not in line and "prohibited" not in line and "legacy" not in line and "Zero Legacy" not in line:
                        violations.append(f"{p.relative_to(REPO_ROOT)}:{idx}: {line.strip()}")
            except Exception:
                pass

        self.assertEqual(
            violations,
            [],
            f"Found instructions referencing retired .agents/ownership:\n" + "\n".join(violations),
        )



if __name__ == "__main__":
    unittest.main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall