@explorer02/cfm-survey-sdk 0.2.2 → 0.2.4

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 (113) hide show
  1. package/dist/cli/index.js +140 -33
  2. package/dist/cli/index.mjs +140 -33
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/package.json +8 -1
  6. package/postinstall.js +8 -5
  7. package/templates/AGENT.md +62 -17
  8. package/templates/deploy-wizard-to-s3.sh +52 -0
  9. package/templates/docs/00-integration/agent-execution-flow.md +281 -0
  10. package/templates/docs/00-integration/agent-operating-contract.md +260 -0
  11. package/templates/docs/00-integration/analytics-events-catalog.md +54 -0
  12. package/templates/docs/00-integration/apply-ui-config.md +365 -0
  13. package/templates/docs/00-integration/canonical-survey-fixtures.md +94 -0
  14. package/templates/docs/00-integration/client-integration-guide.md +10 -8
  15. package/templates/docs/00-integration/client-lib-folder.md +115 -0
  16. package/templates/docs/00-integration/component-checklist.md +90 -54
  17. package/templates/docs/00-integration/constraints.md +13 -5
  18. package/templates/docs/00-integration/custom-field-logic-and-navigation.md +56 -0
  19. package/templates/docs/00-integration/display-logic-and-navigation.md +16 -1
  20. package/templates/docs/00-integration/file-upload-aws.md +116 -0
  21. package/templates/docs/00-integration/logic-fields-catalog.md +105 -0
  22. package/templates/docs/00-integration/partial-save-and-recovery.md +24 -0
  23. package/templates/docs/00-integration/progress.md +4 -2
  24. package/templates/docs/00-integration/question-type-sdk-matrix.md +11 -9
  25. package/templates/docs/00-integration/setup.md +15 -3
  26. package/templates/docs/00-integration/skip-logic-and-navigation.md +1 -1
  27. package/templates/docs/00-integration/survey-lifecycle-analytics.md +1 -1
  28. package/templates/docs/00-integration/ui-customization-wizard.md +144 -0
  29. package/templates/docs/00-integration/useSurveySDK.md +35 -1
  30. package/templates/docs/00-integration/wizard-api.md +134 -0
  31. package/templates/docs/00-integration/wizard-config-handoff.md +246 -0
  32. package/templates/docs/00-integration/wizard-preview-build-guide.md +400 -0
  33. package/templates/docs/00-integration/wizard-question-type-styling.md +195 -0
  34. package/templates/docs/01-components/01-survey-page.md +18 -8
  35. package/templates/docs/01-components/02-question.md +2 -2
  36. package/templates/docs/01-components/03-rating-scale.md +12 -18
  37. package/templates/docs/01-components/05-csat-matrix-scale.md +18 -26
  38. package/templates/docs/01-components/06-likert-matrix-scale.md +19 -38
  39. package/templates/docs/01-components/07-slider-matrix-scale.md +48 -33
  40. package/templates/docs/01-components/08-file-upload-scale.md +15 -52
  41. package/templates/docs/01-components/09-custom-slider-track.md +15 -25
  42. package/templates/docs/01-components/10-header-footer.md +23 -4
  43. package/templates/docs/01-components/11-progress-bar.md +14 -6
  44. package/templates/docs/01-components/13-matrix-dropdown.md +28 -33
  45. package/templates/docs/01-components/17-heatmap-scale.md +4 -4
  46. package/templates/docs/01-components/18-rank-order-scale.md +24 -31
  47. package/templates/docs/01-components/19-survey-sticky-chrome.md +79 -0
  48. package/templates/docs/01-components/README.md +2 -2
  49. package/templates/docs/02-reference/question-types/10-slider-matrix.md +38 -26
  50. package/templates/docs/02-reference/question-types/11-file-upload.md +36 -21
  51. package/templates/docs/02-reference/question-types/README.md +11 -1
  52. package/templates/docs/02-reference/routing-table.md +1 -0
  53. package/templates/docs/02-reference/value-derivation.md +1 -1
  54. package/templates/docs/03-ui-specs/00-question-shell.md +10 -0
  55. package/templates/docs/03-ui-specs/01-rating.md +28 -2
  56. package/templates/docs/03-ui-specs/02-radio.md +94 -24
  57. package/templates/docs/03-ui-specs/03-text.md +12 -1
  58. package/templates/docs/03-ui-specs/04-csat.md +90 -26
  59. package/templates/docs/03-ui-specs/06-slider.md +3 -1
  60. package/templates/docs/03-ui-specs/07-matrix-cfm.md +74 -35
  61. package/templates/docs/03-ui-specs/08-matrix-csat-rating.md +50 -16
  62. package/templates/docs/03-ui-specs/09-slider-matrix.md +70 -26
  63. package/templates/docs/03-ui-specs/10-file-upload.md +52 -20
  64. package/templates/docs/03-ui-specs/11-text-and-media.md +4 -0
  65. package/templates/docs/03-ui-specs/12-survey-chrome.md +92 -5
  66. package/templates/docs/03-ui-specs/13-heatmap.md +21 -3
  67. package/templates/docs/03-ui-specs/14-rank-order.md +108 -28
  68. package/templates/docs/03-ui-specs/README.md +11 -7
  69. package/templates/docs/03-ui-specs/shared/custom-slider-track.md +28 -35
  70. package/templates/docs/03-ui-specs/shared/matrix-dropdown.md +1 -1
  71. package/templates/docs/MANIFEST.json +187 -6
  72. package/templates/docs/index.md +116 -116
  73. package/templates/docs/templates/CsatMatrixScale.tsx +637 -0
  74. package/templates/docs/templates/CustomSliderTrack.tsx +144 -0
  75. package/templates/docs/templates/FileUploadScale.tsx +262 -0
  76. package/templates/docs/templates/HeatmapScale.tsx +114 -0
  77. package/templates/docs/templates/LikertMatrixScale.tsx +414 -0
  78. package/templates/docs/templates/MatrixDropdown.tsx +216 -0
  79. package/templates/docs/templates/Question.tsx +3 -0
  80. package/templates/docs/templates/RankOrderScale.tsx +353 -0
  81. package/templates/docs/templates/RatingScale.tsx +129 -0
  82. package/templates/docs/templates/SliderMatrixScale.tsx +248 -0
  83. package/templates/docs/templates/SurveyStickyChrome.tsx +24 -0
  84. package/templates/docs/templates/customFieldValues.ts +36 -0
  85. package/templates/docs/templates/implementation_plan.md +75 -8
  86. package/templates/docs/templates/labelStyles.ts +33 -0
  87. package/templates/docs/templates/selectionStyles.ts +100 -0
  88. package/templates/docs/templates/survey-inventory.schema.json +28 -23
  89. package/templates/docs/templates/surveyUiIcons.tsx +63 -0
  90. package/templates/docs/templates/surveyUiScaleUtils.ts +51 -0
  91. package/templates/docs/templates/verify-agent-build.sh +151 -0
  92. package/templates/preview-harness/preview-bridge.inline.js +201 -0
  93. package/templates/preview-harness/previewPages.js +108 -0
  94. package/templates/preview-harness/previewPages.ts +298 -0
  95. package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +67 -0
  96. package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +122 -0
  97. package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +75 -0
  98. package/templates/preview-harness/vite-app/src/fixtures/questions.ts +311 -0
  99. package/templates/preview-harness/vite-app/src/globals.css +16 -0
  100. package/templates/preview-harness/vite-app/src/mount.tsx +9 -0
  101. package/templates/preview-harness/vite-app/src/preview-live-overrides.css +101 -0
  102. package/templates/preview-harness/vite-app/stubs/next-dynamic.tsx +25 -0
  103. package/templates/preview-harness/vite-app/stubs/next-image.tsx +29 -0
  104. package/templates/previewBridge.ts +153 -0
  105. package/templates/survey-theme.css +295 -0
  106. package/templates/survey-ui-config.schema.json +213 -0
  107. package/templates/wizard-dist/assets/PreviewMock-DgHfrVeb.js +1 -0
  108. package/templates/wizard-dist/assets/TypePanel-CFVC3Ptn.js +1 -0
  109. package/templates/wizard-dist/assets/index-BhWM50Yu.css +1 -0
  110. package/templates/wizard-dist/assets/index-DYK3X1e5.js +34 -0
  111. package/templates/wizard-dist/assets/vendor-BwkXDkd3.js +17 -0
  112. package/templates/wizard-dist/index.html +20 -0
  113. package/templates/wizard.html +13 -1129
