fix(codex): support packaged lazycodex installs
This commit is contained in:
@@ -6,9 +6,11 @@ import { exists, isRecord } from "./utils.mjs";
|
||||
import { COMMAND_SHIM_MARKER } from "./command-shim.mjs";
|
||||
import { removeLegacyCodexComponentBins } from "./legacy-bins.mjs";
|
||||
|
||||
export async function installCachedPlugin({ codexHome, marketplaceName, name, runCommand, sourcePath, version }) {
|
||||
await maybeRunNpmInstall(sourcePath, runCommand);
|
||||
await maybeRunNpmBuild(sourcePath, runCommand);
|
||||
export async function installCachedPlugin({ buildSource = true, codexHome, marketplaceName, name, runCommand, sourcePath, version }) {
|
||||
if (buildSource) {
|
||||
await maybeRunNpmInstall(sourcePath, runCommand);
|
||||
await maybeRunNpmBuild(sourcePath, runCommand);
|
||||
}
|
||||
|
||||
const targetPath = join(codexHome, "plugins", "cache", marketplaceName, name, version);
|
||||
await replaceDirectory(sourcePath, targetPath, shouldCopyPluginPath);
|
||||
|
||||
@@ -40,7 +40,7 @@ function resolveExternalMcpPackageRoot(runtimePath, sourceRoot) {
|
||||
if (!isPathInside(runtimePath, packagesRoot)) return undefined;
|
||||
let packageRoot = dirname(runtimePath);
|
||||
while (packageRoot !== packagesRoot) {
|
||||
if (existsSync(join(packageRoot, "package.json")) && isPathInside(runtimePath, join(packageRoot, "dist"))) {
|
||||
if (isPathInside(runtimePath, join(packageRoot, "dist")) && isRuntimePackageRoot(packageRoot)) {
|
||||
return packageRoot;
|
||||
}
|
||||
const parent = dirname(packageRoot);
|
||||
@@ -50,6 +50,10 @@ function resolveExternalMcpPackageRoot(runtimePath, sourceRoot) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isRuntimePackageRoot(packageRoot) {
|
||||
return existsSync(join(packageRoot, "package.json")) || existsSync(join(packageRoot, "dist"));
|
||||
}
|
||||
|
||||
function findPackagesRoot(path) {
|
||||
let current = resolve(path);
|
||||
for (let index = 0; index < 8; index++) {
|
||||
|
||||
Reference in New Issue
Block a user