Skip to content

Support for Copilot-based grammar rule generation alongside the existing Claude-based approach - #3084

Merged
Hillary Mutisya (hillary-mutisya) merged 3 commits into
mainfrom
dev/hillarym/mcp2
Sep 26, 2026
Merged

Hillary Mutisya (hillary-mutisya) merged 3 commits into
mainfrom
dev/hillarym/mcp2

Conversation

@hillary-mutisya

Copy link
Copy Markdown
Collaborator

This pull request introduces support for Copilot-based grammar rule generation alongside the existing Claude-based approach, and generalizes the grammar generation pipeline to support multiple LLM providers. It also updates the grammar rule metadata model to support additional status and identity tracking, and refines documentation to reflect these architectural changes.

Grammar Generation Pipeline Refactoring:

  • Refactored the core grammar generation logic into an abstract GrammarGenerator class, with provider-specific implementations for ClaudeGrammarGenerator and the new CopilotGrammarGenerator. This enables easy addition of new LLM providers. [1] [2] [3]
  • Updated all references and error messages in grammarGenerator.ts to refer generically to "the model" or the provider name, rather than "Claude", to support multiple providers. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Copilot LLM Integration:

  • Added a new CopilotGrammarGenerator class that uses the Copilot SDK (@github/copilot-sdk) with the gpt-5.6-sol model for grammar rule generation. [1] [2]
  • Exported Copilot generator types and factory functions from the public API.

API & Usage Changes:

  • Updated the populateCache function to accept either a GrammarGenerator instance or a Claude model string, defaulting to Copilot if not specified. This allows runtime selection of the LLM provider. [1] [2]
  • Updated documentation in actionGrammar.md to describe the four available grammar generation strategies, including the new Copilot-based generator as the default.

Grammar Rule Metadata Model Updates:

  • Extended the StoredGrammarRule type with new fields: schemaHash, actionBinding, status, and invalidationReason to support rule status tracking and schema identity. Added related types for schema identity and reconciliation. [1] [2]

Exports and Internal API:

  • Updated exports in the index to include the new generator classes and types, ensuring they are available for use by other packages. [1] [2]

These changes make the grammar generation system more flexible and future-proof, allowing for the integration of additional LLMs and improved tracking of grammar rule provenance and status.

Expand MCP JSON Schema conversion to support common nullable, composed,
open-object, array, and local-reference forms while preserving existing
catalog safety limits and runtime validation.

Enable learned grammar generation for inline dynamic schemas and persist
schema hashes plus stable provider/action fingerprints with generated rules.
Reconcile these identities during startup and catalog refresh, suspending stale
rules and falling back to normal translation when a tool changes or disappears.
Rules are automatically reactivated when the original identity returns.

Also expose suspended-rule status in grammar management, migrate existing
grammar stores compatibly, and roll back rules that fail in-memory activation.

Add focused coverage for schema conversion, tool fingerprints, manifest
bindings, grammar-store migration, and stale-rule reconciliation.
…utes.

Use GPT-5.6 Sol to generate grammar from confirmed request/action pairs,
removing the runtime dependency on a separate Claude CLI login. Extract the
shared grammar generation and parsing behavior into a provider-independent
base class while retaining the Claude generator for existing CLI and API
callers.

Make Copilot the default generator for runtime cache population, add reliable
session/client cleanup, and support injected clients for isolated tests.
Document the new runtime generation strategy and add focused coverage for
model selection, response handling, and resource cleanup.

Validate the implementation end to end with a read-only MCP tool: the first
request generates and persists a schema-aware, fingerprinted grammar rule,
while repeated requests—including after a server restart—route through the
NFA grammar cache with zero translation-model tokens and continue through the
normal MCP validation, policy, audit, and execution path.
@hillary-mutisya
Hillary Mutisya (hillary-mutisya) merged commit 7939c07 into main Sep 26, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant