@jialanhu/character-counter
v0.1.3
Published
Character counting plugin for opencode - intercepts write tool and returns character statistics
Maintainers
Readme
中文版本: README_zh-CN.md
Chinese Character Counter Plugin
A plugin for opencode that counts and categorizes characters in text, displaying statistics in a <system-reminder> tag after write tool execution.
Features
- Multi-category counting: Chinese, English, Numbers, Punctuation, Spaces
- JSON output: Results displayed in
<system-reminder>tag for LLM reference - Toggle support: Can be enabled/disabled via configuration
- CLI adaptor interface: Ready for extension to other CLI tools
Installation
via npm (Recommended)
npm install @jialanhu/character-counterThen add to opencode.json:
{
"plugins": {
"paths": ["./node_modules/@jialanhu/character-counter"]
}
}Manual Installation
- Copy the plugin files to your opencode plugins directory:
# Create plugins directory if not exists
mkdir -p ~/.opencode/plugins/character-counter
# Copy source files
cp -r src/* ~/.opencode/plugins/character-counter/- Configure opencode to load the plugin in
opencode.json:
{
"plugins": {
"paths": ["~/.opencode/plugins/character-counter"]
}
}Usage
After installation, the plugin automatically activates. When you use the write tool, character statistics will be displayed in a <system-reminder> tag:
<system-reminder>
{
"charCount": {
"total": 100,
"chinese": 50,
"english": 30,
"number": 10,
"punctuation": 5,
"space": 5,
"time": "2024-01-01T12:00:00.000Z"
}
}
</system-reminder>Demo Tool
Test the counter directly:
/character_counter_demoEnter any text to see character statistics.
Project Structure
├── src/
│ ├── index.ts # Plugin entry
│ ├── core/
│ │ ├── counter.ts # Counting engine
│ │ └── types.ts # Type definitions
│ └── adaptors/
│ ├── base.ts # Adaptor interface
│ └── cli.ts # CLI adaptor
├── tests/
│ └── counter.test.ts # Unit tests
└── LICENSEDevelopment
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run buildLicense
MIT
