Skip to content

Commit 48623cb

Browse files
authored
Merge pull request #167 from posit-dev/feat/read-edit-tool
feat: Add hashline-based file read and edit tools
2 parents fb9ad81 + 6960eaf commit 48623cb

18 files changed

Lines changed: 2196 additions & 566 deletions

DESCRIPTION

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ Suggests:
7171
roxygen2,
7272
shiny,
7373
shinychat (>= 0.3.0),
74-
tibble,
7574
testthat (>= 3.0.0),
75+
tibble,
7676
usethis
77-
Config/Needs/website: tidyverse/tidytemplate
77+
Config/Needs/website: brand.yml, tidyverse/tidytemplate
7878
Config/testthat/edition: 3
7979
Config/testthat/parallel: true
8080
Config/testthat/start-first: web, news, covr, search
@@ -106,8 +106,12 @@ Collate:
106106
'tool-docs.R'
107107
'tool-env-df.R'
108108
'tool-env.R'
109+
'tool-files-edit.R'
110+
'tool-files-list.R'
111+
'tool-files-read.R'
112+
'tool-files-replace.R'
109113
'tool-files-search.R'
110-
'tool-files.R'
114+
'tool-files-write.R'
111115
'tool-git.R'
112116
'tool-github.R'
113117
'tool-ide.R'

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ export(btw_tool_docs_vignette)
4040
export(btw_tool_env_describe_data_frame)
4141
export(btw_tool_env_describe_environment)
4242
export(btw_tool_files_code_search)
43+
export(btw_tool_files_edit)
4344
export(btw_tool_files_list)
4445
export(btw_tool_files_list_files)
4546
export(btw_tool_files_read)
4647
export(btw_tool_files_read_text_file)
48+
export(btw_tool_files_replace)
4749
export(btw_tool_files_search)
4850
export(btw_tool_files_write)
4951
export(btw_tool_files_write_text_file)

NEWS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# btw (development version)
22

3+
* New `btw_tool_files_edit()` tool makes targeted, validated line-based edits
4+
to files using `replace`, `insert_after`, and `replace_range` actions. Edits
5+
are anchored to content hashes, so stale edits are rejected if the file has
6+
changed. To support this, `btw_tool_files_read()` now annotates each line
7+
with a short hash (e.g. `2:f1a| return("world")`) when called as a tool
8+
(#167).
9+
10+
* New `btw_tool_files_replace()` tool finds and replaces exact string
11+
occurrences in a file. By default it requires the string to appear exactly
12+
once to prevent unintended changes; set `replace_all = TRUE` to replace all
13+
occurrences (#167).
14+
315
* `btw_tool_files_read()` now correctly reads valid UTF-8 files containing non-ASCII characters (e.g., Cyrillic). Previously, these files were incorrectly rejected on Windows with non-English locales when `Encoding()` returned "unknown" even though they were valid UTF-8 (thanks @RKonstantinR, #160).
416

517
* BREAKING CHANGE: Several tool groups and tool names have been renamed for clarity (#159):

0 commit comments

Comments
 (0)