feat(skills): Add opencode-skills package with BM25 ranking#24
Conversation
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
Remove all package changes from this PR - they belong in separate PRs: - packages/opencode-agent-loader-plugin/ → PR #28 - packages/opencode-font/ → PR #24 - packages/opencode-warcraft-notifications-plugin/ → PR #29 PR #21 now contains ONLY Biome infrastructure: - biome.json configuration - lefthook.yml git hooks - nx.json targets for lint/format - Root package.json scripts - CI workflow (validate-pr.yml) - Infrastructure executors (typecheck, validate-tsdoc) - Generator templates with Biome config Apply Biome formatting to biome.json (trailing newline).
Remove all packages and dev tools that belong in other PRs: - packages/* (moved to PR #22, #23, #24, etc.) - tools/dev/* (moved to PR #5) - tools/executors/dev-proxy/* (moved to PR #5) - tools/executors/check-mirror-exists/* (moved to PR #5) - tools/executors/validate-skill-md/* (moved to PR #5) - tools/executors/validate-skills/* (moved to PR #5) Keep only Biome infrastructure: - biome.json, lefthook.yml, nx.json, package.json - .github/workflows/validate-pr.yml - libs/workflows/project.json - tools/executors/typecheck/ - tools/executors/validate-tsdoc/ - tools/generators/* (templates with Biome config)
* feat(infra): add Biome linting/formatting infrastructure - Add Biome v2.3.13 configuration with custom rules - Configure lint, format, and format:check targets in nx.json - Add validate-tsdoc executor for documentation validation - Update lefthook.yml with Biome pre-commit hooks - Update validate-pr.yml workflow for Biome - Update generators to include Biome configuration This PR establishes the foundation for Biome-based linting and formatting that all subsequent PRs will use. * fix: resolve CI failures on Biome infrastructure PR - Remove opencode-font override from biome.json to enable linting/formatting - Fix ASCIISiteTitle variable name typo (_siteTitle -> siteTitle) - Fix non-null assertion in load-all-agent-specs.ts using type guard pattern All checks now pass: - Biome linting ✓ - Biome formatting ✓ - docs-builder build ✓ * fix(agent-loader): fix type predicate in load-all-agent-specs.ts Use proper type predicate pattern instead of type assertion for filtering successful agent spec loads. Fixes CI typecheck failure. * fix: resolve remaining CI failures on PR #21 - Fix type predicate in load-all-agent-specs.ts using proper pattern - Fix 2 lint errors in validate-docs-links.ts (noImplicitAnyLet, useIterableCallbackReturn) - Add missing imports to Header.astro (ASCIISiteTitle, SocialIcons, Search, ThemeSelect) Typecheck and lint now pass locally. * style: apply Biome formatting to fix CI errors Apply Biome formatting to 4 package.json files: - packages/opencode-agent-loader-plugin/package.json - packages/opencode-agent-loader-plugin/tsconfig.test.json - packages/opencode-font/package.json - packages/opencode-warcraft-notifications-plugin/package.json Fixes format CI failures on PR #21. * fix(agent-loader): use type assertion instead of type predicate Replace type predicate with type assertion to satisfy stricter CI checks. The filter returns items with defined spec, then we safely assert the type. Fixes typecheck failures on PR #21. * refactor: cleanup PR #21 to only include infrastructure Remove all package changes from this PR - they belong in separate PRs: - packages/opencode-agent-loader-plugin/ → PR #28 - packages/opencode-font/ → PR #24 - packages/opencode-warcraft-notifications-plugin/ → PR #29 PR #21 now contains ONLY Biome infrastructure: - biome.json configuration - lefthook.yml git hooks - nx.json targets for lint/format - Root package.json scripts - CI workflow (validate-pr.yml) - Infrastructure executors (typecheck, validate-tsdoc) - Generator templates with Biome config Apply Biome formatting to biome.json (trailing newline). * fix(biome): add overrides for test/template files to fix lint errors Add Biome linter overrides to allow patterns in test/template files: - Disable noBannedTypes for tools/executors/**/*.test.ts (Function type) - Disable noNamespace for executors and templates - Disable noExplicitAny for generator templates Fixes CI lint failures: - 'Don't use Function as a type' errors - 'TypeScript namespaces are outdated' errors - 'Unexpected any' warnings in templates Also fixes dev-proxy test type assertions. * fix(biome): add file ignores for packages not in this PR Add file ignores to biome.json for packages and tools that belong in other PRs: - packages/opencode-agent-loader-plugin/* - packages/opencode-font/* - packages/opencode-warcraft-notifications-plugin/* - tools/dev/* - tools/executors/dev-proxy/* - tools/executors/check-mirror-exists/* - tools/executors/validate-skill-md/* - tools/executors/validate-skills/* This allows the infrastructure PR to pass CI without linting files that will be properly formatted and fixed in their respective PRs. Also apply Biome formatting to biome.json (trailing newline). * fix(biome): add file ignores and template overrides to fix CI - Add files.includes to ignore packages not in this PR: - packages/opencode-agent-loader-plugin - packages/opencode-font - packages/opencode-warcraft-notifications-plugin - Add linter override for generator template files to disable noExplicitAny - Apply Biome formatting to biome.json Fixes CI lint and format errors. * fix(biome): simplify biome.json configuration to fix CI Remove all package file ignores and use a clean, minimal biome.json that only ignores standard directories (dist, node_modules). This ensures the infrastructure PR can pass CI without trying to lint files that belong in other PRs. All local checks pass: - bun run format:check ✓ - bun run lint ✓ * refactor: clean PR #21 to only include infrastructure Remove all packages and dev tools that belong in other PRs: - packages/* (moved to PR #22, #23, #24, etc.) - tools/dev/* (moved to PR #5) - tools/executors/dev-proxy/* (moved to PR #5) - tools/executors/check-mirror-exists/* (moved to PR #5) - tools/executors/validate-skill-md/* (moved to PR #5) - tools/executors/validate-skills/* (moved to PR #5) Keep only Biome infrastructure: - biome.json, lefthook.yml, nx.json, package.json - .github/workflows/validate-pr.yml - libs/workflows/project.json - tools/executors/typecheck/ - tools/executors/validate-tsdoc/ - tools/generators/* (templates with Biome config) * fix: resolve Biome linting and formatting issues for CI - Updated opencode-font package.json to skip Biome (disabled in root config) - Fixed type predicate for AgentSpecLoadResult to remove non-null assertion - Applied Biome formatting to all JSON files - All checks now pass: lint, format, type-check * fix: add verbose flag to Biome CI command for detailed output * fix(biome): add diagnostic level flag to Biome CI command for improved error reporting * fix: add output-style flag to various nx affected commands for consistent output * docs: add Biome diagnostics reference to skill documentation - Add https://biomejs.dev/reference/diagnostics/ to Getting More Help section * fix(biome): add BIOME_CONFIG_PATH environment variable for Biome CI * fix: update globals.d.ts to ignore linting for noNamespace rule * docs: add debugging guidance for CI failures in Biome skill documentation
- Complete skill injection system with BM25 probabilistic ranking - Markdown parsing and validation for skill files - Pattern matching with regex and intent detection - Structured skill format with frontmatter support - Independent package - no internal dependencies - Required by: opencode-core-plugin This package provides the foundation for smart skill injection and context-aware prompt enhancement.
97b13fb to
d564311
Compare
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new opencode-skills package implementing a skill injection system with BM25 probabilistic ranking for intelligent pattern matching. The package provides TypeScript-based skill definitions with automatic injection capabilities.
Changes:
- Complete skill injection system with BM25 relevance ranking
- Pattern matching with intent detection, negation detection, and keyword support
- Markdown parsing with YAML frontmatter for skill files
- Validation system for skill definitions
- Custom Nx executors for skill validation
- Comprehensive test coverage and documentation
Reviewed changes
Copilot reviewed 65 out of 70 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/opencode-skills/src/bm25.ts | BM25 implementation - DUPLICATE of src/bm25/ directory |
| packages/opencode-skills/src/bm25/* | Modular BM25 implementation with separate files for each function |
| packages/opencode-skills/src/pattern-matching.ts | Pattern matching implementation - DUPLICATE of src/pattern-matching/ directory |
| packages/opencode-skills/src/pattern-matching/* | Modular pattern matching with intent/negation detection |
| packages/opencode-skills/src/parsers/markdown-parser.ts | Markdown parser - DUPLICATE of modular parser files |
| packages/opencode-skills/src/parsers/* | Modular markdown parser components |
| packages/opencode-skills/src/validation/* | Skill validation with errors, warnings, and suggestions |
| packages/opencode-skills/src/create-skills-plugin.ts | Plugin factory function |
| packages/opencode-skills/src/define-skill.ts | Helper for creating skill objects |
| packages/opencode-skills/src/examples.ts | Example skills for demonstration |
| packages/opencode-skills/src/types.ts | Type definitions for skills and configuration |
| packages/opencode-skills/src/index.ts | Package entry point |
| tools/executors/validate-skills/* | Nx executor for TypeScript skill validation |
| tools/executors/validate-skill-md/* | Nx executor for markdown skill validation |
| packages/opencode-skills/package.json | Package configuration and dependencies |
| packages/opencode-skills/README.md | Comprehensive documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "yaml": "^2.3.4", | ||
| "zod": "^3.22.4" |
There was a problem hiding this comment.
The csstype and undici-types packages are listed as dependencies but don't appear to be used in the codebase. These should be removed unless there's a specific reason for their inclusion.
| @@ -0,0 +1,108 @@ | |||
| import { readFile } from 'node:fs/promises'; | |||
| import type { ExecutorContext } from '@nx/devkit'; | |||
| import { glob } from 'glob'; | |||
There was a problem hiding this comment.
Missing dependency: The glob package is imported but not listed in package.json dependencies. This will cause a runtime error when the executor tries to run.
Add glob to the dependencies or devDependencies in package.json, or use a built-in Node.js alternative.
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
…up, deprecated category field
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
- Updated ValidationResult to use errors/warnings/suggestions arrays - Added new required Skill fields: whatIDo, whenToUseMe, instructions, checklist - Rewrote validateSkill() to match test expectations - Rewrote formatValidationResult() with skillName parameter - Added validateSkill() and formatValidationResult() exports - All 43 tests now passing
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
- Removed strict mode logic that converted warnings to errors - All 43 tests now passing - Build successful
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
…s, arrow functions - Split skill-validator.ts into separate modules: - validate-skill.ts: single arrow function - format-validation-result.ts: single arrow function - Updated validation/index.ts barrel exports - Moved test to proper __tests__/ location - All 43 tests passing, build successful
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
- Modified validate-skill to accept legacy content field - v2 structured fields only required when legacy content absent - Removed duplicate deprecation warnings - All 58 tests passing, build successful
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
…unctions, unit test collocation, and TDD
- Introduced the subagent-driven development skill with detailed process and advantages. - Added prompt templates for implementer, spec compliance reviewer, and code quality reviewer subagents. - Created a comprehensive test-driven development skill with guidelines and anti-patterns. - Developed a writing plans skill to assist in creating detailed implementation plans.
…eviewer prompt template
…ce skill definitions with licensing, compatibility, and checklists
…eviewer prompt template
…nd improve code organization - Convert 13 named function declarations to arrow functions across all modules - validation/skill-validator.ts: validateSkill - bm25/calculate-score.ts: calculateBM25Score - bm25/build-index.ts: buildBM25Index - bm25/rank-skills.ts: rankSkillsByBM25 - bm25/tokenize.ts: tokenize - bm25/get-top-skills.ts: getTopSkillsByBM25 - parsers/markdown-to-skill.ts: markdownToSkill - parsers/skill-to-markdown.ts: skillToMarkdown - parsers/parse-skill-markdown.ts: parseSkillMarkdown - parsers/extract-frontmatter.ts: extractFrontmatter - parsers/extract-sections.ts: extractSections - pattern-matching/has-intent-to-use.ts: hasIntentToUse - pattern-matching/escape-regex.ts: escapeRegex - pattern-matching/find-matching-skills.ts: findMatchingSkills - create-skills-plugin.ts: createSkillsPlugin - define-skill.ts: defineSkill - examples.ts: validate, MyComponent (documentation) - Remove emojis from validation output format - Replace ❌⚠️ 💡✅ with [ERROR][WARNING][SUGGESTION][OK] - Decompose extract-sections.ts into smaller modules - Create split-by-headings.ts for heading parsing - Create parse-checklist-items.ts for checklist extraction - Reduce extract-sections.ts from 96 to 46 lines - Delete markdown-parser.ts violating one-function-per-file rule - Functions already exist in separate files - Update markdown-parser.test.ts to import from separate modules - Add comprehensive BM25 unit tests - tokenize.test.ts: 10 test cases - term-frequency.test.ts: 6 test cases - inverse-document-frequency.test.ts: 6 test cases - calculate-score.test.ts: 8 test cases - build-index.test.ts: 7 test cases - Add pattern matching edge case tests - escape-regex.test.ts: 13 test cases - has-intent-to-use.test.ts: 19 test cases - find-matching-skills.test.ts: 14 test cases - Move index.test.ts to define-skill.test.ts (colocation) - Fix markdown-to-skill.ts to include version and updatedAt fields All 114 tests passing
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
|
This PR is quite large with:
Consider breaking it down into smaller, focused PRs for easier review. |
Summary
Complete skill injection system with BM25 probabilistic ranking for smart pattern matching.
Changes
BM25 Features
Dependencies
Blocks
Testing
bunx nx test opencode-skillsbunx nx run opencode-skills:test:coveragebunx nx type-check opencode-skills