ocx 1.0.12 → 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 -150
- 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,111 +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));
|
|
12328
|
-
const wellKnownDir = join2(outPath, ".well-known");
|
|
12329
|
-
await mkdir2(wellKnownDir, { recursive: true });
|
|
12330
|
-
const discovery = { registry: "/index.json" };
|
|
12331
|
-
await Bun.write(join2(wellKnownDir, "ocx.json"), JSON.stringify(discovery, null, 2));
|
|
12340
|
+
const result = await buildRegistry({
|
|
12341
|
+
source: sourcePath,
|
|
12342
|
+
out: outPath
|
|
12343
|
+
});
|
|
12332
12344
|
if (!options2.json) {
|
|
12333
|
-
const msg = `Built ${
|
|
12345
|
+
const msg = `Built ${result.componentsCount} components to ${relative(options2.cwd, outPath)}`;
|
|
12334
12346
|
spinner2.succeed(msg);
|
|
12335
12347
|
if (!process.stdout.isTTY) {
|
|
12336
|
-
logger.success(`Built ${
|
|
12348
|
+
logger.success(`Built ${result.componentsCount} components`);
|
|
12337
12349
|
}
|
|
12338
12350
|
}
|
|
12339
12351
|
if (options2.json) {
|
|
12340
12352
|
outputJson({
|
|
12341
12353
|
success: true,
|
|
12342
12354
|
data: {
|
|
12343
|
-
name:
|
|
12344
|
-
version:
|
|
12345
|
-
components:
|
|
12346
|
-
output:
|
|
12355
|
+
name: result.name,
|
|
12356
|
+
version: result.version,
|
|
12357
|
+
components: result.componentsCount,
|
|
12358
|
+
output: result.outputPath
|
|
12347
12359
|
}
|
|
12348
12360
|
});
|
|
12349
12361
|
}
|
|
12350
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
|
+
}
|
|
12351
12372
|
handleError(error, { json: options2.json });
|
|
12352
12373
|
}
|
|
12353
12374
|
});
|
|
@@ -13157,8 +13178,8 @@ function registerDiffCommand(program2) {
|
|
|
13157
13178
|
}
|
|
13158
13179
|
return;
|
|
13159
13180
|
}
|
|
13160
|
-
const
|
|
13161
|
-
if (!
|
|
13181
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13182
|
+
if (!config) {
|
|
13162
13183
|
if (options2.json) {
|
|
13163
13184
|
outputJson({
|
|
13164
13185
|
success: false,
|
|
@@ -13198,7 +13219,7 @@ function registerDiffCommand(program2) {
|
|
|
13198
13219
|
continue;
|
|
13199
13220
|
}
|
|
13200
13221
|
const localContent = await localFile.text();
|
|
13201
|
-
const registryConfig =
|
|
13222
|
+
const registryConfig = config.registries[installed.registry];
|
|
13202
13223
|
if (!registryConfig) {
|
|
13203
13224
|
logger.warn(`Registry '${installed.registry}' not configured for component '${name}'.`);
|
|
13204
13225
|
continue;
|
|
@@ -13246,7 +13267,7 @@ Diff for ${res.name}:`));
|
|
|
13246
13267
|
// src/commands/init.ts
|
|
13247
13268
|
import { existsSync as existsSync2 } from "fs";
|
|
13248
13269
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
13249
|
-
import { join as
|
|
13270
|
+
import { join as join4 } from "path";
|
|
13250
13271
|
|
|
13251
13272
|
// src/constants.ts
|
|
13252
13273
|
var OCX_DOMAIN = "ocx.kdco.dev";
|
|
@@ -13264,7 +13285,7 @@ function registerInitCommand(program2) {
|
|
|
13264
13285
|
}
|
|
13265
13286
|
async function runInit(options2) {
|
|
13266
13287
|
const cwd = options2.cwd ?? process.cwd();
|
|
13267
|
-
const configPath =
|
|
13288
|
+
const configPath = join4(cwd, "ocx.jsonc");
|
|
13268
13289
|
if (existsSync2(configPath)) {
|
|
13269
13290
|
if (!options2.yes) {
|
|
13270
13291
|
logger.warn("ocx.jsonc already exists");
|
|
@@ -13280,8 +13301,8 @@ async function runInit(options2) {
|
|
|
13280
13301
|
$schema: OCX_SCHEMA_URL,
|
|
13281
13302
|
registries: {}
|
|
13282
13303
|
};
|
|
13283
|
-
const
|
|
13284
|
-
const content2 = JSON.stringify(
|
|
13304
|
+
const config = ocxConfigSchema.parse(rawConfig);
|
|
13305
|
+
const content2 = JSON.stringify(config, null, 2);
|
|
13285
13306
|
await writeFile2(configPath, content2, "utf-8");
|
|
13286
13307
|
if (!options2.quiet && !options2.json) {
|
|
13287
13308
|
logger.success("Initialized OCX configuration");
|
|
@@ -13304,28 +13325,28 @@ async function runInit(options2) {
|
|
|
13304
13325
|
|
|
13305
13326
|
// src/commands/registry.ts
|
|
13306
13327
|
function registerRegistryCommand(program2) {
|
|
13307
|
-
const
|
|
13308
|
-
|
|
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) => {
|
|
13309
13330
|
try {
|
|
13310
|
-
const
|
|
13311
|
-
if (!
|
|
13331
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13332
|
+
if (!config) {
|
|
13312
13333
|
logger.error("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13313
13334
|
process.exit(1);
|
|
13314
13335
|
}
|
|
13315
|
-
if (
|
|
13336
|
+
if (config.lockRegistries) {
|
|
13316
13337
|
logger.error("Registries are locked. Cannot add.");
|
|
13317
13338
|
process.exit(1);
|
|
13318
13339
|
}
|
|
13319
13340
|
const name = options2.name || new URL(url).hostname.replace(/\./g, "-");
|
|
13320
|
-
if (
|
|
13341
|
+
if (config.registries[name]) {
|
|
13321
13342
|
logger.warn(`Registry '${name}' already exists. Use a different name.`);
|
|
13322
13343
|
return;
|
|
13323
13344
|
}
|
|
13324
|
-
|
|
13345
|
+
config.registries[name] = {
|
|
13325
13346
|
url,
|
|
13326
13347
|
version: options2.version
|
|
13327
13348
|
};
|
|
13328
|
-
await writeOcxConfig(options2.cwd,
|
|
13349
|
+
await writeOcxConfig(options2.cwd, config);
|
|
13329
13350
|
if (options2.json) {
|
|
13330
13351
|
outputJson({ success: true, data: { name, url } });
|
|
13331
13352
|
} else {
|
|
@@ -13335,23 +13356,23 @@ function registerRegistryCommand(program2) {
|
|
|
13335
13356
|
handleError(error);
|
|
13336
13357
|
}
|
|
13337
13358
|
});
|
|
13338
|
-
|
|
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) => {
|
|
13339
13360
|
try {
|
|
13340
|
-
const
|
|
13341
|
-
if (!
|
|
13361
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13362
|
+
if (!config) {
|
|
13342
13363
|
logger.error("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13343
13364
|
process.exit(1);
|
|
13344
13365
|
}
|
|
13345
|
-
if (
|
|
13366
|
+
if (config.lockRegistries) {
|
|
13346
13367
|
logger.error("Registries are locked. Cannot remove.");
|
|
13347
13368
|
process.exit(1);
|
|
13348
13369
|
}
|
|
13349
|
-
if (!
|
|
13370
|
+
if (!config.registries[name]) {
|
|
13350
13371
|
logger.warn(`Registry '${name}' not found.`);
|
|
13351
13372
|
return;
|
|
13352
13373
|
}
|
|
13353
|
-
delete
|
|
13354
|
-
await writeOcxConfig(options2.cwd,
|
|
13374
|
+
delete config.registries[name];
|
|
13375
|
+
await writeOcxConfig(options2.cwd, config);
|
|
13355
13376
|
if (options2.json) {
|
|
13356
13377
|
outputJson({ success: true, data: { removed: name } });
|
|
13357
13378
|
} else {
|
|
@@ -13361,14 +13382,14 @@ function registerRegistryCommand(program2) {
|
|
|
13361
13382
|
handleError(error);
|
|
13362
13383
|
}
|
|
13363
13384
|
});
|
|
13364
|
-
|
|
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) => {
|
|
13365
13386
|
try {
|
|
13366
|
-
const
|
|
13367
|
-
if (!
|
|
13387
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13388
|
+
if (!config) {
|
|
13368
13389
|
logger.warn("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13369
13390
|
return;
|
|
13370
13391
|
}
|
|
13371
|
-
const registries = Object.entries(
|
|
13392
|
+
const registries = Object.entries(config.registries).map(([name, cfg]) => ({
|
|
13372
13393
|
name,
|
|
13373
13394
|
url: cfg.url,
|
|
13374
13395
|
version: cfg.version || "latest"
|
|
@@ -13378,14 +13399,14 @@ function registerRegistryCommand(program2) {
|
|
|
13378
13399
|
success: true,
|
|
13379
13400
|
data: {
|
|
13380
13401
|
registries,
|
|
13381
|
-
locked:
|
|
13402
|
+
locked: config.lockRegistries
|
|
13382
13403
|
}
|
|
13383
13404
|
});
|
|
13384
13405
|
} else {
|
|
13385
13406
|
if (registries.length === 0) {
|
|
13386
13407
|
logger.info("No registries configured.");
|
|
13387
13408
|
} else {
|
|
13388
|
-
logger.info(`Configured registries${
|
|
13409
|
+
logger.info(`Configured registries${config.lockRegistries ? kleur_default.yellow(" (locked)") : ""}:`);
|
|
13389
13410
|
for (const reg of registries) {
|
|
13390
13411
|
console.log(` ${kleur_default.cyan(reg.name)}: ${reg.url} ${kleur_default.dim(`(${reg.version})`)}`);
|
|
13391
13412
|
}
|
|
@@ -13429,13 +13450,13 @@ function registerSearchCommand(program2) {
|
|
|
13429
13450
|
}
|
|
13430
13451
|
return;
|
|
13431
13452
|
}
|
|
13432
|
-
const
|
|
13433
|
-
if (!
|
|
13453
|
+
const config = await readOcxConfig(options2.cwd);
|
|
13454
|
+
if (!config) {
|
|
13434
13455
|
logger.warn("No ocx.jsonc found. Run 'ocx init' first.");
|
|
13435
13456
|
return;
|
|
13436
13457
|
}
|
|
13437
13458
|
if (options2.verbose) {
|
|
13438
|
-
logger.info(`Searching in ${Object.keys(
|
|
13459
|
+
logger.info(`Searching in ${Object.keys(config.registries).length} registries...`);
|
|
13439
13460
|
}
|
|
13440
13461
|
const allComponents = [];
|
|
13441
13462
|
const spinner2 = createSpinner({
|
|
@@ -13445,7 +13466,7 @@ function registerSearchCommand(program2) {
|
|
|
13445
13466
|
if (!options2.json && !options2.verbose) {
|
|
13446
13467
|
spinner2.start();
|
|
13447
13468
|
}
|
|
13448
|
-
for (const [registryName, registryConfig] of Object.entries(
|
|
13469
|
+
for (const [registryName, registryConfig] of Object.entries(config.registries)) {
|
|
13449
13470
|
try {
|
|
13450
13471
|
if (options2.verbose) {
|
|
13451
13472
|
logger.info(`Fetching index from ${registryName} (${registryConfig.url})...`);
|
|
@@ -13498,9 +13519,8 @@ function registerSearchCommand(program2) {
|
|
|
13498
13519
|
}
|
|
13499
13520
|
});
|
|
13500
13521
|
}
|
|
13501
|
-
|
|
13502
13522
|
// src/index.ts
|
|
13503
|
-
var version = "1.0.
|
|
13523
|
+
var version = "1.0.13";
|
|
13504
13524
|
async function main2() {
|
|
13505
13525
|
const program2 = new Command().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(version);
|
|
13506
13526
|
registerInitCommand(program2);
|
|
@@ -13511,8 +13531,18 @@ async function main2() {
|
|
|
13511
13531
|
registerBuildCommand(program2);
|
|
13512
13532
|
await program2.parseAsync(process.argv);
|
|
13513
13533
|
}
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
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
|
+
};
|
|
13517
13547
|
|
|
13518
|
-
//# debugId=
|
|
13548
|
+
//# debugId=2D4B3AD90B25BFD964756E2164756E21
|