diff --git a/skills/0-editor/README.md b/skills/0-editor/README.md new file mode 100644 index 00000000..0d04af18 --- /dev/null +++ b/skills/0-editor/README.md @@ -0,0 +1,65 @@ +
+

🦞 0-editor 🦞

+

The First File Editor Built for the Latent Space.

+ +

+ License: MIT + Built with 0-lang + Agent Ready +

+
+ +--- + +## 🚨 The Agentic Editing Crisis + +Why do 80% of your AI Agent's autonomous code edits fail silently? +Because you are forcing a neural network to count spaces. + +Current agent harnesses (OpenClaw, Cursor, Claude Code, Aider) often rely on **exact-match string replacement**. If an LLM hallucinates a single tab instead of 4 spaces, or misses a trailing newline, the edit is completely aborted. **You are throttling your agent's autonomy with 1970s Regex.** + +## 🌟 The Paradigm Shift: `0-editor` + +**Stop treating agents like dumb text parsers.** `0-editor` is a next-generation, heuristic-driven, AST-aware fuzzy matching engine written entirely in `0-lang`. + +It understands *intent*. It aligns unified diffs and approximate code blocks to the source file by ignoring formatting drifts, indentation errors, and whitespace hallucinations. + +- **🧠 Forgive & Forget**: Hallucinated an extra newline? Used spaces instead of tabs? `0-editor` doesn't care. It finds the semantic block and patches it perfectly. +- **⚡ Drop-in Replacement**: Plugs directly into any agentic workflow. Just give it the target file, the old hallucinated block, and the new block. +- **🔒 100% Native**: Built natively in `0-lang` for ultimate performance, determinism, and security in decentralized agent networks. +- **🛠️ Multi-Ecosystem**: Provides robust Python (`0_editor.py`) and Rust (`0-editor-rs`) native implementations for drop-in use anywhere. + +## 🚀 Quick Start + +If your Agent is complaining about "Code not found in file", drop this in your harness: + +**For 0-lang Environments:** +```bash +0-run src/main.0 main.js diff_old.txt diff_new.txt +``` + +**For Python Environments:** +```bash +chmod +x python/0_editor.py +./python/0_editor.py main.js diff_old.txt diff_new.txt +``` + +**For Rust/Native Environments:** +```bash +cd rust && cargo build --release +./target/release/0-editor main.js diff_old.txt diff_new.txt +``` + +> **Success: File modified intelligently via 0-editor AST/Fuzzy engine.** + +### OpenClaw Integration +`0-editor` provides a first-class AgentSkill for [OpenClaw](https://github.com/openclaw/openclaw). +To make your OpenClaw agent natively use fuzzy editing instead of the fragile built-in `edit` tool, copy the skill: + +```bash +mkdir -p ~/.openclaw/skills/0-editor +cp openclaw-skill/SKILL.md ~/.openclaw/skills/0-editor/SKILL.md +``` + +No more counting brackets. No more regex parsing. Let your LLMs write code, and let `0-editor` handle the AST injection. + diff --git a/skills/0-editor/SKILL.md b/skills/0-editor/SKILL.md new file mode 100644 index 00000000..6adb9ebf --- /dev/null +++ b/skills/0-editor/SKILL.md @@ -0,0 +1,36 @@ +--- +name: 0-editor +description: A robust, native file editing skill for OpenClaw that uses fuzzy AST/line matching instead of exact string replacement. Use this skill whenever you need to edit source code files to avoid whitespace and indentation matching errors. +--- + +# 0-editor: Agent-Native File Editing + +Do NOT use the built-in `edit` tool for modifying blocks of code. The native `edit` tool requires exact string matches, meaning any hallucinated space, tab, or newline will cause your edit to fail. + +Instead, use `0-editor` which aligns your edits semantically. + +## Usage Instructions + +When you need to modify a file: + +1. Write the code you want to replace into a temporary file: + `write /tmp/old.txt` +2. Write the new code into another temporary file: + `write /tmp/new.txt` +3. Run the `0-editor` CLI via the `exec` tool: + `exec 0-editor /tmp/old.txt /tmp/new.txt` + +## Example Tool Call + +```json +// 1. Write the old block +{"call": "default_api:write", "args": {"file_path": "/tmp/old.txt", "content": "function add(a, b) {\n return a + b;\n}"}} + +// 2. Write the new block +{"call": "default_api:write", "args": {"file_path": "/tmp/new.txt", "content": "function add(a, b, c=0) {\n return a + b + c;\n}"}} + +// 3. Execute 0-editor +{"call": "default_api:exec", "args": {"command": "0-editor /workspace/math.js /tmp/old.txt /tmp/new.txt"}} +``` + +`0-editor` will intelligently ignore indentation and whitespace drifts, locate the old block in `math.js`, and replace it with your new block perfectly.