@explorer02/cfm-survey-sdk 0.2.3 → 0.2.5

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 (100) hide show
  1. package/dist/cli/index.js +141 -33
  2. package/dist/cli/index.mjs +141 -33
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/package.json +3 -1
  6. package/postinstall.js +9 -5
  7. package/templates/AGENT.md +60 -19
  8. package/templates/deploy-wizard-to-s3.sh +52 -0
  9. package/templates/docs/00-integration/agent-execution-flow.md +293 -0
  10. package/templates/docs/00-integration/agent-operating-contract.md +268 -0
  11. package/templates/docs/00-integration/apply-ui-config.md +390 -0
  12. package/templates/docs/00-integration/aws-deploy.md +117 -3
  13. package/templates/docs/00-integration/canonical-survey-fixtures.md +94 -0
  14. package/templates/docs/00-integration/client-integration-guide.md +9 -7
  15. package/templates/docs/00-integration/client-lib-folder.md +115 -0
  16. package/templates/docs/00-integration/component-checklist.md +90 -62
  17. package/templates/docs/00-integration/constraints.md +14 -5
  18. package/templates/docs/00-integration/custom-field-logic-and-navigation.md +56 -0
  19. package/templates/docs/00-integration/mockup-ui-extraction.md +113 -0
  20. package/templates/docs/00-integration/placeholders-and-custom-fields-wiring.md +192 -0
  21. package/templates/docs/00-integration/placeholders-and-tokens.md +2 -1
  22. package/templates/docs/00-integration/progress.md +4 -2
  23. package/templates/docs/00-integration/setup.md +12 -0
  24. package/templates/docs/00-integration/ui-customization-wizard.md +123 -0
  25. package/templates/docs/00-integration/useSurveySDK.md +35 -1
  26. package/templates/docs/00-integration/wizard-api.md +126 -0
  27. package/templates/docs/00-integration/wizard-config-handoff.md +292 -0
  28. package/templates/docs/00-integration/wizard-preview-build-guide.md +405 -0
  29. package/templates/docs/00-integration/wizard-question-type-styling.md +197 -0
  30. package/templates/docs/00-integration/wizard-troubleshooting.md +80 -0
  31. package/templates/docs/01-components/01-survey-page.md +18 -8
  32. package/templates/docs/01-components/02-question.md +2 -2
  33. package/templates/docs/01-components/03-rating-scale.md +12 -18
  34. package/templates/docs/01-components/05-csat-matrix-scale.md +18 -26
  35. package/templates/docs/01-components/06-likert-matrix-scale.md +19 -39
  36. package/templates/docs/01-components/07-slider-matrix-scale.md +48 -33
  37. package/templates/docs/01-components/09-custom-slider-track.md +15 -25
  38. package/templates/docs/01-components/10-header-footer.md +23 -4
  39. package/templates/docs/01-components/11-progress-bar.md +14 -6
  40. package/templates/docs/01-components/19-survey-sticky-chrome.md +79 -0
  41. package/templates/docs/01-components/README.md +2 -2
  42. package/templates/docs/02-reference/question-types/10-slider-matrix.md +38 -26
  43. package/templates/docs/02-reference/routing-table.md +1 -0
  44. package/templates/docs/02-reference/value-derivation.md +1 -1
  45. package/templates/docs/03-ui-specs/00-question-shell.md +10 -0
  46. package/templates/docs/03-ui-specs/01-rating.md +18 -0
  47. package/templates/docs/03-ui-specs/02-radio.md +16 -1
  48. package/templates/docs/03-ui-specs/03-text.md +12 -1
  49. package/templates/docs/03-ui-specs/04-csat.md +84 -50
  50. package/templates/docs/03-ui-specs/06-slider.md +3 -1
  51. package/templates/docs/03-ui-specs/07-matrix-cfm.md +71 -48
  52. package/templates/docs/03-ui-specs/08-matrix-csat-rating.md +48 -18
  53. package/templates/docs/03-ui-specs/09-slider-matrix.md +59 -32
  54. package/templates/docs/03-ui-specs/10-file-upload.md +11 -0
  55. package/templates/docs/03-ui-specs/11-text-and-media.md +4 -0
  56. package/templates/docs/03-ui-specs/12-survey-chrome.md +54 -5
  57. package/templates/docs/03-ui-specs/13-heatmap.md +12 -1
  58. package/templates/docs/03-ui-specs/14-rank-order.md +11 -0
  59. package/templates/docs/03-ui-specs/README.md +4 -2
  60. package/templates/docs/03-ui-specs/shared/matrix-dropdown.md +1 -1
  61. package/templates/docs/MANIFEST.json +180 -7
  62. package/templates/docs/index.md +114 -117
  63. package/templates/docs/templates/CsatMatrixScale.tsx +637 -0
  64. package/templates/docs/templates/FileUploadScale.tsx +262 -0
  65. package/templates/docs/templates/HeatmapScale.tsx +114 -0
  66. package/templates/docs/templates/LikertMatrixScale.tsx +414 -0
  67. package/templates/docs/templates/Question.tsx +3 -0
  68. package/templates/docs/templates/RatingScale.tsx +129 -0
  69. package/templates/docs/templates/SliderMatrixScale.tsx +248 -0
  70. package/templates/docs/templates/SurveyStickyChrome.tsx +24 -0
  71. package/templates/docs/templates/customFieldValues.ts +36 -0
  72. package/templates/docs/templates/deploy-to-aws.sh +74 -0
  73. package/templates/docs/templates/implementation_plan.md +64 -10
  74. package/templates/docs/templates/labelStyles.ts +33 -0
  75. package/templates/docs/templates/selectionStyles.ts +100 -0
  76. package/templates/docs/templates/surveyUiIcons.tsx +11 -0
  77. package/templates/docs/templates/surveyUiScaleUtils.ts +51 -0
  78. package/templates/docs/templates/verify-agent-build.sh +119 -0
  79. package/templates/preview-harness/preview-bridge.inline.js +201 -0
  80. package/templates/preview-harness/previewPages.js +108 -0
  81. package/templates/preview-harness/previewPages.ts +298 -0
  82. package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +67 -0
  83. package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +122 -0
  84. package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +75 -0
  85. package/templates/preview-harness/vite-app/src/fixtures/questions.ts +311 -0
  86. package/templates/preview-harness/vite-app/src/globals.css +16 -0
  87. package/templates/preview-harness/vite-app/src/mount.tsx +9 -0
  88. package/templates/preview-harness/vite-app/src/preview-live-overrides.css +101 -0
  89. package/templates/preview-harness/vite-app/stubs/next-dynamic.tsx +25 -0
  90. package/templates/preview-harness/vite-app/stubs/next-image.tsx +29 -0
  91. package/templates/previewBridge.ts +153 -0
  92. package/templates/survey-theme.css +295 -0
  93. package/templates/survey-ui-config.schema.json +213 -0
  94. package/templates/wizard-dist/assets/PreviewMock-AoZdAEPZ.js +1 -0
  95. package/templates/wizard-dist/assets/TypePanel-39FnbtvG.js +1 -0
  96. package/templates/wizard-dist/assets/index-BhWM50Yu.css +1 -0
  97. package/templates/wizard-dist/assets/index-CWKdsJOp.js +34 -0
  98. package/templates/wizard-dist/assets/vendor-BwkXDkd3.js +17 -0
  99. package/templates/wizard-dist/index.html +20 -0
  100. package/templates/wizard.html +13 -1129
