maxsimcli 4.7.0 → 4.8.0

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/install.cjs CHANGED
@@ -32,10 +32,10 @@ let node_fs = require("node:fs");
32
32
  node_fs = __toESM(node_fs);
33
33
  let node_path = require("node:path");
34
34
  node_path = __toESM(node_path);
35
- let node_os = require("node:os");
36
- node_os = __toESM(node_os);
37
35
  let node_process = require("node:process");
38
36
  node_process = __toESM(node_process);
37
+ let node_os = require("node:os");
38
+ node_os = __toESM(node_os);
39
39
  let node_tty = require("node:tty");
40
40
  node_tty = __toESM(node_tty);
41
41
  let figlet = require("figlet");
@@ -46,7 +46,6 @@ let node_readline = require("node:readline");
46
46
  node_readline = __toESM(node_readline);
47
47
  let node_crypto = require("node:crypto");
48
48
  node_crypto = __toESM(node_crypto);
49
- let node_child_process = require("node:child_process");
50
49
 
51
50
  //#region ../../node_modules/universalify/index.js
52
51
  var require_universalify = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -1974,7 +1973,6 @@ var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1974
1973
 
1975
1974
  //#endregion
1976
1975
  //#region ../../node_modules/chalk/source/vendor/ansi-styles/index.js
1977
- var import_lib = /* @__PURE__ */ __toESM(require_lib$1());
1978
1976
  const ANSI_BACKGROUND_OFFSET = 10;
1979
1977
  const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
1980
1978
  const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
@@ -5645,11 +5643,7 @@ function ora(options) {
5645
5643
 
5646
5644
  //#endregion
5647
5645
  //#region ../../node_modules/@inquirer/core/dist/lib/key.js
5648
- const isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
5649
- const isDownKey = (key, keybindings = []) => key.name === "down" || keybindings.includes("vim") && key.name === "j" || keybindings.includes("emacs") && key.ctrl && key.name === "n";
5650
- const isBackspaceKey = (key) => key.name === "backspace";
5651
5646
  const isTabKey = (key) => key.name === "tab";
5652
- const isNumberKey = (key) => "1234567890".includes(key.name);
5653
5647
  const isEnterKey = (key) => key.name === "enter" || key.name === "return";
5654
5648
 
5655
5649
  //#endregion
@@ -6166,23 +6160,6 @@ function usePrefix({ status = "idle", theme }) {
6166
6160
  return typeof prefix === "string" ? prefix : prefix[status === "loading" ? "idle" : status] ?? prefix["idle"];
6167
6161
  }
6168
6162
 
6169
- //#endregion
6170
- //#region ../../node_modules/@inquirer/core/dist/lib/use-memo.js
6171
- function useMemo(fn, dependencies) {
6172
- return withPointer((pointer) => {
6173
- const prev = pointer.get();
6174
- if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
6175
- const value = fn();
6176
- pointer.set({
6177
- value,
6178
- dependencies
6179
- });
6180
- return value;
6181
- }
6182
- return prev.value;
6183
- });
6184
- }
6185
-
6186
6163
  //#endregion
6187
6164
  //#region ../../node_modules/@inquirer/core/dist/lib/use-ref.js
6188
6165
  function useRef(val) {
@@ -6550,90 +6527,6 @@ function readlineWidth() {
6550
6527
  });
6551
6528
  }
6552
6529
 
6553
- //#endregion
6554
- //#region ../../node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
6555
- function usePointerPosition({ active, renderedItems, pageSize, loop }) {
6556
- const state = useRef({
6557
- lastPointer: active,
6558
- lastActive: void 0
6559
- });
6560
- const { lastPointer, lastActive } = state.current;
6561
- const middle = Math.floor(pageSize / 2);
6562
- const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
6563
- const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
6564
- let pointer = defaultPointerPosition;
6565
- if (renderedLength > pageSize) if (loop) {
6566
- /**
6567
- * Creates the next position for the pointer considering an infinitely
6568
- * looping list of items to be rendered on the page.
6569
- *
6570
- * The goal is to progressively move the cursor to the middle position as the user move down, and then keep
6571
- * the cursor there. When the user move up, maintain the cursor position.
6572
- */
6573
- pointer = lastPointer;
6574
- if (lastActive != null && lastActive < active && active - lastActive < pageSize) pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
6575
- } else {
6576
- /**
6577
- * Creates the next position for the pointer considering a finite list of
6578
- * items to be rendered on a page.
6579
- *
6580
- * The goal is to keep the pointer in the middle of the page whenever possible, until
6581
- * we reach the bounds of the list (top or bottom). In which case, the cursor moves progressively
6582
- * to the bottom or top of the list.
6583
- */
6584
- const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
6585
- pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
6586
- }
6587
- state.current.lastPointer = pointer;
6588
- state.current.lastActive = active;
6589
- return pointer;
6590
- }
6591
- function usePagination({ items, active, renderItem, pageSize, loop = true }) {
6592
- const width = readlineWidth();
6593
- const bound = (num) => (num % items.length + items.length) % items.length;
6594
- const renderedItems = items.map((item, index) => {
6595
- if (item == null) return [];
6596
- return breakLines(renderItem({
6597
- item,
6598
- index,
6599
- isActive: index === active
6600
- }), width).split("\n");
6601
- });
6602
- const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
6603
- const renderItemAtIndex = (index) => renderedItems[index] ?? [];
6604
- const pointer = usePointerPosition({
6605
- active,
6606
- renderedItems,
6607
- pageSize,
6608
- loop
6609
- });
6610
- const activeItem = renderItemAtIndex(active).slice(0, pageSize);
6611
- const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
6612
- const pageBuffer = Array.from({ length: pageSize });
6613
- pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
6614
- const itemVisited = new Set([active]);
6615
- let bufferPointer = activeItemPosition + activeItem.length;
6616
- let itemPointer = bound(active + 1);
6617
- while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
6618
- const linesToAdd = renderItemAtIndex(itemPointer).slice(0, pageSize - bufferPointer);
6619
- pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
6620
- itemVisited.add(itemPointer);
6621
- bufferPointer += linesToAdd.length;
6622
- itemPointer = bound(itemPointer + 1);
6623
- }
6624
- bufferPointer = activeItemPosition - 1;
6625
- itemPointer = bound(active - 1);
6626
- while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
6627
- const lines = renderItemAtIndex(itemPointer);
6628
- const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
6629
- pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
6630
- itemVisited.add(itemPointer);
6631
- bufferPointer -= linesToAdd.length;
6632
- itemPointer = bound(itemPointer - 1);
6633
- }
6634
- return pageBuffer.filter((line) => typeof line === "string").join("\n");
6635
- }
6636
-
6637
6530
  //#endregion
