Generated: 2026-01-15T11:49:40Z
TypeScript OpenCode plugin that replaces case-insensitive opencode text with a configurable value (default: Renamer) across chat messages, system prompts, tool outputs, and session titles. It excludes URLs, file paths, and code blocks from replacement.
Package Manager: Bun
OpenCode is an AI-powered development environment that provides a plugin system for extending functionality. Key concepts:
- Plugin System: OpenCode plugins are TypeScript/JavaScript modules that export a plugin function
- Plugin Function: Receives
{ client, directory, worktree }and returns an object with hook handlers - Hooks: Lifecycle events and transformation points where plugins can intercept and modify behavior
- Configuration: Plugins can read from:
- Project config:
.opencode/plugin-name-config.jsonoropencode.json - Global config:
~/.config/opencode/plugin-name-config.json - Environment variables
- Project config:
- Client API: Provides access to OpenCode services (e.g.,
client.session.update()) - Plugin Directory: Plugins can be installed:
- Locally:
.opencode/plugin/plugin-name.js - Via npm/bun: Listed in
opencode.jsonoropencode.jsoncconfig file
- Locally:
- Event Hooks: React to file system events, session updates, etc.
- Transform Hooks: Modify content as it flows through the system:
chat.message- Transform chat message outputsexperimental.chat.system.transform- Transform system promptsexperimental.chat.messages.transform- Transform message historyexperimental.text.complete- Transform text completionstool.execute.after- Transform tool execution results
./
├── src/index.ts # Plugin implementation + text transform helpers
├── package.json # Publishable npm package metadata (ESM)
├── tsconfig.json # TypeScript compiler config (build → dist/)
├── biome.json # Biome formatter and linter configuration
├── bun.lock # Bun dependency lock file
└── README.md # Install + configuration docs
- Plugin entry/export:
src/index.ts - Replacement rules (skip URLs/paths/code):
src/index.ts - Config/env names and defaults:
src/index.ts - Publish setup (exports/prepack/files):
package.json
# Install deps
bun install
# Build (emits dist/)
bun run build
# Format code
bun run format
# Lint code
bun run lint
# Format and lint together
bun run check
# Pre-publish check (runs build via prepack)
bun pm pack --dry-run
# Publish
bun publishNote: This project uses Bun as the package manager. All commands should use bun instead of npm. Use bun pm pack --dry-run for publish checks.
- Biome is configured for formatting and linting (see
biome.json) - Configuration: 2-space indentation, double quotes, import organization enabled
bun run format- Format code with Biomebun run lint- Lint code with Biomebun run check- Format and lint in one command- Biome automatically respects
.gitignoreand excludesdist/directory
- No test runner configured.
- Single-test execution: not applicable until tests are added.
- Uses
release-pleasevia.github/workflows/release-please.yml. - Config files:
release-please-config.json,.release-please-manifest.json. - Publishes to npm automatically on release creation (requires
NPM_TOKENsecret). - Manual publish workflow retained as
workflow_dispatchin.github/workflows/publish.yml.
- Keep changes small and focused; avoid refactors in bugfixes.
- Do not add heavyweight dependencies; this is a lightweight plugin.
- Preserve behavior that skips URLs/paths/code when replacing text.
- Use ESM imports only (
type:module). - Prefer
import typefor type-only imports (seesrc/index.ts). - Node core imports should be explicit (
node:fs/promises,node:path,node:os).
- Biome is used for code formatting (configured in
biome.json) - TypeScript code is formatted with 2-space indentation
- Double quotes for strings (configured in Biome)
- Keep function signatures and chained calls readable; break long lines
- Use trailing commas in multiline parameter lists and object literals
- Run
bun run formatorbun run checkbefore committing
- Prefer explicit types for config and state objects (e.g.,
ReplaceConfig,ReplaceState). - Use
Partial<T>for config overrides and merge explicitly. - Avoid
any,@ts-ignore, and@ts-expect-error.
- Constants in
SCREAMING_SNAKE_CASEfor env vars and regex names. - Use descriptive function names for transforms (e.g.,
replaceInText). - Boolean helpers should be predicate-style (
shouldReloadConfig).
- File reads should be resilient: treat missing/invalid config as undefined.
- Do not throw on bad config; fall back to defaults.
- Avoid empty
catchblocks unless intentionally swallowing non-critical errors.
- Replacement is case-insensitive (
/opencode/gi). - Exclude URLs, file paths, inline code, and fenced code blocks.
- Do not replace inside URLs/paths/code; treat them as protected ranges.
This project follows Conventional Commits specification. All agents and Cursor must use Conventional Commits for every commit.
Commit Message Format:
<type>(<scope>): <subject>
<body>
<footer>
Required Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, missing semicolons, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasks (dependencies, build config, etc.)
Breaking Changes:
Use ! after the type/scope: feat!: change default replacement
Examples:
feat: add support for custom replacement patternsfix: exclude URLs from text replacementdocs: update installation instructionschore: update dependencies
Guidelines:
- Always use conventional commit format
- Keep subject line under 72 characters
- Use imperative mood ("add" not "added" or "adds")
- Reference issues/PRs in footer if applicable
- Global config:
~/.config/opencode/renamer-config.json - Project config:
.opencode/renamer-config.json - Env overrides:
OPENCODE_RENAMER_REPLACE_ENABLEDOPENCODE_RENAMER_REPLACE_TEXT
- Repository:
https://github.com/Sillybit-io/renamer-opencode-plugin.git - Package files:
dist/,README.md(configured inpackage.jsonfilesfield) - Build: Automatic via
prepackscript before publishing - Verification: Run
bun pm pack --dry-runto verify publish contents
- Package Manager: Bun (uses
bun.lockfor dependency locking, notpackage-lock.jsonoryarn.lock) - Plugin uses ESM (
type: "module"in package.json) - Requires Node.js >= 18 (or Bun runtime)
- No external dependencies except
@opencode-ai/plugin - Code formatting: Biome (configured in
biome.json, 2-space indentation, double quotes) - Commit conventions: Conventional Commits specification (see COMMIT CONVENTIONS section)
- Publish ready: Package includes description, repository, homepage, and bugs URLs
- No test framework configured (consider adding tests)
- Plugins are loaded from
.opencode/plugin/directory or via npm/bun registry - Configuration files follow pattern:
~/.config/opencode/(global) and.opencode/(project) - Plugin hooks are called asynchronously and can modify outputs in-place
- The
clientobject provides access to OpenCode APIs for session management, file operations, etc.