@@ -1,5 +1,5 @@
1
1
  {
2
- "docsSchemaVersion": "2.3.0",
2
+ "docsSchemaVersion": "2.6.0",
3
3
  "sdkTypesVersion": "0.2.1",
4
4
  "packageNames": {
5
5
  "npm": "@explorer02/cfm-survey-sdk",
@@ -13,8 +13,28 @@
13
13
  "clientInputs": [
14
14
  "initialPrompt",
15
15
  "instanceIdJwt",
16
+ "customizationWizardOptional",
16
17
  "deployConfirmation"
17
18
  ],
19
+ "surveyUiConfig": {
20
+ "artifact": "survey-ui-config.json",
21
+ "schema": "templates/survey-ui-config.schema.json",
22
+ "cliCommand": "npx cfm-sdk customize-ui",
23
+ "cliCommands": {
24
+ "aws": "npx cfm-sdk customize-ui",
25
+ "local": "npx cfm-sdk customize",
26
+ "exportPreviews": "npx cfm-sdk export-previews"
27
+ },
28
+ "wizardApiDoc": "00-integration/wizard-api.md",
29
+ "applyDoc": "00-integration/apply-ui-config.md",
30
+ "wizardDoc": "00-integration/ui-customization-wizard.md",
31
+ "previewBuildDoc": "00-integration/wizard-preview-build-guide.md",
32
+ "questionTypeStylingDoc": "00-integration/wizard-question-type-styling.md",
33
+ "agentExecutionFlowDoc": "00-integration/agent-execution-flow.md",
34
+ "agentOperatingContractDoc": "00-integration/agent-operating-contract.md",
35
+ "wizardConfigHandoffDoc": "00-integration/wizard-config-handoff.md",
36
+ "previewBridgeTemplate": "templates/previewBridge.ts"
37
+ },
18
38
  "hookContract": {
19
39
  "answersField": "state.answers",
20
40
  "customFieldValuesField": "options.customFieldValues",
@@ -44,6 +64,14 @@
44
64
  ]
45
65
  },
46
66
  "integrationDocs": [
67
+ {
68
+ "path": "00-integration/agent-operating-contract.md",
69
+ "purpose": "Anti-hallucination rules — read-before-write gates, doc routing, forbidden inventions (read FIRST)"
70
+ },
71
+ {
72
+ "path": "00-integration/agent-execution-flow.md",
73
+ "purpose": "Authoritative agent pipeline — client questions, phase order, wizard-ready build (read with index.md)"
74
+ },
47
75
  {
48
76
  "path": "00-integration/client-integration-guide.md",
49
77
  "purpose": "Master wiring map — start here for full client integration"
@@ -107,14 +135,75 @@
107
135
  {
108
136
  "path": "00-integration/survey-lifecycle-analytics.md",
109
137
  "purpose": "Mark-as-started and question activity"
138
+ },
139
+ {
140
+ "path": "00-integration/logic-fields-catalog.md",
141
+ "purpose": "Logic field reference by question type for skip/display/answer/end"
142
+ },
143
+ {
144
+ "path": "00-integration/analytics-events-catalog.md",
145
+ "purpose": "Consolidated SDK analytics and client lifecycle events"
146
+ },
147
+ {
148
+ "path": "00-integration/file-upload-aws.md",
149
+ "purpose": "Presigned S3 upload flow for FILE_UPLOAD submit contract"
150
+ },
151
+ {
152
+ "path": "00-integration/canonical-survey-fixtures.md",
153
+ "purpose": "Page-by-page UI expectations — matrix labels, slider header, template copy list"
154
+ },
155
+ {
156
+ "path": "00-integration/client-lib-folder.md",
157
+ "purpose": "src/lib layout — customFieldValues + surveyUi portable templates"
158
+ },
159
+ {
160
+ "path": "00-integration/wizard-preview-build-guide.md",
161
+ "purpose": "Build client components for wizard live preview — --cfm-* vars and data-cfm-* hooks (Phase 5)"
162
+ },
163
+ {
164
+ "path": "00-integration/wizard-question-type-styling.md",
165
+ "purpose": "Per-type wizard styling — selection colors, label items, all 11 question types (Phase 5)"
166
+ },
167
+ {
168
+ "path": "00-integration/wizard-config-handoff.md",
169
+ "purpose": "Wait for client submit, review artifacts (.final.json, .diff.md), confirm-ui-config order (Phase 6b→6c)"
170
+ },
171
+ {
172
+ "path": "00-integration/ui-customization-wizard.md",
173
+ "purpose": "Optional web wizard flow, CLI commands, wizard steps"
174
+ },
175
+ {
176
+ "path": "00-integration/apply-ui-config.md",
177
+ "purpose": "Apply survey-ui-config.json tokens after wizard (Phase 6c)"
178
+ },
179
+ {
180
+ "path": "00-integration/wizard-api.md",
181
+ "purpose": "EC2 /wizard/* API for customize-ui and preview hosting"
110
182
  }
111
183
  ],
184
+ "templateScaleFiles": [
185
+ "templates/RankOrderScale.tsx",
186
+ "templates/MatrixDropdown.tsx",
187
+ "templates/CustomSliderTrack.tsx",
188
+ "templates/surveyUiIcons.tsx",
189
+ "templates/surveyUiScaleUtils.ts",
190
+ "templates/SliderMatrixScale.tsx",
191
+ "templates/RatingScale.tsx",
192
+ "templates/LikertMatrixScale.tsx",
193
+ "templates/CsatMatrixScale.tsx",
194
+ "templates/HeatmapScale.tsx",
195
+ "templates/FileUploadScale.tsx",
196
+ "templates/heatmapCoords.ts",
197
+ "templates/customFieldValues.ts"
198
+ ],
112
199
  "deployTargets": {
113
200
  "aws": {
114
201
  "doc": "00-integration/aws-deploy.md",
115
202
  "script": "templates/deploy-to-aws.sh",
116
203
  "apiBaseEnv": "CFM_DEPLOY_API_BASE",
117
204
  "apiBaseDefault": "http://43.204.26.213:3000",
205
+ "wizardClientUrlPattern": "{CFM_DEPLOY_API_BASE}/wizard-app/index.html?session={sessionId}&secret={sessionSecret}",
206
+ "wizardClientUrlNote": "Printed by customize-ui after component previews upload to S3 — agent copies link and sends to client",
118
207
  "instanceIdEnv": "CFM_INSTANCE_ID",
119
208
  "outDirEnv": "OUT_DIR",
120
209
  "healthPath": "/health",
@@ -171,7 +260,10 @@
171
260
  "name": "orient",
172
261
  "read": [
173
262
  "index.md",
174
- "../AGENT.md"
263
+ "../AGENT.md",
264
+ "00-integration/agent-operating-contract.md",
265
+ "00-integration/agent-execution-flow.md",
266
+ "MANIFEST.json"
175
267
  ],
176
268
  "actions": [
177
269
  "detectFramework",
@@ -210,21 +302,30 @@
210
302
  "00-integration/display-logic-and-navigation.md",
211
303
  "00-integration/answer-logic-and-navigation.md",
212
304
  "00-integration/custom-field-logic-and-navigation.md",
305
+ "00-integration/client-lib-folder.md",
213
306
  "00-integration/question-display-variants.md",
214
307
  "00-integration/question-numbering.md",
215
308
  "00-integration/placeholders-and-tokens.md",
216
309
  "00-integration/partial-save-and-recovery.md",
217
310
  "00-integration/survey-lifecycle-analytics.md",
218
311
  "00-integration/end-page-logic.md",
219
- "00-integration/progress.md"
312
+ "00-integration/progress.md",
313
+ "00-integration/logic-fields-catalog.md",
314
+ "00-integration/analytics-events-catalog.md"
220
315
  ]
221
316
  },
222
317
  {
223
318
  "id": 4,
224
319
  "name": "planAndIngest",
225
320
  "readAlways": [
321
+ "00-integration/agent-operating-contract.md",
322
+ "00-integration/agent-execution-flow.md",
226
323
  "00-integration/component-checklist.md",
324
+ "00-integration/canonical-survey-fixtures.md",
325
+ "00-integration/client-lib-folder.md",
326
+ "00-integration/custom-field-logic-and-navigation.md",
227
327
  "00-integration/question-type-sdk-matrix.md",
328
+ "00-integration/logic-fields-catalog.md",
228
329
  "03-ui-specs/00-question-shell.md",
229
330
  "03-ui-specs/12-survey-chrome.md",
230
331
  "01-components/01-survey-page.md",
@@ -244,7 +345,12 @@
244
345
  "id": 5,
245
346
  "name": "build",
246
347
  "read": [
348
+ "00-integration/agent-operating-contract.md",
349
+ "00-integration/agent-execution-flow.md",
247
350
  "00-integration/constraints.md",
351
+ "00-integration/component-checklist.md",
352
+ "00-integration/wizard-preview-build-guide.md",
353
+ "00-integration/wizard-question-type-styling.md",
248
354
  "02-reference/routing-table.md"
249
355
  ],
250
356
  "onDemand": "02-reference/question-types"
@@ -253,7 +359,10 @@
253
359
  "id": 6,
254
360
  "name": "verify",
255
361
  "read": [
256
- "00-integration/constraints.md"
362
+ "00-integration/agent-operating-contract.md",
363
+ "00-integration/agent-execution-flow.md",
364
+ "00-integration/constraints.md",
365
+ "00-integration/component-checklist.md"
257
366
  ],
258
367
  "script": "templates/verify-agent-build.sh",
259
368
  "checklist": [
@@ -271,7 +380,78 @@
271
380
  "npmRunBuildPasses",
272
381
  "nextStaticExportConfigured",
273
382
  "outIndexHtmlExists",
274
- "outFileCountUnder500"
383
+ "outFileCountUnder500",
384
+ "rankOrderScaleTemplateCopied",
385
+ "sliderMatrixScaleTemplateCopied",
386
+ "ratingScaleTemplateCopied",
387
+ "matrixScaleTemplatesCopied",
388
+ "heatmapScaleTemplateCopied",
389
+ "dndKitWhenRankOrder",
390
+ "fileUploadPresignedFlowWhenFileUpload",
391
+ "surveyThemeCssPresent",
392
+ "selectionStylesCopied",
393
+ "labelStylesCopied",
394
+ "chromeDataCfmHooksPresent",
395
+ "draftSurveyUiConfigPresent"
396
+ ],
397
+ "postVerify": [
398
+ "startDevServer",
399
+ "askCustomizationWizard"
400
+ ]
401
+ },
402
+ {
403
+ "id": "6b",
404
+ "name": "optionalUiCustomization",
405
+ "optional": true,
406
+ "requiresClientConfirmation": true,
407
+ "read": [
408
+ "00-integration/wizard-config-handoff.md",
409
+ "00-integration/ui-customization-wizard.md",
410
+ "00-integration/wizard-preview-build-guide.md",
411
+ "00-integration/wizard-question-type-styling.md",
412
+ "00-integration/wizard-api.md"
413
+ ],
414
+ "cliCommand": "npx cfm-sdk customize-ui",
415
+ "cliCommandLocal": "npx cfm-sdk customize",
416
+ "cliConfirmCommand": "npx cfm-sdk confirm-ui-config",
417
+ "output": "survey-ui-config.final.json",
418
+ "outputArtifacts": [
419
+ "survey-ui-config.seed.json",
420
+ "survey-ui-config.final.json",
421
+ "survey-ui-config.diff.json",
422
+ "survey-ui-config.diff.md"
423
+ ],
424
+ "agentMustWait": true,
425
+ "waitUntil": "cliExit0ConfigurationReady",
426
+ "clientHandoff": "shareDeployedWizardUrlAfterS3Upload",
427
+ "prerequisites": [
428
+ "phase6VerifyPassed",
429
+ "devServerRunning"
430
+ ]
431
+ },
432
+ {
433
+ "id": "6c",
434
+ "name": "applyUiConfig",
435
+ "optional": true,
436
+ "when": "wizardUsedOrSurveyUiConfigExists",
437
+ "read": [
438
+ "00-integration/wizard-config-handoff.md",
439
+ "00-integration/apply-ui-config.md",
440
+ "00-integration/wizard-preview-build-guide.md",
441
+ "00-integration/wizard-question-type-styling.md"
442
+ ],
443
+ "inputFile": "survey-ui-config.final.json",
444
+ "inputFileLocal": "survey-ui-config.json",
445
+ "actions": [
446
+ "readDiffMdCompletely",
447
+ "validateAgainstSchema",
448
+ "regenerateSurveyThemeCssFromFinal",
449
+ "applyDataCfmContentHooks",
450
+ "applyLayoutToggles",
451
+ "applyQuestionTypesTokens",
452
+ "runConfirmUiConfigAws",
453
+ "crossCheckEveryDiffPath",
454
+ "reRunVerify"
275
455
  ]
276
456
  },
277
457
  {
@@ -280,7 +460,8 @@
280
460
  "requiresClientConfirmation": true,
281
461
  "selectTargetFromPrompt": {
282
462
  "awsKeywords": ["aws", "cloudfront", "s3", "ec2", "sprinklr"],
283
- "default": "vercel"
463
+ "default": "vercel",
464
+ "fallbackFromConfig": "survey-ui-config.json deploy.target"
284
465
  },
285
466
  "targets": {
286
467
  "aws": {
@@ -4,172 +4,172 @@
4
4
 
5
5
  Master guide for AI coding agents. Machine-readable index: `MANIFEST.json`.
6
6
 
7
+ **Authoritative execution order:** [`00-integration/agent-operating-contract.md`](00-integration/agent-operating-contract.md) (read **first**) → [`agent-execution-flow.md`](00-integration/agent-execution-flow.md) → this file.
8
+
7
9
  **Installed package path:** `node_modules/@explorer02/cfm-survey-sdk/templates/docs/` (docs ship inside `templates/` — no postinstall copy needed).
8
10
 
11
+ ## Anti-hallucination (agents)
12
+
13
+ Client-side coding agents **must not guess** SDK behavior. Before any code:
14
+
15
+ 1. Read [`agent-operating-contract.md`](00-integration/agent-operating-contract.md) — source hierarchy, phase gates, hallucination blocklist, doc routing table
16
+ 2. Read [`agent-execution-flow.md`](00-integration/agent-execution-flow.md) — pipeline and client questions
17
+ 3. For each fetched `question.type`, read MANIFEST `blueprint` + `reference` + `uiSpec` **before** implementing that type
18
+ 4. Copy from `docs/templates/` — do not rewrite dispatchers or scales from memory
19
+ 5. Run `verify-agent-build.sh` before claiming the build is done
20
+
21
+ **Prime directive:** If it is not in these docs or templates, do not implement it.
22
+
9
23
  ## Documentation Layout
10
24
 
11
25
  ```
12
- templates/docs/ ← installed npm package layout
13
- packages/sdk/templates/docs/monorepo layout
14
- ├── index.mdYOU ARE HERE
15
- ├── MANIFEST.json ← Phase + question-type routing (for tooling)
16
- ├── 00-integration/ Setup, hook contract, constraints
17
- ├── 01-components/ Wiring blueprints (read per type from MANIFEST)
18
- ├── 02-reference/ ← Routing table, exports, config-field-index
19
- ├── 03-ui-specs/ ← Authoritative UI specs
26
+ templates/docs/
27
+ ├── index.md YOU ARE HERE
28
+ ├── MANIFEST.jsonPhase + question-type routing
29
+ ├── 00-integration/
30
+ ├── agent-operating-contract.md Anti-hallucination read FIRST
31
+ ├── agent-execution-flow.md Pipeline, client questions, wizard-ready build
32
+ ├── wizard-preview-build-guide.md
33
+ ├── wizard-question-type-styling.md
34
+ │ └── …
35
+ ├── 01-components/ ← Wiring blueprints (per type from MANIFEST)
36
+ ├── 02-reference/ ← Data shapes, routing, config fields
37
+ ├── 03-ui-specs/ ← UI anatomy + wizard token sections
20
38
  └── templates/
21
- ├── implementation_plan.md
22
- ├── survey-inventory.schema.json
23
- ├── verify-agent-build.sh
24
- ├── deploy-to-aws.sh
25
- ├── heatmapCoords.ts
26
- └── Question.tsx ← Canonical dispatcher (copy before building)
39
+ ├── Question.tsx ← Canonical dispatcher (copy first)
40
+ ├── selectionStyles.ts ← Wizard selection colors (copy to src/lib/surveyUi/)
41
+ ├── labelStyles.ts ← Matrix/slider label items
42
+ ├── survey-theme.css ← Full --cfm-* defaults
43
+ └── implementation_plan.md
27
44
  ```
28
45
 
29
- **Import rule:** Use whatever package name appears in the project's `package.json` (`@explorer02/cfm-survey-sdk` or `@repo/sdk`).
46
+ **Import rule:** Use whatever package name appears in `package.json` (`@explorer02/cfm-survey-sdk` or `@repo/sdk`).
30
47
 
31
48
  ## Do Not Read
32
49
 
33
50
  - Internal SDK mapper/source paths (`packages/sdk/src/**` or `node_modules/.../src/**`)
34
- - `cfm-sdk init`, `survey-config.json`, or any setup wizard
35
- - Stale `apps/client` code without verifying type literals against `MANIFEST.json` `typeLiterals`
51
+ - Legacy `survey-config.json` or pre-build setup wizard
52
+ - `apps/client` as implementation source it is a reference snapshot only; agents build from `docs/templates/` + these docs
36
53
 
37
54
  ---
38
55
 
39
- ## Client Inputs (3 only)
56
+ ## Client inputs (4) — when to ask
40
57
 
41
- 1. **Initial prompt** mockup, brand colors, layout preferences
42
- 2. **Instance ID** — JWT token (agent asks in chat)
43
- 3. **Deploy confirmation**yes/no for production deploy
58
+ | # | Phase | Agent question | Doc |
59
+ |---|-------|----------------|-----|
60
+ | 1 | Start | *(Client prompt usually provided)* | Extract branding → `implementation_plan.md` |
61
+ | 2 | Phase 2 | *"Please provide your survey instance ID (JWT token)."* | `useSurveySDK.md` |
62
+ | 3 | Phase 6 | *"Your survey is running locally. Would you like to customize the UI through the web wizard?"* | `ui-customization-wizard.md` |
63
+ | 4 | Phase 7 | *"Your survey is built and verified. Ready to deploy to production?"* | `aws-deploy.md` / deploy CLI |
44
64
 
45
- **Branding comes from INPUT 1 only.** No setup wizard. No `survey-config.json`.
65
+ **Branding defaults from INPUT 1.** Wizard (INPUT 3) is optional — but Phase 5 build must still be **wizard-ready**.
46
66
 
47
67
  ---
48
68
 
49
- ## Execution Pipeline
50
-
51
- ### PHASE 0: ORIENT
69
+ ## Execution pipeline (summary)
52
70
 
53
- - Read this file and `AGENT.md`:
54
- - **Monorepo:** `packages/sdk/templates/AGENT.md`
55
- - **Installed npm:** `node_modules/@explorer02/cfm-survey-sdk/templates/AGENT.md`
56
- - Detect framework: read `package.json` — Next.js / Vite / CRA (see `00-integration/setup.md`)
57
- - Extract branding and layout from client prompt
58
- - For existing apps: read project structure; do not blindly scaffold
71
+ Full step-by-step: [`agent-execution-flow.md`](00-integration/agent-execution-flow.md).
59
72
 
60
- ### PHASE 1: SCAFFOLD
73
+ | Phase | Goal | Key reads |
74
+ |-------|------|-----------|
75
+ | **0** Orient | Framework + branding | `index.md`, `AGENT.md`, `agent-execution-flow.md`, `MANIFEST.json` |
76
+ | **1** Scaffold | Install SDK | `setup.md` |
77
+ | **2** Instance ID | Get JWT | `useSurveySDK.md` — **ask client** |
78
+ | **3** SDK contract | Hook + logic | `client-integration-guide.md`, `question-type-sdk-matrix.md`, logic docs |
79
+ | **4** Plan | Inventory + copy dispatcher | `component-checklist.md`, per-type MANIFEST docs, `implementation_plan.md` |
80
+ | **5** Build | Wizard-ready UI | `constraints.md`, `wizard-preview-build-guide.md`, `wizard-question-type-styling.md`, `03-ui-specs/*` |
81
+ | **6** Verify | Build + dev server | `verify-agent-build.sh` — **ask wizard** |
82
+ | **6b** Wizard | Optional customize | `customize-ui` — only if client said yes |
83
+ | **6c** Apply | Sync final config | `apply-ui-config.md` |
84
+ | **7** Deploy | Production | **ask deploy** — `aws-deploy.md` or Vercel |
61
85
 
62
- Read: `00-integration/setup.md` (matching framework section)
86
+ **Auto-proceed:** Phase 4 → 5 and Phase 5 → 6 without waiting for approval.
63
87
 
64
- Install SDK + `@tanstack/react-query` + `react-icons`. Apply framework-specific config.
65
-
66
- ### PHASE 2: INSTANCE ID (INPUT 2)
88
+ ---
67
89
 
68
- Read: `00-integration/useSurveySDK.md`
90
+ ### PHASE 5 — Build (wizard-ready, required artifacts)
69
91
 
70
- Ask: *"Please provide your survey instance ID (JWT token)."*
92
+ Every agent build includes these even if the client later skips the wizard:
71
93
 
72
- ### PHASE 3: SDK CONTRACT
94
+ | Artifact | Source | Destination |
95
+ |----------|--------|-------------|
96
+ | Theme CSS | `templates/survey-theme.css` | `src/styles/survey-theme.css` |
97
+ | Selection helpers | `templates/selectionStyles.ts` | `src/lib/surveyUi/selectionStyles.ts` |
98
+ | Label helpers | `templates/labelStyles.ts` | `src/lib/surveyUi/labelStyles.ts` |
99
+ | Preview bridge | `templates/previewBridge.ts` | `src/lib/previewBridge.ts` |
100
+ | Dispatcher | `templates/Question.tsx` | `src/components/Question.tsx` |
101
+ | Scale components | `templates/*Scale*.tsx` etc. | `src/components/` per inventory |
102
+ | Draft config | agent-written | `./survey-ui-config.json` |
73
103
 
74
- Read: `00-integration/client-integration-guide.md` (start here), `00-integration/question-type-sdk-matrix.md`, `00-integration/useSurveySDK.md`, `02-reference/exports.md`, `00-integration/skip-logic-and-navigation.md`, `00-integration/display-logic-and-navigation.md`, `00-integration/question-display-variants.md`, `00-integration/question-numbering.md`, `00-integration/placeholders-and-tokens.md`, `00-integration/partial-save-and-recovery.md`, `00-integration/survey-lifecycle-analytics.md`, `00-integration/end-page-logic.md`, `00-integration/answer-logic-and-navigation.md`, `00-integration/custom-field-logic-and-navigation.md`, `00-integration/progress.md`, `02-reference/value-derivation.md`
104
+ **Chrome:** `data-cfm-logo` / `data-cfm-logo-text`, `data-cfm-company`, `data-cfm-btn-next`, `data-cfm-btn-back`, `data-cfm-survey-title`, `data-cfm-thank-you` see `wizard-preview-build-guide.md`.
75
105
 
76
- Understand `useSurveySDK`, `onAction`, `state.answers`. Do **not** read internal mapper/source paths.
106
+ **Selection pattern:** focus ring = outer border + inner dot; cell selected = annulus fill — see `wizard-question-type-styling.md`.
77
107
 
78
- Optional: read `02-reference/routing-table.md` for type overview.
108
+ **Forbidden:** stub branches, `subType` routing, changing `onAction` payloads, hardcoded hex for wizard-controlled tokens.
79
109
 
80
- ### PHASE 4: PLAN + INGEST (CRITICAL)
110
+ Copy scale templates: `SliderMatrixScale`, `LikertMatrixScale`, `CsatMatrixScale`, `RatingScale`, `FileUploadScale`, `HeatmapScale`, `RankOrderScale`, `MatrixDropdown`, `CustomSliderTrack`, `surveyUiIcons`, `surveyUiScaleUtils`, `heatmapCoords`, `customFieldValues` (when needed).
81
111
 
82
- 1. Fetch survey with `instanceId`; extract unique `question.type` values from `survey.pages`
83
- 2. Write inventory to `implementation_plan.md` §3b (validate against `templates/survey-inventory.schema.json`)
84
- 3. Read **always**: `component-checklist.md`, `00-integration/question-type-sdk-matrix.md`, `03-ui-specs/00-question-shell.md`, `03-ui-specs/12-survey-chrome.md`, `01-components/01-survey-page.md`, `01-components/02-question.md`, `01-components/14-intro-page.md`, `01-components/15-end-page.md`, `01-components/16-paused-page.md`
85
- 4. For **each type in the survey**, read MANIFEST `questionTypes.{type}` → blueprint + reference + uiSpec; cross-check the matching row in `question-type-sdk-matrix.md`
86
- 5. When config flags match MANIFEST `sharedUiSpecTriggers` (e.g. `gridLayout:dropdown`, `displayStyle:graphics`) → read matching `03-ui-specs/shared/` specs
87
- 6. Copy `docs/templates/implementation_plan.md` → `./implementation_plan.md` and fill every section
88
- 7. Copy `docs/templates/Question.tsx` as the dispatcher starting point
89
- 8. **Auto-proceed to Phase 5** — do not wait for approval
112
+ ---
90
113
 
91
- **Fallback:** If survey fetch fails, read all `01-components/*.md` blueprints before coding.
114
+ ### PHASE 6 Verify checklist
92
115
 
93
- ### PHASE 5: BUILD
116
+ - [ ] `Question.tsx` covers all **11** `question.type` values (flat literals)
117
+ - [ ] Zero `"not yet implemented"` matches
118
+ - [ ] `src/styles/survey-theme.css` + `selectionStyles.ts` + `labelStyles.ts` present
119
+ - [ ] Chrome `data-cfm-*` hooks on Header, SurveyPage, Intro/End
120
+ - [ ] `npm run build` exits 0
121
+ - [ ] Dev server loads survey
122
+ - [ ] AWS: `out/index.html` exists; file count ≤ 500
94
123
 
95
- Read: `00-integration/constraints.md`, `00-integration/component-checklist.md`, `00-integration/question-type-sdk-matrix.md`
124
+ Run: `bash templates/verify-agent-build.sh`
96
125
 
97
- Create all required scale component files **before** wiring `Question.tsx`. For each question in the survey:
126
+ ---
98
127
 
99
- 1. Read the matching row in `question-type-sdk-matrix.md` (answer shape, visibility helper, performance)
100
- 2. Read `02-reference/question-types/` doc for data shape (MANIFEST `reference`)
101
- 2. Read matching `03-ui-specs/` (MANIFEST `uiSpec`)
102
- 3. If `gridLayout`, `displayStyle`, or `statementLayout` triggers shared specs → read `03-ui-specs/shared/`
103
- 4. Cross-check `02-reference/config-field-index.md` for every non-default field
104
- 5. Implement per ui-spec — trust SDK Integration Checklist in blueprint/reference + `templates/Question.tsx` + exported SDK types + `02-reference/value-derivation.md`
128
+ ### PHASE 6b / 6c Wizard (wait apply every change)
105
129
 
106
- Implement components per blueprints + UI specs. Use exported types:
130
+ Only after Phase 6 passes and client says **yes**:
107
131
 
108
- ```typescript
109
- import { useSurveySDK, ACTIONS, QUESTION_TYPE, type SurveyAction } from '@explorer02/cfm-survey-sdk';
132
+ ```bash
133
+ export CFM_INSTANCE_ID="<JWT>"
134
+ export CFM_DEPLOY_API_BASE="http://43.204.26.213:3000"
135
+ npx cfm-sdk customize-ui # uploads previews → prints client link → WAITS until submit
110
136
  ```
111
137
 
112
- **Dispatch on flat `question.type` only** **11** `QUESTION_TYPE` literals, no `subType`. See `MANIFEST.json` `typeLiterals`.
113
-
114
- **AWS deploy prep (when client prompt mentions AWS / CloudFront / S3 / EC2 / Sprinklr):** apply Next.js static export config **during this phase**, not at deploy time. Read `00-integration/setup.md#nextjs-aws-static-export` and `00-integration/aws-deploy.md` § Build Config. Fill `implementation_plan.md` §8.
115
-
116
- ### PHASE 6: VERIFY
117
-
118
- Read: `00-integration/constraints.md` (troubleshooting)
138
+ **Phase 6b:** CLI uploads component previews to S3, prints deployed wizard link for the client, polls until `Configuration ready`. Read `survey-ui-config.diff.md`. Do **not** apply yet.
119
139
 
120
- Run: `bash templates/verify-agent-build.sh` (from project root, after copying script if needed)
121
-
122
- Checklist:
123
-
124
- - [ ] `Question.tsx` copied from `docs/templates/Question.tsx` — covers all **11** `question.type` values
125
- - [ ] Each matrix variant routes by its own type literal (`CFM_MATRIX`, `CSAT_MATRIX`, `RATING_MATRIX`) — **no `subType`**
126
- - [ ] All scale components from `component-checklist.md` exist for types in survey
127
- - [ ] **Zero stub text:** `grep -r "not yet implemented" src/ components/ app/` returns no matches
128
- - [ ] Every question wrapper has `id={question.id}`
129
- - [ ] No imports from `@explorer02/cfm-survey-sdk/src/...` or `@repo/sdk/src/...`
130
- - [ ] `SurveyPage` handles loading / error / empty / all `state.phase` values / active content
131
- - [ ] Hook uses `state.answers`, `state.canGoBack`, `state.primaryButtonType`, and `payload.answerValue`
132
- - [ ] Stable `customFieldValues` ref when survey uses custom-field logic; passed to hook and `Question` visibility helpers
133
- - [ ] `SURVEY_PLACEHOLDERS` stable ref; `surveyOptions` in `useMemo` (see `placeholders-and-tokens.md`)
134
- - [ ] `SCROLL` + `RECORD_QUESTION_VIEW` lifecycle effects wired (see `survey-lifecycle-analytics.md`)
135
- - [ ] Monorepo: `packages/sdk` built before client dev (`npm run build`)
136
- - [ ] `npm run build` exits 0
137
- - [ ] **AWS intent:** `out/index.html` exists; file count ≤ 500; Next.js static export configured (`output: export`, `assetPrefix: "./"`)
138
-
139
- ### PHASE 7: DEPLOY (INPUT 3)
140
-
141
- Ask: *"Your survey is built and verified. Ready to deploy?"*
142
-
143
- **Route by client prompt** (see MANIFEST `deployTargets` and `phases[7].selectTargetFromPrompt`):
144
-
145
- | Prompt mentions | Target | Action |
146
- |-----------------|--------|--------|
147
- | AWS, CloudFront, S3, EC2, Sprinklr | **AWS** | Read `00-integration/aws-deploy.md`; set env vars; run 3-channel deploy or `bash templates/deploy-to-aws.sh` |
148
- | Vercel or unspecified (default) | **Vercel** | `npx cfm-sdk deploy` (requires `VERCEL_TOKEN` or Vercel CLI) |
149
-
150
- **AWS env vars (dev machine):**
140
+ **Phase 6c:** Apply from `survey-ui-config.final.json` per [`wizard-config-handoff.md`](00-integration/wizard-config-handoff.md) + [`apply-ui-config.md`](00-integration/apply-ui-config.md) **every** diff path. Then:
151
141
 
152
142
  ```bash
153
- export CFM_INSTANCE_ID="<same JWT as SurveyPage>"
154
- export CFM_DEPLOY_API_BASE="http://43.204.26.213:3000"
155
- export OUT_DIR="<absolute path to out/ or dist/>"
143
+ npx cfm-sdk confirm-ui-config
156
144
  ```
157
145
 
158
- **AWS success:** print live CloudFront HTTPS URL from `/deploy/complete`; ask client to open in browser.
159
-
160
- **Vercel success:** CLI prints production URL.
146
+ Re-run verify script + build.
161
147
 
162
148
  ---
163
149
 
164
- ## Progressive Reading Guide
150
+ ## Progressive reading guide
165
151
 
166
152
  | When | Read |
167
153
  |------|------|
168
- | Always first | `index.md`, `00-integration/client-integration-guide.md`, `00-integration/question-type-sdk-matrix.md`, `00-integration/setup.md`, `00-integration/useSurveySDK.md`, `00-integration/constraints.md` |
169
- | Lifecycle & placeholders | `00-integration/survey-lifecycle-analytics.md`, `00-integration/placeholders-and-tokens.md`, `00-integration/partial-save-and-recovery.md` |
170
- | Skip logic & progress | `00-integration/skip-logic-and-navigation.md`, `00-integration/display-logic-and-navigation.md`, `00-integration/question-display-variants.md`, `00-integration/question-numbering.md`, `00-integration/end-page-logic.md`, `00-integration/answer-logic-and-navigation.md`, `00-integration/custom-field-logic-and-navigation.md`, `00-integration/progress.md` |
171
- | Before any React code | `component-checklist.md`, `templates/Question.tsx`, MANIFEST `readAlways` docs |
172
- | After instanceId fetch | Per-type docs from MANIFEST `questionTypes` (blocking: `CFM_MATRIX`, `CSAT_MATRIX`, `RATING_MATRIX`, `SLIDER_MATRIX`, `FILE_UPLOAD`) |
154
+ | **Always first** | `agent-operating-contract.md`, `agent-execution-flow.md`, `index.md`, `client-integration-guide.md`, `constraints.md` |
155
+ | Phase 3 contract | `question-type-sdk-matrix.md`, `useSurveySDK.md`, logic/navigation docs |
156
+ | Before React code | `component-checklist.md`, `templates/Question.tsx`, per-type `03-ui-specs/*` |
157
+ | Wizard build | `wizard-preview-build-guide.md`, `wizard-question-type-styling.md` |
158
+ | Wizard run | `wizard-config-handoff.md`, `ui-customization-wizard.md`, `wizard-api.md` |
159
+ | After wizard (apply all paths) | `apply-ui-config.md` |
160
+ | Deploy | `aws-deploy.md`, `setup.md#nextjs-aws-static-export` |
173
161
  | Config audit | `02-reference/config-field-index.md` |
174
- | AWS deploy | `00-integration/aws-deploy.md`, `setup.md#nextjs-aws-static-export`, `templates/deploy-to-aws.sh` |
175
- | Tooling | `MANIFEST.json`, `templates/implementation_plan.md`, `templates/survey-inventory.schema.json` |
162
+
163
+ ---
164
+
165
+ ## Wizard styling (all types)
166
+
167
+ | Token | Variable | Applies to |
168
+ |-------|----------|------------|
169
+ | Cell selected | `--cfm-matrix-selected` | Radio annulus; numbered/star cell fill |
170
+ | Focus ring | `--cfm-input-focus-ring` | Radio outer border + inner dot |
171
+ | Label items | `--cfm-*-column-label-*` | Matrix column headers (not hint labels on CFM) |
172
+ | Hint labels | `--cfm-hint-label-*` | NPS min/max anchors |
173
+ | Number labels | `--cfm-number-*` | Traffic-light badges (unselected only) |
174
+
175
+ Full per-type table: [`wizard-question-type-styling.md`](00-integration/wizard-question-type-styling.md).