@h-rig/core 0.0.6-alpha.144 → 0.0.6-alpha.146

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/index.js CHANGED
@@ -423,7 +423,6 @@ function buildRigInitConfigSource(input) {
423
423
  const lines = [`import { defineConfig } from "@rig/core/config";`];
424
424
  if (input.useStandardPlugin) {
425
425
  lines.push(`import { standardPlugins } from "@rig/standard-plugin/bundle";`);
426
- lines.push(`import { createRigCliSurfacePlugin } from "@rig/cli/surface-plugin";`);
427
426
  if (input.taskSource.kind === "github-issues") {
428
427
  lines.push(`import { createStateGitHubCredentialProvider } from "@rig/standard-plugin";`);
429
428
  }
@@ -432,7 +431,7 @@ function buildRigInitConfigSource(input) {
432
431
  const projectRepo = input.projectRepo ?? (input.taskSource.kind === "github-issues" ? `${input.taskSource.owner}/${input.taskSource.repo}` : undefined);
433
432
  lines.push(projectRepo ? ` project: { name: ${JSON.stringify(input.projectName)}, repo: ${JSON.stringify(projectRepo)} },` : ` project: { name: ${JSON.stringify(input.projectName)} },`);
434
433
  if (input.useStandardPlugin && input.taskSource.kind === "github-issues") {
435
- lines.push(` plugins: [createRigCliSurfacePlugin(), ...standardPlugins({`);
434
+ lines.push(` plugins: [...standardPlugins({`);
436
435
  lines.push(` taskSources: {`);
437
436
  lines.push(` githubCredentialProvider: createStateGitHubCredentialProvider(),`);
438
437
  lines.push(` githubWorkspaceId: ${JSON.stringify(`${input.taskSource.owner}/${input.taskSource.repo}`)},`);
@@ -440,7 +439,7 @@ function buildRigInitConfigSource(input) {
440
439
  lines.push(` },`);
441
440
  lines.push(` })],`);
442
441
  } else {
443
- lines.push(` plugins: [${input.useStandardPlugin ? "createRigCliSurfacePlugin(), ...standardPlugins()" : ""}],`);
442
+ lines.push(` plugins: [${input.useStandardPlugin ? "...standardPlugins()" : ""}],`);
444
443
  }
445
444
  if (input.taskSource.kind === "github-issues") {
446
445
  lines.push(` taskSource: {`);
@@ -88,6 +88,35 @@ 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
+ }
91
120
  function resolveDirectoryModulePath(directoryPath) {
92
121
  const packageJsonPath = join(directoryPath, "package.json");
93
122
  if (existsSync(packageJsonPath)) {
@@ -128,6 +157,38 @@ function resolveModulePath(candidatePath) {
128
157
  }
129
158
  return null;
130
159
  }
160
+ function resolvePackageExportFromDir(packageDir, subpath) {
161
+ const packageJsonPath = join(packageDir, "package.json");
162
+ if (existsSync(packageJsonPath)) {
163
+ try {
164
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
165
+ const target = exportTargetFromPackageJson(pkg, subpath);
166
+ if (target) {
167
+ const resolved = resolveModulePath(join(packageDir, target));
168
+ if (resolved)
169
+ return resolved;
170
+ }
171
+ } catch {
172
+ return null;
173
+ }
174
+ }
175
+ if (subpath !== ".") {
176
+ const legacySubpath = subpath.replace(/^\.\//, "");
177
+ for (const candidate of [
178
+ join(packageDir, legacySubpath),
179
+ join(packageDir, `${legacySubpath}.js`),
180
+ join(packageDir, `${legacySubpath}.mjs`),
181
+ join(packageDir, `${legacySubpath}.cjs`),
182
+ join(packageDir, `${legacySubpath}.ts`),
183
+ join(packageDir, `${legacySubpath}.json`)
184
+ ]) {
185
+ const resolved = resolveModulePath(candidate);
186
+ if (resolved)
187
+ return resolved;
188
+ }
189
+ }
190
+ return subpath === "." ? resolveDirectoryModulePath(packageDir) : null;
191
+ }
131
192
  var runtimeBundleQueue = Promise.resolve();
132
193
  function enqueueRuntimeBundle(operation) {
133
194
  const next = runtimeBundleQueue.then(operation, operation);
@@ -150,6 +211,15 @@ function resolvedFilePath(path, rootPath) {
150
211
  return null;
151
212
  return rootPath && !isWithinDir(resolved, rootPath) ? null : resolved;
152
213
  }
214
+ function resolveProjectRigPackageImport(specifier, configDir) {
215
+ const parsed = packageNameAndSubpath(specifier);
216
+ if (!parsed?.packageName.startsWith("@rig/"))
217
+ return null;
218
+ const nodeModulesDir = join(configDir, "node_modules");
219
+ const directPackageDir = join(nodeModulesDir, parsed.packageName);
220
+ const packageDir = existsSync(join(directPackageDir, "package.json")) ? directPackageDir : resolvePackageDirFromBunStore(parsed.packageName, nodeModulesDir);
221
+ return packageDir ? resolvePackageExportFromDir(packageDir, parsed.subpath) : null;
222
+ }
153
223
  async function importConfigViaRuntimeBundleUnserialized(configPath) {
154
224
  const bun = globalThis.Bun;
155
225
  if (!bun?.build) {
@@ -164,6 +234,9 @@ async function importConfigViaRuntimeBundleUnserialized(configPath) {
164
234
  const directFilePath = resolvedFilePath(args.path, configDir);
165
235
  if (directFilePath)
166
236
  return { path: directFilePath };
237
+ const projectRigPackagePath = resolveProjectRigPackageImport(args.path, configDir);
238
+ if (projectRigPackagePath)
239
+ return { path: projectRigPackagePath, external: true };
167
240
  if (/^(?:node|bun):/.test(args.path) || isBuiltin(args.path) || packageNameAndSubpath(args.path))
168
241
  return;
169
242
  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];
@@ -4,7 +4,6 @@ function buildRigInitConfigSource(input) {
4
4
  const lines = [`import { defineConfig } from "@rig/core/config";`];
5
5
  if (input.useStandardPlugin) {
6
6
  lines.push(`import { standardPlugins } from "@rig/standard-plugin/bundle";`);
7
- lines.push(`import { createRigCliSurfacePlugin } from "@rig/cli/surface-plugin";`);
8
7
  if (input.taskSource.kind === "github-issues") {
9
8
  lines.push(`import { createStateGitHubCredentialProvider } from "@rig/standard-plugin";`);
10
9
  }
@@ -13,7 +12,7 @@ function buildRigInitConfigSource(input) {
13
12
  const projectRepo = input.projectRepo ?? (input.taskSource.kind === "github-issues" ? `${input.taskSource.owner}/${input.taskSource.repo}` : undefined);
14
13
  lines.push(projectRepo ? ` project: { name: ${JSON.stringify(input.projectName)}, repo: ${JSON.stringify(projectRepo)} },` : ` project: { name: ${JSON.stringify(input.projectName)} },`);
15
14
  if (input.useStandardPlugin && input.taskSource.kind === "github-issues") {
16
- lines.push(` plugins: [createRigCliSurfacePlugin(), ...standardPlugins({`);
15
+ lines.push(` plugins: [...standardPlugins({`);
17
16
  lines.push(` taskSources: {`);
18
17
  lines.push(` githubCredentialProvider: createStateGitHubCredentialProvider(),`);
19
18
  lines.push(` githubWorkspaceId: ${JSON.stringify(`${input.taskSource.owner}/${input.taskSource.repo}`)},`);
@@ -21,7 +20,7 @@ function buildRigInitConfigSource(input) {
21
20
  lines.push(` },`);
22
21
  lines.push(` })],`);
23
22
  } else {
24
- lines.push(` plugins: [${input.useStandardPlugin ? "createRigCliSurfacePlugin(), ...standardPlugins()" : ""}],`);
23
+ lines.push(` plugins: [${input.useStandardPlugin ? "...standardPlugins()" : ""}],`);
25
24
  }
26
25
  if (input.taskSource.kind === "github-issues") {
27
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.144",
3
+ "version": "0.0.6-alpha.146",
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",
@@ -49,7 +49,7 @@
49
49
  "module": "./dist/src/index.js",
50
50
  "types": "./dist/src/index.d.ts",
51
51
  "dependencies": {
52
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.144",
52
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.146",
53
53
  "effect": "4.0.0-beta.90"
54
54
  }
55
55
  }