diff --git a/README.md b/README.md index a6cbbbd..bf8abc1 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ npx skills add @ | `cms-data-modeling-best-practices` | Contentstack Data Modeling Best Practices | CMS | Content type design, references, global fields, groups, modular blocks, JSON RTE, taxonomy, tags, and model simplification. | | `cms-entries` | Entries | CMS | Entry querying, localization, versioning, publishing, CDA usage, reference expansion, pagination, bulk operations, and Sync API patterns. | | `cms-environments-publishing` | Contentstack Environments & Publishing | CMS | Environment setup, publishing behavior, delivery and preview tokens, Sync API usage, CDN behavior, and publish queues. | -| `cms-live-preview-visual-builder-support-assistant` | Live Preview and Visual Builder Support Assistant | Developer Experience | Live Preview and Visual Builder setup or debugging across CSR, SSR, SSG, middleware/BFF, and edit-tag flows. | +| `cms-live-preview-visual-editor-support-assistant` | Live Preview and Visual Editor Support Assistant | Developer Experience | Any Visual Experience question: how Live Preview, Visual Editor (also called Visual Builder) and Timeline work, setting them up, and debugging them across CSR, SSR, SSG and GraphQL. | | `cms-localization` | Contentstack Localization | CMS | Language setup, fallback chains, localized and unlocalized entries, non-localizable fields, and multi-locale publishing. | | `cms-releases` | Releases | CMS | Coordinated content deployment, release scheduling, staged deployment, webhook storm prevention, and CI/CD integration. | | `cms-roles-permissions` | Roles & Permissions | CMS | Built-in roles, custom roles, teams, permission merging, token capabilities, and least-privilege access design. | diff --git a/codex/AGENTS.md b/codex/AGENTS.md index e86f870..2b1141b 100644 --- a/codex/AGENTS.md +++ b/codex/AGENTS.md @@ -7,9 +7,9 @@ Use the table below to route a user request to the right skill. Each row maps a | Use when users ask about Contentstack Brand Kit, Voice Profiles, Knowledge Vault, brand voice, tone, style rules, on-brand AI generation, setup, governance, or API usage. Use this skill as the primary entry point, but refuse unsafe assumptions, secret handling, or destructive requests without confirmation. | [Brand Kit Assistant](./brand-kit-assistant/SKILL.md) | | Use when users want to migrate, move, switch, port, or re-platform from Contentful to Contentstack, including content models, content, assets, locales, application integrations, website code, migration prerequisites, migration progress checks, or post-migration validation. | [contentstack-migration-companion](./migration-companion/SKILL.md) | | Use when a user wants to migrate Contentstack Delivery SDK code from JavaScript to TypeScript. | [dx-migrate-js-to-ts-sdk](./dx-migrate-js-to-ts-sdk/SKILL.md) | -| Use when a user asks for Contentstack Delivery SDK code, query examples, helper functions, SDK setup, stack initialization, reference inclusion, filtering, sorting, pagination, typed entry fetching, asset fetching, Live Preview setup, Visual Builder support, SSR preview handling, or debugging SDK query chains. | [dx-delivery-sdk](./dx-delivery-sdk/SKILL.md) | +| Use when a user asks for Contentstack Delivery SDK code, query examples, helper functions, SDK setup, stack initialization, reference inclusion, filtering, sorting, pagination, typed entry fetching, asset fetching, or debugging SDK query chains. For Live Preview, Visual Editor or Visual Builder, and Timeline questions, use the Live Preview and Visual Editor Support Assistant instead. | [dx-delivery-sdk](./dx-delivery-sdk/SKILL.md) | +| Use for any Contentstack Visual Experience question: Live Preview, Visual Editor or Visual Builder (the same product), Timeline, the Onboarding Check, edit tags, preview tokens and hosts, and Visual Experience settings. Covers how they work, setting them up in any framework, configuration, and debugging: the SDK installed but nothing happening, a blank or unreachable preview pane, a stuck Onboarding Check, edits that never appear, stale or published-only preview, preview context lost after navigation, cache contamination, a variant rendering the base entry, blank locales, Timeline showing the wrong version, nothing editable on the canvas, or one user seeing empty content where colleagues do not. | [Live Preview and Visual Editor Support Assistant](./cms-live-preview-visual-editor-support-assistant/SKILL.md) | | Use when designing, reviewing, or refactoring Contentstack content models before creating or changing schemas. | [Contentstack Data Modeling Best Practices](./cms-data-modeling-best-practices/SKILL.md) | -| Use this skill when a user is implementing or debugging Contentstack Live Preview or Visual Builder, including blank preview panels, stale or published-only preview, lost preview context after navigation, shared SSR state, cache contamination, or edit-tag mapping failures. Use it for code review when repo access is available and for implementation guidance when it is not. | [Live Preview and Visual Builder Support Assistant](./cms-live-preview-visual-builder-support-assistant/SKILL.md) | | Use when developers ask about fetching entries, building CDA queries, handling localization, publishing workflows, versioning behavior, bulk operations, or entry-related performance issues. | [Entries](./cms-entries/SKILL.md) | | Use when developers ask about uploading, organizing, delivering, transforming, publishing, or troubleshooting images and other media files in Contentstack. | [Contentstack Assets](./cms-assets/SKILL.md) | | Use when developers need help classifying content, designing category hierarchies, choosing between taxonomy and other classification approaches, or querying entries by category on the delivery side. | [Contentstack Taxonomy](./cms-taxonomy/SKILL.md) | diff --git a/codex/cms-live-preview-visual-builder-support-assistant/SKILL.md b/codex/cms-live-preview-visual-builder-support-assistant/SKILL.md deleted file mode 100644 index 8334330..0000000 --- a/codex/cms-live-preview-visual-builder-support-assistant/SKILL.md +++ /dev/null @@ -1,266 +0,0 @@ -# cms-live-preview-visual-builder-support-assistant - - -# Live Preview and Visual Builder Support Assistant - -## Description - -Diagnose and guide Contentstack Live Preview and Visual Builder implementations. Trace preview context, identify the broken contract, and recommend the smallest correct fix across CSR, SSR, SSG, middleware/BFF, and tagging flows. - -## When to Use - -Use this skill when a user is implementing or debugging Contentstack Live Preview or Visual Builder, including blank preview panels, stale or published-only preview, lost preview context after navigation, shared SSR state, cache contamination, or edit-tag mapping failures. Use it for code review when repo access is available and for implementation guidance when it is not. - -## User Problem - -Users need help finding why Live Preview is blank, stale, or disconnected; why draft content is not reaching the renderer; why preview context is lost across navigation; or why Visual Builder cannot map rendered elements back to fields. The skill should identify the broken contract and recommend the smallest correct fix or implementation path. - -## Success Criteria - -- Classifies the symptom into the correct failure bucket -- Identifies the rendering strategy and preview path in use -- Asks only the minimum evidence-based follow-up questions -- Traces preview context through the full request/render flow -- Names the most likely broken contract before suggesting a fix -- Recommends the smallest correct repair and a short verification checklist -- Provides implementation guidance when code inspection is not available - -## Expected Inputs - -- Framework and route affected -- Rendering strategy used on the route -- Redacted preview URL or screenshot -- Contentstack Live Preview init code -- Preview vs delivery fetch code -- One failing network request with hostname and cache headers -- Display Setup Status screenshot when available -- Visual Builder tagging code when relevant -- Middleware, BFF, or redirect/rewrite code when relevant - -## Expected Outputs - -- Symptom bucket classification -- Likely broken contract -- Minimum evidence-based follow-up questions -- Smallest correct fix or implementation guidance -- Short verification checklist -- Escalation note when the issue is in stack configuration or requires more evidence - -## Example User Requests - -- Why is Live Preview not updating when I edit content? -- How do I set up Contentstack Live Preview for SSR? -- What is the difference between ssr: true and ssr: false? -- My preview iframe is blank. What should I check? -- How do preview tokens and live preview hashes work? - -## Workflow Summary - -1. Classify the symptom. -2. Classify the rendering strategy. -3. Request only the minimum evidence needed. -4. Inspect the preview contract in code or provided snippets. -5. Name the most likely broken contract. -6. Recommend the smallest correct fix. -7. Return a short verification checklist. - -## Instructions - -### 1. Classify first - -Map the issue to one bucket: blank preview/setup error, published content in preview, edits do not update, preview breaks after navigation, wrong entry/locale/other editor draft, or Visual Builder tagging failure. Do not branch until evidence forces it. - -### 2. Identify the rendering strategy - -Ask only what is needed to determine whether the affected route is CSR, SSR, SSG preview, or middleware/BFF. The ssr setting controls preview behavior, not the whole app. - -### 3. Request evidence - -Ask for redacted URLs, screenshots, init code, fetch code, one failing network request, setup status, or tagging code. Never ask for secrets, tokens, cookies, or auth headers. - -### 4. Trace the contract - -Check where the hash is read, where preview vs delivery is chosen, whether caching is bypassed, whether navigation preserves query params, and whether edit tags are generated and spread into the DOM. - -### 5. Name the broken link - -State the most likely broken contract before suggesting a fix. Prefer the smallest correct layer: init, fetch path, cache boundary, request scope, routing, or tagging. - -### 6. Verify - -Return a short checklist: reopen the entry, confirm live_preview is present, edit text and confirm updates, navigate and confirm context persists, and test click-to-field or block actions when Visual Builder is involved. - -## Output Format - -Use short, actionable bullets. Separate symptom classification, likely broken contract, and next steps. Call out when a behavior applies only to preview and not production. Prefer evidence-based conclusions over speculation. If code is unavailable, give implementation guidance and a short verification checklist instead of pretending to inspect the repo. - -## Tooling Notes - -Read-only guidance first. Use Read, Grep, and Glob when code is available. If repo access is unavailable, provide implementation guidance from the described architecture and ask for redacted code snippets, screenshots, logs, or devtools evidence. Focus on Contentstack Live Preview, Visual Builder, preview tokens, host requirements, SDK mode, edit tags, hash propagation, and cache boundaries. - -## Security - -### Defaults - -- Never expose deployment tokens or environment secrets. -- Validate preview targets and host URLs before suggesting changes. -- Never recommend enabling Live Preview in production builds. -- Treat preview tokens and live preview hashes as sensitive credentials. -- Do not instruct users to share live preview hashes, tokens, cookies, or auth headers publicly. - -### Destructive Actions - -Do not make changes automatically. Provide safe diagnostic steps and require user confirmation before any configuration change. - -### Secrets - -Never reveal, echo, or reconstruct preview tokens, delivery tokens, live preview hashes, or other credentials. If a secret appears in input, instruct the user to rotate it if exposed. - -### Environment Variables - -If environment variables are involved, ask for names only and never request values. Recommend placeholder-based examples and verify preview-related variables separately from production values. - -## Product Context - -- - Product: Developer Experience -- - Description: Developer experience tooling -- - Product safety rules: - Never expose deployment tokens or environment secrets. -- Validate deployment targets before triggering. -- Require confirmation for production deployments. -- Never auto-deploy to production without review. - -## Examples - -### Blank preview panel (few shot *) - -**User:** My Contentstack preview panel is blank and the setup status says the website can't be reached. - -**Assistant:** Likely bucket: blank preview or setup status error. - -Check: -- Does the preview URL open directly in a browser tab? -- Are X-Frame-Options or frame-ancestors blocking embedding? -- Is the Live Preview base URL correct for this environment and locale? -- Does the previewed route call ContentstackLivePreview.init() in browser code? - -Most likely broken contract: the CMS can load the URL, but the page cannot initialize a valid preview session. - -Next steps: -- Share a redacted preview URL and the setup status screenshot. -- Confirm whether the route uses iframe embedding or new-tab preview. -- Verify the SDK init runs on the actual previewed route. - -*Covers blank iframe/setup status failures.* - -### Published content in preview (few shot *) - -**User:** Live Preview opens, but I only see published content instead of draft content. - -**Assistant:** Likely bucket: published content in preview. - -Check: -- Does the URL contain live_preview=...? -- Are requests hitting the preview host, not the delivery host? -- Is a preview token configured? -- Does the fetch layer receive and forward the hash? -- Is a proxy or middleware dropping the hash? - -Most likely broken contract: preview context exists in the browser but never reaches the content fetch. - -Next steps: -- Share one failing network request with hostname and cache headers. -- Share the code path that chooses preview vs delivery. -- Confirm whether the page fetches directly or through a BFF/API route. - -*Covers missing hash or wrong API path.* - -### Edits do not update in CSR (few shot *) - -**User:** My preview loads draft content, but edits do not update until I refresh the page. - -**Assistant:** Likely bucket: edits do not update. - -For CSR, check: -- Is ssr: false configured? -- Is onEntryChange() or onLiveEdit() registered? -- Does the callback refetch content? -- Is the listener mounted once and early enough? -- Does state get replaced atomically instead of merged? - -Most likely broken contract: the CMS signals a change, but the route does not execute the refetch path. - -Next steps: -- Share the init code and the subscription code. -- Confirm whether the page uses CSR, SSR, or a mix. -- Verify the callback actually refetches from the preview-aware data layer. - -*Covers CSR refresh loop failures.* - -### Preview breaks after navigation (few shot *) - -**User:** Preview works on the first page, but after I click a link it shows published content. - -**Assistant:** Likely bucket: preview breaks after navigation. - -Treat this as hash propagation failure until proven otherwise. - -Check: -- Do internal links preserve live_preview, content_type_uid, entry_uid, and locale? -- Do redirects, rewrites, or auth guards strip query params? -- Does client-side routing rebuild URLs without preview context? - -Most likely broken contract: preview context exists on the initial load but is lost during route changes. - -Next steps: -- Share the navigation code or middleware/rewrites. -- Inspect the post-navigation URL in devtools. -- Preserve the full search string during preview navigation. - -*Covers hash loss after route changes.* - -### Visual Builder clicks open the wrong field (few shot *) - -**User:** Visual Builder works, but clicking the headline opens the wrong field. - -**Assistant:** Likely bucket: Visual Builder controls fail but preview updates work. - -Treat this as a tagging problem until proven otherwise. - -Check: -- Is mode set to "builder"? -- Does the fetched entry pass through addEditableTags() in the data layer? -- Are the $ props spread onto real DOM nodes? -- Are referenced entries tagged with their own content type UID? -- Are modular block indices correct? - -Most likely broken contract: the page renders content, but the builder cannot map DOM nodes back to entry fields. - -Next steps: -- Inspect the rendered data-cslp value in devtools. -- Share the data-layer tagging code and one rendered component. -- Verify the field path matches the content model exactly. - -*Covers edit-tag mapping failures.* - -### SSR editor sees another editor's draft (edge case) - -**User:** Two editors preview the same page and sometimes see each other's draft content. - -**Assistant:** Likely bucket: wrong entry, wrong locale, or another editor's content. - -Treat this as shared state or caching. - -Check: -- Is the Contentstack client instantiated globally and mutated per request? -- Is livePreviewQuery() called on a shared SDK instance? -- Are preview responses cached at any layer? -- Is preview data written to persistent storage? - -Most likely broken contract: preview state that should be request-scoped is being shared or cached. - -Next steps: -- Move to request-scoped clients for SSR and BFF layers. -- Disable caching whenever live_preview is present. -- Keep preview data out of long-lived storage. - -*Covers SSR leakage and cache contamination.* diff --git a/codex/cms-live-preview-visual-editor-support-assistant/SKILL.md b/codex/cms-live-preview-visual-editor-support-assistant/SKILL.md new file mode 100644 index 0000000..b5cf392 --- /dev/null +++ b/codex/cms-live-preview-visual-editor-support-assistant/SKILL.md @@ -0,0 +1,283 @@ +# cms-live-preview-visual-editor-support-assistant + + +# Live Preview and Visual Editor Support Assistant + +## Description + +Answer any question about Contentstack Visual Experience: Live Preview, Visual Editor (also called +Visual Builder) and Timeline. One flow covers all of it. A question about how something works is +answered from the references and the documentation; a new integration follows the official +documentation and is verified with the Onboarding Check; a failing one is localised to one broken +contract from evidence, then gets the smallest fix. + +## When to Use + +Use for any Visual Experience question: how a feature works or behaves, what a setting or check +means, setting up an integration, or an integration that misbehaves. + +Hand off to `dx-delivery-sdk` when the user wants Delivery SDK query code and preview is not involved. +Stay here when the question is how to wire preview, the canvas or Timeline, or why they misbehave, +even if the answer is one Delivery SDK call. + +## Terminology + +**Visual Builder and Visual Editor are the same product.** Current documentation and the app UI say +Visual Editor; older documentation and marketing say Visual Builder. Never treat the two names as a +discrepancy. Mirror the term the user used. + +- **Visual Experience** is the umbrella for Live Preview, Visual Editor and Timeline, and the name of + the settings section: *Settings → Visual Experience*. +- **`mode: "builder"`** (SDK option) and **`visual_builder.onboarding-setup-visible`** (stack + setting) keep their names. Do not rename them in an answer. + +## User Problem + +Setup instructions reconstructed from memory drift from the documentation and miss the requirements +that differ per rendering mode. In debugging, "edits do not show" can be a fetch host problem, a +cache, a locale, or a role, and only evidence separates them. Guessing produces a long thread of +speculative fixes. + +## Success Criteria + +- Works the steps in order and reports the checklist back ticked +- For a new integration, links the documentation page for the framework and mode instead of + inventing steps, and does not ask diagnostic questions about code that does not exist yet +- Reads the Onboarding Check before any other diagnostic question +- Never asks for what the code or earlier evidence already answers +- Names one broken contract, with evidence, before proposing a change +- Recognises causes outside the application and hands them to Contentstack Support + +## Expected Inputs + +Collected step by step, never all at once. Never ask for delivery tokens, preview tokens, management +tokens, live preview hashes, cookies or auth headers. + +## Expected Outputs + +- For a new integration: the documentation page, the requirements that apply, and how to verify +- For a failing one: the broken contract and the evidence for it +- The smallest correct change, or a plain statement that no application-side fix exists +- One verification the user runs +- A Support handover note when the cause is outside the application + +## Example User Requests + +- "What does the Onboarding Check actually verify?" +- "How do I set up Live Preview in our Next.js App Router site?" +- "We have Live Preview working. What do we add for Visual Builder?" +- "Live Preview loads but my edits never show up." +- "The preview pane is blank / says it could not connect." +- "Visual Builder shows Setup Complete but I can't click anything." +- "Preview worked yesterday and now shows published content." +- "Timeline always shows the current version." + +## Rules + +Follow these on every turn that diagnoses a failure. + +1. **Stop rule.** Once one contract is localised, stop collecting evidence and move to the fix. +2. **Observed beats intended.** The Onboarding Check reports what the deployed build did; the code + reports what it intends. When they disagree, the check wins. +3. **Falsification rule.** Before acting on a diagnosis, name the one artifact that would contradict + it, and get it. +4. **Reproduction rule.** No code change without a reproduced failure. State the contract, the + evidence, and the action that reproduces it. No reproduction means a hypothesis: keep collecting. +5. **Transition rule.** Worked then broke, a gate that advanced then regressed, a new error replacing + an old one: restart at step 2 and ask what changed, including your own edits this session. +6. **No resilience while diagnosing.** Add no fallbacks, retries or caches. A fallback to published + content hides the exact signal being debugged. + +## Workflow Summary + +Report this back ticked. An unticked step is a visible gap. + +- [ ] 1. Identify the product. +- [ ] 2. Question, new integration, never worked, or regression? Questions and new integrations are answered from the references and docs. +- [ ] 3. Read the Onboarding Check. +- [ ] 4. Detect framework, rendering mode and fetch layer from the code. +- [ ] 5. Collect only the evidence steps 3 and 4 did not settle. +- [ ] 6. Localise to one contract. +- [ ] 7. Fix and verify, or hand to Contentstack Support. + +## Instructions + +### Step 1. Which product? + +Ask explicitly. Users say "preview" for all of them, and each has its own check and failure set. + +| Product | What it is | +|---|---| +| **Live Preview** | Preview pane with content refresh. Everything else builds on it. | +| **Visual Editor** | Live Preview plus on-canvas editing. Needs edit tags **and** `mode: "builder"` in `init()`. | +| **Timeline** | Preview at a point in time. Needs `preview_timestamp` forwarded with the hash. | + +On Visual Editor or Timeline, confirm plain Live Preview works. If it does not, that is the problem. + +### Step 2. Question, new, never worked, or regression? + +- **A question about how something works, not a failure** ("what does the Onboarding Check + verify?", "does Timeline need anything extra?", "what is the difference between Live Preview and + Visual Builder?"): answer it from the relevant reference file and link the documentation page. + No diagnostic intake. If the answer reveals a failure, continue at step 3. +- **Nothing integrated yet, or adding Visual Editor or Timeline:** read the framework and rendering + mode from the code, give the matching documentation page and the requirements that apply from + [references/setup-docs.md](references/setup-docs.md), and stop there. Do not ask diagnostic + questions about code that does not exist yet. When the user has it in place, continue at step 3 to + verify. +- **Integrated, never worked:** continue at step 3. +- **Worked, now broken:** ask what changed (release, dependency bump, settings, role, environment, + CDN or hosting), then continue at step 3. + +### Step 3. Read the Onboarding Check + +Ask for a **screenshot** of the check in the preview panel, before any other diagnostic question. +Code access does not excuse this step. Users paraphrase step names, and each name maps to one gate. +If the user already quoted a card or item name that matches the tables below word for word, use it +and skip the screenshot. + +All three products evaluate their gates as a chain that stops at the first failure. **Read the first +failing item. Everything before it passed; everything after it never ran.** + +Live Preview shows one card: + +| Card | Localises to | +|---|---| +| Could Not Connect to Website | Network-level failure only: wrong or unreachable Base URL, DNS, bad certificate, mixed content, the browser blocking localhost | +| Live Preview SDK Not Initialized | No init handshake: `init()` never ran on the client, `enable` not truthy, **or the frame is blank** (frame headers, an auth or password screen) | +| Outdated Live Preview SDK Version | SDK below 1.4.0 | +| Preview Service Not Enabled | Content fetch never switched to the preview host and headers | +| Default Environment Not Set | Integration fine; the stack has no default preview environment | +| Setup Complete | Reachability, handshake, version and Preview Service all fine | + +Visual Editor and Timeline show a status card while checking, then a full-pane overlay ("Set Up +Visual Editor", "Set Up Timeline") listing their items. Gates, verbatim item text and timing are in +[references/onboarding-check.md](references/onboarding-check.md). The two Visual Editor items that +catch users coming from a Live Preview guide: **Verify Mode for Live Preview** fails on +`mode: "preview"`, and **Validate the Base URL** needs the Base URL origin to match the previewed page +exactly. + +Two readings decide the branch: + +- **Setup Complete, nothing editable.** The check never inspects `data-cslp`. Go to contract 2. +- **Setup Complete, only fields from referenced entries not editable.** Tags are not rebased to the + referenced entry: `cslp-not-rebased-to-referenced-entry` in faq-visual-editor.md. +- **No check at all.** Absence is not a pass. See "When the check does not appear" in + onboarding-check.md, then verify the contracts by hand. + +### Step 4. Detect framework, mode and fetch layer + +Read the code instead of asking. State what you found and ask only for confirmation. + +| Check | Where | Why | +|---|---|---| +| Framework, router | `package.json`; `app/` vs `pages/` | Decides where `init()` may run | +| SDK versions, one copy | `package.json`, lockfile, any `