Replace monolithic if-chains with target-driven INTEGRATION_DISPATCH registry#489
Replace monolithic if-chains with target-driven INTEGRATION_DISPATCH registry#489
Conversation
Agent-Logs-Url: https://github.com/microsoft/apm/sessions/ac5a8b5e-a4fe-469b-be63-e307ca8b62b9 Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Add integrate_cursor flag alongside existing integrate_vscode, integrate_claude, integrate_opencode. Guard all target-specific integrations in _integrate_package_primitives(): - .github/prompts/ and .github/agents/ behind integrate_vscode - .cursor/rules/, .cursor/agents/, .cursor/hooks behind integrate_cursor - .opencode/agents/ and .opencode/commands/ behind integrate_opencode Fixes --target opencode creating .github/ directory. Agent-Logs-Url: https://github.com/microsoft/apm/sessions/ac5a8b5e-a4fe-469b-be63-e307ca8b62b9 Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
|
@copilot think of a better and more scalable architecture which separates concerns. We do have a BaseIntegrator class. Why not think of a CopilotIntegrator, CursorIntegrator etc which manage this? multiplying checkpoints in install.py won't scale and is monolithic. Rethink architectural approach with solid design patterns so that we reduce failure points as much as possible. |
Agent-Logs-Url: https://github.com/microsoft/apm/sessions/1515287c-ba20-4681-8c88-a643718c2f1e Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Introduce INTEGRATION_DISPATCH registry in targets.py that maps (target_name, primitive_name) to (integrator_key, method_name, log_dir). integrate_package_for_targets() loops active TargetProfiles and dispatches to the correct integrator method for each supported primitive. No if-chains needed — adding a target/primitive means adding a registry entry. _integrate_package_primitives() in install.py now accepts targets= (list of TargetProfile) instead of boolean flags and delegates to the centralized dispatcher. Fixes --target opencode creating .github/ and similar cross-target leaks. Agent-Logs-Url: https://github.com/microsoft/apm/sessions/1515287c-ba20-4681-8c88-a643718c2f1e Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/apm/sessions/1515287c-ba20-4681-8c88-a643718c2f1e Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Redesigned the architecture in
Adding a new target or primitive now requires:
No touching install.py. Tests include registry completeness validation ( |
Description
--target opencodeunconditionally writes to.github/prompts/and.github/agents/, creating a.github/directory the user never requested. Same class of bug affects cursor/opencode integrations that ran without flag-level gating.Root cause:
_integrate_package_primitives()used per-target boolean flags (integrate_vscode,integrate_claude,integrate_opencode) with hardcoded if-chains. Prompts,.github/agents, cursor, and opencode integrations ran unconditionally because guards were missing or incomplete. This monolithic approach doesn't scale — adding a target or primitive means editing install.py's if-chain.Fix — declarative target-driven dispatch architecture:
INTEGRATION_DISPATCHregistry intargets.py: a dict mapping(target_name, primitive_name)→(integrator_key, method_name, log_dir). Single source of truth for all routing.integrate_package_for_targets()intargets.py: centralized dispatcher that loops activeTargetProfileinstances and dispatches per-primitive via the registry. One loop, no if-chains._integrate_package_primitives()ininstall.py: simplified to a thin adapter acceptingtargets=(list ofTargetProfile) instead of boolean flags, delegating to the centralized dispatcher.Adding a new target or primitive now requires:
KNOWN_TARGETSentry (already existed)INTEGRATION_DISPATCHentryNo touching install.py.
Type of change
Testing
11 new tests added:
.github/, opencode-only calls its integrators, cursor-only skips all other targets, copilot-only skips cursor/opencode, empty targets returns zeros, etc.)test_every_target_primitive_has_dispatch_entry,test_dispatch_entries_reference_valid_methods) to catch gaps at test time