feat(hashline-edit): add anchor insert modes and strict insert validation#2026
Merged
code-yeongyu merged 2 commits intodevfrom Feb 21, 2026
Merged
feat(hashline-edit): add anchor insert modes and strict insert validation#2026code-yeongyu merged 2 commits intodevfrom
code-yeongyu merged 2 commits intodevfrom
Conversation
There was a problem hiding this comment.
5 issues found across 13 files
Confidence score: 3/5
src/tools/hashline-edit/edit-text-normalization.tshas concrete logic bugs (boundary-only payload length check and early return) that can leave echo artifacts or duplicate a line, which is user-visible behavior.- These are higher-severity issues (6–7/10) with high confidence, so there is some regression risk despite the limited scope.
- Pay close attention to
src/tools/hashline-edit/edit-text-normalization.ts- normalization edge cases around boundary/anchor echoes.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tools/hashline-edit/hash-computation.ts">
<violation number="1" location="src/tools/hashline-edit/hash-computation.ts:75">
P3: Stateful chunking logic (`pushLine` and `flush`) is heavily duplicated between stream formatters.</violation>
<violation number="2" location="src/tools/hashline-edit/hash-computation.ts:131">
P2: `streamHashLinesFromUtf8` handles empty streams inconsistently compared to `formatHashLines`.</violation>
<violation number="3" location="src/tools/hashline-edit/hash-computation.ts:205">
P2: `streamHashLinesFromLines` handles empty iterables inconsistently compared to `formatHashLines`.</violation>
</file>
<file name="src/tools/hashline-edit/edit-text-normalization.ts">
<violation number="1" location="src/tools/hashline-edit/edit-text-normalization.ts:60">
P2: Early return prevents stripping a single-line anchor echo, bypassing empty-insert validation and duplicating the line.</violation>
<violation number="2" location="src/tools/hashline-edit/edit-text-normalization.ts:77">
P1: Incorrect length check prevents stripping of trailing boundary echo when the payload consists only of the boundaries.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…king dedup, empty stream alignment - Fix single-line anchor-echo stripping to trigger empty-insert validation - Fix trailing boundary-echo stripping for boundary-only payloads - Extract shared chunking logic to hashline-chunk-formatter - Align empty stream/iterable handling with formatHashLines - Add regression tests for all fixes
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tools/hashline-edit/edit-text-normalization.ts">
<violation number="1" location="src/tools/hashline-edit/edit-text-normalization.ts:60">
P1: `stripInsertBeforeEcho` still uses `newLines.length <= 1` and was missed in this strict validation update. An `insert_before` payload containing only an echo line will duplicate the anchor instead of erroring out.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -0,0 +1,109 @@ | |||
| const HASHLINE_PREFIX_RE = /^\s*(?:>>>|>>)?\s*\d+#[A-Z]{2}:/ | |||
There was a problem hiding this comment.
P1: stripInsertBeforeEcho still uses newLines.length <= 1 and was missed in this strict validation update. An insert_before payload containing only an echo line will duplicate the anchor instead of erroring out.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tools/hashline-edit/edit-text-normalization.ts, line 60:
<comment>`stripInsertBeforeEcho` still uses `newLines.length <= 1` and was missed in this strict validation update. An `insert_before` payload containing only an echo line will duplicate the anchor instead of erroring out.</comment>
<file context>
@@ -57,7 +57,7 @@ export function restoreLeadingIndent(templateLine: string, line: string): string
export function stripInsertAnchorEcho(anchorLine: string, newLines: string[]): string[] {
- if (newLines.length <= 1) return newLines
+ if (newLines.length === 0) return newLines
if (equalsIgnoringWhitespace(newLines[0], anchorLine)) {
return newLines.slice(1)
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
insert_beforeandinsert_betweenhashline edit operations with dual-anchor validation.>>>context output, add edit dedup/noop reporting, and support delete/rename edit modes in tool args.Verification
bun test src/tools/hashline-edit/edit-operations.test.ts src/tools/hashline-edit/validation.test.ts src/tools/hashline-edit/hash-computation.test.ts src/tools/hashline-edit/tools.test.tsbun run typecheckbun run buildSummary by cubic
Adds precise anchor insert modes with strict validation and improved mismatch context, plus consistent chunked hashline streaming. Reports dedup/no-op edits and supports file delete/rename.
Written for commit 7e68690. Summary will update on new commits.