@bike4mind/cli 0.2.23 → 0.2.24-cli-file-read-offset.18478

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.
Files changed (2) hide show
  1. package/dist/index.js +67 -36
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -3489,8 +3489,16 @@ CORE BEHAVIOR:
3489
3489
 
3490
3490
  FOR SOFTWARE ENGINEERING TASKS:
3491
3491
  When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
3492
- 1. **Understand:** Think about the user's request and the relevant codebase context. Use '${TOOL_GREP_SEARCH}' and '${TOOL_GLOB_FILES}' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use '${TOOL_FILE_READ}' to understand context and validate any assumptions you may have. If you need to read multiple files, you should make multiple parallel calls to '${TOOL_FILE_READ}'.
3493
- When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary action** must be to delegate to the '${EXPLORE_SUBAGENT_TYPE}' agent using the '${TOOL_SUBAGENT_DELEGATE}' tool. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${TOOL_GREP_SEARCH}' or '${TOOL_GLOB_FILES}' directly.
3492
+ 1. **Understand:** Think about the user's request and the relevant codebase context. Use '${TOOL_GREP_SEARCH}' and '${TOOL_GLOB_FILES}' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use '${TOOL_FILE_READ}' to understand context and validate any assumptions you may have.
3493
+
3494
+ IMPORTANT FILE READING RULES:
3495
+ - Read each file ONCE and refer to it in conversation history instead of re-reading
3496
+ - Read files COMPLETELY by default (without offset/limit parameters)
3497
+ - Only use offset/limit for files that are too large to fit in context (thousands of lines)
3498
+ - If you need to read multiple DIFFERENT files, make multiple parallel calls to '${TOOL_FILE_READ}'
3499
+ - NEVER make multiple calls to read the SAME file with different offsets unless it's truly too large
3500
+
3501
+ When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary action** must be to delegate to the '${EXPLORE_SUBAGENT_TYPE}' agent using the '${TOOL_SUBAGENT_DELEGATE}' tool. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${TOOL_GREP_SEARCH}' or '${TOOL_GLOB_FILES}' directly.
3494
3502
  2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.
3495
3503
  If '${EXPLORE_SUBAGENT_TYPE}' subagent was used, do not ignore the output of the agent, you must use it as the foundation of your plan. For complex tasks, break them down into smaller, manageable subtasks and use the \`${TOOL_WRITE_TODOS}\` tool to track your progress. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.
3496
3504
  3. **Implement:** Use the available tools (e.g., '${TOOL_EDIT_LOCAL_FILE}', '${TOOL_CREATE_FILE}', '${TOOL_BASH_EXECUTE}' ...) to act on the plan, strictly adhering to the project's established conventions.
@@ -5585,15 +5593,6 @@ var llmAnalysisResponseSchema = z136.object({
5585
5593
  suggestedTags: z136.array(z136.string()).default([])
5586
5594
  });
5587
5595
 
5588
- // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
5589
- import { z as z138 } from "zod";
5590
-
5591
- // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionInvoke.js
5592
- import { fromZodError } from "zod-validation-error";
5593
-
5594
- // ../../b4m-core/packages/services/dist/src/llm/tools/toolManager.js
5595
- var BUILT_IN_TOOL_SET = new Set(b4mLLMTools.options);
5596
-
5597
5596
  // ../../b4m-core/packages/services/dist/src/llm/tools/ToolCacheManager.js
5598
5597
  var DEFAULT_CONFIG = {
5599
5598
  ttl: 5 * 60 * 1e3,
@@ -8859,7 +8858,7 @@ import { existsSync as existsSync3, statSync as statSync4 } from "fs";
8859
8858
  import path7 from "path";
8860
8859
  var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
8861
8860
  async function readFileContent(params) {
8862
- const { path: filePath, encoding = "utf-8", maxLines } = params;
8861
+ const { path: filePath, encoding = "utf-8", offset = 0, limit } = params;
8863
8862
  const normalizedPath = path7.normalize(filePath);
8864
8863
  const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
8865
8864
  const cwd = path7.resolve(process.cwd());
@@ -8881,16 +8880,39 @@ async function readFileContent(params) {
8881
8880
  throw new Error(`File appears to be binary. Use encoding 'base64' to read binary files, or specify a different encoding.`);
8882
8881
  }
8883
8882
  const content = await fs8.readFile(resolvedPath, encoding);
8884
- if (maxLines && typeof content === "string") {
8883
+ if (typeof content === "string") {
8885
8884
  const lines = content.split("\n");
8886
- if (lines.length > maxLines) {
8887
- const truncatedContent = lines.slice(0, maxLines).join("\n");
8888
- return `${truncatedContent}
8885
+ const totalLines = lines.length;
8886
+ if (offset < 0) {
8887
+ throw new Error(`Invalid offset: ${offset}. Offset must be 0 or greater.`);
8888
+ }
8889
+ if (offset >= totalLines) {
8890
+ return `No content to show. File has ${totalLines} lines, but offset is ${offset}.
8891
+ (offset is 0-based, so valid range is 0-${Math.max(0, totalLines - 1)})`;
8892
+ }
8893
+ if (limit !== void 0 && limit > 0) {
8894
+ const endLine = Math.min(offset + limit, totalLines);
8895
+ const paginatedContent = lines.slice(offset, endLine).join("\n");
8896
+ if (endLine < totalLines) {
8897
+ const nextOffset = endLine;
8898
+ return `${paginatedContent}
8899
+
8900
+ ... Showing lines ${offset + 1}-${endLine} of ${totalLines} total lines (${stats.size} bytes total).
8901
+ To read more, use offset: ${nextOffset}`;
8902
+ }
8903
+ return `${paginatedContent}
8904
+
8905
+ ... Showing lines ${offset + 1}-${endLine} of ${totalLines} total lines (${stats.size} bytes total). End of file reached.`;
8906
+ }
8907
+ if (offset > 0) {
8908
+ const paginatedContent = lines.slice(offset).join("\n");
8909
+ return `${paginatedContent}
8889
8910
 
8890
- ... (truncated: ${lines.length - maxLines} more lines, ${stats.size} bytes total)`;
8911
+ ... Showing lines ${offset + 1}-${totalLines} of ${totalLines} total lines (${stats.size} bytes total).`;
8891
8912
  }
8913
+ return content;
8892
8914
  }
8893
- return typeof content === "string" ? content : `[Binary content, ${stats.size} bytes, base64 encoded]
8915
+ return `[Binary content, ${stats.size} bytes, base64 encoded]
8894
8916
  ${content}`;
8895
8917
  }
