Skip to content

Conversation

amikofalvy
Copy link
Collaborator

Summary

Implements comprehensive validation for inkeep pull that ensures generated TypeScript files can be serialized back to match the original backend data.

This addresses the duplication issue where pull validation logic was reimplementing parts of push conversion logic. Now both commands share the same serialization path.

Changes

Core Utilities

  • Shared Project Loader (agents-cli/src/utils/project-loader.ts)

    • Extracted loadProject() function used by both push and pull commands
    • Eliminates code duplication between commands
  • Deep JSON Comparison (agents-cli/src/utils/json-comparison.ts)

    • Compares two FullProjectDefinition objects field-by-field
    • Ignores computed/timestamp fields
    • Provides detailed error messages showing exact differences

Validation

  • Round-Trip Validation (in pull.ts)
    • Loads generated TypeScript using the same logic as inkeep push
    • Serializes back to JSON via project.getFullDefinition()
    • Compares with original backend data
    • Two-stage validation:
      1. Basic file verification (file existence, structure)
      2. Round-trip validation (TS → JSON conversion accuracy)

Updated Commands

  • Pull Command

    • Now performs comprehensive two-stage validation
    • Provides clear, actionable error messages
    • Catches LLM generation issues immediately
  • Push Command

    • Uses shared loadProject() utility
    • Consistent with pull command implementation

Testing & Documentation

  • Comprehensive Test Suite (agents-cli/src/commands/__tests__/pull-validation.test.ts)

    • 11 tests covering all validation aspects
    • All tests passing ✅
  • Updated Documentation (agents-docs/content/docs/typescript-sdk/cli-reference.mdx)

    • Added "Validation Process" section
    • Explains both validation stages with examples

Benefits

Eliminates Duplication - Reuses toFullProjectDefinition() logic from push
Better Validation - Ensures generated TS is actually correct
Catches Errors Early - LLM generation issues detected before push
Maintainability - Single source of truth for TS → JSON conversion
Confidence - Guarantees pull → push round-trip works correctly

Testing

  • All tests pass (11/11 new tests)
  • TypeScript compilation successful
  • Build completes without errors
  • All pre-push checks pass
  • Documentation updated

Example Output

Success:

✓ Basic file verification passed
✓ Round-trip validation passed - generated TS matches backend data

Failure:

✗ Round-trip validation failed

❌ Round-trip validation errors:
   The generated TypeScript does not serialize back to match the original backend data.
  • Value mismatch at agents.my-agent.name: "Original Name" vs "Generated Name"
  • Missing tool in generated: tool-id

🤖 Generated with Claude Code

Copy link

changeset-bot bot commented Oct 16, 2025

⚠️ No Changeset found

Latest commit: 7a0c95c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
agents-docs Ready Ready Preview Comment Oct 16, 2025 9:40am
agents-manage-api Ready Ready Preview Comment Oct 16, 2025 9:40am
agents-manage-ui Ready Ready Preview Comment Oct 16, 2025 9:40am
agents-run-api Ready Ready Preview Comment Oct 16, 2025 9:40am

Implement comprehensive validation that ensures generated TypeScript
files can be serialized back to match the original backend data.

Changes:
- Extract shared loadProject() utility used by both push and pull
- Add deep JSON comparison utility for project definitions
- Implement round-trip validation in pull command
- Add two-stage validation: basic file check + round-trip
- Update push command to use shared project loader
- Add comprehensive test suite (11 tests, all passing)
- Update CLI documentation with validation process details

Benefits:
- Eliminates code duplication between push/pull commands
- Ensures generated TS matches backend data exactly
- Catches LLM generation errors immediately
- Validates pull → push round-trip works correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

1 participant