ocx 1.0.11 → 1.0.13
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 +180 -146
- package/dist/index.js.map +8 -8
- package/package.json +62 -63
package/dist/index.js
CHANGED
|
@@ -8486,7 +8486,7 @@ var coerce = {
|
|
|
8486
8486
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
8487
8487
|
};
|
|
8488
8488
|
var NEVER = INVALID;
|
|
8489
|
-
//
|
|
8489
|
+
// src/schemas/registry.ts
|
|
8490
8490
|
var openCodeNameSchema = exports_external.string().min(1, "Name cannot be empty").max(64, "Name cannot exceed 64 characters").regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, {
|
|
8491
8491
|
message: "Must be lowercase alphanumeric with single hyphen separators (e.g., 'my-component', 'my-plugin'). Cannot start/end with hyphen or have consecutive hyphens."
|
|
8492
8492
|
});
|
|
@@ -8671,28 +8671,6 @@ var registryIndexSchema = exports_external.object({
|
|
|
8671
8671
|
}))
|
|
8672
8672
|
});
|
|
8673
8673
|
|
|
8674
|
-
// ../schemas/dist/config.js
|
|
8675
|
-
var registryConfigSchema = exports_external.object({
|
|
8676
|
-
url: exports_external.string().url("Registry URL must be a valid URL"),
|
|
8677
|
-
version: exports_external.string().optional(),
|
|
8678
|
-
headers: exports_external.record(exports_external.string()).optional()
|
|
8679
|
-
});
|
|
8680
|
-
var ocxConfigSchema = exports_external.object({
|
|
8681
|
-
$schema: exports_external.string().optional(),
|
|
8682
|
-
registries: exports_external.record(registryConfigSchema).default({}),
|
|
8683
|
-
lockRegistries: exports_external.boolean().default(false)
|
|
8684
|
-
});
|
|
8685
|
-
var installedComponentSchema = exports_external.object({
|
|
8686
|
-
registry: exports_external.string(),
|
|
8687
|
-
version: exports_external.string(),
|
|
8688
|
-
hash: exports_external.string(),
|
|
8689
|
-
files: exports_external.array(exports_external.string()),
|
|
8690
|
-
installedAt: exports_external.string()
|
|
8691
|
-
});
|
|
8692
|
-
var ocxLockSchema = exports_external.object({
|
|
8693
|
-
lockVersion: exports_external.literal(1),
|
|
8694
|
-
installed: exports_external.record(qualifiedComponentSchema, installedComponentSchema).default({})
|
|
8695
|
-
});
|
|
8696
8674
|
// src/utils/errors.ts
|
|
8697
8675
|
var EXIT_CODES = {
|
|
8698
8676
|
SUCCESS: 0,
|
|
@@ -10279,6 +10257,27 @@ function applyEdits(text, edits) {
|
|
|
10279
10257
|
}
|
|
10280
10258
|
|
|
10281
10259
|
// src/schemas/config.ts
|
|
10260
|
+
var registryConfigSchema = exports_external.object({
|
|
10261
|
+
url: exports_external.string().url("Registry URL must be a valid URL"),
|
|
10262
|
+
version: exports_external.string().optional(),
|
|
10263
|
+
headers: exports_external.record(exports_external.string()).optional()
|
|
10264
|
+
});
|
|
10265
|
+
var ocxConfigSchema = exports_external.object({
|
|
10266
|
+
$schema: exports_external.string().optional(),
|
|
10267
|
+
registries: exports_external.record(registryConfigSchema).default({}),
|
|
10268
|
+
lockRegistries: exports_external.boolean().default(false)
|
|
10269
|
+
});
|
|
10270
|
+
var installedComponentSchema = exports_external.object({
|
|
10271
|
+
registry: exports_external.string(),
|
|
10272
|
+
version: exports_external.string(),
|
|
10273
|
+
hash: exports_external.string(),
|
|
10274
|
+
files: exports_external.array(exports_external.string()),
|
|
10275
|
+
installedAt: exports_external.string()
|
|
10276
|
+
});
|
|
10277
|
+
var ocxLockSchema = exports_external.object({
|
|
10278
|
+
lockVersion: exports_external.literal(1),
|
|
10279
|
+
installed: exports_external.record(qualifiedComponentSchema, installedComponentSchema).default({})
|
|
10280
|
+
});
|
|
10282
10281
|
var CONFIG_FILE = "ocx.jsonc";
|
|
10283
10282
|
var LOCK_FILE = "ocx.lock";
|
|
10284
10283
|
async function readOcxConfig(cwd) {
|
|
@@ -10296,9 +10295,9 @@ async function readOcxConfig(cwd) {
|
|
|
10296
10295
|
throw error;
|
|
10297
10296
|
}
|
|
10298
10297
|
}
|
|
10299
|
-
async function writeOcxConfig(cwd,
|
|
10298
|
+
async function writeOcxConfig(cwd, config) {
|
|
10300
10299
|
const configPath = `${cwd}/${CONFIG_FILE}`;
|
|
10301
|
-
const content = JSON.stringify(
|
|
10300
|
+
const content = JSON.stringify(config, null, 2);
|
|
10302
10301
|
await Bun.write(configPath, content);
|
|
10303
10302
|
}
|
|
10304
10303
|
async function readOcxLock(cwd) {
|
|
@@ -10367,8 +10366,8 @@ async function updateOpencodeJsonConfig(cwd, opencode) {
|
|
|
10367
10366
|
content = existing.content;
|
|
10368
10367
|
configPath = existing.path;
|
|
10369
10368
|
} else {
|
|
10370
|
-
const
|
|
10371
|
-
content = JSON.stringify(
|
|
10369
|
+
const config = { $schema: "https://opencode.ai/config.json" };
|
|
10370
|
+
content = JSON.stringify(config, null, "\t");
|
|
10372
10371
|
configPath = `${cwd}/opencode.jsonc`;
|
|
10373
10372
|
created = true;
|
|
10374
10373
|
}
|
|
@@ -11932,8 +11931,8 @@ function registerAddCommand(program2) {
|
|
|
11932
11931
|
async function runAdd(componentNames, options2) {
|
|
11933
11932
|
const cwd = options2.cwd ?? process.cwd();
|
|
11934
11933
|
const lockPath = join(cwd, "ocx.lock");
|
|
11935
|
-
const
|
|
11936
|
-
if (!
|
|
11934
|
+
const config = await readOcxConfig(cwd);
|
|
11935
|
+
if (!config) {
|
|
11937
11936
|
throw new ConfigError("No ocx.jsonc found. Run 'ocx init' first.");
|
|
11938
11937
|
}
|
|
11939
11938
|
let lock = { lockVersion: 1, installed: {} };
|
|
@@ -11944,7 +11943,7 @@ async function runAdd(componentNames, options2) {
|
|
|
11944
11943
|
const spin = options2.quiet ? null : createSpinner({ text: "Resolving dependencies..." });
|
|
11945
11944
|
spin?.start();
|
|
11946
11945
|
try {
|
|
11947
|
-
const resolved = await resolveDependencies(
|
|
11946
|
+
const resolved = await resolveDependencies(config.registries, componentNames);
|
|
11948
11947
|
spin?.succeed(`Resolved ${resolved.components.length} components`);
|
|
11949
11948
|
if (options2.verbose) {
|
|
11950
11949
|
logger.info("Install order:");
|
|
@@ -12243,107 +12242,133 @@ function findComponentByFile(lock, filePath) {
|
|
|
12243
12242
|
}
|
|
12244
12243
|
|
|
12245
12244
|
// src/commands/build.ts
|
|
12245
|
+
import { join as join3, relative } from "path";
|
|
12246
|
+
|
|
12247
|
+
// src/lib/build-registry.ts
|
|
12246
12248
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
12247
|
-
import { dirname as dirname2, join as join2
|
|
12249
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
12250
|
+
class BuildRegistryError extends Error {
|
|
12251
|
+
errors;
|
|
12252
|
+
constructor(message, errors3 = []) {
|
|
12253
|
+
super(message);
|
|
12254
|
+
this.errors = errors3;
|
|
12255
|
+
this.name = "BuildRegistryError";
|
|
12256
|
+
}
|
|
12257
|
+
}
|
|
12258
|
+
async function buildRegistry(options2) {
|
|
12259
|
+
const { source: sourcePath, out: outPath } = options2;
|
|
12260
|
+
const registryFile = Bun.file(join2(sourcePath, "registry.json"));
|
|
12261
|
+
if (!await registryFile.exists()) {
|
|
12262
|
+
throw new BuildRegistryError("No registry.json found in source directory");
|
|
12263
|
+
}
|
|
12264
|
+
const registryData = await registryFile.json();
|
|
12265
|
+
const parseResult = registrySchema.safeParse(registryData);
|
|
12266
|
+
if (!parseResult.success) {
|
|
12267
|
+
const errors3 = parseResult.error.errors.map((e3) => `${e3.path.join(".")}: ${e3.message}`);
|
|
12268
|
+
throw new BuildRegistryError("Registry validation failed", errors3);
|
|
12269
|
+
}
|
|
12270
|
+
const registry = parseResult.data;
|
|
12271
|
+
const validationErrors = [];
|
|
12272
|
+
const componentsDir = join2(outPath, "components");
|
|
12273
|
+
await mkdir2(componentsDir, { recursive: true });
|
|
12274
|
+
for (const component of registry.components) {
|
|
12275
|
+
const packument = {
|
|
12276
|
+
name: component.name,
|
|
12277
|
+
versions: {
|
|
12278
|
+
[registry.version]: component
|
|
12279
|
+
},
|
|
12280
|
+
"dist-tags": {
|
|
12281
|
+
latest: registry.version
|
|
12282
|
+
}
|
|
12283
|
+
};
|
|
12284
|
+
const packumentPath = join2(componentsDir, `${component.name}.json`);
|
|
12285
|
+
await Bun.write(packumentPath, JSON.stringify(packument, null, 2));
|
|
12286
|
+
for (const rawFile of component.files) {
|
|
12287
|
+
const file = normalizeFile(rawFile);
|
|
12288
|
+
const sourceFilePath = join2(sourcePath, "files", file.path);
|
|
12289
|
+
const destFilePath = join2(componentsDir, component.name, file.path);
|
|
12290
|
+
const destFileDir = dirname2(destFilePath);
|
|
12291
|
+
if (!await Bun.file(sourceFilePath).exists()) {
|
|
12292
|
+
validationErrors.push(`${component.name}: Source file not found at ${sourceFilePath}`);
|
|
12293
|
+
continue;
|
|
12294
|
+
}
|
|
12295
|
+
await mkdir2(destFileDir, { recursive: true });
|
|
12296
|
+
const sourceFile = Bun.file(sourceFilePath);
|
|
12297
|
+
await Bun.write(destFilePath, sourceFile);
|
|
12298
|
+
}
|
|
12299
|
+
}
|
|
12300
|
+
if (validationErrors.length > 0) {
|
|
12301
|
+
throw new BuildRegistryError(`Build failed with ${validationErrors.length} errors`, validationErrors);
|
|
12302
|
+
}
|
|
12303
|
+
const index = {
|
|
12304
|
+
name: registry.name,
|
|
12305
|
+
namespace: registry.namespace,
|
|
12306
|
+
version: registry.version,
|
|
12307
|
+
author: registry.author,
|
|
12308
|
+
components: registry.components.map((c) => ({
|
|
12309
|
+
name: c.name,
|
|
12310
|
+
type: c.type,
|
|
12311
|
+
description: c.description
|
|
12312
|
+
}))
|
|
12313
|
+
};
|
|
12314
|
+
await Bun.write(join2(outPath, "index.json"), JSON.stringify(index, null, 2));
|
|
12315
|
+
const wellKnownDir = join2(outPath, ".well-known");
|
|
12316
|
+
await mkdir2(wellKnownDir, { recursive: true });
|
|
12317
|
+
const discovery = { registry: "/index.json" };
|
|
12318
|
+
await Bun.write(join2(wellKnownDir, "ocx.json"), JSON.stringify(discovery, null, 2));
|
|
12319
|
+
return {
|
|
12320
|
+
name: registry.name,
|
|
12321
|
+
namespace: registry.namespace,
|
|
12322
|
+
version: registry.version,
|
|
12323
|
+
componentsCount: registry.components.length,
|
|
12324
|
+
outputPath: outPath
|
|
12325
|
+
};
|
|
12326
|
+
}
|
|
12327
|
+
|
|
12328
|
+
// src/commands/build.ts
|
|
12248
12329
|
function registerBuildCommand(program2) {
|
|
12249
12330
|
program2.command("build").description("Build a registry from source (for registry authors)").argument("[path]", "Registry source directory", ".").option("--out <dir>", "Output directory", "./dist").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (path, options2) => {
|
|
12250
12331
|
try {
|
|
12251
|
-
const sourcePath =
|
|
12252
|
-
const outPath =
|
|
12332
|
+
const sourcePath = join3(options2.cwd, path);
|
|
12333
|
+
const outPath = join3(options2.cwd, options2.out);
|
|
12253
12334
|
const spinner2 = createSpinner({
|
|
12254
12335
|
text: "Building registry...",
|
|
12255
12336
|
quiet: options2.quiet || options2.json
|
|
12256
12337
|
});
|
|
12257
12338
|
if (!options2.json)
|
|
12258
12339
|
spinner2.start();
|
|
12259
|
-
const
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
process.exit(1);
|
|
12264
|
-
}
|
|
12265
|
-
const registryData = await registryFile.json();
|
|
12266
|
-
const parseResult = registrySchema.safeParse(registryData);
|
|
12267
|
-
if (!parseResult.success) {
|
|
12268
|
-
if (!options2.json) {
|
|
12269
|
-
spinner2.fail("Registry validation failed");
|
|
12270
|
-
const errors3 = parseResult.error.errors.map((e3) => ` ${e3.path.join(".")}: ${e3.message}`);
|
|
12271
|
-
for (const err of errors3) {
|
|
12272
|
-
console.log(kleur_default.red(err));
|
|
12273
|
-
}
|
|
12274
|
-
}
|
|
12275
|
-
process.exit(1);
|
|
12276
|
-
}
|
|
12277
|
-
const registry2 = parseResult.data;
|
|
12278
|
-
const validationErrors = [];
|
|
12279
|
-
const componentsDir = join2(outPath, "components");
|
|
12280
|
-
await mkdir2(componentsDir, { recursive: true });
|
|
12281
|
-
for (const component of registry2.components) {
|
|
12282
|
-
const packument = {
|
|
12283
|
-
name: component.name,
|
|
12284
|
-
versions: {
|
|
12285
|
-
[registry2.version]: component
|
|
12286
|
-
},
|
|
12287
|
-
"dist-tags": {
|
|
12288
|
-
latest: registry2.version
|
|
12289
|
-
}
|
|
12290
|
-
};
|
|
12291
|
-
const packumentPath = join2(componentsDir, `${component.name}.json`);
|
|
12292
|
-
await Bun.write(packumentPath, JSON.stringify(packument, null, 2));
|
|
12293
|
-
for (const rawFile of component.files) {
|
|
12294
|
-
const file = normalizeFile(rawFile);
|
|
12295
|
-
const sourceFilePath = join2(sourcePath, "files", file.path);
|
|
12296
|
-
const destFilePath = join2(componentsDir, component.name, file.path);
|
|
12297
|
-
const destFileDir = dirname2(destFilePath);
|
|
12298
|
-
if (!await Bun.file(sourceFilePath).exists()) {
|
|
12299
|
-
validationErrors.push(`${component.name}: Source file not found at ${sourceFilePath}`);
|
|
12300
|
-
continue;
|
|
12301
|
-
}
|
|
12302
|
-
await mkdir2(destFileDir, { recursive: true });
|
|
12303
|
-
const sourceFile = Bun.file(sourceFilePath);
|
|
12304
|
-
await Bun.write(destFilePath, sourceFile);
|
|
12305
|
-
}
|
|
12306
|
-
}
|
|
12307
|
-
if (validationErrors.length > 0) {
|
|
12308
|
-
if (!options2.json) {
|
|
12309
|
-
spinner2.fail(`Build failed with ${validationErrors.length} errors`);
|
|
12310
|
-
for (const err of validationErrors) {
|
|
12311
|
-
console.log(kleur_default.red(` ${err}`));
|
|
12312
|
-
}
|
|
12313
|
-
}
|
|
12314
|
-
process.exit(1);
|
|
12315
|
-
}
|
|
12316
|
-
const index = {
|
|
12317
|
-
name: registry2.name,
|
|
12318
|
-
namespace: registry2.namespace,
|
|
12319
|
-
version: registry2.version,
|
|
12320
|
-
author: registry2.author,
|
|
12321
|
-
components: registry2.components.map((c) => ({
|
|
12322
|
-
name: c.name,
|
|
12323
|
-
type: c.type,
|
|
12324
|
-
description: c.description
|
|
12325
|
-
}))
|
|
12326
|
-
};
|
|
12327
|
-
await Bun.write(join2(outPath, "index.json"), JSON.stringify(index, null, 2));
|
|
12340
|
+
const result = await buildRegistry({
|
|
12341
|
+
source: sourcePath,
|
|
12342
|
+
out: outPath
|
|
12343
|
+
});
|
|
12328
12344
|
if (!options2.json) {
|
|
12329
|
-
const msg = `Built ${
|
|
12345
|
+
const msg = `Built ${result.componentsCount} components to ${relative(options2.cwd, outPath)}`;
|
|
12330
12346
|
spinner2.succeed(msg);
|
|
12331
12347
|
if (!process.stdout.isTTY) {
|
|
12332
|
-
logger.success(`Built ${
|
|
12348
|
+
logger.success(`Built ${result.componentsCount} components`);
|
|
12333
12349
|
}
|
|
12334
12350
|
}
|
|
12335
12351
|
if (options2.json) {
|
|
12336
12352
|
outputJson({
|
|
12337
12353
|
success: true,
|
|
12338
12354
|
data: {
|
|
12339
|
-
name:
|
|
12340
|
-
version:
|
|
12341
|
-
components:
|
|
12342
|
-
output:
|
|
12355
|
+
name: result.name,
|
|
12356
|
+
version: result.version,
|
|
12357
|
+
components: result.componentsCount,
|
|
12358
|
+
output: result.outputPath
|
|
12343
12359
|
}
|
|
12344
12360
|
});
|
|
12345
12361
|
}
|
|
12346
12362
|
} catch (error) {
|
|
12363
|
+
if (error instanceof BuildRegistryError) {
|
|
12364
|
+
if (!options2.json) {
|
|
12365
|
+
logger.error(error.message);
|
|
12366
|
+
for (const err of error.errors) {
|
|
12367
|
+
console.log(kleur_default.red(` ${err}`));
|
|
12368
|
+
}
|
|
12369
|
+
}
|
|
12370
|
+
process.exit(1);
|
|
12371
|
+
}
|
|
12347
12372
|
handleError(error, { json: options2.json });
|
|
12348
12373
|
}
|
|
12349
12374
|
});
|
|
@@ -13153,8 +13178,8 @@ function registerDiffCommand(program2) {
|
|
|
13153
13178
|
}
|
|
13154
13179
|
return;
|
|
13155
13180
|
}
|
|
13156
|
-
const
|
|
13157
|
-
if (!
|
|
13181
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13182
|
+
if (!config) {
|
|
13158
13183
|
if (options2.json) {
|
|
13159
13184
|
outputJson({
|
|
13160
13185
|
success: false,
|
|
@@ -13194,7 +13219,7 @@ function registerDiffCommand(program2) {
|
|
|
13194
13219
|
continue;
|
|
13195
13220
|
}
|
|
13196
13221
|
const localContent = await localFile.text();
|
|
13197
|
-
const registryConfig =
|
|
13222
|
+
const registryConfig = config.registries[installed.registry];
|
|
13198
13223
|
if (!registryConfig) {
|
|
13199
13224
|
logger.warn(`Registry '${installed.registry}' not configured for component '${name}'.`);
|
|
13200
13225
|
continue;
|
|
@@ -13242,7 +13267,7 @@ Diff for ${res.name}:`));
|
|
|
13242
13267
|
// src/commands/init.ts
|
|
13243
13268
|
import { existsSync as existsSync2 } from "fs";
|
|
13244
13269
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
13245
|
-
import { join as
|
|
13270
|
+
import { join as join4 } from "path";
|
|
13246
13271
|
|
|
13247
13272
|
// src/constants.ts
|
|
13248
13273
|
var OCX_DOMAIN = "ocx.kdco.dev";
|
|
@@ -13260,7 +13285,7 @@ function registerInitCommand(program2) {
|
|
|
13260
13285
|
}
|
|
13261
13286
|
async function runInit(options2) {
|
|
13262
13287
|
const cwd = options2.cwd ?? process.cwd();
|
|
13263
|
-
const configPath =
|
|
13288
|
+
const configPath = join4(cwd, "ocx.jsonc");
|
|
13264
13289
|
if (existsSync2(configPath)) {
|
|
13265
13290
|
if (!options2.yes) {
|
|
13266
13291
|
logger.warn("ocx.jsonc already exists");
|
|
@@ -13276,8 +13301,8 @@ async function runInit(options2) {
|
|
|
13276
13301
|
$schema: OCX_SCHEMA_URL,
|
|
13277
13302
|
registries: {}
|
|
13278
13303
|
};
|
|
13279
|
-
const
|
|
13280
|
-
const content2 = JSON.stringify(
|
|
13304
|
+
const config = ocxConfigSchema.parse(rawConfig);
|
|
13305
|
+
const content2 = JSON.stringify(config, null, 2);
|
|
13281
13306
|
await writeFile2(configPath, content2, "utf-8");
|
|
13282
13307
|
if (!options2.quiet && !options2.json) {
|
|
13283
13308
|
logger.success("Initialized OCX configuration");
|
|
@@ -13300,28 +13325,28 @@ async function runInit(options2) {
|
|
|
13300
13325
|
|
|
13301
13326
|
// src/commands/registry.ts
|
|
13302
13327
|
function registerRegistryCommand(program2) {
|
|
13303
|
-
const
|
|
13304
|
-
|
|
13328
|
+
const registry = program2.command("registry").description("Manage registries");
|
|
13329
|
+
registry.command("add").description("Add a registry").argument("<url>", "Registry URL").option("--name <name>", "Registry alias (defaults to hostname)").option("--version <version>", "Pin to specific version").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (url, options2) => {
|
|
13305
13330
|
try {
|
|
13306
|
-
const
|
|
13307
|
-
if (!
|
|
13331
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13332
|
+
if (!config) {
|
|
13308
13333
|
logger.error("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13309
13334
|
process.exit(1);
|
|
13310
13335
|
}
|
|
13311
|
-
if (
|
|
13336
|
+
if (config.lockRegistries) {
|
|
13312
13337
|
logger.error("Registries are locked. Cannot add.");
|
|
13313
13338
|
process.exit(1);
|
|
13314
13339
|
}
|
|
13315
13340
|
const name = options2.name || new URL(url).hostname.replace(/\./g, "-");
|
|
13316
|
-
if (
|
|
13341
|
+
if (config.registries[name]) {
|
|
13317
13342
|
logger.warn(`Registry '${name}' already exists. Use a different name.`);
|
|
13318
13343
|
return;
|
|
13319
13344
|
}
|
|
13320
|
-
|
|
13345
|
+
config.registries[name] = {
|
|
13321
13346
|
url,
|
|
13322
13347
|
version: options2.version
|
|
13323
13348
|
};
|
|
13324
|
-
await writeOcxConfig(options2.cwd,
|
|
13349
|
+
await writeOcxConfig(options2.cwd, config);
|
|
13325
13350
|
if (options2.json) {
|
|
13326
13351
|
outputJson({ success: true, data: { name, url } });
|
|
13327
13352
|
} else {
|
|
@@ -13331,23 +13356,23 @@ function registerRegistryCommand(program2) {
|
|
|
13331
13356
|
handleError(error);
|
|
13332
13357
|
}
|
|
13333
13358
|
});
|
|
13334
|
-
|
|
13359
|
+
registry.command("remove").description("Remove a registry").argument("<name>", "Registry name").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (name, options2) => {
|
|
13335
13360
|
try {
|
|
13336
|
-
const
|
|
13337
|
-
if (!
|
|
13361
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13362
|
+
if (!config) {
|
|
13338
13363
|
logger.error("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13339
13364
|
process.exit(1);
|
|
13340
13365
|
}
|
|
13341
|
-
if (
|
|
13366
|
+
if (config.lockRegistries) {
|
|
13342
13367
|
logger.error("Registries are locked. Cannot remove.");
|
|
13343
13368
|
process.exit(1);
|
|
13344
13369
|
}
|
|
13345
|
-
if (!
|
|
13370
|
+
if (!config.registries[name]) {
|
|
13346
13371
|
logger.warn(`Registry '${name}' not found.`);
|
|
13347
13372
|
return;
|
|
13348
13373
|
}
|
|
13349
|
-
delete
|
|
13350
|
-
await writeOcxConfig(options2.cwd,
|
|
13374
|
+
delete config.registries[name];
|
|
13375
|
+
await writeOcxConfig(options2.cwd, config);
|
|
13351
13376
|
if (options2.json) {
|
|
13352
13377
|
outputJson({ success: true, data: { removed: name } });
|
|
13353
13378
|
} else {
|
|
@@ -13357,14 +13382,14 @@ function registerRegistryCommand(program2) {
|
|
|
13357
13382
|
handleError(error);
|
|
13358
13383
|
}
|
|
13359
13384
|
});
|
|
13360
|
-
|
|
13385
|
+
registry.command("list").description("List configured registries").option("--cwd <path>", "Working directory", process.cwd()).option("--json", "Output as JSON", false).option("-q, --quiet", "Suppress output", false).action(async (options2) => {
|
|
13361
13386
|
try {
|
|
13362
|
-
const
|
|
13363
|
-
if (!
|
|
13387
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13388
|
+
if (!config) {
|
|
13364
13389
|
logger.warn("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13365
13390
|
return;
|
|
13366
13391
|
}
|
|
13367
|
-
const registries = Object.entries(
|
|
13392
|
+
const registries = Object.entries(config.registries).map(([name, cfg]) => ({
|
|
13368
13393
|
name,
|
|
13369
13394
|
url: cfg.url,
|
|
13370
13395
|
version: cfg.version || "latest"
|
|
@@ -13374,14 +13399,14 @@ function registerRegistryCommand(program2) {
|
|
|
13374
13399
|
success: true,
|
|
13375
13400
|
data: {
|
|
13376
13401
|
registries,
|
|
13377
|
-
locked:
|
|
13402
|
+
locked: config.lockRegistries
|
|
13378
13403
|
}
|
|
13379
13404
|
});
|
|
13380
13405
|
} else {
|
|
13381
13406
|
if (registries.length === 0) {
|
|
13382
13407
|
logger.info("No registries configured.");
|
|
13383
13408
|
} else {
|
|
13384
|
-
logger.info(`Configured registries${
|
|
13409
|
+
logger.info(`Configured registries${config.lockRegistries ? kleur_default.yellow(" (locked)") : ""}:`);
|
|
13385
13410
|
for (const reg of registries) {
|
|
13386
13411
|
console.log(` ${kleur_default.cyan(reg.name)}: ${reg.url} ${kleur_default.dim(`(${reg.version})`)}`);
|
|
13387
13412
|
}
|
|
@@ -13425,13 +13450,13 @@ function registerSearchCommand(program2) {
|
|
|
13425
13450
|
}
|
|
13426
13451
|
return;
|
|
13427
13452
|
}
|
|
13428
|
-
const
|
|
13429
|
-
if (!
|
|
13453
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13454
|
+
if (!config) {
|
|
13430
13455
|
logger.warn("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13431
13456
|
return;
|
|
13432
13457
|
}
|
|
13433
13458
|
if (options2.verbose) {
|
|
13434
|
-
logger.info(`Searching in ${Object.keys(
|
|
13459
|
+
logger.info(`Searching in ${Object.keys(config.registries).length} registries...`);
|
|
13435
13460
|
}
|
|
13436
13461
|
const allComponents = [];
|
|
13437
13462
|
const spinner2 = createSpinner({
|
|
@@ -13441,7 +13466,7 @@ function registerSearchCommand(program2) {
|
|
|
13441
13466
|
if (!options2.json && !options2.verbose) {
|
|
13442
13467
|
spinner2.start();
|
|
13443
13468
|
}
|
|
13444
|
-
for (const [registryName, registryConfig] of Object.entries(
|
|
13469
|
+
for (const [registryName, registryConfig] of Object.entries(config.registries)) {
|
|
13445
13470
|
try {
|
|
13446
13471
|
if (options2.verbose) {
|
|
13447
13472
|
logger.info(`Fetching index from ${registryName} (${registryConfig.url})...`);
|
|
@@ -13494,9 +13519,8 @@ function registerSearchCommand(program2) {
|
|
|
13494
13519
|
}
|
|
13495
13520
|
});
|
|
13496
13521
|
}
|
|
13497
|
-
|
|
13498
13522
|
// src/index.ts
|
|
13499
|
-
var version = "1.0.
|
|
13523
|
+
var version = "1.0.13";
|
|
13500
13524
|
async function main2() {
|
|
13501
13525
|
const program2 = new Command().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(version);
|
|
13502
13526
|
registerInitCommand(program2);
|
|
@@ -13507,8 +13531,18 @@ async function main2() {
|
|
|
13507
13531
|
registerBuildCommand(program2);
|
|
13508
13532
|
await program2.parseAsync(process.argv);
|
|
13509
13533
|
}
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13534
|
+
if (import.meta.main) {
|
|
13535
|
+
main2().catch((err) => {
|
|
13536
|
+
handleError(err);
|
|
13537
|
+
});
|
|
13538
|
+
}
|
|
13539
|
+
export {
|
|
13540
|
+
registrySchema,
|
|
13541
|
+
packumentSchema,
|
|
13542
|
+
ocxLockSchema,
|
|
13543
|
+
ocxConfigSchema,
|
|
13544
|
+
componentManifestSchema,
|
|
13545
|
+
buildRegistry
|
|
13546
|
+
};
|
|
13513
13547
|
|
|
13514
|
-
//# debugId=
|
|
13548
|
+
//# debugId=2D4B3AD90B25BFD964756E2164756E21
|