8896
8918
  async function checkIfBinary(filePath) {
@@ -8927,7 +8949,7 @@ var fileReadTool = {
8927
8949
  },
8928
8950
  toolSchema: {
8929
8951
  name: "file_read",
8930
- description: "Read the contents of a file from the local filesystem. Supports text files with various encodings. Files are restricted to the current working directory and subdirectories for security.",
8952
+ description: "Read the contents of a file from the local filesystem. Supports text files with various encodings. Files are restricted to the current working directory and subdirectories for security. IMPORTANT: Read files completely by default (without offset/limit). Only use offset/limit for extremely large files (thousands of lines) that exceed context limits. Never re-read the same file multiple times - refer to previous reads in conversation history instead.",
8931
8953
  parameters: {
8932
8954
  type: "object",
8933
8955
  properties: {
@@ -8940,9 +8962,13 @@ var fileReadTool = {
8940
8962
  description: "File encoding (default: utf-8). Use base64 for binary files.",
8941
8963
  enum: ["utf-8", "ascii", "base64"]
8942
8964
  },
8943
- maxLines: {
8965
+ offset: {
8944
8966
  type: "number",
8945
- description: "Maximum number of lines to return (optional). Useful for previewing large files. Returns full file by default."
8967
+ description: "OPTIONAL: For text files, the 0-based line number to start reading from. Only use for extremely large files (thousands of lines) that cannot fit in context. Default behavior is to read the entire file, which is preferred for most cases."
8968
+ },
8969
+ limit: {
8970
+ type: "number",
8971
+ description: "OPTIONAL: Maximum number of lines to read from offset. Only use for extremely large files (thousands of lines) that cannot fit in context. Default behavior is to read the entire file, which is preferred for most cases."
8946
8972
  }
8947
8973
  },
8948
8974
  required: ["path"]
@@ -10097,16 +10123,8 @@ var generateMcpTools = async (mcpData) => {
10097
10123
  import throttle2 from "lodash/throttle.js";
10098
10124
 
10099
10125
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionFeatures.js
10126
+ import { z as z138 } from "zod";
10100
10127
  import uniq4 from "lodash/uniq.js";
10101
-
10102
- // ../../b4m-core/packages/services/dist/src/llm/StatusManager.js
10103
- import throttle from "lodash/throttle.js";
10104
-
10105
- // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionProcess.js
10106
- var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true";
10107
- var questSaveMutex = new Mutex();
10108
-
10109
- // ../../b4m-core/packages/services/dist/src/llm/ChatCompletion.js
10110
10128
  var QuestStartBodySchema = z138.object({
10111
10129
  userId: z138.string(),
10112
10130
  sessionId: z138.string(),
@@ -10148,6 +10166,19 @@ var QuestStartBodySchema = z138.object({
10148
10166
  timezone: z138.string().optional()
10149
10167
  });
10150
10168
 
10169
+ // ../../b4m-core/packages/services/dist/src/llm/StatusManager.js
10170
+ import throttle from "lodash/throttle.js";
10171
+
10172
+ // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionProcess.js
10173
+ var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true";
10174
+ var questSaveMutex = new Mutex();
10175
+
10176
+ // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionInvoke.js
10177
+ import { fromZodError } from "zod-validation-error";
10178
+
10179
+ // ../../b4m-core/packages/services/dist/src/llm/tools/toolManager.js
10180
+ var BUILT_IN_TOOL_SET = new Set(b4mLLMTools.options);
10181
+
10151
10182
  // ../../b4m-core/packages/services/dist/src/llm/ImageGeneration.js
10152
10183
  import axios8 from "axios";
10153
10184
  import { fileTypeFromBuffer as fileTypeFromBuffer4 } from "file-type";
@@ -12513,7 +12544,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
12513
12544
  // package.json
12514
12545
  var package_default = {
12515
12546
  name: "@bike4mind/cli",
12516
- version: "0.2.23",
12547
+ version: "0.2.24-cli-file-read-offset.18478+9538467fd",
12517
12548
  type: "module",
12518
12549
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
12519
12550
  license: "UNLICENSED",
@@ -12621,10 +12652,10 @@ var package_default = {
12621
12652
  },
12622
12653
  devDependencies: {
12623
12654
  "@bike4mind/agents": "0.1.0",
12624
- "@bike4mind/common": "2.47.0",
12625
- "@bike4mind/mcp": "1.27.0",
12626
- "@bike4mind/services": "2.45.0",
12627
- "@bike4mind/utils": "2.3.2",
12655
+ "@bike4mind/common": "2.47.1-cli-file-read-offset.18478+9538467fd",
12656
+ "@bike4mind/mcp": "1.27.1-cli-file-read-offset.18478+9538467fd",
12657
+ "@bike4mind/services": "2.45.1-cli-file-read-offset.18478+9538467fd",
12658
+ "@bike4mind/utils": "2.3.3-cli-file-read-offset.18478+9538467fd",
12628
12659
  "@types/better-sqlite3": "^7.6.13",
12629
12660
  "@types/diff": "^5.0.9",
12630
12661
  "@types/jsonwebtoken": "^9.0.4",
@@ -12641,7 +12672,7 @@ var package_default = {
12641
12672
  optionalDependencies: {
12642
12673
  "@vscode/ripgrep": "^1.17.0"
12643
12674
  },
12644
- gitHead: "ad52049ef04e434ab45416bed8e4754b4b232c0d"
12675
+ gitHead: "9538467fd3acaaf1c31be03ff723e206139a8469"
12645
12676
  };
12646
12677
 
12647
12678
  // src/config/constants.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.23",
3
+ "version": "0.2.24-cli-file-read-offset.18478+9538467fd",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -108,10 +108,10 @@
108
108
  },
109
109
  "devDependencies": {
110
110
  "@bike4mind/agents": "0.1.0",
111
- "@bike4mind/common": "2.47.0",
112
- "@bike4mind/mcp": "1.27.0",
113
- "@bike4mind/services": "2.45.0",
114
- "@bike4mind/utils": "2.3.2",
111
+ "@bike4mind/common": "2.47.1-cli-file-read-offset.18478+9538467fd",
112
+ "@bike4mind/mcp": "1.27.1-cli-file-read-offset.18478+9538467fd",
113
+ "@bike4mind/services": "2.45.1-cli-file-read-offset.18478+9538467fd",
114
+ "@bike4mind/utils": "2.3.3-cli-file-read-offset.18478+9538467fd",
115
115
  "@types/better-sqlite3": "^7.6.13",
116
116
  "@types/diff": "^5.0.9",
117
117
  "@types/jsonwebtoken": "^9.0.4",
@@ -128,5 +128,5 @@
128
128
  "optionalDependencies": {
129
129
  "@vscode/ripgrep": "^1.17.0"
130
130
  },
131
- "gitHead": "ad52049ef04e434ab45416bed8e4754b4b232c0d"
131
+ "gitHead": "9538467fd3acaaf1c31be03ff723e206139a8469"
132
132
  }