@se-studio/contentful-cms 3.2.1 → 3.3.0

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cli/program.d.ts.map +1 -1
  3. package/dist/cli/program.js +2 -0
  4. package/dist/cli/program.js.map +1 -1
  5. package/dist/commands/media.d.ts +4 -0
  6. package/dist/commands/media.d.ts.map +1 -0
  7. package/dist/commands/media.js +124 -0
  8. package/dist/commands/media.js.map +1 -0
  9. package/dist/generated/version.d.ts +1 -1
  10. package/dist/generated/version.js +1 -1
  11. package/dist/hosted/index.d.ts +1 -0
  12. package/dist/hosted/index.d.ts.map +1 -1
  13. package/dist/hosted/index.js +1 -0
  14. package/dist/hosted/index.js.map +1 -1
  15. package/dist/hosted/next/routes/mcp.d.ts.map +1 -1
  16. package/dist/hosted/next/routes/mcp.js +3 -0
  17. package/dist/hosted/next/routes/mcp.js.map +1 -1
  18. package/dist/mcp/prompts/onboarding.d.ts.map +1 -1
  19. package/dist/mcp/prompts/onboarding.js +11 -8
  20. package/dist/mcp/prompts/onboarding.js.map +1 -1
  21. package/dist/mcp/server.d.ts.map +1 -1
  22. package/dist/mcp/server.js +2 -0
  23. package/dist/mcp/server.js.map +1 -1
  24. package/dist/mcp/tools/media.d.ts +4 -0
  25. package/dist/mcp/tools/media.d.ts.map +1 -0
  26. package/dist/mcp/tools/media.js +138 -0
  27. package/dist/mcp/tools/media.js.map +1 -0
  28. package/dist/media-pipeline/actions.d.ts +30 -0
  29. package/dist/media-pipeline/actions.d.ts.map +1 -0
  30. package/dist/media-pipeline/actions.js +257 -0
  31. package/dist/media-pipeline/actions.js.map +1 -0
  32. package/dist/media-pipeline/client.d.ts +67 -0
  33. package/dist/media-pipeline/client.d.ts.map +1 -0
  34. package/dist/media-pipeline/client.js +75 -0
  35. package/dist/media-pipeline/client.js.map +1 -0
  36. package/dist/media-pipeline/config.d.ts +17 -0
  37. package/dist/media-pipeline/config.d.ts.map +1 -0
  38. package/dist/media-pipeline/config.js +52 -0
  39. package/dist/media-pipeline/config.js.map +1 -0
  40. package/dist/media-pipeline/import.d.ts +19 -0
  41. package/dist/media-pipeline/import.d.ts.map +1 -0
  42. package/dist/media-pipeline/import.js +198 -0
  43. package/dist/media-pipeline/import.js.map +1 -0
  44. package/dist/media-pipeline/index.d.ts +6 -0
  45. package/dist/media-pipeline/index.d.ts.map +1 -0
  46. package/dist/media-pipeline/index.js +6 -0
  47. package/dist/media-pipeline/index.js.map +1 -0
  48. package/dist/media-pipeline/job-store.d.ts +41 -0
  49. package/dist/media-pipeline/job-store.d.ts.map +1 -0
  50. package/dist/media-pipeline/job-store.js +172 -0
  51. package/dist/media-pipeline/job-store.js.map +1 -0
  52. package/dist/media-pipeline/limits.d.ts +14 -0
  53. package/dist/media-pipeline/limits.d.ts.map +1 -0
  54. package/dist/media-pipeline/limits.js +14 -0
  55. package/dist/media-pipeline/limits.js.map +1 -0
  56. package/dist/media-pipeline/log.d.ts +3 -0
  57. package/dist/media-pipeline/log.d.ts.map +1 -0
  58. package/dist/media-pipeline/log.js +12 -0
  59. package/dist/media-pipeline/log.js.map +1 -0
  60. package/dist/media-pipeline/validate.d.ts +18 -0
  61. package/dist/media-pipeline/validate.d.ts.map +1 -0
  62. package/dist/media-pipeline/validate.js +38 -0
  63. package/dist/media-pipeline/validate.js.map +1 -0
  64. package/dist/runtime/context.d.ts +5 -0
  65. package/dist/runtime/context.d.ts.map +1 -1
  66. package/dist/runtime/context.js.map +1 -1
  67. package/docs/editor-tasks/media-pipeline-prepare.md +65 -69
  68. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  # Capability: Media pipeline — prepare pack
2
2
 
3
- Normalize a **folder of designer masters** (or inline files) into short-lived **public HTTPS URLs** under cms-edit upload limits, then import into Contentful with reuse-first.
3
+ Normalize a **folder of designer masters** into short-lived **public HTTPS URLs** under cms-edit upload limits, then import into Contentful with reuse-first.
4
4
 
