ys-code-agent 2.0.0 → 2.0.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.
@@ -4011,7 +4011,7 @@ var init_config = __esm({
4011
4011
  summarizationThreshold: 50
4012
4012
  },
4013
4013
  logging: {
4014
- level: "info",
4014
+ level: "warn",
4015
4015
  file: (0, import_path.join)((0, import_os.homedir)(), ".ys-code-agent", "logs", "agent.log"),
4016
4016
  maxSize: 10485760,
4017
4017
  maxFiles: 5,
@@ -4250,6 +4250,9 @@ var init_config = __esm({
4250
4250
  });
4251
4251
 
4252
4252
  // src/logger/index.ts
4253
+ function setConsoleSuppressed(v) {
4254
+ consoleSuppressed = v;
4255
+ }
4253
4256
  function getLogger(module2) {
4254
4257
  if (!loggers.has(module2)) {
4255
4258
  loggers.set(module2, new Logger(module2));
@@ -4263,13 +4266,18 @@ function renameSync(oldPath, newPath) {
4263
4266
  } catch {
4264
4267
  }
4265
4268
  }
4269
+ function setAllLevels(level) {
4270
+ for (const logger19 of loggers.values()) {
4271
+ logger19.setLevel(level);
4272
+ }
4273
+ }
4266
4274
  function destroyAll() {
4267
4275
  for (const logger19 of loggers.values()) {
4268
4276
  logger19.destroy();
4269
4277
  }
4270
4278
  loggers.clear();
4271
4279
  }
4272
- var import_fs2, import_path2, LOG_LEVELS, Logger, loggers;
4280
+ var import_fs2, import_path2, LOG_LEVELS, consoleSuppressed, Logger, loggers;
4273
4281
  var init_logger = __esm({
4274
4282
  "src/logger/index.ts"() {
4275
4283
  "use strict";
@@ -4282,6 +4290,7 @@ var init_logger = __esm({
4282
4290
  warn: 2,
4283
4291
  error: 3
4284
4292
  };
4293
+ consoleSuppressed = true;
4285
4294
  Logger = class {
4286
4295
  level;
4287
4296
  filePath;
@@ -4371,7 +4380,7 @@ var init_logger = __esm({
4371
4380
  message,
4372
4381
  data
4373
4382
  };
4374
- if (this.consoleOutput) {
4383
+ if (this.consoleOutput && !consoleSuppressed) {
4375
4384
  const formatted = this.formatLog(entry);
4376
4385
  switch (level) {
4377
4386
  case "error":
@@ -13794,10 +13803,10 @@ var init_phoneOptimizer = __esm({
13794
13803
  return !!(process.env.PREFIX?.includes("termux") || process.env.HOME?.includes("com.termux") || process.env.TERMUX_VERSION);
13795
13804
  },
13796
13805
  get terminalWidth() {
13797
- return process.stdout.columns ?? 80;
13806
+ return Math.max(process.stdout.columns ?? 80, 20);
13798
13807
  },
13799
13808
  get terminalHeight() {
13800
- return process.stdout.rows ?? 24;
13809
+ return Math.max(process.stdout.rows ?? 24, 10);
13801
13810
  },
13802
13811
  get isNarrow() {
13803
13812
  return this.terminalWidth < 60;
@@ -13825,7 +13834,9 @@ var init_phoneOptimizer = __esm({
13825
13834
  return (0, import_os2.homedir)();
13826
13835
  },
13827
13836
  getWelcomeBoxWidth() {
13828
- return Math.min(this.terminalWidth - 4, 56);
13837
+ const raw = this.terminalWidth - 4;
13838
+ const clamped = Math.min(raw, 56);
13839
+ return Math.max(clamped, 20);
13829
13840
  },
13830
13841
  getPopupHeight() {
13831
13842
  if (this.isNarrow) return 6;
@@ -13836,7 +13847,7 @@ var init_phoneOptimizer = __esm({
13836
13847
  return !this.isTermux || !this.lowMemory;
13837
13848
  },
13838
13849
  showCompactWelcome() {
13839
- return this.isNarrow || this.terminalWidth < 50;
13850
+ return this.terminalWidth < 60;
13840
13851
  }
13841
13852
  };
13842
13853
  }
@@ -13988,7 +13999,7 @@ var init_CommandPopup = __esm({
13988
13999
  if (!this.visible) return "";
13989
14000
  const pw = phoneConfig.getPopupHeight();
13990
14001
  const maxHeight = Math.min(pw + 2, process.stdout.rows ? process.stdout.rows - 4 : 12);
13991
- const width = Math.min(process.stdout.columns ? process.stdout.columns - 4 : 60, 60);
14002
+ const width = Math.max(Math.min(process.stdout.columns ? process.stdout.columns - 4 : 60, 60), 10);
13992
14003
  const top = `\u250C\u2500${source_default.cyan(" Commands ")}${"\u2500".repeat(Math.max(0, width - 11))}\u2510`;
13993
14004
  const categorized = this.getCategorizedCommands();
13994
14005
  const lines = [];
@@ -15640,6 +15651,12 @@ init_source();
15640
15651
  init_config();
15641
15652
  init_phoneOptimizer();
15642
15653
  var animateState = 0;
15654
+ function safeLen(s) {
15655
+ return s.replace(/\x1b\[[0-9;]*m/g, "").length;
15656
+ }
15657
+ function safeRepeat(n) {
15658
+ return n > 0 ? " ".repeat(n) : "";
15659
+ }
15643
15660
  function generateWelcome() {
15644
15661
  if (phoneConfig.showCompactWelcome()) {
15645
15662
  return generateCompactWelcome();
@@ -15657,11 +15674,12 @@ function generateFullWelcome() {
15657
15674
  const diamond = animateState ? "\u25C6" : "\u25C7";
15658
15675
  const lines = [top];
15659
15676
  const titleRaw = ` ${diamond} YS CODE AGENT ${diamond} `;
15660
- const titlePad = Math.floor((w - titleRaw.length) / 2);
15661
- lines.push(`\u2551${" ".repeat(titlePad)}${source_default.cyan(titleRaw)}${" ".repeat(w - titlePad - titleRaw.length)}\u2551`);
15677
+ const titleStyled = source_default.cyan(titleRaw);
15678
+ const titlePad = Math.floor((w - safeLen(titleStyled)) / 2);
15679
+ lines.push(`\u2551${safeRepeat(titlePad)}${titleStyled}${safeRepeat(w - titlePad - safeLen(titleStyled))}\u2551`);
15662
15680
  const subtitle = source_default.gray("AI-Powered Terminal Coding Assistant");
15663
- const subPad = Math.floor((w - subtitle.length) / 2);
15664
- lines.push(`\u2551${" ".repeat(subPad)}${subtitle}${" ".repeat(w - subPad - subtitle.length)}\u2551`);
15681
+ const subPad = Math.floor((w - safeLen(subtitle)) / 2);
15682
+ lines.push(`\u2551${safeRepeat(subPad)}${subtitle}${safeRepeat(w - subPad - safeLen(subtitle))}\u2551`);
15665
15683
  lines.push(`\u2560${"\u2550".repeat(w)}\u2563`);
15666
15684
  const rows = [
15667
15685
  ["Provider", source_default.yellow(provider.name), "Model", source_default.yellow(modelShort)],
@@ -15673,16 +15691,16 @@ function generateFullWelcome() {
15673
15691
  for (const [label1, val1, label2, val2] of rows) {
15674
15692
  const part1 = `\u2551 ${source_default.white(label1)}: ${val1}`;
15675
15693
  const part2 = `${source_default.white(label2)}: ${val2}`;
15676
- const spacing = w - part1.length - part2.length - 1;
15694
+ const spacing = w - safeLen(part1) - safeLen(part2) - 1;
15677
15695
  const spaceStr = spacing > 0 ? " ".repeat(spacing) : " ";
15678
15696
  lines.push(`${part1}${spaceStr}${part2} ${source_default.gray("\u2502")}`);
15679
15697
  }
15680
15698
  lines.push(`\u2560${"\u2550".repeat(w)}\u2563`);
15681
15699
  const tipLine = ` ${source_default.gray("Type")} ${source_default.cyan("/")}${source_default.gray(" for commands")} ${source_default.gray("|")} ${source_default.cyan("?")}${source_default.gray(" for shortcuts")}`;
15682
- const tipPad = Math.floor((w - tipLine.length) / 2);
15683
- lines.push(`\u2551${" ".repeat(tipPad)}${tipLine}${" ".repeat(w - tipPad - tipLine.length)}\u2551`);
15700
+ const tipPad = Math.floor((w - safeLen(tipLine)) / 2);
15701
+ lines.push(`\u2551${safeRepeat(tipPad)}${tipLine}${safeRepeat(w - tipPad - safeLen(tipLine))}\u2551`);
15684
15702
  const projectLine = getProjectLine(w);
15685
- lines.push(`\u2551${projectLine}${" ".repeat(w - projectLine.length)}\u2551`);
15703
+ lines.push(`\u2551${projectLine}${safeRepeat(w - safeLen(projectLine))}\u2551`);
15686
15704
  lines.push(bottom);
15687
15705
  return lines.join("\n");
15688
15706
  }
@@ -15694,10 +15712,10 @@ function generateCompactWelcome() {
15694
15712
  const top = `\u2554${"\u2550".repeat(w)}\u2557`;
15695
15713
  const bottom = `\u255A${"\u2550".repeat(w)}\u255D`;
15696
15714
  const title = `${source_default.cyan("\u25C6 YS AGENT")} ${source_default.yellow(modelShort)}`;
15697
- const titlePad = Math.floor((w - title.length) / 2);
15715
+ const titlePad = Math.max(0, Math.floor((w - safeLen(title)) / 2));
15698
15716
  return [
15699
15717
  top,
15700
- `\u2551${" ".repeat(titlePad)}${title}${" ".repeat(w - titlePad - title.length)}\u2551`,
15718
+ `\u2551${safeRepeat(titlePad)}${title}${safeRepeat(w - titlePad - safeLen(title))}\u2551`,
15701
15719
  `\u2551 ${source_default.gray("Tools:")} ${source_default.green(`${countActiveTools()} Active`)} ${source_default.gray("Mode:")} ${source_default.cyan(getModeString())} \u2551`,
15702
15720
  `\u2551 ${source_default.gray("/ for commands | ? for shortcuts")} \u2551`,
15703
15721
  bottom
@@ -15713,6 +15731,9 @@ function getProjectLine(maxWidth) {
15713
15731
  let line = ` ${source_default.gray("\u{1F4C1}")} ${source_default.white(displayPath)}`;
15714
15732
  if (projectType) line += ` ${source_default.gray(`(${projectType})`)}`;
15715
15733
  if (gitBranch2) line += ` ${source_default.gray("\u2387")} ${source_default.yellow(gitBranch2)}`;
15734
+ if (safeLen(line) > maxWidth) {
15735
+ line = ` ${source_default.gray("\u{1F4C1}")} ${source_default.white(displayPath)}`;
15736
+ }
15716
15737
  return line;
15717
15738
  } catch {
15718
15739
  return "";
@@ -15858,8 +15879,6 @@ var TUI = class {
15858
15879
  }
15859
15880
  start() {
15860
15881
  this.running = true;
15861
- this.clear();
15862
- this.printWelcome();
15863
15882
  this.showPrompt();
15864
15883
  this.startKeyListener();
15865
15884
  }
@@ -16245,13 +16264,13 @@ var TUI = class {
16245
16264
  }
16246
16265
  printHelp() {
16247
16266
  const { ALL_COMMANDS: ALL_COMMANDS2 } = (init_CommandPopup(), __toCommonJS(CommandPopup_exports));
16248
- const w = Math.min(process.stdout.columns || 80, 72);
16267
+ const w = Math.max(Math.min(process.stdout.columns || 80, 72), 30);
16249
16268
  const top = `\u2554${"\u2550".repeat(w)}\u2557`;
16250
16269
  const bottom = `\u255A${"\u2550".repeat(w)}\u255D`;
16251
16270
  const lines = [top];
16252
16271
  const title = ` YS Code Agent \u2014 Commands `;
16253
- const titlePad = Math.floor((w - title.length) / 2);
16254
- lines.push(`\u2551${" ".repeat(titlePad)}${source_default.cyan(title)}${" ".repeat(w - titlePad - title.length)}\u2551`);
16272
+ const titlePad = Math.max(0, Math.floor((w - title.length) / 2));
16273
+ lines.push(`\u2551${" ".repeat(titlePad)}${source_default.cyan(title)}${" ".repeat(Math.max(0, w - titlePad - title.length))}\u2551`);
16255
16274
  lines.push(`\u2560${"\u2550".repeat(w)}\u2563`);
16256
16275
  const categories = {};
16257
16276
  for (const cmd of ALL_COMMANDS2) {
@@ -16294,7 +16313,7 @@ var TUI = class {
16294
16313
  for (const l of lines) this.printLine(l);
16295
16314
  }
16296
16315
  printWarning(message) {
16297
- const w = Math.min(process.stdout.columns || 80, 60);
16316
+ const w = Math.max(Math.min(process.stdout.columns || 80, 60), 10);
16298
16317
  const top = `\u2554${"\u2550".repeat(w)}\u2557`;
16299
16318
  const bottom = `\u255A${"\u2550".repeat(w)}\u255D`;
16300
16319
  this.printLine("");
@@ -16385,7 +16404,7 @@ var TUI = class {
16385
16404
  this.printLine(formatted);
16386
16405
  }
16387
16406
  printError(error) {
16388
- const w = Math.min(process.stdout.columns || 80, 56);
16407
+ const w = Math.max(Math.min(process.stdout.columns || 80, 56), 10);
16389
16408
  const top = `\u2554${"\u2550".repeat(w)}\u2557`;
16390
16409
  const bottom = `\u255A${"\u2550".repeat(w)}\u255D`;
16391
16410
  this.printLine("");
@@ -16417,15 +16436,15 @@ var TUI = class {
16417
16436
  if (truncated) parts.push(source_default.gray(`task:${truncated}`));
16418
16437
  }
16419
16438
  showShutdownScreen() {
16420
- const w = Math.min(process.stdout.columns || 80, 50);
16439
+ const w = Math.max(Math.min(process.stdout.columns || 80, 50), 30);
16421
16440
  const top = `\u256D${"\u2500".repeat(w)}\u256E`;
16422
16441
  const bottom = `\u2570${"\u2500".repeat(w)}\u256F`;
16423
16442
  console.log("");
16424
16443
  console.log(source_default.cyan(top));
16425
16444
  console.log(`\u2502${" ".repeat(w)}\u2502`);
16426
16445
  const titleLine = " \u25C6 YS Code Agent \u2014 Session Complete ";
16427
- const titlePad = Math.floor((w - titleLine.length) / 2);
16428
- console.log(`\u2502${" ".repeat(titlePad)}${source_default.cyan(titleLine)}${" ".repeat(w - titlePad - titleLine.length)}\u2502`);
16446
+ const titlePad = Math.max(0, Math.floor((w - titleLine.length) / 2));
16447
+ console.log(`\u2502${" ".repeat(titlePad)}${source_default.cyan(titleLine)}${" ".repeat(Math.max(0, w - titlePad - titleLine.length))}\u2502`);
16429
16448
  console.log(`\u2502${" ".repeat(w)}\u2502`);
16430
16449
  const { sessionManager: sessionManager2 } = (init_session(), __toCommonJS(session_exports));
16431
16450
  const session = sessionManager2.getCurrentSession();
@@ -16519,7 +16538,7 @@ ${(0, import_path8.relative)(process.cwd(), fullPath) || "."}/`));
16519
16538
  const ext = (0, import_path8.extname)(fullPath);
16520
16539
  const lang = getLanguageFromExtension(ext);
16521
16540
  tui.printLine(source_default.cyan(`
16522
- \u2554\u2550 ${(0, import_path8.basename)(fullPath)} (${lang}) \u2550${"\u2550".repeat(Math.min(40, phoneConfig.terminalWidth - 20))}\u2557`));
16541
+ \u2554\u2550 ${(0, import_path8.basename)(fullPath)} (${lang}) \u2550${"\u2550".repeat(Math.max(0, Math.min(40, phoneConfig.terminalWidth - 20)))}\u2557`));
16523
16542
  tui.printLine(source_default.gray(` Path: ${(0, import_path8.relative)(process.cwd(), fullPath)} | ${lines.length} lines | ${formatBytes(stat.size)}`));
16524
16543
  tui.printLine("");
16525
16544
  const maxLines = showAll ? lines.length : Math.min(lines.length, 100);
@@ -17416,7 +17435,7 @@ async function arenaStart(prompt) {
17416
17435
  const activeProv = configManager.getActiveProvider();
17417
17436
  const keySet = !!(activeProv.apiKey || process.env.OPENROUTER_API_KEY);
17418
17437
  if (!keySet) {
17419
- tui.printLine(`\u2551 ${source_default.red("\u2717 No API key configured for OpenRouter")}${" ".repeat(w - 44)}\u2551`);
17438
+ tui.printLine(`\u2551 ${source_default.red("\u2717 No API key configured for OpenRouter")}${" ".repeat(Math.max(0, w - 44))}\u2551`);
17420
17439
  tui.printLine(source_default.cyan(`\u255A${"\u2550".repeat(w)}\u255D`));
17421
17440
  return true;
17422
17441
  }
@@ -17438,8 +17457,8 @@ async function handleTasks(args) {
17438
17457
  const w = Math.min(phoneConfig.terminalWidth - 2, 50);
17439
17458
  tui.printLine(source_default.cyan(`
17440
17459
  \u2554\u2550 Background Tasks ${"\u2550".repeat(Math.max(0, w - 18))}\u2557`));
17441
- tui.printLine(`\u2551 ${source_default.gray("No background tasks running")}${" ".repeat(w - 30)}\u2551`);
17442
- tui.printLine(`\u2551 ${source_default.gray("Use /background <command> to run a task")}${" ".repeat(w - 45)}\u2551`);
17460
+ tui.printLine(`\u2551 ${source_default.gray("No background tasks running")}${" ".repeat(Math.max(0, w - 30))}\u2551`);
17461
+ tui.printLine(`\u2551 ${source_default.gray("Use /background <command> to run a task")}${" ".repeat(Math.max(0, w - 45))}\u2551`);
17443
17462
  tui.printLine(source_default.cyan(`\u255A${"\u2550".repeat(w)}\u255D`));
17444
17463
  }
17445
17464
  return true;
@@ -18269,8 +18288,8 @@ function approvalBadge(m) {
18269
18288
  return map[m] || source_default.gray(m);
18270
18289
  }
18271
18290
  function getProgressBar(pct, width) {
18272
- const filled = Math.round(pct / 100 * width);
18273
- const empty = width - filled;
18291
+ const filled = Math.max(0, Math.min(Math.round(pct / 100 * width), width));
18292
+ const empty = Math.max(0, width - filled);
18274
18293
  const fillChar = "\u2588";
18275
18294
  const emptyChar = "\u2591";
18276
18295
  const color = pct > 80 ? source_default.red : pct > 50 ? source_default.yellow : source_default.green;
@@ -18879,7 +18898,7 @@ var InteractiveMode = class {
18879
18898
  // src/cli/index.ts
18880
18899
  var import_fs10 = require("fs");
18881
18900
  var logger18 = getLogger("cli");
18882
- var APP_VERSION = true ? "2.0.0" : "1.0.0";
18901
+ var APP_VERSION = true ? "2.0.1" : "1.0.0";
18883
18902
  var program2 = new Command();
18884
18903
  program2.name("ys").description("YS Code Agent - AI-Powered Terminal Coding Agent").version(APP_VERSION).option("-c, --config <path>", "Path to config file").option("-m, --model <model>", "Model to use").option("-p, --provider <provider>", "Provider to use").option("-d, --directory <path>", "Working directory").option("--read-only", "Enable read-only mode").option("--sandbox", "Enable sandbox mode").option("--verbose", "Enable verbose logging").option("--non-interactive", "Run in non-interactive mode").hook("preAction", () => {
18885
18904
  initializeTools();
@@ -18887,6 +18906,7 @@ program2.name("ys").description("YS Code Agent - AI-Powered Terminal Coding Agen
18887
18906
  program2.command("chat").description("Start interactive chat session").argument("[message]", "Initial message").action(async (message) => {
18888
18907
  try {
18889
18908
  const interactive = new InteractiveMode();
18909
+ showBanner();
18890
18910
  await interactive.start(message);
18891
18911
  } catch (error) {
18892
18912
  console.error(source_default.red("Fatal error:"), error);
@@ -19081,36 +19101,89 @@ program2.command("doctor").description("Run system diagnostics").action(async ()
19081
19101
  console.log(` Previous tasks: ${context.longTerm.previousTasks.length}`);
19082
19102
  console.log(source_default.green("\n\u2713 Diagnostics complete\n"));
19083
19103
  });
19084
- async function main() {
19085
- program2.parse(process.argv);
19086
- const options = program2.opts();
19087
- if (options.config) {
19088
- const { ConfigManager: ConfigManager2 } = await Promise.resolve().then(() => (init_config(), config_exports));
19089
- const customConfig = new ConfigManager2(options.config);
19090
- }
19091
- if (options.model) {
19092
- configManager.set("model.model", options.model);
19093
- }
19094
- if (options.provider) {
19095
- configManager.setActiveProvider(options.provider);
19096
- }
19097
- if (options.directory) {
19098
- process.chdir(options.directory);
19099
- }
19100
- if (options.readOnly) {
19101
- configManager.set("security.readOnlyMode", true);
19102
- }
19103
- if (options.sandbox) {
19104
- configManager.set("security.sandboxMode", true);
19104
+ function showBanner() {
19105
+ const config = configManager.getConfig();
19106
+ const provider = configManager.getActiveProvider();
19107
+ const w = Math.min(process.stdout.columns || 80, 54);
19108
+ const top = `\u2554${"\u2550".repeat(w)}\u2557`;
19109
+ const bottom = `\u255A${"\u2550".repeat(w)}\u255D`;
19110
+ const versionLine = ` YS Code Agent v${APP_VERSION} `;
19111
+ const versionPad = Math.max(0, Math.floor((w - versionLine.length) / 2));
19112
+ const tagline = "AI-Powered Terminal Coding Agent";
19113
+ const taglinePad = Math.max(0, Math.floor((w - tagline.length) / 2));
19114
+ console.log("");
19115
+ console.log(source_default.cyan(top));
19116
+ console.log(`\u2551${" ".repeat(versionPad)}${source_default.white(versionLine)}${" ".repeat(Math.max(0, w - versionPad - versionLine.length))}\u2551`);
19117
+ console.log(`\u2551${" ".repeat(taglinePad)}${source_default.gray(tagline)}${" ".repeat(Math.max(0, w - taglinePad - tagline.length))}\u2551`);
19118
+ console.log(source_default.cyan(bottom));
19119
+ const cwd = process.cwd();
19120
+ const home = process.env.HOME || "/home";
19121
+ const displayPath = cwd.startsWith(home) ? "~" + cwd.slice(home.length) : cwd;
19122
+ const branch = getGitBranch2();
19123
+ console.log(` ${source_default.gray("Provider:")} ${source_default.cyan(provider.name)}`);
19124
+ console.log(` ${source_default.gray("Model:")} ${source_default.yellow(config.model.model)}`);
19125
+ console.log(` ${source_default.gray("Directory:")} ${source_default.white(displayPath)}${branch ? ` ${source_default.gray("\u2387")} ${source_default.yellow(branch)}` : ""}`);
19126
+ console.log(` ${source_default.gray("Memory:")} ${source_default.green("\u2713 Enabled")}`);
19127
+ try {
19128
+ const { toolRegistry: toolRegistry2 } = (init_tools(), __toCommonJS(tools_exports));
19129
+ const tools = toolRegistry2.getToolNames();
19130
+ console.log(` ${source_default.gray("Tools:")} ${source_default.green(`${tools.length} available`)}`);
19131
+ } catch {
19105
19132
  }
19106
- if (options.verbose) {
19107
- configManager.set("logging.level", "debug");
19133
+ console.log("");
19134
+ }
19135
+ function getGitBranch2() {
19136
+ try {
19137
+ const fs = require("fs");
19138
+ const head = fs.readFileSync(".git/HEAD", "utf-8").trim();
19139
+ const match = head.match(/ref: refs\/heads\/(.+)/);
19140
+ return match ? match[1] : null;
19141
+ } catch {
19142
+ return null;
19108
19143
  }
19109
- const noCommand = process.argv.length <= 2 || process.argv[2]?.startsWith("-");
19110
- if (noCommand) {
19111
- const interactive = new InteractiveMode();
19112
- await interactive.start();
19144
+ }
19145
+ function applyGlobalOptions(rawArgs) {
19146
+ let verbose = false;
19147
+ for (let i = 0; i < rawArgs.length; i++) {
19148
+ const arg = rawArgs[i];
19149
+ if (arg === "--verbose") {
19150
+ verbose = true;
19151
+ } else if (arg === "--read-only") {
19152
+ configManager.set("security.readOnlyMode", true);
19153
+ } else if (arg === "--sandbox") {
19154
+ configManager.set("security.sandboxMode", true);
19155
+ } else if (arg === "--non-interactive") {
19156
+ configManager.set("nonInteractive", true);
19157
+ } else if ((arg === "--config" || arg === "-c") && i + 1 < rawArgs.length) {
19158
+ const { ConfigManager: ConfigManager2 } = (init_config(), __toCommonJS(config_exports));
19159
+ new ConfigManager2(rawArgs[++i]);
19160
+ } else if ((arg === "--model" || arg === "-m") && i + 1 < rawArgs.length) {
19161
+ configManager.set("model.model", rawArgs[++i]);
19162
+ } else if ((arg === "--provider" || arg === "-p") && i + 1 < rawArgs.length) {
19163
+ configManager.setActiveProvider(rawArgs[++i]);
19164
+ } else if ((arg === "--directory" || arg === "-d") && i + 1 < rawArgs.length) {
19165
+ process.chdir(rawArgs[++i]);
19166
+ }
19167
+ }
19168
+ setAllLevels(verbose ? "debug" : "warn");
19169
+ setConsoleSuppressed(!verbose);
19170
+ }
19171
+ async function main() {
19172
+ const rawArgs = process.argv.slice(2);
19173
+ const knownCommands = new Set(program2.commands.map((c) => c.name()));
19174
+ const firstArg = rawArgs.find((a) => !a.startsWith("-"));
19175
+ const hasKnownCommand = firstArg ? knownCommands.has(firstArg) : false;
19176
+ const hasHelpFlag = rawArgs.includes("--help") || rawArgs.includes("-h");
19177
+ const hasVersionFlag = rawArgs.includes("--version") || rawArgs.includes("-V");
19178
+ if (hasKnownCommand || hasHelpFlag || hasVersionFlag) {
19179
+ applyGlobalOptions(rawArgs);
19180
+ program2.parse(process.argv);
19181
+ return;
19113
19182
  }
19183
+ applyGlobalOptions(rawArgs);
19184
+ showBanner();
19185
+ const interactive = new InteractiveMode();
19186
+ await interactive.start();
19114
19187
  }
19115
19188
  main().catch((error) => {
19116
19189
  console.error(source_default.red("Fatal error:"), error);