This repository contains a simple Node.js tool for toggling OhMyOpenCode plugin status.
Note: This project has no build step. It's a pure Node.js script.
Tests are manual integration checks via CI. Run locally:
# Setup test config
cp config.example.json opencode.json
# Test all commands
node omo-toggle/omo-toggle.js status
node omo-toggle/omo-toggle.js off
node omo-toggle/omo-toggle.js on
# Or use the convenience script (after installation)
cd %USERPROFILE%\.config\opencode
omo status
omo off
omo onTest via CI:
# GitHub Actions workflow (automated)
./.github/workflows/ci.yml
# Tests on Node.js 16.x, 18.x, 20.x# Direct execution
node omo-toggle/omo-toggle.js [command]
# After installation
odo [command]
opo [command]
# Valid commands: on, off, enable, disable, statusLanguage: CommonJS (not ESM modules)
Imports:
- Use
require()for built-in modules only - No external dependencies
- Import order: built-ins first (fs, path, etc.)
// ✅ Correct
const fs = require('fs');
const path = require('path');Indentation:
- 4 spaces (no tabs)
Naming Conventions:
- Variables: camelCase (
configText,configPath) - Files: kebab-case (
omo-toggle.js)
Error Handling:
- Use try-catch blocks for file operations
- Console.error for error messages
process.exit(1)on fatal errors
try {
configText = fs.readFileSync(configPath, 'utf8');
} catch (error) {
console.error('无法读取配置文件:', error.message);
process.exit(1);
}Comments & Messages:
- Use Chinese for user-facing messages
- Use English for inline code comments (mixed codebase)
- Include emoji for status messages: ✅ ❌
// 获取命令行参数
const command = process.argv[2];
console.log('✅ OhMyOpenCode 已启用');
console.error('无法读取配置文件:', error.message);Project Structure:
/omo-toggle/- Core tool directoryomo-toggle.js- Main logicomo.bat- Windows batch wrapper
/- Root directoryomo.bat- Installation shortcutinstall.bat- Windows installerconfig.example.json- Config templateREADME.md- Chinese documentation
Script Entry Point:
- Shebang:
#!/usr/bin/env node - CLI args:
process.argv[2]for commands - Exit codes: 0 for success, 1 for errors
Target Config File: opencode.json (not in repo)
- Location: Parent directory of script
- Modified in-place for enable/disable toggling
No Build Tools:
- No package.json
- No dependencies
- No TypeScript
- No linting config
Style:
- Use
@echo off(silent execution) - SET variables for paths
- XCOPY for directory copy
- COPY for file copy
>nulto suppress copy output- Error handling with
errorlevel
@echo off
setlocal enabledelayedexpansion
set TARGET_DIR=%USERPROFILE%\.config\opencodeCore Logic:
- Plugin enabled when
"oh-my-opencode"appears in config - Plugin disabled when
"oh-my-opencode"appears commented (//prefix) - Simple string replacement: removes/adds
//prefix - Status check: searches for unquoted plugin string
Critical Paths:
- Config path:
path.join(__dirname, '..', 'opencode.json') - This assumes the script runs from
omo-toggle/subdirectory
Platform Support:
- Primary: Windows (batch scripts)
- Cross-platform: Node.js script runs anywhere
No Testing Framework:
- Manual testing only
- CI runs direct Node.js commands (no test harness)