@h-rig/core 0.0.6-alpha.142 → 0.0.6-alpha.143
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.
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.js +136 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +5 -5
- package/dist/src/load-config.js +18 -7
- package/dist/src/rig-init-builder.js +5 -5
- package/package.json +6 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { defineConfig, type RigConfigInput } from "./define-config";
|
|
2
|
+
export { definePlugin } from "./define-plugin";
|
|
3
|
+
export type { RegisteredValidator, RigPluginRuntime, RigPluginWithRuntime, RuntimeCliCommand, RuntimeCliContext, RuntimePanelProducer, TaskSourceFactoryContext, TaskSourceFactoryEntry, ValidatorContext, ValidatorResult, } from "./plugin-runtime";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/define-config.ts
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { RigConfig } from "@rig/contracts";
|
|
5
|
+
function normalizeWorkspaceConfig(raw) {
|
|
6
|
+
const workspace = raw && typeof raw === "object" && !Array.isArray(raw) ? { ...raw } : { mainRepo: "." };
|
|
7
|
+
workspace.checkout = workspace.checkout ?? workspace.isolation ?? "worktree";
|
|
8
|
+
workspace.isolation = workspace.isolation ?? workspace.checkout;
|
|
9
|
+
workspace.sandbox = workspace.sandbox ?? "enforce";
|
|
10
|
+
return workspace;
|
|
11
|
+
}
|
|
12
|
+
function applyConfigDefaults(raw) {
|
|
13
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
14
|
+
return raw;
|
|
15
|
+
const record = raw;
|
|
16
|
+
return {
|
|
17
|
+
...record,
|
|
18
|
+
plugins: Array.isArray(record.plugins) ? record.plugins : [],
|
|
19
|
+
workspace: normalizeWorkspaceConfig(record.workspace)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function defineConfig(cfg) {
|
|
23
|
+
const runtimeByName = new Map;
|
|
24
|
+
const plugins = cfg.plugins ?? [];
|
|
25
|
+
for (const plugin of plugins) {
|
|
26
|
+
if (plugin?.__runtime) {
|
|
27
|
+
runtimeByName.set(plugin.name, plugin.__runtime);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const decoded = Schema.decodeUnknownSync(RigConfig)(applyConfigDefaults(cfg));
|
|
31
|
+
const decodedPlugins = decoded.plugins.map((p) => {
|
|
32
|
+
const runtime = runtimeByName.get(p.name);
|
|
33
|
+
if (!runtime)
|
|
34
|
+
return p;
|
|
35
|
+
return { ...p, __runtime: runtime };
|
|
36
|
+
});
|
|
37
|
+
return { ...decoded, plugins: decodedPlugins };
|
|
38
|
+
}
|
|
39
|
+
// packages/core/src/define-plugin.ts
|
|
40
|
+
import { Schema as Schema2 } from "effect";
|
|
41
|
+
import { RigPlugin } from "@rig/contracts";
|
|
42
|
+
function definePlugin(meta, runtime) {
|
|
43
|
+
const validated = Schema2.decodeUnknownSync(RigPlugin)(meta);
|
|
44
|
+
if (!runtime) {
|
|
45
|
+
return validated;
|
|
46
|
+
}
|
|
47
|
+
const declaredValidators = new Map((validated.contributes?.validators ?? []).map((v) => [v.id, v]));
|
|
48
|
+
const runtimeValidators = new Map((runtime.validators ?? []).map((v) => [v.id, v]));
|
|
49
|
+
for (const v of runtimeValidators.values()) {
|
|
50
|
+
const metadata = declaredValidators.get(v.id);
|
|
51
|
+
if (!metadata) {
|
|
52
|
+
throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" has no matching metadata entry in contributes.validators`);
|
|
53
|
+
}
|
|
54
|
+
if (metadata.category !== v.category) {
|
|
55
|
+
throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" category "${v.category}" does not match metadata category "${metadata.category}"`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (runtime.validators) {
|
|
59
|
+
for (const v of declaredValidators.values()) {
|
|
60
|
+
if (!runtimeValidators.has(v.id)) {
|
|
61
|
+
throw new Error(`definePlugin(${validated.name}): validator metadata "${v.id}" has no runtime implementation`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const declaredSources = new Map((validated.contributes?.taskSources ?? []).map((s) => [s.id, s]));
|
|
66
|
+
const runtimeSources = new Map((runtime.taskSources ?? []).map((s) => [s.id, s]));
|
|
67
|
+
for (const s of runtimeSources.values()) {
|
|
68
|
+
const metadata = declaredSources.get(s.id);
|
|
69
|
+
if (!metadata) {
|
|
70
|
+
throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" has no matching metadata entry in contributes.taskSources`);
|
|
71
|
+
}
|
|
72
|
+
if (metadata.kind !== s.kind) {
|
|
73
|
+
throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" kind "${s.kind}" does not match metadata kind "${metadata.kind}"`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (runtime.taskSources) {
|
|
77
|
+
for (const s of declaredSources.values()) {
|
|
78
|
+
if (!runtimeSources.has(s.id)) {
|
|
79
|
+
throw new Error(`definePlugin(${validated.name}): task source metadata "${s.id}" has no runtime implementation`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const declaredHooks = new Map((validated.contributes?.hooks ?? []).map((h) => [h.id, h]));
|
|
84
|
+
for (const hookId of Object.keys(runtime.hooks ?? {})) {
|
|
85
|
+
const metadata = declaredHooks.get(hookId);
|
|
86
|
+
if (!metadata) {
|
|
87
|
+
throw new Error(`definePlugin(${validated.name}): typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
|
|
88
|
+
}
|
|
89
|
+
if (metadata.command) {
|
|
90
|
+
throw new Error(`definePlugin(${validated.name}): hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (runtime.hooks) {
|
|
94
|
+
for (const h of declaredHooks.values()) {
|
|
95
|
+
if (!runtime.hooks[h.id] && !h.command) {
|
|
96
|
+
throw new Error(`definePlugin(${validated.name}): hook metadata "${h.id}" has no implementation (typed function or command)`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const declaredCapabilities = new Map((validated.contributes?.capabilities ?? []).map((capability) => [capability.id, capability]));
|
|
101
|
+
for (const capability of runtime.featureCapabilities ?? []) {
|
|
102
|
+
if (!declaredCapabilities.has(capability.id)) {
|
|
103
|
+
throw new Error(`definePlugin(${validated.name}): executable capability "${capability.id}" has no matching metadata entry in contributes.capabilities`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const declaredPanels = new Map((validated.contributes?.panels ?? []).map((panel) => [panel.id, panel]));
|
|
107
|
+
for (const panel of runtime.panels ?? []) {
|
|
108
|
+
const metadata = declaredPanels.get(panel.id);
|
|
109
|
+
if (!metadata) {
|
|
110
|
+
throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" has no matching metadata entry in contributes.panels`);
|
|
111
|
+
}
|
|
112
|
+
if (metadata.slot !== panel.slot) {
|
|
113
|
+
throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" slot "${panel.slot}" does not match metadata slot "${metadata.slot}"`);
|
|
114
|
+
}
|
|
115
|
+
if (metadata.capabilityId !== panel.capabilityId) {
|
|
116
|
+
throw new Error(`definePlugin(${validated.name}): executable panel "${panel.id}" capabilityId "${panel.capabilityId ?? "(none)"}" does not match metadata capabilityId "${metadata.capabilityId ?? "(none)"}"`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const declaredBlockerClassifiers = new Map((validated.contributes?.blockerClassifiers ?? []).map((classifier) => [classifier.id, classifier]));
|
|
120
|
+
for (const classifier of runtime.blockerClassifiers ?? []) {
|
|
121
|
+
if (!declaredBlockerClassifiers.has(classifier.id)) {
|
|
122
|
+
throw new Error(`definePlugin(${validated.name}): executable blocker classifier "${classifier.id}" has no matching metadata entry in contributes.blockerClassifiers`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const declaredCliCommands = new Map((validated.contributes?.cliCommands ?? []).map((command) => [command.id, command]));
|
|
126
|
+
for (const command of runtime.cliCommands ?? []) {
|
|
127
|
+
if (!declaredCliCommands.has(command.id)) {
|
|
128
|
+
throw new Error(`definePlugin(${validated.name}): executable cli command "${command.id}" has no matching metadata entry in contributes.cliCommands`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { ...validated, __runtime: runtime };
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
definePlugin,
|
|
135
|
+
defineConfig
|
|
136
|
+
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { defineConfig } from "./define-config";
|
|
|
4
4
|
export { createPluginHost } from "./plugin-host";
|
|
5
5
|
export type { PluginHost } from "./plugin-host";
|
|
6
6
|
export { buildRigInitConfigSource, type RigInitConfigInput, } from "./rig-init-builder";
|
|
7
|
-
export type { RegisteredValidator, RigPluginRuntime, RigPluginWithRuntime, TaskSourceFactoryContext, RuntimeCliCommand, RuntimeCliContext, TaskSourceFactoryEntry, ValidatorContext, ValidatorResult, } from "./plugin-runtime";
|
|
7
|
+
export type { RegisteredValidator, RigPluginRuntime, RigPluginWithRuntime, TaskSourceFactoryContext, RuntimeCliCommand, RuntimeCliContext, RuntimePanelProducer, TaskSourceFactoryEntry, ValidatorContext, ValidatorResult, } from "./plugin-runtime";
|
|
8
8
|
export { applyEngineEvent, applyEngineEvents, applyEngineEvent as applyRigEvent, pruneQueueEntries, type ApplyStatus, type EngineEventApplyResult, type EngineEventApplyResult as RigEventApplyResult, } from "./engineReadModelReducer";
|
|
9
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
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";
|
package/dist/src/index.js
CHANGED
|
@@ -420,9 +420,9 @@ function createPluginHost(plugins) {
|
|
|
420
420
|
}
|
|
421
421
|
// packages/core/src/rig-init-builder.ts
|
|
422
422
|
function buildRigInitConfigSource(input) {
|
|
423
|
-
const lines = [`import { defineConfig } from "@rig/core";`];
|
|
423
|
+
const lines = [`import { defineConfig } from "@rig/core/config";`];
|
|
424
424
|
if (input.useStandardPlugin) {
|
|
425
|
-
lines.push(`import {
|
|
425
|
+
lines.push(`import { standardPlugins } from "@rig/standard-plugin/bundle";`);
|
|
426
426
|
if (input.taskSource.kind === "github-issues") {
|
|
427
427
|
lines.push(`import { createStateGitHubCredentialProvider } from "@rig/standard-plugin";`);
|
|
428
428
|
}
|
|
@@ -431,15 +431,15 @@ function buildRigInitConfigSource(input) {
|
|
|
431
431
|
const projectRepo = input.projectRepo ?? (input.taskSource.kind === "github-issues" ? `${input.taskSource.owner}/${input.taskSource.repo}` : undefined);
|
|
432
432
|
lines.push(projectRepo ? ` project: { name: ${JSON.stringify(input.projectName)}, repo: ${JSON.stringify(projectRepo)} },` : ` project: { name: ${JSON.stringify(input.projectName)} },`);
|
|
433
433
|
if (input.useStandardPlugin && input.taskSource.kind === "github-issues") {
|
|
434
|
-
lines.push(` plugins: [...
|
|
435
|
-
lines.push(`
|
|
434
|
+
lines.push(` plugins: [...standardPlugins({`);
|
|
435
|
+
lines.push(` taskSources: {`);
|
|
436
436
|
lines.push(` githubCredentialProvider: createStateGitHubCredentialProvider(),`);
|
|
437
437
|
lines.push(` githubWorkspaceId: ${JSON.stringify(`${input.taskSource.owner}/${input.taskSource.repo}`)},`);
|
|
438
438
|
lines.push(` githubUserId: process.env.RIG_GITHUB_USER_ID ?? "server-selected-user",`);
|
|
439
439
|
lines.push(` },`);
|
|
440
440
|
lines.push(` })],`);
|
|
441
441
|
} else {
|
|
442
|
-
lines.push(` plugins: [${input.useStandardPlugin ? "...
|
|
442
|
+
lines.push(` plugins: [${input.useStandardPlugin ? "...standardPlugins()" : ""}],`);
|
|
443
443
|
}
|
|
444
444
|
if (input.taskSource.kind === "github-issues") {
|
|
445
445
|
lines.push(` taskSource: {`);
|
package/dist/src/load-config.js
CHANGED
|
@@ -109,8 +109,14 @@ function resolveDirectoryModulePath(directoryPath) {
|
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
111
|
function resolveModulePath(candidatePath) {
|
|
112
|
-
if (!existsSync(candidatePath))
|
|
112
|
+
if (!existsSync(candidatePath)) {
|
|
113
|
+
for (const extension of [".ts", ".mts", ".tsx", ".js", ".mjs", ".cjs", ".json"]) {
|
|
114
|
+
const withExtension = `${candidatePath}${extension}`;
|
|
115
|
+
if (existsSync(withExtension))
|
|
116
|
+
return resolveModulePath(withExtension);
|
|
117
|
+
}
|
|
113
118
|
return null;
|
|
119
|
+
}
|
|
114
120
|
try {
|
|
115
121
|
const stat = statSync(candidatePath);
|
|
116
122
|
if (stat.isFile())
|
|
@@ -155,19 +161,24 @@ async function importConfigViaRuntimeBundleUnserialized(configPath) {
|
|
|
155
161
|
name: "rig-config-unresolved-local",
|
|
156
162
|
setup(build) {
|
|
157
163
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
164
|
+
const directFilePath = resolvedFilePath(args.path, configDir);
|
|
165
|
+
if (directFilePath)
|
|
166
|
+
return { path: directFilePath };
|
|
158
167
|
if (/^(?:node|bun):/.test(args.path) || isBuiltin(args.path) || packageNameAndSubpath(args.path))
|
|
159
168
|
return;
|
|
160
|
-
const
|
|
169
|
+
const parentCandidates = args.path.startsWith(".") ? [args.importer && isAbsolute(args.importer) ? dirname(args.importer) : null, configDir].filter((value) => Boolean(value)) : [args.importer && isAbsolute(args.importer) ? dirname(args.importer) : configDir];
|
|
170
|
+
for (const parent2 of parentCandidates) {
|
|
171
|
+
const filePath = resolvedFilePath(resolve(parent2, args.path), configDir);
|
|
172
|
+
if (filePath)
|
|
173
|
+
return { path: filePath };
|
|
174
|
+
}
|
|
175
|
+
const parent = parentCandidates[0] ?? configDir;
|
|
161
176
|
try {
|
|
162
177
|
const resolved = bun.resolveSync?.(args.path, parent) ?? resolve(parent, args.path);
|
|
163
178
|
const filePath = resolvedFilePath(resolved, configDir);
|
|
164
179
|
if (filePath)
|
|
165
180
|
return { path: filePath };
|
|
166
|
-
} catch {
|
|
167
|
-
const filePath = resolvedFilePath(resolve(parent, args.path), configDir);
|
|
168
|
-
if (filePath)
|
|
169
|
-
return { path: filePath };
|
|
170
|
-
}
|
|
181
|
+
} catch {}
|
|
171
182
|
return { path: args.path, namespace: UNRESOLVED_NAMESPACE };
|
|
172
183
|
});
|
|
173
184
|
build.onLoad({ filter: /.*/, namespace: UNRESOLVED_NAMESPACE }, (args) => ({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/core/src/rig-init-builder.ts
|
|
3
3
|
function buildRigInitConfigSource(input) {
|
|
4
|
-
const lines = [`import { defineConfig } from "@rig/core";`];
|
|
4
|
+
const lines = [`import { defineConfig } from "@rig/core/config";`];
|
|
5
5
|
if (input.useStandardPlugin) {
|
|
6
|
-
lines.push(`import {
|
|
6
|
+
lines.push(`import { standardPlugins } from "@rig/standard-plugin/bundle";`);
|
|
7
7
|
if (input.taskSource.kind === "github-issues") {
|
|
8
8
|
lines.push(`import { createStateGitHubCredentialProvider } from "@rig/standard-plugin";`);
|
|
9
9
|
}
|
|
@@ -12,15 +12,15 @@ function buildRigInitConfigSource(input) {
|
|
|
12
12
|
const projectRepo = input.projectRepo ?? (input.taskSource.kind === "github-issues" ? `${input.taskSource.owner}/${input.taskSource.repo}` : undefined);
|
|
13
13
|
lines.push(projectRepo ? ` project: { name: ${JSON.stringify(input.projectName)}, repo: ${JSON.stringify(projectRepo)} },` : ` project: { name: ${JSON.stringify(input.projectName)} },`);
|
|
14
14
|
if (input.useStandardPlugin && input.taskSource.kind === "github-issues") {
|
|
15
|
-
lines.push(` plugins: [...
|
|
16
|
-
lines.push(`
|
|
15
|
+
lines.push(` plugins: [...standardPlugins({`);
|
|
16
|
+
lines.push(` taskSources: {`);
|
|
17
17
|
lines.push(` githubCredentialProvider: createStateGitHubCredentialProvider(),`);
|
|
18
18
|
lines.push(` githubWorkspaceId: ${JSON.stringify(`${input.taskSource.owner}/${input.taskSource.repo}`)},`);
|
|
19
19
|
lines.push(` githubUserId: process.env.RIG_GITHUB_USER_ID ?? "server-selected-user",`);
|
|
20
20
|
lines.push(` },`);
|
|
21
21
|
lines.push(` })],`);
|
|
22
22
|
} else {
|
|
23
|
-
lines.push(` plugins: [${input.useStandardPlugin ? "...
|
|
23
|
+
lines.push(` plugins: [${input.useStandardPlugin ? "...standardPlugins()" : ""}],`);
|
|
24
24
|
}
|
|
25
25
|
if (input.taskSource.kind === "github-issues") {
|
|
26
26
|
lines.push(` taskSource: {`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/core",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.143",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Config and plugin composition library for Rig's OMP extension ecosystem; not a product host/runtime.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"types": "./dist/src/load-config.d.ts",
|
|
18
18
|
"import": "./dist/src/load-config.js"
|
|
19
19
|
},
|
|
20
|
+
"./config": {
|
|
21
|
+
"types": "./dist/src/config.d.ts",
|
|
22
|
+
"import": "./dist/src/config.js"
|
|
23
|
+
},
|
|
20
24
|
"./task-graph": {
|
|
21
25
|
"types": "./dist/src/taskGraph.d.ts",
|
|
22
26
|
"import": "./dist/src/taskGraph.js"
|
|
@@ -45,7 +49,7 @@
|
|
|
45
49
|
"module": "./dist/src/index.js",
|
|
46
50
|
"types": "./dist/src/index.d.ts",
|
|
47
51
|
"dependencies": {
|
|
48
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
52
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.143",
|
|
49
53
|
"effect": "4.0.0-beta.90"
|
|
50
54
|
}
|
|
51
55
|
}
|