feat(introspect): routes, tokens and --json, over one query layer an MCP server can reuse
CI / installer (macos-14) (pull_request) Successful in 4s
CI / check (pull_request) Successful in 27s
CI / starter (bun) (pull_request) Successful in 30s
CI / starter (deno) (pull_request) Successful in 32s
CI / starter (edge) (pull_request) Successful in 36s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 14s
CI / starter (node) (pull_request) Successful in 32s
CI / installer (macos-14) (pull_request) Successful in 4s
CI / check (pull_request) Successful in 27s
CI / starter (bun) (pull_request) Successful in 30s
CI / starter (deno) (pull_request) Successful in 32s
CI / starter (edge) (pull_request) Successful in 36s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 14s
CI / starter (node) (pull_request) Successful in 32s
Agents that inspect a green-tea app should read its graph instead of guessing it. - Add `matcha routes`: every route with its transport and chain. - Add `matcha tokens`: every token, who provides it and who needs it, handlers included. - explain, routes and tokens take --json. It prints one JSON document on stdout; a refused query prints a structured error on stderr and exits 1. All introspection now goes through src/introspect.rs. Each Query variant runs one script that prints a single JSON envelope, and the CLI renders the data as text unless --json is given. Text output is unchanged. A future `matcha mcp` serves the same queries as tools without a second implementation, which is why the formatting moved from the generated script into Rust. Adds serde_json (dtolnay, 1.0.154). Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
8 files changed
+697
-216
No files matched your search
@@ -42,6 +42,8 @@ matcha create plugin "Plugin Algo" # an in-app plugin, or --package for
|
||||
matcha add sse # add a capability to your controller
|
||||
matcha graph # draw the dependency graph
|
||||
matcha explain /users/:id # one route's chain, in execution order
|
||||
matcha routes # every route and the chain it runs
|
||||
matcha tokens # every token: who provides it, who needs it
|
||||
matcha openapi # structural OpenAPI 3.1 for the route table
|
||||
matcha doctor # check the project for confusing misconfigurations
|
||||
```
|
||||
@@ -75,6 +77,9 @@ matcha graph --format dot # Graphviz
|
||||
matcha graph --format json # the raw GraphView
|
||||
matcha graph --out docs/graph.mmd # to a file instead of stdout
|
||||
matcha explain /users/:id # providers → steps → handler, with needs/provides
|
||||
matcha routes # every route: method, pattern, transport, chain
|
||||
matcha tokens # every token, who provides it, who needs it
|
||||
matcha explain /users/:id --json # any of explain/routes/tokens as JSON, for a program or an agent
|
||||
matcha openapi --title "My API" --api-version 1.0.0 --out openapi.json
|
||||
```
|
||||
|
||||
@@ -90,6 +95,17 @@ be installed, since this runs your code under your runtime.
|
||||
`explain` takes the route **pattern** as declared, not a concrete URL:
|
||||
`/users/:id`, not `/users/42`. A miss lists the patterns that are registered.
|
||||
|
||||
`tokens` answers the question to ask before writing `@needs('x')`: does anything
|
||||
provide `x`, and who else depends on it? A token nothing provides is listed with
|
||||
`— (nothing provides it)`, which is the boot error you are about to get.
|
||||
|
||||
**For agents.** `--json` prints the same data the text is rendered from: exactly
|
||||
one JSON document on stdout, so a program parses stdout and nothing else. When a
|
||||
query is refused (an unknown route pattern), stderr carries
|
||||
`{"error": {"code", "message", …}}` and the exit code is 1. Every query is one
|
||||
self-contained document, so the same set can later be served over MCP without a
|
||||
second implementation.
|
||||
|
||||
### `add` capabilities
|
||||
|
||||
| | generates |
|
||||
|
||||
Reference in new issue
Block a user