ocx 2.0.1 → 2.0.2
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/index.js +91 -32
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6098,7 +6098,7 @@ var package_default;
|
|
|
6098
6098
|
var init_package = __esm(() => {
|
|
6099
6099
|
package_default = {
|
|
6100
6100
|
name: "ocx",
|
|
6101
|
-
version: "2.0.
|
|
6101
|
+
version: "2.0.2",
|
|
6102
6102
|
description: "OCX CLI - ShadCN-style registry for OpenCode extensions. Install agents, plugins, skills, and MCP servers.",
|
|
6103
6103
|
author: "kdcokenny",
|
|
6104
6104
|
license: "MIT",
|
|
@@ -16771,7 +16771,7 @@ async function copyDir(src, dest) {
|
|
|
16771
16771
|
}
|
|
16772
16772
|
function getReleaseTag() {
|
|
16773
16773
|
if (false) {}
|
|
16774
|
-
return `v${"2.0.
|
|
16774
|
+
return `v${"2.0.2"}`;
|
|
16775
16775
|
}
|
|
16776
16776
|
function getTemplateUrl(version) {
|
|
16777
16777
|
const ref = version === "main" ? "heads/main" : `tags/${version}`;
|
|
@@ -17494,6 +17494,9 @@ async function applyConfigNormalizationToFile(root, actions) {
|
|
|
17494
17494
|
await writeFile3(configInfo.path, content2);
|
|
17495
17495
|
}
|
|
17496
17496
|
|
|
17497
|
+
// src/commands/opencode.ts
|
|
17498
|
+
import * as path8 from "path";
|
|
17499
|
+
|
|
17497
17500
|
// src/utils/terminal-title.ts
|
|
17498
17501
|
import path7 from "path";
|
|
17499
17502
|
var MAX_BRANCH_LENGTH = 20;
|
|
@@ -18166,17 +18169,62 @@ function dedupeLastWins(items) {
|
|
|
18166
18169
|
function resolveOpenCodeBinary(opts) {
|
|
18167
18170
|
return opts.configBin ?? opts.envBin ?? "opencode";
|
|
18168
18171
|
}
|
|
18172
|
+
function isPathLikeLauncherToken(token) {
|
|
18173
|
+
return token.includes("/") || token.includes("\\");
|
|
18174
|
+
}
|
|
18175
|
+
function resolveStableOpenCodeLauncherPath(opts) {
|
|
18176
|
+
const { configuredBin, cwd } = opts;
|
|
18177
|
+
const resolveExecutable = opts.resolveExecutable ?? ((command) => Bun.which(command));
|
|
18178
|
+
if (!configuredBin.trim()) {
|
|
18179
|
+
throw new Error("OpenCode launcher is empty and cannot be resolved to a stable path");
|
|
18180
|
+
}
|
|
18181
|
+
if (isPathLikeLauncherToken(configuredBin)) {
|
|
18182
|
+
return path8.isAbsolute(configuredBin) ? configuredBin : path8.resolve(cwd, configuredBin);
|
|
18183
|
+
}
|
|
18184
|
+
const resolvedFromPath = resolveExecutable(configuredBin);
|
|
18185
|
+
if (!resolvedFromPath) {
|
|
18186
|
+
throw new Error(`OpenCode launcher "${configuredBin}" is not available in PATH and cannot be used as OPENCODE_BIN`);
|
|
18187
|
+
}
|
|
18188
|
+
return path8.isAbsolute(resolvedFromPath) ? resolvedFromPath : path8.resolve(cwd, resolvedFromPath);
|
|
18189
|
+
}
|
|
18190
|
+
function resolveStableOcxExecutablePath(opts) {
|
|
18191
|
+
const resolveExecutable = opts.resolveExecutable ?? ((command) => Bun.which(command));
|
|
18192
|
+
const argv = opts.argv ?? process.argv;
|
|
18193
|
+
const execPath = opts.execPath ?? process.execPath;
|
|
18194
|
+
const isCompiledBinary = opts.isCompiledBinary ?? (typeof Bun !== "undefined" && typeof Bun.main === "string" && Bun.main.startsWith("/$bunfs/"));
|
|
18195
|
+
const inheritedOcxBin = opts.inheritedOcxBin?.trim();
|
|
18196
|
+
const runtimeExecutable = isCompiledBinary ? execPath : argv[1];
|
|
18197
|
+
const candidate = inheritedOcxBin && inheritedOcxBin.length > 0 ? inheritedOcxBin : runtimeExecutable;
|
|
18198
|
+
if (!candidate?.trim()) {
|
|
18199
|
+
throw new Error("OCX executable path is empty and cannot be resolved from the current process");
|
|
18200
|
+
}
|
|
18201
|
+
if (isPathLikeLauncherToken(candidate)) {
|
|
18202
|
+
return path8.isAbsolute(candidate) ? candidate : path8.resolve(opts.cwd, candidate);
|
|
18203
|
+
}
|
|
18204
|
+
const resolvedFromPath = resolveExecutable(candidate);
|
|
18205
|
+
if (!resolvedFromPath) {
|
|
18206
|
+
throw new Error(`OCX executable "${candidate}" is not available in PATH and cannot be persisted as OCX_BIN`);
|
|
18207
|
+
}
|
|
18208
|
+
return path8.isAbsolute(resolvedFromPath) ? resolvedFromPath : path8.resolve(opts.cwd, resolvedFromPath);
|
|
18209
|
+
}
|
|
18169
18210
|
function buildOpenCodeEnv(opts) {
|
|
18170
18211
|
const hasProfile = Boolean(opts.profileName);
|
|
18171
18212
|
const {
|
|
18172
18213
|
OPENCODE_DISABLE_PROJECT_CONFIG: _inheritedDisableProjectConfig,
|
|
18214
|
+
OPENCODE_BIN: _inheritedOpencodeBin,
|
|
18215
|
+
OCX_CONTEXT: _inheritedOcxContext,
|
|
18216
|
+
OCX_BIN: _inheritedOcxBin,
|
|
18217
|
+
OCX_PROFILE: _inheritedOcxProfile,
|
|
18173
18218
|
...baseEnvWithoutDisableProjectConfig
|
|
18174
18219
|
} = opts.baseEnv;
|
|
18175
18220
|
return {
|
|
18176
18221
|
...baseEnvWithoutDisableProjectConfig,
|
|
18222
|
+
...opts.opencodeBin !== undefined && { OPENCODE_BIN: opts.opencodeBin },
|
|
18177
18223
|
...hasProfile && { OPENCODE_DISABLE_PROJECT_CONFIG: "true" },
|
|
18178
18224
|
OPENCODE_CONFIG_DIR: opts.configDir ?? (hasProfile ? getProfileDir(opts.profileName) : getGlobalConfigPath()),
|
|
18179
18225
|
...opts.configContent && { OPENCODE_CONFIG_CONTENT: opts.configContent },
|
|
18226
|
+
...hasProfile && { OCX_CONTEXT: "1" },
|
|
18227
|
+
...hasProfile && opts.ocxBin && { OCX_BIN: opts.ocxBin },
|
|
18180
18228
|
...opts.profileName && { OCX_PROFILE: opts.profileName }
|
|
18181
18229
|
};
|
|
18182
18230
|
}
|
|
@@ -18269,18 +18317,29 @@ async function runOpencode(args, options2) {
|
|
|
18269
18317
|
childExitCode = preSpawnSignalExitCode;
|
|
18270
18318
|
return;
|
|
18271
18319
|
}
|
|
18272
|
-
const
|
|
18320
|
+
const configuredBin = resolveOpenCodeBinary({
|
|
18273
18321
|
configBin: ocxConfig?.bin,
|
|
18274
18322
|
envBin: process.env.OPENCODE_BIN
|
|
18275
18323
|
});
|
|
18324
|
+
const hasProfileLaunchContext = Boolean(config.profileName);
|
|
18325
|
+
const resolvedOpenCodeLaunchBin = hasProfileLaunchContext ? resolveStableOpenCodeLauncherPath({
|
|
18326
|
+
configuredBin,
|
|
18327
|
+
cwd: projectDir
|
|
18328
|
+
}) : configuredBin;
|
|
18329
|
+
const resolvedOcxBin = hasProfileLaunchContext ? resolveStableOcxExecutablePath({
|
|
18330
|
+
cwd: projectDir,
|
|
18331
|
+
inheritedOcxBin: process.env.OCX_BIN
|
|
18332
|
+
}) : undefined;
|
|
18276
18333
|
const configContent = configToPass ? JSON.stringify(configToPass) : undefined;
|
|
18277
18334
|
try {
|
|
18278
18335
|
proc = Bun.spawn({
|
|
18279
|
-
cmd: [
|
|
18336
|
+
cmd: [resolvedOpenCodeLaunchBin, ...args],
|
|
18280
18337
|
cwd: projectDir,
|
|
18281
18338
|
env: buildOpenCodeEnv({
|
|
18282
18339
|
baseEnv: process.env,
|
|
18283
18340
|
profileName: config.profileName ?? undefined,
|
|
18341
|
+
ocxBin: resolvedOcxBin,
|
|
18342
|
+
opencodeBin: resolvedOpenCodeLaunchBin,
|
|
18284
18343
|
configDir: mergedConfig?.path,
|
|
18285
18344
|
configContent
|
|
18286
18345
|
}),
|
|
@@ -18289,7 +18348,7 @@ async function runOpencode(args, options2) {
|
|
|
18289
18348
|
stderr: "inherit"
|
|
18290
18349
|
});
|
|
18291
18350
|
} catch (error) {
|
|
18292
|
-
throw createOpencodeOcError("spawn", `Failed to launch OpenCode binary "${
|
|
18351
|
+
throw createOpencodeOcError("spawn", `Failed to launch OpenCode binary "${configuredBin}": ${error instanceof Error ? error.message : String(error)}`);
|
|
18293
18352
|
}
|
|
18294
18353
|
childExitCode = await proc.exited;
|
|
18295
18354
|
} catch (error) {
|
|
@@ -19749,7 +19808,7 @@ async function runSearchCore(query, options2, provider) {
|
|
|
19749
19808
|
// src/commands/self/uninstall.ts
|
|
19750
19809
|
import { existsSync as existsSync16, lstatSync as lstatSync2, readdirSync as readdirSync2, realpathSync as realpathSync2, rmSync, unlinkSync } from "fs";
|
|
19751
19810
|
import { homedir as homedir5 } from "os";
|
|
19752
|
-
import
|
|
19811
|
+
import path9 from "path";
|
|
19753
19812
|
|
|
19754
19813
|
// src/self-update/detect-method.ts
|
|
19755
19814
|
init_errors2();
|
|
@@ -19763,11 +19822,11 @@ Valid methods: ${VALID_METHODS.join(", ")}`);
|
|
|
19763
19822
|
return method;
|
|
19764
19823
|
}
|
|
19765
19824
|
var isCompiledBinary = () => Bun.main.startsWith("/$bunfs/");
|
|
19766
|
-
var isTempExecution = (
|
|
19767
|
-
var isYarnGlobalInstall = (
|
|
19768
|
-
var isPnpmGlobalInstall = (
|
|
19769
|
-
var isBunGlobalInstall = (
|
|
19770
|
-
var isNpmGlobalInstall = (
|
|
19825
|
+
var isTempExecution = (path9) => path9.includes("/_npx/") || path9.includes("/.cache/bunx/") || path9.includes("/.pnpm/_temp/");
|
|
19826
|
+
var isYarnGlobalInstall = (path9) => path9.includes("/.yarn/global") || path9.includes("/.config/yarn/global");
|
|
19827
|
+
var isPnpmGlobalInstall = (path9) => path9.includes("/.pnpm/") || path9.includes("/pnpm/global");
|
|
19828
|
+
var isBunGlobalInstall = (path9) => path9.includes("/.bun/bin") || path9.includes("/.bun/install/global");
|
|
19829
|
+
var isNpmGlobalInstall = (path9) => path9.includes("/.npm/") || path9.includes("/node_modules/");
|
|
19771
19830
|
function detectInstallMethod() {
|
|
19772
19831
|
if (isCompiledBinary()) {
|
|
19773
19832
|
return "curl";
|
|
@@ -19836,16 +19895,16 @@ function tildify(absolutePath) {
|
|
|
19836
19895
|
return absolutePath;
|
|
19837
19896
|
if (absolutePath === home)
|
|
19838
19897
|
return "~";
|
|
19839
|
-
if (absolutePath.startsWith(home +
|
|
19898
|
+
if (absolutePath.startsWith(home + path9.sep)) {
|
|
19840
19899
|
return `~${absolutePath.slice(home.length)}`;
|
|
19841
19900
|
}
|
|
19842
19901
|
return absolutePath;
|
|
19843
19902
|
}
|
|
19844
19903
|
function getRelativePathIfContained(parent, child) {
|
|
19845
|
-
const normalizedParent =
|
|
19846
|
-
const normalizedChild =
|
|
19847
|
-
const relative8 =
|
|
19848
|
-
if (relative8.startsWith("..") ||
|
|
19904
|
+
const normalizedParent = path9.normalize(parent);
|
|
19905
|
+
const normalizedChild = path9.normalize(child);
|
|
19906
|
+
const relative8 = path9.relative(normalizedParent, normalizedChild);
|
|
19907
|
+
if (relative8.startsWith("..") || path9.isAbsolute(relative8)) {
|
|
19849
19908
|
return null;
|
|
19850
19909
|
}
|
|
19851
19910
|
return relative8;
|
|
@@ -19949,8 +20008,8 @@ function getPackageManagerCommand(method) {
|
|
|
19949
20008
|
}
|
|
19950
20009
|
}
|
|
19951
20010
|
function getGlobalConfigRoot() {
|
|
19952
|
-
const base = process.env.XDG_CONFIG_HOME ||
|
|
19953
|
-
return
|
|
20011
|
+
const base = process.env.XDG_CONFIG_HOME || path9.join(homedir5(), ".config");
|
|
20012
|
+
return path9.join(base, "opencode");
|
|
19954
20013
|
}
|
|
19955
20014
|
function buildConfigTargets() {
|
|
19956
20015
|
const rootPath = getGlobalConfigRoot();
|
|
@@ -20003,10 +20062,10 @@ function buildBinaryTarget() {
|
|
|
20003
20062
|
if (method === "curl") {
|
|
20004
20063
|
const binaryPath = getExecutablePath();
|
|
20005
20064
|
const kind = getPathKind(binaryPath);
|
|
20006
|
-
const parentDir =
|
|
20065
|
+
const parentDir = path9.dirname(binaryPath);
|
|
20007
20066
|
return {
|
|
20008
20067
|
rootPath: parentDir,
|
|
20009
|
-
relativePath:
|
|
20068
|
+
relativePath: path9.basename(binaryPath),
|
|
20010
20069
|
absolutePath: binaryPath,
|
|
20011
20070
|
displayPath: tildify(binaryPath),
|
|
20012
20071
|
kind,
|
|
@@ -20052,8 +20111,8 @@ function executeRemovals(targets) {
|
|
|
20052
20111
|
}
|
|
20053
20112
|
function removeBinary(binaryPath, options2 = {}) {
|
|
20054
20113
|
const target = {
|
|
20055
|
-
rootPath:
|
|
20056
|
-
relativePath:
|
|
20114
|
+
rootPath: path9.dirname(binaryPath),
|
|
20115
|
+
relativePath: path9.basename(binaryPath),
|
|
20057
20116
|
absolutePath: binaryPath,
|
|
20058
20117
|
displayPath: tildify(binaryPath),
|
|
20059
20118
|
kind: getPathKind(binaryPath),
|
|
@@ -20348,7 +20407,7 @@ init_errors2();
|
|
|
20348
20407
|
|
|
20349
20408
|
// src/self-update/version-provider.ts
|
|
20350
20409
|
class BuildTimeVersionProvider {
|
|
20351
|
-
version = "2.0.
|
|
20410
|
+
version = "2.0.2";
|
|
20352
20411
|
}
|
|
20353
20412
|
var defaultVersionProvider = new BuildTimeVersionProvider;
|
|
20354
20413
|
|
|
@@ -21154,7 +21213,7 @@ function outputUpdateDryRun(results, options2) {
|
|
|
21154
21213
|
}
|
|
21155
21214
|
|
|
21156
21215
|
// src/commands/validate.ts
|
|
21157
|
-
import { resolve as
|
|
21216
|
+
import { resolve as resolve8 } from "path";
|
|
21158
21217
|
init_errors2();
|
|
21159
21218
|
function createLoadValidationError2(message, errorKind) {
|
|
21160
21219
|
if (errorKind === "not_found") {
|
|
@@ -21190,9 +21249,9 @@ function outputValidationErrors(errors3) {
|
|
|
21190
21249
|
}
|
|
21191
21250
|
}
|
|
21192
21251
|
function registerValidateCommand(program2) {
|
|
21193
|
-
program2.command("validate").description("Validate a registry source (for registry authors)").argument("[path]", "Registry source directory", ".").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).option("--no-duplicate-targets", "Skip duplicate target validation").action(async (
|
|
21252
|
+
program2.command("validate").description("Validate a registry source (for registry authors)").argument("[path]", "Registry source directory", ".").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).option("--no-duplicate-targets", "Skip duplicate target validation").action(async (path10, options2) => {
|
|
21194
21253
|
try {
|
|
21195
|
-
const sourcePath =
|
|
21254
|
+
const sourcePath = resolve8(options2.cwd, path10);
|
|
21196
21255
|
const validationResult = await runCompleteValidation(sourcePath, {
|
|
21197
21256
|
skipDuplicateTargets: options2.duplicateTargets === false
|
|
21198
21257
|
});
|
|
@@ -21315,11 +21374,11 @@ async function runVerify(componentNames, options2) {
|
|
|
21315
21374
|
}
|
|
21316
21375
|
} else {
|
|
21317
21376
|
logger.error(`\u2717 ${result.canonicalId} - integrity check failed`);
|
|
21318
|
-
for (const
|
|
21319
|
-
logger.error(` Modified: ${
|
|
21377
|
+
for (const path10 of result.modified) {
|
|
21378
|
+
logger.error(` Modified: ${path10}`);
|
|
21320
21379
|
}
|
|
21321
|
-
for (const
|
|
21322
|
-
logger.error(` Missing: ${
|
|
21380
|
+
for (const path10 of result.missing) {
|
|
21381
|
+
logger.error(` Missing: ${path10}`);
|
|
21323
21382
|
}
|
|
21324
21383
|
}
|
|
21325
21384
|
}
|
|
@@ -21369,7 +21428,7 @@ function registerUpdateCheckHook(program2) {
|
|
|
21369
21428
|
});
|
|
21370
21429
|
}
|
|
21371
21430
|
// src/index.ts
|
|
21372
|
-
var version = "2.0.
|
|
21431
|
+
var version = "2.0.2";
|
|
21373
21432
|
async function main2() {
|
|
21374
21433
|
const program2 = new Command().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(version);
|
|
21375
21434
|
registerInitCommand(program2);
|
|
@@ -21403,4 +21462,4 @@ export {
|
|
|
21403
21462
|
buildRegistry
|
|
21404
21463
|
};
|
|
21405
21464
|
|
|
21406
|
-
//# debugId=
|
|
21465
|
+
//# debugId=F324B1CA6BEB983B64756E2164756E21
|