feat(graph): draw the graph, and stop scaffolding a two-month-old core

The CLI's last feature work was 12 July; core has shipped 26.8 and 26.9 since.
Two consequences, fixed together because they share an entry-file convention.

Every runtime overlay pinned `^26.7.0-beta.0`. Core is prerelease-only, and
npm's semver excludes a prerelease from any range whose comparators carry a
different major.minor.patch — so that caret is not a loose pin, it is a pin to
the oldest matching prerelease that nothing can move off. Every project
`matcha new` has produced since July installed 26.7.0-beta.0 and could not
upgrade: no logger, no request budget, no resumable `@Sse` id, and none of the
crashes 26.9 fixed. The pin is now exact, lives in one `CORE_VERSION` const,
and Deno resolves through JSR — which is core's native path for Deno and the
one 26.9 repaired.

Nothing caught that because CI never ran JavaScript. `cargo test` proves the CLI
writes the files it means to write; it cannot prove those files describe a
project the current core will run. `scripts/starter-smoke.sh` scaffolds,
installs, type-checks, boots, curls `/` and the `/zen` stream, and introspects a
real starter per runtime; a weekly job fails when the pin falls behind the
`beta` dist-tag. The smoke immediately found a second defect: the bun overlay
carried no Bun types, so `tsc --noEmit` — and therefore `matcha create --check`
— failed on every bun project the CLI has ever scaffolded.

`matcha graph` and `matcha explain <pattern>` close the widest gap in the
surface: the framework's claim is that an API is a graph rather than a
middleware chain, `toMermaid`/`toDOT`/`graph`/`explain` have been exported all
along, and the CLI could not draw any of it. Both reach the app through
`app.ready()`, which resolves the graph and is documented as deliberately not
running provider factories — asking for a diagram must not open your database
connections. Formatting lives in the generated script rather than in Rust,
which keeps serde out for output `console.log` already has the values for.

That needed an app the CLI can import without binding a port, so the starter
now composes the graph in `src/app.ts` and leaves `src/main.ts` holding only
the serve call. `create module` follows, preferring `src/app.ts` and falling
back to `src/main.ts` so projects scaffolded before the split keep working.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012x1UPw987zNSxjH2DxHy2C
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-09-05 14:30:19 -05:00
1 parent 8910fe22ee
commit 827e6863ad
21 files changed
+747 -27

No files matched your search

+47
View File
@@ -37,6 +37,8 @@ matcha new my-api --template-url gh:owner/repo # scaffold from any git templat
matcha run # detect node/deno/bun and run in watch
matcha create controller Users # generate + auto-wire into @Module
matcha add sse # add a capability (sse|stream|buffer) to your controller
matcha graph # draw the dependency graph
matcha explain /users/:id # one route's chain, in execution order
```
### The starter
@@ -45,6 +47,39 @@ matcha add sse # add a capability (sse|stream|buffer
with the green-tea logo and streams a rotating zen message over `@Sse('/zen')`.
Open the browser and it's already alive — `matcha run` boots it.
The graph is composed in `src/app.ts`, which exports the app; `src/main.ts`
imports it and binds a port. The split is what lets `matcha graph` and
`matcha explain` read your application without starting a server.
The `@green-tea/core` version is pinned exactly, not with a caret. Core is
prerelease-only, and npm's semver excludes a prerelease from any range whose
comparators carry a different `major.minor.patch` — so `^26.7.0-beta.0` never
resolves past `26.7.0-beta.0` however many betas ship after it. CI scaffolds,
installs, boots and introspects a real starter on every runtime, and a weekly
job fails when the pin falls behind the `beta` dist-tag.
### Introspection
green-tea derives execution order from what each node declares it `needs` and
`provides`, so the graph is a real artifact rather than a diagram someone drew.
`matcha graph` prints it and `matcha explain` prints one route's slice of it.
```bash
matcha graph # Mermaid (default)
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
```
Both import `src/app.ts` (override with `--entry`) and call `app.ready()`, which
resolves the graph and deliberately does **not** run provider factories — asking
for a diagram will not open your database connections. Your dependencies have to
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.
### `create` / `add` auto-wiring
`create` and `add` edit your TypeScript with tree-sitter: they insert imports
@@ -63,6 +98,18 @@ idempotent and revert themselves if they would break the file's syntax. Pass
Edge is a deploy target, not a `matcha run` target.
## Development
```bash
cargo test # unit + CLI integration
scripts/starter-smoke.sh node # scaffold, install, type-check, boot, introspect
scripts/starter-smoke.sh deno # (also bun) — needs that runtime installed
```
`starter-smoke.sh` is the check that `cargo test` cannot be: `cargo test` proves
the CLI writes the files it means to write, not that those files describe a
project the current core will run.
## License
MIT — same as the green-tea framework. Contributions require a DCO sign-off (`git commit -s`).