@@ -0,0 +1,126 @@
1
+ # Wizard API — EC2 fallback (`customize-ui` only)
2
+
3
+ > **Default wizard is `npx cfm-sdk customize` on localhost** — no EC2 API needed.
4
+ > This doc applies **only** when the client customizes from another device.
5
+
6
+ Base URL: `CFM_DEPLOY_API_BASE` — default: `http://43.204.26.213:3000`
7
+
8
+ ## Architecture
9
+
10
+ ```mermaid
11
+ flowchart LR
12
+ CLI[customize-ui CLI] -->|PUT preview files| Disk[EC2 disk data/wizard-sessions/]
13
+ Client[Client browser] --> SPA[wizard-app SPA]
14
+ SPA -->|GET /api/inventory| API[deploy-api]
15
+ SPA -->|iframe /previews/...| Disk
16
+ SPA -->|POST /api/save-config| API
17
+ API -->|final config + logo| S3[S3 hosting bucket]
18
+ CLI -->|poll GET /wizard/config| API
19
+ ```
20
+
21
+ | During session | Storage |
22
+ |----------------|---------|
23
+ | Preview HTML | EC2 disk (`WIZARD_DATA_DIR/{sessionId}/previews/`) |
24
+ | Seed config | EC2 disk (`seed-config.json`) |
25
+ | Temp logo | EC2 disk (`assets/`) |
26
+ | **On submit** | Final JSON + permanent logo → S3 |
27
+
28
+ Previews are **not** loaded from S3 during customization — avoids "Storage service unavailable" on preview iframes.
29
+
30
+ ## Client wizard link
31
+
32
+ ```
33
+ {CFM_DEPLOY_API_BASE}/wizard-app/index.html?session={sessionId}&secret={sessionSecret}
34
+ ```
35
+
36
+ | Route | Role |
37
+ |-------|------|
38
+ | `/wizard-app/` | Wizard SPA |
39
+ | `/api/inventory` | Session metadata + `previewManifest` (local-server API) |
40
+ | `/previews/{sessionId}/{key}/index.html` | Component preview iframes |
41
+ | `/api/save-config` | Client submit (same as local `customize`) |
42
+
43
+ ## Local-server routes (`/api/*`, `/previews/*`)
44
+
45
+ Same contract as `packages/sdk/src/cli/customize.ts`:
46
+
47
+ ### `GET /api/inventory?session=&secret=`
48
+
49
+ Returns `{ surveyTypes, instanceId, previewUrl, previewManifest, initialConfig, localServer: true }`.
50
+
51
+ ### `GET /api/preview-url`
52
+
53
+ Health check for preview availability indicator.
54
+
55
+ ### `POST /api/upload-logo?session=&secret=`
56
+
57
+ Body: `{ filename, base64 }` — stores logo on EC2 disk for session.
58
+
59
+ ### `POST /api/save-config?session=&secret=`
60
+
61
+ Body: full `survey-ui-config.json`. Persists final config + logo to S3, cleans session disk.
62
+
63
+ ## Session management (`/wizard/*`)
64
+
65
+ ### `POST /wizard/session/start`
66
+
67
+ **Auth:** `Authorization: Bearer {JWT}`
68
+
69
+ **Body:** `{ files, surveyTypes, initialConfig }`
70
+
71
+ **Response:** `{ sessionId, sessionSecret, wizardUrl, uploads[], localServer: true }`
72
+
73
+ `uploads[].uploadUrl` → `PUT /wizard/session/:sessionId/preview-file?path=previews/...` (EC2 disk, not S3 presign).
74
+
75
+ ### `PUT /wizard/session/:sessionId/preview-file?path=...`
76
+
77
+ **Auth:** `X-Wizard-Session` + `X-Wizard-Session-Id`
78
+
79
+ Raw file body → written to session disk.
80
+
81
+ ### `POST /wizard/previews/upload/complete`
82
+
83
+ **Auth:** JWT. Verifies all files on disk; activates session; builds manifest with `/previews/{sessionId}/…` URLs.
84
+
85
+ ### `POST /wizard/session/quit`
86
+
87
+ Deletes session disk folder + in-memory session. CLI poll returns `status: abandoned`.
88
+
89
+ ### `GET /wizard/config/:surveyId?sessionId=`
90
+
91
+ CLI poll after client submit.
92
+
93
+ - **pending** — waiting
94
+ - **abandoned** — client quit
95
+ - **ready** — `{ config, logoUrl, … }`
96
+
97
+ ## Env (deploy-api)
98
+
99
+ ```bash
100
+ WIZARD_DATA_DIR=./data/wizard-sessions # preview + seed + temp logo on disk
101
+ WIZARD_SESSION_TTL_MS=7200000
102
+ HOSTING_BUCKET=... # final config + permanent logo only
103
+ CLOUDFRONT_BASE_URL=...
104
+ ```
105
+
106
+ ## IAM (EC2 instance role)
107
+
108
+ Required for **submit** (not previews):
109
+
110
+ - `s3:PutObject`, `s3:GetObject` on hosting bucket
111
+ - `cloudfront:CreateInvalidation` (logo cache bust)
112
+
113
+ ## CLI flow
114
+
115
+ ```bash
116
+ export CFM_INSTANCE_ID="..." CFM_DEPLOY_API_BASE="http://43.204.26.213:3000"
117
+ npx cfm-sdk customize-ui
118
+ ```
119
+
120
+ 1. `export-previews` on agent machine
121
+ 2. Upload preview files to EC2 disk
122
+ 3. Print client wizard link
123
+ 4. Poll until `status: ready`
124
+ 5. Write `.final.json` + `.diff.md`
125
+
126
+ See [`wizard-config-handoff.md`](wizard-config-handoff.md), [`ui-customization-wizard.md`](ui-customization-wizard.md).
@@ -0,0 +1,292 @@
1
+ # Wizard Config Handoff — Wait, Capture, Apply
2
+
3
+ > **Phase 6b → 6c.** Read with [`ui-customization-wizard.md`](ui-customization-wizard.md) and [`apply-ui-config.md`](apply-ui-config.md).
4
+ > Pipeline: [`agent-execution-flow.md`](agent-execution-flow.md).
5
+
6
+ This doc tells the agent **exactly** how to wait for the client to finish the wizard, capture the JSON output, and apply **every** change without omission.
7
+
8
+ ---
9
+
10
+ ## Prime rule
11
+
12
+ **Do not apply wizard changes until the client has submitted the wizard.**
13
+
14
+ - **Default (`customize`):** CLI blocks until client saves — wait for `✅ UI configuration saved`.
15
+ - **Remote client (`customize-ui`):** CLI blocks and polls until status `ready`.
16
+
17
+ **Do not** guess final colors from memory or proceed to deploy before the wizard CLI exits 0.
18
+
19
+ ---
20
+
21
+ ## Default flow — `npx cfm-sdk customize`
22
+
23
+ ### Step 1 — Agent runs CLI (and waits)
24
+
25
+ ```bash
26
+ npx cfm-sdk customize
27
+ ```
28
+
29
+ The CLI will:
30
+
31
+ 1. Export all 11 component preview pages (`export-previews` if needed)
32
+ 2. Start wizard at `http://localhost:4200`
33
+ 3. Open browser on the **agent machine**
34
+ 4. **Block** until client clicks **Review & Build**
35
+ 5. Write `survey-ui-config.json` and exit 0
36
+
37
+ **Agent must:**
38
+
39
+ - [ ] Client is on the **same machine** (can see `localhost:4200`)
40
+ - [ ] Keep terminal open until `✅ UI configuration saved`
41
+ - [ ] Apply per Phase 6c from `survey-ui-config.json`
42
+
43
+ **Artifact:** `survey-ui-config.json` — apply source for local flow.
44
+
45
+ **Logo on local wizard (critical for AWS deploy):**
46
+
47
+ When the client uploads a logo in the local wizard:
48
+
49
+ 1. CLI writes the file to `public/logo_{timestamp}_{name}.jpg` via `POST /api/upload-logo`.
50
+ 2. Saved config has `global.logo.fileName` — preview `data:` URL is **not** persisted (stripped on save).
51
+ 3. Agent **must** set `Header.tsx` `data-cfm-logo` to `src="./{fileName}"` during Phase 6c.
52
+ 4. `yarn build` copies `public/` → `out/`; Phase 7 uploads `out/` to `sites/{surveyId}/{deployId}/`.
53
+
54
+ The logo is **not** fetched from wizard memory on CloudFront — only from the deploy bundle. See [`aws-deploy.md`](aws-deploy.md) § Logos & local assets.
55
+
56
+ ---
57
+
58
+ ## Remote client flow — `customize-ui` (fallback only)
59
+
60
+ ### Step 1 — Agent runs CLI (and waits)
61
+
62
+ ```bash
63
+ export CFM_INSTANCE_ID="<JWT>"
64
+ export CFM_DEPLOY_API_BASE="<EC2 URL>"
65
+ npx cfm-sdk customize-ui
66
+ ```
67
+
68
+ **Default is review mode** (no flags). The CLI will:
69
+
70
+ 1. Export component preview pages (`export-previews`)
71
+ 2. Upload preview HTML to **EC2 disk** (local-server model — same as agent `customize`)
72
+ 3. Print the **deployed EC2 wizard link** — agent **must share this URL with the client**
73
+ 4. **Poll every ~3s** (`GET /wizard/config/:surveyId`) until the client submits
74
+ 5. Print `✅ Configuration ready` when `status === 'ready'`
75
+
76
+ ### Deployed wizard link (give to client after preview upload)
77
+
78
+ The client does **not** use localhost. After previews are uploaded, the CLI prints:
79
+
80
+ ```
81
+ 🔗 Client wizard link — share with the client:
82
+ http://43.204.26.213:3000/wizard-app/index.html?session=<uuid>&secret=<hex>
83
+ ```
84
+
85
+ - **Previews:** stored on **EC2 disk** (`WIZARD_DATA_DIR/{sessionId}/previews/`); wizard iframes load via `GET /previews/{sessionId}/{component}/index.html` (local-server API — same model as `customize`)
86
+ - **Wizard UI:** served from EC2 at `/wizard-app/`; inventory via `GET /api/inventory`
87
+ - **On submit:** final config + permanent logo → S3 only
88
+
89
+ Set `CFM_DEPLOY_API_BASE=http://43.204.26.213:3000` (or your EC2 host). The link is built from that base + session credentials returned by `POST /wizard/session/start`.
90
+
91
+ **Agent must:**
92
+
93
+ - [ ] Keep the terminal process **running** — do not Ctrl+C while polling
94
+ - [ ] Tell the client: *"Please complete all wizard steps and click **Review & Build** / save to finish."*
95
+ - [ ] Wait until CLI exits **0** with `Configuration ready`
96
+ - [ ] **Not** start Phase 6c apply until this completes
97
+
98
+ **Timeout:** default 2 hours (`CFM_WIZARD_TIMEOUT_MS`). If timeout, ask client to re-run or use `fetch-ui-config` (see §5).
99
+
100
+ ### Step 2 — Review artifacts (written on success)
101
+
102
+ | File | Role |
103
+ |------|------|
104
+ | `survey-ui-config.seed.json` | Snapshot before client edits |
105
+ | `survey-ui-config.final.json` | Client config + `global.logo.url` (public CloudFront URL) |
106
+ | `survey-ui-config.diff.json` / `.diff.md` | Every changed path — **read before apply** |
107
+ | `survey-ui-config.json` | Still **seed** until `confirm-ui-config` |
108
+ | `public/{logoFileName}` | Logo file downloaded from `logoUrl` |
109
+
110
+ Poll response includes `logoUrl` and `logoKey` — CLI merges `logo.url` into final JSON.
111
+
112
+ **EC2 logo vs deploy bundle:** `logoUrl` points to `sites/{surveyId}/assets/{fileName}` on CloudFront. That path is for **wizard handoff** (download into `public/` via `confirm-ui-config`). The **live survey** loads the logo from `sites/{surveyId}/{deployId}/{fileName}` only after you rebuild and run Phase 7 deploy. Apply `data-cfm-logo src="./{fileName}"` then deploy — see [`aws-deploy.md`](aws-deploy.md) § Logos & local assets.
113
+
114
+ **If all diff counts are 0:** client submitted without changes — still verify; skip heavy apply.
115
+
116
+ ### S3 garbage collection
117
+
118
+ | When | Deleted | Kept |
119
+ |------|---------|------|
120
+ | Client **Review & Build** | EC2 session disk folder (`data/wizard-sessions/{sessionId}/`) | `sites/{surveyId}/assets/{logo}`, `wizard/config.json` |
121
+ | Client **Quit** (or tab close) | Same session prefix — `POST /wizard/session/quit` | N/A |
122
+ | Session **expires** (2h default) | Same session prefix — auto sweep every 5 min | N/A |
123
+
124
+ ### Step 3 — Agent reads diff before touching code
125
+
126
+ ```bash
127
+ # Agent MUST open and read:
128
+ cat survey-ui-config.diff.md
129
+ ```
130
+
131
+ For **every** section in the diff (`Changed`, `Added`, `Removed`):
132
+
133
+ 1. Find the config path (e.g. `global.colorScheme.primary`)
134
+ 2. Look up apply target in [`apply-ui-config.md`](apply-ui-config.md) § Complete mapping
135
+ 3. Apply to the listed file/CSS var/`data-cfm-*` attribute
136
+ 4. Mark the path done (mental checklist or notes in `implementation_plan.md`)
137
+
138
+ **Blocking rule:** If a path appears in the diff, it **must** be reflected in the codebase after Phase 6c.
139
+
140
+ ### Step 4 — Apply to codebase (Phase 6c)
141
+
142
+ Follow [`apply-ui-config.md`](apply-ui-config.md) using **`survey-ui-config.final.json`** as input.
143
+
144
+ Order:
145
+
146
+ 1. Validate `survey-ui-config.final.json` against `templates/survey-ui-config.schema.json`
147
+ 2. Regenerate `src/styles/survey-theme.css` from **all** tokens in final config (not only diff paths — full sync prevents missed derived vars)
148
+ 3. Apply `data-cfm-*` content patches (title, buttons, footer links, logo)
149
+ 4. Apply layout toggles in `SurveyPage` / chrome
150
+ 5. Apply `placeholders`, `customFields`, `debug` in hook options
151
+ 6. Re-run `bash templates/verify-agent-build.sh` and `npm run build`
152
+
153
+ ### Step 5 — Promote config + logo
154
+
155
+ After codebase apply succeeds:
156
+
157
+ ```bash
158
+ export CFM_INSTANCE_ID="<JWT>"
159
+ export CFM_DEPLOY_API_BASE="<EC2 URL>"
160
+ npx cfm-sdk confirm-ui-config
161
+ ```
162
+
163
+ This:
164
+
165
+ - Copies `survey-ui-config.final.json` → `survey-ui-config.json`
166
+ - Downloads logo to `public/{fileName}` when `global.logo.fileName` is set
167
+
168
+ **Do not run `confirm-ui-config` before applying tokens to the codebase** — you would promote JSON while the UI still shows seed styling.
169
+
170
+ Optional: `npx cfm-sdk confirm-ui-config --diff-only` to re-print diff without writing.
171
+
172
+ ---
173
+
174
+ ## Local flow (`customize`)
175
+
176
+ ```bash
177
+ npx cfm-sdk customize
178
+ ```
179
+
180
+ 1. CLI starts wizard at `http://localhost:4200`
181
+ 2. **Blocks** until client clicks save → `POST /api/save-config`
182
+ 3. Writes **`survey-ui-config.json` directly** (no `.final.json` / diff artifacts)
183
+ 4. Prints `✅ UI configuration saved` and exits
184
+
185
+ **Agent must:**
186
+
187
+ - [ ] Wait for CLI to exit 0 after client saves
188
+ - [ ] Apply from `survey-ui-config.json` per [`apply-ui-config.md`](apply-ui-config.md)
189
+ - [ ] No `confirm-ui-config` step (not used locally)
190
+
191
+ ---
192
+
193
+ ## Legacy AWS mode (`--apply`)
194
+
195
+ ```bash
196
+ npx cfm-sdk customize-ui --apply
197
+ ```
198
+
199
+ Writes final config + logo immediately (no review artifacts). Still requires Phase 6c codebase apply from `survey-ui-config.json`.
200
+
201
+ **Prefer default review mode** so the agent can audit `survey-ui-config.diff.md` before apply.
202
+
203
+ ---
204
+
205
+ ## Detached session (`--no-wait`)
206
+
207
+ ```bash
208
+ npx cfm-sdk customize-ui --no-wait
209
+ # CLI prints wizard URL and exits — client works asynchronously
210
+ ```
211
+
212
+ When client finishes:
213
+
214
+ ```bash
215
+ export CFM_WIZARD_SESSION_ID="<sessionId from CLI output>"
216
+ npx cfm-sdk fetch-ui-config
217
+ # Writes .final.json + .diff.md — then apply + confirm-ui-config
218
+ ```
219
+
220
+ **Do not apply** until `fetch-ui-config` succeeds.
221
+
222
+ ---
223
+
224
+ ## Agent ↔ client script
225
+
226
+ **When starting wizard (tell client after you send the link):**
227
+
228
+ > *"I've uploaded your survey component previews to the cloud. Open this customization link: [paste deployed wizard URL]. Adjust branding, colors, and question-type styling — the preview panel shows your real components. When finished, click **Review & Build** on the last step. I'll wait here until your changes are saved."*
229
+
230
+ **While waiting (agent):**
231
+
232
+ - Do not refactor unrelated code
233
+ - Do not start deploy
234
+ - Do not re-run `customize-ui` (overwrites session artifacts)
235
+
236
+ **After CLI success (tell client):**
237
+
238
+ > *"Your wizard changes are captured. I'm applying them to the survey UI now and will verify the build."*
239
+
240
+ ---
241
+
242
+ ## Phase checklist
243
+
244
+ ### Phase 6b — Wizard session
245
+
246
+ - [ ] Client explicitly said yes to wizard (INPUT 3)
247
+ - [ ] `CFM_INSTANCE_ID` and `CFM_DEPLOY_API_BASE` set
248
+ - [ ] Ran `npx cfm-sdk customize-ui` (or `customize` locally)
249
+ - [ ] **Waited** until CLI exit 0 (`Configuration ready` or `UI configuration saved`)
250
+ - [ ] AWS: `survey-ui-config.final.json` and `survey-ui-config.diff.md` exist
251
+ - [ ] Read `survey-ui-config.diff.md` completely
252
+
253
+ ### Phase 6c — Apply (no skipped paths)
254
+
255
+ - [ ] Applied from **`survey-ui-config.final.json`** (AWS) or **`survey-ui-config.json`** (local)
256
+ - [ ] Every diff path in `changed` + `added` + `removed` addressed
257
+ - [ ] `src/styles/survey-theme.css` fully synced to final config
258
+ - [ ] All `data-cfm-*` content hooks updated
259
+ - [ ] Logo file exists in `public/` when config has `global.logo.fileName`
260
+ - [ ] `out/{fileName}` exists after build when logo configured (AWS deploy gate)
261
+ - [ ] `Header.tsx` uses `data-cfm-logo src="./{fileName}"` — not `data:` or `/assets/` URL
262
+ - [ ] `placeholders` / `customFields` / `debug` wired if present in final
263
+ - [ ] AWS: ran `npx cfm-sdk confirm-ui-config` after codebase apply
264
+ - [ ] `verify-agent-build.sh` + `npm run build` pass
265
+ - [ ] Visually spot-check: header, footer, progress, one question type from inventory
266
+
267
+ ---
268
+
269
+ ## Common mistakes
270
+
271
+ | Mistake | Fix |
272
+ |---------|-----|
273
+ | Killed CLI during poll | Re-run `customize-ui`; client re-submits |
274
+ | Client quit wizard | CLI exits with abandon message; S3 GC done — re-run `customize-ui` for new session |
275
+ | Applied from `survey-ui-config.json` while still seed | Use `.final.json` or run `confirm-ui-config` after apply |
276
+ | Only changed primary color, ignored diff | Read **entire** `diff.md` — clients often change 20+ paths |
277
+ | Skipped `confirm-ui-config` | Active JSON stays seed; next wizard re-open is wrong |
278
+ | Changed `Question.tsx` dispatch during apply | UI tokens only — see `apply-ui-config.md` scope |
279
+ | Proceeded to deploy before apply | Complete Phase 6c first |
280
+ | Logo works in wizard but broken on CloudFront | Preview uses memory; deploy needs `public/` → `out/` → S3 — see `aws-deploy.md` § Logos |
281
+ | Used `global.logo.url` as Header src | Use `./{fileName}` only; download assets URL via `confirm-ui-config` |
282
+
283
+ ---
284
+
285
+ ## Related docs
286
+
287
+ | Doc | Role |
288
+ |-----|------|
289
+ | [`apply-ui-config.md`](apply-ui-config.md) | Complete config path → file mapping |
290
+ | [`wizard-api.md`](wizard-api.md) | Poll endpoint, complete payload |
291
+ | [`wizard-question-type-styling.md`](wizard-question-type-styling.md) | Per-type CSS vars |
292
+ | [`agent-operating-contract.md`](agent-operating-contract.md) | Anti-hallucination gates |