Skip to content

Fix validate command: unify CLI/TUI logic, add missing schema checks, improve TUI screen #12

@aidandaly24

Description

@aidandaly24

Summary

The agentcore validate command has divergent behavior between CLI mode and TUI mode, missing schema validations in CLI mode, and duplicated business logic. The TUI validate screen also has UX issues (empty next steps, no suggested actions on success).

Current Behavior

CLI mode (agentcore validate)

  • Only validates 3 files: agentcore.json, aws-targets.json, .cli/state.json
  • Missing validation of: mcp.json and mcp-defs.json
  • Returns on first error — doesn't report all validation failures
  • No --json flag for CI/CD usage
  • registerValidate not re-exported from src/cli/commands/index.ts (inconsistency with all other commands)

TUI mode (validate screen)

  • Validates 5 files (correct set): agentcore.json, aws-targets.json, mcp.json, mcp-defs.json, .cli/state.json
  • Reimplements validation logic independently instead of calling handleValidate() from action.ts
  • NextSteps component passes empty steps={[]} — no suggested actions after validation
  • No tests for ValidateScreen.tsx

The problem

Running agentcore validate from the command line reports success even when mcp.json or mcp-defs.json are malformed. Only the TUI catches those errors. This is especially bad for CI/CD pipelines (agentcore validate && agentcore deploy -y --json).

Expected Behavior

  1. CLI and TUI validate the same set of files (all 5 config files)
  2. Single source of truth: TUI screen calls handleValidate() instead of reimplementing
  3. Report all errors instead of stopping on the first failure
  4. Suggest next steps in TUI (e.g., "Run deploy to deploy your agent" on success)

Files to Modify

File Change
src/cli/commands/validate/action.ts Add mcp.json and mcp-defs.json validation. Return all errors (not just first). Export a step-level result type the TUI can consume.
src/cli/commands/validate/command.tsx Display all errors, not just the first
src/cli/tui/screens/validate/ValidateScreen.tsx Refactor to call handleValidate() instead of reimplementing. Map results to StepProgress UI. Add meaningful next steps (e.g., deploy).
src/cli/commands/validate/index.ts Ensure all new types are exported
src/cli/commands/index.ts Add missing registerValidate re-export
src/cli/commands/validate/__tests__/action.test.ts Add tests for mcp.json and mcp-defs.json validation

Acceptance Criteria

  • agentcore validate validates all 5 config files (agentcore.json, aws-targets.json, mcp.json, mcp-defs.json, .cli/state.json)
  • CLI and TUI produce consistent validation results
  • TUI validate screen reuses handleValidate() — no duplicated validation logic
  • All validation errors are reported (not just the first)
  • TUI shows "deploy" as a suggested next step on successful validation
  • registerValidate is re-exported from src/cli/commands/index.ts
  • Unit tests cover mcp.json and mcp-defs.json validation paths
  • Existing integration tests still pass

Technical Notes

  • ConfigIO already supports all 5 config types via readAndValidate() with Zod schemas
  • The StepProgress component in the TUI screen can be driven from handleValidate() results if the return type includes per-file status
  • Consider making handleValidate() return { results: Array<{ file: string, success: boolean, error?: string }> } instead of a single { success, error } — this gives both CLI and TUI granular results
  • mcp.json and mcp-defs.json may not exist in all projects (they're optional) — handle missing files gracefully (skip or warn, don't fail)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions