zrb 1.5.6__py3-none-any.whl → 1.5.7__py3-none-any.whl

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.
@@ -4,8 +4,7 @@ import os
4
4
  import re
5
5
  from typing import Any, Optional
6
6
 
7
- from zrb.util.file import read_file as _read_file
8
- from zrb.util.file import write_file as _write_file
7
+ from zrb.util.file import read_file, read_file_with_line_numbers, write_file
9
8
 
10
9
  DEFAULT_EXCLUDED_PATTERNS = [
11
10
  # Common Python artifacts
@@ -182,7 +181,7 @@ def read_from_file(
182
181
  start_line: Optional[int] = None,
183
182
  end_line: Optional[int] = None,
184
183
  ) -> str:
185
- """Read file content (or specific lines) at a path.
184
+ """Read file content (or specific lines) at a path, including line numbers.
186
185
  Args:
187
186
  path (str): Path to read. Pass exactly as provided, including '~'.
188
187
  start_line (Optional[int]): Starting line number (1-based).
@@ -191,6 +190,7 @@ def read_from_file(
191
190
  Defaults to None (end of file).
192
191
  Returns:
193
192
  str: JSON: {"path": "...", "content": "...", "start_line": N, ...} or {"error": "..."}
193
+ The content includes line numbers.
194
194
  Raises:
195
195
  Exception: If an error occurs.
196
196
  """
@@ -199,7 +199,7 @@ def read_from_file(
199
199
  # Check if file exists
200
200
  if not os.path.exists(abs_path):
201
201
  return json.dumps({"error": f"File {path} does not exist"})
202
- content = _read_file(abs_path)
202
+ content = read_file_with_line_numbers(abs_path)
203
203
  lines = content.splitlines()
204
204
  total_lines = len(lines)
205
205
  # Adjust line indices (convert from 1-based to 0-based)
@@ -259,7 +259,7 @@ def write_to_file(
259
259
  directory = os.path.dirname(abs_path)
260
260
  if directory and not os.path.exists(directory):
261
261
  os.makedirs(directory, exist_ok=True)
262
- _write_file(abs_path, content)
262
+ write_file(abs_path, content)
263
263
  result_data = {"success": True, "path": path}
264
264
  if warning:
265
265
  result_data["warning"] = warning
@@ -391,6 +391,7 @@ def apply_diff(
391
391
  replace_marker (str): Marker for end of replacement block.
392
392
  Defaults to ">>>>>> REPLACE".
393
393
  SEARCH block must exactly match file content including whitespace/indentation.
394
+ SEARCH block should NOT contains line numbers
394
395
  Format example:
395
396
  [Search Marker, e.g., <<<<<< SEARCH]
396
397
  :start_line:10
@@ -414,7 +415,7 @@ def apply_diff(
414
415
  return json.dumps(
415
416
  {"success": False, "path": path, "error": f"File not found at {path}"}
416
417
  )
417
- content = _read_file(abs_path)
418
+ content = read_file(abs_path)
418
419
  lines = content.splitlines()
419
420
  if start_line < 1 or end_line > len(lines) or start_line > end_line:
420
421
  return json.dumps(
@@ -444,7 +445,7 @@ def apply_diff(
444
445
  new_content = "\n".join(new_lines)
445
446
  if content.endswith("\n"):
446
447
  new_content += "\n"
447
- _write_file(abs_path, new_content)
448
+ write_file(abs_path, new_content)
448
449
  return json.dumps({"success": True, "path": path})
449
450
  except ValueError as e:
450
451
  raise ValueError(f"Error parsing diff: {e}")
@@ -4,7 +4,7 @@ import platform
4
4
  import re
5
5
  from typing import Any
6
6
 
7
- from zrb.util.file import read_dir, read_file
7
+ from zrb.util.file import read_dir, read_file_with_line_numbers
8
8
 
9
9
 
10
10
  def get_default_context(user_message: str) -> dict[str, Any]:
@@ -14,12 +14,13 @@ def get_default_context(user_message: str) -> dict[str, Any]:
14
14
  for ref in references:
15
15
  resource_path = os.path.abspath(os.path.expanduser(ref))
16
16
  if os.path.isfile(resource_path):
17
- content = read_file(resource_path)
17
+ content = read_file_with_line_numbers(resource_path)
18
18
  current_references.append(
19
19
  {
20
20
  "reference": ref,
21
21
  "name": resource_path,
22
22
  "type": "file",
23
+ "note": "line numbers are included in the content",
23
24
  "content": content,
24
25
  }
25
26
  )
zrb/util/file.py CHANGED
@@ -12,6 +12,15 @@ def read_file(file_path: str, replace_map: dict[str, str] = {}) -> str:
12
12
  return content
13
13
 
14
14
 
15
+ def read_file_with_line_numbers(
16
+ file_path: str, replace_map: dict[str, str] = {}
17
+ ) -> str:
18
+ content = read_file(file_path, replace_map)
19
+ lines = content.splitlines()
20
+ numbered_lines = [f"{i + 1} | {line}" for i, line in enumerate(lines)]
21
+ return "\n".join(numbered_lines)
22
+
23
+
15
24
  def read_dir(dir_path: str) -> list[str]:
16
25
  return [f for f in os.listdir(os.path.abspath(os.path.expanduser(dir_path)))]
17
26
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zrb
3
- Version: 1.5.6
3
+ Version: 1.5.7
4
4
  Summary: Your Automation Powerhouse
5
5
  Home-page: https://github.com/state-alchemists/zrb
6
6
  License: AGPL-3.0-or-later
@@ -13,7 +13,7 @@ zrb/builtin/llm/llm_chat.py,sha256=XL5HK_o1EejkYS0fJIBI39vApuqYYsGHFSigvXfS7CI,4
13
13
  zrb/builtin/llm/previous-session.js,sha256=xMKZvJoAbrwiyHS0OoPrWuaKxWYLoyR5sguePIoCjTY,816
14
14
  zrb/builtin/llm/tool/api.py,sha256=yR9I0ZsI96OeQl9pgwORMASVuXsAL0a89D_iPS4C8Dc,1699
15
15
  zrb/builtin/llm/tool/cli.py,sha256=_CNEmEc6K2Z0i9ppYeM7jGpqaEdT3uxaWQatmxP3jKE,858
16
- zrb/builtin/llm/tool/file.py,sha256=rBMSWvElWQN0-c2CkwTHqY_A3dq5p4XFAAO-pgpupQk,19163
16
+ zrb/builtin/llm/tool/file.py,sha256=ecFBmbMaqCIfqNGTmvd-Yt3vLtKuQ15KbjXlnIMWdho,19269
17
17
  zrb/builtin/llm/tool/rag.py,sha256=tw4MW5VW_3hezGufS0nICHe28eg5hPLMO4SsiDp4srQ,7500
18
18
  zrb/builtin/llm/tool/web.py,sha256=4qzom9xX-JxztIaTWneNfyTRlgweHIxzC1uSEAxJ00A,5507
19
19
  zrb/builtin/md5.py,sha256=0pNlrfZA0wlZlHvFHLgyqN0JZJWGKQIF5oXxO44_OJk,949
@@ -305,7 +305,7 @@ zrb/task/http_check.py,sha256=Gf5rOB2Se2EdizuN9rp65HpGmfZkGc-clIAlHmPVehs,2565
305
305
  zrb/task/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
306
306
  zrb/task/llm/agent_runner.py,sha256=-6i351_AViek2xXpqPHa0LdwhhRDPLpcnKeyr-pAGyI,1848
307
307
  zrb/task/llm/context_enricher.py,sha256=eNjyHkL2g5X1jMtYR711-N_x7EtkoP6d577uT3anOYA,3016
308
- zrb/task/llm/default_context.py,sha256=ROC0n_QcULzd_CWIaWgdZgnasrNnRCZzaB-l6287xwU,1352
308
+ zrb/task/llm/default_context.py,sha256=IgHpmlGsBXILJcWC4Fn9dr52UG-puMXlQ-AHoXd6Oh0,1460
309
309
  zrb/task/llm/error.py,sha256=YOwnEdFMtqOlaiA83tDHpC6uh2_9r5NeS-inrlb5a8E,3622
310
310
  zrb/task/llm/history.py,sha256=qQtp-8a71sYL0A9YWo94KRy9o9J5ZCCJlMk4jM-t_rI,3572
311
311
  zrb/task/llm/history_summarizer.py,sha256=WZRyVRh1eGOmZKHypaxEidzruDYEM-Gcmdy2Z_XJ4Ro,2572
@@ -339,7 +339,7 @@ zrb/util/codemod/modify_function_call.py,sha256=F7EejY7nzvYVElJPVneMcLIUig_Hj0lL
339
339
  zrb/util/codemod/modify_method.py,sha256=FPPkNtvf2QO2cEfYtiO_GlNDNFOLylEET1NEOqkV7aA,3684
340
340
  zrb/util/codemod/modify_module.py,sha256=_P6yq5TA_n72mmZIOrK914zPtv1RrRI8WC3YxpWNsRs,437
341
341
  zrb/util/cron.py,sha256=9fTGatUMYCRgmDFGg-z6_XerT4U5Vq72nD05NnEVUm4,2852
342
- zrb/util/file.py,sha256=lDEL_lOD7I7zr2liPNLa947gbSQcB0k2YBSgNeddwRE,1073
342
+ zrb/util/file.py,sha256=wa86GQjCR0i-8_FSnA_4eWZoiuH9VCom7ajkN-NaFAw,1364
343
343
  zrb/util/git.py,sha256=TShnMxPAk20Tglp25d_XPVZX-q0mvKeqdprVMeXQ5f0,4787
344
344
  zrb/util/git_subtree.py,sha256=zyWl0aUEZJyUJKjfw1uglozB4R1kF9pWtfKjhu8DN44,2658
345
345
  zrb/util/group.py,sha256=Bg7HrSycoK110U5s_Tca6-uUQuZ5CMgb8wxZSrvDQ98,2790
@@ -352,7 +352,7 @@ zrb/util/string/name.py,sha256=8picJfUBXNpdh64GNaHv3om23QHhUZux7DguFLrXHp8,1163
352
352
  zrb/util/todo.py,sha256=1nDdwPc22oFoK_1ZTXyf3638Bg6sqE2yp_U4_-frHoc,16015
353
353
  zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
354
354
  zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
355
- zrb-1.5.6.dist-info/METADATA,sha256=ca7RqSQ9hcGOJ_7lJH7x8L-bK_Og2sB2I-b0KujD24I,8470
356
- zrb-1.5.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
357
- zrb-1.5.6.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
358
- zrb-1.5.6.dist-info/RECORD,,
355
+ zrb-1.5.7.dist-info/METADATA,sha256=jnJmD2uvg38nJvh5kYyMM77rWT4HEIEjnOCIgI8IhJY,8470
356
+ zrb-1.5.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
357
+ zrb-1.5.7.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
358
+ zrb-1.5.7.dist-info/RECORD,,
File without changes