### Local Development Setup for OpenSlimedit Source: https://context7.com/asidorenkocode/openslimedit/llms.txt Instructions for setting up OpenSlimedit locally using Bun and pointing OpenCode to the local source file for development and testing. ```bash # Clone and install dependencies git clone https://github.com/ASidorenkoCode/openslimedit.git cd openslimedit bun install # Point OpenCode at the local source file for testing # ~/.config/opencode/config.json { "plugins": { "openslimedit": { "module": "file:///absolute/path/to/openslimedit/src/index.ts" } } } # Verify the plugin is active by starting OpenCode and: # 1. Reading a file — path should appear relative, footer should be absent # 2. Running an edit with oldString="10-15" — should succeed without reproducing line content # 3. Checking that edit responses return "OK" instead of the full success message ``` -------------------------------- ### Install OpenSlimedit Plugin Source: https://context7.com/asidorenkocode/openslimedit/llms.txt Add the plugin entry to your .opencode/opencode.jsonc file. Using @latest ensures the newest version is always fetched automatically when OpenCode starts. ```jsonc // .opencode/opencode.jsonc { "plugin": ["openslimedit@latest"] } ``` -------------------------------- ### Clone and Install Project Dependencies Source: https://github.com/asidorenkocode/openslimedit/blob/master/CONTRIBUTING.md Use these commands to clone the repository and install project dependencies using Bun. ```bash git clone https://github.com/ASidorenkoCode/openhashline.git cd openhashline bun install ``` -------------------------------- ### Install OpenSlimedit Plugin Source: https://github.com/asidorenkocode/openslimedit/blob/master/README.md Add the 'openslimedit@latest' package to your OpenCode configuration file to enable the plugin. Ensure OpenCode is restarted for the changes to take effect. ```jsonc // .opencode/opencode.jsonc { "plugin": ["openslimedit@latest"] } ``` -------------------------------- ### Project Structure Overview Source: https://github.com/asidorenkocode/openslimedit/blob/master/CONTRIBUTING.md The project is structured with the main plugin logic located in a single file for simplicity. ```plaintext src/ └── index.ts # Entire plugin — hooks for read, edit, and system prompt ``` -------------------------------- ### Configure OpenCode Plugin Source: https://github.com/asidorenkocode/openslimedit/blob/master/CONTRIBUTING.md Add this configuration to your OpenCode config file to enable the local hashline plugin. Ensure the module path is absolute. ```json { "plugins": { "hashline": { "module": "file:///absolute/path/to/openhashline/src/index.ts" } } } ``` -------------------------------- ### Initialize OpenSlimedit Plugin Source: https://context7.com/asidorenkocode/openslimedit/llms.txt The default export is an async OpenCode Plugin factory function. It receives the working directory from OpenCode and returns an object containing three hook handlers. ```typescript import type { Plugin } from "@opencode-ai/plugin" import OpenSlimeditPlugin from "openslimedit" // OpenCode calls this factory with the current working directory const hooks = await OpenSlimeditPlugin({ directory: "/home/user/myproject" }) // hooks is an object with three registered hook handlers: // { // "tool.definition": ..., // "tool.execute.after": ..., // "tool.execute.before": ... // } ``` -------------------------------- ### Tool Description Compression Map Source: https://context7.com/asidorenkocode/openslimedit/llms.txt This map shows the replacement descriptions applied by the 'tool.definition' hook for the nine most-used tools. This delivers the largest per-step token savings. ```typescript // Internal SLIM map — shows the replacement descriptions applied const SLIM: Record = { read: "Read file content.", edit: "Edit file. oldString can be line range '55-64'.", apply_patch: "Apply a patch to files.", write: "Write file.", bash: "Run shell command.", glob: "Find files.", grep: "Search in files.", list: "List directory.", fetch: "Fetch URL." } // Hook signature (called by OpenCode for each tool schema resolution): // input.toolID — the tool being described (e.g., "read", "edit") // output.description — the description field OpenCode will forward to the LLM // Example: before hook runs // output.description = "Reads the content of a file at the given absolute path. // Use this to inspect the contents of existing files. Returns file content..." // (hundreds of tokens) // After hook runs for toolID "read": // output.description = "Read file content." (4 tokens) ``` -------------------------------- ### Compact Read & Edit Output Source: https://context7.com/asidorenkocode/openslimedit/llms.txt This hook fires after a tool has finished executing. For 'read' operations, it shortens file paths and removes footers. For 'edit' operations, it replaces the full success message with 'OK'. ```typescript // --- Edit output compression --- // Before: "Edit applied successfully. Here is the updated content of the file: ..." // After: "OK" // --- Read output transformation --- // Before (raw OpenCode read output): // /home/user/myproject/src/utils/parser.ts // file // function parse(input: string) { ... } // // (End of file - total 42 lines) // After (OpenSlimedit processed): // src/utils/parser.ts // function parse(input: string) { ... } // (trailing newline only, footer removed) // The hook does NOT modify directory listings: // if (output.output.includes("directory")) return // skipped ``` -------------------------------- ### Line-Range Edit Expansion Hook Source: https://context7.com/asidorenkocode/openslimedit/llms.txt This hook fires before an edit tool call. If the oldString argument is a line-range expression and not literally present in the file, the hook expands it to the actual content of those lines. Expansion is skipped if oldString already exists literally in the file or if line numbers are out of bounds. ```typescript // LINE_RANGE_RE matches: "55-64", "42", "10 - 20" (whitespace-tolerant) const LINE_RANGE_RE = /^(\d+)(?:\s*-\s*(\d+))?$/ // Example: LLM emits this edit call const editArgs = { filePath: "src/server.ts", oldString: "55-64", // line range shorthand newString: " // refactored block\n return handler(req, res)\n", } // Hook resolves the file and expands oldString: // lines 55–64 of src/server.ts: // " const result = await db.query(sql)\n" + // " if (!result) {\n" // " throw new Error('not found')\n" // " }\n" // ... (10 lines total) // After expansion, editArgs becomes: // { // filePath: "src/server.ts", // oldString: " const result = await db.query(sql)\n if (!result) {\n throw new Error('not found')\n }\n...", // newString: " // refactored block\n return handler(req, res)\n" // } // Guard: if oldString already exists literally in the file, expansion is skipped // Guard: if line numbers are out of bounds, expansion is skipped (no-op) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.