bravecode-cli 0.1.50 → 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
@@ -37204,25 +37204,71 @@ var init_provider = __esm({
37204
37204
  /**
37205
37205
  * Also recognize the model-native tool tag format some LLMs default to,
37206
37206
  * e.g. <write_file path="src/App.tsx">...content...</write_file>.
37207
- * Translates these into real `write` tool calls.
37207
+ * Also accepts the HTML-entity-escaped form (&lt;write_file ...&gt;) that
37208
+ * some models emit when prompted to avoid HTML. Translates all of these
37209
+ * into real tool calls.
37208
37210
  */
37209
37211
  consumeNativeTags(text2) {
37210
37212
  const out = [];
37211
37213
  const calls = [];
37212
- const re = /<write_file\s+path="([^"]+)">([\s\S]*?)<\/write_file>/g;
37213
- let last = 0;
37214
- let m;
37215
- while ((m = re.exec(text2)) !== null) {
37216
- const [full, path2, content] = m;
37217
- out.push(text2.slice(last, m.index));
37218
- calls.push({
37219
- id: this.newCallId(),
37220
- name: "write",
37221
- arguments: { filePath: path2, content }
37222
- });
37223
- last = m.index + full.length;
37214
+ const decoded = text2.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"');
37215
+ const nextCall = () => this.newCallId();
37216
+ {
37217
+ const re = /<write_file\s+path="([^"]+)">([\s\S]*?)<\/write_file>/g;
37218
+ let last = 0;
37219
+ let m;
37220
+ while ((m = re.exec(decoded)) !== null) {
37221
+ const [full, path2, content] = m;
37222
+ out.push(decoded.slice(last, m.index));
37223
+ calls.push({
37224
+ id: nextCall(),
37225
+ name: "write",
37226
+ arguments: { filePath: path2, content }
37227
+ });
37228
+ last = m.index + full.length;
37229
+ }
37230
+ out.push(decoded.slice(last));
37231
+ }
37232
+ {
37233
+ const text22 = out.join("");
37234
+ const re = /<read_file\s+path="([^"]+)"\s*\/>/g;
37235
+ let last = 0;
37236
+ let m;
37237
+ const replaced = [];
37238
+ while ((m = re.exec(text22)) !== null) {
37239
+ const [full, path2] = m;
37240
+ replaced.push(text22.slice(last, m.index));
37241
+ calls.push({
37242
+ id: nextCall(),
37243
+ name: "read",
37244
+ arguments: { filePath: path2 }
37245
+ });
37246
+ last = m.index + full.length;
37247
+ }
37248
+ replaced.push(text22.slice(last));
37249
+ out.length = 0;
37250
+ out.push(replaced.join(""));
37251
+ }
37252
+ {
37253
+ const text22 = out.join("");
37254
+ const re = /<run_command>([\s\S]*?)<\/run_command>/g;
37255
+ let last = 0;
37256
+ let m;
37257
+ const replaced = [];
37258
+ while ((m = re.exec(text22)) !== null) {
37259
+ const [full, cmd] = m;
37260
+ replaced.push(text22.slice(last, m.index));
37261
+ calls.push({
37262
+ id: nextCall(),
37263
+ name: "bash",
37264
+ arguments: { command: cmd.trim() }
37265
+ });
37266
+ last = m.index + full.length;
37267
+ }
37268
+ replaced.push(text22.slice(last));
37269
+ out.length = 0;
37270
+ out.push(replaced.join(""));
37224
37271
  }
37225
- out.push(text2.slice(last));
37226
37272
  return { text: out.join(""), toolCalls: calls };
37227
37273
  }
37228
37274
  end() {
@@ -38234,7 +38280,7 @@ var APP_VERSION, APP_NAME;
38234
38280
  var init_version = __esm({
38235
38281
  "src/version.ts"() {
38236
38282
  "use strict";
38237
- APP_VERSION = "0.1.50";
38283
+ APP_VERSION = "0.1.52";
38238
38284
  APP_NAME = "BraveCode";
38239
38285
  }
38240
38286
  });
@@ -41203,6 +41249,31 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41203
41249
  setAutoApprove(auto) {
41204
41250
  this.autoApprove = auto;
41205
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
+ }
41206
41277
  async run(userMessage, onChunk, signal, onToolCall) {
41207
41278
  let message = userMessage;
41208
41279
  if (this.pluginHooks.beforeAgentRun) {
@@ -41246,6 +41317,9 @@ IMPORTANT: Only test APIs you have authorization to test. Never attempt to acces
41246
41317
  toolCalls.push(chunk.toolCall);
41247
41318
  }
41248
41319
  }
41320
+ if (toolCalls.length === 0) {
41321
+ toolCalls = this.extractNativeToolTags(fullResponse);
41322
+ }
41249
41323
  } else {
41250
41324
  const result = await this.provider.chat({
41251
41325
  model: this.config.model,