Skip to content

feat(cli): write refs in the short form in export and fmt - #212

Merged
yordis merged 1 commit into
TrogonStack:mainfrom
enilsen16:enilsen16/feat-export-short-refs
Oct 20, 2026
Merged

yordis merged 1 commit into
TrogonStack:mainfrom
enilsen16:enilsen16/feat-export-short-refs

Conversation

@enilsen16

@enilsen16 enilsen16 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The manifest parser accepts slug, ns/slug or ns/slug@version wherever an Id, Ref, Edge or Example goes. But trogon-atlas export and trogon-atlas fmt write the long form ({id: {namespace, slug, version}}). Agents copy that output and write the long form too.

Change

This PR changes the default output format of export and fmt. If you prefer to keep the long form as the canonical form, you can decline this PR.

  • entity_to_manifest now writes each Id, Ref, Edge and Example wrapper as the shortest string that the parser reads back to the same value: slug in the manifest's namespace, ns/slug in a different namespace, and @version only when the version is not 1.
  • The walk follows the proto schema in the same way as the parser. Scenario id strings, Any values and map fields do not change.
  • The object form stays when the wrapper has other fields (for example an edge doc, or EntityRef.kind). It also stays when a string would not read back as the same Id (for example a slug with @ or /, or an empty namespace).
  • The CLI README now says that export and fmt write the short form.

This PR does not change the files in examples/manifests. If you accept this change, a second PR regenerates them with trogon-atlas fmt examples/manifests --write.

Test

  • New unit tests in export.rs. One test makes sure that a command-slice ref exports as command: add-item-to-cart, a ref in a different namespace exports as ns/slug@2, and an edge with a doc stays a mapping. The other test makes sure that an Id whose slug contains @ stays in the long form.
  • fmt_integration.rs already checks parse(fmt(x)) == parse(x) and fmt(fmt(x)) == fmt(x) for every example manifest. It passes with the new output.
  • cargo test -p trogon-atlas-client, cargo test -p trogon-atlas-cli, and clippy with -D warnings on both crates pass.

Closes #85


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae08ff4a-33db-407f-9b80-226cb7ce0e25
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@enilsen16
enilsen16 marked this pull request as ready for review October 20, 2026 15:19
@cursor

cursor Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Output-format change only for YAML emission; parsing and apply semantics are unchanged, with round-trip and idempotency tests already in place.

Overview
trogon-atlas export and fmt now emit manifest refs in the same short string form the parser accepts, instead of defaulting to expanded {namespace, slug, version} objects.

entity_to_manifest walks each entity spec with a new compact_message pass (proto-schema-driven, mirroring parse-time normalization). Ids become slug, ns/slug, or ns/slug@version when safe; single-field Ref/Edge/Example wrappers collapse to that string. Mappings are kept when extra fields exist (e.g. edge doc) or when a string would round-trip differently (e.g. slugs containing @). Scenario id strings, maps, and google.protobuf.* values are unchanged.

The CLI README documents this canonical output. Unit tests cover short-form export and the long-form fallback case.

Reviewed by Cursor Bugbot for commit 02a492b. Bugbot is set up for automated code reviews on this repo. Configure here.

@yordis
yordis merged commit 2dfc923 into TrogonStack:main Oct 20, 2026
28 checks passed
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.

Use the short ref form in examples and export

2 participants