| 1 | // Package extension is the unified extension kernel: every capability the |
| 2 | // runtime exposes — tools, skills, commands, prompts, hooks, MCP servers, |
| 3 | // providers, themes, interceptors, and replacement slots — is modeled as a |
| 4 | // Contribution with explicit provenance, assembled by a deterministic Builder |
| 5 | // into an immutable RuntimeSnapshot. |
| 6 | // |
| 7 | // Spatiotemporal composability (plugin/runtime v2) adds EffectScope-owned live |
| 8 | // resources, a typed DependencyGraph, component epochs, and RuntimePlan-driven |
| 9 | // activate/publish/drain. RuntimeSnapshot stays configuration-only; live |
| 10 | // handles (processes, streams, watchers, goroutines) never enter the snapshot. |
| 11 | // |
| 12 | // The kernel exists so that shadowing, conflicts, and ordering stop being |
| 13 | // emergent side effects of whichever discovery path ran last. Discovery still |
| 14 | // lives in the existing packages (internal/skill, internal/command, |
| 15 | // internal/hook, internal/tool, internal/plugin, internal/provider); the |
| 16 | // adapters in adapters.go only wrap that discovery in the Contributor |
| 17 | // interface. Winner rules are resolved here, once, identically for every |
| 18 | // caller: a higher-tier scope shadows a lower one for the same canonical ID, |
| 19 | // same-tier duplicates from different sources are hard conflicts instead of |
| 20 | // silent overrides, and hooks/interceptors stay additive. Callers assembling |
| 21 | // pre-kernel legacy resources (boot) can opt into ConflictCollect, which |
| 22 | // records such conflicts on the snapshot's Diagnostics and keeps the |
| 23 | // deterministic winner instead of failing the build; native extensions keep |
| 24 | // the default ConflictFail. |
| 25 | // |
| 26 | // A RuntimeSnapshot is immutable after Freeze: every accessor returns |
| 27 | // defensive copies, so a snapshot can be shared across turns, subagents, and |
| 28 | // frontends without locking. CacheHash fingerprints exactly the |
| 29 | // provider-visible prefix state (system prompt + canonical tool schemas), so |
| 30 | // a snapshot rebuild that changes nothing observable reuses the same hash and |
| 31 | // preserves provider-side prompt caching. |
| 32 | package extension |
| 33 |