This repository contains 3 custom AI-native tools built for OpenCode and adaptable to other coding CLIs that support custom TypeScript/JavaScript tools:
smart_edit— universal file creation/edit/delete toolsmart_grep— fast code/content search toolsmart_glob— fast file discovery tool
These tools are designed to replace fragmented default workflows like edit + write + glob + grep with faster, more AI-friendly alternatives.
.
├─ opencode.png
├─ smart-edit/
│ ├─ README.md
│ └─ smart_edit.ts
├─ smart-grep/
│ ├─ README.md
│ └─ smart_grep.ts
└─ smart-glob/
├─ README.md
└─ smart_glob.ts
Purpose: one tool for almost all file write operations.
What it does well:
- Creates files and directories
- Edits existing files with exact replacements
- Supports multiple edits in one file
- Supports batch edits across many files
- Inserts content before/after anchors
- Inserts content at line / line+column
- Safe delete via trash instead of permanent removal
- Gives rich error messages when replacement fails
Best use cases:
- Refactors across multiple files
- AI agents updating imports/usages
- Creating scaffolding files/folders
- Safer cleanup operations
Dependencies used by the tool:
@opencode-ai/plugindifftrash- Node built-ins:
fs,path
Why it is valuable: It merges several operations into one API, which reduces tool-selection mistakes for AI agents and speeds up multi-file work.
Purpose: search inside files with AI-friendly output.
What it does well:
- Supports single-pattern and batch-pattern searches
- Works with literal or regex matching
- Shows line and column positions
- Supports include/exclude filters
- Can return context lines around matches
- Handles large files more safely
- Produces grouped output by file
Best use cases:
- Finding code patterns before refactoring
- Searching TODO/FIXME/HACK markers
- Locating functions, imports, hooks, classes, selectors
- Debugging across large repositories
Dependencies used by the tool:
@opencode-ai/plugin- Node built-ins:
fs,path
Why it is valuable: It is much easier for agents to consume than raw grep output and reduces failures caused by regex/literal confusion.
Purpose: discover files and folders quickly.
What it does well:
- Fast recursive file matching
- Supports size/date/depth filters
- Supports hidden files and directory-only mode
- Multiple output modes: rich, compact, json
- Good for structured project discovery
- Works cross-platform
Best use cases:
- Finding files by extension or pattern
- Limiting searches by folder depth or date
- Project indexing for AI agents
- Directory discovery in large repos
Dependencies used by the tool:
@opencode-ai/plugin- Node built-ins:
fs,path
Why it is valuable: It gives more control and cleaner output than plain globbing, especially in large monorepos.
These tools are best suited for:
- OpenCode
- Other AI coding CLIs that support:
- custom tools/plugins
- TypeScript or JavaScript runtime loading
- JSON-schema-style tool arguments
If another CLI does not use the OpenCode plugin API directly, the code may need a light wrapper because these files currently import:
import { tool } from "@opencode-ai/plugin"So the tools are OpenCode-ready first, and portable second.
OpenCode is an AI coding agent/CLI that supports custom tools, agents, skills, and project rules.
Official docs and install entrypoint:
Common install options:
curl -fsSL https://opencode.ai/install | bashnpm install -g opencode-aipnpm add -g opencode-aiyarn global add opencode-aibun install -g opencode-aibrew install anomalyco/tap/opencodechoco install opencodescoop install opencodedocker run -it --rm ghcr.io/anomalyco/opencodeYou need a JavaScript runtime and package manager.
- Node.js 20+
- npm (comes with Node.js)
Download Node.js:
Check versions:
node -v
npm -vOptional alternatives:
- Bun: https://bun.sh/
- pnpm: https://pnpm.io/
- Yarn: https://yarnpkg.com/
Choose one method above, then verify:
opencode --versionIf the command is not found, restart the terminal after install.
Typical locations:
%USERPROFILE%\.config\opencode\
~/.config/opencode/
Important subfolders:
~/.config/opencode/
├─ opencode.json
├─ AGENTS.md
├─ tools/
├─ agents/
├─ commands/
└─ skill/
If tools/ does not exist, create it.
Because the tool files use imports, install their modules in the same environment where OpenCode resolves custom tools.
npm install @opencode-ai/plugin diff trashIf you want them installed globally too:
npm install -g @opencode-ai/plugin diff trash@opencode-ai/plugin→ required by all 3 toolsdiff→ required bysmart_edittrash→ required bysmart_editfor safe delete
No extra install needed for:
fsfs/promisespath
Copy the tool source files into your OpenCode tools folder.
Copy-Item .\smart-edit\smart_edit.ts "$HOME/.config/opencode/tools/"
Copy-Item .\smart-grep\smart_grep.ts "$HOME/.config/opencode/tools/"
Copy-Item .\smart-glob\smart_glob.ts "$HOME/.config/opencode/tools/"cp ./smart-edit/smart_edit.ts ~/.config/opencode/tools/
cp ./smart-grep/smart_grep.ts ~/.config/opencode/tools/
cp ./smart-glob/smart_glob.ts ~/.config/opencode/tools/Open or create:
~/.config/opencode/opencode.json
Recommended config:
This enables the smart tools and disables the older overlapping ones.
In your project AGENTS.md or global ~/.config/opencode/AGENTS.md, add something like:
## Tool Rules
- Always use `smart_edit` for file creation and edits
- Always use `smart_grep` for content search
- Always use `smart_glob` for file discovery
- Do not use legacy `edit`, `write`, `grep`, or `glob`This makes the behavior more consistent.
Restart the CLI/app after copying tools and updating config.
Example prompts inside OpenCode:
- “Find all TypeScript files in src using smart_glob”
- “List top-level folders using smart_glob”
- “Search for useEffect in all TSX files using smart_grep”
- “Find TODO, FIXME and HACK in one batch search”
- “Create docs/test.md with a hello heading using smart_edit”
- “Replace old function name with new function name in app.ts using smart_edit”
npm install -g opencode-ainpm install @opencode-ai/plugin diff trashmkdir -p ~/.config/opencode/toolscp ./smart-edit/smart_edit.ts ~/.config/opencode/tools/
cp ./smart-grep/smart_grep.ts ~/.config/opencode/tools/
cp ./smart-glob/smart_glob.ts ~/.config/opencode/tools/{
"$schema": "https://opencode.ai/config.json",
"tools": {
"smart_edit": true,
"smart_grep": true,
"smart_glob": true,
"edit": false,
"write": false,
"grep": false,
"glob": false
}
}opencodeIf you want to use these in another CLI:
- Check whether it supports custom JS/TS tools.
- Check whether it supports OpenCode plugin format directly.
- If not, wrap the tool entrypoint to match that CLI’s tool registration format.
- Install the same npm dependencies:
npm install @opencode-ai/plugin diff trashsmart_grepandsmart_globare easier to adaptsmart_editmay need extra care because of file writes, diff previews, and trash behavior
- Strongest tool in the set
- Best for AI reliability
- Could later benefit from regex replace mode
- Very useful for batch search
- Excellent for AI parsing because results are structured by file and pattern
- Good discovery features
- Particularly useful in big codebases where default globbing is too noisy
This tool trio works best together:
smart_glob→ find filessmart_grep→ inspect contentsmart_edit→ modify safely
That makes them a solid replacement stack for default coding-agent file operations.
- Ensure the
.tsfile is inside~/.config/opencode/tools/ - Ensure the tool is enabled in
opencode.json - Restart OpenCode
Run:
npm install @opencode-ai/plugin diff trash- Check OS permissions
- Update Node.js
- Reinstall dependencies
- Reopen terminal
- Verify global install path
- Run
opencode --version
Each tool folder already has its own README, but you may also want to add:
- exact npm dependency list
- sample prompts
- known limitations
- compatibility notes for non-OpenCode CLIs
If you are using OpenCode, this repository gives you a practical high-value smart tool stack:
- smart_edit for writing/changing files
- smart_grep for searching code/content
- smart_glob for discovering files/folders
For OpenCode, the install path is straightforward:
- Install OpenCode
- Install Node dependencies
- Copy tool files into
~/.config/opencode/tools/ - Enable them in
opencode.json - Restart OpenCode
If you want, I can also create:
- a package.json for this repo
- a ready-to-copy opencode.json
- or update each individual tool README with the same detailed install guide

{ "$schema": "https://opencode.ai/config.json", "tools": { "smart_edit": true, "smart_grep": true, "smart_glob": true, "edit": false, "write": false, "grep": false, "glob": false } }