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

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:
chrnx committed 2026-10-30 10:51:21 -05:00
1 parent 47d1d6e037
commit a4827f2e13
8 files changed
+697 -216

No files matched your search

+19
View File
@@ -9,6 +9,25 @@ green-tea's convention. **The CLI ships on its own version line**: `matcha` 26.8
mean `@green-tea/core` 26.8, and the two release independently. The core version a scaffold
is pinned to is `CORE_VERSION` in `src/template.rs`, and each entry below says when it moved.
## [Unreleased]
### Added
- **`matcha routes` and `matcha tokens`.** `routes` lists every route with its transport and chain.
`tokens` lists every token, with who provides it and who needs it, handlers included. It is
the check to run before writing `@needs('x')`.
- **`--json` on `explain`, `routes` and `tokens`** (`graph --format json` already had it). It
prints one JSON document on stdout, so an agent inspecting an app reads the graph instead of
guessing it. A refused query (an unknown pattern) prints a structured error on stderr and
exits 1.
### Changed
- Introspection runs through one query layer (`src/introspect.rs`): every command asks one
question and gets one JSON document back, then renders it as text unless `--json` is passed.
Text output is unchanged. The layer is also the seam a future `matcha mcp` would serve over
MCP. It adds `serde_json` as a dependency.
## [26.9.0-beta.1] - 2026-09-24
### Added