@se-studio/contentful-cms 3.10.0 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/commands/discard.d.ts +3 -0
- package/dist/commands/discard.d.ts.map +1 -1
- package/dist/commands/discard.js +16 -2
- package/dist/commands/discard.js.map +1 -1
- package/dist/commands/entry-lookup-target.d.ts +18 -0
- package/dist/commands/entry-lookup-target.d.ts.map +1 -1
- package/dist/commands/entry-lookup-target.js +14 -1
- package/dist/commands/entry-lookup-target.js.map +1 -1
- package/dist/commands/nav.d.ts.map +1 -1
- package/dist/commands/nav.js +46 -30
- package/dist/commands/nav.js.map +1 -1
- package/dist/commands/preview.d.ts.map +1 -1
- package/dist/commands/preview.js +23 -8
- package/dist/commands/preview.js.map +1 -1
- package/dist/contentful/cma-user-agent.d.ts +1 -1
- package/dist/generated/help-topics.d.ts.map +1 -1
- package/dist/generated/help-topics.js +1 -1
- package/dist/generated/help-topics.js.map +1 -1
- package/dist/generated/hosted-guide.d.ts +1 -1
- package/dist/generated/hosted-guide.d.ts.map +1 -1
- package/dist/generated/hosted-guide.js +1 -1
- package/dist/generated/hosted-guide.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/mcp/tools/cms-edit.d.ts +1 -1
- package/dist/mcp/tools/cms-edit.d.ts.map +1 -1
- package/dist/mcp/tools/cms-edit.js +7 -3
- package/dist/mcp/tools/cms-edit.js.map +1 -1
- package/dist/preview/resolve-preview-entry.d.ts +18 -0
- package/dist/preview/resolve-preview-entry.d.ts.map +1 -0
- package/dist/preview/resolve-preview-entry.js +30 -0
- package/dist/preview/resolve-preview-entry.js.map +1 -0
- package/dist/session/navigation-fields.d.ts +21 -0
- package/dist/session/navigation-fields.d.ts.map +1 -0
- package/dist/session/navigation-fields.js +79 -0
- package/dist/session/navigation-fields.js.map +1 -0
- package/dist/session/refs.d.ts +3 -3
- package/dist/session/refs.d.ts.map +1 -1
- package/dist/session/refs.js +6 -15
- package/dist/session/refs.js.map +1 -1
- package/docs/editor-tasks/navigation.md +11 -6
- package/docs/help/lookup.md +6 -3
- package/docs/mcp/hosted-guide.md +3 -2
- package/package.json +1 -1
- package/skills/core/SKILL.md +10 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"hosted-guide.d.ts","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,k6kBAAumkB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Generated by scripts/generate-embedded-assets.mjs — do not edit manually.
|
|
2
|
-
export const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through a hosted MCP connector (Claude Desktop Integrations + OAuth, or Grok Build).\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n**Assets:** cms-edit **can upload** draft assets via **staged upload** (hosted) or `--url` (public HTTPS last resort). **`--base64` is not supported on hosted MCP.** Always **search and reuse existing assets first** (`index sync`, then `asset search` or `list --type media`). Use `--if-exists-by-filename` when uploading to avoid duplicates.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_request_staged_upload` | Presigned URL for binaries. Raster/video: then `cms_edit_media` prepare. SVG/PDF/Lottie: then `asset upload --staged` |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Guide topics (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) **or** playbooks (`create-from-json`, `fields-component`, …) |\n\n## Customer editor pack (read first)\n\nWhen a site editor pack is deployed, these MCP resources provide **site-specific** context. Read them before creating or editing content:\n\n| Resource | Purpose |\n|----------|---------|\n| `cms-edit://customer/index` | List of all customer resources |\n| `cms-edit://customer/tasks-index` | Intent → task playbook map (filtered for this site) |\n| `cms-edit://customer/capabilities` | Machine-readable list of what this site supports |\n| `cms-edit://customer/checklist` | First-session onboarding steps |\n| `cms-edit://customer/overview` | Site name, space, staging URL, handoff rules |\n| `cms-edit://customer/routing` | Article/tag URL rules for this site |\n| `cms-edit://customer/production-site` | Production URL and how to fetch page markdown (do not guess `.md` URLs) |\n| `cms-edit://customer/components-index` | Component types and when to use each |\n| `cms-edit://customer/collections-index` | Collection types |\n| `cms-edit://customer/brand` | Brand voice and terminology (if configured) |\n| `cms-edit://customer/articles` | Article/publication playbook (if configured) |\n| `cms-edit://customer/defaults` | Featured image rules and article types (if configured) |\n| `cms-edit://customer/site-facts` | Optional canonical business facts (if configured) |\n| `cms-edit://customer/task-*` | Capability playbooks (e.g. `task-media-reuse-and-upload`) |\n\n**Workflow:** read `tasks-index` → `capabilities` → `checklist` → `overview` → `routing` → `production-site` → pick a `task-*` playbook for your goal → `components-index` → then use `cms_edit` commands.\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff → save |\n| `cms_edit_edit_article` | Edit an article through diff → save |\n| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_create_article` | Create an article (requires article type; featured image rules) |\n| `cms_edit_create_from_doc` | Create a page from a freeform document (infer → confirm → dry-run) |\n| `cms_edit_create_article_from_doc` | Create an article from a freeform document |\n| `cms_edit_taxonomy` | Import taxonomy entries (`create … --if-not-exists`) |\n| `cms_edit_bulk_seo` | Update SEO meta descriptions (read `task-seo-descriptions`) |\n| `cms_edit_bulk_find_replace` | Bulk find-replace in rich text across entries |\n| `cms_edit_bulk_article_tags` | Update tags on one or more articles |\n| `cms_edit_import_authors` | Create person/author entries from a list or sheet |\n| `cms_edit_media` | Find existing assets or upload new ones (reuse-first) |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## End-to-end QA prompt\n\nFor release QA after cms-edit or editor-pack upgrades, use a **copy-paste Claude Desktop test script** (phases: connector → customer resources → discovery → session → schema → media → dry-run writes → negatives). See [e2e-test-prompt.md](./e2e-test-prompt.md) to author one per customer site. Example: Brightline `docs/cms-edit/MCP-E2E-TEST.md`.\n\n## Core workflow\n\nStandard editing flow: **open → snapshot → read → set/rtf → diff → save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"open\", \"--page-slug\", \"/pricing\"]\n[\"open\", \"--id\", \"<entry-id>\"]\n[\"open\", \"--include-chrome\", \"--page-slug\", \"/pricing\"]\n```\n\nDefault `open` / `peek` fetch the page or article tree and the template entry, but **not** template menu/footer/navigation. Edit nav with `nav open`. Use `--include-chrome` only when you need those trees.\n\n**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).\n\n### 2. Snapshot — see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, … refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## When to use Contentful UI\n\n| Task | Where |\n|------|-------|\n| Edit copy, add sections, create pages/articles | **Agent + cms-edit** (drafts) |\n| Upload new images and files | **Agent + cms-edit** — search/reuse first; raster/video via `cms_edit_media` import |\n| Publish approved drafts | **Contentful UI** |\n| Edit copy directly in Contentful | **Avoid** — use cms-edit instead |\n\ncms-edit saves **drafts only**. A colleague must **publish in Contentful** for changes to go live.\n\n## Asset upload (hosted MCP)\n\nHosted connectors have **no server filesystem** and **reject `asset upload --base64`**. Raster/video: staged intake then **media pipeline**. SVG/PDF/Lottie: staged then `asset upload --staged`.\n\n| Source | When | Example |\n|--------|------|---------|\n| **Staged + pipeline** | jpeg/png/webp/gif/mp4 | `cms_edit_media` prepare `stagedUploadIds` → import (required for video) |\n| **`--url`** | Pipeline-ready **images** only, or SVG/PDF | `[\"asset\", \"upload\", \"--url\", \"https://….blob.vercel-storage.com/ready.jpg\"]` |\n| **Staged consume** | SVG/PDF/Lottie | `asset upload --staged` |\n\n**After upload:** note the returned asset `id`, attach to the entry (`asset set @root media <id>` for person portraits), then `diff` → `save`. Upload alone does not update entries.\n\n**PNG** when transparency matters.\n\nFull workflow: `cms-edit://customer/task-media-reuse-and-upload`.\n\n### Common pitfalls (agents)\n\n| Issue | Do this |\n|-------|---------|\n| Singular Media on a component (`visual`) | `set @cN visual <mediaId> --link` — **not** `add … --target visual` |\n| Shared Drive folder has extra files | Import with `sourceNames` or `onlyWithOverrides` after catalog |\n| Prepare says no media / empty folder | Share folder **Viewer** with `media-pipeline-reader@se-media-pipeline.iam.gserviceaccount.com`, then re-prepare once |\n| MCP tool times out ~180s | `read` / `diff` / re-`catalog` before retrying the same write — server may already have saved |\n| `preview urls` has no Live Preview URL | Use staging + classic entry editor; row includes `unavailableReason` when CMA preview fails |\n| Reuse-first import matches old fileNames | dry-run first; set `overrides[].fileName` for unique names when duplication is required |\n\n### Staged upload\n\nKeeps binary **out of MCP tool args**. The agent uploads via `curl`, then passes only a short `uploadId`.\n\n1. `cms_edit_request_staged_upload` with `fileName`, `mimeType`, optional `byteLength`, optional `title`\n2. Run the returned `curlCommand` in a shell (POST multipart to `uploadUrl`)\n3. Follow `consumeArgs`: **media prepare** (`cms_edit_media` / `media prepare --staged-ids`) for jpeg/png/webp/gif/mp4; **asset upload --staged** for SVG/PDF/Lottie\n4. For pipeline jobs: wait → catalog → **import** (required for video). Then link and save\n\nHosted limit: **4 MB** per staged file (Vercel body limit). Rate limit: **1000 upload URLs per user per hour**. TTL: **60 minutes**. Raster/video staged files are intake (GET by the pipeline); they are not consumed into CMA.\n\n## Featured images (articles)\n\nRead `cms-edit://customer/defaults` when present. Otherwise:\n\n1. **Custom** — set `featuredImage` or `featuredImageAssetFilename` on the article when the editor provides a specific image\n2. **Article type** — if omitted, cms-edit inherits the linked **articleType** `featuredImage`\n3. **Site default** — from `editor.defaults` in the site config (also in `defaults.json` in the editor pack)\n\nRun `[\"index\", \"sync\"]` before resolving assets by filename.\n\n## JSON payloads (filesystem vs no filesystem)\n\nHosted MCP cannot see your disk. Same commands either way:\n\n- **Filesystem client:** write `page.json`, then `cms_edit [\"create\", \"from-json\", \"--json-base64\", \"<base64 of file>\", \"--dry-run\", \"--strict\"]`\n- **No filesystem (Desktop):** put the JSON in `--json` on the tool call\n\nNever use a local `cms-edit` binary, `--file`, or stdin for content.\n\n## Create content\n\n### Create a page\n\n```\n[\"schema\", \"component\"]\n[\"help\", \"create-from-json\"]\n[\"create\", \"from-json\", \"--json\", \"{...}\", \"--dry-run\", \"--strict\"]\n[\"create\", \"from-json\", \"--json\", \"{...}\"]\n```\n\nUse `\"components\"` (not `\"content\"`) and nested `\"type\"` (not `\"componentType\"`). Peek a live entry or `schema <ct>` before authoring field ids.\n\nEmpty `components` fails validation. Incremental `add`/`set` is for tiny patches only.\n\n### Create an article\n\nEvery article requires an **articleType**:\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"articleType\"]\n[\"create\", \"article\", \"--slug\", \"resources/blog/my-post\", \"--title\", \"My Post\", \"--article-type-slug\", \"resources/blog\"]\n```\n\nOr `create from-json` with `\"type\": \"article\"` and `articleTypeSlug` / `articleTypeId`.\n\nUse MCP prompt `cms_edit_create_article` for guided creation.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"list\", \"--type\", \"page\"]\n```\n\n### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\n\n### Explore the homepage\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"--page-slug\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Grok Build setup\n\nGrok connects to the same hosted MCP URL as Claude. Add to `~/.grok/config.toml`:\n\n```toml\n[mcp_servers.cms-edit-brightline]\nurl = \"https://brightline.content.se.studio/api/mcp\"\nenabled = true\n```\n\nReplace the server name and host with your site's deployment. The URL **must** end with `/api/mcp` (not the site root).\n\n**Connect:**\n\n1. In Grok, run `/mcps` and select your cms-edit server\n2. Press **`i`** to initiate OAuth (not just enable the toggle)\n3. Sign in with Contentful when the browser opens\n4. Verify with `grok mcp doctor <server-name>` or call `cms_edit_version`\n\nOAuth is two steps: Grok obtains an MCP token, then you sign in with Contentful to link your account. If the browser flashes and closes immediately, reconnect after upgrading cms-edit (loopback redirect handling).\n\n## Hosted connector rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages — pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-id>\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` — reports store, userId, active session key |\n\n- **`peek` is one-shot** — prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **Use flat lookup flags** for `open` and `peek` — same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`.\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** — there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / connection failed** | Reconnect: Claude → Settings → Integrations, or Grok `/mcps` → press `i`. Complete Contentful sign-in. If Grok says “Failed to get tools after auth” or `auth required`, check Vercel `[cms-edit:oauth] auth_failure`. `invalid_refresh_token` is a rotated/missing MCP refresh UUID (fixed in **3.6.1+** by not rotating). `missing_contentful_token` / `invalid_contentful_token` means the CMA cache is gone — **3.5.3+** returns `invalid_token` so Grok re-runs Contentful sign-in. If it still loops, delete that server’s entry from `~/.grok/mcp_credentials.json` and press `i` again. Set `LOG_CMS_OAUTH=1` for connect success traces. |\n| **No cms_edit tool** | Confirm the integration is connected under Settings → Integrations |\n| **No active session** | Do not pass `--space` on hosted. Check `/api/health` — `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `[\"--session\", \"name\", \"open\", \"--page-slug\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Your Contentful account must have access to this deployment's space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Articles\n\n**Recent articles** (by publication `date`, not last-updated):\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"]\n```\n\nAlternative: `[\"search\", \"<keyword>\", \"--type\", \"article\"]` (also sorts by date).\n\n**Draft articles** — `peek` and `open` load drafts via CMA (not published-only). To discover drafts:\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\"]\n[\"search\", \"<title>\", \"--type\", \"article\"]\n[\"list\", \"--type\", \"article\", \"--slug\", \"<slug>\"]\n```\n\nThen open: `[\"peek\", \"--article-slug\", \"<slug>\"]` or `[\"open\", \"--id\", \"<entry-id>\"]`. Use `--article-slug`, not `--page-slug`.\n\n**Published-only** is opt-in: `list --published` and `resolve --published` use the Delivery API index and omit never-published drafts.\n\nAfter upgrading cms-edit, run `[\"index\", \"sync\"]` once so the local index includes article `date` values (schema v4).\n\n**Index freshness on hosted MCP:** The catalog index is shared via Redis (gzipped SQLite blob). `index status` on a cold instance may show **not built** until `list`, `open`, or another index command runs — that is normal. Committed writes (`save`, `create page`, `asset upload`, …) mark the index dirty; the next discovery command refreshes it. In-session `set` edits do not trigger a sync.\n\n## Command reference (cms_edit args)\n\n**Discovery:** `list --type <type>`, `search <query>`, `schema <contentType>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\n\n**Diagnostics:** `diagnose` — session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create from-json --json … --dry-run --strict`, `export from-json`, `apply from-json --json …`, `create page` / `create article` for empty shells, `add` for tiny inserts\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
2
|
+
export const HOSTED_GUIDE_TEMPLATE = "# cms-edit MCP guide\n\nUse this guide when editing Contentful draft content through a hosted MCP connector (Claude Desktop Integrations + OAuth, or Grok Build).\n\n{{SITE_INTRO}}\n\n## Safety rules\n\ncms-edit **cannot and will not**:\n\n- Publish or unpublish entries\n- Archive or delete published entries\n\nAll `save` operations create **drafts only**. A human must review and publish in Contentful.\n\n**Assets:** cms-edit **can upload** draft assets via **staged upload** (hosted) or `--url` (public HTTPS last resort). **`--base64` is not supported on hosted MCP.** Always **search and reuse existing assets first** (`index sync`, then `asset search` or `list --type media`). Use `--if-exists-by-filename` when uploading to avoid duplicates.\n\n## MCP tools\n\n| Tool | Purpose |\n|------|---------|\n| `cms_edit` | Run any cms-edit command via an `args` array |\n| `cms_edit_request_staged_upload` | Presigned URL for binaries. Raster/video: then `cms_edit_media` prepare. SVG/PDF/Lottie: then `asset upload --staged` |\n| `cms_edit_version` | Check the installed cms-edit version (no session required) |\n| `cms_edit_help` | Guide topics (`overview`, `workflow`, `commands`, `troubleshooting`, `hosted`) **or** playbooks (`create-from-json`, `fields-component`, …) |\n\n## Customer editor pack (read first)\n\nWhen a site editor pack is deployed, these MCP resources provide **site-specific** context. Read them before creating or editing content:\n\n| Resource | Purpose |\n|----------|---------|\n| `cms-edit://customer/index` | List of all customer resources |\n| `cms-edit://customer/tasks-index` | Intent → task playbook map (filtered for this site) |\n| `cms-edit://customer/capabilities` | Machine-readable list of what this site supports |\n| `cms-edit://customer/checklist` | First-session onboarding steps |\n| `cms-edit://customer/overview` | Site name, space, staging URL, handoff rules |\n| `cms-edit://customer/routing` | Article/tag URL rules for this site |\n| `cms-edit://customer/production-site` | Production URL and how to fetch page markdown (do not guess `.md` URLs) |\n| `cms-edit://customer/components-index` | Component types and when to use each |\n| `cms-edit://customer/collections-index` | Collection types |\n| `cms-edit://customer/brand` | Brand voice and terminology (if configured) |\n| `cms-edit://customer/articles` | Article/publication playbook (if configured) |\n| `cms-edit://customer/defaults` | Featured image rules and article types (if configured) |\n| `cms-edit://customer/site-facts` | Optional canonical business facts (if configured) |\n| `cms-edit://customer/task-*` | Capability playbooks (e.g. `task-media-reuse-and-upload`) |\n\n**Workflow:** read `tasks-index` → `capabilities` → `checklist` → `overview` → `routing` → `production-site` → pick a `task-*` playbook for your goal → `components-index` → then use `cms_edit` commands.\n\n## MCP prompts\n\n| Prompt | Purpose |\n|--------|---------|\n| `cms_edit_verify` | Check version and connectivity |\n| `cms_edit_explore` | List site content and open a page |\n| `cms_edit_edit_page` | Edit a page through diff → save |\n| `cms_edit_edit_article` | Edit an article through diff → save |\n| `cms_edit_index_sync` | Build/refresh local index (assets, media, templates, taxonomy) |\n| `cms_edit_create_page` | Create a page with template selection |\n| `cms_edit_create_article` | Create an article (requires article type; featured image rules) |\n| `cms_edit_create_from_doc` | Create a page from a freeform document (infer → confirm → dry-run) |\n| `cms_edit_create_article_from_doc` | Create an article from a freeform document |\n| `cms_edit_taxonomy` | Import taxonomy entries (`create … --if-not-exists`) |\n| `cms_edit_bulk_seo` | Update SEO meta descriptions (read `task-seo-descriptions`) |\n| `cms_edit_bulk_find_replace` | Bulk find-replace in rich text across entries |\n| `cms_edit_bulk_article_tags` | Update tags on one or more articles |\n| `cms_edit_import_authors` | Create person/author entries from a list or sheet |\n| `cms_edit_media` | Find existing assets or upload new ones (reuse-first) |\n\nRead the full guide anytime via the `cms-edit://guide` resource or `cms_edit_help`.\n\n## End-to-end QA prompt\n\nFor release QA after cms-edit or editor-pack upgrades, use a **copy-paste Claude Desktop test script** (phases: connector → customer resources → discovery → session → schema → media → dry-run writes → negatives). See [e2e-test-prompt.md](./e2e-test-prompt.md) to author one per customer site. Example: Brightline `docs/cms-edit/MCP-E2E-TEST.md`.\n\n## Core workflow\n\nStandard editing flow: **open → snapshot → read → set/rtf → diff → save**\n\nEach step is a separate `cms_edit` call. Sessions persist in Redis between calls (hosted) or on disk (local). MCP auto-uses session `_mcp`.\n\n### 1. Open a page\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"open\", \"--page-slug\", \"/pricing\"]\n[\"open\", \"--id\", \"<entry-id>\"]\n[\"open\", \"--include-chrome\", \"--page-slug\", \"/pricing\"]\n```\n\nDefault `open` / `peek` fetch the page or article tree and the template entry, but **not** template menu/footer/navigation. Edit nav with `[\"nav\", \"open\", \"--nav-id\", \"<id>\"]` or `--nav-name` (not `--id`). Use `--include-chrome` only when you need those trees. Template `menu` is site-wide; `page.menu` overrides one page. Nested nav items are often shared — ask global vs page-specific before `set`.\n\n**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).\n\n### 2. Snapshot — see the content tree\n\n```\n[\"snapshot\"]\n```\n\nOutput shows `@c0`, `@c1`, … refs for each component. Use these refs in `read`, `set`, and `rtf`.\n\n### 3. Read fields\n\n```\n[\"read\", \"@c1\"]\n[\"read\", \"@c1\", \"heading\"]\n```\n\n### 4. Edit fields\n\n```\n[\"set\", \"@c1\", \"heading\", \"New heading text\"]\n[\"rtf\", \"@c1\", \"body\", \"--content\", \"# Title\\n\\nParagraph text.\"]\n```\n\nFor rich text, prefer `--content` with inline markdown. Use `--base64` when special characters cause issues.\n\n### 5. Review and save\n\n```\n[\"diff\"]\n[\"save\"]\n```\n\nAlways run `diff` before `save`. To abandon changes: `[\"discard\"]`.\n\n## When to use Contentful UI\n\n| Task | Where |\n|------|-------|\n| Edit copy, add sections, create pages/articles | **Agent + cms-edit** (drafts) |\n| Upload new images and files | **Agent + cms-edit** — search/reuse first; raster/video via `cms_edit_media` import |\n| Publish approved drafts | **Contentful UI** |\n| Edit copy directly in Contentful | **Avoid** — use cms-edit instead |\n\ncms-edit saves **drafts only**. A colleague must **publish in Contentful** for changes to go live.\n\n## Asset upload (hosted MCP)\n\nHosted connectors have **no server filesystem** and **reject `asset upload --base64`**. Raster/video: staged intake then **media pipeline**. SVG/PDF/Lottie: staged then `asset upload --staged`.\n\n| Source | When | Example |\n|--------|------|---------|\n| **Staged + pipeline** | jpeg/png/webp/gif/mp4 | `cms_edit_media` prepare `stagedUploadIds` → import (required for video) |\n| **`--url`** | Pipeline-ready **images** only, or SVG/PDF | `[\"asset\", \"upload\", \"--url\", \"https://….blob.vercel-storage.com/ready.jpg\"]` |\n| **Staged consume** | SVG/PDF/Lottie | `asset upload --staged` |\n\n**After upload:** note the returned asset `id`, attach to the entry (`asset set @root media <id>` for person portraits), then `diff` → `save`. Upload alone does not update entries.\n\n**PNG** when transparency matters.\n\nFull workflow: `cms-edit://customer/task-media-reuse-and-upload`.\n\n### Common pitfalls (agents)\n\n| Issue | Do this |\n|-------|---------|\n| Singular Media on a component (`visual`) | `set @cN visual <mediaId> --link` — **not** `add … --target visual` |\n| Shared Drive folder has extra files | Import with `sourceNames` or `onlyWithOverrides` after catalog |\n| Prepare says no media / empty folder | Share folder **Viewer** with `media-pipeline-reader@se-media-pipeline.iam.gserviceaccount.com`, then re-prepare once |\n| MCP tool times out ~180s | `read` / `diff` / re-`catalog` before retrying the same write — server may already have saved |\n| `preview urls` has no Live Preview URL | Use staging + classic entry editor; row includes `unavailableReason` when CMA preview fails |\n| Reuse-first import matches old fileNames | dry-run first; set `overrides[].fileName` for unique names when duplication is required |\n\n### Staged upload\n\nKeeps binary **out of MCP tool args**. The agent uploads via `curl`, then passes only a short `uploadId`.\n\n1. `cms_edit_request_staged_upload` with `fileName`, `mimeType`, optional `byteLength`, optional `title`\n2. Run the returned `curlCommand` in a shell (POST multipart to `uploadUrl`)\n3. Follow `consumeArgs`: **media prepare** (`cms_edit_media` / `media prepare --staged-ids`) for jpeg/png/webp/gif/mp4; **asset upload --staged** for SVG/PDF/Lottie\n4. For pipeline jobs: wait → catalog → **import** (required for video). Then link and save\n\nHosted limit: **4 MB** per staged file (Vercel body limit). Rate limit: **1000 upload URLs per user per hour**. TTL: **60 minutes**. Raster/video staged files are intake (GET by the pipeline); they are not consumed into CMA.\n\n## Featured images (articles)\n\nRead `cms-edit://customer/defaults` when present. Otherwise:\n\n1. **Custom** — set `featuredImage` or `featuredImageAssetFilename` on the article when the editor provides a specific image\n2. **Article type** — if omitted, cms-edit inherits the linked **articleType** `featuredImage`\n3. **Site default** — from `editor.defaults` in the site config (also in `defaults.json` in the editor pack)\n\nRun `[\"index\", \"sync\"]` before resolving assets by filename.\n\n## JSON payloads (filesystem vs no filesystem)\n\nHosted MCP cannot see your disk. Same commands either way:\n\n- **Filesystem client:** write `page.json`, then `cms_edit [\"create\", \"from-json\", \"--json-base64\", \"<base64 of file>\", \"--dry-run\", \"--strict\"]`\n- **No filesystem (Desktop):** put the JSON in `--json` on the tool call\n\nNever use a local `cms-edit` binary, `--file`, or stdin for content.\n\n## Create content\n\n### Create a page\n\n```\n[\"schema\", \"component\"]\n[\"help\", \"create-from-json\"]\n[\"create\", \"from-json\", \"--json\", \"{...}\", \"--dry-run\", \"--strict\"]\n[\"create\", \"from-json\", \"--json\", \"{...}\"]\n```\n\nUse `\"components\"` (not `\"content\"`) and nested `\"type\"` (not `\"componentType\"`). Peek a live entry or `schema <ct>` before authoring field ids.\n\nEmpty `components` fails validation. Incremental `add`/`set` is for tiny patches only.\n\n### Create an article\n\nEvery article requires an **articleType**:\n\n```\n[\"index\", \"sync\"]\n[\"list\", \"--type\", \"articleType\"]\n[\"create\", \"article\", \"--slug\", \"resources/blog/my-post\", \"--title\", \"My Post\", \"--article-type-slug\", \"resources/blog\"]\n```\n\nOr `create from-json` with `\"type\": \"article\"` and `articleTypeSlug` / `articleTypeId`.\n\nUse MCP prompt `cms_edit_create_article` for guided creation.\n\n## Common sequences\n\n### List all pages\n\n```\n[\"list\", \"--type\", \"page\"]\n```\n\n### Refresh local index (assets, media, templates, taxonomy)\n\nRun before asset filename search, media-by-filename list, or fast template/taxonomy lookup:\n\n```\n[\"index\", \"sync\"]\n[\"index\", \"status\"]\n[\"list\", \"--type\", \"template\"]\n```\n\nAsset search and media-by-filename list **require** the index. Template/taxonomy list prefers the index when built.\n\n### Explore the homepage\n\n```\n[\"open\", \"--page-slug\", \"/\"]\n[\"snapshot\"]\n[\"read\", \"@c1\"]\n```\n\n### Edit copy on a page\n\n```\n[\"open\", \"--page-slug\", \"{{EXAMPLE_SLUG}}\"]\n[\"snapshot\"]\n[\"read\", \"@c1\", \"heading\"]\n[\"set\", \"@c1\", \"heading\", \"Updated heading\"]\n[\"diff\"]\n[\"save\"]\n```\n\n## Field discovery\n\n```\n[\"schema\", \"component\"]\n[\"list\", \"--type\", \"page\"]\n[\"search\", \"pricing\"]\n```\n\n## Grok Build setup\n\nGrok connects to the same hosted MCP URL as Claude. Add to `~/.grok/config.toml`:\n\n```toml\n[mcp_servers.cms-edit-brightline]\nurl = \"https://brightline.content.se.studio/api/mcp\"\nenabled = true\n```\n\nReplace the server name and host with your site's deployment. The URL **must** end with `/api/mcp` (not the site root).\n\n**Connect:**\n\n1. In Grok, run `/mcps` and select your cms-edit server\n2. Press **`i`** to initiate OAuth (not just enable the toggle)\n3. Sign in with Contentful when the browser opens\n4. Verify with `grok mcp doctor <server-name>` or call `cms_edit_version`\n\nOAuth is two steps: Grok obtains an MCP token, then you sign in with Contentful to link your account. If the browser flashes and closes immediately, reconnect after upgrading cms-edit (loopback redirect handling).\n\n## Hosted connector rules\n\n{{HOSTED_RULES}}\n\n## Session tips\n\n- After `open`, subsequent MCP commands share session `_mcp` automatically (stored in Redis on hosted).\n- Use `--session <name>` only when juggling multiple pages — pass it **before** the subcommand on every call: `[\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"]`.\n- Snapshot JSON includes `sessionName` and `sessionKey` for debugging.\n- If you see \"No active session\", check `/api/health` (Redis must be ok), then run `open` again. Set `LOG_CMS_SESSION=1` on Vercel and search runtime logs for `[cms-edit:session]` (`redis save ok` / `redis load hit` / `requireSession miss`).\n\n### peek vs open vs read\n\n| Goal | MCP args |\n|------|----------|\n| Edit workflow (session) | `[\"open\", \"--page-slug\", \"/\"]` then `[\"read\", \"@c0\"]` |\n| Preview tree + fields, no session | `[\"peek\", \"--page-slug\", \"/pricing\"]` or `[\"peek\", \"--id\", \"<entry-id>\"]` (JSON includes `rootFields`) |\n| Read fields by entry ID, no session | `[\"read\", \"<entry-id>\", \"--id\"]` or `[\"read\", \"<entry-id>\", \"--id\", \"heading\"]` |\n| Debug session persistence | `[\"diagnose\"]` — reports store, userId, active session key |\n\n- **`peek` is one-shot** — prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.\n- **`open` / `nav open` persist** the session. `preview urls /slug` follows that slug even if leftover `_mcp` is another page (JSON may include `sessionRootIgnored`).\n- **Use flat lookup flags** for `open` and `peek` — same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`. `nav open` uses `--nav-id` or `--nav-name` only.\n- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.\n- **Do not invent flags** — there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.\n\n## Troubleshooting\n\n| Problem | What to do |\n|---------|------------|\n| **401 / connection failed** | Reconnect: Claude → Settings → Integrations, or Grok `/mcps` → press `i`. Complete Contentful sign-in. If Grok says “Failed to get tools after auth” or `auth required`, check Vercel `[cms-edit:oauth] auth_failure`. `invalid_refresh_token` is a rotated/missing MCP refresh UUID (fixed in **3.6.1+** by not rotating). `missing_contentful_token` / `invalid_contentful_token` means the CMA cache is gone — **3.5.3+** returns `invalid_token` so Grok re-runs Contentful sign-in. If it still loops, delete that server’s entry from `~/.grok/mcp_credentials.json` and press `i` again. Set `LOG_CMS_OAUTH=1` for connect success traces. |\n| **No cms_edit tool** | Confirm the integration is connected under Settings → Integrations |\n| **No active session** | Do not pass `--space` on hosted. Check `/api/health` — `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `[\"--session\", \"name\", \"open\", \"--page-slug\", \"/\"]`. Fallback: `[\"read\", \"<entry-id>\", \"--id\"]` |\n| **Wrong space** | Your Contentful account must have access to this deployment's space |\n| **Check version** | Call `cms_edit_version` or `curl /api/health` and read `cmsEdit` |\n\n## Articles\n\n**Recent articles** (by publication `date`, not last-updated):\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"]\n```\n\nAlternative: `[\"search\", \"<keyword>\", \"--type\", \"article\"]` (also sorts by date).\n\n**Draft articles** — `peek` and `open` load drafts via CMA (not published-only). To discover drafts:\n\n```json\n[\"list\", \"--type\", \"article\", \"--sort\", \"date\"]\n[\"search\", \"<title>\", \"--type\", \"article\"]\n[\"list\", \"--type\", \"article\", \"--slug\", \"<slug>\"]\n```\n\nThen open: `[\"peek\", \"--article-slug\", \"<slug>\"]` or `[\"open\", \"--id\", \"<entry-id>\"]`. Use `--article-slug`, not `--page-slug`.\n\n**Published-only** is opt-in: `list --published` and `resolve --published` use the Delivery API index and omit never-published drafts.\n\nAfter upgrading cms-edit, run `[\"index\", \"sync\"]` once so the local index includes article `date` values (schema v4).\n\n**Index freshness on hosted MCP:** The catalog index is shared via Redis (gzipped SQLite blob). `index status` on a cold instance may show **not built** until `list`, `open`, or another index command runs — that is normal. Committed writes (`save`, `create page`, `asset upload`, …) mark the index dirty; the next discovery command refreshes it. In-session `set` edits do not trigger a sync.\n\n## Command reference (cms_edit args)\n\n**Discovery:** `list --type <type>`, `search <query>`, `schema <contentType>`, `index sync`, `index status`\n\n**Reading:** `open --page-slug <slug>`, `open --id <id>`, `peek --page-slug <slug>`, `peek --id <id>`, `snapshot`, `read <ref>`, `read <ref> <field>`, `read <id> --id [field]`\n\n**Diagnostics:** `diagnose` — session store, userId, active session (after open/read issues)\n\n**Editing:** `set <ref> <field> <value>`, `rtf <ref> <field> --content \"<md>\"`, `diff`, `save`, `discard`\n\n**Creating:** `create from-json --json … --dry-run --strict`, `export from-json`, `apply from-json --json …`, `create page` / `create article` for empty shells, `add` for tiny inserts\n\n**Other:** `health`, `version`, `guide [topic]`\n";
|
|
3
3
|
//# sourceMappingURL=hosted-guide.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-guide.js","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG
|
|
1
|
+
{"version":3,"file":"hosted-guide.js","sourceRoot":"","sources":["../../src/generated/hosted-guide.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,omkBAAomkB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { HostedMcpInfo } from '../guide.js';
|
|
3
3
|
import type { RunCmsEditFn } from '../types.js';
|
|
4
|
-
export declare const TOOL_DESCRIPTION = "Run any cms-edit command. cms-edit edits Contentful draft content (no publishing).\n\nUse hosted MCP only for content. Do not run a local cms-edit binary, --file, or stdin for pages.\n\nJSON-first (preferred for a whole page):\n [\"schema\", \"component\"] then [\"schema\", \"types\", \"component\"] \u2014 field ids and enums for THIS space\n [\"help\", \"create-from-json\"] or cms_edit_help {topic:\"create-from-json\"}\n Filesystem client: write JSON on disk, send [\"create\", \"from-json\", \"--json-base64\", \"<b64>\", \"--dry-run\", \"--strict\"]\n No-filesystem client: [\"create\", \"from-json\", \"--json\", \"{...}\", \"--dry-run\", \"--strict\"]\n Then the same command without --dry-run. Never publish.\n Edit existing: [\"open\", \"--page-slug\", \"/x\"] \u2192 [\"export\", \"from-json\"] \u2192 edit JSON \u2192 [\"apply\", \"from-json\", \"--json-base64\", \"<b64>\"]\n Tiny patches only: set / rtf / add.\n\nUse cms_edit_version (no args) to check the installed version.\nUse cms_edit_help to read the getting-started guide or playbooks (including create-from-json).\n Topic \"workflow\" is the playbook; use topic \"guide/workflow\" for the short hosted-guide section.\nOutput: command JSON, then a last line {\"cma_requests\":N,\"cpa_requests\":N} (parse the last line for CMA counts; JSON.parse the command body separately).\nUse cms_edit_customer to read site-specific playbooks (articles, routing, blog-tag-matrix, etc.).\nIf Integrations only exposes cms_edit, use [\"customer\", \"index\"] or [\"customer\", \"resource=index\"] instead.\nRead the cms-edit://guide resource for the full guide.\n\nWorkflow (patches): open \u2192 snapshot \u2192 read/set/rtf/add/remove \u2192 diff \u2192 save\nAll saves create drafts only \u2014 a human must publish in Contentful.\n\nCRITICAL \u2014 sessions and open:\n set/rtf field edits are staged until save. Plain open while dirty HARD-FAILS (does not wipe silently).\n [\"open\", \"--resume\"] \u2014 re-print current session; keeps all staged edits (no Contentful refetch)\n [\"open\", \"--overwrite\", \"--id\", \"<id>\"] \u2014 abandon staged work and load a new entry\n [\"discard\"] then open \u2014 also valid abandon path\n Never re-open the same article mid-edit without save/discard \u2014 use --resume if you only need the tree again.\n\nCommon command sequences:\n [\"open\", \"--page-slug\", \"/\"] \u2014 homepage (CMS slug index; /index is equivalent)\n [\"open\", \"--page-slug\", \"/pricing\"] \u2014 load a page by slug (skips template menu/footer)\n [\"open\", \"--include-chrome\", \"--page-slug\", \"/pricing\"] \u2014 also fetch template nav chrome\n [\"open\", \"--id\", \"<entry-id>\"] \u2014 load by Contentful entry ID\n [\"open\", \"--resume\"] \u2014 keep staged work; re-print snapshot\n [\"snapshot\"] \u2014 print content tree with @refs\n [\"read\", \"@c0\"] \u2014 read all fields of a component (requires open session)\n [\"read\", \"@c0\", \"heading\"] \u2014 read a specific field (requires open session)\n [\"read\", \"@root\"] \u2014 read root entry fields (requires open session)\n [\"read\", \"<entry-id>\", \"--id\"] \u2014 read entry by ID (no session)\n [\"read\", \"<entry-id>\", \"--id\", \"heading\"] \u2014 read one field by entry ID (no session)\n [\"peek\", \"--page-slug\", \"/pricing\"] \u2014 preview tree + root fields (no session)\n [\"peek\", \"--id\", \"<entry-id>\"] \u2014 preview by entry ID with rootFields in JSON\n [\"set\", \"@c0\", \"heading\", \"New heading\"] \u2014 set a scalar field\n [\"set\", \"<entry-id>\", \"autoplay\", \"true\"] \u2014 mid-session scalar by ID (e.g. media; no re-open)\n [\"set\", \"<entry-id>:autoplay=true\"] \u2014 same, batch-shaped token on page session\n [\"set\", \"@c1\", \"visual\", \"<media-id>\", \"--link\"] \u2014 single Entry link field only\n [\"set\", \"@c2\", \"contents\", \"<id1>,<id2>\", \"--links\"] \u2014 array of links (full replace); never --link on arrays\n [\"rtf\", \"@c0\", \"body\", \"--content\", \"# H1\\n\\nBody.\"] \u2014 set rich text (preferred for AI)\n [\"rtf\", \"@c0\", \"body\", \"--base64\", \"<encoded>\"] \u2014 set rich text via base64 (no filesystem)\n [\"diff\"] \u2014 show pending changes\n [\"save\"] \u2014 write drafts to Contentful\n [\"discard\"] \u2014 discard unsaved changes\n [\"links\", \"set\", \"@c0\", \"0\", \"variant\", \"link\"] \u2014 set scalar field on link at index 0\n [\"batch\", \"set\", \"<entry-id>:variant=link\"] \u2014 scalar by ID (OK mid-page session; then save)\n [\"batch\", \"diff\"] \u2014 show pending batch edits\n [\"batch\", \"save\"] \u2014 save all batch edits as drafts\n [\"health\"] \u2014 verify config and connectivity\n [\"diagnose\"] \u2014 session/MCP diagnostics (store, userId, active session)\n [\"version\"] \u2014 print installed cms-edit version\n [\"guide\"] \u2014 print getting-started guide\n [\"guide\", \"workflow\"] \u2014 print a guide section\n [\"customer\", \"index\"] \u2014 list site editor playbooks\n [\"customer\", \"articles\"] \u2014 read articles playbook\n [\"customer\", \"resource=index\"] \u2014 same as index (Integrations fallback)\n [\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"] \u2014 recent articles by publication date\n [\"list\", \"--type\", \"article\", \"--sort\", \"date\"] \u2014 list articles (preview index includes drafts)\n [\"peek\", \"--article-slug\", \"<slug>\"] \u2014 preview draft or published article (CMA)\n [\"preview\", \"url\", \"/pricing\"] \u2014 staging page URL (open in browser MCP)\n [\"preview\", \"urls\", \"/pricing\"] \u2014 all preview targets
|
|
4
|
+
export declare const TOOL_DESCRIPTION = "Run any cms-edit command. cms-edit edits Contentful draft content (no publishing).\n\nUse hosted MCP only for content. Do not run a local cms-edit binary, --file, or stdin for pages.\n\nJSON-first (preferred for a whole page):\n [\"schema\", \"component\"] then [\"schema\", \"types\", \"component\"] \u2014 field ids and enums for THIS space\n [\"help\", \"create-from-json\"] or cms_edit_help {topic:\"create-from-json\"}\n Filesystem client: write JSON on disk, send [\"create\", \"from-json\", \"--json-base64\", \"<b64>\", \"--dry-run\", \"--strict\"]\n No-filesystem client: [\"create\", \"from-json\", \"--json\", \"{...}\", \"--dry-run\", \"--strict\"]\n Then the same command without --dry-run. Never publish.\n Edit existing: [\"open\", \"--page-slug\", \"/x\"] \u2192 [\"export\", \"from-json\"] \u2192 edit JSON \u2192 [\"apply\", \"from-json\", \"--json-base64\", \"<b64>\"]\n Tiny patches only: set / rtf / add.\n\nUse cms_edit_version (no args) to check the installed version.\nUse cms_edit_help to read the getting-started guide or playbooks (including create-from-json).\n Topic \"workflow\" is the playbook; use topic \"guide/workflow\" for the short hosted-guide section.\nOutput: command JSON, then a last line {\"cma_requests\":N,\"cpa_requests\":N} (parse the last line for CMA counts; JSON.parse the command body separately).\nUse cms_edit_customer to read site-specific playbooks (articles, routing, blog-tag-matrix, etc.).\nIf Integrations only exposes cms_edit, use [\"customer\", \"index\"] or [\"customer\", \"resource=index\"] instead.\nRead the cms-edit://guide resource for the full guide.\n\nWorkflow (patches): open \u2192 snapshot \u2192 read/set/rtf/add/remove \u2192 diff \u2192 save\nAll saves create drafts only \u2014 a human must publish in Contentful.\n\nCRITICAL \u2014 sessions and open:\n set/rtf field edits are staged until save. Plain open while dirty HARD-FAILS (does not wipe silently).\n [\"open\", \"--resume\"] \u2014 re-print current session; keeps all staged edits (no Contentful refetch)\n [\"open\", \"--overwrite\", \"--id\", \"<id>\"] \u2014 abandon staged work and load a new entry\n [\"discard\"] then open \u2014 also valid abandon path\n Never re-open the same article mid-edit without save/discard \u2014 use --resume if you only need the tree again.\n\nCommon command sequences:\n [\"open\", \"--page-slug\", \"/\"] \u2014 homepage (CMS slug index; /index is equivalent)\n [\"open\", \"--page-slug\", \"/pricing\"] \u2014 load a page by slug (skips template menu/footer)\n [\"open\", \"--include-chrome\", \"--page-slug\", \"/pricing\"] \u2014 also fetch template nav chrome\n [\"open\", \"--id\", \"<entry-id>\"] \u2014 load by Contentful entry ID\n [\"open\", \"--resume\"] \u2014 keep staged work; re-print snapshot\n [\"snapshot\"] \u2014 print content tree with @refs\n [\"read\", \"@c0\"] \u2014 read all fields of a component (requires open session)\n [\"read\", \"@c0\", \"heading\"] \u2014 read a specific field (requires open session)\n [\"read\", \"@root\"] \u2014 read root entry fields (requires open session)\n [\"read\", \"<entry-id>\", \"--id\"] \u2014 read entry by ID (no session)\n [\"read\", \"<entry-id>\", \"--id\", \"heading\"] \u2014 read one field by entry ID (no session)\n [\"peek\", \"--page-slug\", \"/pricing\"] \u2014 preview tree + root fields (no session)\n [\"peek\", \"--id\", \"<entry-id>\"] \u2014 preview by entry ID with rootFields in JSON\n [\"set\", \"@c0\", \"heading\", \"New heading\"] \u2014 set a scalar field\n [\"set\", \"<entry-id>\", \"autoplay\", \"true\"] \u2014 mid-session scalar by ID (e.g. media; no re-open)\n [\"set\", \"<entry-id>:autoplay=true\"] \u2014 same, batch-shaped token on page session\n [\"set\", \"@c1\", \"visual\", \"<media-id>\", \"--link\"] \u2014 single Entry link field only\n [\"set\", \"@c2\", \"contents\", \"<id1>,<id2>\", \"--links\"] \u2014 array of links (full replace); never --link on arrays\n [\"rtf\", \"@c0\", \"body\", \"--content\", \"# H1\\n\\nBody.\"] \u2014 set rich text (preferred for AI)\n [\"rtf\", \"@c0\", \"body\", \"--base64\", \"<encoded>\"] \u2014 set rich text via base64 (no filesystem)\n [\"diff\"] \u2014 show pending changes\n [\"save\"] \u2014 write drafts to Contentful\n [\"discard\"] \u2014 discard unsaved changes\n [\"links\", \"set\", \"@c0\", \"0\", \"variant\", \"link\"] \u2014 set scalar field on link at index 0\n [\"batch\", \"set\", \"<entry-id>:variant=link\"] \u2014 scalar by ID (OK mid-page session; then save)\n [\"batch\", \"diff\"] \u2014 show pending batch edits\n [\"batch\", \"save\"] \u2014 save all batch edits as drafts\n [\"health\"] \u2014 verify config and connectivity\n [\"diagnose\"] \u2014 session/MCP diagnostics (store, userId, active session)\n [\"version\"] \u2014 print installed cms-edit version\n [\"guide\"] \u2014 print getting-started guide\n [\"guide\", \"workflow\"] \u2014 print a guide section\n [\"customer\", \"index\"] \u2014 list site editor playbooks\n [\"customer\", \"articles\"] \u2014 read articles playbook\n [\"customer\", \"resource=index\"] \u2014 same as index (Integrations fallback)\n [\"list\", \"--type\", \"article\", \"--sort\", \"date\", \"-n\", \"10\"] \u2014 recent articles by publication date\n [\"list\", \"--type\", \"article\", \"--sort\", \"date\"] \u2014 list articles (preview index includes drafts)\n [\"peek\", \"--article-slug\", \"<slug>\"] \u2014 preview draft or published article (CMA)\n [\"preview\", \"url\", \"/pricing\"] \u2014 staging page URL (open in browser MCP)\n [\"preview\", \"urls\", \"/pricing\"] \u2014 all preview targets; slug wins over leftover session root\n [\"nav\", \"open\", \"--nav-id\", \"<id>\"] \u2014 persist a navigation session (not --id)\n [\"nav\", \"open\", \"--nav-name\", \"Main menu\"] \u2014 same by navigation name\n [\"preview\", \"showcase\", \"--component\", \"HeroSimple\"] \u2014 component showcase URL (mock data)\n [\"preview\", \"showcase\", \"--collection\", \"CardGrid\", \"--param\", \"backgroundColour=Navy\"]\n\nDiscovery notes:\n Visual checks: use preview url / preview showcase, then open the returned URL with a browser MCP (cms-edit does not capture screenshots).\n peek/open/read --id load draft content via CMA \u2014 NOT published-only.\n Only list --published / resolve --published use the published-only Delivery API index.\n Articles: use --article-slug (not --page-slug). search --type article sorts by publication date.\n\nSessions persist between MCP calls (Redis on hosted, disk locally). MCP auto-uses session \"_mcp\" unless you pass --session.\nUse --session <name> before the subcommand to isolate concurrent workflows, e.g. [\"--session\", \"my-work\", \"open\", \"--page-slug\", \"/\"].\nUse --space <name> to target a specific Contentful space (local MCP only \u2014 omit for hosted Integrations).\nStateless read (no open required): [\"read\", \"<entry-id>\", \"--id\"] or [\"read\", \"<entry-id>\", \"--id\", \"heading\"].\npeek is one-shot (no session). open / nav open persist. preview urls /slug follows that slug even if _mcp is another page (JSON may include sessionRootIgnored).\nBefore set on a nested nav item (often a shared header CTA): ask whether the change is global or page-specific. Page-specific \u2192 new NavigationItem + page.menu (or a cloned menu), do not mutate the shared entry.\nTemplate menu is site-wide; page.menu overrides one page. nav clone is shallow for nested navigationItems.\nOutput is always JSON (CMS_EDIT_JSON=1 is forced by the MCP server).\n\n\nRich text tips:\n --content \"<markdown>\" preferred named flag for inline content (any length)\n --base64 \"<encoded>\" fully environment-agnostic, no filesystem needed\n\nJSON bulk input (create from-json, batch run, taxonomy/person/article-tags imports, set object fields, rtf patch):\n --json \"<string>\" inline JSON (small payloads)\n --json-base64 \"<b64>\" base64-encoded JSON (large payloads)\n\nAsset upload (hosted MCP):\n Raster/video: cms_edit_request_staged_upload \u2192 curl \u2192 cms_edit_media prepare with stagedUploadIds \u2192 wait \u2192 catalog \u2192 import (video: import only; overrides[].alt required). Never asset upload --staged/--base64 for jpeg/png/webp/gif/mp4. Never asset upload --url for video.\n SVG/PDF/Lottie: [\"staged-upload\", \"request\", ...] then curl, then [\"asset\", \"upload\", \"--staged\", \"<id>\", ...].\n Pipeline ready **image** URLs may use import or asset upload --url on a Blob pack host.";
|
|
5
5
|
export declare function registerCmsEditTools(server: McpServer, runCmsEdit: RunCmsEditFn, hosted?: HostedMcpInfo): void;
|
|
6
6
|
export declare function getMcpServerInfo(hosted?: HostedMcpInfo): {
|
|
7
7
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-edit.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"cms-edit.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,gBAAgB,iiTAwG6D,CAAC;AAE3F,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,YAAY,EACxB,MAAM,CAAC,EAAE,aAAa,GACrB,IAAI,CAmEN;AAED,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAE1F"}
|
|
@@ -74,7 +74,9 @@ Common command sequences:
|
|
|
74
74
|
["list", "--type", "article", "--sort", "date"] — list articles (preview index includes drafts)
|
|
75
75
|
["peek", "--article-slug", "<slug>"] — preview draft or published article (CMA)
|
|
76
76
|
["preview", "url", "/pricing"] — staging page URL (open in browser MCP)
|
|
77
|
-
["preview", "urls", "/pricing"] — all preview targets
|
|
77
|
+
["preview", "urls", "/pricing"] — all preview targets; slug wins over leftover session root
|
|
78
|
+
["nav", "open", "--nav-id", "<id>"] — persist a navigation session (not --id)
|
|
79
|
+
["nav", "open", "--nav-name", "Main menu"] — same by navigation name
|
|
78
80
|
["preview", "showcase", "--component", "HeroSimple"] — component showcase URL (mock data)
|
|
79
81
|
["preview", "showcase", "--collection", "CardGrid", "--param", "backgroundColour=Navy"]
|
|
80
82
|
|
|
@@ -85,10 +87,12 @@ Discovery notes:
|
|
|
85
87
|
Articles: use --article-slug (not --page-slug). search --type article sorts by publication date.
|
|
86
88
|
|
|
87
89
|
Sessions persist between MCP calls (Redis on hosted, disk locally). MCP auto-uses session "_mcp" unless you pass --session.
|
|
88
|
-
Use --session <name> before the subcommand to isolate concurrent workflows, e.g. ["--session", "my-work", "open", "/"].
|
|
90
|
+
Use --session <name> before the subcommand to isolate concurrent workflows, e.g. ["--session", "my-work", "open", "--page-slug", "/"].
|
|
89
91
|
Use --space <name> to target a specific Contentful space (local MCP only — omit for hosted Integrations).
|
|
90
92
|
Stateless read (no open required): ["read", "<entry-id>", "--id"] or ["read", "<entry-id>", "--id", "heading"].
|
|
91
|
-
peek is one-shot (no session)
|
|
93
|
+
peek is one-shot (no session). open / nav open persist. preview urls /slug follows that slug even if _mcp is another page (JSON may include sessionRootIgnored).
|
|
94
|
+
Before set on a nested nav item (often a shared header CTA): ask whether the change is global or page-specific. Page-specific → new NavigationItem + page.menu (or a cloned menu), do not mutate the shared entry.
|
|
95
|
+
Template menu is site-wide; page.menu overrides one page. nav clone is shallow for nested navigationItems.
|
|
92
96
|
Output is always JSON (CMS_EDIT_JSON=1 is forced by the MCP server).
|
|
93
97
|
|
|
94
98
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-edit.js","sourceRoot":"","sources":["../../../src/mcp/tools/cms-edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAA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,EAAE,GAAG,CAAC,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC/B,UAAU,CAAC,eAAe,EAAE;YAC1B,UAAU;YACV,IAAI,EAAE,UAAU,IAAI,MAAM;YAC1B,EAAE,EAAE,CAAC,UAAU;YACf,WAAW,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;SACxC,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACxD,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAsB;IACrD,OAAO,EAAE,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SerializedEntry } from '../session/state.js';
|
|
2
|
+
export declare function slugFromSerializedEntry(entry: SerializedEntry | undefined, locale: string): string | undefined;
|
|
3
|
+
export interface PreviewEntryResolution {
|
|
4
|
+
/** Use session root when slug lookup yields nothing. */
|
|
5
|
+
sessionFallbackId?: string;
|
|
6
|
+
/** Session root slug disagreed with the requested slug — do not use session entry id. */
|
|
7
|
+
sessionRootIgnored: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Decides whether leftover session root may supply preview entry id.
|
|
11
|
+
* Explicit `--entry-id` is handled by the caller (never call this for that path).
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolvePreviewSessionFallback(options: {
|
|
14
|
+
requestedSlug: string | undefined;
|
|
15
|
+
sessionRootId: string | undefined;
|
|
16
|
+
sessionRootSlug: string | undefined;
|
|
17
|
+
}): PreviewEntryResolution;
|
|
18
|
+
//# sourceMappingURL=resolve-preview-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-preview-entry.d.ts","sourceRoot":"","sources":["../../src/preview/resolve-preview-entry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAIpB;AAOD,MAAM,WAAW,sBAAsB;IACrC,wDAAwD;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yFAAyF;IACzF,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE;IACrD,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,GAAG,sBAAsB,CAYzB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { normalizeSlug } from '../contentful/fetch.js';
|
|
2
|
+
export function slugFromSerializedEntry(entry, locale) {
|
|
3
|
+
if (!entry)
|
|
4
|
+
return undefined;
|
|
5
|
+
const slugVal = entry.fields['slug']?.[locale] ?? entry.fields['slug']?.['en-US'];
|
|
6
|
+
return typeof slugVal === 'string' && slugVal ? slugVal : undefined;
|
|
7
|
+
}
|
|
8
|
+
function slugsEqual(a, b) {
|
|
9
|
+
if (!a || !b)
|
|
10
|
+
return false;
|
|
11
|
+
return normalizeSlug(a.replace(/^\//, '')) === normalizeSlug(b.replace(/^\//, ''));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Decides whether leftover session root may supply preview entry id.
|
|
15
|
+
* Explicit `--entry-id` is handled by the caller (never call this for that path).
|
|
16
|
+
*/
|
|
17
|
+
export function resolvePreviewSessionFallback(options) {
|
|
18
|
+
const { requestedSlug, sessionRootId, sessionRootSlug } = options;
|
|
19
|
+
if (!sessionRootId) {
|
|
20
|
+
return { sessionRootIgnored: false };
|
|
21
|
+
}
|
|
22
|
+
if (!requestedSlug) {
|
|
23
|
+
return { sessionFallbackId: sessionRootId, sessionRootIgnored: false };
|
|
24
|
+
}
|
|
25
|
+
if (slugsEqual(requestedSlug, sessionRootSlug)) {
|
|
26
|
+
return { sessionFallbackId: sessionRootId, sessionRootIgnored: false };
|
|
27
|
+
}
|
|
28
|
+
return { sessionRootIgnored: true };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=resolve-preview-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-preview-entry.js","sourceRoot":"","sources":["../../src/preview/resolve-preview-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,MAAM,UAAU,uBAAuB,CACrC,KAAkC,EAClC,MAAc;IAEd,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAClF,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,UAAU,CAAC,CAAqB,EAAE,CAAqB;IAC9D,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACrF,CAAC;AASD;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAI7C;IACC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAClE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACzE,CAAC;IACD,IAAI,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,EAAE,CAAC;QAC/C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACzE,CAAC;IACD,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ContentTypeProps } from 'contentful-management';
|
|
2
|
+
export declare const NAVIGATION_ITEM_ARRAY_FIELD_IDS: readonly ['entries', 'items', 'navigationItems'];
|
|
3
|
+
export type NavigationItemArrayFieldId = (typeof NAVIGATION_ITEM_ARRAY_FIELD_IDS)[number];
|
|
4
|
+
export declare function schemaFieldIdSet(ct: ContentTypeProps | undefined): Set<string> | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Field id for a navigation's item array.
|
|
7
|
+
* Prefers a populated field among entries / items / navigationItems (optionally
|
|
8
|
+
* restricted to the content type). Empty nav: first allowed id, else `items`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function pickNavigationItemsFieldId(locale: string, entryFields?: Record<string, Record<string, unknown>>, schemaFieldIds?: ReadonlySet<string>): NavigationItemArrayFieldId;
|
|
11
|
+
export declare function clonedItemsHaveSharedNestedChildren(itemFields: Array<Record<string, Record<string, unknown>>>, locale: string): boolean;
|
|
12
|
+
export declare function buildClonedNavigationFields(options: {
|
|
13
|
+
sourceFields: Record<string, Record<string, unknown>>;
|
|
14
|
+
locale: string;
|
|
15
|
+
schemaFieldIds: ReadonlySet<string>;
|
|
16
|
+
newLabel: string;
|
|
17
|
+
newSlug: string;
|
|
18
|
+
newItemIds: string[];
|
|
19
|
+
}): Record<string, Record<string, unknown>>;
|
|
20
|
+
export declare function defaultCloneNavLabel(sourceFields: Record<string, Record<string, unknown>>, locale: string, fallback: string): string;
|
|
21
|
+
//# sourceMappingURL=navigation-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-fields.d.ts","sourceRoot":"","sources":["../../src/session/navigation-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,eAAO,MAAM,+BAA+B,YAAI,SAAS,EAAE,OAAO,EAAE,iBAAiB,CAAU,CAAC;AAEhG,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAI1F,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,gBAAgB,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAG1F;AAaD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrD,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,0BAA0B,CAe5B;AAED,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAC1D,MAAM,EAAE,MAAM,GACb,OAAO,CAQT;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2B1C;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CAQR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export const NAVIGATION_ITEM_ARRAY_FIELD_IDS = ['entries', 'items', 'navigationItems'];
|
|
2
|
+
const CLONE_LABEL_FIELD_IDS = ['name', 'adminLabel', 'label'];
|
|
3
|
+
export function schemaFieldIdSet(ct) {
|
|
4
|
+
if (!ct?.fields)
|
|
5
|
+
return undefined;
|
|
6
|
+
return new Set(ct.fields.map((field) => field.id));
|
|
7
|
+
}
|
|
8
|
+
function arrayValue(fields, fieldId, locale) {
|
|
9
|
+
const fieldData = fields?.[fieldId];
|
|
10
|
+
if (!fieldData || typeof fieldData !== 'object')
|
|
11
|
+
return undefined;
|
|
12
|
+
const items = fieldData[locale] ?? fieldData['en-US'];
|
|
13
|
+
return Array.isArray(items) ? items : undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Field id for a navigation's item array.
|
|
17
|
+
* Prefers a populated field among entries / items / navigationItems (optionally
|
|
18
|
+
* restricted to the content type). Empty nav: first allowed id, else `items`.
|
|
19
|
+
*/
|
|
20
|
+
export function pickNavigationItemsFieldId(locale, entryFields, schemaFieldIds) {
|
|
21
|
+
const allowed = NAVIGATION_ITEM_ARRAY_FIELD_IDS.filter((id) => schemaFieldIds ? schemaFieldIds.has(id) : true);
|
|
22
|
+
const pool = allowed.length > 0 ? allowed : ['items'];
|
|
23
|
+
for (const fieldId of pool) {
|
|
24
|
+
if (arrayValue(entryFields, fieldId, locale)) {
|
|
25
|
+
return fieldId;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (schemaFieldIds && pool.at(0)) {
|
|
29
|
+
return pool[0] ?? 'items';
|
|
30
|
+
}
|
|
31
|
+
return 'items';
|
|
32
|
+
}
|
|
33
|
+
export function clonedItemsHaveSharedNestedChildren(itemFields, locale) {
|
|
34
|
+
for (const fields of itemFields) {
|
|
35
|
+
const nested = arrayValue(fields, 'navigationItems', locale);
|
|
36
|
+
if (nested && nested.length > 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
export function buildClonedNavigationFields(options) {
|
|
43
|
+
const { sourceFields, locale, schemaFieldIds, newLabel, newSlug, newItemIds } = options;
|
|
44
|
+
const itemsFieldId = pickNavigationItemsFieldId(locale, sourceFields, schemaFieldIds);
|
|
45
|
+
const next = {};
|
|
46
|
+
for (const [key, value] of Object.entries(sourceFields)) {
|
|
47
|
+
if (!schemaFieldIds.has(key))
|
|
48
|
+
continue;
|
|
49
|
+
if (key === itemsFieldId)
|
|
50
|
+
continue;
|
|
51
|
+
next[key] = { ...value };
|
|
52
|
+
}
|
|
53
|
+
for (const fieldId of CLONE_LABEL_FIELD_IDS) {
|
|
54
|
+
if (schemaFieldIds.has(fieldId)) {
|
|
55
|
+
next[fieldId] = { [locale]: newLabel };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (newSlug && schemaFieldIds.has('slug')) {
|
|
59
|
+
next['slug'] = { [locale]: newSlug };
|
|
60
|
+
}
|
|
61
|
+
if (schemaFieldIds.has(itemsFieldId)) {
|
|
62
|
+
next[itemsFieldId] = {
|
|
63
|
+
[locale]: newItemIds.map((id) => ({
|
|
64
|
+
sys: { type: 'Link', linkType: 'Entry', id },
|
|
65
|
+
})),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return next;
|
|
69
|
+
}
|
|
70
|
+
export function defaultCloneNavLabel(sourceFields, locale, fallback) {
|
|
71
|
+
const get = (id) => sourceFields[id]?.[locale] ?? sourceFields[id]?.['en-US'] ?? null;
|
|
72
|
+
for (const id of ['name', 'adminLabel', 'label', 'title']) {
|
|
73
|
+
const value = get(id);
|
|
74
|
+
if (typeof value === 'string' && value)
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
return fallback;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=navigation-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-fields.js","sourceRoot":"","sources":["../../src/session/navigation-fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,iBAAiB,CAAU,CAAC;AAIhG,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAU,CAAC;AAEvE,MAAM,UAAU,gBAAgB,CAAC,EAAgC;IAC/D,IAAI,CAAC,EAAE,EAAE,MAAM;QAAE,OAAO,SAAS,CAAC;IAClC,OAAO,IAAI,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CACjB,MAA2D,EAC3D,OAAe,EACf,MAAc;IAEd,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC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AM,GAAG,GAAG,CAAC,EAAU,EAAW,EAAE,CAClC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACpE,KAAK,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAU,EAAE,CAAC;QACnE,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;QACtB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/session/refs.d.ts
CHANGED
|
@@ -18,10 +18,10 @@ export declare function findTreeNode(session: SessionState, ref: string): TreeNo
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function buildTree(rootEntryId: string, entries: Record<string, SerializedEntry>, locale: string): Pick<SessionState, 'refs' | 'refsByEntry' | 'treeNodes'>;
|
|
20
20
|
/**
|
|
21
|
-
* Returns the field name for a navigation's item array
|
|
22
|
-
*
|
|
21
|
+
* Returns the field name for a navigation's item array
|
|
22
|
+
* (`entries`, `items`, or `navigationItems`).
|
|
23
23
|
*/
|
|
24
|
-
export declare function getNavigationItemsFieldName(entry: SerializedEntry, locale: string): string;
|
|
24
|
+
export declare function getNavigationItemsFieldName(entry: SerializedEntry, locale: string, schemaFieldIds?: ReadonlySet<string>): string;
|
|
25
25
|
/**
|
|
26
26
|
* Creates a Contentful entry link object for inserting into content arrays.
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/session/refs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/session/refs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAoB1E;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,CAgB9E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAGhF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACxC,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,WAAW,CAAC,CA0D1D;AAUD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,MAAM,CAER;AAYD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG;IAC9C,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD,CAEA;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG;IAC9C,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD,CAEA"}
|
package/dist/session/refs.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pickNavigationItemsFieldId } from './navigation-fields.js';
|
|
1
2
|
/**
|
|
2
3
|
* Normalises a ref string, resolving the special alias @root to the root entry's @cN ref.
|
|
3
4
|
* Ensures the result always starts with @.
|
|
@@ -107,28 +108,18 @@ export function buildTree(rootEntryId, entries, locale) {
|
|
|
107
108
|
return { refs, refsByEntry, treeNodes };
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
|
-
* For navigation entries, returns the single array field to expand
|
|
111
|
-
* Prefers 'items' if both exist and are arrays.
|
|
111
|
+
* For navigation entries, returns the single array field to expand.
|
|
112
112
|
*/
|
|
113
113
|
function getNavigationItemsField(entry, locale) {
|
|
114
114
|
const name = getNavigationItemsFieldName(entry, locale);
|
|
115
115
|
return name ? [name] : [];
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* Returns the field name for a navigation's item array
|
|
119
|
-
*
|
|
118
|
+
* Returns the field name for a navigation's item array
|
|
119
|
+
* (`entries`, `items`, or `navigationItems`).
|
|
120
120
|
*/
|
|
121
|
-
export function getNavigationItemsFieldName(entry, locale) {
|
|
122
|
-
|
|
123
|
-
for (const fieldId of ['items', 'navigationItems']) {
|
|
124
|
-
const fieldData = entry.fields[fieldId];
|
|
125
|
-
if (!fieldData || typeof fieldData !== 'object')
|
|
126
|
-
continue;
|
|
127
|
-
const items = fieldData[locale] ?? fieldData[fallback];
|
|
128
|
-
if (Array.isArray(items))
|
|
129
|
-
return fieldId;
|
|
130
|
-
}
|
|
131
|
-
return 'items';
|
|
121
|
+
export function getNavigationItemsFieldName(entry, locale, schemaFieldIds) {
|
|
122
|
+
return pickNavigationItemsFieldId(locale, entry.fields, schemaFieldIds);
|
|
132
123
|
}
|
|
133
124
|
function isEntryLink(item) {
|
|
134
125
|
return (typeof item === 'object' &&
|
package/dist/session/refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/session/refs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/session/refs.ts"],"names":[],"mappings":"AAAA,OAAO,E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;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAG3C,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAG3C,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -18,16 +18,21 @@
|
|
|
18
18
|
## Steps
|
|
19
19
|
|
|
20
20
|
1. `cms_edit ["list", "--type", "navigation"]` — find nav entry
|
|
21
|
-
2. `cms_edit ["nav", "open", "--id", "<navigationId>"]` or
|
|
22
|
-
3. `snapshot` — inspect nav items
|
|
23
|
-
4.
|
|
24
|
-
|
|
21
|
+
2. `cms_edit ["nav", "open", "--nav-id", "<navigationId>"]` or `["nav", "open", "--nav-name", "Main menu"]` — **not** `--id`
|
|
22
|
+
3. `snapshot` — inspect nav items (array field may be `entries`, `items`, or `navigationItems`)
|
|
23
|
+
4. **Ask** whether the change is **global** (template `menu`) or **page-specific** (`page.menu` override). Nested children (often the last header CTA) are usually **shared**.
|
|
24
|
+
- Global: `set` on the existing NavigationItem
|
|
25
|
+
- Page-specific: new NavigationItem + cloned/new menu, then `set` `page.menu` — do not mutate the shared item
|
|
26
|
+
5. Add/clone/link items per navigation commands. `nav clone` is **shallow** for nested `navigationItems`.
|
|
27
|
+
6. `diff` → `save`
|
|
28
|
+
|
|
29
|
+
`peek` is one-shot. `open` / `nav open` persist. `preview urls /slug` follows that slug even if session `_mcp` is another page.
|
|
25
30
|
|
|
26
31
|
See `contentful-cms-navigation` skill for full command reference in dev environments.
|
|
27
32
|
|
|
28
33
|
## Confirmation gates
|
|
29
34
|
|
|
30
|
-
1. Confirm which menu (header/footer) and
|
|
35
|
+
1. Confirm which menu (header/footer) and whether the edit is global vs this page
|
|
31
36
|
2. `diff` before `save`
|
|
32
37
|
|
|
33
38
|
## Out of scope
|
|
@@ -36,4 +41,4 @@ See `contentful-cms-navigation` skill for full command reference in dev environm
|
|
|
36
41
|
|
|
37
42
|
## Related resources
|
|
38
43
|
|
|
39
|
-
- `cms-edit://customer/routing`
|
|
44
|
+
- `cms-edit://customer/routing`
|
package/docs/help/lookup.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
# Flat lookup flags (`open`, `
|
|
1
|
+
# Flat lookup flags (`open`, `peek`, `resolve`)
|
|
2
2
|
|
|
3
|
-
cms-edit resolves entries using **explicit flags** — not positional slugs. Provide **exactly one** primary lookup flag per command. Scope flags (for example `--tag-type-name` with `--tag-name`) do not count as a second primary.
|
|
3
|
+
cms-edit resolves entries using **explicit flags** — not positional slugs. Provide **exactly one** primary lookup flag per command. Scope flags (for example `--tag-type-name` with `--tag-name`, or `--nav-id` with `--nav-item-title`) do not count as a second primary.
|
|
4
|
+
|
|
5
|
+
`cms-edit nav open` is separate: pass **`--nav-id` or `--nav-name`**, never `--id`. `--nav-id` alone is not a `resolve` primary.
|
|
4
6
|
|
|
5
7
|
Run `cms-edit index sync` once per space (or let commands auto-sync) so catalog types resolve from the local index.
|
|
6
8
|
|
|
@@ -98,9 +100,10 @@ Navigation entries use the **`name`** field (not slug).
|
|
|
98
100
|
| `--nav-item-id` | `navigationItem` entry ID |
|
|
99
101
|
| `--nav-item-title` | `navigationItem.fields.title` |
|
|
100
102
|
|
|
101
|
-
When multiple nav items share a title, add **`--nav-id`** to scope:
|
|
103
|
+
When multiple nav items share a title, add **`--nav-id`** to scope `resolve` (do not use `--nav-id` alone on `resolve`):
|
|
102
104
|
|
|
103
105
|
```bash
|
|
106
|
+
cms-edit nav open --nav-id <navigation-entry-id>
|
|
104
107
|
cms-edit nav open --nav-name "Main header"
|
|
105
108
|
cms-edit resolve --nav-item-title "Contact" --nav-id <navigation-entry-id>
|
|
106
109
|
```
|
package/docs/mcp/hosted-guide.md
CHANGED
|
@@ -88,7 +88,7 @@ Each step is a separate `cms_edit` call. Sessions persist in Redis between calls
|
|
|
88
88
|
["open", "--include-chrome", "--page-slug", "/pricing"]
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
Default `open` / `peek` fetch the page or article tree and the template entry, but **not** template menu/footer/navigation. Edit nav with `nav open
|
|
91
|
+
Default `open` / `peek` fetch the page or article tree and the template entry, but **not** template menu/footer/navigation. Edit nav with `["nav", "open", "--nav-id", "<id>"]` or `--nav-name` (not `--id`). Use `--include-chrome` only when you need those trees. Template `menu` is site-wide; `page.menu` overrides one page. Nested nav items are often shared — ask global vs page-specific before `set`.
|
|
92
92
|
|
|
93
93
|
**Homepage (all SE Studio sites):** Contentful stores the marketing homepage slug as `index`. The live site URL is `/`. In cms-edit, `--page-slug /` and `--page-slug /index` are equivalent (both resolve to `index`). Read `cms-edit://customer/routing` for site-specific exceptions (e.g. Pedestal uses `home`).
|
|
94
94
|
|
|
@@ -311,7 +311,8 @@ OAuth is two steps: Grok obtains an MCP token, then you sign in with Contentful
|
|
|
311
311
|
| Debug session persistence | `["diagnose"]` — reports store, userId, active session key |
|
|
312
312
|
|
|
313
313
|
- **`peek` is one-shot** — prints tree and **root field values** (`rootFields` in JSON). No session is created; do not chain `read @ref` afterward.
|
|
314
|
-
-
|
|
314
|
+
- **`open` / `nav open` persist** the session. `preview urls /slug` follows that slug even if leftover `_mcp` is another page (JSON may include `sessionRootIgnored`).
|
|
315
|
+
- **Use flat lookup flags** for `open` and `peek` — same as CLI (`--page-slug`, `--id`, etc.). See `help lookup`. `nav open` uses `--nav-id` or `--nav-name` only.
|
|
315
316
|
- **`read @root`** only works after `open` (uses the active session). The hint in peek output is for terminal users who already ran `open`.
|
|
316
317
|
- **Do not invent flags** — there is no `--read`, `--then`, or chained peek+read syntax. One command per `cms_edit` call.
|
|
317
318
|
|