Repository navigation
Generate API commands from the OpenAPI spec - #29
Open
dennis-chen-vanta wants to merge 4 commits into
Open
dennis-chen-vanta wants to merge 4 commits into
dennis-chen-vanta wants to merge 4 commits into
Conversation
|
Semgrep found 6
🟡 Medium severity issue identified in your code: RegExp() called with a View Dataflow Graphflowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>scripts/codegen/generate-commands.ts</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L141 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 141] word</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L141 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 141] word</a>"]
v3["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L152 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 152] singularize</a>"]
v4["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L152 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 152] words</a>"]
v5["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L489 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 489] singular</a>"]
v6["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L489 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 489] own</a>"]
v7["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L490 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 490] `</a>"]
end
v2 --> v3
v3 --> v4
v4 --> v5
v5 --> v6
v6 --> v7
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/OpenVanta/cli/blob/17b4866451a6c346bce42c8d5d32f49600520186/scripts/codegen/generate-commands.ts#L490 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 490] new RegExp(`-(to|from|for)-${own}$`)</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
|
dennis-chen-vanta
force-pushed
the
dennis-chen-vanta/cli-command-structure
branch
from
October 21, 2026 17:46
680d6c8 to
aebb6f2
Compare
dennis-chen-vanta
force-pushed
the
dennis-chen-vanta/command-codegen
branch
from
October 21, 2026 17:46
9172332 to
0a3dbec
Compare
Add scripts/codegen/generate-commands.ts, which derives every API command in src/commands/ from api-spec.json using the conventions in AGENTS.md. Exceptions to the rules and help text overrides live in scripts/codegen/config.ts. - `pnpm generate:commands` regenerates src/commands/ - CI fails if the generated commands are out of date - Generated files are marked with a "Code generated" header; the generator removes generated files for groups that no longer exist The generated output matches the previous commit apart from the header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Semgrep flags `new RegExp` built from a path segment (detect-non-literal-regexp). Compare the suffix as a string instead; generated output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Resolve every $ref once when the spec loads, instead of calling deref() wherever a schema is read - Type the parts of the OpenAPI spec the generator reads; no `any` - Keep groups in a map keyed by CLI path instead of a tree with a fake root node - Clearer names (`placement`, `topGroup`, `valueSchema`) Generated commands are byte-for-byte identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `links` in config.ts lists operations that attach or detach an existing resource; the generator names them add/remove. The spec can't mark these itself, since its summaries also say "Add" for creates. - GETs that return a file use `download`. - `commandPlural` lets `uploads` read as `files` in list commands. - Drops the overrides that shortened names repeating the group (`list-library`, `list-deactivated`, `add-document`, `add-test`). - Removes mounts: every group is its path's first segment, so the generator no longer nests groups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dennis-chen-vanta
force-pushed
the
dennis-chen-vanta/command-codegen
branch
from
October 21, 2026 19:11
0a3dbec to
80902d0
Compare
dennis-chen-vanta
force-pushed
the
dennis-chen-vanta/cli-command-structure
branch
from
October 21, 2026 19:11
aebb6f2 to
866696d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #28.
Summary
Adds the generator that produced the commands in #28, so they're regenerated from
api-spec.jsoninstead of edited by hand.scripts/codegen/generate-commands.tsderives every API command insrc/commands/from the OpenAPI spec using the conventions in AGENTS.md. It reads each operation, names it (<group> <verb>-<noun>), turns its inputs into flags, writes help text, and renders one file per command group plusindex.ts.scripts/codegen/config.tsholds what the rules can't derive: top-level order, display names, the words that mark an action, the operations that attach or detach an existing resource (namedadd/remove), 2 command-name overrides, and help text that reads better than the generated default. Each entry says why it exists.pnpm generate:commandsregeneratessrc/commands/.The generator fails on duplicate command names and on help-text overrides that are stale or repeat the default.
Command changes
None. The only change to
src/commands/is a// Code generated by scripts/codegen/generate-commands.ts. DO NOT EDIT.header on each generated file. The generator uses that header to find and remove files for groups that no longer exist.Test plan
pnpm generate:commandsleavessrc/commands/unchanged (the new CI check), andpnpm typecheckandpnpm test(21/21) pass.mainin Document command structure conventions and restructure commands to match #28, including dry-run, a local mock API, and the staging API (reads compared withmain; write lifecycles on test resources). This PR's output is identical apart from the headers.🤖 Generated with Claude Code