Add ComponentPlan CLI commands#90
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new component command group to the CLI, enabling validation, expansion, compilation, material listing, layer analysis, support diagnostics, and schematic export for ComponentPlan JSON files. It also updates the documentation and adds comprehensive integration tests. The feedback suggests improving error handling for JSON parsing under the --json flag, printing detailed diagnostic summaries instead of just counts in the human-readable support command output, and validating the --data-version option to prevent potential failures from NaN values.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| .action((file, options) => { | ||
| const doc = readJsonFile(file); | ||
| try { | ||
| validateComponentPlan(doc); |
There was a problem hiding this comment.
To ensure that file-reading and JSON-parsing errors are properly caught and formatted as machine-readable JSON when --json is enabled, readJsonFile should be refactored to throw errors instead of calling process.exit(1) directly, and its invocation should be moved inside the try block.
| .action((file, options) => { | |
| const doc = readJsonFile(file); | |
| try { | |
| validateComponentPlan(doc); | |
| .action((file, options) => { | |
| try { | |
| const doc = readJsonFile(file); | |
| validateComponentPlan(doc); |
| } else { | ||
| console.log(`Support diagnostics: ${result.diagnostics.length}`); | ||
| console.log(`Total blocks: ${result.totalBlocks}`); | ||
| console.log(`Vertical unsupported blocks: ${result.verticalUnsupportedBlocks}`); | ||
| console.log(`Disconnected blocks: ${result.disconnectedBlocks}`); | ||
| console.log(`Large cantilever blocks: ${result.largeCantileverBlocks}`); | ||
| } |
There was a problem hiding this comment.
When running the support command without the --json flag, only the counts of diagnostics are printed, making it difficult for a human user to identify which components have issues or where they are located. Printing a brief summary of each diagnostic improves usability for local debugging.
} else {
console.log(`Support diagnostics: ${result.diagnostics.length}`);
for (const d of result.diagnostics) {
console.log(` - [${d.code}] ${d.message} (Component: ${d.componentId ?? "unknown"})`);
}
console.log(`Total blocks: ${result.totalBlocks}`);
console.log(`Vertical unsupported blocks: ${result.verticalUnsupportedBlocks}`);
console.log(`Disconnected blocks: ${result.disconnectedBlocks}`);
console.log(`Large cantilever blocks: ${result.largeCantileverBlocks}`);
}| const dataVersion = options.dataVersion ? Number(options.dataVersion) : undefined; | ||
| const buffer = exportToSchematic(plan, { dataVersion }); |
There was a problem hiding this comment.
If the user passes an invalid string to --data-version (e.g., --data-version abc), Number(options.dataVersion) will evaluate to NaN. Passing NaN to exportToSchematic can lead to silent failures or corrupt schematic files. Adding a validation check prevents this.
const dataVersion = options.dataVersion ? Number(options.dataVersion) : undefined;
if (dataVersion !== undefined && isNaN(dataVersion)) {
throw new Error(`Invalid data-version: ${options.dataVersion}`);
}
const buffer = exportToSchematic(plan, { dataVersion });There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af8f7b0ace
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .argument("<file>", "path to the ComponentPlan JSON file") | ||
| .option("--json", "emit machine-readable JSON") | ||
| .action((file, options) => { | ||
| const doc = readJsonFile(file); |
There was a problem hiding this comment.
Preserve JSON diagnostics for invalid input files
When component validate --json is used with a missing file or malformed JSON, this readJsonFile call exits before the try block can route the failure through writeJsonError, so the command prints plain text like Error parsing JSON file... instead of the documented machine-readable diagnostics. The same pattern appears in the other new component commands, which breaks agent loops for one of the most common failure modes; load the file inside the JSON-aware error path or make readJsonFile throw so these failures also return { ok: false, diagnostics: [...] }.
Useful? React with 👍 / 👎.
Summary
Closes #54
Closes #55
Validation