Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
721d581
docs: add graph command design spec
kanoru3101 Jun 11, 2026
0d92261
docs: add graph command implementation plan
kanoru3101 Jun 11, 2026
64d9632
feat: add dependency graph builder for graph command
kanoru3101 Jun 11, 2026
5e061ab
docs: sync graph plan with review fixes (slash, ResolveError, typeche…
kanoru3101 Jun 11, 2026
a9a894e
feat: add affected-files filter for graph command
kanoru3101 Jun 11, 2026
d5edfc5
feat: add graph command output renderers
kanoru3101 Jun 11, 2026
09d4e63
docs: reconcile mermaid label escaping in graph spec with implementation
kanoru3101 Jun 11, 2026
94b72e4
feat: register graph command in CLI
kanoru3101 Jun 11, 2026
3acea63
docs: document repeated --affected-by flag syntax in graph spec and plan
kanoru3101 Jun 11, 2026
a725935
test: add graph command e2e tests
kanoru3101 Jun 11, 2026
3b65a51
docs: document graph command and add changeset
kanoru3101 Jun 11, 2026
4afc761
docs: align spec warning wording with implementation
kanoru3101 Jun 11, 2026
b02b2f2
docs: add tree command rework spec and plan
kanoru3101 Jun 12, 2026
5cbdc48
refactor: rename graph command to tree
kanoru3101 Jun 12, 2026
643906d
feat: add pointer-to-node mapping for the tree structure view
kanoru3101 Jun 12, 2026
0fd392e
feat: add internal-structure builder for the tree command
kanoru3101 Jun 12, 2026
6c9072f
refactor: make stylish summary and empty message caller-provided
kanoru3101 Jun 12, 2026
9473d77
feat: match affected-by inputs against tree nodes
kanoru3101 Jun 12, 2026
f9a14d5
feat: make document structure the default tree view behind --files fa…
kanoru3101 Jun 12, 2026
d6e2caa
test: cover tree structure mode end to end
kanoru3101 Jun 12, 2026
8c77337
docs: document the tree command and update the changeset
kanoru3101 Jun 12, 2026
649e927
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 12, 2026
5730de6
fix: hoist entity test imports to avoid per-test transform timeout
kanoru3101 Jun 12, 2026
5eec56f
docs: unbreak documentation tests for the tree command
kanoru3101 Jun 15, 2026
da60c95
refactor(tree): share toNodeId/byString/OPERATION_METHODS via node-id
kanoru3101 Jun 15, 2026
c9fe0d7
fix: improvments
kanoru3101 Jun 15, 2026
93b9830
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 17, 2026
49904e3
refactor: tidy tree renderer sort and trim a restating comment
kanoru3101 Jun 17, 2026
a25a166
test: drop redundant tree tests (runtime round-trip, path.resolve var…
kanoru3101 Jun 17, 2026
d63acb4
docs: clarify --affected-by per mode and JSON field scope in tree docs
kanoru3101 Jun 17, 2026
d9eb1f4
test: cover multi-API rejection in default view and multi-API --files…
kanoru3101 Jun 17, 2026
2bfb339
fix: tidy tree command — share mode context, dedupe location mapping,…
kanoru3101 Jun 17, 2026
0fe4623
Merge remote-tracking branch 'origin/main' into feat/graph-command
kanoru3101 Jun 17, 2026
619ada1
fix: remove comments
kanoru3101 Jun 17, 2026
0a49e51
Merge remote-tracking branch 'origin/main' into feat/graph-command
kanoru3101 Jun 22, 2026
a9845ec
fix: refactoring
kanoru3101 Jun 22, 2026
2748189
fix: resolve bug with splitted files
kanoru3101 Jun 22, 2026
d45ab50
fix: update tests
kanoru3101 Jun 22, 2026
9afbdc0
Apply suggestions from code review
JLekawa Jun 23, 2026
c3c29af
Update tree.md
JLekawa Jun 23, 2026
21ccf18
Update docs/@v2/commands/tree.md
JLekawa Jun 23, 2026
808714d
docs(cli): fix issues in file
JLekawa Jun 23, 2026
cafbab8
Apply suggestion from @JLekawa
JLekawa Jun 23, 2026
cc10b6a
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 23, 2026
1ec983f
fix: add spaces in the options-table separator
kanoru3101 Jun 23, 2026
eeede48
fix: refactoring and update snapshots
kanoru3101 Jun 24, 2026
b2df52d
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 24, 2026
ed18a16
fix: update docs
kanoru3101 Jun 24, 2026
a3a9227
Merge branches 'feat/graph-command' and 'feat/graph-command' of githu…
kanoru3101 Jun 24, 2026
7df48d3
fix: resolve cursor bugs
kanoru3101 Jun 24, 2026
7565984
fix: update docs
kanoru3101 Jun 24, 2026
518e767
Merge branch 'main' into feat/graph-command
kanoru3101 Jun 25, 2026
ebbcc71
chore: small fixes
kanoru3101 Jun 26, 2026
16fbb5b
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 1, 2026
e75f4bb
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 2, 2026
314e9dc
feat: add level flag
kanoru3101 Jul 13, 2026
879a918
test: add snapshot
kanoru3101 Jul 13, 2026
7031128
Merge branch 'main' into feat/graph-command
kanoru3101 Jul 13, 2026
8e15c82
feat(tree): show operationId on operation nodes
kanoru3101 Jul 16, 2026
890b336
docs(tree): fix options table having a stray fourth column
kanoru3101 Jul 17, 2026
b72d3d2
feat(core): add api-graph node model and node-id mapping
kanoru3101 Aug 1, 2026
79be267
feat(core): add api-graph builder walking the original document
kanoru3101 Aug 1, 2026
67dabde
refactor(cli): back the tree structure view with the core api-graph
kanoru3101 Aug 1, 2026
849d289
test(cli): update split-fixture tree snapshots for real source files
kanoru3101 Aug 1, 2026
badc7c6
fix(core): attribute foreign-file ref edges to their spine operation
kanoru3101 Aug 1, 2026
369815e
docs(cli): document unbundled tree structure view
kanoru3101 Aug 1, 2026
2fb842c
docs(cli): fix remaining bundling-era statements in tree reference
kanoru3101 Aug 1, 2026
9a708c5
fix(cli): align uses docs, e2e titles, and callback-ref test with unb…
kanoru3101 Aug 1, 2026
442dfd7
feat(core): collect index metadata in the api-graph walk
kanoru3101 Aug 1, 2026
c0adb41
feat(core): assemble the hierarchical api index from walk metadata
kanoru3101 Aug 1, 2026
0153e3c
refactor(core): inline single-use docDescription spread helper
kanoru3101 Aug 1, 2026
8b8d43c
feat(core): add api-graph retrieval slice with envelopes and refs
kanoru3101 Aug 1, 2026
9dfdd20
fix(core): share path normalization between index and retrieval slice
kanoru3101 Aug 1, 2026
9b0beda
feat(core): add dependency closure to api-graph envelopes
kanoru3101 Aug 1, 2026
6b3e051
fix(core): gate deps-closure seeds and restrict file aliasing to comp…
kanoru3101 Aug 1, 2026
f41c4da
feat(cli): render the agent index for tree --format json
kanoru3101 Aug 1, 2026
fdf18e4
refactor(core): consolidate component-section list into one export
kanoru3101 Aug 1, 2026
842b842
fix(cli): keep split components and warn about webhooks in uses-filte…
kanoru3101 Aug 3, 2026
d1d321c
feat(cli): add --node retrieval and --with-deps closure to tree
kanoru3101 Aug 3, 2026
c1e680a
fix(cli): match components by file only when split from the root docu…
kanoru3101 Aug 3, 2026
39fd095
fix(cli): apply --level as-is to --node sub-indexes and add the chang…
kanoru3101 Aug 3, 2026
4beb2d9
refactor: consolidate tree changesets, drop interim wrappers, documen…
kanoru3101 Aug 3, 2026
74e4b8e
docs(cli): complete tree usage and options for the agent index flags
kanoru3101 Aug 3, 2026
072800d
Merge remote-tracking branch 'origin/main' into feat/tree-v2
kanoru3101 Aug 3, 2026
26a35f3
feat(core): keep canonical component ids for split whole-file refs
kanoru3101 Aug 3, 2026
f5257d1
docs: add a guide measuring agent context savings from the tree index
kanoru3101 Aug 3, 2026
b616f1c
docs: state that the JSON index requires an OpenAPI description
kanoru3101 Aug 3, 2026
e248d68
docs: add Google Compute and GitHub scaling cases to the tree index b…
kanoru3101 Aug 4, 2026
db69271
docs: list the tree benchmark guide on the guides index
kanoru3101 Aug 4, 2026
55bd506
fix(core): take the tree index Servers section from the root server list
kanoru3101 Aug 4, 2026
ad2690a
docs: rebuild the tree index benchmark on the GitHub REST API descrip…
kanoru3101 Aug 4, 2026
c3854da
feat(core): add typed selection lookups for the api graph
kanoru3101 Aug 5, 2026
3ae33ff
feat(core): add reverse ref chains and shared node ref collection
kanoru3101 Aug 5, 2026
3cb69f0
feat(core): add overview and listing views over the api graph
kanoru3101 Aug 5, 2026
20d0890
feat(core): add operation and component cards with typed refs and usedBy
kanoru3101 Aug 5, 2026
5f05a6d
feat(core): add transitive used-by report and export the view api
kanoru3101 Aug 5, 2026
d1561e5
feat(cli): route tree through typed selectors
kanoru3101 Aug 5, 2026
8c86be8
feat(cli): render tree views and drop the node/uses/level surface
kanoru3101 Aug 5, 2026
632823c
test(e2e): pin the typed-selector tree surface
kanoru3101 Aug 5, 2026
e00ed11
docs: document the typed-selector tree surface
kanoru3101 Aug 6, 2026
def0c79
docs: re-measure the benchmark on the typed-selector surface
kanoru3101 Aug 6, 2026
a47c1f9
fix: close webhook and consistency gaps found in the tree final review
kanoru3101 Aug 6, 2026
43d6e73
feat(core): named webhooks, card-shaped listings, and the file view
kanoru3101 Aug 6, 2026
95b6f38
feat(cli): tree-glyph stylish views, --file selector, and --webhooks …
kanoru3101 Aug 6, 2026
ab40807
test(e2e): pin the revision-2 tree surface
kanoru3101 Aug 6, 2026
1a01d9e
docs: document the revision-2 tree surface and re-measure the benchmark
kanoru3101 Aug 6, 2026
0aac400
perf(core): index line offsets and graph lookups for tree views
kanoru3101 Aug 6, 2026
edb9a47
docs: add a live agent run to the tree benchmark
kanoru3101 Aug 6, 2026
9190aac
docs: add multi-operation workflow runs to the live tree benchmark
kanoru3101 Aug 6, 2026
8785f36
feat(cli): expand the default tree to operations and render cards as …
kanoru3101 Aug 7, 2026
0b26198
docs: measure the hybrid stylish-navigation chain in the tree benchmark
kanoru3101 Aug 7, 2026
0ec5a8b
docs: add an unguessable hard-task live run to the tree benchmark
kanoru3101 Aug 7, 2026
0190078
docs: add a tree-versus-grep head-to-head live run to the benchmark
kanoru3101 Aug 7, 2026
9417dab
docs: compare whole-spec-in-context against tree in the live benchmark
kanoru3101 Aug 7, 2026
ed17ef7
docs: add a free-method no-tree baseline to the benchmark comparison
kanoru3101 Aug 7, 2026
3661f64
docs: measure the no-instruction automatic-discovery run in the bench…
kanoru3101 Aug 7, 2026
4973ee1
feat(cli): collapse the default tree to tag counts past 100 operations
kanoru3101 Aug 7, 2026
0d821dc
docs: run the synthetic private-spec test and withdraw the refuted claim
kanoru3101 Aug 8, 2026
b3b6388
feat(cli): add --brief and --compact to cut tree JSON costs
kanoru3101 Aug 8, 2026
cc456fb
docs: measure the brief-compact chain and the trusted used-by protocol
kanoru3101 Aug 8, 2026
f706e73
feat(cli): fold brief and compact into a third tree output format
kanoru3101 Aug 8, 2026
5bd1a4b
docs: retarget the benchmark protocol to the brief output format
kanoru3101 Aug 8, 2026
7a5007b
docs: document the tree exploration protocol for AI assistants
kanoru3101 Aug 9, 2026
98dcd38
docs: measure how instruction placement changes agent cost
kanoru3101 Aug 9, 2026
36e5f58
docs: separate compactness ratios from head-to-head session costs in …
kanoru3101 Aug 9, 2026
899f79c
feat(cli): replace the brief format with an ai format that emits sche…
kanoru3101 Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/tree-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@redocly/openapi-core': minor
'@redocly/cli': minor
---

Added the experimental `tree` command: it prints an overview of an API description as a tree — its servers, every tag and webhook down to their individual operations, and component sections — and lets you drill into one tag, path, webhook, operation, component, or file with `--tag`, `--path`, `--webhook`, `--operation`, `--component`/`--name`, and `--file`, with every result attributed to the file that defines it.
`--paths`, `--operations`, and `--webhooks` list the whole API surface, each entry already carrying its own typed one-hop `refs` and `usedBy`; `--used-by` runs impact analysis (which operations and components depend on a selection, including everything a whole file defines); `--with-deps` appends an operation's or component's transitive `$ref` closure. An operation or component selection renders as a tree too — coordinates, then `refs`/`usedBy`/`deps` as branches — with no raw source in the terminal output.
`--format=json` prints the same selection as machine-readable data — stable ids, JSON pointers, source files, line ranges, summaries, and (with `--with-deps`) raw source, all taken from the description itself; `--files` shows the file-level `$ref` graph, optionally filtered to one file's neighborhood with `--file`.
`--format=ai` is the agent format: it trims listing views (`--tag`, `--path`/`--webhook`, `--operations`, `--webhooks`, `--component`, and a `--file` card's `defines`) to one compact entry per item (method, path, summary, line range), serializes every view without indentation, and turns a `--with-deps` closure into compact schema signatures — required fields, types, enums, and `$ref` targets — instead of raw YAML, with anything more than two `$ref` hops away listed as a bare id instead of a body; on a large listing the projection and indentation cuts together save over 90%, and a schema-heavy `--with-deps` closure can shrink by a similar margin.
The underlying engines live in `@redocly/openapi-core`'s new `api-graph` module (`analyzeApi`, `buildOverview`, `buildOperationCard`, `buildUsedByReport`, `buildFileCard`).
16 changes: 16 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ The root `npm run compile` runs both steps: tsc for core/respect-core, then the

The published CLI package ships from a staged `.publish/` directory (created by `packages/cli/scripts/prepare-publish-dir.mjs`) with a hand-crafted `package.json` that has zero runtime dependencies — everything is bundled.

## Explore an API description with `tree`

API descriptions are often too large to read directly — the OpenAPI descriptions used in this repository's benchmarks run to millions of tokens.
Use [`tree`](./docs/@v2/commands/tree.md) to walk one in bounded steps instead of reading or grepping the file:

```bash
redocly tree <file> --format=ai # overview: tags, webhooks, component sections
redocly tree <file> --tag=<tag> --format=ai # one tag's operations
redocly tree <file> --path=<path> --operation=<method> --with-deps --format=ai # one operation with its full $ref closure, as schema signatures
redocly tree <file> --component=<section> --name=<Name> --used-by --format=ai # what breaks if this component changes
```

`--format=ai` is the agent format: projected listings, no indentation, and schema signatures instead of raw YAML in a `--with-deps` closure.
`--used-by` returns the complete transitive dependency graph with a `via` chain per entry, so walking `$ref`s by hand is unnecessary.
Every result carries the defining `file` and `start_line`/`end_line`, so any answer can be checked against the source it came from.

## Respect the architecture: Walker, Visitors, Nodes

Linting in `packages/core` rests on three concepts: the **Walker** traverses the parsed API description and resolves `$ref`s, **Visitors** are objects keyed by **Node** type, and the Walker calls each visitor's `enter` / `leave` / `skip` hooks as it reaches a node.
Expand Down
1 change: 1 addition & 0 deletions docs/@v2/commands/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ API management commands:
- [`score`](score.md) Score an API for integration simplicity and AI agent readiness.
- [`split`](split.md) Split API description into a multi-file structure.
- [`stats`](stats.md) Gather statistics for a document.
- [`tree`](tree.md) Display the structure of an API description as a tree.

Linting commands:

Expand Down
1,774 changes: 1,774 additions & 0 deletions docs/@v2/commands/tree.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/@v2/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ Authenticate, handle errors, and compose middleware with a client from `generate
Pre-configure publisher defaults and write custom client generators.
{% /card %}

{% card title="Agent context costs with tree"
to="./tree-agent-index-benchmark"
%}
Measured token counts for exploring GitHub's 10.0 MB REST API description with `tree`, compared against reading the whole file and against searching it with `grep`.
{% /card %}

{% card title="Set up tab completion"
to="./autocomplete"
%}
Expand Down
Loading
Loading