@useorgx/wizard 0.1.0 → 0.1.3

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 CHANGED
@@ -578,15 +578,12 @@ async function checkOrgxAuth(options = {}) {
578
578
  ok: false,
579
579
  skipped: true,
580
580
  source: "none",
581
- error: "No OrgX API key found in ORGX_API_KEY, the wizard auth store, or OpenClaw config.",
581
+ error: "No OrgX account connected. Run `orgx-wizard auth login` to connect.",
582
582
  url: buildOrgxApiUrl("/client/sync", DEFAULT_ORGX_BASE_URL)
583
583
  };
584
584
  }
585
585
  return verifyOrgxAuth(auth);
586
586
  }
587
- function describeSetupStatusScope() {
588
- return "The setup-status endpoint is still service-key-only and uses ORGX_SERVICE_KEY.";
589
- }
590
587
 
591
588
  // src/lib/browser-auth.ts
592
589
  function asString(value) {
@@ -745,48 +742,6 @@ function openBrowser(url) {
745
742
  return { ok: true };
746
743
  }
747
744
 
748
- // src/lib/setup-status.ts
749
- async function fetchSetupStatus(apiKey = process.env.ORGX_SERVICE_KEY?.trim()) {
750
- if (!apiKey) {
751
- return {
752
- ok: false,
753
- skipped: true,
754
- error: "ORGX_SERVICE_KEY is not set; /api/setup/status is a service-level check and was skipped.",
755
- url: ORGX_SETUP_STATUS_URL
756
- };
757
- }
758
- try {
759
- const response = await fetch(ORGX_SETUP_STATUS_URL, {
760
- headers: {
761
- Authorization: `Bearer ${apiKey}`
762
- },
763
- signal: AbortSignal.timeout(7e3)
764
- });
765
- const text2 = await response.text();
766
- let data = text2;
767
- try {
768
- data = text2.length > 0 ? JSON.parse(text2) : null;
769
- } catch {
770
- data = text2;
771
- }
772
- return {
773
- ok: response.ok,
774
- skipped: false,
775
- status: response.status,
776
- data,
777
- url: ORGX_SETUP_STATUS_URL,
778
- ...response.ok ? {} : { error: `HTTP ${response.status}` }
779
- };
780
- } catch (error) {
781
- return {
782
- ok: false,
783
- skipped: false,
784
- error: error instanceof Error ? error.message : String(error),
785
- url: ORGX_SETUP_STATUS_URL
786
- };
787
- }
788
- }
789
-
790
745
  // src/lib/openclaw-health.ts
791
746
  import { spawnSync as spawnSync2 } from "child_process";
792
747
  function trimOutput(value) {
@@ -2106,36 +2061,30 @@ async function addAutomatedSurface(name) {
2106
2061
  }
2107
2062
  case "vscode": {
2108
2063
  const previous = readTextIfExists(path);
2064
+ if (inspectVscodeMcpConfig(previous).hostedConfigured) {
2065
+ return { name, changed: false, path, message: "OrgX cloud MCP is connected in VS Code." };
2066
+ }
2109
2067
  const next = patchVscodeMcpConfig(previous);
2110
2068
  writeTextFile(path, next);
2111
- return {
2112
- name,
2113
- changed: previous !== next,
2114
- path,
2115
- message: "OrgX cloud MCP is connected in VS Code."
2116
- };
2069
+ return { name, changed: true, path, message: "OrgX cloud MCP is connected in VS Code." };
2117
2070
  }
2118
2071
  case "windsurf": {
2119
2072
  const previous = readTextIfExists(path);
2073
+ if (inspectWindsurfMcpConfig(previous).hostedConfigured) {
2074
+ return { name, changed: false, path, message: "OrgX cloud MCP is connected in Windsurf." };
2075
+ }
2120
2076
  const next = patchWindsurfMcpConfig(previous);
2121
2077
  writeTextFile(path, next);
2122
- return {
2123
- name,
2124
- changed: previous !== next,
2125
- path,
2126
- message: "OrgX cloud MCP is connected in Windsurf."
2127
- };
2078
+ return { name, changed: true, path, message: "OrgX cloud MCP is connected in Windsurf." };
2128
2079
  }
2129
2080
  case "zed": {
2130
2081
  const previous = readTextIfExists(path);
2082
+ if (inspectZedMcpConfig(previous).hostedConfigured) {
2083
+ return { name, changed: false, path, message: "OrgX cloud MCP is connected in Zed." };
2084
+ }
2131
2085
  const next = patchZedMcpConfig(previous);
2132
2086
  writeTextFile(path, next);
2133
- return {
2134
- name,
2135
- changed: previous !== next,
2136
- path,
2137
- message: "OrgX cloud MCP is connected in Zed."
2138
- };
2087
+ return { name, changed: true, path, message: "OrgX cloud MCP is connected in Zed." };
2139
2088
  }
2140
2089
  default:
2141
2090
  return {
@@ -2294,9 +2243,8 @@ async function runDoctor() {
2294
2243
  const hostedMcpTool = await checkHostedMcpToolAccess();
2295
2244
  const npmRegistry = await checkNpmRegistryHealth();
2296
2245
  const workspace = await checkWorkspaceConnectivity();
2297
- const remote = await fetchSetupStatus();
2298
2246
  const openclaw = openclawSurface?.detected ? await checkOpenClawHealth(openclawSurface.path) : skippedOpenClawHealth();
2299
- return { surfaces, auth, hostedMcp, hostedMcpTool, npmRegistry, workspace, remote, openclaw };
2247
+ return { surfaces, auth, hostedMcp, hostedMcpTool, npmRegistry, workspace, openclaw };
2300
2248
  }
2301
2249
  function assessDoctorReport(report) {
2302
2250
  const issues = [];
@@ -2348,13 +2296,6 @@ function assessDoctorReport(report) {
2348
2296
  suggestion: "Run `openclaw doctor` or `openclaw doctor --repair` before relying on local bridge clients like Cursor."
2349
2297
  });
2350
2298
  }
2351
- if (!report.remote.skipped && !report.remote.ok) {
2352
- issues.push({
2353
- level: "warning",
2354
- title: "Remote setup status check failed.",
2355
- suggestion: "If you expected the service-key check to pass, verify ORGX_SERVICE_KEY before trusting setup-status output."
2356
- });
2357
- }
2358
2299
  return {
2359
2300
  ok: !issues.some((issue) => issue.level === "error"),
2360
2301
  issues
@@ -3389,24 +3330,6 @@ function printAuthStatus(status) {
3389
3330
  console.log(` error: ${status.error}`);
3390
3331
  }
3391
3332
  }
3392
- function printRemoteSetupStatus(status) {
3393
- if (status.skipped) {
3394
- console.log(pc3.yellow(status.error ?? "Remote setup check skipped."));
3395
- console.log(pc3.dim(describeSetupStatusScope()));
3396
- return;
3397
- }
3398
- if (!status.ok) {
3399
- console.log(pc3.red(`Remote setup check failed: ${status.error ?? "unknown error"}`));
3400
- if (status.status) {
3401
- console.log(`status: ${status.status}`);
3402
- }
3403
- return;
3404
- }
3405
- console.log(pc3.green(`Remote setup check passed via ${status.url}`));
3406
- if (status.data) {
3407
- console.log(JSON.stringify(status.data, null, 2));
3408
- }
3409
- }
3410
3333
  function printWorkspaceConnectivity(check) {
3411
3334
  console.log(pc3.bold("workspace connectivity"));
3412
3335
  if (!check.configured) {
@@ -3493,8 +3416,6 @@ async function main() {
3493
3416
  console.log("");
3494
3417
  printOpenClawHealth(doctor2.openclaw);
3495
3418
  console.log("");
3496
- printRemoteSetupStatus(doctor2.remote);
3497
- console.log("");
3498
3419
  const assessment2 = assessDoctorReport(doctor2);
3499
3420
  printDoctorAssessment(assessment2);
3500
3421
  if (!assessment2.ok) {
@@ -3507,7 +3428,35 @@ async function main() {
3507
3428
  const results = await setupDetectedSurfaces();
3508
3429
  spinner.succeed("Detected surfaces configured");
3509
3430
  printMutationResults(results);
3510
- const resolvedAuth = await resolveOrgxAuth();
3431
+ let resolvedAuth = await resolveOrgxAuth();
3432
+ if (!resolvedAuth) {
3433
+ console.log("");
3434
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
3435
+ if (interactive) {
3436
+ const choice = await selectPrompt({
3437
+ message: "Connect your OrgX account to enable workspace and AI tool access",
3438
+ options: [
3439
+ { value: "login", label: "Open browser to connect", hint: "recommended" },
3440
+ { value: "skip", label: "Skip for now", hint: "run `orgx-wizard auth login` later" }
3441
+ ]
3442
+ });
3443
+ if (!clack.isCancel(choice) && choice === "login") {
3444
+ const loginOk = await runBrowserLogin();
3445
+ if (loginOk) {
3446
+ resolvedAuth = await resolveOrgxAuth();
3447
+ }
3448
+ } else if (clack.isCancel(choice)) {
3449
+ clack.cancel("Setup cancelled.");
3450
+ return;
3451
+ } else {
3452
+ console.log(pc3.dim(`Run ${pc3.cyan("orgx-wizard auth login")} to connect later.`));
3453
+ }
3454
+ } else {
3455
+ console.log(
3456
+ `${pc3.yellow("No OrgX account connected.")} Run ${pc3.cyan("orgx-wizard auth login")} to connect.`
3457
+ );
3458
+ }
3459
+ }
3511
3460
  if (resolvedAuth) {
3512
3461
  console.log("");
3513
3462
  const workspaceSetup = await runWorkspaceSetup(
@@ -3549,59 +3498,26 @@ async function main() {
3549
3498
  console.log("");
3550
3499
  printOpenClawHealth(doctor.openclaw);
3551
3500
  console.log("");
3552
- printRemoteSetupStatus(doctor.remote);
3553
- console.log("");
3554
3501
  const assessment = assessDoctorReport(doctor);
3555
3502
  printDoctorAssessment(assessment);
3556
3503
  if (!assessment.ok) {
3557
3504
  process.exitCode = 1;
3558
3505
  }
3559
3506
  });
3560
- const auth = program.command("auth").description("Manage OrgX API key auth for the wizard.");
3561
- auth.command("status").description("Show the resolved OrgX API key source and verify it against OrgX.").action(async () => {
3562
- const spinner = createOrgxSpinner("Checking OrgX auth");
3563
- spinner.start();
3564
- const status = await checkOrgxAuth();
3565
- spinner.stop();
3566
- printAuthStatus(status);
3567
- });
3568
- auth.command("login").description("Start browser pairing for OrgX auth, with direct API key fallback for CI and blocked browsers.").option("--api-key <key>", "Bypass browser pairing and verify this OrgX API key directly.").option("--base-url <url>", "OrgX base URL").option("--device-name <name>", "Device name shown during browser approval.").option("--no-open", "Do not automatically open the browser connect URL.").option("--timeout <seconds>", "How long to wait for browser pairing before giving up.", parseTimeoutSeconds, 600).action(async (options) => {
3569
- if (options.apiKey) {
3570
- const spinner2 = createOrgxSpinner("Verifying OrgX API key");
3571
- spinner2.start();
3572
- const result = await verifyAndPersistAuth(options.apiKey, options);
3573
- if (!("stored" in result)) {
3574
- spinner2.fail("OrgX API key verification failed");
3575
- printAuthStatus(result.verification);
3576
- return;
3577
- }
3578
- spinner2.succeed("OrgX API key verified and saved");
3579
- await syncContinuityAfterAuth();
3580
- printAuthStatus({
3581
- ...result.verification,
3582
- source: "wizard-store",
3583
- path: ORGX_WIZARD_AUTH_PATH,
3584
- verifiedAt: result.stored.verifiedAt
3585
- });
3586
- if (result.openclawResults.length > 0) {
3587
- console.log("");
3588
- printMutationResults(result.openclawResults);
3589
- }
3590
- return;
3591
- }
3507
+ async function runBrowserLogin(opts = {}) {
3592
3508
  const installationId = getOrCreateWizardInstallationId();
3593
3509
  const spinner = createOrgxSpinner("Starting OrgX browser pairing");
3594
3510
  spinner.start();
3595
3511
  try {
3596
3512
  const pairing = await startBrowserPairing({
3597
3513
  installationId,
3598
- baseUrl: options.baseUrl,
3599
- deviceName: options.deviceName ?? hostname(),
3514
+ baseUrl: opts.baseUrl,
3515
+ deviceName: opts.deviceName ?? hostname(),
3600
3516
  platform: process.platform
3601
3517
  });
3602
3518
  spinner.succeed("OrgX browser pairing started");
3603
3519
  console.log(`Open to continue: ${pairing.connectUrl}`);
3604
- if (options.open !== false) {
3520
+ if (opts.open !== false) {
3605
3521
  const openResult = openBrowser(pairing.connectUrl);
3606
3522
  if (!openResult.ok && openResult.error) {
3607
3523
  console.log(pc3.yellow(`Browser open failed: ${openResult.error}`));
@@ -3610,21 +3526,23 @@ async function main() {
3610
3526
  spinner.start();
3611
3527
  spinner.text = pc3.cyan("Waiting for OrgX browser approval");
3612
3528
  const ready = await waitForBrowserPairing({
3613
- baseUrl: options.baseUrl,
3529
+ baseUrl: opts.baseUrl,
3614
3530
  pairingId: pairing.pairingId,
3615
3531
  pollIntervalMs: pairing.pollIntervalMs,
3616
3532
  pollToken: pairing.pollToken,
3617
- timeoutMs: options.timeout * 1e3
3533
+ timeoutMs: (opts.timeout ?? 600) * 1e3
3618
3534
  });
3619
3535
  spinner.text = pc3.cyan("Verifying OrgX API key");
3620
- const result = await verifyAndPersistAuth(ready.key, options);
3536
+ const result = await verifyAndPersistAuth(ready.key, {
3537
+ ...opts.baseUrl !== void 0 ? { baseUrl: opts.baseUrl } : {}
3538
+ });
3621
3539
  if (!("stored" in result)) {
3622
3540
  spinner.fail("OrgX browser pairing delivered an invalid API key");
3623
3541
  printAuthStatus(result.verification);
3624
- return;
3542
+ return false;
3625
3543
  }
3626
3544
  await acknowledgeBrowserPairing({
3627
- baseUrl: options.baseUrl,
3545
+ baseUrl: opts.baseUrl,
3628
3546
  pairingId: pairing.pairingId,
3629
3547
  pollToken: pairing.pollToken
3630
3548
  }).catch((error) => {
@@ -3648,10 +3566,51 @@ async function main() {
3648
3566
  console.log("");
3649
3567
  printMutationResults(result.openclawResults);
3650
3568
  }
3569
+ return true;
3651
3570
  } catch (error) {
3652
3571
  spinner.fail("OrgX browser pairing failed");
3653
3572
  console.log(pc3.red(describeBrowserPairingFailure(error)));
3573
+ return false;
3654
3574
  }
3575
+ }
3576
+ const auth = program.command("auth").description("Manage OrgX API key auth for the wizard.");
3577
+ auth.command("status").description("Show the resolved OrgX API key source and verify it against OrgX.").action(async () => {
3578
+ const spinner = createOrgxSpinner("Checking OrgX auth");
3579
+ spinner.start();
3580
+ const status = await checkOrgxAuth();
3581
+ spinner.stop();
3582
+ printAuthStatus(status);
3583
+ });
3584
+ auth.command("login").description("Start browser pairing for OrgX auth, with direct API key fallback for CI and blocked browsers.").option("--api-key <key>", "Bypass browser pairing and verify this OrgX API key directly.").option("--base-url <url>", "OrgX base URL").option("--device-name <name>", "Device name shown during browser approval.").option("--no-open", "Do not automatically open the browser connect URL.").option("--timeout <seconds>", "How long to wait for browser pairing before giving up.", parseTimeoutSeconds, 600).action(async (options) => {
3585
+ if (options.apiKey) {
3586
+ const spinner = createOrgxSpinner("Verifying OrgX API key");
3587
+ spinner.start();
3588
+ const result = await verifyAndPersistAuth(options.apiKey, options);
3589
+ if (!("stored" in result)) {
3590
+ spinner.fail("OrgX API key verification failed");
3591
+ printAuthStatus(result.verification);
3592
+ return;
3593
+ }
3594
+ spinner.succeed("OrgX API key verified and saved");
3595
+ await syncContinuityAfterAuth();
3596
+ printAuthStatus({
3597
+ ...result.verification,
3598
+ source: "wizard-store",
3599
+ path: ORGX_WIZARD_AUTH_PATH,
3600
+ verifiedAt: result.stored.verifiedAt
3601
+ });
3602
+ if (result.openclawResults.length > 0) {
3603
+ console.log("");
3604
+ printMutationResults(result.openclawResults);
3605
+ }
3606
+ return;
3607
+ }
3608
+ await runBrowserLogin({
3609
+ ...options.baseUrl !== void 0 ? { baseUrl: options.baseUrl } : {},
3610
+ ...options.deviceName !== void 0 ? { deviceName: options.deviceName } : {},
3611
+ ...options.open !== void 0 ? { open: options.open } : {},
3612
+ timeout: options.timeout
3613
+ });
3655
3614
  });
3656
3615
  auth.command("set-key").description("Verify and persist a per-user OrgX API key for the wizard.").argument("<apiKey>", "per-user OrgX API key (oxk_...)").option("--base-url <url>", "OrgX base URL").action(async (apiKey, options) => {
3657
3616
  const spinner = createOrgxSpinner("Verifying OrgX API key");
@@ -3773,8 +3732,6 @@ async function main() {
3773
3732
  console.log("");
3774
3733
  printOpenClawHealth(report.openclaw);
3775
3734
  console.log("");
3776
- printRemoteSetupStatus(report.remote);
3777
- console.log("");
3778
3735
  const assessment = assessDoctorReport(report);
3779
3736
  printDoctorAssessment(assessment);
3780
3737
  if (!assessment.ok) {
@@ -3783,10 +3740,9 @@ async function main() {
3783
3740
  });
3784
3741
  const skills = program.command("skills").description("Install OrgX rules and Claude skill packs.");
3785
3742
  skills.command("add").description("Write Cursor and Claude OrgX rules and install OrgX Claude skill packs.").argument("[packs...]", "skill pack names or 'all'", ["all"]).action(async (packs) => {
3786
- const selectedPacks = resolveSkillPackNames(packs);
3787
3743
  const spinner = createOrgxSpinner("Installing OrgX rules and skills");
3788
3744
  spinner.start();
3789
- const report = await installOrgxSkills({ skillNames: selectedPacks });
3745
+ const report = await installOrgxSkills({ skillNames: packs });
3790
3746
  spinner.succeed("OrgX rules and skills installed");
3791
3747
  printSkillInstallReport(report);
3792
3748
  });