Skip to content

feat(capabilities): function discovery carries the cookbook handler example (#1106) - #1111

Merged
jimhoyd merged 1 commit into
mainfrom
claude/handler-example-1106
Sep 30, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/handler-example-1106

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #1106.

What changed

  • getCapability('function') (so urlcode capabilities function [--json] and MCP get_capability) now carries an example:
    • yaml: the cookbook /hello/{name} route lines exactly as examples/cookbook/routes/code.yaml has them (path/query {from} args, an {env} arg, a literal, a named export);
    • module: functions/hello.mjs read from its file, with the export the route names;
    • contract: one sentence on (request, context), context.args, context.inputs.path/query/header, context.env, context.secrets (operator-granted) and context.requestId, and how to copy the whole cookbook.
  • Nothing is hand-copied: the route and module are read from the bundled cookbook at query time. Tests are the drift check: the YAML is a verbatim slice of the file, the module equals the file, the handler runs, the contract names real FunctionContext members (a rename fails typecheck), and the example stays under a 2 KiB bound (handlerExampleMaxBytes). A missing route or file throws instead of degrading silently.
  • The function args constraint now also names {secret} references, which the schema already accepts.
  • get_capability tool description mentions the example (only mcp.ts change).
  • Package smoke: the packed CLI's capabilities function --json is bounded, and its handler is imported from the installed package and run.
  • Docs: docs/CAPABILITIES.md (authoritative page) and a short pointer in docs/AI-AUTHORING.md; llms-full.txt regenerated. docs/TOOLING.md and scripts/check-agent-facts.ts do not encode this output, so they are unchanged.

Sizes

  • urlcode capabilities function --json: 4,421 -> 6,032 bytes
  • urlcode capabilities function (text): 5,978 -> 7,596 bytes

Evidence

npm run typecheck, npm run verify and npm run test:package pass locally (macOS). Not verified: an agent-run comparison showing reduced discovery time.

🤖 Generated with Claude Code

…xample (#1106)

`urlcode capabilities function` and MCP `get_capability` now include an
`example`: the cookbook /hello/{name} route lines read verbatim from
examples/cookbook/routes/code.yaml, the handler module it names read from
its file, and one sentence on how args, inputs, env, secrets and requestId
reach `(request, context)`. Nothing is copied: tests assert the YAML is the
file's own lines, the module is the file, the handler runs, the contract
names real FunctionContext members, and the example stays under 2 KiB.
The packed-consumer smoke runs the handler from the installed package.

The function `args` constraint now names `{secret}` references too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 30, 2026 21:35
@jimhoyd
jimhoyd merged commit cdd7b2b into main Sep 30, 2026
24 checks passed
@jimhoyd
jimhoyd deleted the claude/handler-example-1106 branch September 30, 2026 21:45
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.

[Request]: Make the minimal handler example directly retrievable from function capability discovery

1 participant