bravecode-cli 0.1.51 → 0.1.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli-main.mjs CHANGED
@@ -38280,7 +38280,7 @@ var APP_VERSION, APP_NAME;
38280
38280
  var init_version = __esm({
38281
38281
  "src/version.ts"() {
38282
38282
  "use strict";
38283
- APP_VERSION = "0.1.51";
38283
+ APP_VERSION = "0.1.52";
38284
38284
  APP_NAME = "BraveCode";
38285
38285
  }
38286
38286
  });
@@ -41249,6 +41249,31 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41249
41249
  setAutoApprove(auto) {
41250
41250
  this.autoApprove = auto;
41251
41251
  }
41252
+ /**
41253
+ * Last-resort extractor for tool calls that the provider's parser missed.
41254
+ * Handles non-standard tag formats the model emits in plain text, e.g.
41255
+ * <write_file path="...">...</write_file>, <read_file path="..."/>,
41256
+ * <run_command>cmd</run_command>, including the HTML-entity-escaped form.
41257
+ */
41258
+ extractNativeToolTags(text2) {
41259
+ const decoded = text2.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"');
41260
+ const calls = [];
41261
+ const idSeq = () => `native_${Date.now().toString(36)}_${calls.length}`;
41262
+ const wfRe = /<write_file\s+path="([^"]+)">([\s\S]*?)<\/write_file>/g;
41263
+ let m;
41264
+ while ((m = wfRe.exec(decoded)) !== null) {
41265
+ calls.push({ id: idSeq(), name: "write", arguments: { filePath: m[1], content: m[2] } });
41266
+ }
41267
+ const rfRe = /<read_file\s+path="([^"]+)"\s*\/>/g;
41268
+ while ((m = rfRe.exec(decoded)) !== null) {
41269
+ calls.push({ id: idSeq(), name: "read", arguments: { filePath: m[1] } });
41270
+ }
41271
+ const rcRe = /<run_command>([\s\S]*?)<\/run_command>/g;
41272
+ while ((m = rcRe.exec(decoded)) !== null) {
41273
+ calls.push({ id: idSeq(), name: "bash", arguments: { command: m[1].trim() } });
41274
+ }
41275
+ return calls;
41276
+ }
41252
41277
  async run(userMessage, onChunk, signal, onToolCall) {
41253
41278
  let message = userMessage;
41254
41279
  if (this.pluginHooks.beforeAgentRun) {
@@ -41292,6 +41317,9 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41292
41317
  toolCalls.push(chunk.toolCall);
41293
41318
  }
41294
41319
  }
41320
+ if (toolCalls.length === 0) {
41321
+ toolCalls = this.extractNativeToolTags(fullResponse);
41322
+ }
41295
41323
  } else {
41296
41324
  const result = await this.provider.chat({
41297
41325
  model: this.config.model,