dominus-cli 0.5.0 → 0.5.1

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 CHANGED
@@ -19,6 +19,7 @@ import { randomBytes } from 'crypto';
19
19
  import Spinner from 'ink-spinner';
20
20
  import OpenAI from 'openai';
21
21
  import https from 'https';
22
+ import { fileURLToPath } from 'url';
22
23
 
23
24
  var __defProp = Object.defineProperty;
24
25
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -4751,7 +4752,62 @@ function formatUpdateMessage(info) {
4751
4752
  ""
4752
4753
  ].join("\n");
4753
4754
  }
4754
- var VERSION = "0.2.1";
4755
+ async function autoUpdate(currentVersion) {
4756
+ const info = await checkForUpdate(currentVersion);
4757
+ if (!info?.updateAvailable) {
4758
+ return { success: true, from: currentVersion, to: currentVersion };
4759
+ }
4760
+ const managers = [
4761
+ { name: "pnpm", check: "pnpm list -g dominus-cli", cmd: "pnpm add -g dominus-cli@latest" },
4762
+ { name: "npm", check: "npm list -g dominus-cli", cmd: "npm install -g dominus-cli@latest" },
4763
+ { name: "yarn", check: "yarn global list --pattern dominus-cli", cmd: "yarn global add dominus-cli@latest" }
4764
+ ];
4765
+ let installCmd = null;
4766
+ for (const mgr of managers) {
4767
+ try {
4768
+ const out = execSync(mgr.check, { stdio: "pipe", timeout: 1e4 }).toString();
4769
+ if (out.includes("dominus-cli")) {
4770
+ installCmd = mgr.cmd;
4771
+ break;
4772
+ }
4773
+ } catch {
4774
+ }
4775
+ }
4776
+ if (!installCmd) {
4777
+ try {
4778
+ const out = execSync("pnpm list -g dominus-cli", { stdio: "pipe", timeout: 1e4 }).toString();
4779
+ if (out.includes("link:")) {
4780
+ const pkgPath = path4.resolve(__dirname$1, "..");
4781
+ if (fs5.existsSync(path4.join(pkgPath, ".git"))) {
4782
+ try {
4783
+ execSync("git pull", { cwd: pkgPath, stdio: "pipe", timeout: 3e4 });
4784
+ execSync("pnpm install", { cwd: pkgPath, stdio: "pipe", timeout: 6e4 });
4785
+ execSync("pnpm build", { cwd: pkgPath, stdio: "pipe", timeout: 6e4 });
4786
+ execSync("pnpm build:plugin", { cwd: pkgPath, stdio: "pipe", timeout: 3e4 });
4787
+ return { success: true, from: currentVersion, to: info.latestVersion };
4788
+ } catch (err) {
4789
+ return { success: false, from: currentVersion, to: info.latestVersion, error: `Git pull/rebuild failed: ${err}` };
4790
+ }
4791
+ }
4792
+ return { success: false, from: currentVersion, to: info.latestVersion, error: 'Linked install without git \u2014 run "pnpm build" manually in the repo' };
4793
+ }
4794
+ } catch {
4795
+ }
4796
+ }
4797
+ if (!installCmd) {
4798
+ installCmd = `npm install -g ${NPM_PACKAGE}@latest`;
4799
+ }
4800
+ try {
4801
+ execSync(installCmd, { stdio: "pipe", timeout: 12e4 });
4802
+ writeCache({ lastCheck: 0, latestVersion: null });
4803
+ return { success: true, from: currentVersion, to: info.latestVersion };
4804
+ } catch (err) {
4805
+ return { success: false, from: currentVersion, to: info.latestVersion, error: `Update command failed: ${err}` };
4806
+ }
4807
+ }
4808
+ var __dirname$1 = path4.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1"));
4809
+ var __dirname2 = path4.dirname(fileURLToPath(import.meta.url));
4810
+ var VERSION = JSON.parse(fs5.readFileSync(path4.join(__dirname2, "..", "package.json"), "utf-8")).version;
4755
4811
  var program = new Command();
4756
4812
  program.name("dominus").description("AI-powered autonomous agent for Roblox Studio development").version(VERSION);
4757
4813
  program.command("start", { isDefault: true }).description("Launch the Dominus TUI agent").option("-p, --port <port>", "WebSocket server port", "18088").action(async (opts) => {
@@ -4863,9 +4919,24 @@ rulesCmd.command("list").description("List all rules").action(() => {
4863
4919
  }
4864
4920
  console.log("");
4865
4921
  });
4922
+ program.command("update").description("Auto-update Dominus to the latest version").action(async () => {
4923
+ console.log(` Current version: ${VERSION}`);
4924
+ console.log(" Checking for updates...");
4925
+ const result = await autoUpdate(VERSION);
4926
+ if (result.from === result.to && result.success) {
4927
+ console.log(" Already on the latest version.");
4928
+ return;
4929
+ }
4930
+ if (result.success) {
4931
+ console.log(` \u2714 Updated: ${result.from} \u2192 ${result.to}`);
4932
+ console.log(" Restart dominus to use the new version.");
4933
+ } else {
4934
+ console.error(` \u2718 Update failed: ${result.error}`);
4935
+ }
4936
+ });
4866
4937
  program.command("install-plugin").description("Build & install the Dominus plugin into Roblox Studio").action(async () => {
4867
- const { execSync: execSync2 } = await import('child_process');
4868
- const packageRoot = path4.resolve(import.meta.dirname ?? __dirname, "..");
4938
+ const { execSync: execSync3 } = await import('child_process');
4939
+ const packageRoot = path4.resolve(import.meta.dirname ?? __dirname2, "..");
4869
4940
  const pluginDir = path4.join(packageRoot, "plugin");
4870
4941
  const pluginProject = path4.join(pluginDir, "default.project.json");
4871
4942
  const studioPlugins = path4.join(
@@ -4886,14 +4957,14 @@ program.command("install-plugin").description("Build & install the Dominus plugi
4886
4957
  }
4887
4958
  let rojoAvailable = false;
4888
4959
  try {
4889
- execSync2("rojo --version", { stdio: "pipe" });
4960
+ execSync3("rojo --version", { stdio: "pipe" });
4890
4961
  rojoAvailable = true;
4891
4962
  } catch {
4892
4963
  }
4893
4964
  if (rojoAvailable) {
4894
4965
  try {
4895
4966
  console.log(" Building plugin with Rojo...");
4896
- execSync2(`rojo build "${pluginDir}" -o "${destFile}"`, { stdio: "pipe" });
4967
+ execSync3(`rojo build "${pluginDir}" -o "${destFile}"`, { stdio: "pipe" });
4897
4968
  console.log(` \u2714 Plugin built and installed to: ${destFile}`);
4898
4969
  console.log(" Restart Roblox Studio to load the plugin.");
4899
4970
  } catch (err) {