Files
gabrielvidalandClaude Opus 5.5 c8fa334528 refactor(resources): plugin-driven resource kinds — retire live PR polling and Profile.resources
Work Resources becomes generic core composition over declarative plugin
`resources[]`, ahead of the `github` / `linear` / `slack` plugins (Wave 2B-2).

- Core knows only `branch` and `url` (cli/resource_urls.py). Every link is
  mined raw, so the plugins' kinds apply at view time: installing a plugin
  lights up the whole archive with zero re-parse. Notion links are plain
  `url` pills.
- New backend/plugins/resources.py: PluginResourceRegistry compiled from the
  owner's active plugins' `resources[]` + each plugin's settings (workers,
  cwdGlobs, notifPills, channelMap, {config.*} templates); cached on the new
  PluginStore.version and kept by identity while unchanged.
- manifest.py: expanded, ReDoS-checked `resources[]` (urlRegex, idRegex,
  id/url/label templates, titleToken, bareKeyRegex + team gate,
  branchKeyPattern cross-links, ignoreUrlRegex, toolExtractors[], icon,
  color, stateTones, clickAction, priority, hueRole); the v3 shape and the
  approval fingerprint stay as they were.
- ResourceMiner runs declarative toolExtractors / bare keys in-process (no
  subprocess); legacy resourcesAuto / resourceTeams / slackChannels still read.
- resource_view: per-plugin scope, branchKeyPattern cross-linking, priority
  primary, generic `<lead> · <title> · <shade>` title; Context cached on
  (summaries, meta, registry) with per-transcript memo.
- look.subject → generic (hueKey, shadeKey) from hueRole; past.py generic.
- conv add/rm send raw links / keys; the hub's registry reads them.
- Removed: conversations/pr_state.py, sidecar/routes_gh.py (/gh/pr-states),
  deps.pr_states, Profile.resources + Orus defaults (dropped on load),
  GET /api/profiles/resource-directory, ProfileResourcesEditor + the
  Profile page's Tracking tab.
- Frontend pills read `ui.resources` descriptors (icon, tone, stateTones,
  clickAction); historical kinds keep a fallback. ResourceKind widens to str.
- Fixture manifests + test kit for the three plugins in
  backend/fixtures/resource_plugins/.

OpenAPI not re-dumped (coordinator does it after Batch 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 11:59:25 +01:00

78 lines
2.4 KiB
Python

"""Test kit: the ``github`` / ``linear`` / ``slack`` resource plugins as the
fixture manifests beside this file (the shape Wave 2B-2 ships in
``ai-agent-plugins``), a fake plugin store serving them, and the Orus-like
settings the old hardcoded profile block carried.
from fixtures.resource_plugins.kit import FakePluginStore, bound, registry
"""
from __future__ import annotations
import contextlib
import copy
import pathlib
import types
from plugins import resources as plugin_resources
from plugins.manifest import validate_manifest
HERE = pathlib.Path(__file__).resolve().parent
PLUGINS = ("github", "linear", "slack")
WORK_CWD = "/Users/gabrielvidal/WORK/ORUS/orus*"
SETTINGS = {
"github": {"githubRepo": "orus-tech/orus-monorepo"},
"linear": {"linearWorkspace": "orus"},
"slack": {"slackWorkspace": "orus-insurance"},
}
_MANIFESTS: dict[str, dict] = {}
def manifest(pid: str) -> dict:
if pid not in _MANIFESTS:
_MANIFESTS[pid] = validate_manifest(HERE / pid)
return copy.deepcopy(_MANIFESTS[pid])
class FakePluginStore:
"""What the registry reads of a ``PluginStore``: ``version`` and the
owner's active manifests + settings."""
def __init__(self, plugins=PLUGINS, settings=None, scope=None):
settings = copy.deepcopy(SETTINGS if settings is None else settings)
self.version = 1
self.rows = {}
for p in plugins:
cfg = dict(settings.get(p) or {})
cfg.update(scope or {})
self.rows[p] = (manifest(p), cfg)
def active_manifests(self, uid):
return [(p, copy.deepcopy(mf), dict(cfg)) for p, (mf, cfg) in sorted(self.rows.items())]
def configure(self, pid: str, **cfg) -> None:
self.rows[pid][1].update(cfg)
self.version += 1
def remove(self, pid: str) -> None:
self.rows.pop(pid, None)
self.version += 1
def deps_with(store) -> types.SimpleNamespace:
return types.SimpleNamespace(plugin_store=store)
def registry(plugins=PLUGINS, settings=None, scope=None):
return plugin_resources.registry(deps_with(FakePluginStore(plugins, settings, scope)))
@contextlib.contextmanager
def bound(store=None):
"""The transcript miner reads ``store``'s kinds (``plugins.resources.current``)."""
prev = plugin_resources._bound
plugin_resources.bind(deps_with(store if store is not None else FakePluginStore()))
try:
yield
finally:
plugin_resources._bound = prev