5
- **Never** expect this service to write Contentful. Pipeline → ready URLs only. **cms-edit** owns assets/entries.
5
+ **Never** expect the media pipeline service to write Contentful. Pipeline → ready URLs only. **cms-edit** owns assets/entries.
6
6
 
7
7
  ## Intent phrases
8
8
 
@@ -19,13 +19,14 @@ Normalize a **folder of designer masters** (or inline files) into short-lived **
19
19
 
20
20
  ## Prerequisites
21
21
 
22
- - Media pipeline base URL (ops default for SE Studio: `https://se-media-pipeline.vercel.app`)
23
- - API bearer key (ops secret — e.g. env `MEDIA_PIPELINE_API_KEY` or site runbook; never invent)
24
- - Tenant id: `se` | `om1` | … (explicit; never infer only from Drive URL)
25
- - Drive folder **shared Viewer** with pipeline service account
22
+ - Hosted cms-edit with media pipeline **configured on the host** (ops env):
23
+ - `MEDIA_PIPELINE_BASE_URL`
24
+ - `MEDIA_PIPELINE_SERVICE_KEY` (server-only — **never ask the agent/user for this**)
25
+ - `MEDIA_PIPELINE_TENANT` (e.g. `se`, not the cms-edit projectKey)
26
+ - Drive folder shared **Viewer** with pipeline service account
26
27
  `media-pipeline-reader@se-media-pipeline.iam.gserviceaccount.com`
27
- (or “anyone with the link” if using API-key-only mode)
28
- - Profile default: `case-study-v1` (images ≤ ~3.5MB, videos H.264 mp4 ≤ ~8MB)
28
+ (or “anyone with the link” if using API-key Drive mode on the pipeline)
29
+ - Profile default: `case-study-v1`
29
30
 
30
31
  ## When to use
31
32
 
@@ -35,94 +36,89 @@ Normalize a **folder of designer masters** (or inline files) into short-lived **
35
36
  | Single small image already in library | `task-media-reuse-and-upload` only |
36
37
  | Masters already under limits and catalogued | Reuse search only |
37
38
 
38
- ## Steps
39
+ ## Steps (agent — single auth)
39
40
 
40
- ### 1. Confirm job inputs
41
+ ### 1. Prepare
41
42
 
42
- 1. Tenant (`se`, `om1`, …)
43
- 2. Profile (`case-study-v1` unless overridden)
44
- 3. Source:
45
- - **Preferred:** `google_drive_folder` + folder URL
46
- - **Dev/test:** `inline_files` with base64 (small files only)
47
- 4. Optional: `ttlHours` (1–24, default 24), `namingPrefix` (defaults from tenant)
48
-
49
- ### 2. Start the pack job
50
-
51
- ```http
52
- POST {MEDIA_PIPELINE_BASE}/api/v1/jobs
53
- Authorization: Bearer {MEDIA_PIPELINE_API_KEY}
54
- Content-Type: application/json
43
+ Call MCP tool **`cms_edit_media`**:
55
44
 
45
+ ```json
56
46
  {
57
- "tenant": "se",
58
- "profile": "case-study-v1",
59
- "source": {
60
- "type": "google_drive_folder",
61
- "url": "https://drive.google.com/drive/folders/…"
62
- },
63
- "options": { "ttlHours": 24 }
47
+ "action": "prepare",
48
+ "driveFolderUrl": "https://drive.google.com/drive/folders/…",
49
+ "profile": "case-study-v1"
64
50
  }
65
51
  ```
66
52
 
67
- Expect **202** with `jobId`, `runId`, `statusUrl` / poll path.
53
+ CLI: `cms-edit media prepare --drive-folder "https://drive.google.com/drive/folders/…"`
54
+
55
+ Expect `{ ok: true, jobId, status: "queued", pollHint }`.
56
+
57
+ If `{ ok: false, code: "pipeline_unconfigured" }` → host ops must set env vars. **Do not** ask the user for a pipeline API key.
58
+
59
+ ### 2. Wait / status
60
+
61
+ ```json
62
+ { "action": "wait", "jobId": "<jobId>" }
63
+ ```
68
64
 
69
- ### 3. Poll until terminal
65
+ or
70
66
 
71
- ```http
72
- GET {MEDIA_PIPELINE_BASE}/api/v1/jobs/{jobId}?tenant={tenant}
73
- Authorization: Bearer {MEDIA_PIPELINE_API_KEY}
67
+ ```json
68
+ { "action": "status", "jobId": "<jobId>" }
74
69
  ```
