Skip to content

Add ComponentPlan CLI commands#90

Merged
madawei2699 merged 1 commit into
mainfrom
codex/component-cli-agent-toolkit
Jun 16, 2026
Merged

Add ComponentPlan CLI commands#90
madawei2699 merged 1 commit into
mainfrom
codex/component-cli-agent-toolkit

Conversation

@madawei2699

Copy link
Copy Markdown
Contributor

Summary

  • add craftdag component commands for validate, expand, compile, materials, layers, support, and schem export
  • emit machine-readable JSON for validation, materials, layers, and support agent loops
  • update the agent toolkit docs to describe the implemented ComponentPlan CLI contract

Closes #54
Closes #55

Validation

  • pnpm --filter @i365dev/craftdag-core build
  • pnpm --filter @i365dev/craftdag-cli build
  • pnpm --filter @i365dev/craftdag-cli typecheck
  • pnpm --filter @i365dev/craftdag-core typecheck
  • pnpm --filter @i365dev/craftdag-cli test
  • pnpm --filter @i365dev/craftdag-core test
  • pnpm lint

@madawei2699 madawei2699 merged commit 828646a into main Jun 16, 2026
1 check passed
@madawei2699 madawei2699 deleted the codex/component-cli-agent-toolkit branch June 16, 2026 14:03

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/cli/src/index.ts
Comment on lines +166 to +169
.action((file, options) => {
const doc = readJsonFile(file);
try {
validateComponentPlan(doc);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
.action((file, options) => {
const doc = readJsonFile(file);
try {
validateComponentPlan(doc);
.action((file, options) => {
try {
const doc = readJsonFile(file);
validateComponentPlan(doc);

Comment thread packages/cli/src/index.ts
Comment on lines +283 to +289
} 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}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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}`);
      }

Comment thread packages/cli/src/index.ts
Comment on lines +314 to +315
const dataVersion = options.dataVersion ? Number(options.dataVersion) : undefined;
const buffer = exportToSchematic(plan, { dataVersion });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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 });

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/cli/src/index.ts
.argument("<file>", "path to the ComponentPlan JSON file")
.option("--json", "emit machine-readable JSON")
.action((file, options) => {
const doc = readJsonFile(file);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Future: Make CraftDAG toolkit friendly to harness agents Create comprehensive LLM authoring pack for ComponentPlan generation

1 participant