Repository navigation
acture/lite: commands as tools without Zod (jsonParams, toolDefs) - #119
Merged
Merged
Conversation
A params schema may state its JSON Schema (ParamSchema.jsonSchema); every
projection, toJsonSchema included, uses it as it is. jsonParams builds one,
with a shallow check at dispatch. toolDefs(registry) projects listed commands
to { name, description, inputSchema }, named by commandIdToToolName.
Closes #110
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
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.
Closes #110.
A page on
acture/lite(no Zod, no build step) can now hand its commands to an agent as tools, with no side map of schemas beside the records:ParamSchemagains an optionaljsonSchema: the JSON Schema the params schema stands for, stated rather than converted.toJsonSchemauses it as it is, soacture-mcp-serverandacture-ai-vercelhonour it with no change (their tests pass unchanged).jsonParams(schema, { check? })(inacture/liteandacture) builds such a params schema. At dispatch it runs a shallow check (an object, therequiredkeys, each top-level property'stypeandenum);checkreplaces it (a full validator, or() => []for none).toolDefs(registry, listOptions?)returns{ name, description, inputSchema }per listed command, named bycommandIdToToolName(re-exported fromacture/litewithbuildToolNameToIdMap), with the same deprecation banner the MCP adapter adds. A command whose params carry nojsonSchemais an error naming it.Answers to the two questions in the issue: a stated schema is now validated at dispatch in lite, shallowly by default and pluggably. A ready-to-load single script is not added: the built ESM files load in a page as they are (
<script type="module">importingdist/lite.jsand its chunks), which is what the pages that asked for this do.Size:
createRegistry, defineCommand, ok, errfromacture/litestays at 2895 B (budget 2900; a top-levelObject.freezewas turned into a function so it tree-shakes). The new path, addingjsonParams, toolDefs, is 4785 B min / 2262 B gzip, with its own budget of 4900 B insize-budget.json.Checks run locally: core vitest 207 passed (6 new in
tool-defs.test.ts),tsc --noEmitclean,size-budget.mjsok;acture-mcp-server50 passed andacture-ai-vercel15 passed against the changed core.