ocx 1.0.0 → 1.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 +100 -15
- package/dist/index.js.map +6 -5
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -4510,7 +4510,7 @@ var {
|
|
|
4510
4510
|
// src/commands/add.ts
|
|
4511
4511
|
import { createHash } from "crypto";
|
|
4512
4512
|
import { existsSync } from "fs";
|
|
4513
|
-
import { mkdir,
|
|
4513
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
4514
4514
|
import { dirname, join } from "path";
|
|
4515
4515
|
|
|
4516
4516
|
// ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
|
|
@@ -8709,6 +8709,98 @@ async function fetchFileContent(baseUrl, componentName, filePath) {
|
|
|
8709
8709
|
return response.text();
|
|
8710
8710
|
}
|
|
8711
8711
|
|
|
8712
|
+
// ../../node_modules/.bun/strip-json-comments@5.0.3/node_modules/strip-json-comments/index.js
|
|
8713
|
+
var singleComment = Symbol("singleComment");
|
|
8714
|
+
var multiComment = Symbol("multiComment");
|
|
8715
|
+
var stripWithoutWhitespace = () => "";
|
|
8716
|
+
var stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/[^ \t\r\n]/g, " ");
|
|
8717
|
+
var isEscaped = (jsonString, quotePosition) => {
|
|
8718
|
+
let index = quotePosition - 1;
|
|
8719
|
+
let backslashCount = 0;
|
|
8720
|
+
while (jsonString[index] === "\\") {
|
|
8721
|
+
index -= 1;
|
|
8722
|
+
backslashCount += 1;
|
|
8723
|
+
}
|
|
8724
|
+
return Boolean(backslashCount % 2);
|
|
8725
|
+
};
|
|
8726
|
+
function stripJsonComments(jsonString, { whitespace = true, trailingCommas = false } = {}) {
|
|
8727
|
+
if (typeof jsonString !== "string") {
|
|
8728
|
+
throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
|
|
8729
|
+
}
|
|
8730
|
+
const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
|
|
8731
|
+
let isInsideString = false;
|
|
8732
|
+
let isInsideComment = false;
|
|
8733
|
+
let offset = 0;
|
|
8734
|
+
let buffer = "";
|
|
8735
|
+
let result = "";
|
|
8736
|
+
let commaIndex = -1;
|
|
8737
|
+
for (let index = 0;index < jsonString.length; index++) {
|
|
8738
|
+
const currentCharacter = jsonString[index];
|
|
8739
|
+
const nextCharacter = jsonString[index + 1];
|
|
8740
|
+
if (!isInsideComment && currentCharacter === '"') {
|
|
8741
|
+
const escaped = isEscaped(jsonString, index);
|
|
8742
|
+
if (!escaped) {
|
|
8743
|
+
isInsideString = !isInsideString;
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8746
|
+
if (isInsideString) {
|
|
8747
|
+
continue;
|
|
8748
|
+
}
|
|
8749
|
+
if (!isInsideComment && currentCharacter + nextCharacter === "//") {
|
|
8750
|
+
buffer += jsonString.slice(offset, index);
|
|
8751
|
+
offset = index;
|
|
8752
|
+
isInsideComment = singleComment;
|
|
8753
|
+
index++;
|
|
8754
|
+
} else if (isInsideComment === singleComment && currentCharacter + nextCharacter === `\r
|
|
8755
|
+
`) {
|
|
8756
|
+
index++;
|
|
8757
|
+
isInsideComment = false;
|
|
8758
|
+
buffer += strip(jsonString, offset, index);
|
|
8759
|
+
offset = index;
|
|
8760
|
+
continue;
|
|
8761
|
+
} else if (isInsideComment === singleComment && currentCharacter === `
|
|
8762
|
+
`) {
|
|
8763
|
+
isInsideComment = false;
|
|
8764
|
+
buffer += strip(jsonString, offset, index);
|
|
8765
|
+
offset = index;
|
|
8766
|
+
} else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
|
|
8767
|
+
buffer += jsonString.slice(offset, index);
|
|
8768
|
+
offset = index;
|
|
8769
|
+
isInsideComment = multiComment;
|
|
8770
|
+
index++;
|
|
8771
|
+
continue;
|
|
8772
|
+
} else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
|
|
8773
|
+
index++;
|
|
8774
|
+
isInsideComment = false;
|
|
8775
|
+
buffer += strip(jsonString, offset, index + 1);
|
|
8776
|
+
offset = index + 1;
|
|
8777
|
+
continue;
|
|
8778
|
+
} else if (trailingCommas && !isInsideComment) {
|
|
8779
|
+
if (commaIndex !== -1) {
|
|
8780
|
+
if (currentCharacter === "}" || currentCharacter === "]") {
|
|
8781
|
+
buffer += jsonString.slice(offset, index);
|
|
8782
|
+
result += strip(buffer, 0, 1) + buffer.slice(1);
|
|
8783
|
+
buffer = "";
|
|
8784
|
+
offset = index;
|
|
8785
|
+
commaIndex = -1;
|
|
8786
|
+
} else if (currentCharacter !== " " && currentCharacter !== "\t" && currentCharacter !== "\r" && currentCharacter !== `
|
|
8787
|
+
`) {
|
|
8788
|
+
buffer += jsonString.slice(offset, index);
|
|
8789
|
+
offset = index;
|
|
8790
|
+
commaIndex = -1;
|
|
8791
|
+
}
|
|
8792
|
+
} else if (currentCharacter === ",") {
|
|
8793
|
+
result += buffer + jsonString.slice(offset, index);
|
|
8794
|
+
buffer = "";
|
|
8795
|
+
offset = index;
|
|
8796
|
+
commaIndex = index;
|
|
8797
|
+
}
|
|
8798
|
+
}
|
|
8799
|
+
}
|
|
8800
|
+
const remaining = isInsideComment === singleComment ? strip(jsonString, offset) : jsonString.slice(offset);
|
|
8801
|
+
return result + buffer + remaining;
|
|
8802
|
+
}
|
|
8803
|
+
|
|
8712
8804
|
// src/registry/opencode-config.ts
|
|
8713
8805
|
async function readOpencodeConfig(cwd) {
|
|
8714
8806
|
const jsonPath = `${cwd}/opencode.json`;
|
|
@@ -8759,11 +8851,6 @@ function applyMcpServers(config, mcpServers) {
|
|
|
8759
8851
|
}
|
|
8760
8852
|
return { config, added, skipped };
|
|
8761
8853
|
}
|
|
8762
|
-
function stripJsonComments(content) {
|
|
8763
|
-
let result = content.replace(/\/\/.*$/gm, "");
|
|
8764
|
-
result = result.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
8765
|
-
return result;
|
|
8766
|
-
}
|
|
8767
8854
|
async function updateOpencodeConfig(cwd, options) {
|
|
8768
8855
|
const existing = await readOpencodeConfig(cwd);
|
|
8769
8856
|
let config;
|
|
@@ -10465,17 +10552,15 @@ function registerAddCommand(program2) {
|
|
|
10465
10552
|
}
|
|
10466
10553
|
async function runAdd(componentNames, options2) {
|
|
10467
10554
|
const cwd = options2.cwd ?? process.cwd();
|
|
10468
|
-
const configPath = join(cwd, "ocx.jsonc");
|
|
10469
10555
|
const lockPath = join(cwd, "ocx.lock");
|
|
10470
|
-
|
|
10556
|
+
const config = await readOcxConfig(cwd);
|
|
10557
|
+
if (!config) {
|
|
10471
10558
|
throw new ConfigError("No ocx.jsonc found. Run 'ocx init' first.");
|
|
10472
10559
|
}
|
|
10473
|
-
const configContent = await readFile(configPath, "utf-8");
|
|
10474
|
-
const config = ocxConfigSchema.parse(JSON.parse(configContent));
|
|
10475
10560
|
let lock = { lockVersion: 1, installed: {} };
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
lock =
|
|
10561
|
+
const existingLock = await readOcxLock(cwd);
|
|
10562
|
+
if (existingLock) {
|
|
10563
|
+
lock = existingLock;
|
|
10479
10564
|
}
|
|
10480
10565
|
const spin = options2.quiet ? null : createSpinner({ text: "Resolving dependencies..." });
|
|
10481
10566
|
spin?.start();
|
|
@@ -11842,7 +11927,7 @@ function registerSearchCommand(program2) {
|
|
|
11842
11927
|
}
|
|
11843
11928
|
|
|
11844
11929
|
// src/index.ts
|
|
11845
|
-
var version =
|
|
11930
|
+
var version = "1.0.2";
|
|
11846
11931
|
async function main2() {
|
|
11847
11932
|
const program2 = new Command().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(version);
|
|
11848
11933
|
registerInitCommand(program2);
|
|
@@ -11857,4 +11942,4 @@ main2().catch((err) => {
|
|
|
11857
11942
|
handleError(err);
|
|
11858
11943
|
});
|
|
11859
11944
|
|
|
11860
|
-
//# debugId=
|
|
11945
|
+
//# debugId=E1F0036F628E968A64756E2164756E21
|