75
70
 
76
71
  Statuses: `queued` → `running` → `succeeded` | `partial` | `failed`.
77
72
 
78
73
  - **succeeded** — all files ready
79
- - **partial** — some ready; `gaps[]` lists failures (e.g. quality floor)
74
+ - **partial** — some ready; `gaps[]` lists failures
80
75
  - **failed** — nothing usable; stop and report gaps
81
76
 
82
- **Do not** invent assets for gaps. Carry gaps into source-readiness / GO-WITH-GAPS.
77
+ **Do not** invent assets for gaps.
83
78
 
84
- ### 4. Map pack → Contentful (reuse-first)
85
-
86
- For **each** ready asset in `assets[]`:
87
-
88
- 1. `cms_edit ["index", "sync"]` once per session if catalog may be stale
89
- 2. Search: `asset search` / `--filename-match` using `fileName` or source stem
90
- 3. If no match: **prefer URL upload** (ready URLs are already under limits):
79
+ ### 3. Catalog
91
80
 
81
+ ```json
82
+ { "action": "catalog", "jobId": "<jobId>" }
92
83
  ```
93
- cms_edit ["asset", "upload", "--url", "<assets[i].url>", "--mime", "<mime>", "--file-name", "<fileName>", "--title", "<titleDraft>", "--if-exists-by-filename"]
94
- ```
95
84
 
96
- Hosted MCP: `--url` is preferred for pipeline packs. Staged upload only if URL fetch fails (then download is unnecessary — pipeline already normalized).
85
+ Each asset includes:
86
+
87
+ | Field | Use |
88
+ |-------|-----|
89
+ | `readyUrl` | `asset upload --url` into Contentful |
90
+ | `previewUrl` / `posterUrl` | Agent vision for **title / fileName / alt** (when present) |
91
+ | `altDraft` / `titleDraft` | Filename seeds only — improve before save |
97
92
 
98
- 4. Set alt / description from `altDraft` when the site workflow requires it (`asset set` / asset fields per site)
99
- 5. Create **Media** wrappers only when needed; **reuse** existing Media entries by asset id
100
- 6. Record map: `sourceName` → `{ assetId, mediaId?, readyUrl }` for the article/page build
93
+ ### 4. Import into Contentful (reuse-first)
101
94
 
102
- ### 5. Hand off to structure build
95
+ After drafting titles/alts from **previewUrl** / **posterUrl**:
103
96
 
104
- Return to:
97
+ ```json
98
+ {
99
+ "action": "import",
100
+ "jobId": "<jobId>",
101
+ "withMedia": true,
102
+ "overrides": [
103
+ { "sourceName": "OM1_Hero.jpg", "title": "OM1 hero", "alt": "…" }
104
+ ]
105
+ }
106
+ ```
105
107
 
106
- - `task-create-from-document` / `task-create-article` / customer case-study task
107
- - Soft-proof component order with **real** asset/media ids in the plan
108
+ Optional: `"dryRun": true` to preview the map without writing.
108
109
 
109
- ## Confirmation gates
110
+ CLI: `cms-edit media import --job <id> [--dry-run] [--with-media] [--overrides-json '[…]']`
110
111
 
111
- 1. Report pipeline `status` + asset count + `gaps` before CMS uploads
112
- 2. Report reuse hits vs new uploads
113
- 3. Do not start multi-block article create until the pack map is complete (or gaps accepted as GO-WITH-GAPS)
112
+ Import:
114
113
 
115
- ## Out of scope
114
+ 1. Searches existing assets by fileName
115
+ 2. Else uploads from `readyUrl` as the authenticated Contentful user
116
+ 3. Returns `map: { sourceName → { assetId, mediaId?, … } }` for page build
116
117
 
117
- - Contentful publish
118
- - Copy rewrite
119
- - Pipeline writing CMA (forbidden permanently)
120
- - Video/image creative edits beyond normalize
118
+ Manual `asset upload --url` remains available for one-offs.
121
119
 
122
- ## Related resources
120
+ ### Hardening notes (for agents)
123
121
 
124
- - `task-media-reuse-and-upload`
125
- - `task-source-readiness-review`
126
- - `task-create-from-document`
127
- - `task-create-article`
128
- - `task-preview-verify`
122
+ - Jobs are **owned by the OAuth user** who prepared them — you cannot poll another user’s `jobId`.
123
+ - Rate limits apply (prepares/hour, concurrent jobs).
124
+ - Never document or request `MEDIA_PIPELINE_API_KEY` in chat.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/contentful-cms",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "CLI tool for AI agents to read and edit Contentful draft content without publish permissions",
5
5
  "repository": {
6
6
  "type": "git",