Core Directive:
@h-rig/coreis a configuration and plugin composition library facilitating Rigβs specific OMP extension ecosystem. It acts as the task-graph engine and plugin host, strictly separating static metadata from executable runtime components.
π Quick Start
- Plugin Authoring: Use
definePlugin(meta, runtime?)to export aRigPluginWithRuntimethat enforces static vs. executable parity. - Config Assembly: Use
defineConfig(cfg)to load and validate configurations while preserving runtime functions acrosseffectschema boundaries. - Engine Core: No app-shell assumptions. Keep reducers (
engineReadModelReducer) and graph traversals (taskGraph) pure and reusable across CLI, desktop, and UI.
π§ Configuration & Architecture
- Bifurcated Plugin Model: Plugins consist of Schema-validated static metadata (
contributes) and an optional executable__runtimemap. - Host Aggregation:
createPluginHost(plugins)indexes all validators, hooks, skills, and task sources, flattening them into querying registries. - Task Graph Engine: Graph logic (
computeTaskBlockingDepths,computeTaskDependencyBadges) uses cycle-safe memoized DFS to manage task dependencies, blocking statuses, and priority-based selection.
π¦ Dependencies
@rig/contracts: Interfaces and schema definitions.effect: Used for robust schema definition, decoding, and validation (Schema.decodeUnknownSync).
π‘ Best Practices (Patterns)
- Strict Runtime-Metadata Parity: Ensure every executable item in
__runtimehas an exact corresponding metadata entry incontributeswith identical IDs, kinds, and categories. - Pure Configuration Assembly: Use pure builders (
buildRigInitConfigSource) without FS or Node dependencies to allow safe bundling in both CLI and Web/Vite environments. - Graceful Auto-Defaults: Wrap all incoming configuration in
applyConfigDefaults()before decoding to ensure minimal configurations work out-of-the-box (e.g., auto-fillingplugins: []or normalizingworkspace.checkout). - Resilient Dependency Resolution: Fallback task dependency matching across
exactId->sourceIssueId->externalIdto bridge external trackers smoothly.
π¨ Gotchas / Anti-Patterns (Warnings)
- Losing Runtime Objects: Never pass config directly to
Schema.decodeUnknownSync. This strips unknown fields and silently deletes the__runtimeexecutable bits; always usedefineConfigwhich reattaches them. - Dual Hook Implementations: Defining both a
commandstring (in metadata) and a typed function (in__runtime.hooks) for the same hook is an anti-pattern and triggers a crash. Pick one. - Missing Implementations: Declaring an executable runtime category without supplying the implementations for all metadata entries of that category throws validation errors.
- Duplicate Registration: Reusing plugin names, contribution IDs, or task source
kinds across the ecosystem throws explicit duplicate registration errors at host creation time.