[PR #13405] feat(hashline): add hashline edit tool with experimental flags #14649

Open
opened 2026-02-16 18:19:25 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13405

State: open
Merged: No


Summary

Adds an experimental hashline edit mode for line-anchored edits with stale-anchor protection, and wires it through tool selection + CLI/TUI surfaces.

  • hashline mode now ships through the existing edit tool ID (not a separate hashline tool), with schema switching when enabled
  • adds hashline operations (set_line, replace_lines, insert_after, replace) and mismatch remap diagnostics
  • enables hashline-gated edit behavior via OPENCODE_EXPERIMENTAL_HASHLINE / OPENCODE_EXPERIMENTAL_EDIT
  • keeps GPT behavior aligned with existing apply_patch flow
  • updates read output to emit LINE:HASH|content when hashline mode is enabled
  • extends tests for tool selection and replace behavior (all: true, no-op replace rejection)

Verification

  • bun test test/tool/hashline-mode-selection.test.ts test/tool/hashline.test.ts
  • bun run typecheck
  • bun run build
  • pre-push typecheck hook passed

Sources used for hashline implementation

  • Internal implementation references:
    • packages/opencode/src/tool/hashline.ts
    • packages/opencode/src/tool/registry.ts
    • packages/opencode/src/tool/read.ts
    • packages/opencode/src/flag/flag.ts
    • packages/opencode/src/cli/cmd/run.ts
    • packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
  • Internal test references:
    • packages/opencode/test/tool/hashline.test.ts
    • packages/opencode/test/tool/hashline-mode-selection.test.ts

Fixes #13393

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13405 **State:** open **Merged:** No --- ## Summary Adds an experimental hashline edit mode for line-anchored edits with stale-anchor protection, and wires it through tool selection + CLI/TUI surfaces. - hashline mode now ships through the existing `edit` tool ID (not a separate `hashline` tool), with schema switching when enabled - adds `hashline` operations (`set_line`, `replace_lines`, `insert_after`, `replace`) and mismatch remap diagnostics - enables hashline-gated edit behavior via `OPENCODE_EXPERIMENTAL_HASHLINE` / `OPENCODE_EXPERIMENTAL_EDIT` - keeps GPT behavior aligned with existing `apply_patch` flow - updates read output to emit `LINE:HASH|content` when hashline mode is enabled - extends tests for tool selection and replace behavior (`all: true`, no-op replace rejection) ## Verification - [x] `bun test test/tool/hashline-mode-selection.test.ts test/tool/hashline.test.ts` - [x] `bun run typecheck` - [x] `bun run build` - [x] pre-push typecheck hook passed ## Sources used for hashline implementation - Internal implementation references: - `packages/opencode/src/tool/hashline.ts` - `packages/opencode/src/tool/registry.ts` - `packages/opencode/src/tool/read.ts` - `packages/opencode/src/flag/flag.ts` - `packages/opencode/src/cli/cmd/run.ts` - `packages/opencode/src/cli/cmd/tui/routes/session/index.tsx` - Internal test references: - `packages/opencode/test/tool/hashline.test.ts` - `packages/opencode/test/tool/hashline-mode-selection.test.ts` Fixes #13393
yindo added the pull-request label 2026-02-16 18:19:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14649