@bonginkan/maria 3.0.9 → 3.1.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.
@@ -28,7 +28,6 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
28
28
  isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
29
29
  mod
30
30
  ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
31
 
33
32
  // src/services/startup-display.ts
34
33
  var startup_display_exports = {};
@@ -166,10 +165,6 @@ function displayFinalStartupScreen(_selectedProvider, _selectedModel) {
166
165
  console.log(import_chalk.default.magentaBright("\u2551 \u2551"));
167
166
  console.log(import_chalk.default.magentaBright("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
168
167
  console.log("");
169
- console.log("");
170
- console.log(import_chalk.default.gray("AI-Powered Development Platform"));
171
- console.log(import_chalk.default.gray(" (c) 2025 Bonginkan Inc."));
172
- console.log("");
173
168
  console.log(import_chalk.default.cyan.bold(`MARIA CODE v${version}`) + import_chalk.default.gray(" \u2014 Ready"));
174
169
  console.log(import_chalk.default.yellow("/help for commands") + import_chalk.default.gray(" | Providers: 8/8 OK"));
175
170
  console.log("");
@@ -11411,14 +11406,7 @@ var init_ai_response_service = __esm({
11411
11406
  async callAIProvider(context2, _options) {
11412
11407
  const userInput2 = context2.currentInput.toLowerCase();
11413
11408
  const hasContext = context2.messages.length > 0;
11414
- console.log("\u{1F9E0} AI Provider Debug:", {
11415
- userInput: userInput2,
11416
- hasContext,
11417
- messagesCount: context2.messages.length,
11418
- contextStats: context2.contextStats
11419
- });
11420
11409
  const intent2 = this.analyzeIntent(userInput2, context2);
11421
- console.log("\u{1F3AF} Intent Analysis:", intent2);
11422
11410
  switch (intent2.type) {
11423
11411
  case "TETRIS_REQUEST":
11424
11412
  return this.generateTetrisGame(userInput2);
@@ -11442,11 +11430,6 @@ var init_ai_response_service = __esm({
11442
11430
  const messages2 = context2.messages || [];
11443
11431
  const recentMessages2 = messages2.slice(-3);
11444
11432
  const contextString = recentMessages2.map((m2) => m2.content).join(" ").toLowerCase();
11445
- console.log("\u{1F50D} Context Analysis:", {
11446
- userInput: userInput2,
11447
- contextString: contextString.substring(0, 100) + "...",
11448
- recentMessagesCount: recentMessages2.length
11449
- });
11450
11433
  if (userInput2.includes("tetris") || contextString.includes("tetris") && (userInput2.includes("html") || userInput2.includes("game") || userInput2.includes("whole code") || userInput2.includes("start") || userInput2.includes("black") || userInput2.includes("background"))) {
11451
11434
  return {
11452
11435
  type: "TETRIS_REQUEST",
@@ -14030,13 +14013,350 @@ var init_template_manager = __esm({
14030
14013
  }
14031
14014
  });
14032
14015
 
14016
+ // src/services/batch-execution.ts
14017
+ var import_chalk10, BatchExecutionEngine;
14018
+ var init_batch_execution = __esm({
14019
+ "src/services/batch-execution.ts"() {
14020
+ import_chalk10 = __toESM(require("chalk"), 1);
14021
+ BatchExecutionEngine = class _BatchExecutionEngine {
14022
+ static instance;
14023
+ commandHandler = null;
14024
+ variables = {};
14025
+ isExecuting = false;
14026
+ constructor() {
14027
+ }
14028
+ /**
14029
+ * Set command handler via dependency injection
14030
+ */
14031
+ setCommandHandler(handler) {
14032
+ this.commandHandler = handler;
14033
+ }
14034
+ getCommandHandler() {
14035
+ if (!this.commandHandler) {
14036
+ throw new Error("CommandHandler not injected. Call setCommandHandler() first.");
14037
+ }
14038
+ return this.commandHandler;
14039
+ }
14040
+ static getInstance() {
14041
+ if (!_BatchExecutionEngine.instance) {
14042
+ _BatchExecutionEngine.instance = new _BatchExecutionEngine();
14043
+ }
14044
+ return _BatchExecutionEngine.instance;
14045
+ }
14046
+ /**
14047
+ * Parse _batch command string
14048
+ */
14049
+ parseBatchString(batchString) {
14050
+ const _lines = batchString.split("\n").filter((line) => line.trim() && !line.trim().startsWith("#"));
14051
+ const commands2 = [];
14052
+ lines.forEach((line) => {
14053
+ const _ifMatch = line.match(/^IF\s+(.+)\s+THEN\s+(.+)(?:\s+ELSE\s+(.+))?$/i);
14054
+ if (_ifMatch) {
14055
+ const [, condition, thenCmd, elseCmd] = _ifMatch;
14056
+ if (condition && thenCmd) {
14057
+ commands2.push({
14058
+ command: thenCmd.split(" ")[0] || "",
14059
+ args: thenCmd.split(" ").slice(1),
14060
+ condition
14061
+ });
14062
+ if (elseCmd) {
14063
+ commands2.push({
14064
+ command: elseCmd.split(" ")[0] || "",
14065
+ args: elseCmd.split(" ").slice(1),
14066
+ condition: `!${condition}`
14067
+ });
14068
+ }
14069
+ }
14070
+ return;
14071
+ }
14072
+ if (line.startsWith("PARALLEL:")) {
14073
+ const _parallelCommands = line.substring(9).split("&&").map((cmd2) => cmd2.trim());
14074
+ parallelCommands.forEach((cmd2) => {
14075
+ const _parts2 = cmd2.split(" ");
14076
+ if (_parts2[0]) {
14077
+ commands2.push({
14078
+ command: _parts2[0],
14079
+ args: parts.slice(1),
14080
+ parallel: true
14081
+ });
14082
+ }
14083
+ });
14084
+ return;
14085
+ }
14086
+ const _parts = line.split(" ");
14087
+ if (_parts[0]) {
14088
+ commands2.push({
14089
+ command: _parts[0],
14090
+ args: parts.slice(1)
14091
+ });
14092
+ }
14093
+ });
14094
+ return commands2;
14095
+ }
14096
+ /**
14097
+ * Execute a _batch of commands
14098
+ */
14099
+ async executeBatch(commands2, context2, options2 = {}) {
14100
+ if (this.isExecuting) {
14101
+ throw new Error("Batch execution already in progress");
14102
+ }
14103
+ this.isExecuting = true;
14104
+ const _startTime = Date.now();
14105
+ this.variables = { ...options2.variables };
14106
+ const result2 = {
14107
+ success: true,
14108
+ totalCommands: commands2.length,
14109
+ executed: 0,
14110
+ succeeded: 0,
14111
+ failed: 0,
14112
+ skipped: 0,
14113
+ _duration: 0,
14114
+ results: [],
14115
+ variables: this.variables
14116
+ };
14117
+ console.log(import_chalk10.default.blue("\n\u{1F680} Starting _batch execution\n"));
14118
+ if (options2.dryRun) {
14119
+ console.log(import_chalk10.default.yellow("DRY RUN MODE - Commands will not be executed\n"));
14120
+ commands2.forEach((cmd2, _i) => {
14121
+ console.log(import_chalk10.default.gray(`${i + 1}. ${cmd2.command} ${cmd2.args.join(" ")}`));
14122
+ if (cmd2.condition) {
14123
+ console.log(import_chalk10.default.gray(` IF: ${cmd2.condition}`));
14124
+ }
14125
+ });
14126
+ this.isExecuting = false;
14127
+ return result2;
14128
+ }
14129
+ try {
14130
+ const _commandGroups = this.groupCommands(commands2);
14131
+ for (const group of _commandGroups) {
14132
+ if (options2.stopOnError && result2.failed > 0) {
14133
+ console.log(import_chalk10.default.yellow("\n\u23F9\uFE0F Stopping due to _error (stopOnError=true)"));
14134
+ break;
14135
+ }
14136
+ if (group.length === 1 && group[0]) {
14137
+ await this.executeSingleCommand(group[0], context2, result2);
14138
+ } else {
14139
+ await this.executeParallelCommands(group, context2, result2, options2.maxParallel || 3);
14140
+ }
14141
+ }
14142
+ result2.duration = Date.now() - _startTime;
14143
+ result2.success = result2.failed === 0;
14144
+ this.printSummary(result2);
14145
+ } finally {
14146
+ this.isExecuting = false;
14147
+ }
14148
+ return result2;
14149
+ }
14150
+ /**
14151
+ * Execute a single command
14152
+ */
14153
+ async executeSingleCommand(cmd2, context2, result2) {
14154
+ if (cmd2.condition && !this.evaluateCondition(cmd2.condition)) {
14155
+ result2.skipped++;
14156
+ console.log(import_chalk10.default.gray(`\u23ED\uFE0F Skipping ${cmd2.command} (condition not met)`));
14157
+ return;
14158
+ }
14159
+ console.log(import_chalk10.default.cyan(`
14160
+ \u25B6\uFE0F Executing: ${cmd2.command} ${cmd2.args.join(" ")}`));
14161
+ const _startTime = Date.now();
14162
+ let attempts = 0;
14163
+ const _maxAttempts = cmd2.retries ? cmd2.retries + 1 : 1;
14164
+ while (attempts < _maxAttempts) {
14165
+ attempts++;
14166
+ try {
14167
+ const _cmdResult = await this.executeWithTimeout(
14168
+ () => this.getCommandHandler().handleCommand(cmd2.command, cmd2.args, context2),
14169
+ cmd2.timeout || 3e4
14170
+ );
14171
+ const _duration = Date.now() - _startTime;
14172
+ result2.executed++;
14173
+ if (cmdResult.success) {
14174
+ result2.succeeded++;
14175
+ console.log(import_chalk10.default.green(`\u2705 Success (${_duration}ms)`));
14176
+ result2.results.push({
14177
+ command: `${cmd2.command} ${cmd2.args.join(" ")}`,
14178
+ success: true,
14179
+ output: cmdResult.message,
14180
+ _duration
14181
+ });
14182
+ if (cmdResult.data && typeof cmdResult.data === "object" && "variable" in cmdResult.data && "_value" in cmdResult.data) {
14183
+ const _resultData = cmdResult.data;
14184
+ this.variables[resultData.variable] = resultData.value;
14185
+ }
14186
+ break;
14187
+ } else {
14188
+ if (attempts < _maxAttempts) {
14189
+ console.log(import_chalk10.default.yellow(`\u26A0\uFE0F Failed, retrying (${attempts}/${_maxAttempts})...`));
14190
+ await this.delay(1e3);
14191
+ } else {
14192
+ result2.failed++;
14193
+ console.log(import_chalk10.default.red(`\u274C Failed: ${cmdResult.message}`));
14194
+ result2.results.push({
14195
+ command: `${cmd2.command} ${cmd2.args.join(" ")}`,
14196
+ success: false,
14197
+ _error: cmdResult.message,
14198
+ _duration
14199
+ });
14200
+ }
14201
+ }
14202
+ } catch (_error) {
14203
+ const _duration = Date.now() - _startTime;
14204
+ if (attempts < _maxAttempts) {
14205
+ console.log(import_chalk10.default.yellow(`\u26A0\uFE0F Error, retrying (${attempts}/${_maxAttempts})...`));
14206
+ await this.delay(1e3);
14207
+ } else {
14208
+ result2.failed++;
14209
+ result2.executed++;
14210
+ const _errorMsg = _error instanceof Error ? error.message : "Unknown _error";
14211
+ console.log(import_chalk10.default.red(`\u274C Error: ${_errorMsg}`));
14212
+ result2.results.push({
14213
+ command: `${cmd2.command} ${cmd2.args.join(" ")}`,
14214
+ success: false,
14215
+ _error: _errorMsg,
14216
+ _duration
14217
+ });
14218
+ }
14219
+ }
14220
+ }
14221
+ }
14222
+ /**
14223
+ * Execute commands in parallel
14224
+ */
14225
+ async executeParallelCommands(commands2, context2, result2, maxParallel) {
14226
+ console.log(import_chalk10.default.cyan(`
14227
+ \u26A1 Executing ${commands2.length} commands in parallel`));
14228
+ const _promises = commands2.map(
14229
+ (cmd2) => this.executeSingleCommand(cmd2, context2, {
14230
+ ...result2,
14231
+ executed: 0,
14232
+ succeeded: 0,
14233
+ failed: 0,
14234
+ skipped: 0,
14235
+ results: []
14236
+ })
14237
+ );
14238
+ for (let i2 = 0; i2 < promises.length; i2 += maxParallel) {
14239
+ const _batch = promises.slice(i2, i2 + maxParallel);
14240
+ const _batchResults = await Promise.allSettled(_batch);
14241
+ batchResults.forEach((batchResult) => {
14242
+ if (batchResult.status === "rejected") {
14243
+ result2.failed++;
14244
+ result2.executed++;
14245
+ }
14246
+ });
14247
+ }
14248
+ }
14249
+ /**
14250
+ * Group commands for execution
14251
+ */
14252
+ groupCommands(commands2) {
14253
+ const groups = [];
14254
+ let currentGroup = [];
14255
+ commands2.forEach((cmd2) => {
14256
+ if (cmd2.parallel && currentGroup.length > 0) {
14257
+ currentGroup.push(cmd2);
14258
+ } else {
14259
+ if (currentGroup.length > 0) {
14260
+ groups.push(currentGroup);
14261
+ }
14262
+ currentGroup = [cmd2];
14263
+ }
14264
+ });
14265
+ if (currentGroup.length > 0) {
14266
+ groups.push(currentGroup);
14267
+ }
14268
+ return groups;
14269
+ }
14270
+ /**
14271
+ * Evaluate condition
14272
+ */
14273
+ evaluateCondition(condition) {
14274
+ if (condition.startsWith("!")) {
14275
+ return !this.evaluateCondition(condition.substring(1));
14276
+ }
14277
+ if (condition.startsWith("$")) {
14278
+ const _varName = condition.substring(1);
14279
+ return this.variables[_varName] !== void 0;
14280
+ }
14281
+ const _eqMatch = condition.match(/^\$(\w+)\s*==\s*(.+)$/);
14282
+ if (_eqMatch && _eqMatch[1] && _eqMatch[2] !== void 0) {
14283
+ const _varName = _eqMatch[1];
14284
+ const _value = _eqMatch[2];
14285
+ return String(this.variables[_varName] || "") === _value;
14286
+ }
14287
+ switch (condition) {
14288
+ case "hasErrors":
14289
+ return this.variables["hasErrors"] === true;
14290
+ case "testsPass":
14291
+ return this.variables["testsPass"] === true;
14292
+ default:
14293
+ return true;
14294
+ }
14295
+ }
14296
+ /**
14297
+ * Execute with timeout
14298
+ */
14299
+ async executeWithTimeout(fn, timeout) {
14300
+ return Promise.race([
14301
+ fn(),
14302
+ new Promise(
14303
+ (_, reject) => setTimeout(() => reject(new Error("Command timeout")), timeout)
14304
+ )
14305
+ ]);
14306
+ }
14307
+ /**
14308
+ * Print execution summary
14309
+ */
14310
+ printSummary(result2) {
14311
+ console.log(import_chalk10.default.blue("\n\u{1F4CA} Batch Execution Summary\n"));
14312
+ const _successRate = result2.executed > 0 ? Math.round(result2.succeeded / result2.executed * 100) : 0;
14313
+ console.log(`Total Commands: ${result2.totalCommands}`);
14314
+ console.log(`Executed: ${result2.executed}`);
14315
+ console.log(import_chalk10.default.green(`Succeeded: ${result2.succeeded}`));
14316
+ if (result2.failed > 0) {
14317
+ console.log(import_chalk10.default.red(`Failed: ${result2.failed}`));
14318
+ }
14319
+ if (result2.skipped > 0) {
14320
+ console.log(import_chalk10.default.gray(`Skipped: ${result2.skipped}`));
14321
+ }
14322
+ console.log(`Success Rate: ${_successRate}%`);
14323
+ console.log(`Duration: ${(result2.duration / 1e3).toFixed(2)}s`);
14324
+ if (Object.keys(result2.variables).length > 0) {
14325
+ console.log("\nVariables Set:");
14326
+ Object.entries(result2.variables).forEach(([key2, _value]) => {
14327
+ console.log(` ${key2} = ${JSON.stringify(_value)}`);
14328
+ });
14329
+ }
14330
+ }
14331
+ /**
14332
+ * Helper to add delay
14333
+ */
14334
+ delay(ms) {
14335
+ return new Promise((resolve6) => setTimeout(resolve6, ms));
14336
+ }
14337
+ /**
14338
+ * Check if _batch is executing
14339
+ */
14340
+ getExecutionStatus() {
14341
+ return this.isExecuting;
14342
+ }
14343
+ /**
14344
+ * Get current variables
14345
+ */
14346
+ getVariables() {
14347
+ return { ...this.variables };
14348
+ }
14349
+ };
14350
+ }
14351
+ });
14352
+
14033
14353
  // src/services/hotkey-manager.ts
14034
- var import_chalk10, import_fs4, import_path3, import_os3, logger4, HotkeyManager;
14354
+ var import_chalk11, import_fs4, import_path3, import_os3, logger4, HotkeyManager;
14035
14355
  var init_hotkey_manager = __esm({
14036
14356
  "src/services/hotkey-manager.ts"() {
14037
14357
  init_slash_command_handler();
14038
14358
  init_logger();
14039
- import_chalk10 = __toESM(require("chalk"), 1);
14359
+ import_chalk11 = __toESM(require("chalk"), 1);
14040
14360
  import_fs4 = require("fs");
14041
14361
  import_path3 = require("path");
14042
14362
  import_os3 = require("os");
@@ -14437,19 +14757,19 @@ var init_hotkey_manager = __esm({
14437
14757
  if (_bindings.length === 0) {
14438
14758
  return "No hotkeys configured.";
14439
14759
  }
14440
- let help = import_chalk10.default.bold("\nAvailable Hotkeys:\n\n");
14760
+ let help = import_chalk11.default.bold("\nAvailable Hotkeys:\n\n");
14441
14761
  _bindings.forEach((raw) => {
14442
14762
  const _binding = this.normalize(raw);
14443
- const _hotkey = import_chalk10.default.cyan(this.formatHotkey(raw));
14444
- const _command = import_chalk10.default.yellow(_binding.command);
14445
- const _args = _binding.args ? import_chalk10.default.gray(` ${_binding.args.join(" ")}`) : "";
14446
- const _desc = _binding.description ? import_chalk10.default.gray(` - ${_binding.description}`) : "";
14447
- const _status = !_binding.enabled ? import_chalk10.default.red(" [disabled]") : "";
14763
+ const _hotkey = import_chalk11.default.cyan(this.formatHotkey(raw));
14764
+ const _command = import_chalk11.default.yellow(_binding.command);
14765
+ const _args = _binding.args ? import_chalk11.default.gray(` ${_binding.args.join(" ")}`) : "";
14766
+ const _desc = _binding.description ? import_chalk11.default.gray(` - ${_binding.description}`) : "";
14767
+ const _status = !_binding.enabled ? import_chalk11.default.red(" [disabled]") : "";
14448
14768
  help += ` ${_hotkey.padEnd(20)} \u2192 ${_command}${_args}${_desc}${_status}
14449
14769
  `;
14450
14770
  });
14451
14771
  help += `
14452
- ${import_chalk10.default.gray("Use /_hotkey to manage hotkeys")}
14772
+ ${import_chalk11.default.gray("Use /_hotkey to manage hotkeys")}
14453
14773
  `;
14454
14774
  return help;
14455
14775
  }
@@ -16634,12 +16954,12 @@ var init_ReferentialResolver = __esm({
16634
16954
  });
16635
16955
 
16636
16956
  // src/services/conversation/ContextAwareSaveHandler.ts
16637
- var fs6, path8, import_chalk11, ContextAwareSaveHandler;
16957
+ var fs6, path8, import_chalk12, ContextAwareSaveHandler;
16638
16958
  var init_ContextAwareSaveHandler = __esm({
16639
16959
  "src/services/conversation/ContextAwareSaveHandler.ts"() {
16640
16960
  fs6 = __toESM(require("fs/promises"), 1);
16641
16961
  path8 = __toESM(require("path"), 1);
16642
- import_chalk11 = __toESM(require("chalk"), 1);
16962
+ import_chalk12 = __toESM(require("chalk"), 1);
16643
16963
  init_TurnManager();
16644
16964
  init_ReferentialResolver();
16645
16965
  ContextAwareSaveHandler = class _ContextAwareSaveHandler {
@@ -16873,7 +17193,7 @@ var init_ContextAwareSaveHandler = __esm({
16873
17193
  await fs6.access(this.mariaGeneratedDir);
16874
17194
  } catch (_error) {
16875
17195
  await fs6.mkdir(this.mariaGeneratedDir, { recursive: true });
16876
- console.log(import_chalk11.default.blue(`\u{1F4C1} Created '${this.mariaGeneratedDir}' folder for MARIA outputs`));
17196
+ console.log(import_chalk12.default.blue(`\u{1F4C1} Created '${this.mariaGeneratedDir}' folder for MARIA outputs`));
16877
17197
  }
16878
17198
  }
16879
17199
  async ensureDirectoryExists(dirPath) {
@@ -17000,347 +17320,6 @@ ${dirName}/
17000
17320
  }
17001
17321
  });
17002
17322
 
17003
- // src/services/batch-execution.ts
17004
- var batch_execution_exports = {};
17005
- __export(batch_execution_exports, {
17006
- BatchExecutionEngine: () => BatchExecutionEngine
17007
- });
17008
- var import_chalk12, BatchExecutionEngine;
17009
- var init_batch_execution = __esm({
17010
- "src/services/batch-execution.ts"() {
17011
- import_chalk12 = __toESM(require("chalk"), 1);
17012
- BatchExecutionEngine = class _BatchExecutionEngine {
17013
- static instance;
17014
- commandHandler = null;
17015
- variables = {};
17016
- isExecuting = false;
17017
- constructor() {
17018
- }
17019
- /**
17020
- * Set command handler via dependency injection
17021
- */
17022
- setCommandHandler(handler) {
17023
- this.commandHandler = handler;
17024
- }
17025
- getCommandHandler() {
17026
- if (!this.commandHandler) {
17027
- throw new Error("CommandHandler not injected. Call setCommandHandler() first.");
17028
- }
17029
- return this.commandHandler;
17030
- }
17031
- static getInstance() {
17032
- if (!_BatchExecutionEngine.instance) {
17033
- _BatchExecutionEngine.instance = new _BatchExecutionEngine();
17034
- }
17035
- return _BatchExecutionEngine.instance;
17036
- }
17037
- /**
17038
- * Parse _batch command string
17039
- */
17040
- parseBatchString(batchString) {
17041
- const _lines = batchString.split("\n").filter((line) => line.trim() && !line.trim().startsWith("#"));
17042
- const commands2 = [];
17043
- lines.forEach((line) => {
17044
- const _ifMatch = line.match(/^IF\s+(.+)\s+THEN\s+(.+)(?:\s+ELSE\s+(.+))?$/i);
17045
- if (_ifMatch) {
17046
- const [, condition, thenCmd, elseCmd] = _ifMatch;
17047
- if (condition && thenCmd) {
17048
- commands2.push({
17049
- command: thenCmd.split(" ")[0] || "",
17050
- args: thenCmd.split(" ").slice(1),
17051
- condition
17052
- });
17053
- if (elseCmd) {
17054
- commands2.push({
17055
- command: elseCmd.split(" ")[0] || "",
17056
- args: elseCmd.split(" ").slice(1),
17057
- condition: `!${condition}`
17058
- });
17059
- }
17060
- }
17061
- return;
17062
- }
17063
- if (line.startsWith("PARALLEL:")) {
17064
- const _parallelCommands = line.substring(9).split("&&").map((cmd2) => cmd2.trim());
17065
- parallelCommands.forEach((cmd2) => {
17066
- const _parts2 = cmd2.split(" ");
17067
- if (_parts2[0]) {
17068
- commands2.push({
17069
- command: _parts2[0],
17070
- args: parts.slice(1),
17071
- parallel: true
17072
- });
17073
- }
17074
- });
17075
- return;
17076
- }
17077
- const _parts = line.split(" ");
17078
- if (_parts[0]) {
17079
- commands2.push({
17080
- command: _parts[0],
17081
- args: parts.slice(1)
17082
- });
17083
- }
17084
- });
17085
- return commands2;
17086
- }
17087
- /**
17088
- * Execute a _batch of commands
17089
- */
17090
- async executeBatch(commands2, context2, options2 = {}) {
17091
- if (this.isExecuting) {
17092
- throw new Error("Batch execution already in progress");
17093
- }
17094
- this.isExecuting = true;
17095
- const _startTime = Date.now();
17096
- this.variables = { ...options2.variables };
17097
- const result2 = {
17098
- success: true,
17099
- totalCommands: commands2.length,
17100
- executed: 0,
17101
- succeeded: 0,
17102
- failed: 0,
17103
- skipped: 0,
17104
- _duration: 0,
17105
- results: [],
17106
- variables: this.variables
17107
- };
17108
- console.log(import_chalk12.default.blue("\n\u{1F680} Starting _batch execution\n"));
17109
- if (options2.dryRun) {
17110
- console.log(import_chalk12.default.yellow("DRY RUN MODE - Commands will not be executed\n"));
17111
- commands2.forEach((cmd2, _i) => {
17112
- console.log(import_chalk12.default.gray(`${i + 1}. ${cmd2.command} ${cmd2.args.join(" ")}`));
17113
- if (cmd2.condition) {
17114
- console.log(import_chalk12.default.gray(` IF: ${cmd2.condition}`));
17115
- }
17116
- });
17117
- this.isExecuting = false;
17118
- return result2;
17119
- }
17120
- try {
17121
- const _commandGroups = this.groupCommands(commands2);
17122
- for (const group of _commandGroups) {
17123
- if (options2.stopOnError && result2.failed > 0) {
17124
- console.log(import_chalk12.default.yellow("\n\u23F9\uFE0F Stopping due to _error (stopOnError=true)"));
17125
- break;
17126
- }
17127
- if (group.length === 1 && group[0]) {
17128
- await this.executeSingleCommand(group[0], context2, result2);
17129
- } else {
17130
- await this.executeParallelCommands(group, context2, result2, options2.maxParallel || 3);
17131
- }
17132
- }
17133
- result2.duration = Date.now() - _startTime;
17134
- result2.success = result2.failed === 0;
17135
- this.printSummary(result2);
17136
- } finally {
17137
- this.isExecuting = false;
17138
- }
17139
- return result2;
17140
- }
17141
- /**
17142
- * Execute a single command
17143
- */
17144
- async executeSingleCommand(cmd2, context2, result2) {
17145
- if (cmd2.condition && !this.evaluateCondition(cmd2.condition)) {
17146
- result2.skipped++;
17147
- console.log(import_chalk12.default.gray(`\u23ED\uFE0F Skipping ${cmd2.command} (condition not met)`));
17148
- return;
17149
- }
17150
- console.log(import_chalk12.default.cyan(`
17151
- \u25B6\uFE0F Executing: ${cmd2.command} ${cmd2.args.join(" ")}`));
17152
- const _startTime = Date.now();
17153
- let attempts = 0;
17154
- const _maxAttempts = cmd2.retries ? cmd2.retries + 1 : 1;
17155
- while (attempts < _maxAttempts) {
17156
- attempts++;
17157
- try {
17158
- const _cmdResult = await this.executeWithTimeout(
17159
- () => this.getCommandHandler().handleCommand(cmd2.command, cmd2.args, context2),
17160
- cmd2.timeout || 3e4
17161
- );
17162
- const _duration = Date.now() - _startTime;
17163
- result2.executed++;
17164
- if (cmdResult.success) {
17165
- result2.succeeded++;
17166
- console.log(import_chalk12.default.green(`\u2705 Success (${_duration}ms)`));
17167
- result2.results.push({
17168
- command: `${cmd2.command} ${cmd2.args.join(" ")}`,
17169
- success: true,
17170
- output: cmdResult.message,
17171
- _duration
17172
- });
17173
- if (cmdResult.data && typeof cmdResult.data === "object" && "variable" in cmdResult.data && "_value" in cmdResult.data) {
17174
- const _resultData = cmdResult.data;
17175
- this.variables[resultData.variable] = resultData.value;
17176
- }
17177
- break;
17178
- } else {
17179
- if (attempts < _maxAttempts) {
17180
- console.log(import_chalk12.default.yellow(`\u26A0\uFE0F Failed, retrying (${attempts}/${_maxAttempts})...`));
17181
- await this.delay(1e3);
17182
- } else {
17183
- result2.failed++;
17184
- console.log(import_chalk12.default.red(`\u274C Failed: ${cmdResult.message}`));
17185
- result2.results.push({
17186
- command: `${cmd2.command} ${cmd2.args.join(" ")}`,
17187
- success: false,
17188
- _error: cmdResult.message,
17189
- _duration
17190
- });
17191
- }
17192
- }
17193
- } catch (_error) {
17194
- const _duration = Date.now() - _startTime;
17195
- if (attempts < _maxAttempts) {
17196
- console.log(import_chalk12.default.yellow(`\u26A0\uFE0F Error, retrying (${attempts}/${_maxAttempts})...`));
17197
- await this.delay(1e3);
17198
- } else {
17199
- result2.failed++;
17200
- result2.executed++;
17201
- const _errorMsg = _error instanceof Error ? error.message : "Unknown _error";
17202
- console.log(import_chalk12.default.red(`\u274C Error: ${_errorMsg}`));
17203
- result2.results.push({
17204
- command: `${cmd2.command} ${cmd2.args.join(" ")}`,
17205
- success: false,
17206
- _error: _errorMsg,
17207
- _duration
17208
- });
17209
- }
17210
- }
17211
- }
17212
- }
17213
- /**
17214
- * Execute commands in parallel
17215
- */
17216
- async executeParallelCommands(commands2, context2, result2, maxParallel) {
17217
- console.log(import_chalk12.default.cyan(`
17218
- \u26A1 Executing ${commands2.length} commands in parallel`));
17219
- const _promises = commands2.map(
17220
- (cmd2) => this.executeSingleCommand(cmd2, context2, {
17221
- ...result2,
17222
- executed: 0,
17223
- succeeded: 0,
17224
- failed: 0,
17225
- skipped: 0,
17226
- results: []
17227
- })
17228
- );
17229
- for (let i2 = 0; i2 < promises.length; i2 += maxParallel) {
17230
- const _batch = promises.slice(i2, i2 + maxParallel);
17231
- const _batchResults = await Promise.allSettled(_batch);
17232
- batchResults.forEach((batchResult) => {
17233
- if (batchResult.status === "rejected") {
17234
- result2.failed++;
17235
- result2.executed++;
17236
- }
17237
- });
17238
- }
17239
- }
17240
- /**
17241
- * Group commands for execution
17242
- */
17243
- groupCommands(commands2) {
17244
- const groups = [];
17245
- let currentGroup = [];
17246
- commands2.forEach((cmd2) => {
17247
- if (cmd2.parallel && currentGroup.length > 0) {
17248
- currentGroup.push(cmd2);
17249
- } else {
17250
- if (currentGroup.length > 0) {
17251
- groups.push(currentGroup);
17252
- }
17253
- currentGroup = [cmd2];
17254
- }
17255
- });
17256
- if (currentGroup.length > 0) {
17257
- groups.push(currentGroup);
17258
- }
17259
- return groups;
17260
- }
17261
- /**
17262
- * Evaluate condition
17263
- */
17264
- evaluateCondition(condition) {
17265
- if (condition.startsWith("!")) {
17266
- return !this.evaluateCondition(condition.substring(1));
17267
- }
17268
- if (condition.startsWith("$")) {
17269
- const _varName = condition.substring(1);
17270
- return this.variables[_varName] !== void 0;
17271
- }
17272
- const _eqMatch = condition.match(/^\$(\w+)\s*==\s*(.+)$/);
17273
- if (_eqMatch && _eqMatch[1] && _eqMatch[2] !== void 0) {
17274
- const _varName = _eqMatch[1];
17275
- const _value = _eqMatch[2];
17276
- return String(this.variables[_varName] || "") === _value;
17277
- }
17278
- switch (condition) {
17279
- case "hasErrors":
17280
- return this.variables["hasErrors"] === true;
17281
- case "testsPass":
17282
- return this.variables["testsPass"] === true;
17283
- default:
17284
- return true;
17285
- }
17286
- }
17287
- /**
17288
- * Execute with timeout
17289
- */
17290
- async executeWithTimeout(fn, timeout) {
17291
- return Promise.race([
17292
- fn(),
17293
- new Promise(
17294
- (_, reject) => setTimeout(() => reject(new Error("Command timeout")), timeout)
17295
- )
17296
- ]);
17297
- }
17298
- /**
17299
- * Print execution summary
17300
- */
17301
- printSummary(result2) {
17302
- console.log(import_chalk12.default.blue("\n\u{1F4CA} Batch Execution Summary\n"));
17303
- const _successRate = result2.executed > 0 ? Math.round(result2.succeeded / result2.executed * 100) : 0;
17304
- console.log(`Total Commands: ${result2.totalCommands}`);
17305
- console.log(`Executed: ${result2.executed}`);
17306
- console.log(import_chalk12.default.green(`Succeeded: ${result2.succeeded}`));
17307
- if (result2.failed > 0) {
17308
- console.log(import_chalk12.default.red(`Failed: ${result2.failed}`));
17309
- }
17310
- if (result2.skipped > 0) {
17311
- console.log(import_chalk12.default.gray(`Skipped: ${result2.skipped}`));
17312
- }
17313
- console.log(`Success Rate: ${_successRate}%`);
17314
- console.log(`Duration: ${(result2.duration / 1e3).toFixed(2)}s`);
17315
- if (Object.keys(result2.variables).length > 0) {
17316
- console.log("\nVariables Set:");
17317
- Object.entries(result2.variables).forEach(([key2, _value]) => {
17318
- console.log(` ${key2} = ${JSON.stringify(_value)}`);
17319
- });
17320
- }
17321
- }
17322
- /**
17323
- * Helper to add delay
17324
- */
17325
- delay(ms) {
17326
- return new Promise((resolve6) => setTimeout(resolve6, ms));
17327
- }
17328
- /**
17329
- * Check if _batch is executing
17330
- */
17331
- getExecutionStatus() {
17332
- return this.isExecuting;
17333
- }
17334
- /**
17335
- * Get current variables
17336
- */
17337
- getVariables() {
17338
- return { ...this.variables };
17339
- }
17340
- };
17341
- }
17342
- });
17343
-
17344
17323
  // src/services/init/scanner.ts
17345
17324
  async function runWithBudget(tasks2, totalMs = 6e3, perStepMs = 600) {
17346
17325
  const started = Date.now();
@@ -22990,6 +22969,7 @@ var init_slash_command_handler = __esm({
22990
22969
  init_command_chain_service();
22991
22970
  init_alias_system();
22992
22971
  init_template_manager();
22972
+ init_batch_execution();
22993
22973
  init_hotkey_manager();
22994
22974
  import_inquirer2 = __toESM(require("inquirer"), 1);
22995
22975
  init_chat_context_service();
@@ -23018,8 +22998,7 @@ var init_slash_command_handler = __esm({
23018
22998
  this.suggestionService = SuggestionService.getInstance();
23019
22999
  this.aliasSystem = AliasSystem.getInstance();
23020
23000
  this.templateManager = TemplateManager.getInstance();
23021
- const { BatchExecutionEngine: BatchExecutionEngine2 } = (init_batch_execution(), __toCommonJS(batch_execution_exports));
23022
- this.batchEngine = BatchExecutionEngine2.getInstance();
23001
+ this.batchEngine = BatchExecutionEngine.getInstance();
23023
23002
  this.batchEngine.setCommandHandler(this);
23024
23003
  this.hotkeyManager = HotkeyManager.getInstance();
23025
23004
  this.chatContextService = ChatContextService2.getInstance();
@@ -27574,13 +27553,11 @@ __export(cli_exports, {
27574
27553
  });
27575
27554
  async function initializeServices() {
27576
27555
  try {
27577
- console.log(import_chalk18.default.cyan("Initializing conversation memory..."));
27578
27556
  conversationPersistence = new ConversationPersistence();
27579
27557
  chatContext = ChatContextService.getInstance();
27580
27558
  aiResponseService = new AIResponseService();
27581
27559
  slashCommandHandler = SlashCommandHandler.getInstance();
27582
27560
  const previousHistory = await conversationPersistence.loadHistory();
27583
- console.log(import_chalk18.default.green(`\u2705 Memory loaded: ${previousHistory.length} previous messages`));
27584
27561
  for (const msg2 of previousHistory) {
27585
27562
  await chatContext.addMessage({
27586
27563
  role: msg2.role,
@@ -27596,15 +27573,6 @@ async function initializeServices() {
27596
27573
  }
27597
27574
  async function generateAIResponse(input3) {
27598
27575
  try {
27599
- if (process.env.NODE_ENV !== "production") {
27600
- console.log("\u{1F527} CLI Debug - Session Memory:", {
27601
- sessionMemoryLength: sessionMemory.length,
27602
- lastFewMessages: sessionMemory.slice(-3).map((m2) => ({
27603
- role: m2.role,
27604
- content: m2.content.substring(0, 50) + "..."
27605
- }))
27606
- });
27607
- }
27608
27576
  const response2 = await aiResponseService.generateResponse({
27609
27577
  userInput: input3,
27610
27578
  sessionMemory,
@@ -27799,7 +27767,7 @@ var init_cli = __esm({
27799
27767
  init_chat_context_fixed_service();
27800
27768
  init_ai_response_service();
27801
27769
  init_slash_command_handler();
27802
- packageJson2 = { version: "3.0.9" };
27770
+ packageJson2 = { version: "3.1.0" };
27803
27771
  sessionMemory = [];
27804
27772
  program = createCLI();
27805
27773
  program.parse(process.argv);
@@ -37747,8 +37715,8 @@ var init_package = __esm({
37747
37715
  "package.json"() {
37748
37716
  package_default = {
37749
37717
  name: "@bonginkan/maria",
37750
- version: "3.0.9",
37751
- description: "\u{1F680} MARIA v3.0.9 - Minimal API, Maximum Power. Intelligent Router + Dual Memory + File System. Enterprise-ready AI development platform with enhanced /help command and stability improvements.",
37718
+ version: "3.1.0",
37719
+ description: "\u{1F680} MARIA v3.1.0 - Minimal API, Maximum Power. Intelligent Router + Dual Memory + File System. Enterprise-ready AI development platform with CLI cleanup and production-ready improvements.",
37752
37720
  keywords: [
37753
37721
  "ai",
37754
37722
  "cli",