@h-rig/core 0.0.6-alpha.154 → 0.0.6-alpha.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  export { defineConfig, type RigConfigInput } from "./define-config";
2
2
  export { definePlugin } from "./define-plugin";
3
- export type { RegisteredValidator, RigPluginRuntime, RigPluginWithRuntime, RuntimeCliCommand, RuntimeCliContext, RuntimePanelProducer, TaskSourceFactoryContext, TaskSourceFactoryEntry, ValidatorContext, ValidatorResult, } from "./plugin-runtime";
3
+ export type { RigPlugin, PluginContributes, Validator, TaskSource, FeatureCapability, Panel, BlockerClassifierEntry, CliCommand, Hook, StageEntry, SessionExtensionEntry, SessionExtensionInstall, RuntimeCliContext, TaskSourceFactoryContext, ValidatorContext, ValidatorResult, } from "./plugin-runtime";
@@ -30,97 +30,10 @@ function defineConfig(cfg) {
30
30
  }
31
31
  // packages/core/src/define-plugin.ts
32
32
  import { Schema as Schema2 } from "effect";
33
- import { RigPlugin } from "@rig/contracts";
34
- function definePlugin(meta, runtime) {
35
- const validated = Schema2.decodeUnknownSync(RigPlugin)(meta);
36
- if (!runtime) {
37
- return validated;
38
- }
39
- const declaredValidators = new Map((validated.contributes?.validators ?? []).map((v) => [v.id, v]));
40
- const runtimeValidators = new Map((runtime.validators ?? []).map((v) => [v.id, v]));
41
- for (const v of runtimeValidators.values()) {
42
- const metadata = declaredValidators.get(v.id);
43
- if (!metadata) {
44
- throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" has no matching metadata entry in contributes.validators`);
45
- }
46
- if (metadata.category !== v.category) {
47
- throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" category "${v.category}" does not match metadata category "${metadata.category}"`);
48
- }
49
- }
50
- if (runtime.validators) {
51
- for (const v of declaredValidators.values()) {
52
- if (!runtimeValidators.has(v.id)) {
53
- throw new Error(`definePlugin(${validated.name}): validator metadata "${v.id}" has no runtime implementation`);
54
- }
55
- }
56
- }
57
- const declaredSources = new Map((validated.contributes?.taskSources ?? []).map((s) => [s.id, s]));
58
- const runtimeSources = new Map((runtime.taskSources ?? []).map((s) => [s.id, s]));
59
- for (const s of runtimeSources.values()) {
60
- const metadata = declaredSources.get(s.id);
61
- if (!metadata) {
62
- throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" has no matching metadata entry in contributes.taskSources`);
63
- }
64
- if (metadata.kind !== s.kind) {
65
- throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" kind "${s.kind}" does not match metadata kind "${metadata.kind}"`);
66
- }
67
- }
68
- if (runtime.taskSources) {
69
- for (const s of declaredSources.values()) {
70
- if (!runtimeSources.has(s.id)) {
71
- throw new Error(`definePlugin(${validated.name}): task source metadata "${s.id}" has no runtime implementation`);
72
- }
73
- }
74
- }
75
- const declaredHooks = new Map((validated.contributes?.hooks ?? []).map((h) => [h.id, h]));
76
- for (const hookId of Object.keys(runtime.hooks ?? {})) {
77
- const metadata = declaredHooks.get(hookId);
78
- if (!metadata) {
79
- throw new Error(`definePlugin(${validated.name}): typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
80
- }
81
- if (metadata.command) {
82
- throw new Error(`definePlugin(${validated.name}): hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
83
- }
84
- }
85
- if (runtime.hooks) {
86
- for (const h of declaredHooks.values()) {
87
- if (!runtime.hooks[h.id] && !h.command) {
88
- throw new Error(`definePlugin(${validated.name}): hook metadata "${h.id}" has no implementation (typed function or command)`);
89
- }
90
- }
91
- }
92
- const declaredCapabilities = new Map((validated.contributes?.capabilities ?? []).map((capability) => [capability.id, capability]));
93
- for (const capability of runtime.featureCapabilities ?? []) {
94
- if (!declaredCapabilities.has(capability.id)) {
95
- throw new Error(`definePlugin(${validated.name}): executable capability "${capability.id}" has no matching metadata entry in contributes.capabilities`);
96
- }
97
- }
98
- const declaredPanels = new Map((validated.contributes?.panels ?? []).map((panel) => [panel.id, panel]));
99
- for (const panel of runtime.panels ?? []) {
100
- const metadata = declaredPanels.get(panel.id);
101
- if (!metadata) {
102
- throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" has no matching metadata entry in contributes.panels`);
103
- }
104
- if (metadata.slot !== panel.slot) {
105
- throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" slot "${panel.slot}" does not match metadata slot "${metadata.slot}"`);
106
- }
107
- if (metadata.capabilityId !== panel.capabilityId) {
108
- throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" capabilityId "${panel.capabilityId ?? "(none)"}" does not match metadata capabilityId "${metadata.capabilityId ?? "(none)"}"`);
109
- }
110
- }
111
- const declaredBlockerClassifiers = new Map((validated.contributes?.blockerClassifiers ?? []).map((classifier) => [classifier.id, classifier]));
112
- for (const classifier of runtime.blockerClassifiers ?? []) {
113
- if (!declaredBlockerClassifiers.has(classifier.id)) {
114
- throw new Error(`definePlugin(${validated.name}): executable blocker classifier "${classifier.id}" has no matching metadata entry in contributes.blockerClassifiers`);
115
- }
116
- }
117
- const declaredCliCommands = new Map((validated.contributes?.cliCommands ?? []).map((command) => [command.id, command]));
118
- for (const command of runtime.cliCommands ?? []) {
119
- if (!declaredCliCommands.has(command.id)) {
120
- throw new Error(`definePlugin(${validated.name}): executable cli command "${command.id}" has no matching metadata entry in contributes.cliCommands`);
121
- }
122
- }
123
- return { ...validated, ...runtime };
33
+ import { RigPlugin as RigPluginManifest } from "@rig/contracts";
34
+ function definePlugin(plugin) {
35
+ Schema2.decodeUnknownSync(RigPluginManifest)(plugin);
36
+ return plugin;
124
37
  }
125
38
  export {
126
39
  definePlugin,
@@ -1,9 +1,13 @@
1
- import { RigPlugin } from "@rig/contracts";
2
- import type { RigPluginRuntime, RigPluginWithRuntime } from "./plugin-runtime";
1
+ import type { RigPlugin } from "./plugin-runtime";
3
2
  /**
4
- * Define a Rig plugin. The first argument is the schema-validated metadata
5
- * (id strings, version, contributions). The optional second argument carries
6
- * executable fields (validator `run` functions, task-source factories, CLI
7
- * handlers, etc.) on the returned plugin object itself.
3
+ * Define a Rig plugin. Single-channel: the plugin is ONE object whose
4
+ * `contributes` entries each carry their schema-validated metadata AND their
5
+ * executable fn together (no second argument, no separate runtime channel).
6
+ *
7
+ * Validation decodes the plugin against the `RigPlugin` metadata manifest in
8
+ * @rig/contracts — this throws on malformed metadata (bad name/version,
9
+ * invalid registration). The executable fns and `capabilityProviders` ride on
10
+ * the same object and are ignored by Schema decode (effect strips excess), so
11
+ * the original object is returned unchanged with its fns intact.
8
12
  */
9
- export declare function definePlugin(meta: RigPlugin, runtime?: RigPluginRuntime): RigPluginWithRuntime;
13
+ export declare function definePlugin(plugin: RigPlugin): RigPlugin;
@@ -1,97 +1,10 @@
1
1
  // @bun
2
2
  // packages/core/src/define-plugin.ts
3
3
  import { Schema } from "effect";
4
- import { RigPlugin } from "@rig/contracts";
5
- function definePlugin(meta, runtime) {
6
- const validated = Schema.decodeUnknownSync(RigPlugin)(meta);
7
- if (!runtime) {
8
- return validated;
9
- }
10
- const declaredValidators = new Map((validated.contributes?.validators ?? []).map((v) => [v.id, v]));
11
- const runtimeValidators = new Map((runtime.validators ?? []).map((v) => [v.id, v]));
12
- for (const v of runtimeValidators.values()) {
13
- const metadata = declaredValidators.get(v.id);
14
- if (!metadata) {
15
- throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" has no matching metadata entry in contributes.validators`);
16
- }
17
- if (metadata.category !== v.category) {
18
- throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" category "${v.category}" does not match metadata category "${metadata.category}"`);
19
- }
20
- }
21
- if (runtime.validators) {
22
- for (const v of declaredValidators.values()) {
23
- if (!runtimeValidators.has(v.id)) {
24
- throw new Error(`definePlugin(${validated.name}): validator metadata "${v.id}" has no runtime implementation`);
25
- }
26
- }
27
- }
28
- const declaredSources = new Map((validated.contributes?.taskSources ?? []).map((s) => [s.id, s]));
29
- const runtimeSources = new Map((runtime.taskSources ?? []).map((s) => [s.id, s]));
30
- for (const s of runtimeSources.values()) {
31
- const metadata = declaredSources.get(s.id);
32
- if (!metadata) {
33
- throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" has no matching metadata entry in contributes.taskSources`);
34
- }
35
- if (metadata.kind !== s.kind) {
36
- throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" kind "${s.kind}" does not match metadata kind "${metadata.kind}"`);
37
- }
38
- }
39
- if (runtime.taskSources) {
40
- for (const s of declaredSources.values()) {
41
- if (!runtimeSources.has(s.id)) {
42
- throw new Error(`definePlugin(${validated.name}): task source metadata "${s.id}" has no runtime implementation`);
43
- }
44
- }
45
- }
46
- const declaredHooks = new Map((validated.contributes?.hooks ?? []).map((h) => [h.id, h]));
47
- for (const hookId of Object.keys(runtime.hooks ?? {})) {
48
- const metadata = declaredHooks.get(hookId);
49
- if (!metadata) {
50
- throw new Error(`definePlugin(${validated.name}): typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
51
- }
52
- if (metadata.command) {
53
- throw new Error(`definePlugin(${validated.name}): hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
54
- }
55
- }
56
- if (runtime.hooks) {
57
- for (const h of declaredHooks.values()) {
58
- if (!runtime.hooks[h.id] && !h.command) {
59
- throw new Error(`definePlugin(${validated.name}): hook metadata "${h.id}" has no implementation (typed function or command)`);
60
- }
61
- }
62
- }
63
- const declaredCapabilities = new Map((validated.contributes?.capabilities ?? []).map((capability) => [capability.id, capability]));
64
- for (const capability of runtime.featureCapabilities ?? []) {
65
- if (!declaredCapabilities.has(capability.id)) {
66
- throw new Error(`definePlugin(${validated.name}): executable capability "${capability.id}" has no matching metadata entry in contributes.capabilities`);
67
- }
68
- }
69
- const declaredPanels = new Map((validated.contributes?.panels ?? []).map((panel) => [panel.id, panel]));
70
- for (const panel of runtime.panels ?? []) {
71
- const metadata = declaredPanels.get(panel.id);
72
- if (!metadata) {
73
- throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" has no matching metadata entry in contributes.panels`);
74
- }
75
- if (metadata.slot !== panel.slot) {
76
- throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" slot "${panel.slot}" does not match metadata slot "${metadata.slot}"`);
77
- }
78
- if (metadata.capabilityId !== panel.capabilityId) {
79
- throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" capabilityId "${panel.capabilityId ?? "(none)"}" does not match metadata capabilityId "${metadata.capabilityId ?? "(none)"}"`);
80
- }
81
- }
82
- const declaredBlockerClassifiers = new Map((validated.contributes?.blockerClassifiers ?? []).map((classifier) => [classifier.id, classifier]));
83
- for (const classifier of runtime.blockerClassifiers ?? []) {
84
- if (!declaredBlockerClassifiers.has(classifier.id)) {
85
- throw new Error(`definePlugin(${validated.name}): executable blocker classifier "${classifier.id}" has no matching metadata entry in contributes.blockerClassifiers`);
86
- }
87
- }
88
- const declaredCliCommands = new Map((validated.contributes?.cliCommands ?? []).map((command) => [command.id, command]));
89
- for (const command of runtime.cliCommands ?? []) {
90
- if (!declaredCliCommands.has(command.id)) {
91
- throw new Error(`definePlugin(${validated.name}): executable cli command "${command.id}" has no matching metadata entry in contributes.cliCommands`);
92
- }
93
- }
94
- return { ...validated, ...runtime };
4
+ import { RigPlugin as RigPluginManifest } from "@rig/contracts";
5
+ function definePlugin(plugin) {
6
+ Schema.decodeUnknownSync(RigPluginManifest)(plugin);
7
+ return plugin;
95
8
  }
96
9
  export {
97
10
  definePlugin
@@ -3,14 +3,4 @@ export { definePlugin } from "./define-plugin";
3
3
  export { defineConfig } from "./define-config";
4
4
  export { createPluginHost } from "./plugin-host";
5
5
  export type { PluginHost } from "./plugin-host";
6
- export { buildRigInitConfigSource, type RigInitConfigInput, } from "./rig-init-builder";
7
- export type { RegisteredValidator, RigPluginRuntime, RigPluginWithRuntime, TaskSourceFactoryContext, RuntimeCliCommand, RuntimeCliContext, RuntimePanelProducer, TaskSourceFactoryEntry, ValidatorContext, ValidatorResult, } from "./plugin-runtime";
8
- export { applyEngineEvent, applyEngineEvents, applyEngineEvent as applyRigEvent, pruneQueueEntries, type ApplyStatus, type EngineEventApplyResult, type EngineEventApplyResult as RigEventApplyResult, } from "./engineReadModelReducer";
9
- export { pickDefaultWorkspaceId, projectRunStatusForTaskGrouping, projectTaskStatusForGrouping, projectTaskStatusWithSessions, normalizeTaskAssigneeFilter, readTaskAssigneeLogins, selectAdhocRuns, selectAdhocRunsForWorkspace, selectApprovalsForRun, selectApprovalsForWorkspace, selectGraphsForWorkspace, selectPendingApprovals, selectPrimaryWorkspace, selectQueueForWorkspace, selectRun, selectRunsByTask, selectRunsForTask, selectRunsForWorkspace, selectTask, selectTasksByStatus, selectTasksByWorkspace, selectTasksForWorkspace, selectTasksGroupedByStatus, selectTasksAssignedTo, selectTasksAssignedToMe, selectUserInputsForRun, selectUserInputsForWorkspace, selectWorkspace, selectWorkspaces, type RigTaskSessionProjection, type RigTaskStatusGroup, type RigTaskStatusGroupingInput, } from "./rigSelectors";
10
- export { buildTaskReferenceIndex, computeTaskBlockingDepths, computeTaskDependencyBadges, disjointScope, isTaskTerminalStatus, rankReadyTasks, readTaskBlockingDependencyRefs, readTaskDependencyRefs, readTaskMetadataStringList, readTaskScope, readTaskSourceIssueId, resolveTaskReference, selectNextReadyTaskByPriority, selectRankedReadyTasks, type RankedReadyTask, type RankedReadyTaskOptions, type ReadyTaskSelectionMode, type TaskDependencyBadge, type TaskDependencyBadgeKind, type TaskDependencyBadgeSummary, type TaskDependencyProjection, type TaskScopeInput, } from "./taskGraph";
11
- export { extractTaskCode, extractTaskGroupKey, stripTaskCode, } from "./taskGraphCodes";
12
- export { buildTaskGraphLayout, type TaskGraphEdge, type TaskGraphLane, type TaskGraphLayout, type TaskGraphNode, type TaskGraphStage, } from "./taskGraphLayout";
13
- export { PipelineUnresolvableError, resolveStagePipeline, type DroppedStageAnchor, type ResolvableStage, type ResolvedStagePipeline, type ResolveStagePipelineInput, type StageKind, type StageMutation, type StageMutationOp, type StageResolutionRecordEntry, type StageWrapper, } from "./stageResolve";
14
- export { rankTasks, scoreTask, type RankedTask, type TaskCriticality, type TaskScoreInput, } from "./taskScore";
15
- export { buildDependencyGraphModel, type BuildDependencyGraphModelOptions, type DependencyEdge, type DependencyEdgeType, type DependencyGraphModel, type DependencyNode, } from "./dependencyGraph";
16
- export { rollupByAssignee, rollupByEpic, type AssigneeRollup, type BlockerClass, type EpicRollup, } from "./rollups";
6
+ export type { RigPlugin, PluginContributes, Validator, TaskSource, FeatureCapability, Panel, BlockerClassifierEntry, CliCommand, Hook, StageEntry, SessionExtensionEntry, SessionExtensionInstall, TaskSourceFactoryContext, RuntimeCliContext, ValidatorContext, ValidatorResult, } from "./plugin-runtime";