Skip to content

feat(validator-speclynx): simplify plugins signature#208

Merged
char0n merged 2 commits intomainfrom
char0n/validator-speclynx-simplified
Feb 13, 2026
Merged

feat(validator-speclynx): simplify plugins signature#208
char0n merged 2 commits intomainfrom
char0n/validator-speclynx-simplified

Conversation

@char0n
Copy link
Member

@char0n char0n commented Feb 13, 2026

Along with that, provide more of convinient deps
via toolbox.

Summary by CodeRabbit

  • Documentation

    • Updated plugin development docs to describe the new toolbox-based initialization, dependency access, and diagnostic payload shape.
  • Refactor

    • Reworked custom plugin interfaces to accept a toolbox (providing dependencies and diagnostics), return lifecycle hooks directly, and derive diagnostic path/context dynamically.

Along with that, provide more of convinient deps
via toolbox.
@char0n char0n requested a review from Copilot February 13, 2026 20:47
@char0n char0n self-assigned this Feb 13, 2026
@char0n char0n added the enhancement New feature or request label Feb 13, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Refactors SpecLynx plugin API from a diagnostics-only injection to a toolbox pattern: plugins now receive a toolbox containing diagnostics and deps, and resolve external dependencies via toolbox.deps; plugin factories return lifecycle hooks using the toolbox-provided context.

Changes

Cohort / File(s) Summary
Documentation
packages/jentic-openapi-validator-speclynx/README.md, packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/__init__.py
Docs and docstring updated to describe the toolbox-based plugin API (toolbox contains diagnostics and deps) replacing prior diagnostics-only contract.
Plugin Samples & Implementations
packages/jentic-openapi-validator-speclynx/src/.../resources/plugins/example-plugin.mjs.sample, packages/jentic-openapi-validator-speclynx/src/.../resources/plugins/openapi-document.mjs, packages/jentic-openapi-validator-speclynx/tests/fixtures/plugins/version-validator.mjs
Plugin factories refactored to accept toolbox, destructure diagnostics and deps, derive dependencies (e.g., DiagnosticSeverity, toValue) from toolbox.deps, update diagnostic payloads to use path.getPathKeys(), and return plugin object directly with pre/visitor/post.
Backend wiring
packages/jentic-openapi-validator-speclynx/src/.../resources/speclynx.mjs
Toolbox construction extended to expose additional ApiDOM dependencies and diagnostics; plugin invocation updated to pass constructed toolbox (plugins no longer wrapped with a diagnostics-only object).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • frantuma
  • frankkilcommins

Poem

"🐇 I found a little toolbox bright and new,
It held deps and diagnostics, tidy too.
Plugins hop in, resolve what they need,
Paths traced in keys, diagnostics take heed.
Hooray — a rabbit cheers this tidy cue!"

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (7 files):

⚔️ packages/jentic-openapi-validator-speclynx/README.md (content)
⚔️ packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/__init__.py (content)
⚔️ packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample (content)
⚔️ packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/openapi-document.mjs (content)
⚔️ packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/speclynx.mjs (content)
⚔️ packages/jentic-openapi-validator-speclynx/tests/fixtures/plugins/version-validator.mjs (content)
⚔️ uv.lock (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(validator-speclynx): simplify plugins signature' accurately describes the main change—refactoring plugins from a complex curried function structure to a simpler toolbox-based API.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch char0n/validator-speclynx-simplified
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch char0n/validator-speclynx-simplified
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample (1)

22-104: Plugin implementation is a solid, well-structured example.

Good coverage of the toolbox API surface: pre/post lifecycle hooks, multiple visitor types, path.node and path.getPathKeys() usage, and dependency extraction. This serves well as a template for plugin authors.

One minor style note: this file constructs diagnostic objects manually (plain objects), while openapi-document.mjs uses Diagnostic.create() / Range.create() from vscode-languageserver-types. Both approaches work, but it could be worth showing the Diagnostic.create approach here as well (or adding a comment noting both styles are valid) so users discover the richer API.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the plugin system in the SpecLynx OpenAPI validator to simplify the plugin signature. Previously, plugins used a curried function pattern ({diagnostics}) => () => ({...}), and now they accept a single toolbox parameter and return the visitor object directly (toolbox) => ({...}). The toolbox provides both the diagnostics array and a deps object containing external dependencies (vscode-languageserver-types, @speclynx/apidom-* packages), eliminating the need for plugins to import these dependencies directly.

Changes:

  • Simplified plugin signature from curried function to direct function accepting toolbox parameter
  • Extended toolbox with additional @speclynx/apidom-* dependencies (core, datamodel, json-path, json-pointer, traverse)
  • Updated all existing plugins (openapi-document.mjs, version-validator.mjs) and example plugin to use new signature
  • Updated documentation in README.md and Python docstrings to reflect the new plugin API

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/jentic-openapi-validator-speclynx/tests/fixtures/plugins/version-validator.mjs Updated test plugin to use new toolbox signature and access dependencies via deps object
packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/speclynx.mjs Added new dependency imports, updated createToolbox to include deps object, changed plugin invocation to pass plugins directly with toolboxCreator
packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/openapi-document.mjs Updated built-in plugin to use new toolbox signature and access dependencies via deps object
packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample Updated example plugin template to demonstrate new toolbox signature with improved documentation
packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/init.py Updated Python docstring to document new plugin toolbox structure
packages/jentic-openapi-validator-speclynx/README.md Updated plugin documentation with corrected example using toolbox signature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In
`@packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/__init__.py`:
- Around line 62-64: The docstring for plugin toolbox plugins currently lists an
incomplete set of deps; update the docstring in __init__.py so the toolbox.deps
description matches the actual keys exported by speclynx.mjs (the toolbox built
in speclynx.mjs lines ~145–152): include `@speclynx/apidom-core`,
`@speclynx/apidom-datamodel`, `@speclynx/apidom-json-path`,
`@speclynx/apidom-json-pointer`, and `@speclynx/apidom-traverse` in addition to
vscode-languageserver-types and `@speclynx/apidom-reference`, and mention that
built-in plugins like openapi-document.mjs rely on `@speclynx/apidom-core`.

In
`@packages/jentic-openapi-validator-speclynx/src/jentic/apitools/openapi/validator/backends/speclynx/resources/plugins/example-plugin.mjs.sample`:
- Around line 8-18: Update the JSDoc for the default plugin function to
accurately list the dependencies available on toolbox.deps (notably including
'@speclynx/apidom-core' which provides toValue used in the example); modify the
`@param` lines so toolbox.deps documents all relevant packages used in the sample
(e.g., 'vscode-languageserver-types', '@speclynx/apidom-reference',
'@speclynx/apidom-core' etc.), referencing the concrete symbol toValue and the
toolbox.deps object so readers can locate the import in
example-plugin.mjs.sample.

In
`@packages/jentic-openapi-validator-speclynx/tests/fixtures/plugins/version-validator.mjs`:
- Around line 3-6: The JSDoc for the plugin lists `@speclynx/apidom-reference` but
the code actually destructures toValue from deps['@speclynx/apidom-core'];
update the JSDoc to accurately reflect the dependencies used (add
`@speclynx/apidom-core` or list all available deps) so consumers of the fixture
know to expect toValue from '@speclynx/apidom-core' when using the plugin (refer
to the destructuring of toValue in the plugin code).

@char0n char0n merged commit 2135d5b into main Feb 13, 2026
4 checks passed
@char0n char0n deleted the char0n/validator-speclynx-simplified branch February 13, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant