feat(mcp): expose language operation discovery contract
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

This commit is contained in:
2026-11-27 01:19:37 +00:00
parent 219969b9e6
commit 82ceb746ad
7 changed files with 643 additions and 35 deletions
@@ -229,7 +229,8 @@ Input is a replacement snapshot: booleans `up/down/left/right/a/b/x/y/l/r/start/
select/touch`, signed 32-bit `touchX/touchY`. Omitted fields reset to false/zero.
It preserves the runtime's normal sampling/edge semantics, not UI keyboard events.
Language queries use the capabilities returned by project context. Parameters
Language queries use the capabilities returned by project context. Capability
names are not necessarily callable operation names. Parameters
may contain URI, zero-based UTF-16 position/range/positions, workspace query,
newName, includeDeclaration or task-local itemId for multi-stage queries. The
provider MUST validate the parameters needed by the selected operation and reject
@@ -256,15 +257,55 @@ the application adapter. Studio API/Core use maps, lists and scalar values only.
| `selectionRanges` | `uri`, nonempty `positions` |
| `codeActions` | `uri`, ordered `range`; diagnostics are obtained from the current saved file |
| `incomingCalls`, `outgoingCalls` | task-local `itemId` from a hierarchy result |
| `readExternalSource` | `uri`: a task-owned `prometeu-source:` URI returned by `definition` |
The packaged `studio_language_query` descriptor MUST enumerate all recognized
operation names in `inputSchema.properties.operation.enum`. Its `inputSchema.oneOf`
MUST describe each operation's required `parameters` and additional constraints
(including nonempty `selectionRanges.positions`). Common parameter types and
coordinate rules belong in the shared `parameters` schema. Known additional
parameters tolerated by the adapter remain permitted; irrelevant parameters do
not imply an additional operation. `references.includeDeclaration` defaults to
false, and `workspaceSymbols.query` defaults to the empty string.
The authenticated MCP `studio_project_context` result MUST add `languageQuery`,
derived from that same packaged descriptor, without changing API/Core knowledge:
- `tool`: `studio_language_query`.
- `description` and `parametersSchema`: the shared description and parameter schema.
- `operations`: entries with `operation`, `capability`, `description`,
`requiredParameters`, and the operation's `parametersSchema` constraints. Apply
both the shared and operation-specific schemas to the parameters.
Each descriptor branch records its related context capability as
`x-studio-capability`. These mappings describe recognized operations, not universal
support. Clients MUST consult `languages[].capabilities` separately. In particular,
`callHierarchy` maps to `prepareCallHierarchy`, `incomingCalls` and `outgoingCalls`;
`rename` maps to `prepareRename` and `rename`. `callHierarchy` and `typeHierarchy`
are not valid operation names. `readExternalSource` relates to `lsp` but additionally
requires negotiated `prometeuExternalSources`; `prepareRename` additionally requires
the running server's `renameProvider.prepareProvider`. Connection/initialize
instructions MUST direct clients to this discovery contract, without requiring
checkout code or specifications.
Support MUST be checked against the running server's initialize response before
dispatch. Unknown operations, including currently unsupported type hierarchy,
return `UNSUPPORTED_CAPABILITY`. Context publishes the installed provider's
dispatch. MCP rejects unknown operations and structurally invalid arguments at
tool-schema validation. The language adapter continues to return
`UNSUPPORTED_CAPABILITY` for unknown operations or absent server capabilities.
Context publishes the installed provider's
capabilities, including semantic tokens; hierarchy and rename preparations use
their corresponding server capability. Positions are zero-based UTF-16 offsets,
must fit the saved file and must not split surrogate pairs. Reversed ranges and
missing operation-specific parameters are rejected.
`uri` is a document URI, not a filesystem path: use `file:` for accessible saved
source files in the declared project/dependency scope, or a `prometeu-source:`
identity returned by `definition` in the same task/project. UTF-16 character offsets
are neither UTF-8 byte offsets nor Unicode code-point counts. Start a call hierarchy
with `prepareCallHierarchy(uri, position)`, then use a returned opaque `itemId` for
`incomingCalls` or `outgoingCalls`. Returned hierarchy items may supply new `itemId`
values for further traversal. Item IDs cannot be invented from symbol names or URIs.
The application lifecycle supplies each open project's bound loopback LSP
endpoint. Studio uses OS-assigned ports so different open projects do not compete
for one fixed port. The public LSP configuration default remains unchanged for