← 全部工具

EkKorat/blamehash-cursor

热度 60 更新于 效率与自动化

Stable File Editing with Content-Hashed Anchors 2026 – LineHash Repo Guide

githubauto-collected

安装

暂未验证可直接使用的安装命令,请查看项目官方文档或 Release。

ContentHash Editor: Immutable File Anchoring via Semantic Line Signatures for AI-Assisted Codebases

Zero-Fragility Editing for Large Language Model Workflows

Tired of your AI code assistant breaking your files with every regeneration? ContentHash Editor introduces a paradigm shift: instead of editing files by line numbers or string patterns, it uses cryptographic content hashes of individual lines as immutable anchors. This means Claude Code, Codex, and other AI tools can surgically modify your source files without accidentally corrupting adjacent code blocks.

2026 is the year of reliable AI-driven development. ContentHash Editor makes it possible.

---

🧬 Mermaid Diagram: How ContentHash Anchoring Works

flowchart TD
    A[User Request: "Edit function calculateTax"] --> B[AI Assistant generates edit instruction]
    B --> C[ContentHash Engine parses target file]
    C --> D[Computes SHA-256 hash for each line]
    D --> E{Matches anchor hash?}
    E -->|Yes| F[Locates exact line to modify]
    E -->|No| G[Returns nearest context match]
    F --> H[Applies mutation only to anchored line]
    G --> I[Fuzzy fallback with similarity threshold > 95%]
    H --> J[Recomputes hashes for affected block]
    I --> J
    J --> K[Output: Valid file with no collateral damage]

---

## 🚀 The Fragility Problem That ContentHash Editor Solves

Traditional AI code editing relies on two broken models:

1. **Line-number addressing** - Works only if file structure never changes. One added comment shifts everything.
2. **String/regex replacement** - Accidentally matches wrong instances or damages formatting.

**ContentHash Editor** uses each line's unique digital fingerprint as its address. A line that says `def calculate_tax(income):` has a specific hash like `a3f8b2c1`. That hash stays constant regardless of what happens above or below it. Even if the entire file is reformatted, the anchor remains valid.

Imagine a 500-line Python file where an AI assistant needs to change line 142. One hundred lines of new code have been added above it since the last session. Traditional tools would target the wrong block entirely. ContentHash Editor? It finds the exact line by its semantic hash – every single time.

---

🎯 Example Profile Configuration

Create a .contenthash.yml file in your project root to define editing behavior:

version: "2026.1"
project:
  name: "e-commerce-migration"
  language: "python"
  ai_assistants:
    - claude_code: { enabled: true, anchor_mode: "strict" }
    - openai_codex: { enabled: true, anchor_mode: "fuzzy" }
  anchoring:
    default_algorithm: "sha256"
    fallback_strategy: "nearest_neighbor"
    similarity_threshold: 0.95
  protected_patterns:
  • "class definitions"
  • "decorators"

ignore:

  • "generated/"
  • "vendor/"

hooks: preedit: "runlinter.sh" postedit: "runtests.sh"


### Configuration Parameters Explained

| Parameter | Type | Purpose |
|-----------|------|---------|
| `anchor_mode` | string | `strict` requires exact hash match; `fuzzy` allows context-based fallback |
| `similarity_threshold` | float | Minimum hash similarity percentage for fuzzy matching |
| `protected_patterns` | list | Line categories that cannot be modified without explicit override |
| `hooks` | object | Shell commands executed before/after every edit operation |

---