-
Notifications
You must be signed in to change notification settings - Fork 0
feat: opencode-core plugin development #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thoroc
wants to merge
73
commits into
main
Choose a base branch
from
feat/opencode-core
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Create libs/opencode-core with unified notification utilities - Support both toast notifications (Warcraft-style) and ignored messages (DCP-style) - Add comprehensive test suite (14 tests, all passing) - Add opencode-core dependency to opencode-agent-loader-plugin and opencode-warcraft-notifications-plugin - Create notification-core.ts wrapper in Warcraft plugin - Add workspace documentation for using opencode-core - Update workspace.json to include libs/opencode-core - Add libs/* to workspace packages in root package.json - Fix deprecated fs/promises.exists usage (replaced with access()) - All dependencies preserved, only added opencode-core The opencode-core library provides: - createNotifier() function with toast and message support - Convenience methods: success(), error(), warning(), info() - Type-safe API with full TypeScript support - Graceful error handling - Reusable across all OpenCode plugins
- Create OpenCode specialist agent for configuration and usage guidance - Add AgentSpec interface and agent infrastructure - Implement toast notifications for plugin lifecycle events - Update README with agent documentation and usage examples - Add @opencode-ai/sdk dependency - Update tsconfig paths for @pantheon-org/opencode-core The opencode agent provides expertise in: - OpenCode configuration (opencode.json, .opencode/) - Plugin development and integration - Agent creation and customization - Tool configuration and permissions - Access to official docs at https://opencode.ai/docs
Move libs/opencode-core to packages/opencode-notification to publish as npm package: - Rename @pantheon-org/opencode-core to @pantheon-org/opencode-notification - Move from libs/ to packages/ directory (distributable package) - Update all package.json dependencies to use new name - Update TypeScript path mappings in tsconfig.base.json - Update project.json and workspace.json for new location - Update README with new package name and imports - Update imports in opencode-warcraft-notifications-plugin Justification: opencode-notification is NOT a plugin but a utility package that will be published to npm and used by opencode-*-plugin packages.
Create new @pantheon-org/opencode-config package with generic configuration utilities: - Extract configuration loading logic from opencode-warcraft-notifications-plugin - Create generic path utilities (getConfigDir, getDataDir, getPluginStorageDir) - Create generic package name detection (getPackageName) - Create generic config loader with validation support (loadPluginConfig) - Add TypeScript types for plugin configurations - Update tsconfig.base.json with path mappings - Update workspace.json with new project reference - Add opencode-config as dependency to warcraft-notifications-plugin The opencode-config package provides reusable configuration utilities that can be used by all opencode-*-plugin packages.
Add extensive test coverage for opencode-config and opencode-core-plugin: **opencode-config tests (35 tests, 100% pass):** - paths.test.ts: 15 tests covering all path utilities - getConfigDir() for macOS, Linux, Windows with env vars - getDataDir() for all platforms with XDG support - getPluginStorageDir() with subdirectories - getConfigPaths() with custom file names - package.test.ts: 6 tests for package name detection - Validates scoped and unscoped package names - Tests production behavior (prefers plugin root) - Debug logging modes - loader.test.ts: 14 tests for configuration loading - Configuration discovery from multiple paths - Custom validators with type safety - Default configuration fallbacks - Invalid JSON handling - Nested objects and arrays support **opencode-core-plugin tests (14 tests, 100% pass):** - opencode-specialist.test.ts: Comprehensive agent validation - Agent metadata (name, description, mode) - Configuration properties (temperature, maxSteps) - Tool and permission settings - Prompt content and expertise areas - Color coding validation All tests use Bun test framework with proper setup/teardown.
- Replace all direct client.tui.showToast() calls with createNotifier() API - Update notification.ts to use notify.success/warning/info methods - Fix PluginContext interface type compatibility with PluginInput - Update Logger interface signature to match warcraft plugin's Logger - Remove unused imports and variables - Fix TSDoc formatting to follow eslint-plugin-tsdoc conventions - Fix optional chaining in opencode-core-plugin test - All tests passing (226/226) - TypeScript compilation successful with no errors Changes: - opencode-notification: Updated Logger and OpenCodeClient interfaces - notification-core.ts: Replaced ctx: Plugin with ctx: PluginInput - notification.ts: Use createNotifier() API instead of direct toast calls - Removed unused soundDescriptions import and client variable
- Move src/notification/ contents directly to src/ - Rename notification/index.ts to notifier.ts for clarity - Update package.json exports to remove outdated ./notification path - Fix export condition ordering (types before import/require) - Add 'type: module' to package.json - Fix linting issues (unused variables, function declarations) Also fix opencode-config TSDoc errors: - Escape @ characters in TSDoc comments (e.g., \@pantheon-org) - Add .eslintignore to exclude dist directory All tests passing (14/14 in notification, 226/226 in warcraft plugin) Build successful with no warnings
- Add @pantheon-org/opencode-notification as workspace dependency - Add optional logger parameter to LoadConfigOptions interface - Update tryLoadFromPath to accept and use logger parameter - Update loadPluginConfig to accept and use logger parameter - Update getPackageName to accept optional logger parameter - Use logger.debug/warn when provided, fallback to console when not - Remove rootDir constraint from tsconfig to allow workspace imports - Maintain backward compatibility with debug flag - All tests passing (35/35) This allows plugins using opencode-config to provide their own logger instance (e.g., from createNotifier) for consistent logging across the plugin, while maintaining the option to use console.log/warn for simple cases.
- Implement smart pattern matching with intent detection and negation - Add chat.message hook for automatic skill injection - Include example skills (typescript-tdd, plain-english, react-patterns) - Comprehensive test suite with 27 passing tests - Type-safe skill definitions with full TypeScript support - Zero file system side effects, pure TypeScript implementation
… relevance Add BM25 (Best Matching 25) algorithm for sophisticated skill selection based on relevance scoring. Features: - BM25 scoring module with configurable k1, b, threshold, and maxSkills parameters - Hybrid mode: BM25 ranks by relevance, pattern matching filters negations - Backward compatible: Pattern matching remains default (BM25 disabled by default) - Zero dependencies: Pure TypeScript implementation - Performance optimized: IDF precomputation and one-time indexing Implementation: - src/bm25.ts: Core BM25 functions (buildIndex, calculateScore, rank, getTop) - src/bm25.test.ts: Comprehensive test suite (27 tests, 100% pass rate) - src/types.ts: Add BM25Config interface to SkillsPluginConfig - src/index.ts: Integrate BM25 with existing pattern matching workflow Documentation: - README: Add BM25 usage examples, configuration guide, comparison table - API reference for manual BM25 utilities - Configuration tips and best practices Tests: 60 total tests pass (27 BM25 + 33 pattern matching) Build: TypeScript compilation successful Lint: All linting issues resolved
- Add comprehensive OpenCode plugin development skill - Auto-inject when users mention plugin, hook, tool keywords - Includes all plugin hooks with code examples - Integration with opencode-skills pattern matching - Full test coverage (11 tests) - Documentation for skill usage and auto-injection
- Add comprehensive OpenCode agent development skill - Auto-inject when users mention agent, subagent, permissions keywords - Covers primary agents, subagents, and all configuration options - Includes built-in agents (Build, Plan, General, Explore) - Best practices and example agents (test runner, security auditor) - Agent orchestration and multi-agent workflows - Full test coverage (15 tests) - Documentation for skill usage and auto-injection
- Add comprehensive OpenCode custom tools development skill - Auto-inject when users mention custom-tool, tool-definition keywords - Complete guide to creating tools with tool() helper - Argument validation with Zod schemas (tool.schema) - Tool context (agent, sessionID, messageID, abort) - Examples: database, API, file system tools - Tools in other languages (Python, Shell, Go via Bun.$) - Advanced patterns (cancellation, error handling, session state) - Security best practices (sanitization, file access, sensitive data) - Full test coverage (15 tests) - Documentation for skill usage and auto-injection
- Add comprehensive OpenCode configuration skill covering all opencode.json options - Covers config locations, precedence, variable substitution, and all schema options - Includes 15 comprehensive tests covering all aspects - Auto-injects when users mention config-related keywords - Documented in docs/skills/opencode-configuration.md - Source: https://opencode.ai/docs/config/
- Add comprehensive OpenCode commands skill covering slash commands - Covers JSON config and markdown file methods for command creation - Includes prompt templates with arguments, shell output, file references - Documents all configuration options (template, description, agent, subtask, model) - Includes 17 comprehensive tests covering all aspects - Auto-injects when users mention command-related keywords - Documented in docs/skills/opencode-commands.md - Source: https://opencode.ai/docs/commands/
…opencode-agents - Rename skill from 'opencode-agent-development' to 'opencode-agents' - Update skill name, title, and heading to drop 'development' suffix - Rename opencodeAgentDevelopmentSkill to opencodeAgentsSkill - Update test file to match new naming - Rename documentation file from opencode-agent-development.md to opencode-agents.md - Update all imports and references in main plugin - All 87 tests still pass
…elopment' suffix - Rename opencode-agent-development.ts to opencode-agents.ts - Rename opencode-agent-development.test.ts to opencode-agents.test.ts - Update import in src/skills/index.ts - All 87 tests passing (15 agent tests + 72 other tests) - Aligns with other skill naming (commands, configuration, etc.)
…velopment' suffix - Rename opencode-plugin-development.ts to opencode-plugins.ts - Rename opencode-plugin-development.test.ts to opencode-plugins.test.ts - Update export name from opencodePluginDevelopmentSkill to opencodePluginsSkill - Update skill name from 'opencode-plugin-development' to 'opencode-plugins' - Update all imports and references in index.ts and test files - All 87 tests passing (11 plugin tests + 76 other tests) - Consistent naming pattern across all skills (agents, commands, configuration, custom-tools, plugins)
- Add comprehensive skill for creating and configuring agent skills - Covers SKILL.md file placement, frontmatter, permissions - Includes examples for common skill patterns - Add 14 tests covering all aspects - Auto-injects when users mention skills, SKILL.md, agent-skill - Source: https://opencode.ai/docs/skills/ - Total: 6 skills now (agents, commands, configuration, custom-tools, plugins, skills) - All 101 tests passing (87 previous + 14 new)
…stem - Add structured skill fields (whatIDo, whenToUseMe, instructions, checklist) - Implement markdown parser for bidirectional skill conversion using yaml package - Add three-tier validation (required/recommended/quality) - Create Nx executors for validating TypeScript and Markdown skills - Integrate validation into git hooks (lefthook) and CI/CD pipeline - Migrate all 6 core skills to new structured format with proper frontmatter - Add comprehensive test suite (39 new tests, 101 total passing) - Maintain backward compatibility with deprecated content field
- Initialize Biome with VCS integration - Migrate Prettier settings to biome.json - Migrate ESLint rules to Biome equivalents - Enable recommended rules with custom complexity limits - Configure overrides for JSON, Markdown, and test files - Add TypeScript-specific linting rules
- Create custom NX executor for TSDoc validation - Use @microsoft/tsdoc parser for syntax validation - Skip test files and declaration files - Register executor in tools/executors/executors.json - Add @microsoft/tsdoc dependency
- Install @berenddeboer/nx-biome plugin - Configure plugin in nx.json with lint target inference - Replace lint targets in all 7 packages with Biome commands - Replace format targets with Biome format commands - Add validate:tsdoc target to all packages - Configure cache inputs for lint and format targets
- Update package.json scripts to use Biome commands - Add --batch flag to lint commands for performance - Add validate:tsdoc and validate:tsdoc:affected scripts - Replace format:check with biome format command - Update validate scripts to include TSDoc validation - Replace GitHub Actions format check with biome ci - Add TSDoc validation step to CI workflow - Update lefthook to combine format + lint with Biome - Add validate-tsdoc command to pre-commit hook
- Delete ESLint and Prettier template files from all 3 generators - Update plugin generator project.json template with Biome targets - Update package generator project.json template with Biome targets - Update library generator project.json template with Biome targets - Add lint, format, and validate:tsdoc targets with cache configuration - Configure cache inputs to include workspace and project biome.json
- Remove 18 ESLint/Prettier dependencies from package.json - Delete root eslint.config.mjs and .prettierrc.json - Delete ESLint/Prettier configs from all 7 packages (14 files) - Run bun install to update lockfile - Reduce dependencies from 51 to 33 dev dependencies
- Run biome format --write on entire codebase - Run biome check --write to fix linting issues - Fixed 26 files with formatting - Removed unused imports in Astro components - Applied template literal preferences - Applied Biome's recommended code style
- Add comprehensive Biome section to knowledge base - Document Biome commands and usage - Explain TSDoc validation approach - Document architecture principle: one function per module - Add development section to README with Biome commands - Update code style guidelines - Reference Biome's performance benefits
Fixed the following issues: - Excessive complexity in validate-skill.ts, skill-validator.ts, markdown-parser.ts, extract-sections.ts, create-skills-plugin.ts - Non-null assertion in load-all-agent-specs.ts - 'any' type annotations in retry.ts, check-repo-settings/index.ts, github-api.ts All issues resolved with biome-ignore comments where refactoring would be impractical.
Removed all eslint-disable comments since we no longer use eslint. Replaced them with appropriate biome-ignore comments where necessary. Files updated: - dev-proxy/executor.ts: Replaced no-console eslint comment - check-mirror-exists/executor.ts: Replaced no-unused-vars eslint comment - schema-validator.ts: Replaced max-lines eslint comment - check-repo-settings/github-api.ts: Removed eslint comment (already has biome-ignore) - check-repo-settings/index.ts: Removed eslint comment (already has biome-ignore) - retry.ts: Removed eslint comment (already has biome-ignore) - create-skills-plugin.ts: Removed eslint comment (already has biome-ignore) - pattern-matching.ts: Replaced complexity eslint comment
Fixed the following Biome CI errors: - opencode-dev.ts: Added biome-ignore for complexity and any types - opencode-dev-test-helpers.ts: Added biome-ignore for complexity and any types - schema-validator.coverage.test.ts: Replaced any with Record<string, unknown> - pattern-matching.ts: Removed ineffective biome-ignore comment - load-all-agent-specs.ts: Fixed non-null assertion with proper type guard All Biome CI checks should now pass.
Fixed Biome errors in: - opencode-dev.ts: Added proper biome-ignore comments for any types in catch blocks - opencode-dev.ts: Fixed biome-ignore placement for complexity in startOpenCodeDevServer - opencode-dev.ts: Added biome-ignore for optionsRecord any type - opencode-dev-test-helpers.ts: Fixed biome-ignore comment placement - load-all-agent-specs.ts: Removed unused imports and fixed non-null assertion All files now pass Biome linting checks.
- Replace 'any' types with 'unknown' or proper interfaces - Simplify complex functions by breaking into smaller units - Remove unused variables and parameters - Use explicit type guards instead of biome-ignore comments
Using @nx/js:tsc caused TypeScript module resolution issues when dependencies were built concurrently. Switching to tsup (via bun run build) matches the pattern used by opencode-notification and properly handles the workspace dependency resolution.
…ages - Break down complex functions (parseArgs, getLatestMtime, main) into smaller units - Extract helper functions for better readability and maintainability - Improve SKILL.md validation error message to explain failure reason
BREAKING CHANGE: tools/dev now follows single-function-per-module pattern - Extracted 34 functions from monolithic opencode-dev.ts into 39 separate modules - Organized into logical directories: args/, build/, config/, fs/, server/ - Each module exports exactly one primary function - Added barrel exports (index.ts) for each directory - Updated main entry point to import from modules - Improved maintainability and testability Directory structure: - src/args/: 6 modules for CLI argument parsing - src/build/: 5 modules for build operations - src/config/: 6 modules for JSON configuration - src/fs/: 10 modules for filesystem operations - src/server/: 8 modules for server lifecycle management
The build/ pattern in .gitignore was incorrectly ignoring the source files in tools/dev/src/build/. Added negation pattern to ensure these source files are tracked.
…ADME
1. Converted 32 function declarations to arrow functions
- All src/ modules now use const fn = () => syntax
- Maintains type safety and export compatibility
2. Added comprehensive unit test coverage
- Updated opencode-dev.test.ts with proper imports
- Added 5 collocated test files:
- src/args/parse-flag.test.ts
- src/args/create-default-opts.test.ts
- src/build/wait-for-dist.test.ts
- src/config/backup-file.test.ts
- src/fs/remove-existing-link.test.ts
- All 603 tests passing
3. Created comprehensive README.md
- Architecture documentation
- Usage examples
- API reference
- Troubleshooting guide
4. Maintained single-function-per-module architecture
- Verified all index.ts files are barrel-only
- 39 modules each export exactly one primary function
5. Removed obsolete opencode-dev-test-helpers.ts
- Functions moved to src/ directory during refactoring
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the opencode-core plugin along with comprehensive Biome linting configuration and various project-wide improvements.
Changes
Core Features
Code Quality & Linting
Cleanup
Testing
Type of Change