@h-rig/core 0.0.6-alpha.141 → 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 +28 -142
- 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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from "fs";
|
|
4
4
|
import { isBuiltin } from "module";
|
|
5
5
|
import { dirname, isAbsolute, join, relative, resolve } from "path";
|
|
6
|
-
import {
|
|
6
|
+
import { pathToFileURL } from "url";
|
|
7
7
|
import { Schema as Schema2 } from "effect";
|
|
8
8
|
import { RigConfig as RigConfig2 } from "@rig/contracts";
|
|
9
9
|
|
|
@@ -88,35 +88,6 @@ function exportTargetFromPackageJson(pkg, subpath) {
|
|
|
88
88
|
return target;
|
|
89
89
|
return subpath === "." && typeof pkg.module === "string" ? pkg.module : subpath === "." && typeof pkg.main === "string" ? pkg.main : null;
|
|
90
90
|
}
|
|
91
|
-
function resolvePackageDirFromBunStore(packageName, nodeModulesDir) {
|
|
92
|
-
const storeDir = join(nodeModulesDir, ".bun");
|
|
93
|
-
if (!existsSync(storeDir))
|
|
94
|
-
return null;
|
|
95
|
-
const encoded = packageName.replace("/", "+");
|
|
96
|
-
try {
|
|
97
|
-
const candidates = readdirSync(storeDir).filter((entry) => entry.startsWith(`${encoded}@`)).map((entry) => {
|
|
98
|
-
const candidateDir = join(storeDir, entry, "node_modules", packageName);
|
|
99
|
-
const packageJsonPath = join(candidateDir, "package.json");
|
|
100
|
-
if (!existsSync(packageJsonPath))
|
|
101
|
-
return null;
|
|
102
|
-
try {
|
|
103
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
104
|
-
return {
|
|
105
|
-
dir: candidateDir,
|
|
106
|
-
sortKey: pkg.version?.trim() || entry
|
|
107
|
-
};
|
|
108
|
-
} catch {
|
|
109
|
-
return {
|
|
110
|
-
dir: candidateDir,
|
|
111
|
-
sortKey: entry
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}).filter((candidate) => candidate !== null).sort((a, b) => b.sortKey.localeCompare(a.sortKey, undefined, { numeric: true, sensitivity: "base" }));
|
|
115
|
-
return candidates[0]?.dir ?? null;
|
|
116
|
-
} catch {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
91
|
function resolveDirectoryModulePath(directoryPath) {
|
|
121
92
|
const packageJsonPath = join(directoryPath, "package.json");
|
|
122
93
|
if (existsSync(packageJsonPath)) {
|
|
@@ -138,8 +109,14 @@ function resolveDirectoryModulePath(directoryPath) {
|
|
|
138
109
|
return null;
|
|
139
110
|
}
|
|
140
111
|
function resolveModulePath(candidatePath) {
|
|
141
|
-
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
|
+
}
|
|
142
118
|
return null;
|
|
119
|
+
}
|
|
143
120
|
try {
|
|
144
121
|
const stat = statSync(candidatePath);
|
|
145
122
|
if (stat.isFile())
|
|
@@ -151,68 +128,6 @@ function resolveModulePath(candidatePath) {
|
|
|
151
128
|
}
|
|
152
129
|
return null;
|
|
153
130
|
}
|
|
154
|
-
function resolvePackageExportFromDir(packageDir, subpath) {
|
|
155
|
-
const packageJsonPath = join(packageDir, "package.json");
|
|
156
|
-
if (existsSync(packageJsonPath)) {
|
|
157
|
-
try {
|
|
158
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
159
|
-
const target = exportTargetFromPackageJson(pkg, subpath);
|
|
160
|
-
if (target) {
|
|
161
|
-
const resolved = resolveModulePath(join(packageDir, target));
|
|
162
|
-
if (resolved)
|
|
163
|
-
return resolved;
|
|
164
|
-
}
|
|
165
|
-
} catch {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (subpath !== ".") {
|
|
170
|
-
const legacySubpath = subpath.replace(/^\.\//, "");
|
|
171
|
-
for (const candidate of [
|
|
172
|
-
join(packageDir, legacySubpath),
|
|
173
|
-
join(packageDir, `${legacySubpath}.js`),
|
|
174
|
-
join(packageDir, `${legacySubpath}.mjs`),
|
|
175
|
-
join(packageDir, `${legacySubpath}.cjs`),
|
|
176
|
-
join(packageDir, `${legacySubpath}.ts`),
|
|
177
|
-
join(packageDir, `${legacySubpath}.json`)
|
|
178
|
-
]) {
|
|
179
|
-
const resolved = resolveModulePath(candidate);
|
|
180
|
-
if (resolved)
|
|
181
|
-
return resolved;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return subpath === "." ? resolveDirectoryModulePath(packageDir) : null;
|
|
185
|
-
}
|
|
186
|
-
function resolveBarePackageExport(specifier, parentDir, ceilingDir) {
|
|
187
|
-
const parsed = packageNameAndSubpath(specifier);
|
|
188
|
-
if (!parsed)
|
|
189
|
-
return null;
|
|
190
|
-
const packageNames = parsed.packageName.startsWith("@rig/") ? [parsed.packageName, parsed.packageName.replace(/^@rig\//, "@h-rig/")] : [parsed.packageName];
|
|
191
|
-
const ceiling = ceilingDir ? resolve(ceilingDir) : null;
|
|
192
|
-
let current = resolve(parentDir);
|
|
193
|
-
while (true) {
|
|
194
|
-
const nodeModulesDir = join(current, "node_modules");
|
|
195
|
-
for (const packageName of packageNames) {
|
|
196
|
-
const directPackageDir = join(nodeModulesDir, packageName);
|
|
197
|
-
const resolvedDirect = resolvePackageExportFromDir(directPackageDir, parsed.subpath);
|
|
198
|
-
if (resolvedDirect)
|
|
199
|
-
return resolvedDirect;
|
|
200
|
-
const bunStorePackageDir = resolvePackageDirFromBunStore(packageName, nodeModulesDir);
|
|
201
|
-
if (bunStorePackageDir) {
|
|
202
|
-
const resolvedFromStore = resolvePackageExportFromDir(bunStorePackageDir, parsed.subpath);
|
|
203
|
-
if (resolvedFromStore)
|
|
204
|
-
return resolvedFromStore;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (ceiling && current === ceiling)
|
|
208
|
-
break;
|
|
209
|
-
const next = dirname(current);
|
|
210
|
-
if (next === current)
|
|
211
|
-
break;
|
|
212
|
-
current = next;
|
|
213
|
-
}
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
131
|
var runtimeBundleQueue = Promise.resolve();
|
|
217
132
|
function enqueueRuntimeBundle(operation) {
|
|
218
133
|
const next = runtimeBundleQueue.then(operation, operation);
|
|
@@ -235,70 +150,41 @@ function resolvedFilePath(path, rootPath) {
|
|
|
235
150
|
return null;
|
|
236
151
|
return rootPath && !isWithinDir(resolved, rootPath) ? null : resolved;
|
|
237
152
|
}
|
|
238
|
-
var RUNTIME_BUNDLE_EXTERNALS = [];
|
|
239
|
-
function shouldDeferToRuntimeExternal(specifier) {
|
|
240
|
-
return RUNTIME_BUNDLE_EXTERNALS.includes(specifier);
|
|
241
|
-
}
|
|
242
153
|
async function importConfigViaRuntimeBundleUnserialized(configPath) {
|
|
243
154
|
const bun = globalThis.Bun;
|
|
244
155
|
if (!bun?.build) {
|
|
245
156
|
throw new Error(`Failed to import ${configPath}: bare imports could not be resolved and no Bun.build runtime bundler is available.`);
|
|
246
157
|
}
|
|
247
|
-
const hostDir = (() => {
|
|
248
|
-
try {
|
|
249
|
-
return dirname(fileURLToPath(import.meta.url));
|
|
250
|
-
} catch {
|
|
251
|
-
return process.cwd();
|
|
252
|
-
}
|
|
253
|
-
})();
|
|
254
158
|
const configDir = dirname(configPath);
|
|
255
159
|
const UNRESOLVED_NAMESPACE = "rig-config-unresolved";
|
|
256
|
-
const
|
|
257
|
-
name: "rig-
|
|
160
|
+
const unresolvedLocalPlugin = {
|
|
161
|
+
name: "rig-config-unresolved-local",
|
|
258
162
|
setup(build) {
|
|
259
|
-
build.onResolve({ filter: /^@rig\// }, (args) => {
|
|
260
|
-
const candidates = [
|
|
261
|
-
{ specifier: args.path, parent: hostDir },
|
|
262
|
-
{ specifier: args.path.replace(/^@rig\//, "@h-rig/"), parent: hostDir },
|
|
263
|
-
{ specifier: args.path, parent: configDir, root: configDir }
|
|
264
|
-
];
|
|
265
|
-
for (const candidate of candidates) {
|
|
266
|
-
try {
|
|
267
|
-
const resolved = resolvedFilePath(bun.resolveSync?.(candidate.specifier, candidate.parent) ?? resolveBarePackageExport(candidate.specifier, candidate.parent, candidate.root), candidate.root);
|
|
268
|
-
if (resolved)
|
|
269
|
-
return { path: resolved };
|
|
270
|
-
} catch {
|
|
271
|
-
const resolved = resolvedFilePath(resolveBarePackageExport(candidate.specifier, candidate.parent, candidate.root), candidate.root);
|
|
272
|
-
if (resolved)
|
|
273
|
-
return { path: resolved };
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return;
|
|
277
|
-
});
|
|
278
163
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
164
|
+
const directFilePath = resolvedFilePath(args.path, configDir);
|
|
165
|
+
if (directFilePath)
|
|
166
|
+
return { path: directFilePath };
|
|
167
|
+
if (/^(?:node|bun):/.test(args.path) || isBuiltin(args.path) || packageNameAndSubpath(args.path))
|
|
281
168
|
return;
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
const filePath = resolvedFilePath(resolved, projectScoped ? configDir : undefined);
|
|
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);
|
|
286
172
|
if (filePath)
|
|
287
173
|
return { path: filePath };
|
|
288
|
-
if (resolved)
|
|
289
|
-
return { path: args.path, namespace: UNRESOLVED_NAMESPACE };
|
|
290
|
-
} catch {
|
|
291
|
-
const resolved = resolvedFilePath(resolveBarePackageExport(args.path, parent, projectScoped ? configDir : undefined), projectScoped ? configDir : undefined);
|
|
292
|
-
if (resolved)
|
|
293
|
-
return { path: resolved };
|
|
294
|
-
return { path: args.path, namespace: UNRESOLVED_NAMESPACE };
|
|
295
174
|
}
|
|
296
|
-
|
|
175
|
+
const parent = parentCandidates[0] ?? configDir;
|
|
176
|
+
try {
|
|
177
|
+
const resolved = bun.resolveSync?.(args.path, parent) ?? resolve(parent, args.path);
|
|
178
|
+
const filePath = resolvedFilePath(resolved, configDir);
|
|
179
|
+
if (filePath)
|
|
180
|
+
return { path: filePath };
|
|
181
|
+
} catch {}
|
|
182
|
+
return { path: args.path, namespace: UNRESOLVED_NAMESPACE };
|
|
297
183
|
});
|
|
298
184
|
build.onLoad({ filter: /.*/, namespace: UNRESOLVED_NAMESPACE }, (args) => ({
|
|
299
185
|
loader: "js",
|
|
300
186
|
contents: `module.exports = {};
|
|
301
|
-
throw new Error(${JSON.stringify(`Failed to bundle ${configPath}: Could not resolve
|
|
187
|
+
throw new Error(${JSON.stringify(`Failed to bundle ${configPath}: Could not resolve local import "${args.path}". Maybe you need to fix a relative import in rig.config.ts or install project deps.`)});
|
|
302
188
|
`
|
|
303
189
|
}));
|
|
304
190
|
}
|
|
@@ -308,8 +194,8 @@ throw new Error(${JSON.stringify(`Failed to bundle ${configPath}: Could not reso
|
|
|
308
194
|
target: "bun",
|
|
309
195
|
format: "esm",
|
|
310
196
|
throw: false,
|
|
311
|
-
|
|
312
|
-
plugins: [
|
|
197
|
+
packages: "external",
|
|
198
|
+
plugins: [unresolvedLocalPlugin]
|
|
313
199
|
});
|
|
314
200
|
if (!result.success || !result.outputs[0]) {
|
|
315
201
|
const detail = result.logs.map((log) => String(log)).join(`
|
|
@@ -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
|
}
|