From 13b467c2eb6e039bdfbf1bd54ac5658f8401e12d Mon Sep 17 00:00:00 2001 From: Janni Turunen Date: Thu, 26 Feb 2026 16:23:26 +0200 Subject: [PATCH 1/4] fix(hashline): warn agents to check for duplicates before insert_after (#349) --- packages/opencode/src/tool/hashline_edit.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/tool/hashline_edit.txt b/packages/opencode/src/tool/hashline_edit.txt index 88303a1942f..c52d7f4a1ea 100644 --- a/packages/opencode/src/tool/hashline_edit.txt +++ b/packages/opencode/src/tool/hashline_edit.txt @@ -3,10 +3,17 @@ Apply precise line edits to a file using content-addressable anchors from hashli Each edit references a line by its anchor (line number + CJK hash character). The tool validates all anchors before applying any edits — if any anchor doesn't match, no changes are made. -Supports three operations: +Supports five operations: - set_line: Replace or delete a single line - replace_lines: Replace or delete a contiguous range of lines -- insert_after: Insert new lines after an anchor line +- insert_after: Insert new lines after an anchor line. ⚠️ Does NOT check for duplicates. Before inserting, verify lines don't exist. Example: rg "^const foo = 1$" file.ts (use ^ and $ for exact match) +- insert_before: Insert new lines before an anchor line. ⚠️ Does NOT check for duplicates. Before inserting, verify lines don't exist. Example: rg "^const foo = 1$" file.ts (use ^ and $ for exact match) + +⚠️ Workflow Checklist: +- Before insertion: rg "^exact_line$" full/path/to/file.ts --case-sensitive +- If multiple lines (e.g., "line1\nline2"): split and rg each line separately +- If duplicate found: use replace_lines or set_line instead of insert +- For special regex chars ([, ], (, ), ., *): escape them or use fixed strings If lines have moved since last read, anchors are automatically relocated by hash. Always use hashline_read to get current anchors before editing. \ No newline at end of file From 3832f4bfb2773b9762b20fc206da30c868c41b41 Mon Sep 17 00:00:00 2001 From: Janni Turunen Date: Thu, 26 Feb 2026 16:37:49 +0200 Subject: [PATCH 2/4] fix(hashline): correct operation count and improve rg examples in insert warning (#349) --- packages/opencode/src/tool/hashline_edit.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/tool/hashline_edit.txt b/packages/opencode/src/tool/hashline_edit.txt index c52d7f4a1ea..54217a98b20 100644 --- a/packages/opencode/src/tool/hashline_edit.txt +++ b/packages/opencode/src/tool/hashline_edit.txt @@ -3,17 +3,17 @@ Apply precise line edits to a file using content-addressable anchors from hashli Each edit references a line by its anchor (line number + CJK hash character). The tool validates all anchors before applying any edits — if any anchor doesn't match, no changes are made. -Supports five operations: +Supports four operations: - set_line: Replace or delete a single line - replace_lines: Replace or delete a contiguous range of lines - insert_after: Insert new lines after an anchor line. ⚠️ Does NOT check for duplicates. Before inserting, verify lines don't exist. Example: rg "^const foo = 1$" file.ts (use ^ and $ for exact match) - insert_before: Insert new lines before an anchor line. ⚠️ Does NOT check for duplicates. Before inserting, verify lines don't exist. Example: rg "^const foo = 1$" file.ts (use ^ and $ for exact match) ⚠️ Workflow Checklist: -- Before insertion: rg "^exact_line$" full/path/to/file.ts --case-sensitive +- Before insertion: rg "^exact_line$" full/path/to/file.ts - If multiple lines (e.g., "line1\nline2"): split and rg each line separately - If duplicate found: use replace_lines or set_line instead of insert -- For special regex chars ([, ], (, ), ., *): escape them or use fixed strings +- For special regex chars ([, ], (, ), ., *): escape them. Example: rg "const my\\.special = 1$" file.ts (escape dot for exact match) If lines have moved since last read, anchors are automatically relocated by hash. Always use hashline_read to get current anchors before editing. \ No newline at end of file From 5dc66471a97da49e57477241b17e47c0fbd58cc7 Mon Sep 17 00:00:00 2001 From: Janni Turunen Date: Thu, 26 Feb 2026 17:56:22 +0200 Subject: [PATCH 3/4] ci: re-trigger CI after stuck runner From 3758d6de55d2923b97d8303f1af554ae3b76c688 Mon Sep 17 00:00:00 2001 From: Janni Turunen Date: Thu, 26 Feb 2026 19:06:45 +0200 Subject: [PATCH 4/4] fix(hashline): add rg case-sensitivity note and -F flag example (#349) --- packages/opencode/src/tool/hashline_edit.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/opencode/src/tool/hashline_edit.txt b/packages/opencode/src/tool/hashline_edit.txt index 54217a98b20..2792dff1480 100644 --- a/packages/opencode/src/tool/hashline_edit.txt +++ b/packages/opencode/src/tool/hashline_edit.txt @@ -14,6 +14,8 @@ Supports four operations: - If multiple lines (e.g., "line1\nline2"): split and rg each line separately - If duplicate found: use replace_lines or set_line instead of insert - For special regex chars ([, ], (, ), ., *): escape them. Example: rg "const my\\.special = 1$" file.ts (escape dot for exact match) +- Note: rg is case-sensitive by default — no --case-sensitive flag needed +- For literal strings (no regex): use -F flag. Example: rg -F "const my.special = 1" file.ts If lines have moved since last read, anchors are automatically relocated by hash. Always use hashline_read to get current anchors before editing. \ No newline at end of file