@useorgx/wizard 0.1.57 → 0.1.59
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/cli.js +86 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
|
|
5
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
5
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="38a8c165-aa33-5892-9af0-25fee0a694c7")}catch(e){}}();
|
|
6
6
|
import * as clack from "@clack/prompts";
|
|
7
7
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
8
8
|
import { readFileSync as readFileSync10 } from "fs";
|
|
@@ -32,6 +32,7 @@ import { join } from "path";
|
|
|
32
32
|
var ORGX_HOSTED_MCP_KEY = "orgx";
|
|
33
33
|
var ORGX_LOCAL_MCP_KEY = "orgx-openclaw";
|
|
34
34
|
var ORGX_HOSTED_MCP_URL = "https://mcp.useorgx.com/mcp";
|
|
35
|
+
var ORGX_CODEX_MCP_URL = `${ORGX_HOSTED_MCP_URL}?profile=commander`;
|
|
35
36
|
var ORGX_HOSTED_MCP_HEALTH_URL = "https://mcp.useorgx.com/health";
|
|
36
37
|
var ORGX_HOSTED_OAUTH_BASE_URL = "https://mcp.useorgx.com";
|
|
37
38
|
var ORGX_HOSTED_OAUTH_AUTHORIZE_URL = `${ORGX_HOSTED_OAUTH_BASE_URL}/authorize`;
|
|
@@ -2440,12 +2441,15 @@ function stringifyTomlDocument(document) {
|
|
|
2440
2441
|
return rendered.endsWith("\n") ? rendered : `${rendered}
|
|
2441
2442
|
`;
|
|
2442
2443
|
}
|
|
2443
|
-
function upsertCodexEntry(servers, key, url) {
|
|
2444
|
+
function upsertCodexEntry(servers, key, url, oauthResource) {
|
|
2444
2445
|
const current = readObject(servers[key]);
|
|
2445
2446
|
const next = {
|
|
2446
2447
|
...current,
|
|
2447
2448
|
url
|
|
2448
2449
|
};
|
|
2450
|
+
if (oauthResource) {
|
|
2451
|
+
next.oauth_resource = oauthResource;
|
|
2452
|
+
}
|
|
2449
2453
|
delete next.command;
|
|
2450
2454
|
delete next.args;
|
|
2451
2455
|
delete next.startup_timeout_sec;
|
|
@@ -2465,7 +2469,12 @@ function removeLegacyCodexEntries(servers) {
|
|
|
2465
2469
|
function patchCodexConfigToml(input, localMcpUrl) {
|
|
2466
2470
|
const current = parseTomlDocument(input);
|
|
2467
2471
|
const servers = readObject(current.mcp_servers);
|
|
2468
|
-
upsertCodexEntry(
|
|
2472
|
+
upsertCodexEntry(
|
|
2473
|
+
servers,
|
|
2474
|
+
ORGX_HOSTED_MCP_KEY,
|
|
2475
|
+
ORGX_CODEX_MCP_URL,
|
|
2476
|
+
ORGX_HOSTED_MCP_URL
|
|
2477
|
+
);
|
|
2469
2478
|
if (localMcpUrl) {
|
|
2470
2479
|
upsertCodexEntry(servers, ORGX_LOCAL_MCP_KEY, localMcpUrl);
|
|
2471
2480
|
}
|
|
@@ -2473,6 +2482,61 @@ function patchCodexConfigToml(input, localMcpUrl) {
|
|
|
2473
2482
|
current.mcp_servers = servers;
|
|
2474
2483
|
return stringifyTomlDocument(current);
|
|
2475
2484
|
}
|
|
2485
|
+
function migrateCodexHostedMcpConnection(input) {
|
|
2486
|
+
if (!input) return input;
|
|
2487
|
+
const current = parseTomlDocument(input);
|
|
2488
|
+
const servers = readObject(current.mcp_servers);
|
|
2489
|
+
const hosted = readObject(servers[ORGX_HOSTED_MCP_KEY]);
|
|
2490
|
+
if (hosted.url !== ORGX_HOSTED_MCP_URL && hosted.url !== ORGX_CODEX_MCP_URL) {
|
|
2491
|
+
return input;
|
|
2492
|
+
}
|
|
2493
|
+
const lines = input.match(/.*(?:\r\n|\n|$)/g)?.filter((line) => line.length > 0) ?? [];
|
|
2494
|
+
let inOrgxSection = false;
|
|
2495
|
+
let urlIndex = -1;
|
|
2496
|
+
let oauthResourceIndex = -1;
|
|
2497
|
+
for (const [index, line] of lines.entries()) {
|
|
2498
|
+
if (/^\s*\[/.test(line)) {
|
|
2499
|
+
inOrgxSection = /^\s*\[mcp_servers\.(?:orgx|"orgx")\]\s*(?:#.*)?(?:\r?\n)?$/.test(line);
|
|
2500
|
+
continue;
|
|
2501
|
+
}
|
|
2502
|
+
if (!inOrgxSection) continue;
|
|
2503
|
+
if (/^\s*url\s*=/.test(line)) urlIndex = index;
|
|
2504
|
+
if (/^\s*oauth_resource\s*=/.test(line)) oauthResourceIndex = index;
|
|
2505
|
+
}
|
|
2506
|
+
if (urlIndex < 0) return input;
|
|
2507
|
+
const urlMatch = lines[urlIndex]?.match(
|
|
2508
|
+
/^(\s*url\s*=\s*)(["'])(https:\/\/mcp\.useorgx\.com\/mcp(?:\?profile=commander)?)\2([ \t]*(?:#.*)?)(\r?\n)?$/
|
|
2509
|
+
);
|
|
2510
|
+
if (!urlMatch) return input;
|
|
2511
|
+
let changed = false;
|
|
2512
|
+
if (urlMatch[3] !== ORGX_CODEX_MCP_URL) {
|
|
2513
|
+
lines[urlIndex] = `${urlMatch[1]}${urlMatch[2]}${ORGX_CODEX_MCP_URL}${urlMatch[2]}${urlMatch[4]}${urlMatch[5] ?? ""}`;
|
|
2514
|
+
changed = true;
|
|
2515
|
+
}
|
|
2516
|
+
if (oauthResourceIndex >= 0) {
|
|
2517
|
+
const oauthResourceMatch = lines[oauthResourceIndex]?.match(
|
|
2518
|
+
/^(\s*oauth_resource\s*=\s*)(["'])([^"']*)\2([ \t]*(?:#.*)?)(\r?\n)?$/
|
|
2519
|
+
);
|
|
2520
|
+
if (!oauthResourceMatch) return input;
|
|
2521
|
+
if (oauthResourceMatch[3] !== ORGX_HOSTED_MCP_URL) {
|
|
2522
|
+
lines[oauthResourceIndex] = `${oauthResourceMatch[1]}${oauthResourceMatch[2]}${ORGX_HOSTED_MCP_URL}${oauthResourceMatch[2]}${oauthResourceMatch[4]}${oauthResourceMatch[5] ?? ""}`;
|
|
2523
|
+
changed = true;
|
|
2524
|
+
}
|
|
2525
|
+
} else {
|
|
2526
|
+
const lineEnding = urlMatch[5] ?? (input.includes("\r\n") ? "\r\n" : "\n");
|
|
2527
|
+
if (!urlMatch[5]) {
|
|
2528
|
+
lines[urlIndex] = `${lines[urlIndex]}${lineEnding}`;
|
|
2529
|
+
}
|
|
2530
|
+
const indent = urlMatch[1]?.match(/^\s*/)?.[0] ?? "";
|
|
2531
|
+
lines.splice(
|
|
2532
|
+
urlIndex + 1,
|
|
2533
|
+
0,
|
|
2534
|
+
`${indent}oauth_resource = "${ORGX_HOSTED_MCP_URL}"${urlMatch[5] ? lineEnding : ""}`
|
|
2535
|
+
);
|
|
2536
|
+
changed = true;
|
|
2537
|
+
}
|
|
2538
|
+
return changed ? lines.join("") : input;
|
|
2539
|
+
}
|
|
2476
2540
|
function removeCodexConfigToml(input) {
|
|
2477
2541
|
const current = parseTomlDocument(input);
|
|
2478
2542
|
const servers = readObject(current.mcp_servers);
|
|
@@ -2480,7 +2544,7 @@ function removeCodexConfigToml(input) {
|
|
|
2480
2544
|
if (isRecord(servers[ORGX_LOCAL_MCP_KEY])) {
|
|
2481
2545
|
delete servers[ORGX_LOCAL_MCP_KEY];
|
|
2482
2546
|
}
|
|
2483
|
-
if (hosted.url === ORGX_HOSTED_MCP_URL) {
|
|
2547
|
+
if (hosted.url === ORGX_HOSTED_MCP_URL || hosted.url === ORGX_CODEX_MCP_URL) {
|
|
2484
2548
|
delete servers[ORGX_HOSTED_MCP_KEY];
|
|
2485
2549
|
}
|
|
2486
2550
|
removeLegacyCodexEntries(servers);
|
|
@@ -2492,7 +2556,7 @@ function inspectCodexConfigToml(input) {
|
|
|
2492
2556
|
const servers = readObject(current.mcp_servers);
|
|
2493
2557
|
const hosted = readObject(servers[ORGX_HOSTED_MCP_KEY]);
|
|
2494
2558
|
const local = readObject(servers[ORGX_LOCAL_MCP_KEY]);
|
|
2495
|
-
const hostedConfigured = hosted.url === ORGX_HOSTED_MCP_URL;
|
|
2559
|
+
const hostedConfigured = hosted.url === ORGX_CODEX_MCP_URL && hosted.oauth_resource === ORGX_HOSTED_MCP_URL;
|
|
2496
2560
|
const localConfigured = typeof local.url === "string";
|
|
2497
2561
|
return {
|
|
2498
2562
|
configured: hostedConfigured && localConfigured,
|
|
@@ -3585,6 +3649,7 @@ function defaultPluginPaths() {
|
|
|
3585
3649
|
claudeMarketplaceDir: CLAUDE_MANAGED_MARKETPLACE_DIR,
|
|
3586
3650
|
claudeMarketplaceManifestPath: CLAUDE_MANAGED_MARKETPLACE_MANIFEST_PATH,
|
|
3587
3651
|
claudePluginDir: CLAUDE_MANAGED_PLUGIN_DIR,
|
|
3652
|
+
codexConfigPath: CODEX_CONFIG_PATH ?? join4(CODEX_DIR, "config.toml"),
|
|
3588
3653
|
codexMarketplacePath: CODEX_MARKETPLACE_PATH,
|
|
3589
3654
|
codexPluginDir: CODEX_ORGX_PLUGIN_DIR,
|
|
3590
3655
|
cursorPluginDir: CURSOR_ORGX_PLUGIN_DIR,
|
|
@@ -4227,11 +4292,22 @@ async function installCodexPlugin(paths, fetchImpl, runner) {
|
|
|
4227
4292
|
}
|
|
4228
4293
|
const syncResult = await syncManagedRepoTree(CODEX_PLUGIN_SYNC_SPEC, paths.codexPluginDir, fetchImpl);
|
|
4229
4294
|
const marketplaceChanged = upsertCodexMarketplaceEntry(paths.codexMarketplacePath);
|
|
4230
|
-
const
|
|
4295
|
+
const previousConfig = readTextIfExists(paths.codexConfigPath);
|
|
4296
|
+
const nextConfig = migrateCodexHostedMcpConnection(previousConfig);
|
|
4297
|
+
const configChanged = nextConfig !== previousConfig;
|
|
4298
|
+
if (configChanged && nextConfig !== null) {
|
|
4299
|
+
writeTextFile(paths.codexConfigPath, nextConfig);
|
|
4300
|
+
}
|
|
4301
|
+
const changed = syncResult.changed || marketplaceChanged || configChanged;
|
|
4302
|
+
const changes = [
|
|
4303
|
+
...syncResult.changed ? [`Synced ${syncResult.fileCount} Codex plugin files.`] : [],
|
|
4304
|
+
...marketplaceChanged ? ["Updated the Codex marketplace entry."] : [],
|
|
4305
|
+
...configChanged ? ["Updated the existing OrgX MCP connection for the commander profile and OAuth."] : []
|
|
4306
|
+
];
|
|
4231
4307
|
return {
|
|
4232
4308
|
target: "codex",
|
|
4233
4309
|
changed,
|
|
4234
|
-
message: changed ?
|
|
4310
|
+
message: changed ? changes.join(" ") : "Codex plugin files and marketplace entry already match the managed OrgX plugin."
|
|
4235
4311
|
};
|
|
4236
4312
|
}
|
|
4237
4313
|
async function installOpenclawPlugin(fetchImpl, runner) {
|
|
@@ -6214,7 +6290,7 @@ function initializeWizardSentry() {
|
|
|
6214
6290
|
Sentry.init({
|
|
6215
6291
|
dsn,
|
|
6216
6292
|
environment: process.env.ORGX_SENTRY_ENVIRONMENT || "production",
|
|
6217
|
-
release: "useorgx-wizard@0.1.
|
|
6293
|
+
release: "useorgx-wizard@0.1.59",
|
|
6218
6294
|
tracesSampleRate: sampleRate(process.env.ORGX_SENTRY_TRACES_SAMPLE_RATE),
|
|
6219
6295
|
enableLogs: true,
|
|
6220
6296
|
sendDefaultPii: false,
|
|
@@ -18245,7 +18321,7 @@ async function main() {
|
|
|
18245
18321
|
initializeWizardSentry();
|
|
18246
18322
|
const program = new Command();
|
|
18247
18323
|
program.name("orgx-wizard").description("Add OrgX MCP configs, skills/rules, and companion plugins to your local AI tools.").showHelpAfterError();
|
|
18248
|
-
const pkgVersion = true ? "0.1.
|
|
18324
|
+
const pkgVersion = true ? "0.1.59" : void 0;
|
|
18249
18325
|
program.version(pkgVersion ?? "unknown", "-V, --version");
|
|
18250
18326
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
18251
18327
|
if (Boolean(actionCommand.optsWithGlobals().json)) return;
|
|
@@ -19289,4 +19365,4 @@ main().catch(async (error) => {
|
|
|
19289
19365
|
process.exitCode = 1;
|
|
19290
19366
|
});
|
|
19291
19367
|
//# sourceMappingURL=cli.js.map
|
|
19292
|
-
//# debugId=
|
|
19368
|
+
//# debugId=38a8c165-aa33-5892-9af0-25fee0a694c7
|