Repository navigation
fix(cli): print the same template source that copy writes - #6870
Conversation
astryx template <name> printed the file as it is on disk, while astryx template <name> <path> swapped demo media that only Astryx previews serve for a placeholder. The show leaf now runs the same swap, so both return the same source.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression15 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Thanks — this fixes a real trap: printing a template and pasting it kept demo-media paths that only Astryx previews serve, while scaffolding the same template already replaced them. The two paths now return identical source for every template, previews still show the real media, and the response descriptions match the new behaviour.
No changes needed from this review.
[Automated review]
Show now replaces demo media the way copy does, so it reports the count the way #6567 has copy report it: demoMediaReplaced on template.show, and in text a stderr line in the copy receipt wording so stdout stays the exact source. The helper replaceDemoMedia sits beside stripTemplateAssetRefs in the template adapter.
There was a problem hiding this comment.
Thanks — this fixes a real trap: printing a template and pasting it kept demo-media paths that only Astryx previews serve, while scaffolding the same template already replaced them. The two paths now return identical source for every template, the new demoMediaReplaced count says how many references were replaced (in JSON, and on stderr in text mode so stdout stays exactly the source), and the response type, docs, and generated README all describe the corrected behaviour. Previews, copy, and skeleton output are unchanged.
No changes needed from this review.
[Automated review]
demoMediaReplaced counted the drop in /template-assets/ substrings, so one reference whose URL carried a second fixture path counted twice. It now counts the references the replacement pass actually replaces. stripTemplateAssetRefs output is unchanged.
# Conflicts: # packages/cli/README.md
There was a problem hiding this comment.
Thanks — this fixes a real trap: printing a template and pasting it kept demo-media paths that only Astryx previews serve, while scaffolding the same template already replaced them. The two paths now return identical source for every template, the new demoMediaReplaced count says how many references were replaced (in JSON, and on stderr in text mode so stdout stays exactly the source), and the response type, docs, and generated README all describe the corrected behaviour. Previews, copy, and skeleton output are unchanged.
No changes needed from this review.
[Automated review]
…out half Review fix. The count was the drop in '/template-assets/' substrings, so one reference whose query held a second fixture path counted twice. The count now comes from the replacement pass itself (replaceDemoMedia in the template adapter, the same code as #6870, so the two PRs merge cleanly), one per replaced reference. copy.mjs uses it instead of its own helper. The layout half is gone: #6615 removes the layout command, so layout expand no longer gets a receipt field, and the changeset names template only.
…#6567) * fix(cli): say when a template copy replaced demo media Copying a template swaps Astryx demo images and video for placeholders, but the receipt never said so. `template.copy` now reports `demoMediaReplaced`, and the text output names the file whose media the consumer has to supply. * fix(cli): say when layout expand replaced demo media Expanding a layout splices template blocks through the same demo media replacement as a template copy, but `layout.expand` never said so. It now reports `demoMediaReplaced` from the copy path's shared count, and the text output states it, as a trailing comment when the code is printed. * fix(cli): count each replaced demo media reference once; drop the layout half Review fix. The count was the drop in '/template-assets/' substrings, so one reference whose query held a second fixture path counted twice. The count now comes from the replacement pass itself (replaceDemoMedia in the template adapter, the same code as #6870, so the two PRs merge cleanly), one per replaced reference. copy.mjs uses it instead of its own helper. The layout half is gone: #6615 removes the layout command, so layout expand no longer gets a receipt field, and the changeset names template only. * docs(cli): regenerate the README tables on current main * fix(cli): layout expand says when it replaced demo media again #6887 restored the layout command, so the layout half this PR dropped for #6615 applies again: layout expand splices template blocks and replaces their demo media without saying so (AST-028 FR11). This restores it as it was before that drop, with one change: the count comes from replaceDemoMedia in the template adapter, the same pass template copy uses, so one reference counts once however many fixture paths its URL carries. * docs(cli): regenerate the README tables on current main --------- Co-authored-by: Joey Farina <[email protected]>
User impact
astryx template <name>(andtemplate()from@astryxdesign/cli/api) printed a different file thanastryx template <name> <path>writes. 44 of the 714 templates show demo images or video from/template-assets/, which only Astryx's own previews serve. Copy swaps those for a placeholder. Show didn't, so anyone who printed a template and pasted it got broken images. That's the normal way an agent reads a template, and it's the only way to get a template's source through the API without writing a file.Show now prints exactly what copy writes, and it says how many demo media references it replaced, the same way #6567 makes the copy receipt say it.
Problem and solution fit
The show leaf now runs the same replacement copy runs. It goes through
replaceDemoMedia, the same pass asstripTemplateAssetRefsplus a count of the references it replaced, and the count comes back asdemoMediaReplaced. Without the count, show would change the source without saying so.Expected behavior and authority
spec:AST-028FR7: copying a template must drop every Astryx-owned fixture reference, and printing the source is how agents copy it. FR11 has copy disclose what it replaced, and show now does the same.spec:AST-017FR14: no CLI behavior is hidden. The replacement is documented in the function doc, the response types, and the README, and every call reports it.template()is integration blocks, and none of them use demo media.Smallest restoration
api/template/show/show.mjsreturnsreplaceDemoMedia(source), so its source is the same file copy writes.replaceDemoMedialives infoundation/discovery/template-adapter.mjs.stripTemplateAssetRefsnow returns its.source, so the replaced output is unchanged. The count is one per reference the pass replaces. A URL that carries a second fixture path in its query is replaced whole and counts once, and a prose mention or third-party URL it leaves as written counts 0.template.showgainsdemoMediaReplaced: number. It's additive, always present, and 0 when the template carried none.astryx template x > page.tsxstill works. The count goes to stderr in the copy receipt's words, "Replaced N Astryx demo media references: …", and nothing prints when it's 0.templategolden read pick up the field.Copy and skeleton don't change. Skeleton only keeps layout props, so it never carried media paths.
One side effect worth knowing. Each demo image becomes the inline placeholder copy already writes, so the printed source for those 44 templates gets longer. The worst is
library(30 images), which goes from about 15 KB to 35 KB. A shorter placeholder would shrink both outputs, but that's a separate change.Coordination with #6567
#6567 adds the same count to the copy and
layout expandreceipts. Its owner and I agreed on one shape: same field name, same meaning, and the same sentence with the same pluralization. Our first version counted the drop in/template-assets/substrings, which counts one reference twice when its query carries a second fixture path. CodeBunny caught that on #6567, so both PRs now count one per replaced reference. The helper lives once, intemplate-adapter.mjs. If #6567 lands first with its own copy, this PR's rebase removes the duplicate, and the other way round. Git won't flag the duplicate, so that's a deliberate step.Evidence
astryx template libraryprinted 30/template-assets/paths, andastryx template library app/librarywrote placeholders.demoMediaReplaced(30 forlibrary).api/template/show/show.test.mjscompares show and copy for all 714 templates, checks that the count is above 0 exactly when the source changed, and checks a page with a demo image throughtemplate().foundation/discovery/template-adapter.fixture-refs.test.mjspins the count: a reference with a second fixture path in its query counts 1, a poster plus a video counts 2, and a prose mention, a third-party URL, or source with no fixture counts 0. The query case fails against the old substring count.clients/cli/commands/template.show-media.test.mjschecks--jsoncarries the count, text stdout equals the JSON source, stderr states the count, and nothing is said when it's 0.Scope
demoMediaReplaced, is listed above.Testing
On main at 505e3d8 with this branch applied. The branch merges main at 2982c61, and the only commit after 505e3d8 touches the docsite, so these results still hold:
pnpm exec vitest run packages/cli(5,561 passed, 2 expected failures)pnpm check:repo(includescheck:cli-structure)pnpm --filter @astryxdesign/cli typecheck:strict,typecheck:json-api,typecheck:authoring,typecheck:template-docspnpm --filter @astryxdesign/cli readme:checkeslintonpackages/cli/api/template,packages/cli/clients/cli/commands, and the changed foundation filestemplategolden read was updated withvitest run -uand only gained"demoMediaReplaced": 0.