6638
6531
  //#region ../../node_modules/mute-stream/lib/index.js
6639
6532
  var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -7121,23 +7014,6 @@ function createPrompt(view) {
7121
7014
  return prompt;
7122
7015
  }
7123
7016
 
7124
- //#endregion
7125
- //#region ../../node_modules/@inquirer/core/dist/lib/Separator.js
7126
- /**
7127
- * Separator object
7128
- * Used to space/separate choices group
7129
- */
7130
- var Separator = class {
7131
- separator = (0, node_util.styleText)("dim", Array.from({ length: 15 }).join(figures.line));
7132
- type = "separator";
7133
- constructor(separator) {
7134
- if (separator) this.separator = separator;
7135
- }
7136
- static isSeparator(choice) {
7137
- return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
7138
- }
7139
- };
7140
-
7141
7017
  //#endregion
7142
7018
  //#region ../../node_modules/@inquirer/confirm/dist/index.js
7143
7019
  function getBooleanValue(value, defaultValue) {
@@ -7149,7 +7025,7 @@ function getBooleanValue(value, defaultValue) {
7149
7025
  function boolToString(value) {
7150
7026
  return value ? "Yes" : "No";
7151
7027
  }
7152
- var dist_default$1 = createPrompt((config, done) => {
7028
+ var dist_default = createPrompt((config, done) => {
7153
7029
  const { transformer = boolToString } = config;
7154
7030
  const [status, setStatus] = useState("idle");
7155
7031
  const [value, setValue] = useState("");
@@ -7179,162 +7055,6 @@ var dist_default$1 = createPrompt((config, done) => {
7179
7055
  return `${prefix} ${theme.style.message(config.message, status)}${defaultValue} ${formattedValue}`;
7180
7056
  });
7181
7057
 
7182
- //#endregion
7183
- //#region ../../node_modules/@inquirer/select/dist/index.js
7184
- const selectTheme = {
7185
- icon: { cursor: figures.pointer },
7186
- style: {
7187
- disabled: (text) => (0, node_util.styleText)("dim", text),
7188
- description: (text) => (0, node_util.styleText)("cyan", text),
7189
- keysHelpTip: (keys) => keys.map(([key, action]) => `${(0, node_util.styleText)("bold", key)} ${(0, node_util.styleText)("dim", action)}`).join((0, node_util.styleText)("dim", " • "))
7190
- },
7191
- i18n: { disabledError: "This option is disabled and cannot be selected." },
7192
- indexMode: "hidden",
7193
- keybindings: []
7194
- };
7195
- function isSelectable(item) {
7196
- return !Separator.isSeparator(item) && !item.disabled;
7197
- }
7198
- function isNavigable(item) {
7199
- return !Separator.isSeparator(item);
7200
- }
7201
- function normalizeChoices(choices) {
7202
- return choices.map((choice) => {
7203
- if (Separator.isSeparator(choice)) return choice;
7204
- if (typeof choice !== "object" || choice === null || !("value" in choice)) {
7205
- const name = String(choice);
7206
- return {
7207
- value: choice,
7208
- name,
7209
- short: name,
7210
- disabled: false
7211
- };
7212
- }
7213
- const name = choice.name ?? String(choice.value);
7214
- const normalizedChoice = {
7215
- value: choice.value,
7216
- name,
7217
- short: choice.short ?? name,
7218
- disabled: choice.disabled ?? false
7219
- };
7220
- if (choice.description) normalizedChoice.description = choice.description;
7221
- return normalizedChoice;
7222
- });
7223
- }
7224
- var dist_default = createPrompt((config, done) => {
7225
- const { loop = true, pageSize = 7 } = config;
7226
- const theme = makeTheme(selectTheme, config.theme);
7227
- const { keybindings } = theme;
7228
- const [status, setStatus] = useState("idle");
7229
- const prefix = usePrefix({
7230
- status,
7231
- theme
7232
- });
7233
- const searchTimeoutRef = useRef();
7234
- const searchEnabled = !keybindings.includes("vim");
7235
- const items = useMemo(() => normalizeChoices(config.choices), [config.choices]);
7236
- const bounds = useMemo(() => {
7237
- const first = items.findIndex(isNavigable);
7238
- const last = items.findLastIndex(isNavigable);
7239
- if (first === -1) throw new ValidationError("[select prompt] No selectable choices. All choices are disabled.");
7240
- return {
7241
- first,
7242
- last
7243
- };
7244
- }, [items]);
7245
- const defaultItemIndex = useMemo(() => {
7246
- if (!("default" in config)) return -1;
7247
- return items.findIndex((item) => isSelectable(item) && item.value === config.default);
7248
- }, [config.default, items]);
7249
- const [active, setActive] = useState(defaultItemIndex === -1 ? bounds.first : defaultItemIndex);
7250
- const selectedChoice = items[active];
7251
- const [errorMsg, setError] = useState();
7252
- useKeypress((key, rl) => {
7253
- clearTimeout(searchTimeoutRef.current);
7254
- if (errorMsg) setError(void 0);
7255
- if (isEnterKey(key)) if (selectedChoice.disabled) setError(theme.i18n.disabledError);
7256
- else {
7257
- setStatus("done");
7258
- done(selectedChoice.value);
7259
- }
7260
- else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
7261
- rl.clearLine(0);
7262
- if (loop || isUpKey(key, keybindings) && active !== bounds.first || isDownKey(key, keybindings) && active !== bounds.last) {
7263
- const offset = isUpKey(key, keybindings) ? -1 : 1;
7264
- let next = active;
7265
- do
7266
- next = (next + offset + items.length) % items.length;
7267
- while (!isNavigable(items[next]));
7268
- setActive(next);
7269
- }
7270
- } else if (isNumberKey(key) && !Number.isNaN(Number(rl.line))) {
7271
- const selectedIndex = Number(rl.line) - 1;
7272
- let selectableIndex = -1;
7273
- const position = items.findIndex((item) => {
7274
- if (Separator.isSeparator(item)) return false;
7275
- selectableIndex++;
7276
- return selectableIndex === selectedIndex;
7277
- });
7278
- const item = items[position];
7279
- if (item != null && isSelectable(item)) setActive(position);
7280
- searchTimeoutRef.current = setTimeout(() => {
7281
- rl.clearLine(0);
7282
- }, 700);
7283
- } else if (isBackspaceKey(key)) rl.clearLine(0);
7284
- else if (searchEnabled) {
7285
- const searchTerm = rl.line.toLowerCase();
7286
- const matchIndex = items.findIndex((item) => {
7287
- if (Separator.isSeparator(item) || !isSelectable(item)) return false;
7288
- return item.name.toLowerCase().startsWith(searchTerm);
7289
- });
7290
- if (matchIndex !== -1) setActive(matchIndex);
7291
- searchTimeoutRef.current = setTimeout(() => {
7292
- rl.clearLine(0);
7293
- }, 700);
7294
- }
7295
- });
7296
- useEffect(() => () => {
7297
- clearTimeout(searchTimeoutRef.current);
7298
- }, []);
7299
- const message = theme.style.message(config.message, status);
7300
- const helpLine = theme.style.keysHelpTip([["↑↓", "navigate"], ["⏎", "select"]]);
7301
- let separatorCount = 0;
7302
- const page = usePagination({
7303
- items,
7304
- active,
7305
- renderItem({ item, isActive, index }) {
7306
- if (Separator.isSeparator(item)) {
7307
- separatorCount++;
7308
- return ` ${item.separator}`;
7309
- }
7310
- const cursor = isActive ? theme.icon.cursor : " ";
7311
- const indexLabel = theme.indexMode === "number" ? `${index + 1 - separatorCount}. ` : "";
7312
- if (item.disabled) {
7313
- const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
7314
- const disabledCursor = isActive ? theme.icon.cursor : "-";
7315
- return theme.style.disabled(`${disabledCursor} ${indexLabel}${item.name} ${disabledLabel}`);
7316
- }
7317
- return (isActive ? theme.style.highlight : (x) => x)(`${cursor} ${indexLabel}${item.name}`);
7318
- },
7319
- pageSize,
7320
- loop
7321
- });
7322
- if (status === "done") return [
7323
- prefix,
7324
- message,
7325
- theme.style.answer(selectedChoice.short)
7326
- ].filter(Boolean).join(" ");
7327
- const { description } = selectedChoice;
7328
- return `${[
7329
- [prefix, message].filter(Boolean).join(" "),
7330
- page,
7331
- " ",
7332
- description ? theme.style.description(description) : "",
7333
- errorMsg ? theme.style.error(errorMsg) : "",
7334
- helpLine
7335
- ].filter(Boolean).join("\n").trimEnd()}${cursorHide}`;
7336
- });
7337
-
7338
7058
  //#endregion
7339
7059
  //#region ../../node_modules/minimist/index.js
7340
7060
  var require_minimist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -7575,6 +7295,10 @@ const builtInSkills = [
7575
7295
  /**
7576
7296
  * Get the global config directory for Claude Code.
7577
7297
  * Priority: explicitDir > CLAUDE_CONFIG_DIR env > ~/.claude
7298
+ *
7299
+ * @deprecated Global install is no longer supported in v5.0+.
7300
+ * Kept for uninstall.ts (cleaning up old global installs) and adapters.ts.
7301
+ * TODO: Remove when global install cleanup path is no longer needed.
7578
7302
  */
7579
7303
  function getGlobalDir(explicitDir = null) {
7580
7304
  if (explicitDir) return expandTilde(explicitDir);
@@ -7584,6 +7308,9 @@ function getGlobalDir(explicitDir = null) {
7584
7308
  /**
7585
7309
  * Get the config directory path relative to home for hook templating.
7586
7310
  * Used for path.join(homeDir, '<configDir>', ...) replacement in hooks.
7311
+ *
7312
+ * @deprecated Global install is no longer supported in v5.0+.
7313
+ * TODO: Remove when hooks.ts no longer needs global/local distinction.
7587
7314
  */
7588
7315
  function getConfigDirFromHome(_isGlobal) {
7589
7316
  return "'.claude'";
@@ -7595,19 +7322,6 @@ function getDirName() {
7595
7322
  return ".claude";
7596
7323
  }
7597
7324
  /**
7598
- * Recursively remove a directory, handling Windows read-only file attributes.
7599
- * fs-extra handles cross-platform edge cases (EPERM on Windows, symlinks, etc.)
7600
- */
7601
- function safeRmDir(dirPath) {
7602
- import_lib.default.removeSync(dirPath);
7603
- }
7604
- /**
7605
- * Recursively copy a directory (dereferences symlinks)
7606
- */
7607
- function copyDirRecursive(src, dest) {
7608
- import_lib.default.copySync(src, dest, { dereference: true });
7609
- }
7610
- /**
7611
7325
  * Verify a directory exists and contains files.
7612
7326
  * If expectedFiles is provided, also checks that those specific files exist inside the directory.
7613
7327
  */
@@ -7709,154 +7423,6 @@ function getCommitAttribution(explicitConfigDir) {
7709
7423
  return attributionValue;
7710
7424
  }
7711
7425
 
7712
- //#endregion
7713
- //#region src/install/dashboard.ts
7714
- /** Check whether the current process is running with admin/root privileges. */
7715
- function isElevated() {
7716
- if (process.platform === "win32") try {
7717
- (0, node_child_process.execSync)("net session", { stdio: "pipe" });
7718
- return true;
7719
- } catch {
7720
- return false;
7721
- }
7722
- return process.getuid?.() === 0;
7723
- }
7724
- /**
7725
- * Add a firewall rule to allow inbound traffic on the given port.
7726
- * Handles Windows (netsh), Linux (ufw / iptables), and macOS (no rule needed).
7727
- */
7728
- function applyFirewallRule(port) {
7729
- const platform = process.platform;
7730
- try {
7731
- if (platform === "win32") {
7732
- const cmd = `netsh advfirewall firewall add rule name="MAXSIM Dashboard" dir=in action=allow protocol=TCP localport=${port}`;
7733
- if (isElevated()) {
7734
- (0, node_child_process.execSync)(cmd, { stdio: "pipe" });
7735
- console.log(chalk.green(" ✓ Windows Firewall rule added for port " + port));
7736
- } else {
7737
- console.log(chalk.gray(" Requesting administrator privileges for firewall rule..."));
7738
- (0, node_child_process.execSync)(`powershell -NoProfile -Command "${`Start-Process cmd -ArgumentList '/c ${cmd}' -Verb RunAs -Wait`}"`, { stdio: "pipe" });
7739
- console.log(chalk.green(" ✓ Windows Firewall rule added for port " + port));
7740
- }
7741
- } else if (platform === "linux") {
7742
- const sudoPrefix = isElevated() ? "" : "sudo ";
7743
- try {
7744
- (0, node_child_process.execSync)(`${sudoPrefix}ufw allow ${port}/tcp`, { stdio: "pipe" });
7745
- console.log(chalk.green(" ✓ UFW rule added for port " + port));
7746
- } catch {
7747
- try {
7748
- (0, node_child_process.execSync)(`${sudoPrefix}iptables -A INPUT -p tcp --dport ${port} -j ACCEPT`, { stdio: "pipe" });
7749
- console.log(chalk.green(" ✓ iptables rule added for port " + port));
7750
- } catch {
7751
- console.log(chalk.yellow(` \u26a0 Could not add firewall rule automatically. Run: sudo ufw allow ${port}/tcp`));
7752
- }
7753
- }
7754
- } else if (platform === "darwin") console.log(chalk.gray(" macOS: No firewall rule needed (inbound connections are allowed by default)"));
7755
- } catch (err) {
7756
- console.warn(chalk.yellow(` \u26a0 Firewall rule failed: ${err.message}`));
7757
- console.warn(chalk.gray(` You may need to manually allow port ${port} through your firewall.`));
7758
- }
7759
- }
7760
- /**
7761
- * Handle the `dashboard` subcommand — refresh assets, install node-pty, launch server
7762
- */
7763
- async function runDashboardSubcommand(argv) {
7764
- const { spawn: spawnDash, execSync: execSyncDash } = await import("node:child_process");
7765
- const dashboardAssetSrc = node_path.resolve(__dirname, "assets", "dashboard");
7766
- const installDir = node_path.join(process.cwd(), ".claude");
7767
- const installDashDir = node_path.join(installDir, "dashboard");
7768
- if (node_fs.existsSync(dashboardAssetSrc)) {
7769
- const nodeModulesDir = node_path.join(installDashDir, "node_modules");
7770
- const nodeModulesTmp = node_path.join(installDir, "_dashboard_node_modules_tmp");
7771
- const hadNodeModules = node_fs.existsSync(nodeModulesDir);
7772
- if (hadNodeModules) node_fs.renameSync(nodeModulesDir, nodeModulesTmp);
7773
- safeRmDir(installDashDir);
7774
- node_fs.mkdirSync(installDashDir, { recursive: true });
7775
- copyDirRecursive(dashboardAssetSrc, installDashDir);
7776
- if (hadNodeModules && node_fs.existsSync(nodeModulesTmp)) node_fs.renameSync(nodeModulesTmp, nodeModulesDir);
7777
- const dashConfigPath = node_path.join(installDir, "dashboard.json");
7778
- if (!node_fs.existsSync(dashConfigPath)) node_fs.writeFileSync(dashConfigPath, JSON.stringify({ projectCwd: process.cwd() }, null, 2) + "\n");
7779
- }
7780
- const localDashboard = node_path.join(process.cwd(), ".claude", "dashboard", "server.js");
7781
- const globalDashboard = node_path.join(node_os.homedir(), ".claude", "dashboard", "server.js");
7782
- let serverPath = null;
7783
- if (node_fs.existsSync(localDashboard)) serverPath = localDashboard;
7784
- else if (node_fs.existsSync(globalDashboard)) serverPath = globalDashboard;
7785
- if (!serverPath) {
7786
- console.log(chalk.yellow("\n Dashboard not available.\n"));
7787
- console.log(" Install MAXSIM first: " + chalk.cyan("npx maxsimcli@latest") + "\n");
7788
- process.exit(0);
7789
- }
7790
- const forceNetwork = !!argv["network"];
7791
- const dashboardDir = node_path.dirname(serverPath);
7792
- const dashboardConfigPath = node_path.join(node_path.dirname(dashboardDir), "dashboard.json");
7793
- let projectCwd = process.cwd();
7794
- let networkMode = forceNetwork;
7795
- if (node_fs.existsSync(dashboardConfigPath)) try {
7796
- const config = JSON.parse(node_fs.readFileSync(dashboardConfigPath, "utf8"));
7797
- if (config.projectCwd) projectCwd = config.projectCwd;
7798
- if (!forceNetwork) networkMode = config.networkMode ?? false;
7799
- } catch {}
7800
- const dashDirForPty = node_path.dirname(serverPath);
7801
- const ptyModulePath = node_path.join(dashDirForPty, "node_modules", "node-pty");
7802
- if (!node_fs.existsSync(ptyModulePath)) {
7803
- console.log(chalk.gray(" Installing node-pty for terminal support..."));
7804
- try {
7805
- const dashPkgPath = node_path.join(dashDirForPty, "package.json");
7806
- if (!node_fs.existsSync(dashPkgPath)) node_fs.writeFileSync(dashPkgPath, "{\"private\":true}\n");
7807
- execSyncDash("npm install node-pty --save-optional --no-audit --no-fund --loglevel=error", {
7808
- cwd: dashDirForPty,
7809
- stdio: "inherit",
7810
- timeout: 12e4
7811
- });
7812
- } catch {
7813
- console.warn(chalk.yellow(" node-pty installation failed — terminal will be unavailable."));
7814
- }
7815
- }
7816
- console.log(chalk.blue("Starting dashboard..."));
7817
- console.log(chalk.gray(` Project: ${projectCwd}`));
7818
- console.log(chalk.gray(` Server: ${serverPath}`));
7819
- if (networkMode) console.log(chalk.gray(" Network: enabled (local network access + QR code)"));
7820
- console.log("");
7821
- spawnDash(process.execPath, [serverPath], {
7822
- cwd: dashboardDir,
7823
- detached: true,
7824
- stdio: "ignore",
7825
- env: {
7826
- ...process.env,
7827
- MAXSIM_PROJECT_CWD: projectCwd,
7828
- MAXSIM_NETWORK_MODE: networkMode ? "1" : "0",
7829
- NODE_ENV: "production"
7830
- }
7831
- }).unref();
7832
- const POLL_INTERVAL_MS = 500;
7833
- const POLL_TIMEOUT_MS = 2e4;
7834
- const HEALTH_TIMEOUT_MS = 1e3;
7835
- const DEFAULT_PORT = 3333;
7836
- const PORT_RANGE_END = 3343;
7837
- let foundUrl = null;
7838
- const deadline = Date.now() + POLL_TIMEOUT_MS;
7839
- while (Date.now() < deadline) {
7840
- await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
7841
- for (let p = DEFAULT_PORT; p <= PORT_RANGE_END; p++) try {
7842
- const controller = new AbortController();
7843
- const timer = setTimeout(() => controller.abort(), HEALTH_TIMEOUT_MS);
7844
- const res = await fetch(`http://localhost:${p}/api/health`, { signal: controller.signal });
7845
- clearTimeout(timer);
7846
- if (res.ok) {
7847
- if ((await res.json()).status === "ok") {
7848
- foundUrl = `http://localhost:${p}`;
7849
- break;
7850
- }
7851
- }
7852
- } catch {}
7853
- if (foundUrl) break;
7854
- }
7855
- if (foundUrl) console.log(chalk.green(` Dashboard ready at ${foundUrl}`));
7856
- else console.log(chalk.yellow("\n Dashboard did not respond after 20s. The server may still be starting — check http://localhost:3333"));
7857
- process.exit(0);
7858
- }
7859
-
7860
7426
  //#endregion
7861
7427
  //#region src/install/hooks.ts
7862
7428
  /**
@@ -7998,7 +7564,7 @@ async function handleStatusline(settings, isInteractive, forceStatusline) {
7998
7564
  console.log(" • Current task (from todo list)");
7999
7565
  console.log(" • Context window usage (color-coded)");
8000
7566
  console.log();
8001
- return await dist_default$1({
7567
+ return await dist_default({
8002
7568
  message: "Replace with MAXSIM statusline?",
8003
7569
  default: false
8004
7570
  });
@@ -8318,9 +7884,9 @@ function uninstall(isGlobal, explicitConfigDir = null) {
8318
7884
 
8319
7885
  //#endregion
8320
7886
  //#region src/install/index.ts
7887
+ var import_lib = /* @__PURE__ */ __toESM(require_lib$1());
8321
7888
  const argv = (0, import_minimist.default)(process.argv.slice(2), {
8322
7889
  boolean: [
8323
- "global",
8324
7890
  "local",
8325
7891
  "claude",
8326
7892
  "uninstall",
@@ -8331,14 +7897,12 @@ const argv = (0, import_minimist.default)(process.argv.slice(2), {
8331
7897
  ],
8332
7898
  string: ["config-dir"],
8333
7899
  alias: {
8334
- g: "global",
8335
7900
  l: "local",
8336
7901
  u: "uninstall",
8337
7902
  h: "help",
8338
7903
  c: "config-dir"
8339
7904
  }
8340
7905
  });
8341
- const hasGlobal = !!argv["global"];
8342
7906
  const hasLocal = !!argv["local"];
8343
7907
  const hasUninstall = !!argv["uninstall"];
8344
7908
  const banner = "\n" + chalk.cyan(figlet.default.textSync("MAXSIM", { font: "ANSI Shadow" }).split("\n").map((line) => " " + line).join("\n")) + "\n\n MAXSIM " + chalk.dim("v" + pkg.version) + "\n A meta-prompting, context engineering and spec-driven\n development system for Claude Code.\n";
@@ -8356,29 +7920,35 @@ for (const flag of [
8356
7920
  console.error(`Error: The --${flag} flag is no longer supported. MAXSIM v2.0 is Claude Code only.`);
8357
7921
  process.exit(1);
8358
7922
  }
7923
+ if (argv["global"] || argv["g"]) {
7924
+ console.error(chalk.red("Error: Global install is no longer supported."));
7925
+ console.error("MAXSIM v5.0+ installs locally to .claude/ in your project directory.");
7926
+ console.error("Run: npx maxsimcli --local");
7927
+ process.exit(1);
7928
+ }
8359
7929
  if (hasVersion) {
8360
7930
  console.log(pkg.version);
8361
7931
  process.exit(0);
8362
7932
  }
8363
7933
  console.log(banner);
8364
7934
  if (hasHelp) {
8365
- console.log(` ${chalk.yellow("Usage:")} npx maxsimcli [options]\n\n ${chalk.yellow("Options:")}\n ${chalk.cyan("-g, --global")} Install globally (to config directory)\n ${chalk.cyan("-l, --local")} Install locally (to current directory)\n ${chalk.cyan("-u, --uninstall")} Uninstall MAXSIM (remove all MAXSIM files)\n ${chalk.cyan("-c, --config-dir <path>")} Specify custom config directory\n ${chalk.cyan("-h, --help")} Show this help message\n ${chalk.cyan("--force-statusline")} Replace existing statusline config\n\n ${chalk.yellow("Examples:")}\n ${chalk.dim("# Interactive install (prompts for location)")}\n npx maxsimcli\n\n ${chalk.dim("# Install globally")}\n npx maxsimcli --global\n\n ${chalk.dim("# Install to current project only")}\n npx maxsimcli --local\n\n ${chalk.dim("# Install to custom config directory")}\n npx maxsimcli --global --config-dir ~/.claude-work\n\n ${chalk.dim("# Uninstall MAXSIM globally")}\n npx maxsimcli --global --uninstall\n\n ${chalk.yellow("Notes:")}\n The --config-dir option is useful when you have multiple configurations.\n It takes priority over the CLAUDE_CONFIG_DIR environment variable.\n`);
7935
+ console.log(` ${chalk.yellow("Usage:")} npx maxsimcli [options]\n\n ${chalk.yellow("Options:")}\n ${chalk.cyan("-l, --local")} Install to current project directory (default)\n ${chalk.cyan("-u, --uninstall")} Uninstall MAXSIM (remove all MAXSIM files)\n ${chalk.cyan("-c, --config-dir <path>")} Specify custom local directory name\n ${chalk.cyan("-h, --help")} Show this help message\n ${chalk.cyan("--force-statusline")} Replace existing statusline config\n\n ${chalk.yellow("Examples:")}\n ${chalk.dim("# Install to current project")}\n npx maxsimcli\n\n ${chalk.dim("# Explicit local install")}\n npx maxsimcli --local\n\n ${chalk.dim("# Uninstall MAXSIM")}\n npx maxsimcli --local --uninstall\n\n ${chalk.yellow("Notes:")}\n MAXSIM installs to .claude/ in your project directory.\n The --config-dir option specifies a custom directory name (relative to CWD).\n`);
8366
7936
  process.exit(0);
8367
7937
  }
8368
- async function install(isGlobal) {
7938
+ async function install() {
8369
7939
  const dirName = getDirName();
8370
7940
  const src = templatesRoot;
8371
- const targetDir = isGlobal ? getGlobalDir(explicitConfigDir) : node_path.join(process.cwd(), dirName);
8372
- const locationLabel = isGlobal ? targetDir.replace(node_os.homedir(), "~") : targetDir.replace(process.cwd(), ".");
8373
- const pathPrefix = isGlobal ? `${targetDir.replace(/\\/g, "/")}/` : `./${dirName}/`;
7941
+ const targetDir = explicitConfigDir ? node_path.resolve(process.cwd(), explicitConfigDir) : node_path.join(process.cwd(), dirName);
7942
+ const locationLabel = targetDir.replace(process.cwd(), ".");
7943
+ const pathPrefix = `./${dirName}/`;
8374
7944
  console.log(` Installing for ${chalk.cyan("Claude Code")} to ${chalk.cyan(locationLabel)}\n`);
8375
7945
  const failures = [];
8376
7946
  const existingManifest = readManifest(targetDir);
8377
7947
  const isAlreadyCurrent = existingManifest !== null && existingManifest.version === pkg.version;
8378
7948
  if (existingManifest !== null) {
8379
7949
  const { complete, missing } = verifyInstallComplete(targetDir, existingManifest);
8380
- if (!complete) console.log(` ${chalk.yellow("!")} Previous install (v${existingManifest.version}) is incomplete ${missing.length} missing file(s). Re-installing.`);
8381
- else if (isAlreadyCurrent) console.log(` ${chalk.dim(`Version ${pkg.version} already installed upgrading in place`)}`);
7950
+ if (!complete) console.log(` ${chalk.yellow("!")} Previous install (v${existingManifest.version}) is incomplete -- ${missing.length} missing file(s). Re-installing.`);
7951
+ else if (isAlreadyCurrent) console.log(` ${chalk.dim(`Version ${pkg.version} already installed -- upgrading in place`)}`);
8382
7952
  }
8383
7953
  saveLocalPatches(targetDir);
8384
7954
  cleanupOrphanedFiles(targetDir);
@@ -8518,7 +8088,7 @@ async function install(isGlobal) {
8518
8088
  node_fs.copyFileSync(toolSrc, toolDest);
8519
8089
  console.log(` ${chalk.green("✓")} Installed maxsim-tools.cjs`);
8520
8090
  } else {
8521
- console.warn(` ${chalk.yellow("!")} cli.cjs not found at ${toolSrc} maxsim-tools.cjs not installed`);
8091
+ console.warn(` ${chalk.yellow("!")} cli.cjs not found at ${toolSrc} -- maxsim-tools.cjs not installed`);
8522
8092
  failures.push("maxsim-tools.cjs");
8523
8093
  }
8524
8094
  const mcpSrc = node_path.resolve(__dirname, "mcp-server.cjs");
@@ -8527,35 +8097,9 @@ async function install(isGlobal) {
8527
8097
  node_fs.mkdirSync(binDir, { recursive: true });
8528
8098
  node_fs.copyFileSync(mcpSrc, mcpDest);
8529
8099
  console.log(` ${chalk.green("✓")} Installed mcp-server.cjs`);
8530
- } else console.warn(` ${chalk.yellow("!")} mcp-server.cjs not found MCP server not installed`);
8531
- installHookFiles(targetDir, isGlobal, failures);
8532
- const dashboardSrc = node_path.resolve(__dirname, "assets", "dashboard");
8533
- if (node_fs.existsSync(dashboardSrc)) {
8534
- let networkMode = false;
8535
- try {
8536
- networkMode = await dist_default$1({
8537
- message: "Allow dashboard to be accessible on your local network? (adds firewall rule, enables QR code)",
8538
- default: false
8539
- });
8540
- } catch {}
8541
- spinner = ora({
8542
- text: "Installing dashboard...",
8543
- color: "cyan"
8544
- }).start();
8545
- const dashboardDest = node_path.join(targetDir, "dashboard");
8546
- safeRmDir(dashboardDest);
8547
- copyDirRecursive(dashboardSrc, dashboardDest);
8548
- const dashboardConfigDest = node_path.join(targetDir, "dashboard.json");
8549
- const projectCwd = isGlobal ? targetDir : process.cwd();
8550
- node_fs.writeFileSync(dashboardConfigDest, JSON.stringify({
8551
- projectCwd,
8552
- networkMode
8553
- }, null, 2) + "\n");
8554
- if (node_fs.existsSync(node_path.join(dashboardDest, "server.js"))) spinner.succeed(chalk.green("✓") + " Installed dashboard");
8555
- else spinner.succeed(chalk.green("✓") + " Installed dashboard (server.js not found in bundle)");
8556
- if (networkMode) applyFirewallRule(3333);
8557
- }
8558
- const mcpJsonPath = isGlobal ? node_path.join(targetDir, "..", ".mcp.json") : node_path.join(process.cwd(), ".mcp.json");
8100
+ } else console.warn(` ${chalk.yellow("!")} mcp-server.cjs not found -- MCP server not installed`);
8101
+ installHookFiles(targetDir, false, failures);
8102
+ const mcpJsonPath = node_path.join(process.cwd(), ".mcp.json");
8559
8103
  let mcpConfig = {};
8560
8104
  let skipMcpConfig = false;
8561
8105
  if (node_fs.existsSync(mcpJsonPath)) {
@@ -8566,7 +8110,7 @@ async function install(isGlobal) {
8566
8110
  console.warn(` ${chalk.yellow("!")} .mcp.json is corrupted (invalid JSON). Backup saved to .mcp.json.bak`);
8567
8111
  let startFresh = true;
8568
8112
  try {
8569
- startFresh = await dist_default$1({
8113
+ startFresh = await dist_default({
8570
8114
  message: ".mcp.json is corrupted. Start with a fresh config? (No = abort MCP setup)",
8571
8115
  default: true
8572
8116
  });
@@ -8595,7 +8139,7 @@ async function install(isGlobal) {
8595
8139
  writeManifest(targetDir);
8596
8140
  console.log(` ${chalk.green("✓")} Wrote file manifest (${MANIFEST_NAME})`);
8597
8141
  reportLocalPatches(targetDir);
8598
- const { settingsPath, settings, statuslineCommand } = configureSettingsHooks(targetDir, isGlobal);
8142
+ const { settingsPath, settings, statuslineCommand } = configureSettingsHooks(targetDir, false);
8599
8143
  return {
8600
8144
  settingsPath,
8601
8145
  settings,
@@ -8603,26 +8147,6 @@ async function install(isGlobal) {
8603
8147
  };
8604
8148
  }
8605
8149
  /**
8606
- * Prompt for install location
8607
- */
8608
- async function promptLocation() {
8609
- if (!process.stdin.isTTY) {
8610
- console.log(chalk.yellow("Non-interactive terminal detected, defaulting to global install") + "\n");
8611
- return true;
8612
- }
8613
- const globalPath = getGlobalDir(explicitConfigDir).replace(node_os.homedir(), "~");
8614
- return await dist_default({
8615
- message: "Where would you like to install?",
8616
- choices: [{
8617
- name: "Global " + chalk.dim(`(${globalPath})`) + " — available in all projects",
8618
- value: "global"
8619
- }, {
8620
- name: "Local " + chalk.dim("(./.claude)") + " — this project only",
8621
- value: "local"
8622
- }]
8623
- }) === "global";
8624
- }
8625
- /**
8626
8150
  * Prompt whether to enable Agent Teams (experimental feature)
8627
8151
  */
8628
8152
  async function promptAgentTeams() {
@@ -8631,16 +8155,16 @@ async function promptAgentTeams() {
8631
8155
  console.log(chalk.dim(" Coordinate multiple Claude Code instances working in parallel."));
8632
8156
  console.log(chalk.dim(" Enables CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS in settings.json."));
8633
8157
  console.log();
8634
- return dist_default$1({
8158
+ return dist_default({
8635
8159
  message: "Enable Agent Teams?",
8636
8160
  default: false
8637
8161
  });
8638
8162
  }
8639
8163
  /**
8640
- * Install MAXSIM for Claude Code
8164
+ * Install MAXSIM for Claude Code (always local)
8641
8165
  */
8642
- async function installForClaude(isGlobal, isInteractive) {
8643
- const result = await install(isGlobal);
8166
+ async function installForClaude(isInteractive) {
8167
+ const result = await install();
8644
8168
  let shouldInstallStatusline = false;
8645
8169
  if (result.settings) shouldInstallStatusline = await handleStatusline(result.settings, isInteractive, forceStatusline);
8646
8170
  let enableAgentTeams = false;
@@ -8650,17 +8174,13 @@ async function installForClaude(isGlobal, isInteractive) {
8650
8174
  env["CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS"] = "1";
8651
8175
  result.settings.env = env;
8652
8176
  }
8653
- finishInstall(result.settingsPath, result.settings, result.statuslineCommand, shouldInstallStatusline, isGlobal);
8177
+ finishInstall(result.settingsPath, result.settings, result.statuslineCommand, shouldInstallStatusline, false);
8654
8178
  }
8655
8179
  const subcommand = argv._[0];
8656
8180
  (async () => {
8657
- if (subcommand === "dashboard") {
8658
- await runDashboardSubcommand(argv);
8659
- return;
8660
- }
8661
8181
  if (subcommand === "skill-list" || subcommand === "skill-install" || subcommand === "skill-update") {
8662
- const { cmdSkillList, cmdSkillInstall, cmdSkillUpdate } = await Promise.resolve().then(() => require("./skills-MYlMkYNt.cjs"));
8663
- const { CliOutput, writeOutput, CliError } = await Promise.resolve().then(() => require("./core-RRjCSt0G.cjs"));
8182
+ const { cmdSkillList, cmdSkillInstall, cmdSkillUpdate } = await Promise.resolve().then(() => require("./skills-CjFWZIGM.cjs"));
8183
+ const { CliOutput, writeOutput, CliError } = await Promise.resolve().then(() => require("./core-D5zUr9cb.cjs"));
8664
8184
  const cwd = process.cwd();
8665
8185
  try {
8666
8186
  if (subcommand === "skill-list") cmdSkillList(cwd, false);
@@ -8679,23 +8199,13 @@ const subcommand = argv._[0];
8679
8199
  }
8680
8200
  return;
8681
8201
  }
8682
- if (hasGlobal && hasLocal) {
8683
- console.error(chalk.yellow("Cannot specify both --global and --local"));
8684
- process.exit(1);
8685
- } else if (explicitConfigDir && hasLocal) {
8686
- console.error(chalk.yellow("Cannot use --config-dir with --local"));
8687
- process.exit(1);
8688
- } else if (hasUninstall) {
8689
- if (!hasGlobal && !hasLocal) {
8690
- console.error(chalk.yellow("--uninstall requires --global or --local"));
8202
+ if (hasUninstall) {
8203
+ if (!hasLocal) {
8204
+ console.error(chalk.yellow("--uninstall requires --local"));
8691
8205
  process.exit(1);
8692
8206
  }
8693
- uninstall(hasGlobal, explicitConfigDir);
8694
- } else if (hasGlobal || hasLocal) await installForClaude(hasGlobal, false);
8695
- else if (!process.stdin.isTTY) {
8696
- console.log(chalk.yellow("Non-interactive terminal detected, defaulting to global install") + "\n");
8697
- await installForClaude(true, false);
8698
- } else await installForClaude(await promptLocation(), true);
8207
+ uninstall(false, explicitConfigDir);
8208
+ } else await installForClaude(process.stdin.isTTY === true);
8699
8209
  })().catch((err) => {
8700
8210
  if (err instanceof Error && err.message.includes("User force closed")) {
8701
8211
  console.log("\n" + chalk.yellow("Installation cancelled") + "\n");