feat(m7.2): TypeScript capabilities — schema, classification, linter - #28
Merged
Conversation
- capability(name, config, handler) → BoundCapability {spec, handler, returnsRaw};
access is classified from the name unless config.reads/destructive overrides it.
An optional Args type parameter types the handler's arguments for the caller.
- Schema authoring, TS-appropriately: types are erased at runtime, so instead of
reflecting them the package offers params({order_id:'integer', reason:'string?',
tags:'string[]'}) — a tiny JSON Schema builder (? = optional, [] = array) with
ZERO dependencies — and Zod v4 users just pass z.toJSONSchema(schema), so no
converter and no hard zod dep are needed.
- classify/classifyWith mirror the exact Python/Go verb sets (read/write/
destructive), ambiguous ⇒ write (§2.4), and throw a hinted error if a capability
is marked both reads and destructive.
- lint/lintCapability + LintReport with the same four language-neutral violation
codes (opaque_name, missing_description, too_many_params, raw_response),
MAX_PARAMS=7, MIN_DESCRIPTION_CHARS=10, and the same opaque-name rule (clean
snake_case with at least one 4+ char token). Both conformance linter shapes
(linter_rejects_raw_capability / linter_accepts_clean_capability) are reproduced
as unit tests.
Verified: make js-check green — format, typecheck, 35 tests (classification across
all verb classes + ambiguous default + overrides; linter pass/fail shapes and each
code; capability construction, handler context/args, params builder incl. arrays,
optionals, and hinted errors on unknown types).
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.
Verified: make js-check green — format, typecheck, 35 tests (classification across all verb classes + ambiguous default + overrides; linter pass/fail shapes and each code; capability construction, handler context/args, params builder incl. arrays, optionals, and hinted errors on unknown types).