Repository navigation
Generate API commands from the OpenAPI spec - #29
Closed
dennis-chen-vanta wants to merge 4 commits into
Closed
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 <[email protected]>
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 <[email protected]>
- 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 <[email protected]>
- `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 <[email protected]>
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 was referenced Oct 26, 2026
Contributor
Author
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 #31.
Summary
Adds the generator for the API commands in
src/commands/, so they're regenerated fromapi-spec.jsoninstead of edited by hand.scripts/codegen/derives every command using the conventions in AGENTS.md, one module per stage:main.tsspec.tsnaming.tsvendors list-findings)options.tshelp.tsgroups.tsrender.tsindex.tswords.tsconfig.tspnpm generate:commandsregeneratessrc/commands/.Command changes
// Code generated by \pnpm generate:commands`. DO NOT EDIT.` header. The generator uses it to remove files for groups that no longer exist.trust-centers download-resource-mediapassesparseAs: "blob", as fix csv file downloads #30 did fordocuments download-file-media. The generator adds it to every download, which keeps fix csv file downloads #30's fix when the files are regenerated.No other lines in
src/commands/change, and--helpfor all 276 commands is identical tomain.Test plan
pnpm generate:commandsleavessrc/commands/unchanged;pnpm format:check,pnpm typecheck, andpnpm test(21/21) pass.mainand this branch and compared--helpfor every command: identical.🤖 Generated with Claude Code