bravecode-cli 0.1.55 → 0.1.57

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
@@ -37777,8 +37777,15 @@ var init_file = __esm({
37777
37777
  required: ["filePath"]
37778
37778
  },
37779
37779
  async execute(input) {
37780
- const { filePath } = input;
37781
- const absPath = isAbsolute(filePath) ? filePath : resolve2(process.cwd(), filePath);
37780
+ let { filePath } = input;
37781
+ if (isAbsolute(filePath)) {
37782
+ const cwd = process.cwd();
37783
+ const home = process.env.HOME || "";
37784
+ if (filePath.startsWith(cwd + "/")) filePath = filePath.slice(cwd.length + 1);
37785
+ else if (filePath.startsWith("/" + home + "/")) filePath = filePath.slice(home.length + 2);
37786
+ else filePath = filePath.replace(/^\/+/, "");
37787
+ }
37788
+ const absPath = resolve2(process.cwd(), filePath);
37782
37789
  if (!existsSync(absPath)) {
37783
37790
  return `Error: File not found: ${absPath}`;
37784
37791
  }
@@ -37792,22 +37799,35 @@ var init_file = __esm({
37792
37799
  };
37793
37800
  writeTool = {
37794
37801
  name: "write",
37795
- description: "Write a file to the local filesystem. Accepts absolute or relative paths (relative to the current working directory). Creates parent directories automatically if they don't exist.",
37802
+ description: "Write a file. If you pass an absolute path, it is automatically rewritten to a relative path under a project directory. The model should pass paths like snake-game/index.html, my-app/src/main.tsx, etc.",
37796
37803
  parameters: {
37797
37804
  type: "object",
37798
37805
  properties: {
37799
- filePath: { type: "string", description: "The path to the file (absolute or relative to the current working directory)" },
37806
+ filePath: { type: "string", description: "Project-relative path like 'snake-game/index.html' or 'my-app/src/main.tsx'." },
37800
37807
  content: { type: "string", description: "The content to write" }
37801
37808
  },
37802
37809
  required: ["filePath", "content"]
37803
37810
  },
37804
37811
  async execute(input) {
37805
- const { filePath, content } = input;
37806
- const absPath = isAbsolute(filePath) ? filePath : resolve2(process.cwd(), filePath);
37812
+ let { filePath, content } = input;
37813
+ if (isAbsolute(filePath)) {
37814
+ const cwd = process.cwd();
37815
+ const home = process.env.HOME || "";
37816
+ let rel = filePath;
37817
+ if (rel.startsWith(cwd + "/")) {
37818
+ rel = rel.slice(cwd.length + 1);
37819
+ } else if (rel.startsWith("/" + home + "/")) {
37820
+ rel = rel.slice(home.length + 2);
37821
+ } else {
37822
+ rel = rel.replace(/^\/+/, "");
37823
+ }
37824
+ filePath = rel;
37825
+ }
37826
+ const absPath = resolve2(process.cwd(), filePath);
37807
37827
  try {
37808
37828
  mkdirSync(dirname(absPath), { recursive: true });
37809
37829
  writeFileSync(absPath, content, "utf-8");
37810
- return `File written successfully: ${absPath}`;
37830
+ return `File written successfully: ${filePath} (absolute: ${absPath})`;
37811
37831
  } catch (error40) {
37812
37832
  return `Error writing file: ${error40.message}`;
37813
37833
  }
@@ -37826,8 +37846,15 @@ var init_file = __esm({
37826
37846
  required: ["filePath", "oldString", "newString"]
37827
37847
  },
37828
37848
  async execute(input) {
37829
- const { filePath, oldString, newString } = input;
37830
- const absPath = isAbsolute(filePath) ? filePath : resolve2(process.cwd(), filePath);
37849
+ let { filePath, oldString, newString } = input;
37850
+ if (isAbsolute(filePath)) {
37851
+ const cwd = process.cwd();
37852
+ const home = process.env.HOME || "";
37853
+ if (filePath.startsWith(cwd + "/")) filePath = filePath.slice(cwd.length + 1);
37854
+ else if (filePath.startsWith("/" + home + "/")) filePath = filePath.slice(home.length + 2);
37855
+ else filePath = filePath.replace(/^\/+/, "");
37856
+ }
37857
+ const absPath = resolve2(process.cwd(), filePath);
37831
37858
  if (!existsSync(absPath)) {
37832
37859
  return `Error: File not found: ${absPath}`;
37833
37860
  }
@@ -38286,7 +38313,7 @@ var APP_VERSION, APP_NAME;
38286
38313
  var init_version = __esm({
38287
38314
  "src/version.ts"() {
38288
38315
  "use strict";
38289
- APP_VERSION = "0.1.55";
38316
+ APP_VERSION = "0.1.57";
38290
38317
  APP_NAME = "BraveCode";
38291
38318
  }
38292
38319
  });